[英]Trouble converting project to Typescript paths
So I asked this question earlier today on how to use paths . 所以我今天早些时候问了这个关于如何使用路径的问题。
Now I'm trying to convert this project using that approach.现在我正在尝试使用这种方法转换这个项目。
So I first clone it:所以我首先克隆它:
git clone git@github.com:fireflysemantics/validator.git
Then edit the paths
setting so it looks like this:然后编辑
paths
设置,使其看起来像这样:
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": {
"@fs": ["./src"],
"@test": ["./test"]
}, /*
Then I tried editing the src/container/error/index.ts
so that it looks like this:然后我尝试编辑
src/container/error/index.ts
使它看起来像这样:
export { ObjectErrors } from "@fs/container/error/ObjectErrors";
export { ValidationError } from "./ValidationError";
When I compile Typescript still generates this error:当我编译 Typescript 时仍然会产生这个错误:
src/container/error/index.ts:1:30 - error TS2307: Cannot find module '@fs/container/error/ObjectErrors'.
src/container/error/index.ts:1:30 - 错误 TS2307:找不到模块“@fs/container/error/ObjectErrors”。
1 export { ObjectErrors } from "@fs/container/error/ObjectErrors"; 1 从 "@fs/container/error/ObjectErrors" 导出 { ObjectErrors }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thoughts?想法?
Add your paths property to the compilerOptions in the tsconfig file.将您的路径属性添加到 tsconfig 文件中的 compilerOptions。
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"paths": {
"@app/*": [
"./app/*"
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.