1// Cast to the type of `HTMLElement`
2const el = document.getElementById('whatever') as HTMLElement;
3el.style.paddingTop = ...;
4
5// Or, if it is an array
6const els = document.getElementsByClassName('my-class') as HTMLCollectionOf<HTMLElement>;
1document.getElementById() returns the type HTMLElement which does not contain a value property.
2The subtype HTMLInputElement does however contain the value property.
3
4So a solution is to cast the result of getElementById() to HTMLInputElement like this:
5
6var inputValue = (<HTMLInputElement>document.getElementById(elementId)).value;
7<> is the casting operator in typescript.
8See TypeScript: casting HTMLElement: https://fireflysemantics.medium.com/casting-htmlelement-to-htmltextareaelement-in-typescript-f047cde4b4c3
9
10The resulting javascript from the line above looks like this:
11
12inputValue = (document.getElementById(elementId)).value;
13i.e. containing no type information.