Live data from Hacker News

Ts-migrate: tool to automatically migrate JavaScript projects to TS

github.com

1–10 of 28 posts

Re: Ts-migrate: tool to automatically migrate JavaScript projects to TS

#4

I thought the tool to automatically migrate JS to TS was tsc --init and then set the flag to include js files.

This tool actually converts JS files to valid TS files with strict typing, attempting to add types to everything it can and adding placeholder types where it can't.

Re: Ts-migrate: tool to automatically migrate JavaScript projects to TS

#6

I thought the tool to automatically migrate JS to TS was tsc --init and then set the flag to include js files.

That’s just running js files within ts files. Nothing to really do with migrating, unless you’re writing everything by hand and want everything to work while you’re at it.

Re: Ts-migrate: tool to automatically migrate JavaScript projects to TS

#8
If I understand correctly, they convert the js file to .ts file, ask tsc for error diagnostics and automatically apply transformations to resolve those errors when they can.

Yep that’s how I’d do it too. I wrote a simpler version when doing a tsc upgrade to resolve a whole bunch of errors. It parses the tsc errors and does simple string replaces.

Has anyone played with the tool to report how good it is?

I remember v8 did an experiment back in the day where it would run code and profile the input parameters and output of functions and automatically generate typescript types.

Re: Ts-migrate: tool to automatically migrate JavaScript projects to TS

#9
post #8

If I understand correctly, they convert the js file to .ts file, ask tsc for error diagnostics and automatically apply transformations to resolve those errors when they can. Yep that’s how I’d do it too. I wrote a simpler version when doing a tsc upgrade to resolve a whole bunch of errors. It parses the tsc errors and does simple string replaces. Has anyone played with the tool to report how good it is? I remember v8…

I hadn't heard of that, but there is the typewiz project - https://github.com/urish/typewiz
Post reply on HN