Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created July 14, 2020 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/151072514f64e5880fab9dd24c21d819 to your computer and use it in GitHub Desktop.
Save whoisryosuke/151072514f64e5880fab9dd24c21d819 to your computer and use it in GitHub Desktop.
Typescript - HTMLTextAreaElement or HTMLInputElement instead of HTMLElement -- @see: https://stackoverflow.com/a/33460539
// ⛔️ Don't do this
const textbox: HTMLTextAreaElement = document.getElementById("theme");
// You'll get following error:
// Type 'HTMLElement' is missing the following properties from type 'HTMLTextAreaElement': autocomplete, cols, defaultValue, dirName, and 26 more.
// ✅ Do this
var controlCheckbox = <HTMLTextAreaElement>document.getElementById("mainTextArea")
// Or for input elements
var controlCheckbox = <HTMLInputElement>document.getElementById("mainCheckbox")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment