Hacker News new | ask | show | jobs
by Zalastax 2848 days ago
Thanks, I did not know that!

TypeScript can do type refinements based on the flow (e.g. a null check refines a type with null to one without) but can't do what you just showed. Are there any tools that can emit the inferred types to source code? I just now got a vision of using flow style type inference to gradually augment a project with either flow or TS types with very little work.

1 comments

Flow has an API that can expose its inferences. There are Flow to TypeScript conversion tools that might bake the types into definitions.

Ironically, we’re considering switching to TypeScript and in my team the lack of inference is seen as an advantage. It forces people to consider their types as part of the design of their interfaces.