TypeScript: Errors
error TS2339: Property 'style' does not exist on type 'Element'.
error TS2339: Property 'style' does not exist on type 'Element'.
const x = document.querySelector("span.x42663").style;
change the above to
const x = (document.querySelector("span.x42663") as HTMLElement).style; // or const x = (<HTMLElement> document.querySelector("span.x42663")).style;
error TS2339: Property 'value' does not exist on type 'HTMLElement'
error TS2339: Property 'value' does not exist on type 'HTMLElement'.
solution.
change the line
document.getElementById("user_input_24066").value
to
(document.getElementById("user_input_24066") as HTMLInputElement).value // or (<HTMLInputElement> document.getElementById("user_input_24066")).value
TypeScript: Declare Library by Triple-Slash Directives
make TypeScript aware of libs.
/// <reference path="xah_keyboard_lib.ts" />
SVG Element Types
type of svg elements, such as circle
, is SVGElement
type of svg container, such as svg
, is SVGSVGElement
〔see SVG: Basic Examples〕
Declare Tuple
// declare a array as array of tuple, each element is a array of [string, number] type source_text_96834 = { [key: string]: Array<[string, number]> }