SoYoung210 / soso-tip

🍯소소한 팁들과 정리, 버그 해결기를 모아두는 레포
24 stars 0 forks source link

TypeScript Triple Slash Directive #47

Open SoYoung210 opened 4 years ago

SoYoung210 commented 4 years ago

filename

/// <reference path='./HelloComponent.ts' />
/// <reference path='./ByeComponent.ts' />
export * from '@src/OtherComponent';

이렇게 되어 있을 때, index.d.ts는 아래와 같이 출력된다.

/// <reference type="hellocomponent" />
/// <reference path="byecomponent" />
export * from "./OtherComponent";

referecne path에 들어간 이름이 lowercase로 바뀌는 것인데, TypeScript의 Use lowercase names for type reference directives PR때문이 아닌가.. 싶다..

+ /// <reference path='./hello-component.ts' />
- /// <reference path='./HelloComponent..ts' />

로 써줬다..

relative path not working

/// <reference path='./hello-component.ts' />

이렇게 써줘도 ./가 생략되어버린다. 혹은 다른 paths로 들어가거나.. 상대경로로 참조할 수 없다.

TypeScript issue를 보고 추측한 내용을 바탕으로 tsconfig.json을 일부 수정했다.

"baseUrl": "./",
"paths": {
    "@some/*": ["src/some/*"],
    "./*": ["./*"],
    "@root/*": ["./*"],
}

./을 그대로 ./으로 치환하라는 뜻이다 (.......)