Skip to content

Conversation

marklawlor
Copy link
Contributor

No description provided.

@Copilot Copilot AI review requested due to automatic review settings October 1, 2025 14:20
Copy link
Contributor Author

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

Copy link
Contributor

@Copilot Copilot AI left a 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 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 on lines +21 to +23
const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = {
className: "style",
};
Copy link
Preview

Copilot AI Oct 1, 2025

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 on lines +33 to +35
const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = {
className: "style",
};
Copy link
Preview

Copilot AI Oct 1, 2025

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,
Copy link
Preview

Copilot AI Oct 1, 2025

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.

>(
baseComponent: C,
mapping: M,
mapping: M = defaultMapping as M,
Copy link
Preview

Copilot AI Oct 1, 2025

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

1 participant