Live data from Hacker News

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

github.com

11–20 of 28 posts

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

#12

I've wondered if you could run JS code, keep track of runtime types, and generate interfaces off of that. Of course the program wouldn't know what to name the interface, but it's still better than nothing.

This is interesting, it would be great to make this a general tool. Extract invariants from untyped runs to generate tests/interfaces or else. Migrations would be smoother.

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

#13

I've wondered if you could run JS code, keep track of runtime types, and generate interfaces off of that. Of course the program wouldn't know what to name the interface, but it's still better than nothing.

Generating starting points for interface definitions based on runtime logs does sound like a good idea.

There's a similar project I'm aware of that uses runtime behavior to help create type annotations but for python: https://github.com/instagram/MonkeyType

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

#14
post #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.

Well, actually is a good base to migratee a js codebase to ts manually, one file at a time.

You can leave parts in JS while you upgrade/add new features in TS

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

#16
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

I keep a list of migration tools here fwiw https://github.com/typescript-cheatsheets/react/blob/master/...

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

#17
This tool is ridiculous and less than useless. Can't anyone else see how ridiculous of an idea it is to add types automatically? Isn't the whole point of static typing to allow the human developer to specify what the types should be? If a machine could resolve the type integrity issue automatically from dynamically typed code (which is what this tool claims to do), why do we need this tool to physically insert type annotations into the code to begin with? I can't believe I even have to explain myself. I thought static typing was meant to protect the code's integrity?

Clearly this tool is undeniable proof that static typing exists merely to satisfy human ego and neuroticism and has nothing to do with logical integrity... Since this tool itself supposedly proves that this integrity can be derived automatically from dynamically typed code. This tool is a paradox, a blatant logical contradiction.

If this tool does work as advertised, then it proves the uselessness of static typing and thus, by extension, this tools proves its own uselessness.

EDIT I removed a potentially offensive remark from my comment. This makes zero sense to me is my point.

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

#19

This tool is ridiculous and less than useless. Can't anyone else see how ridiculous of an idea it is to add types automatically? Isn't the whole point of static typing to allow the human developer to specify what the types should be? If a machine could resolve the type integrity issue automatically from dynamically typed code (which is what this tool claims to do), why do we need this tool to physically insert type a…

There's no conspiracy here, just TypeScript is now strict enough to need annotation, and the authors deemed it better to work with a valid TS file and annotate from there than loosen that strictness.

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

#20

This tool is ridiculous and less than useless. Can't anyone else see how ridiculous of an idea it is to add types automatically? Isn't the whole point of static typing to allow the human developer to specify what the types should be? If a machine could resolve the type integrity issue automatically from dynamically typed code (which is what this tool claims to do), why do we need this tool to physically insert type a…

Who hurt you?

This project is meant to make developers more efficient and support them in migrating projects to TypeScript. The entire point of TypeScript is to make developers more efficient, too, through clear structuring, types and assistance through its toolchain.

Static typing does not protect you from integrity issues. However, it allows you to extend existing code with confidence.

I'm not sure if you work in a team, but your general attitude isn't exactly conducive to a constructive, open and efficient working environment.

Post reply on HN