Hacker News new | ask | show | jobs
by makkesk8 3148 days ago
I've always wondered if you could let the engine do the type checking or create type definition files for you, maybe an optional v8 flag?

This would be best case scenario so we could get rid of the tedious work that one has to put in to make an older library have type checking.

1 comments

Typescript has inference for "plain" JS files if you use the `--allowJS` flag.

That inference is also made available more directly in dts-gen [1], which is a tool built around Typescript inferencing that produces decent first pass type definition files for a library.

dts-gen may be something to try the next time you need a definition file. (Personally, I still prefer to start a new definition file by hand, but it's good to have an automated option, even if only to double-check your work.)

[1] https://github.com/Microsoft/dts-gen