Re:The Ergonomics of Type Checking (2016)
by bcherny on Saturday October 28, 2017 @03:57PM
(#15576531)
This is a well explored area. Wikipedia article is short but has some good references [0].
Languages like Haskell, OCaml, F#, and Elm use global type inference.
Languages like Scala and TypeScript use local type inference. TypeScript in particular uses flowed type inference (there might be a more formal name for this). For example:
let a = document.querySelector('#a') // typeof a is Element | null
if (a == null) throw 'not found' // typeof a is now Element
Languages like Haskell, OCaml, F#, and Elm use global type inference.
Languages like Scala and TypeScript use local type inference. TypeScript in particular uses flowed type inference (there might be a more formal name for this). For example:
[0] https://en.wikipedia.org/wiki/Type_inference