Closed
Description
TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms: generics, typeof, object, never
Code
function f<TData>(data: TData): boolean {
if (typeof data === "object") return true;
return data;
}
let x: boolean = f(1);
Expected behavior:
Code should not compile - function actually returns boolean | TData, but states only boolean
Actual behavior:
Code compiles without errors. After the if statement, data is considered never
Related Issues: