mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[react-router] Add failing test for union props
This commit is contained in:
@@ -22,3 +22,31 @@ const WithRouterTestFunction = () => (
|
||||
<WithRouterComponentFunction username="John" />
|
||||
);
|
||||
const WithRouterTestClass = () => <WithRouterComponentClass username="John" />;
|
||||
|
||||
// union props
|
||||
{
|
||||
interface Book {
|
||||
kind: 'book';
|
||||
author: string;
|
||||
}
|
||||
|
||||
interface Magazine {
|
||||
kind: 'magazine';
|
||||
issue: number;
|
||||
}
|
||||
|
||||
type SomethingToRead = (Book | Magazine) & RouteComponentProps;
|
||||
|
||||
const Readable: React.SFC<SomethingToRead> = props => {
|
||||
if (props.kind === 'magazine') {
|
||||
return <div>magazine #{props.issue}</div>;
|
||||
}
|
||||
|
||||
return <div>magazine #{props.author}</div>;
|
||||
};
|
||||
|
||||
const RoutedReadable = withRouter(Readable);
|
||||
|
||||
<RoutedReadable kind="book" author="Hejlsberg" />;
|
||||
<RoutedReadable kind="magazine" author="Hejlsberg" />; // $ExpectError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user