我知道这个话题非常受欢迎 我尝试阅读但仍然失败
这是我的tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"sourceMap": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"rootDir": ".",
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"alwaysStrict": true,
"locale": "zh-TW",
"pretty": true,
"paths": {
"src/*": [
"./src/*"
],
"/root/src/*": [
"./src/*"
]
},
"include": [
"./src/**/*.ts"
],
"exclude": [
"node_modules"
],
"newLine": "lf"
}
}
这是我的目录结构
node_modules
src
gw2taco
index
test
r
r.ts(全部失败)
即时通讯使用intellij-idea
答案 0 :(得分:0)
鉴于此目录结构:
node_modules
src
gw2taco
index.ts
test
r.ts
r.ts
中导入的一个选项是:
import "../src/gw2taco";
baseUrl
,rootDir
和paths
条目。include
和exclude
属性放在compilerOptions
之外。include
。 newLine
属性大写为LF
。 文件结果如下所示:
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"sourceMap": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"alwaysStrict": true,
"locale": "zh-TW",
"pretty": true,
"newLine": "LF"
},
"include": [
"./src/**/*.ts",
"./test/**/*.ts"
],
"exclude": [
"node_modules"
]
}