In what to me seems like two similar setups, on one machine I was allowed to call
<MyApp
accountId={this.props.accountId}
children={toggleButton} />
Where MyApp had the class signature
export interface IMyAppProps {
accountId: string;
dispatch: any;
}
class MyApp extends React.Component<IMyAppProps, IMyAppState> {
On the other machine, running npm run-script build
fails with
TypeScript build error TS2322: Type ' ... ' is not assignable to type ' ... '
Property 'children' does not exist on type 'IntrinsicAttributes & Pick<IMyAppProps, "accountId">'
Versions used on both machines react-scripts-ts 4.0.8, typescript 3.4.5.
Changing the class definition to this made it work on both machines
class MyApp extends React.Component<React.PropsWithChildren<IMyAppProps>, IMyAppState> {
I am unsure why it works in one setup and not the other. When do I wrap my props interface in React.PropsWithChildren
?
My best guess would be that the change is to be found in a typings file for React or for a React-related package.