Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

styled.shouldForwardProp: require prop to be a string #2759

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/good-cars-roll.md
@@ -0,0 +1,6 @@
---
'@emotion/native': patch
'@emotion/styled': patch
---

Change the argument of the `shouldForwardProp` option of `styled` from `PropertyKey` to `string` in the TypeScript definitions.
5 changes: 5 additions & 0 deletions .changeset/purple-ladybugs-think.md
@@ -0,0 +1,5 @@
---
'@emotion/is-prop-valid': patch
---

Change the type of the argument to `isPropValid` from `PropertyKey` to `string` in the TypeScript definitions.
2 changes: 1 addition & 1 deletion packages/is-prop-valid/types/index.d.ts
@@ -1,5 +1,5 @@
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
// TypeScript Version: 2.1

declare function isPropValid(string: PropertyKey): boolean
declare function isPropValid(prop: string): boolean
export default isPropValid
12 changes: 7 additions & 5 deletions packages/native/types/base.d.ts
Expand Up @@ -61,13 +61,13 @@ export type Interpolation<
/** Same as StyledOptions but shouldForwardProp must be a type guard */
export interface FilteringStyledOptions<
Props,
ForwardedProps extends keyof Props = keyof Props
ForwardedProps extends keyof Props & string = keyof Props & string
> {
shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps
shouldForwardProp?(propName: string): propName is ForwardedProps
}

export interface StyledOptions<Props> {
shouldForwardProp?(propName: PropertyKey): boolean
shouldForwardProp?(propName: string): boolean
}

/**
Expand Down Expand Up @@ -146,7 +146,8 @@ export interface CreateStyledComponent<
export interface CreateStyled {
<
C extends React.ComponentClass<React.ComponentProps<C>>,
ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>
ForwardedProps extends keyof React.ComponentProps<C> &
string = keyof React.ComponentProps<C> & string
>(
component: C,
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
Expand Down Expand Up @@ -175,7 +176,8 @@ export interface CreateStyled {

<
C extends React.ComponentType<React.ComponentProps<C>>,
ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>
ForwardedProps extends keyof React.ComponentProps<C> &
string = keyof React.ComponentProps<C> & string
>(
component: C,
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
Expand Down
15 changes: 9 additions & 6 deletions packages/styled/types/base.d.ts
Expand Up @@ -16,16 +16,16 @@ export { ComponentSelector, Interpolation }
/** Same as StyledOptions but shouldForwardProp must be a type guard */
export interface FilteringStyledOptions<
Props,
ForwardedProps extends keyof Props = keyof Props
ForwardedProps extends keyof Props & string = keyof Props & string
> {
label?: string
shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps
shouldForwardProp?(propName: string): propName is ForwardedProps
target?: string
}

export interface StyledOptions<Props> {
label?: string
shouldForwardProp?(propName: PropertyKey): boolean
shouldForwardProp?(propName: string): boolean
target?: string
}

Expand Down Expand Up @@ -118,7 +118,8 @@ export interface CreateStyledComponent<
export interface CreateStyled {
<
C extends React.ComponentClass<React.ComponentProps<C>>,
ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>
ForwardedProps extends keyof React.ComponentProps<C> &
string = keyof React.ComponentProps<C> & string
>(
component: C,
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
Expand Down Expand Up @@ -147,7 +148,8 @@ export interface CreateStyled {

<
C extends React.ComponentType<React.ComponentProps<C>>,
ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>
ForwardedProps extends keyof React.ComponentProps<C> &
string = keyof React.ComponentProps<C> & string
>(
component: C,
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
Expand All @@ -168,7 +170,8 @@ export interface CreateStyled {

<
Tag extends keyof JSX.IntrinsicElements,
ForwardedProps extends keyof JSX.IntrinsicElements[Tag] = keyof JSX.IntrinsicElements[Tag]
ForwardedProps extends keyof JSX.IntrinsicElements[Tag] &
string = keyof JSX.IntrinsicElements[Tag] & string
>(
tag: Tag,
options: FilteringStyledOptions<JSX.IntrinsicElements[Tag], ForwardedProps>
Expand Down