我得到了我的
tsconfig.json
如下:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@app/*": ["app/*"],
"@env/*": ["environments/*"]
},
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"]
}
}
这让我有了简单易读的应用程序和环境代码导入。然而,现在的Visual Studio代码会显示出可怕的
node_modules
进口。例如,这个:
import { AppInsightsService } from '../../../../node_modules/@markpieszak/ng-application-insights';
而不仅仅是:
import { AppInsightsService } from '@markpieszak/ng-application-insights';
我试过改变
TSOCONT.JSON
致:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["*"],
"@app/*": ["src/app/*"],
"@env/*": ["src/environments/*"]
},
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"]
}
}
我希望我的vscode能够导入
节点模块
果不其然。