Closed
Description
TypeScript Version: 3.4.0-dev.20190202
Search Terms: any, array, argument
Code
function getProps<T, K extends keyof T>(obj: T, list: K[]): Pick<T, K> {
return {} as any;
}
const myAny: any = {};
// TS 3.2.2 - getProps returns Pick<any, "foo" | "bar">
// TS 3.4 - getProps returns Pick<any, "foo" | "bar">
const o1 = getProps(myAny, ['foo', 'bar']);
// TS 3.2.2 - getProps returns Pick<any, "foo" | "bar">
// TS 3.4 - getProps returns Pick<any, string>
// └ 🚨 Type 'Pick<any, string>' is missing the following properties
// from type '{ foo: any; bar: any; }': foo, bar [2739]
const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']);
Expected behavior:
I expect o2
above to type-check successfully in 3.4
Actual behavior:
Playground Link: NOTE: does not demonstrate the reported behavior, since it's only reproducible in recent 3.4 nightly builds