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
Products component has matches, path, url props inside.
When I am describing them in interface - I am getting error in root tsx file:
Type '{ path: string; }' is not assignable to type 'IntrinsicAttributes & ProductsProps & Readonly<Attributes & { children?: ComponentChildren; ref?: Ref | undefined; }>'.
Type '{ path: string; }' is missing the following properties from type 'ProductsProps': matches, url, idts(2322)
Of course I can make props optional, but this is a hack, not a solution
Not really, no. This is an inherent limitation of TypeScript and type safety in general. AFAIK, TS offers no mechanism to override or extend the props of child nodes. If you say ProductProps takes specific props, then they need to be supplied or marked as optional.
However, there's sort of a workaround in the Route component, if you want to appease TS:
I created a router in a way that is explained in the description:
Products
component hasmatches
,path
,url
props inside.When I am describing them in interface - I am getting error in root tsx file:
Of course I can make props optional, but this is a hack, not a solution. When I render component inside
<Route>
it will always have this props.The text was updated successfully, but these errors were encountered: