Created
July 14, 2020 22:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ⛔️ 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