// ./tsconfig.json
{
"compilerOptions": {
"typeRoots": ["./node_modules/@types", "./src/types"]
...
}
}
// ./src/types/index.d.ts
type Item = {
location: string;
time: string;
pm10: string;
pm25: string;
};
// ./node_modules/my-type/index.d.ts
type TestItem = {
location: string;
time: string;
pm10: string;
pm25: string;
};
// ./package.json
{
"scripts": {
"start": "nodemon src/index.ts"
},
}
// start시,
TSError: ⨯ Unable to compile TypeScript:
src/index.ts:38:24 - error TS2304: Cannot find name 'Item'.
const airItem: Item = {
location: location,
time: items.dataTime,
pm10: items.pm10Value,
pm25: items.pm25Value,
};
// start시 에러 발생 안하고 잘 실행
const airItem: TestItem = {
location: location,
time: items.dataTime,
pm10: items.pm10Value,
pm25: items.pm25Value,
};
express 맛보기 중인 데,
타입 내용물은 같음
1은 Item 타입은 ./src/types/index.d.ts에 했더니 에디터에서 에러는 안 뜨는 데 실행 시 빌드 에러 발생
2는 TestItem 타입은 ./node_modules/@types/my-type/index.d.ts에 만들어 둔 거는 실행도 잘 됨
근데 ts-node던 nodemon이던 이런 데 tsconfig 어캐 손 봐야 되나요 ㅜㅜ
잘 달래줘