Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- partitioning
- 개발자
- Partition
- PostgreSQL
- node.js란
- localStorage
- SSE
- ServerSentEvent
- node.js
- 실시간알림
- 성장기
- 파티셔닝
- 열공하자
- EventSource
- Lag
- mariadb
- Node.js기본
- frontend
Archives
- Today
- Total
써치킴의 우당탕탕 개발 블로그
[TypeScript][ch7][Generic] Generic with extends 본문
클래스 내부에서 사용하는 타입 T의 자료형을 제한한다.
// <T extends string | number> : T는 string | number인 union type만 가능
class PersonExtends<T extends string | number> {
private _name: T;
constructor(name: T){
this._name = name;
}
}
new PersonExtends('Searchkim');
new PersonExtends(123);
// new PersonExtends(boolean); // Error 발생: string, number타입이 아니기 때문에
- <T extends string | number>
- T는 string | number인 union type만 가능
'TypeScript 합시다' 카테고리의 다른 글
[TypeScript][ch7][Generic] Generic Class (0) | 2022.02.18 |
---|---|
[TypeScript][ch7][Generic] Generic Function (0) | 2022.02.18 |
[TypeScript][ch7][Generic] Generic Array & Tuple (0) | 2022.02.18 |
[TypeScript][ch7][Generic] Generic Basic (0) | 2022.02.18 |
[TypeScript][ch7][Generic] Generic, Any와 다른 점 (0) | 2022.02.18 |
Comments