DEV Community

Discussion on: Why I'm Learning Typescript

Collapse
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Hi @annabaker ,
About that:

If you're familiar with React, you may have used the createreactapp CLI tool to create a new React project. The createreactapp tool uses TypeScript by default. This is because React is developed using TypeScript and it's recommended that you use TypeScript for React projects.

Create react app is NOT using TS by default neither they recommend nor reject TS, because it has no sense. It's not their competence as library, to define which other dependencies you need in the whole project.

It's an option to choose by the developers (usually the TL or LD) taking in mind the specific use-case and it has many pros but some drawbacks as well.
While TS brings some advantages, still JS is the most used in the whole world* and it's in backend where it shines most (Node JS, Deno, Bum...) IMHO.

If you want to use create react app executable along with typescript you need to explicitly state that by using:

npx create-react-app my-app --template typescript
Enter fullscreen mode Exit fullscreen mode

Or the yarn equivalent:

yarn create react-app my-app --template typescript
Enter fullscreen mode Exit fullscreen mode

Otherwise it will be JS (without TS).

Despite that, it is not recommended to use create-react-app executable for other thing than learning purposes. It is boilerplaty and with all probability will add dependencies that you may not use. It's better to add the dependencies (react, react-dom, a bundler like Webpack or Parcel, jest...) When you're about to use them than using the create-react-app and then start deleting things when you realise you're not using some of them.

Maybe you prefer (or need) Parcel because it's -almost- zero config, or using a different testing suite than what comes along the executable or... Whatever.

As bonus there is more than one way to use TS:

Best regards! 😁


*You can search jobs with TypeScript keyword in LinkedIn with some desired filters (or not) and then do the same using JavaScript instead.
Even that I also think that learning TS is a good thing (you'll be able to work in both JS and TS and, using what is explained in the embedded post I added, it will be almost the same with few exceptions).

Collapse
 
annabaker profile image
Anna Baker

Thank you so much for your comment! I will check it out!