1
我正在嘗試使用TypeScript和React Native。rootDir和outDir的意外行爲
這是我tsconfig.json
:
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"jsx": "react",
"outDir": "build",
"rootDir": "src",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"allowJs": true,
"sourceMap": true
},
"filesGlob": [
"typings/index.d.ts",
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"index.android.js",
"index.ios.js",
"build",
"node_modules"
],
"compileOnSave": false
}
我想所有的.ts(X)在src目錄中的文件被編譯到構建目錄。
預計:
MyAwesomeReactNativeApp/
├── src/
│ └── index.tsx
└── build/
└── index.js
了:
MyAwesomeReactNativeApp/
├── src/
│ └── index.tsx
└── build/
├── src/
│ └── index.js
├── index.android.js
├── index.ios.js
└── __tests__/
編譯器會抱怨:
error TS6059: File '[...]/__tests__/index.android.js' is not under 'rootDir' '[...]/src'. 'rootDir' is expected to contain all source files.
error TS6059: File '[...]/__tests__/index.ios.js' is not under 'rootDir' '[...]/src'. 'rootDir' is expected to contain all source files.
error TS6059: File '[...]/index.android.js' is not under 'rootDir' '[...]/src'. 'rootDir' is expected to contain all source files.
error TS6059: File '[...]/index.ios.js' is not under 'rootDir' '[...]/src'. 'rootDir' is expected to contain all source files.
我在做什麼錯在這裏?
預先感謝您!
是'[...]單曲不同(具體地具有不同的情況下)?我在我的Mach上看到類似錯誤的錯誤是:錯誤TS6059:File'/ Users/[...]'不在'rootDir'/ users/[...]'下。 'rootDir'預計包含所有源文件。一個是'/ Users',另一個是'/ users'。 – Gingi