Javascript 将项目转换为类型脚本路径时出现问题
现在我正试图用这种方法转换 所以我首先克隆它:Javascript 将项目转换为类型脚本路径时出现问题,javascript,node.js,angular,typescript,npm,Javascript,Node.js,Angular,Typescript,Npm,现在我正试图用这种方法转换 所以我首先克隆它: git clone git@github.com:fireflysemantics/validator.git 然后编辑路径设置,使其如下所示: "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ "paths": { "@fs": ["./src"], "@test": ["./test
git clone git@github.com:fireflysemantics/validator.git
然后编辑路径设置,使其如下所示:
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": {
"@fs": ["./src"],
"@test": ["./test"]
}, /*
export { ObjectErrors } from "@fs/container/error/ObjectErrors";
export { ValidationError } from "./ValidationError";
然后我尝试编辑src/container/error/index.ts
,使其看起来像这样:
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": {
"@fs": ["./src"],
"@test": ["./test"]
}, /*
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}”;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
想法
类型脚本Github问题
将路径属性添加到tsconfig文件中的编译器选项中
"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/*"
]
}
}
}
只是仔细检查了一下-好的,它在
compilerOptions
部分…?您没有查看示例配置对象吗?它在compilerOptions部分。我首先创建了一个最小的MVCE,以确保我有一些有效的东西。现在我尝试将其应用到另一个项目中,但它不起作用……您是否尝试克隆该项目以查看它是否在您的端起作用?你会注意到在前面的回答中,我链接到我们必须删除glob模式才能让它工作。