2

With the new --typescript option, Create React App generates a dependency on the typescript compiler (among several other changes). However it uses @babel/preset-typescript for compiling TypeScript. So what does it use the TypeScript compiler for? Also, what is the tsconfig.js file used for?

2
  • Some people may choose to write their react application using TypeScript(typescriptlang.org), which is essentially a superset of JavaScript. However, it still needs to be transpiled into JavaScript before running to application. tsconfig the settings which specifies the root files, and other options required to compile the application. Commented May 11, 2019 at 19:26
  • @wentjun, I just clarified my question. I am already using TypeScript with my React project, however I was curious where CRA uses the the typescript compiler vs the Babel TypeScript plugin. Commented May 11, 2019 at 19:32

1 Answer 1

2

@babel/plugin-transform-typescript that is used by @babel/preset-typescript doesn't make type checking, it just strips out type information which is much faster. For type checking you need to install and set up TypeScript.

https://babeljs.io/docs/en/babel-plugin-transform-typescript/

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

Comments

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.