Closed
Description
interface I {
fn: <T>(t: T) => void;
}
interface X {
x: number;
}
function toI<T extends X>() : I {
return {
fn: (t: T) => { // <-- expected a warning from the compiler that the type constraint cannot be enforced
alert(t.x);
}
};
}
function test(i: I): void {
i.fn({}); // <-- problem unnoticed
}
test(toI<X>()); // displays "undefined"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment