Add missing types AnyIfEmpty, ThemeProps, ThemedStyledProps and StyledProps#4126
Add missing types AnyIfEmpty, ThemeProps, ThemedStyledProps and StyledProps#4126takurinton wants to merge 8 commits intostyled-components:mainfrom
Conversation
…StyledProps`, and `IntrinsicElementsKeys`
7a09f72 to
354a2ce
Compare
|
As @grubersjoe has written, the absence of I think it's also a strategy to write this in the migration guide. |
8d7ecad to
c403b3e
Compare
|
|
||
| type AnyIfEmpty<T extends object> = keyof T extends never ? any : T; | ||
|
|
||
| export interface ThemeProps<T> { |
There was a problem hiding this comment.
This could definitely be an alias to something else like ExecutionContext
There was a problem hiding this comment.
But it'd need to be on top of #4103 so we can have the first generic param to ExecutionContext be the Theme
There was a problem hiding this comment.
Should it be defined as an alias? Or should I add to the migration guide?
There was a problem hiding this comment.
@probablyup
#4103 is still WIP, so I felt it wouldn't be too late to merge this PR first.
Until then, how about exporting the conventional ThemeProps once?
What do you think??
There was a problem hiding this comment.
When I upgraded from v5 to v6, I replaced ThemeProps<T> with ExecutionContext in my codebase.
If we do decide to add this to ease upgrading that it should be aliased instead of declaring a new type. For example:
export interface ThemeProps extends ExecutionContext {}| export type ThemedStyledProps<P, T> = P & ThemeProps<T>; | ||
| export type StyledProps<P> = ThemedStyledProps<P, AnyIfEmpty<DefaultTheme>>; |
There was a problem hiding this comment.
When I upgraded from v5 to v6, I was able to replace ThemedStyledProps<P, T> with P & ExecutionContext in my codebase.
If we do want to add some aliases for the old v5 types to make upgrading easier, we could map them to the new types like this:
export type ThemedStyledProps<P> = P & ExecutionContext;There was a problem hiding this comment.
Sure, that would be fine, but it would lead to inconsistencies in the type arguments of StyledProps.
I think it's better to wait for this to be addressed.
https://github.com/styled-components/styled-components/pull/4103/files#diff-adc775db811d749ad367a5fd61454d85f453f549d088fd97ea1575c3eb3290f4R75-R76
(and, until then, the old-style types should be defined anyway.)
bcole808
left a comment
There was a problem hiding this comment.
👍 This looks reasonable to me. Aliasing these old type names from v5 to the new equivalent types in v6 should make upgrading easier for folks.
Co-authored-by: Ben Cole <[email protected]>
|
|
||
| export type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B; | ||
|
|
||
| export interface ThemeProps extends ExecutionContext {} |
There was a problem hiding this comment.
ThemeProps was generic in @types/styled-components package:
There was a problem hiding this comment.
Yes, it is.
As mentioned in #4126 (comment), it needs to be placed on top of #4103. Or merge this first and then follow.
However, in some cases it should be possible to replace it by using ExecutionContext.
|
Any blocks in this merging PR or is it still in review |
|
Any update on this? |
|
any update on this? |
|
Talk about a blast from the past. I gave up on this. 😂 But, any updates on this? |
refs #4062 #4117
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/styled-components/index.d.ts#L37-L43
Add more missing types in addition to #4117.
I added some of them.