solid icon indicating copy to clipboard operation
solid copied to clipboard

Fix `For` component `keyed` prop type

Open scythewyvern opened this issue 7 months ago • 1 comments

Summary

looks like there was a small type error and because of that in the <For /> component inside the keyed prop we were getting the array instead of the array element

How did you test this change?

current mapArray function types:

export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options?: {
    keyed?: boolean | ((item: Item) => any);
    fallback?: Accessor<any>;
}): Accessor<MappedItem[]>;

current For types:

export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
    each: T | undefined | null | false;
    fallback?: JSX.Element;
    keyed?: boolean | ((item: T) => any);
    children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
}): JSX.Element;

fixed For types:

export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
    each: T | undefined | null | false;
    fallback?: JSX.Element;
    keyed?: boolean | ((item: T[number]) => any);
    children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
}): JSX.Element;

notice that keyed has (item: T[number]) => any instead of (item: T) => any

scythewyvern avatar Jun 04 '25 16:06 scythewyvern

⚠️ No Changeset found

Latest commit: 4598d718ed177d1e5bd52b6f4b30c7b6498b91cc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jun 04 '25 16:06 changeset-bot[bot]

Thanks

ryansolid avatar Jun 23 '25 23:06 ryansolid