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 64fd974
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/solid/src/reactive/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ export function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner)
export type Accessor<T> = () => T;

export type Setter<in out T> = {
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
<U extends T>(
...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]
): undefined extends T ? undefined : U;
<U extends T>(value: (prev: T) => U): U;
<U extends T>(value: Exclude<U, Function>): U;
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
};

export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
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 64fd974

Please sign in to comment.