[英]Import module from root path in TypeScript with intellij-idea
i know this topic is very much asked i try read it but still fail 我知道这个话题非常多,我尝试阅读但仍然失败
this is my tsconfig.json 这是我的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"
}
}
this is my directory structure 这是我的目录结构
node_modules
src
gw2taco
index
test
r
r.ts (all fail) r.ts(全部失败)
im use intellij-idea 我使用了智能想法
Given this directory structure: 给定此目录结构:
node_modules
src
gw2taco
index.ts
test
r.ts
One option for the import in r.ts
is this: 在
r.ts
导入的一种选择是:
import "../src/gw2taco";
baseUrl
, rootDir
, and paths
entries. baseUrl
, rootDir
和paths
条目。 include
and exclude
properties outside of the compilerOptions
. include
和exclude
属性放在compilerOptions
之外。 include
. include
。 newLine
property to LF
. newLine
属性大写为LF
。 The file result looks like this: 文件结果如下所示:
{
"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"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.