TypeScript Version: 2.7.0-dev.20180104
Code
import * as React from "react";
interface Props {
x?: "a" | "b";
}
class MyComponent<P extends Props = Props> extends React.Component<P> {}
const m = <MyComponent x="a"/>
Expected behavior:
No error.
Actual behavior:
src/a.tsx(7,24): error TS2322: Type '{ x: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComponent<Props>> & Readonly<{ children?: ReactN...'.
Type '{ x: string; }' is not assignable to type 'Readonly<Props>'.
Types of property 'x' are incompatible.
Type 'string' is not assignable to type '"a" | "b" | undefined'.
This was working in 2.7.0-dev.20180103.
There is no error if x is made non-optional.
But discovered in react-leaflet on DefinitelyTyped. There are also errors in react-router that look similar.
TypeScript Version: 2.7.0-dev.20180104
Code
Expected behavior:
No error.
Actual behavior:
This was working in
2.7.0-dev.20180103.There is no error if
xis made non-optional.But discovered in
react-leafleton DefinitelyTyped. There are also errors inreact-routerthat look similar.