Type Assertions

This won’t work because Propery ‘value’ does not exist on type ‘HTMLElement’.

const input1 = document.getElementById('my-input-text');
console.log(input1.value);

Even adding a type annotation won’t work

const input1: HTMLInputElement = document.getElementById('my-input-text');
console.log(input1.value);

Nonetheless, applying a type assertion will work

const input1 = document.getElementById('my-input-text') as HTMLInputElement;
console.log(input1.value);