*undefined와 null은 모든 타입의 서프타입이기 때문에, 어떤 타입으로 선언된 변수에도 들어갈 수 있다.


1
2
3
4
5
6
7
8
9
10
11
12
13
class Person{
    name:string = null;
    age: number = null;
    constructor(name:string) {
        this.name = name;
    }
    hello(): void{
        console.log('what the hell');
    }
}
const person = new Person('mark');
console.log(person);
 
cs








































'frameworks > typescript' 카테고리의 다른 글

[typescript]iterator  (0) 2018.12.11
[typescript]generic(+additional:string literal type)  (0) 2018.12.07
[typescript]class  (0) 2018.12.07
[typescript]interface  (0) 2018.12.06
[typescript]type assertion  (0) 2018.12.06

+ Recent posts