[typescript]advanced non null assertion

Wed Apr 16

typescript

Author:Noritaka

Astro
const input3 = document.getElementById('input')!;
// You can get rid of null from input3's type as HTMLInputElement | null

// if (input3){
//   const input3 = document.getElementyId('input');
// })
input3.value = 'initial input value';
(document.getElementById(('input')) as HTMLInputElement).value = 'initial input value'

// You can get rid of null from input3's value as HTMLInputElement | null

typescript