Closed
Description
TypeScript Version: 2.6.0-dev.20170922
Code
function test<T>(target: T, name: keyof T) {}
test({ a: 1, b: 2, c: 3, d() {} }, "d");
but below code worked.
function test<T>(target: T, name: keyof T) {}
test({ a: 1, b: 2, c: 3, d: () => {} }, "d");
Probably keyof operator can't iterate over properties if object contains method signature passed as function arguments.
And then, below code worked expectedly.
function test<T>(target: T): keyof T {
return "a" as any;
}
const k = test({ a: 1, b: 2, c: 3, d() {} });
// typeof k = 'a' | 'b' | 'c' | 'd'
Expected behavior:
Compiled
Actual behavior:
Error occured.
error TS2345: Argument of type '"d"' is not assignable to parameter of type 'never'.
I think this issue caused by getPropertiesOfObjectType
of checker.ts
not return callSignatures.