Closed
Description
Problem comes from react-redux
package when using ```connect`` function.
TypeScript Version: 2.6.2
Code
interface F {
a?: number;
}
interface P {
a?: number;
}
const u: P = { a: undefined };
const v = { a: u.a };
class C extends React.Component<F, {}> {
constructor(p: F) {
super(p);
}
render() {
return <div>Hello</div>;
}
}
interface IGC<Y> {
<P extends Y>(component: React.ComponentClass<P>): React.ComponentClass<P>;
}
interface IGB<K extends any = any> {
<K>(p: K): IGC<K>;
}
const gb: IGB = p => {
return function(Componentklass) {
return Componentklass;
};
};
let y = gb(v);
y(C);
Expected behavior:
Allow to assign optional property into it equivalent number | undefined
Actual behavior:
TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'ComponentClass<{ a: number | undefined; }>'.
Type 'C' is not assignable to type 'Component<{ a: number | undefined; }, ComponentState>'.
Types of property 'props' are incompatible.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<F>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<{ a: number | undefined; }>'.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<F>' is not assignable to type 'Readonly<{ a: number | undefined; }>'.
Property 'a' is optional in type 'Readonly<{ children?: ReactNode; }> & Readonly<F>' but required in type 'Readonly<{ a: number | undefined; }>'.
Activity
j-oliveras commentedon Dec 22, 2017
Duplicate of #12400? (seams like will be solved into typescript 2.8)