【发布时间】:2019-03-04 06:10:12
【问题描述】:
我有一个 Angular 项目,它有一个 lib 文件夹,用于需要修改 node_module 的情况。我可以使用 tsconfigs 路径选项连接 lib 文件夹,并且实际上 可以编译 应用程序以无错误地运行。问题是 vscodes tslint 仍然无法识别 lib 文件夹。
lib文件夹在项目的根目录下:
root/lib/ng2-smart-table
项目的 tsconfig 设置是:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "./",
"types": [],
"paths": {
"@angular/*": [
"../node_modules/@angular/*"
],
"@lib/*": [
"../lib/*"
],
}
},
"exclude": [
"test.ts",
"**/*.spec.ts",
"../node_modules/@nebular/**/*.spec.ts"
],
"include": [
"../src/*.ts",
"../src/**/*.ts",
"../node_modules/@nebular/**/*.ts",
"../lib/**/*.ts",
]
}
如果您想下载此问题的基本示例,还有一个公共 repo。链接:https://github.com/Jonathan002/tslint-cannot-find-module-example
如何消除 vscode 中的 lint 错误?
【问题讨论】:
-
你试过重启ide吗?
-
是的,我已经多次重新启动它。示例项目是否可以在没有 lint 错误的情况下为您工作?
标签: angular typescript