4 ms·
You can sometimes use overloads to make it better: function transform(a: number): number function transform(a: string): false function transform(""
by ygra 6y ago
You can sometimes use overloads to make it better:
function transform(a: number): number
function transform(a: string): false
function transform(""): ""
Depending on how predictable the output is from the types, of course. But for many things it works better than just using union types everywhere.