✘✘✘ Javascript/Typescript3 Non-Null assertion:: exclamation mark (!) after variable. 변수 뒤 ! 느낌표 The exclamation mark (!) is the non-null assertion operator in TypeScript. It tells the compiler that we are sure that the value returned by document.getElementById('root') is not null or undefined. const dom = document.getElementById('root')! // dom is not null 2023. 4. 8. [type] keyof, typeof 를 사용해 type 지정 예시 const keyToPropertyMap = { 'on-off': 'active', name: 'name', appliedTo: 'level', frequency: 'period', }; type SortInfo = { key?: keyof typeof keyToPropertyMap; // asc: boolean; }; 질문 keyof typeof keyToPropertyMap? 답변 type:: keyof typeof keyToPropertyMap = 'on-off' | 'name' | 'appliedTo' | 'frequencyÏ' 설명 이 예에서 keyof typeo.. 2023. 4. 8. Constructor overloading with default 변수 선언 후 생성자에서 할당 class Test { name: string; protected age: number; public id?: string; private password?: string; constructor(name = "", age = 0, id = undefined, password = undefined) { this.name = name; this.age = age; this.id = id; this.password = password; } }생성자에서 선언하고 변수 할당하기 => id, password class Test { name: string; protected age: number; constructor( name: string = "", age: number = 0, p.. 2022. 6. 25. 이전 1 다음