3 ms·
You don't even need to do this much, you can just invoke the function and let the return type be inferred. const inferred = (() => "Hello")() // Inferred as
by gavinray 3y ago
You don't even need to do this much, you can just invoke the function and let the return type be inferred.
const inferred = (() => "Hello")() // Inferred as "string"
If you really don't want to use an IIFE because you don't like the "()" at the end, you can just:
const myFn = () => { switch(...) }
const inferred = myFn()