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
All components were refactored to use type from interface following #19850 they are always inlined during build by typescript. The addition of IntrinsicShorthandProps in #19642 is another major factor.
The resulting props for the root slot includes a property css (as seen in the above error). Here is the type declaration in @emotion/core:
declare module 'react'{interfaceDOMAttributes<T>{🚨🚨🚨🚨Thisleaksintothepropsof `PopoverSurface`
css?: InterpolationWithTheme<any>}}declare global {namespaceJSX{/** * Do we need to modify `LibraryManagedAttributes` too, * to make `className` props optional when `css` props is specified? */interfaceIntrinsicAttributes{🚨🚨🚨🚨Thisleaksintothepropsof `PopoverSurface`
css?: InterpolationWithTheme<any>}}}
The css property leaks into the expanded type. There is no way for typescript to exclude type roots in the build process and a way to do so is an open issue microsoft/TypeScript#37053.
Solutions
Explicitly typing the return of forwardRef which is already proposed in #19923
⚠️⚠️ This does mean that types will not leak in the future thanks to type inlining, read article in the next section
Components can't be used in simple create-react-app projects with the following error:
What
To make
PopoverSurface
work the code needs to be written this way:otherwise TS will continuously error
Why ?
All components were refactored to use
type
frominterface
following #19850 they are always inlined during build by typescript. The addition ofIntrinsicShorthandProps
in #19642 is another major factor.Let's look at the example of
PopoverSurface
The resulting props for the
root
slot includes a propertycss
(as seen in the above error). Here is the type declaration in@emotion/core
:The
css
property leaks into the expanded type. There is no way for typescript to exclude type roots in the build process and a way to do so is an open issue microsoft/TypeScript#37053.Solutions
Explicitly typing the return of
forwardRef
which is already proposed in #19923Use interfaces over types
interface
are not inlined during the typescript build process and is why Bloomberg has advocated not usingtype
altogether: https://www.techatbloomberg.com/blog/10-insights-adopting-typescript-at-scale/The text was updated successfully, but these errors were encountered: