Closed
Description
Hi, I found that the following example that uses type argument inference and generic type alias doesn't compile:
Example with generic type alias (does not work)
type Maybe<T> = T | void;
function get<T>(x: Maybe<T>): T {
return null; // just an example
}
let foo: Maybe<string>;
get(foo).toUpperCase(); // I think T == string in this function call...
Error
test.ts(8,10): error TS2339: Property 'toUpperCase' does not exist on type 'string | void'.
Example with generic interface (works)
interface Maybe<T> {}
function get<T>(x: Maybe<T>): T {
return null;
}
let foo: Maybe<string>;
get(foo).toUpperCase();
Version
1.8.0-dev.20151027