Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use plain javascript react component in a typescript react project

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

like image 227
dark-kun Avatar asked Jun 21 '26 23:06

dark-kun


1 Answers

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

like image 184
Dmitriy Zhiganov Avatar answered Jun 23 '26 11:06

Dmitriy Zhiganov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!