Closed
Description
TypeScript Version: 3.4.0-dev.20190326
Search Terms: Function Generic Extends Keyof Property
Code
interface Type {
a: 123;
b: "some string";
}
function get123<K extends keyof Type>(): Type[K] {
return 123;
}
Expected behavior:
The function get123
would yield an error as the return type might not be correct as it depends on K
.
Actual behavior:
No error for get123
. That function would obviously always return 123.
Playground Link: Example on TypeScript Playground