Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Typescript type checking #29

Open
ceremonious opened this issue Dec 17, 2020 · 4 comments
Open

Typescript type checking #29

ceremonious opened this issue Dec 17, 2020 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@ceremonious
Copy link

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?

@jaysoo jaysoo added the question Further information is requested label Dec 17, 2020
@jaysoo
Copy link
Member

jaysoo commented Dec 17, 2020

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.

@jaysoo jaysoo self-assigned this Dec 18, 2020
@jaysoo
Copy link
Member

jaysoo commented Dec 21, 2020

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: microsoft/TypeScript#21926

@jaysoo
Copy link
Member

jaysoo commented Jan 11, 2021

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).

@raymondji
Copy link

raymondji commented Nov 19, 2021

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 tsc with the tsconfig.app.json and tsconfig.spec.json setup. If I do tsc -b tsconfig.json, any type errors show up twice.
  • B) run-commands removes the formatting from the output of tsc, so it's a lot less legible than running tsc directly

Appreciate if you have any advice :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants