tsconfig 设置了路径,但不编译别名



当我使用tsc编译代码时,我发现我的别名没有转换,但我已经配置了路径,这里是tsconfig.json

{
"compilerOptions": {
// https://github.com/TypeStrong/ts-loader/issues/1061
"target": "ES5",
"lib": ["dom", "dom.iterable", "esnext"],
"paths": {
"@/*": ["./src/*"],
"doc/*": ["./site/*"],
"docs/*": ["./site/Components/*"],
"ethan/*": ["./src/*"],
"ethan": ["./src/index.ts"]
},
"rootDir": "src",
"outDir": "publish/css",
"experimentalDecorators": true,
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"jsx": "react",
"strict": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"baseUrl": "./",
"strictNullChecks": false,
"alwaysStrict": false,
"downlevelIteration": true,
},
"include": ["src"],
"exclude": ["node_modules", "ssh-client", "webpack", "scripts", "docs-pages","publish"]
}

代码的一个编译文件部分在这里

var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocale = exports.setLocale = void 0;
// @ts-nocheck 
var objects_1 = require("@/utils/objects");

我的代码哪里错了

谢谢~~~

您可能需要为其安装额外的依赖项,如模块别名或tsconfig路径

在我看来,在编译过程中解析路径会更容易,但正如TS团队所说,在一些使用符号链接的环境中,它会变得复杂。

最新更新