// Definitions by: Junyoung Clare Jang // TypeScript Version: 3.2 import * as React from 'react' import { ComponentSelector, Interpolation } from '@emotion/serialize' import { PropsOf, DistributiveOmit, Theme } from '@emotion/react' export { ArrayInterpolation, CSSObject, FunctionInterpolation } from '@emotion/serialize' export { ComponentSelector, Interpolation } /** Same as StyledOptions but shouldForwardProp must be a type guard */ export interface FilteringStyledOptions< Props, ForwardedProps extends keyof Props = keyof Props > { label?: string shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps target?: string } export interface StyledOptions { label?: string shouldForwardProp?(propName: PropertyKey): boolean target?: string } /** * @typeparam ComponentProps Props which will be included when withComponent is called * @typeparam SpecificComponentProps Props which will *not* be included when withComponent is called */ export interface StyledComponent< ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {} > extends React.FC, ComponentSelector { withComponent>>( component: C ): StyledComponent< ComponentProps & PropsOf, {}, { ref?: React.Ref> } > withComponent>>( component: C ): StyledComponent> withComponent( tag: Tag ): StyledComponent } /** * @typeparam ComponentProps Props which will be included when withComponent is called * @typeparam SpecificComponentProps Props which will *not* be included when withComponent is called */ export interface CreateStyledComponent< ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {} > { /** * @typeparam AdditionalProps Additional props to add to your styled component */ ( ...styles: Array< Interpolation< ComponentProps & SpecificComponentProps & AdditionalProps & { theme: Theme } > > ): StyledComponent< ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps > ( template: TemplateStringsArray, ...styles: Array< Interpolation > ): StyledComponent /** * @typeparam AdditionalProps Additional props to add to your styled component */ ( template: TemplateStringsArray, ...styles: Array< Interpolation< ComponentProps & SpecificComponentProps & AdditionalProps & { theme: Theme } > > ): StyledComponent< ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps > } /** * @desc * This function accepts a React component or tag ('div', 'a' etc). * * @example styled(MyComponent)({ width: 100 }) * @example styled(MyComponent)(myComponentProps => ({ width: myComponentProps.width }) * @example styled('div')({ width: 100 }) * @example styled('div')(props => ({ width: props.width }) */ export interface CreateStyled { < C extends React.ComponentClass>, ForwardedProps extends keyof React.ComponentProps = keyof React.ComponentProps >( component: C, options: FilteringStyledOptions, ForwardedProps> ): CreateStyledComponent< Pick, ForwardedProps> & { theme?: Theme }, {}, { ref?: React.Ref> } > >>( component: C, options?: StyledOptions> ): CreateStyledComponent< PropsOf & { theme?: Theme }, {}, { ref?: React.Ref> } > < C extends React.ComponentType>, ForwardedProps extends keyof React.ComponentProps = keyof React.ComponentProps >( component: C, options: FilteringStyledOptions, ForwardedProps> ): CreateStyledComponent< Pick, ForwardedProps> & { theme?: Theme } > >>( component: C, options?: StyledOptions> ): CreateStyledComponent< PropsOf & { theme?: Theme } > < Tag extends keyof JSX.IntrinsicElements, ForwardedProps extends keyof JSX.IntrinsicElements[Tag] = keyof JSX.IntrinsicElements[Tag] >( tag: Tag, options: FilteringStyledOptions ): CreateStyledComponent< { theme?: Theme; as?: React.ElementType }, Pick > ( tag: Tag, options?: StyledOptions ): CreateStyledComponent< { theme?: Theme; as?: React.ElementType }, JSX.IntrinsicElements[Tag] > } declare const styled: CreateStyled export default styled