장바구니에 상품이 없습니다.
home2 › 게시판 › JavaScript, TS 게시판 › typescript generic custom
interface lengthCheck { length : number } function 함수<MyType extends lengthCheck>(x: MyType) { return x.length } let a = 함수<string>('hello') //가능 제 머릿속에서는 type이 string === { length: number } 이렇게 그려지는데 어떻게 타입제한이 이루어지는지 모르겠습니다. 센세...
실은 문자자료 뒤에 .length할 수 있는데 그걸보면 문자도 실은 object자료형같군요