File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
apps/meteor/app/api/server Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -39,3 +39,23 @@ it('Should return the expected type', () => {
3939 > ;
4040 true as test ;
4141} ) ;
42+
43+ describe ( 'ExtractRoutesFromAPI' , ( ) => {
44+ it ( 'Should extract correct function signature when query is not present' , ( ) => {
45+ type APIWithNeverQuery = APIClass <
46+ '/v1' ,
47+ {
48+ method : 'GET' ;
49+ path : '/v1/endpoint.test' ;
50+ response : {
51+ 200 : ValidateFunction < unknown > ;
52+ } ;
53+ authRequired : true ;
54+ }
55+ > ;
56+ type ExpectedFunctionSignature = Expect <
57+ ShallowEqual < ExtractRoutesFromAPI < APIWithNeverQuery > [ '/v1/endpoint.test' ] [ 'GET' ] , ( ) => unknown >
58+ > ;
59+ true as ExpectedFunctionSignature ;
60+ } ) ;
61+ } ) ;
Original file line number Diff line number Diff line change @@ -73,7 +73,9 @@ type ConvertToRoute<TRoute extends MinimalRoute> = {
7373 [ K in TRoute [ 'path' ] ] : {
7474 [ K2 in Extract < TRoute , { path : K } > [ 'method' ] ] : K2 extends 'GET'
7575 ? (
76- params : ExtractValidation < Extract < TRoute , { path : K ; method : K2 } > [ 'query' ] > ,
76+ ...args : [ ExtractValidation < Extract < TRoute , { path : K ; method : K2 } > [ 'query' ] > ] extends [ never ]
77+ ? [ params ?: never ]
78+ : [ params : ExtractValidation < Extract < TRoute , { path : K ; method : K2 } > [ 'query' ] > ]
7779 ) => ExtractValidation < Extract < TRoute , { path : K ; method : K2 } > [ 'response' ] [ 200 ] >
7880 : K2 extends 'POST'
7981 ? (
You can’t perform that action at this time.
0 commit comments