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

add type for component #5

Merged
merged 2 commits into from
Sep 4, 2021
Merged

add type for component #5

merged 2 commits into from
Sep 4, 2021

Conversation

jay-es
Copy link
Contributor

@jay-es jay-es commented Aug 31, 2021

Added a type of styled() to accept Components.

ref #2 (comment)

src/index.d.ts Outdated
Comment on lines 60 to 83
args_0:
| string
| TemplateStringsArray
| CSSAttribute
| ((
props: P & {
theme?: any;
as?: string | number | symbol | undefined;
className?: any;
children?: any;
}
) => string | CSSAttribute),
...args_1: (
| string
| number
| ((
props: P & {
theme?: any;
as?: string | number | symbol | undefined;
className?: any;
children?: any;
}
) => string | number | CSSAttribute | undefined)
)[]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The types of the arguments are exactly the same as above.
Should I create new types and replace them?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that's probably better. I very hastily ported these because Goobers types didn't play nice with ours but it was mostly copy and paste. I appreciate you taking the time to clean this up.

Comment on lines +33 to +34
props: P &
T & {
Copy link
Contributor Author

@jay-es jay-es Sep 1, 2021

Choose a reason for hiding this comment

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

T & P
added component's props to use them in the styling function without specifying the type.

export declare function styled<T extends keyof JSX.IntrinsicElements>(
tag: T | ((props: JSX.IntrinsicElements[T]) => JSX.Element)
): <P>(
type Tagged<T> = <P>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

return type of the styled function

@jay-es jay-es requested a review from ryansolid September 1, 2021 16:52
@ryansolid ryansolid merged commit d434218 into solidjs:main Sep 4, 2021
@ryansolid
Copy link
Member

Thank you

@jay-es jay-es deleted the component-type branch September 4, 2021 02:50
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.

2 participants