-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new overload for CreateStyled which supports shouldForwardProp…
… being a custom type guard (#1624) * Created overload of create styled which supports shouldForwardProp being a custom type guard * Add test case for filtering conflicting props * Add docs and overload for normal components * Update .changeset/polite-tips-attend/changes.md Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
1 parent
99c6b7e
commit ad77ed2
Showing
6 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"releases": [{ "name": "@emotion/styled", "type": "minor" }], | ||
"dependents": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Added `CreateStyled` overload to handle when `shouldForwardProp` is a custom type guard for intrinsic props. | ||
|
||
As an example, if you want to override the type of the `color` prop: | ||
|
||
```ts | ||
export const Box = styled('div', { | ||
shouldForwardProp: ( | ||
propName | ||
): propName is Exclude<keyof JSX.IntrinsicElements['div'], 'color'> => | ||
propName !== 'color' | ||
})<{ color: Array<string> }>(props => ({ | ||
color: props.color[0] | ||
})) | ||
;<Box color={['green']} /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters