Closed

Description
TypeScript Version: 3.1.0-dev.20180801
(works in 3.1.0-dev.20180731)
Code
Simplified from the compile error in DefinitelyTyped/types/ember
:
type ComputedPropertyGetters<T> = { [K in keyof T]: ComputedProperty<T[K]> | T[K] };
declare class ComputedProperty<T> { t: T; }
interface Array<T> {
get<T, K extends keyof T>(this: ComputedPropertyGetters<T>, key: K): T[K];
firstObject: ComputedProperty<T | undefined>;
}
const n: number | undefined = [0].get("firstObject");
Expected behavior:
No error.
Actual behavior:
src/a.ts:10:7 - error TS2322: Type 'ComputedProperty<number | undefined>' is not assignable to type 'number'.
10 const n: number | undefined = [0].get("firstObject");
The intention was for the following type arguments to be inferred:
[0].get<{ firstObject: number | undefined }, "firstObject">("firstObject");
The code still works when the above type is explicitly provided.
I think this change is due to #26063 (CC @ahejlsberg).