ts-plus / typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: passing 'undefined as never' into function with 'LazyArg' compiles wrong code

wesselvdv opened this issue · comments

function f<X>(x: LazyArg<X>): X {
   return x()
}

f(undefined as never)
f(undefined as void)

compiles into:

function f(x) {
    return x();
}
f(undefined);
f(() => undefined);

This is due to never extends () => any, but we should show a diagnostic that this is not correct.