2020. 10. 2. 11:14, Developer
제한을 둔다
class Person<T extends string|number>{
private _name:T;
constructor(name:T){
this._name=name;
}
}
new Person('aa');
new Person(22);
'Developer' 카테고리의 다른 글
[typescript]Generic type 응용 (0) | 2020.10.02 |
---|---|
[typescript]Generic type - 2개이상 타입 (0) | 2020.10.02 |
[typescript]Generic class (0) | 2020.10.02 |
[typescript]Generic (0) | 2020.10.02 |
[typescript]class - readonly (0) | 2020.10.01 |
Comments, Trackbacks