Home > Back-end >  How to use plain javascript react component in a typescript react project
How to use plain javascript react component in a typescript react project

Time:12-12

One of my colleague used typescript for a frontend React project. She is now leaving the company and management has assigned me into this project. They want me to deliver from Day 1, and they are ok with me using Javascript in the project. So how can I use plain Javascript components in a Typescript React project. I understand the advantages of Typescript but right now I do not have time for learning it. So any solutions to the problem would be great.

PS:

  1. We cannot create a new project as it will take time to recreate everything.
  2. For now she made 2 end to end features using Typescript, there are 7 more features to cover and I intend to write them in JS and convert the current 2 features to JS after I am done with the 7 features which are remaining.

I was not able to find any solutions for now

CodePudding user response:

Add allowJs: true to the tsconfig file. This will allow you to import .js/.jsx files into .ts/.tsx Read more about option

CodePudding user response:

You can basically use Javascript in Typescript since TypeScript is a superset of JavaScript, just find the key differences in both languages (like: writing variables etc.) and you can start coding in Typescript. You can read more here to give you an overview of these differences

  • Related