Skip to content

fix: make styled mapping optional#206

Merged
marklawlor merged 1 commit into
mainfrom
10-02-fix_make_styled_mapping_optional
Oct 1, 2025
Merged

fix: make styled mapping optional#206
marklawlor merged 1 commit into
mainfrom
10-02-fix_make_styled_mapping_optional

Conversation

@marklawlor

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings October 1, 2025 14:20

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 the styled 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.

Comment thread src/web/api.tsx
Comment on lines +21 to +23
const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = {
className: "style",
};

Copilot AI Oct 1, 2025

Copy link

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.
Comment thread src/native/api.tsx
Comment on lines +33 to +35
const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = {
className: "style",
};

Copilot AI Oct 1, 2025

Copy link

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.
Comment thread src/web/api.tsx
>(
baseComponent: C,
mapping: M,
mapping: M = defaultMapping as M,

Copilot AI Oct 1, 2025

Copy link

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.

Suggested change
mapping: M = defaultMapping as M,
mapping: M,

Copilot uses AI. Check for mistakes.
Comment thread src/native/api.tsx
>(
baseComponent: C,
mapping: M,
mapping: M = defaultMapping as M,

Copilot AI Oct 1, 2025

Copy link

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.

Suggested change
mapping: M = defaultMapping as M,
mapping: M,

Copilot uses AI. Check for mistakes.
@marklawlor marklawlor merged commit d6f42ab into main Oct 1, 2025
7 checks passed

Copy link
Copy Markdown
Contributor Author

Merge activity

@marklawlor marklawlor deleted the 10-02-fix_make_styled_mapping_optional branch October 1, 2025 14:24
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