by hliyan · 9y ago · 0 comments
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
[0] https://en.wikipedia.org/wiki/Type_inference[1] https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_sy...