Closed
Description
TypeScript Version: playground
Code
function check<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
function fn(){}
var f1: Function = fn;
var f2: {():void} = fn;
check(f1, "bind"); //ok
check(f2, "bind"); //error
f2.bind; //ok
Expected behavior:
An index type query keyof T yields the type of permitted property names for T
I expected that "bind" is permitted (as I assume, public and in some cases protected) and apparent members of type {():void}
Form spec:
The apparent members of an object type T are the combination of the following:
- The declared and/or inherited members of T.
- The properties of the global interface type 'Object' that aren't hidden by properties with the same name in T.
- If T has one or more call or construct signatures, the properties of the global interface type 'Function' that aren't hidden by properties with the same name in T.
Actual behavior:
Error.
If it by design I am with great pleasure would like to know what is permitted property names?