2
I know that the Typescript language is used to compile Javascript files. But I wonder if there is any tool that makes it possible to do the reverse.
Is there any way to convert a Javascript file to a Typescript structure, something automatic?
For me it would be much more interesting to be able to work from the Typescript language, to refactor a file, and improve the logic from that, because the version we have here is very disorganized, and has a very complex and messy structure, I believe that if I switch to Typescript, I can merge and improve some things, because Typescript is much more flexible in this sense.
I’m having to recreate everything manually in Typescript, but I spend a lot of time having to review each item, and each snippet of code. I would like to save effort and work from the old version converted to a strongly typed language, as is Typescript.
I do not know Typescript, seems based on Ecmascript 4 in some points, maybe not worth just transpose Javascript to typescript, the result will not be the most expectative (for example, the code could work identically, but would not use much of the new features of Typescript, such as :Typevalue | ..., and tals). The result of the conversion will be illegible type.
– Klaider
The typescript language is "superior" to javascript, so any tool you invent will have conversion problems. There are some people using resharp 9 for this, if you know English, here’s a good read: https://blog.jetbrains.com/dotnet/2015/02/05/ways-and-advantages-of-migrating-javascript-code-to-typescript/
– Scoup