-
Notifications
You must be signed in to change notification settings - Fork 11
fix: make styled mapping optional #206
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
Conversation
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.
Pull Request Overview
This pull request makes the mapping
parameter optional in the styled
function by providing a default mapping configuration. The change allows developers to use the styled
function without explicitly providing a mapping, defaulting to a standard className
to style
mapping.
- Added default mapping configuration for both web and native platforms
- Made the
mapping
parameter optional in thestyled
function signature - Imported
ComponentType
type to support the default mapping type definition
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
src/web/api.tsx | Added default mapping constant and made mapping parameter optional |
src/native/api.tsx | Added default mapping constant and made mapping parameter optional |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = { | ||
className: "style", | ||
}; |
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.
The defaultMapping
uses a generic type that may not match all component types used with styled
. Consider using a more flexible type or making it a function that returns the appropriate mapping type.
Copilot uses AI. Check for mistakes.
const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = { | ||
className: "style", | ||
}; |
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.
The defaultMapping
uses a generic type that may not match all component types used with styled
. Consider using a more flexible type or making it a function that returns the appropriate mapping type.
Copilot uses AI. Check for mistakes.
>( | ||
baseComponent: C, | ||
mapping: M, | ||
mapping: M = defaultMapping as M, |
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.
Using type assertion as M
to force the default mapping type could lead to runtime errors if the default mapping is incompatible with the expected mapping type. Consider using a type-safe default or validation.
mapping: M = defaultMapping as M, | |
mapping: M, |
Copilot uses AI. Check for mistakes.
>( | ||
baseComponent: C, | ||
mapping: M, | ||
mapping: M = defaultMapping as M, |
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.
Using type assertion as M
to force the default mapping type could lead to runtime errors if the default mapping is incompatible with the expected mapping type. Consider using a type-safe default or validation.
mapping: M = defaultMapping as M, | |
mapping: M, |
Copilot uses AI. Check for mistakes.
Merge activity
|
No description provided.