본문 바로가기

개발/TS

[TS] TS Doc Handbook 1회독 - 5

Generic Object Types

interface Obj<Type> {
  content: Type;
}
type Obj<Type> = {
  content: Type;
}

let strObj: Obj<string>;
let numObj: Obj<number>;

function genericFunc<Type>(obj: Obj<Type>, newContent: Type) {
  box.content = newContent;
}

 

제네릭 오브젝트 타입으로 Array, Map, Set, Promise 등이 있다.

 

ReadonlyArray type

const arr: ReadonlyArray<T>;
const arr: readonly T[];

 

Tuple type

optional tuple elements, rest elements

readonly tuple

 

참고

무료 사이트 모음 2021, 자라는 것을 잘하는 개발, 2025.02.06

https://www.typescriptlang.org/ko/docs/handbook/typescript-from-scratch.html, 2025.02.06

https://opentutorials.org/course/5080, 생활코딩, 2025.02.06

 

'개발 > TS' 카테고리의 다른 글

[TS] TS Doc Handbook 1회독 - 7  (0) 2025.06.17
[TS] TS Doc Handbook 1회독 - 6  (0) 2025.06.16
[TS] TS Doc Handbook 1회독 - 4  (0) 2025.03.04
[TS] TS Doc Handbook 1회독 - 3  (0) 2025.02.28
[TS] TS Doc Handbook 1회독 - 2  (0) 2025.02.26