Source:  Twitter logo

I am working on a React Project and have a bunch of tsx files that I want to convert as use as javascript for my project. How should I do that?

I am working on a React Project and have a bunch of tsx files that I want to convert as use as javascript for my project. How should I do that

You can use the typescript compiler e.g.

npx -p typescript tsc somefile.tsx
4 users liked answer #0dislike answer #04
basarat profile pic
basarat

Ciao, while the web is full of guide on how to translate React Javascript into Typescript, I don't found any reverse guide (so strange...). Anyway, I had same problem some time ago and I found useful get one of those guide JS => TS for React and read backwards. For example, I used this guide. When he said "JavaScript looks like that so you can translate this into Typescript in this way..." I did the contrary (and it worked!). Of course you can skip all the dependencies part. Try and let us know.

1 users liked answer #1dislike answer #11
Giovanni Esposito profile pic
Giovanni Esposito

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).