1. tsconfig.json에 아래와 같은 설정
    {
    "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
     "paths": {
       "@/*": [
         "./*"
       ],
       "@test/*": [
         "test/*"
       ]
     }
    }
  2. tsconfig-paths 필요
    npm i tsconfig-paths

A & B extends C 인경우

A & (B extends C)가 아니라

(A & B) extends C가 된다

 

extends를 쓸 때는 우선 순위를 항상 조심하자

 

변수에 할당되어있는 string은 literal로 인식하지 못한다.

literal로 인식하게 하려면 캐스팅을 해줘야 한다.

이건 enum도 마찬가지이다

 

sinon 7.3.2

typescript 3.1 기본 내장

import {spy} form "sinon" 조차 안된다.

 

styled-component

generic 설정때문에 typescript 2.7.2 에서는 아무래도 쓰기 매우 어려워 보인다.

@types를 제거하면 props를 전혀 넘길 수가 없다.

typescript 2.7.2

일반적인 function call또는 declaration 이 아닌 경우 generic 인식을 잘 못한다.

taged template literal 호출시 generic 인식을 못한다.

 

production typescript version이 2.7.2인데

로컬버전이 2.9.1인줄 전혀 모르고

styled-component신나게 쓰다가 빌드가 안되서 다 터져나갔다

아 내가 왜 타입스크리븥 버전을 올린건지 모르겠다

const foo = <T extends {}>(x: T): T => x


<>가 HTML태그가 아니라 제네릭이라는 힌트를 extends로 주면 된다.

https://stackoverflow.com/questions/37910669/what-is-the-difference-between-never-and-void-in-typescript


function expression 과  function declaration 에서 void 와 never의 차이

https://stackoverflow.com/questions/40251524/typescript-never-type-inference


never를 이용한 타입 안정성 예시

https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html

"Types_have_separate_declarations_of_a_private_property_0_2442": "형식에 별도의 전용 속성 '{0}' 선언이 있습니다.",


private 속성이 있으면 상속이 안된다


+ Recent posts