Typescript type checking
Is there a way for me to view all of the type errors in a NX React Native app? When running the React app or the Node app, NX automatically runs the type checker when running nx serve, but it doesn't do the same when running nx start for my React Native app.
Do I need to use tsc? What's the proper configuration for that?
We rely on the metro bundler and the corresponding babel metro preset to transpile TypeScript. There might be a way to tweak it to not do transpile only, but also type check.
Need to look into it.
Need to give this one some thought, the best way to do typechecking currently is to run tsc.
You can add a tsc target to your app:
npx nx g @nrwl/workspace:run-commands \
typecheck \
--command="tsc" \
--project=my-app \
--cwd=apps/my-app
Then you can run npx nx typecheck my-app during CI, and rely on your IDE (VSCode or IntelliJ to check locally).
There are some issues making it hard to get tsc to work fully with React Native. For example, it cannot resolve platform specific files like foo.android.tsx vs foo.ios.tsx so it wouldn't be good to force typechecks everywhere just yet.
Related issue: https://github.com/microsoft/TypeScript/issues/21926
Just a quick update, we are still looking into this but we have a few higher priority items in the works right now (including moving this repo back into the main Nx monorepo).
I'm doing the above and running tsc through @nrwl/workspace:run-commands (thanks for the suggestion!), but:
- A) not sure what is the right way to use
tscwith thetsconfig.app.jsonandtsconfig.spec.jsonsetup. If I dotsc -b tsconfig.json, any type errors show up twice. - B)
run-commandsremoves the formatting from the output oftsc, so it's a lot less legible than runningtscdirectly
Appreciate if you have any advice :)