Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Huliiiiii committed Oct 1, 2024
1 parent ab424d5 commit ef8f62a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/solid/src/reactive/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,8 @@ export function untrack<T>(fn: Accessor<T>): T {
export type ReturnTypes<T> = T extends readonly Accessor<unknown>[]
? { [K in keyof T]: T[K] extends Accessor<infer I> ? I : never }
: T extends Accessor<infer I>
? I
: never;
? I
: never;

// transforms a tuple to a tuple of accessors in a way that allows generics to be inferred
export type AccessorArray<T> = [...Extract<{ [K in keyof T]: Accessor<T[K]> }, readonly unknown[]>];
Expand Down
9 changes: 9 additions & 0 deletions packages/solid/test/signals.type-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,13 @@ interface KobalteBaseSelectProps<Option, OptGroup = never> {
interface KobaltSingleSelectProps<T> {
value?: T | null;
onChange?: (value: T) => void;
multiple?: false;
}

interface KobaltMultiSelectProps<T> {
value?: T[];
onChange?: (value: T[]) => void;
multiple?: true;
}

type KobaltSelectProps<Option, OptGroup = never> = (
Expand All @@ -903,8 +905,15 @@ type KobaltSelectProps<Option, OptGroup = never> = (
type fruits = "apple" | "banana" | "orange";
const fruits: fruits[] = ["apple", "banana", "orange"];
const [fruit, setFruit] = createSignal<fruits>("apple");
const [fruitArr, setFruitArr] = createSignal<fruits[]>(["apple"]);
function kobalteSelect<T>(props: KobaltSelectProps<T>) {}
kobalteSelect({ value: fruit(), onChange: setFruit, options: fruits });
kobalteSelect<fruits>({
value: fruitArr(),
onChange: setFruitArr,
options: fruits,
multiple: true
});

//////////////////////////////////////////////////////////////////////////
// test explicit generic args ////////////////////////////////////////////
Expand Down

0 comments on commit ef8f62a

Please sign in to comment.