TypeScript Version: 2.5.2
Code
export interface ConfirmationComponentProps {
title?: string,
}
function propTypes<OProps extends {}>() : {[K in keyof (OProps & ConfirmationComponentProps)]?: any } {
return {
title: null,
};
};
Expected behavior:
Compile with no errors.
Actual behavior:
Fails with: { title: null }is not assignable to {[K in keyof (OProps & ConfirmationComponentProps)]?: any }`
The problem disappears if I remove the intersection type & and just use ConfirmationComponentProps; or if I replace OProps with a concrete type like:
function propTypes<OProps extends {}>() : {[K in keyof {x: number} & ConfirmationComponentProps]?: any } {
return {
title: null,
};
};