You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
however if you try to use "spread" syntax, it's a type error:
declareconstinfoProps: InfoProps<Info{...infoProps}/>/* . ^^^^^^^^^^^^^^Type '{ status: "hidden" | "visible"; }' is not assignable to type '(IntrinsicAttributes & { status: "hidden"; }) | (IntrinsicAttributes & { status: "visible"; conte...'. Type '{ status: "hidden" | "visible"; }' is not assignable to type 'IntrinsicAttributes & { status: "visible"; content: string; }'. Type '{ status: "hidden" | "visible"; }' is not assignable to type '{ status: "visible"; content: string; }'. Types of property 'status' are incompatible. Type '"hidden" | "visible"' is not assignable to type '"visible"'. Type '"hidden"' is not assignable to type '"visible"'.*/
As I understand it, this should be no different semantically from
React.createElement(Info,infoProps)
which the compiler approves of.
The text was updated successfully, but these errors were encountered:
Just hit on exactly the same problem, reproducible in 2.4.1 and 2.5.2. Another example:
importReact,{SFC}from'react';{typeCommonProps={common: string};typeProps=CommonProps&({type: 'foo'}|{type: 'bar';message: string});constButton: SFC<Props>=(props)=>null;constOtherButton1: SFC<Props>=(props)=>React.createElement(Button,props);// Type '"foo"' is not assignable to type '"bar"'.constOtherButton2: SFC<Props>=(props)=><Button{...props}/>;}
TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
It's often useful to define a React component's properties as a union type, e.g.
When constructing elements from this component, it works fine in concrete cases:
however if you try to use "spread" syntax, it's a type error:
As I understand it, this should be no different semantically from
which the compiler approves of.
The text was updated successfully, but these errors were encountered: