@@ -2,7 +2,6 @@ import {test} from 'vitest';
22import { zeroForTest } from '@rocicorp/zero/testing' ;
33import { builder , schema } from '../shared/schema.ts' ;
44import { mutators } from '../shared/mutators.ts' ;
5- import type { AuthData } from '../shared/auth.ts' ;
65import { defineMutator , defineMutators } from '@rocicorp/zero' ;
76import { z } from 'zod/mini' ;
87
@@ -13,7 +12,8 @@ const userSchema = z.object({
1312 role : z . union ( [ z . literal ( 'user' ) , z . literal ( 'crew' ) ] ) ,
1413} ) ;
1514
16- const mutatorsForTest = defineMutators ( {
15+ // Use the merge overload to inherit context type from the base mutators
16+ const mutatorsForTest = defineMutators ( mutators , {
1717 user : {
1818 create : defineMutator ( userSchema , async ( { tx, args} ) => {
1919 await tx . mutate . user . insert ( {
@@ -32,16 +32,14 @@ test('local mutate', async () => {
3232 cacheURL : null ,
3333 kvStore : 'mem' ,
3434 schema,
35- mutators : {
36- ...mutators ,
37- ...mutatorsForTest ,
38- } ,
35+ mutators : mutatorsForTest ,
3936 userID : 'user-1' ,
40- context : { sub : 'user-1' , role : 'user' } as AuthData | undefined ,
37+ // can't make this work using the proper type. Context always throws an error
38+ // no matter what we do.
39+ context : { sub : 'user-1' , role : 'user' } as any ,
4140 } ) ;
4241
4342 await zero . mutate (
44- // @ts -ignore - can't get context type to play nicely with the mutator definitions
4543 mutatorsForTest . user . create ( {
4644 id : 'user-1' ,
4745 login : 'holden' ,
@@ -51,8 +49,7 @@ test('local mutate', async () => {
5149 ) . client ;
5250
5351 const result = await zero . mutate (
54- // @ts -ignore - can't get context type to play nicely with the mutator definitions
55- mutators . issue . create ( {
52+ mutatorsForTest . issue . create ( {
5653 id : 'issue-1' ,
5754 title : 'Test Issue' ,
5855 description : 'This is a test issue' ,
0 commit comments