3 ms·
Possibly! But trickier than it seems at first. For types to help with optimization, those types have to be correct and reliable (i.e. sound). If every line of
by rictic 8y ago
Possibly! But trickier than it seems at first.
For types to help with optimization, those types have to be correct and reliable (i.e. sound). If every line of your app and all of its dependencies are sound, then you should expect a speedup. If there is any unsound code, then you'll have to generate runtime checks to preserve the soundness properties that your optimizer assumes, and those can actually result in _slower_ code.
Even Flow has made compromises that are good for a type checker, but likely unacceptable if an optimizer is relying on them. Quoting https://flow.org/en/docs/lang/types-and-expressions/ https://flow.org/en/docs/lang/types-and-expressions/
> Soundness is fine as long as Flow isn’t being too noisy and preventing you from being productive. Sometimes when soundness would get in your way too much, Flow will favor completeness instead. There’s only a handful of cases where Flow does this.