by domlebo70 · 3y ago · 0 comments
export const run = <T>(f: () => T): T => f();
Now you can go: const inferred_type = run(() => {
switch(blah) {
...
}
}) 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()