Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/native/api.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
import { useContext, useState } from "react";
import { useContext, useState, type ComponentType } from "react";
import { Appearance } from "react-native";

import type { StyleDescriptor } from "react-native-css/compiler";
Expand Down Expand Up @@ -30,6 +30,10 @@ export {

export { useNativeCss };

const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = {
className: "style",
};
Comment on lines +33 to +35
Copy link

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.


/**
* Generates a new Higher-Order component the wraps the base component and applies the styles.
* This is added to the `interopComponents` map so that it can be used in the `wrapJSX` function
Expand All @@ -41,7 +45,7 @@ export const styled = <
const M extends StyledConfiguration<C>,
>(
baseComponent: C,
mapping: M,
mapping: M = defaultMapping as M,
Copy link

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.

options?: StyledOptions,
) => {
let component: any;
Expand Down
7 changes: 6 additions & 1 deletion src/web/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
createElement,
useMemo,
type ComponentPropsWithRef,
type ComponentType,
type PropsWithChildren,
} from "react";
import { Appearance } from "react-native";
Expand All @@ -17,12 +18,16 @@ import type {
import type { ReactComponent } from "../runtime.types";
import { assignStyle } from "./assign-style";

const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = {
className: "style",
};
Comment on lines +21 to +23
Copy link

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.


export const styled = <
const C extends ReactComponent,
const M extends StyledConfiguration<C>,
>(
baseComponent: C,
mapping: M,
mapping: M = defaultMapping as M,
Copy link

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.

_options?: StyledOptions,
) => {
return (props: StyledProps<ComponentPropsWithRef<C>, M>) => {
Expand Down