Skip to content

Commit

Permalink
refactor: fix remaining type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Jul 3, 2023
1 parent f0762b3 commit fc37542
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/styled-components/src/models/StyledComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function createStyledComponent<
*/
let WrappedStyledComponent = React.forwardRef(forwardRefRender) as unknown as IStyledComponent<
'web',
OuterProps
any
> &
Statics;
WrappedStyledComponent.attrs = finalAttrs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default (InlineStyle: IInlineStyleConstructor<any>) => {
*/
let WrappedStyledComponent = React.forwardRef(forwardRef) as unknown as IStyledComponent<
'native',
OuterProps
any
> &
Statics;

Expand Down
12 changes: 7 additions & 5 deletions packages/styled-components/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import createWarnTooManyClasses from './utils/createWarnTooManyClasses';

export { CSS, DefaultTheme };

interface ExoticComponentWithDisplayName<P = any> extends React.ExoticComponent<P> {
interface ExoticComponentWithDisplayName<P extends object = {}> extends React.ExoticComponent<P> {
defaultProps?: Partial<P>;
displayName?: string;
}
Expand All @@ -22,13 +22,15 @@ export type BaseObject = {};
// from https://stackoverflow.com/a/69852402
export type OmitNever<T> = { [K in keyof T as T[K] extends never ? never : K]: T[K] };

type FastOmit<T, U extends string | number | symbol> = {
type FastOmit<T extends object, U extends string | number | symbol> = {
[K in keyof T as K extends U ? never : K]: T[K];
}
};

export type Runtime = 'web' | 'native';

export type AnyComponent<P = any> = ExoticComponentWithDisplayName<P> | React.ComponentType<P>;
export type AnyComponent<P extends object = any> =
| ExoticComponentWithDisplayName<P>
| React.ComponentType<P>;

export type KnownTarget = Exclude<keyof JSX.IntrinsicElements, 'symbol' | 'object'> | AnyComponent;

Expand Down Expand Up @@ -199,7 +201,7 @@ export interface IStyledComponent<R extends Runtime, Props extends object = Base
extends PolymorphicComponent<R, Props>,
IStyledStatics<R, Props>,
StyledComponentBrand {
defaultProps?: Partial<Substitute<ExecutionProps, Props>>;
defaultProps?: ExecutionProps & Partial<Props>;
toString: () => string;
}

Expand Down

0 comments on commit fc37542

Please sign in to comment.