我在tyepscript 3.3.3
中使用VS Code 1.30.2
。 tyepscript找不到位于src/@types
中的自定义类型定义文件。尽管据我所知,不需要在ts的最新版本中配置typeRoot
,但是我也这样做了,ts仍然找不到index.d.ts
文件。文件夹名称和模块名称匹配。
.
├── config.ts
├── node_modules
├── ormconfig.json
├── package.json
├── project_manager
├── src
├── tsconfig.json
├── tslint.json
└── yarn.lock
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"lib": [ "es2015", "dom" ],
"target": "es2015",
"module": "commonjs",
"resolveJsonModule": true,
"allowJs": true,
"jsx": "react",
"outDir": "./dist",
"strict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"pretty": true,
},
"exclude": [
"node_modules",
"project_manager",
"dist",
"@types"
]
}
答案 0 :(得分:0)
开始工作,就像是在魔咒恰到好处。在为最近的项目进行了一些挖掘之后,我在GitHub上发现了以下配置:
$scope.editBusiness = function (business) {
var ObjResolve = function () {
return business;
}
$rootScope.OpenModal("BusinessTypesModal.html", "ModalInstanceCtrl", ObjResolve);
};
设置为baseUrl
.
映射paths
文件 types-dir/module-name/index.d.ts
的最小子部分如下所示:
tsconfig.json
在您的情况下,您可能希望{
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"rootDir": "src",
"paths": {
"*": ["./types/*"]
}
}
}
指向paths
。