1

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.

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

except npm start did not fail when I put in compile errors while npx tsc does (the other person's answer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.