mlscript icon indicating copy to clipboard operation
mlscript copied to clipboard

Allow consuming TypeScript types and trees from MLscript

Open LPTK opened this issue 4 years ago • 0 comments

The main idea is to interface with the TypeScript compiler and leverage its parser and type checker.

The benefits would be twofold:

  • We can reuse TS types from TS libraries or JS libraries with existing TS bindings, such as those in the popular DefinitelyTyped project. This would be a huge boon and would make MLscript actually usable for practical, real-world coding.

  • We can reuse the TS parser to retrieve functions that are missing some type annotations (for example, missing the return type, or plain JS functions missing all types), and still perform type inference for them.

The second point is actually really interesting on its own. Together with https://github.com/hkust-taco/mlscript/issues/57, it would mean we could use MLscript as a standalone TypeScript type-inferencer for JavaScript (and also for partially-annotated TypeScript files).

LPTK avatar Jan 03 '22 06:01 LPTK