-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
chore(styled): let StyledOptions generic argument be optional #2333
Merged
Andarist
merged 44 commits into
emotion-js:main
from
antongolub-forks:let-styledopts-arg-be-optional
Jun 12, 2022
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
ccc955d
chore(style): let StyledOptions generic argument be optional
antongolub 29ca437
chore(native): let StyledOptions generic argument be optional
antongolub 107e017
test(types): add tests for StyledOptions iface
antongolub d163c00
feat(types): add keys assertion for StyledOptions generic
antongolub 4c5b17e
fix(styled): add StyledOptions type to CreateStyledComponent call sig…
antongolub 659f6ec
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 165a422
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 696213b
test(styled): check type StyledOpts for composite component
antongolub fae2dab
test(styled): revert erroneous changes
antongolub 2238e9e
test(styled): clarify StyledOptsBroken test case
antongolub a1775f8
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub e36ff17
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 009b7b0
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub b2e0b7a
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub b9ecb17
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 1cc73a2
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 34be1e2
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 04e367b
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 310dba8
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub b8d3039
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 5286a60
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub d889b0e
test: refactor `styledOptions` generics tests
antongolub 0fa6ee4
test: add more tests for StyledOptions
antongolub 83fae39
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub ebfbd9a
test: linting
antongolub 9e78345
test: tweak ups
antongolub 894aa3b
feat: expose FilteringStyledOptions
antongolub 43f318b
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub 27b4f2d
fix: expost `FilteringStyledOptions` from native, tweak up some tests…
antongolub c2c2c27
Merge branch 'main' into let-styledopts-arg-be-optional
antongolub d3092bb
chore: use consistent default props type for both StyledOptions and F…
antongolub 4104c2a
chore: snap #3
antongolub 5595c8d
styled.shouldForwardProp: require prop to be a string
srmagura 09df01d
Add PropertyKey->string changesets
srmagura 5f3f5e5
Remove redundant `compilerOptions`
Andarist da3a461
make `shouldForwardProp` always contravariant
Andarist a4c2a75
Merge branch 'main' into let-styledopts-arg-be-optional
Andarist d133a83
Merge branch 'main' into let-styledopts-arg-be-optional
Andarist f360473
Type fixes
Andarist ac3f8c7
Tweak `FilteringStyledOptions` and `StyledOptions` interfaces
Andarist fce092c
Change `Props` constraint
Andarist 59e8aec
Tweak type-level tests around `shouldForwardProp`
Andarist 65f4444
Merge remote-tracking branch 'srmagura/styled-prop-string' into let-s…
Andarist 682313b
add changesets
Andarist File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,10 @@ | ||
--- | ||
'@emotion/native': patch | ||
'@emotion/styled': patch | ||
--- | ||
|
||
pr: #2759 | ||
author: @srmagura | ||
author: @Andarist | ||
|
||
Change the argument of the `shouldForwardProp` option of `styled` from `PropertyKey` to `string` in the TypeScript definitions. |
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,8 @@ | ||
--- | ||
'@emotion/is-prop-valid': patch | ||
--- | ||
|
||
pr: #2759 | ||
author: @srmagura | ||
|
||
Change the type of the argument to `isPropValid` from `PropertyKey` to `string` in the TypeScript definitions. |
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,8 @@ | ||
--- | ||
'@emotion/native': patch | ||
'@emotion/styled': patch | ||
--- | ||
|
||
author: @Andarist | ||
|
||
`shouldForwardProp` has been changed from being a bivariant method to a contravariant function - it improves the type-safety for those that type this option. |
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,6 @@ | ||
--- | ||
'@emotion/native': patch | ||
'@emotion/styled': patch | ||
--- | ||
|
||
`FilteringStyledOptions` and `StyledOptions` types no longer require a type argument for the `Props` generic. |
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 |
---|---|---|
@@ -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 |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
AdditionalProps
referring to here? Maybe it is supposed to sayForwardedProps
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AdditionalProps
are declared here:emotion/packages/styled/types/base.d.ts
Line 72 in 65f4444
The problem is this:
As we might see here -
AdditionalProps
are provided to what is being returned fromstyled
but yetshouldForwardProp
has only access to what is given tostyled
.