Skip to content

Commit

Permalink
test(type): add type example
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Jan 1, 2025
1 parent ab23bb5 commit 104cecf
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions packages/core/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,47 @@ describe('Slices', () => {
}
});

const useServerStore = create(
const counter1: Slices<
{
counter
counter1: {
count: number;
increment: () => void;
};
},
'counter1'
> = (set) => ({
count: 0,
increment() {
set((draft) => {
draft.counter1.count += 1;
});
}
});

// TODO: improve type for slices
const useServerStore = create<{
counter: Slices<
{
counter: {
count: number;
increment: () => void;
};
},
'counter'
>;
counter1: Slices<
{
counter1: {
count: number;
increment: () => void;
};
},
'counter1'
>;
}>(
{
counter,
counter1
},
{
name: 'test',
Expand Down

0 comments on commit 104cecf

Please sign in to comment.