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
interfaceChildProps{val: number;}interfaceParentProps{val: number;str: string;}constChildComponent=(props: ChildProps)=><div>{props.val}</div>;
constParentComponent=(props: ParentProps)=><ChildComponent{...props}/>;// ERROR: ~~~~~~~~~~ Property 'str' does not exist on type 'IntrinsicAttributes & ChildProps'.functionchild(props: ChildProps){}functionparent(props: ParentProps){child(props);// OK}
Expected behavior:
I updated my project from TypeScript 2.2 --> 2.3.2 and began getting errors along these lines.
I'd expect passing props via JSX to be similar to passing a parameter to a function: it's OK so long as the parameter is compatible with the type that the function specifies. But this doesn't seem to be the case with JSX. The attributes you pass must match the Props type precisely. No additional attributes are allowed.
But the React runtime is fine with additional attributes and this makes it difficult to use spread props.
This might be by design, see #10393. But it's strange that the analogy with passing parameters to a function breaks down, especially since this is exactly how JSX is implemented.
TypeScript Version: 2.3.2
Code
Expected behavior:
I updated my project from TypeScript 2.2 --> 2.3.2 and began getting errors along these lines.
I'd expect passing props via JSX to be similar to passing a parameter to a function: it's OK so long as the parameter is compatible with the type that the function specifies. But this doesn't seem to be the case with JSX. The attributes you pass must match the Props type precisely. No additional attributes are allowed.
But the React runtime is fine with additional attributes and this makes it difficult to use spread props.
This might be by design, see #10393. But it's strange that the analogy with passing parameters to a function breaks down, especially since this is exactly how JSX is implemented.
cc @jacobbaskin
Actual behavior:
The text was updated successfully, but these errors were encountered: