@@ -8,15 +8,22 @@ type User = {
88 name : string
99}
1010
11+ type Message = {
12+ id : number
13+ text : string
14+ }
15+
1116const app = feathers < {
1217 users : MemoryService < User >
13- messages : MemoryService
18+ messages : MemoryService < Message >
1419} > ( )
1520
1621type App = typeof app
17- type Ctx = HookContext < App , MemoryService < User > >
22+ type AppCtx = HookContext < App >
23+ type UserCtx = HookContext < App , MemoryService < User > >
1824
19- const context = { } as Ctx
25+ const context = { } as UserCtx
26+ const appContext = { } as AppCtx
2027
2128it ( 'options overload accepts valid options' , ( ) => {
2229 checkContext ( context , { type : 'before' } )
@@ -34,6 +41,22 @@ it('options overload rejects invalid type', () => {
3441 checkContext ( context , { type : 'invalid' } )
3542} )
3643
44+ it ( 'options overload accepts valid path for app-level context' , ( ) => {
45+ checkContext ( appContext , { path : 'users' } )
46+ checkContext ( appContext , { path : 'messages' } )
47+ checkContext ( appContext , { path : [ 'users' , 'messages' ] } )
48+ } )
49+
50+ it ( 'options overload rejects invalid path for service-specific context' , ( ) => {
51+ // @ts -expect-error "messages" is not valid when context is narrowed to MemoryService<User>
52+ checkContext ( context , { path : 'messages' } )
53+ } )
54+
55+ it ( 'options overload rejects invalid path for app-level context' , ( ) => {
56+ // @ts -expect-error "nonExistent" is not a valid service path
57+ checkContext ( appContext , { path : 'nonExistent' } )
58+ } )
59+
3760it ( 'positional overload accepts valid args' , ( ) => {
3861 checkContext ( context , 'before' )
3962 checkContext ( context , [ 'before' , 'after' ] )
0 commit comments