타입스크립트 앰비언트 모듈
212
작성한 질문수 1
제가 @types/styled-components를 설치하고 src/@types/styled.d.ts 와 같은 앰비언트 모듈 파일도 만들었습니다. 제가 알기론 타입스크립트 컴파일러는 non-relative-path로 import 할 경우에 node_modules/@types를 먼저 뒤져보고 없으면 앰비언트 모듈 파일을 찾아보는걸로 알고 있는데 왜 App.tsx에서 참조하는건 src/@types/styled.d.ts 파일인지 알 수 있을 까요?? traceResolution 옵션을 줘서 컴파일 과정을 찾아봐도 node_modules/@types에 있는 styled-components/index.d.ts 파일을 찾아서 참조한다고 나와잇는데 영문을 모르겠습니다
//src/@types/styled.d.ts
declare module "styled-components" {
interface TestProps {
name: string
}
}
//src/App.tsx
import styled from "styled-components"
const test: styled.TestProps = { name: "123"}
function App() {
return <div>{test.name}</div>
}
export default App;
//tsconfig.json
{
"compilerOptions": {
"target": "es5",
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"noImplicitAny": false,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"noEmit": true,
"traceResolution": true
},
"include": [
"src"
]
}
======== Resolving type reference directive 'styled-components', containing file 'C:/Users/boh00/github/apollo-todolist/__inferred type names__.ts', root director
y 'C:/Users/boh00/github/apollo-todolist/node_modules/@types,C:/Users/boh00/node_modules/@types'. ========
Resolving with primary search path 'C:/Users/boh00/github/apollo-todolist/node_modules/@types, C:/Users/boh00/node_modules/@types'.
File 'C:/Users/boh00/github/apollo-todolist/node_modules/@types/styled-components/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references 'C:/Users/boh00/github/apollo-todolist/node_modules/@types/styled-components/index.d.ts'.
File 'C:/Users/boh00/github/apollo-todolist/node_modules/@types/styled-components/index.d.ts' exist - use it as a name resolution result.
Resolving real path for 'C:/Users/boh00/github/apollo-todolist/node_modules/@types/styled-components/index.d.ts', result 'C:/Users/boh00/github/apollo-todolist/no
de_modules/@types/styled-components/index.d.ts'.
======== Type reference directive 'styled-components' was successfully resolved to 'C:/Users/boh00/github/apollo-todolist/node_modules/@types/styled-components/in
dex.d.ts' with Package ID '@types/styled-components/index.d.ts@5.1.15', primary: true. ========
답변 0
리액트 강의관련해서 질문드립니다!
0
37
1
TS 진위값 관련 질문
1
368
1
선언된 인터페이스를 Map자료형의 타입으로 할당할 수 있는 방법이 있을까요..?
0
346
1
Map의 제네릭에 일반 인터페이스를 할당할 수 있나요?
1
364
1
char.js 3.대로 업그레이드 후 발견된 오류
0
459
1
git hub 관련 파일설치후 해당 파일이없음...
1
223
1
[#타입스크립트-노드버드] 해당 강좌를 타입스크립트 버전으로 작성하려고 하는데, 강의영상이랑 코드내용이 많이 차이 있을까요?
0
416
2
강의 처럼 안됩니다~!
1
490
3
제네릭 타입 제한 강의에서 질문드립니다.
3
400
1
타입 가드의 정의
2
343
1
타입추론에 대해서 궁금한점이 있습니다.
1
404
2
권한 허가 부탁드립니다.
1
201
1
완강하고 다음 코스에 대한 질문!
1
211
1
이건.. 강의대한 질문은 아니지만...
0
193
1
유니온 타입의 장점
5
233
1
안녕하세요! 타입스크립트 관련 질문있습니다. ㅎㅎ
0
311
2
프론트단에 질문이 있습니다
0
173
1





