Home > database >  command to compile typescript in react-native?
command to compile typescript in react-native?

Time:02-07

I went through this tutorial

https://reactnative.dev/docs/typescript

However, I am using npm and the only command to compile typescript I see in that page is "yarn tsc"

I found another blog that said "npm start" does this but when I add this one line to my typescript, it still compiles and should not since I do not declare a variable something, nor a variable called blah ->

something = blah;

What command should I run to compile/type-check? I am looking for it to fail because of the above line.

CodePudding user response:

I think the TS compilation (transcompilation or transpiling to JS) happens when the JS bundle is generated when you run npm start or when you release your app.

If you just want to check types, syntax and lint you might want to run:

eslint . --ext .js,.jsx,.ts,.tsx

You can also do tsc only, and this will check typescript according to your tsconfig.json file. Please note you need to have typescript installed globally with npm install -g typescript

CodePudding user response:

You can also use npx to run things you don't have globally: npx tsc

  •  Tags:  
  • Related