-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone

Description
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue