Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6208

Unexpected behaviour of rootDir and outDir

$
0
0

I am trying to use TypeScript with React Native.

This is my 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
}

I would like all .ts(x) files in the src directory to be compiled to the build directory.

Expected:

MyAwesomeReactNativeApp/
├── src/
│   └── index.tsx
└── build/
    └── index.js

Got:

MyAwesomeReactNativeApp/
├── src/
│   └── index.tsx
└── build/
    ├── src/
    │   └── index.js
    ├── index.android.js
    ├── index.ios.js
    └── __tests__/

The compiler complains:

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.

What am I doing wrong here?

Thank you in advance!


Viewing all articles
Browse latest Browse all 6208

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>