-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't set children on Modal using TypeScript 3.3.1 #7874
Comments
Looks like TS 3.3's TSX checks that it can pass children as part of the component props (the output js passes everything in createElement's props argument). This probably means that functional components need to include children in their props interface (IModalProps in this case). The FunctionComponent in newer @types/react versions explicitly adds children to the accepted props:
|
For a workaround I was able to do the following type augmentation:
I noticed that the Dialog component didn't have this issue and saw that it was using React.StatelessComponent as the type rather then relying on the implicit type generated by the styled HOC. Putting this explicit type would fix the issue, but this makes me wonder if the return type of the styled HOC should be looked at for a possible root cause. |
I spent many time to understand where I should set this declare module.
May be some people doesn't understand too. |
Replace previous return type of (props) => JSX.Element Also added type annotations to all usages of styled due to TypeScript compiler.
* Modify styled to return StatelessComponent (#7874) Replace previous return type of (props) => JSX.Element Also added type annotations to all usages of styled due to TypeScript compiler. * Changelog
🎉This issue was addressed in #8189, which has now been successfully released as Handy links: |
🎉This issue was addressed in #8189, which has now been successfully released as Handy links: |
🎉This issue was addressed in #8189, which has now been successfully released as Handy links: |
🎉This issue was addressed in #8189, which has now been successfully released as Handy links: |
🎉This issue was addressed in #8189, which has now been successfully released as Handy links: |
🎉This issue was addressed in #8189, which has now been successfully released as Handy links: |
* Modify styled to return StatelessComponent (microsoft#7874) Replace previous return type of (props) => JSX.Element Also added type annotations to all usages of styled due to TypeScript compiler. * Changelog
I am also experiencing this issue. How do I resolve this? |
Updating to the latest version of office-ui-fabric-react (v6.166.0) worked for me |
Yes, version office-ui-fabric-react (v6.166.0) works fine |
Environment Information
Please provide a reproduction of the bug in a codepen:
Try to compile the following code using Typescript 3.3.1
Actual behavior:
Compile error
Expected behavior:
No compile error
Priorities and help requested:
Are you willing to submit a PR to fix? No
Requested priority: High
Products/sites affected: (if applicable)
The text was updated successfully, but these errors were encountered: