So I asked this question earlier today on how to use paths。
现在,我正尝试使用该方法转换this project。
所以我首先克隆它:
git clone git@github.com:fireflysemantics/validator.git
然后编辑paths
设置,使其看起来像这样:
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": {
"@fs": ["./src"],
"@test": ["./test"]
}, /*
然后我尝试编辑src/container/error/index.ts
,使其看起来像这样:
export { ObjectErrors } from "@fs/container/error/ObjectErrors";
export { ValidationError } from "./ValidationError";
当我编译Typescript时仍然产生此错误:
src / container / error / index.ts:1:30-错误TS2307:找不到模块'@ fs / container / error / ObjectErrors'。
1从“ @ fs / container / error / ObjectErrors”中导出{ObjectErrors}; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
有想法吗?
答案 0 :(得分:-1)
将您的paths属性添加到tsconfig文件中的editorOptions中。
"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/*"
]
}
}
}