Expo Typescript won't build the project, no outDir is produced

Viewed 3464

I'm trying to get my typescript project to build. It has built successfully in the past with the same settings, but now it's not building even though it isn't showing any errors. I run:

npx tsc -p tsconfig.json

Where my tsconfig.json is:

{
  "compilerOptions": {
    "module": "ES6",
    "target": "ES6",
    "declaration": true,
    "outDir": "./lib",
    "strict": true,
    "jsx": "react-native",
    "skipLibCheck": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
  },
  "include": [
    "src/**/*"
  ],
  "extends": "expo/tsconfig.base"
}

No lib folder is produced at all.

My src folder contains several typescript files, as well as an index that exports the required components.

I'm really confused because my project structure and settings haven't changed at all yet tsc is no longer producing the outDir or any of the files when it worked before.

1 Answers

Expo is using typescript for typechecking only. Bundling files is done with Metro bundler. Thus expo/tsconfig.base has noEmit option set to true.

If you want to compile js files yourself you have to either run you command as:

npx tsc -p tsconfig.json --noEmit false

or to set noEmit option to false in your tsconfig.json. Don't forget to remove it back in you tsconfig. Or next time on build expo will run both metro bundling and tsc typecheck and tsc compilation.

As the last resort you may stop extending expo/tsconfig.base in your tsconfig.json. But do this only if you really know what you're doing.

Related