Reputation: 470
I've done some googling, and haven't found a solid answer. In fact, I keep finding the exact opposite answer to my question (i.e., how to migrate TO TypeScript rather than from). As a TS newbie, I'm trying to consider the pros/cons of using it to pitch it to my org. My main question:
If we did adopt TS, what is the level of effort of removing it from a React project if we change our minds later?
My understanding is that TS transpiles to JS. If we wanted to switch to JS later on, we could simply take those transpiled JS files, check them into source, and remove the TS transpiler and files - no more TS. However, React itself has its own conventions that aren't plain JS, so I believe the transpiled files will be JS rather than JSX. Is there a method of transpiling React with TS to React directly that's as effortless as going directly to JS?
Upvotes: 3
Views: 8993
Reputation: 17
the easiest way is to create a new project
steps to do this.
run tsc delete node modules folder
use your terminal to delete all ts files exp: rm -r /.ts or //.tsx
copy the js code to a new react project
Upvotes: -1
Reputation: 5763
As per my comment, you can set jsx: "preserve"
as an option in your TS configuration file, which will make the compiler forego transpiling the JSX into regular JS and output .jsx files you can use. Happy to help!
Upvotes: 4