Closed
Description
TypeScript Version: 2.6.0-dev.201xxxxx
Code
import * as React from "react";
import { SFC } from "react";
type CommonProps = { common: string };
type Props = CommonProps &
({ type: 'foo' } | { type: 'bar'; message: string });
const Button: SFC<Props> = (props) => null;
const OtherButton1: SFC<Props> = (props) => {
const props2 = {...props};
return React.createElement(Button, props2); // `props2` should be fine, just like `props` is
};
Expected behavior:
No errors
Actual behavior:
test.tsx(13,40): error TS2345: Argument of type '{ common: string; type: "foo"; children?: ReactNode; } | { common: string; type: "bar"; message: ...'
is not assignable to parameter of type '(Attributes & CommonProps & { type: "foo"; }) | (Attributes & CommonProps & { type: "bar"; messag...'.
Type '{ common: string; type: "foo"; children?: ReactNode; }' is not assignable to type '(Attributes & CommonProps & { type: "foo"; }) | (Attributes
& CommonProps & { type: "bar"; messag...'.
Object literal may only specify known properties, and 'children' does not exist in type 'Attributes & CommonProps & { type: "foo"; }'.
Found when revisiting some test code for something else.