Skip to content

Instantly share code, notes, and snippets.

@jord-goldberg
Created July 7, 2021 20:15
Show Gist options
  • Save jord-goldberg/b06341bd639865d2241434b769fff1a2 to your computer and use it in GitHub Desktop.
Save jord-goldberg/b06341bd639865d2241434b769fff1a2 to your computer and use it in GitHub Desktop.
declare module 'styled-transition-group' {
import type { TransitionProps as TProps } from 'react-transition-group/Transition';
import type {
AnyStyledComponent,
DefaultTheme as Theme,
StyledComponentInnerAttrs,
StyledComponentInnerComponent,
StyledComponentInnerOtherProps,
ThemedStyledFunction,
} from 'styled-components';
type TransitionProps = {
[P in keyof TProps as string extends P ? never : P]: TProps[P]
};
type ThemedStyledComponentFactories<O extends TransitionProps> = {
[Tag in keyof JSX.IntrinsicElements]: ThemedStyledFunction<Tag, Theme, O>;
};
interface ThemedBaseStyledInterface<
O extends TransitionProps = TransitionProps
> extends ThemedStyledComponentFactories<O> {
<C extends AnyStyledComponent>(component: C): ThemedStyledFunction<
StyledComponentInnerComponent<C>,
Theme,
StyledComponentInnerOtherProps<C> & O,
StyledComponentInnerAttrs<C>
>;
<C extends keyof JSX.IntrinsicElements | React.ComponentType<any>>(
// unfortunately using a conditional type to validate that it can receive a `theme?: Theme`
// causes tests to fail in TS 3.1
component: C
): ThemedStyledFunction<C, Theme, O>;
}
const transition: ThemedBaseStyledInterface;
export default transition;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment