Closed
Description
TypeScript Version: 2.7.0-dev.20171214
Code
export class Missing {
public str : string;
}
export type ResultOrMissing<A> = A | Missing;
export interface IBar<A> {
myParam: ResultOrMissing<A>;
}
export interface IFoo<A> {
myParam: A;
}
export type BothOrUndefined<A> = (IFoo<A> | IBar<A>);
export interface IReturnsBoth {
<A>() : (BothOrUndefined<A> | undefined);
}
const helper : IReturnsBoth = <A>() : (BothOrUndefined<A> | undefined) => {
return undefined;
};
Expected behavior:
Compiling the above code with "tsc .ts -strictFunctionTypes" should succeed.
Actual behavior:
Somehow wires get crossed and we get this error:
repro.ts(20,7): error TS2322: Type '<A>() => IFoo<A> | IBar<A>' is not assignable to type 'IReturnsBoth'.
Type 'IFoo<ResultOrMissing<A>> | IBar<ResultOrMissing<A>>' is not assignable to type 'IFoo<A> | IBar<A>'.
Type 'IBar<ResultOrMissing<A>>' is not assignable to type 'IFoo<A> | IBar<A>'.
Type 'IBar<ResultOrMissing<A>>' is not assignable to type 'IBar<A>'.
Type 'ResultOrMissing<A>' is not assignable to type 'A'.
Type 'Missing' is not assignable to type 'A'.
Note the unexplained switch from IBar<A>
to IBar<ResultOrMissing<A>>
.