Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add other missing types#4127

Draft
takurinton wants to merge 2 commits intostyled-components:mainfrom
takurinton:add-other-missing-types
Draft

Add other missing types#4127
takurinton wants to merge 2 commits intostyled-components:mainfrom
takurinton:add-other-missing-types

Conversation

@takurinton
Copy link
Contributor

refs #4062 #4117 #4126

Add more missing types in addition to #4126.

I added some of them.

  • FlattenInterpolation
  • FlattenSimpleInterpolation
  • InterpolationFunction
  • SimpleInterpolation
  • StyledComponentBase

I also added the types they depend on.

referenced here https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/styled-components/index.d.ts

@takurinton takurinton marked this pull request as ready for review August 10, 2023 23:22
@takurinton takurinton marked this pull request as draft August 10, 2023 23:57
@takurinton takurinton marked this pull request as ready for review August 11, 2023 00:02
// Distribute unions early to avoid quadratic expansion
P extends any ? OmitU<ReactDefaultizedProps<C, P> & O, A> & Partial<PickU<P & O, A>> : never;

export type StyledComponentProps<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit overwhelming to add to the list of things to maintain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too (I thought it was difficult when I wrote it)

I'm having a hard time deciding how to maintain this complicated type definition, or considering alternatives, so I'd like some advice.
what do you think you should do

| InterpolationFunction<Props>
| FlattenInterpolation<Props>;

export type InterpolationFunction<P extends object> = (props: P) => Interpolation<P>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InterpolationFunction and other types here looks like they come from the Definitely Typed definitions for v5.

InterpolationFunction from v5 can be replaced with StyleFunction from v6.

Maybe we can either write a migration guide from v5 to v6, or consider just aliasing some of the types that are 1 to 1 replacements?

I don't think we should copy all of the types over from Definitely Typed because there are new, similar types defined in v6. It might get really confusing to maintain two very similar copies of the same type but with different names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, and thank you!!
I didn't realize the new types were defined because I only referred to the migration guide to define the types.

consider just aliasing some of the types that are 1 to 1 replacements?

For now, I'll try aliasing some of the types that are 1 to 1 replacements. thank you!!

@takurinton takurinton marked this pull request as draft August 19, 2023 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants