(tag: React.ElementType, options?: StyledOptions<any>)
| 16 | export type { CreateStyled, StyledComponent, StyledOptions, StyledTags } from '@emotion/styled'; |
| 17 | |
| 18 | function styled(tag: React.ElementType, options?: StyledOptions<any>) { |
| 19 | // Emotion's `styled` overloads each expect a specific tag/component shape; |
| 20 | // none accept the broadened `React.ElementType` union, so cast the passthrough. |
| 21 | const stylesFactory = emStyled(tag as any, options); |
| 22 | |
| 23 | if (process.env.NODE_ENV !== 'production') { |
| 24 | return (...styles: any[]) => { |
| 25 | const component = typeof tag === 'string' ? `"${tag}"` : 'component'; |
| 26 | if (styles.length === 0) { |
| 27 | console.error( |
| 28 | [ |
| 29 | `MUI: Seems like you called \`styled(${component})()\` without a \`style\` argument.`, |
| 30 | 'You must provide a `styles` argument: `styled("div")(styleYouForgotToPass)`.', |
| 31 | ].join('\n'), |
| 32 | ); |
| 33 | } else if (styles.some((style) => style === undefined)) { |
| 34 | console.error( |
| 35 | `MUI: the styled(${component})(...args) API requires all its args to be defined.`, |
| 36 | ); |
| 37 | } |
| 38 | return stylesFactory(...styles); |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | return stylesFactory; |
| 43 | } |
| 44 | |
| 45 | export default styled as unknown as CreateStyled; |
| 46 |
no outgoing calls
searching dependent graphs…