Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  37] [ 1]  / answers: 1 / hits: 22373  / 3 Years ago, mon, january 25, 2021, 12:00:00

I have a project where I wrote some new code in Expo with TypeScript (since I am more used to having a type safe language). However, I want to port what I wrote to something that was written with Expo with JavaScript.


I can manually just strip off the types as I go along to solve the problem, but I was wondering if there's a more automatic way of doing it. I know typescript eventually compiles down to JavaScript but I want to keep the HTML embedded code the same when I do the conversion. Is it possible?


More From » reactjs

 Answers
19

The answer provided by @Jason is close to what I needed.


In the end I ran this command


npx tsc --jsx preserve -t es2020 --outDir js --noEmit false

This generated the .js and .jsx files in the js folder which can be copied over to non-typescript systems.


--noEmit false is needed for the Expo generated tsconfig.js which is noEmit: true


The -t es2020 generates output using ES2020 standards so you can get import and export along with the async await intact.


[#50433] Friday, January 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gerardamosy

Total Points: 600
Total Questions: 116
Total Answers: 102

Location: Ukraine
Member since Tue, May 30, 2023
1 Year ago
;