Skip to content

Commit 091ccfc

Browse files
committed
fix(postgrest): add more retro-compatibility never record
1 parent a9c6fd1 commit 091ccfc

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

packages/core/postgrest-js/src/types.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,28 @@ export type GetRpcFunctionFilterBuilderByArgs<
3636
1: IsAny<Schema> extends true
3737
? any
3838
: IsNever<Args> extends true
39-
? ExtractExactFunction<Schema['Functions'][FnName], Args>
40-
: // Otherwise, we attempt to match with one of the function definition in the union based
41-
// on the function arguments provided
42-
Args extends GenericFunction['Args']
43-
? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
44-
// we fallback to the last function definition matched by name
45-
IsNever<
46-
LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
47-
> extends true
48-
? LastOf<Schema['Functions'][FnName]>
49-
: // Otherwise, we use the arguments based function definition narrowing to get the right value
50-
LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
51-
: // If we can't find a matching function by args, we try to find one by function name
52-
ExtractExactFunction<Schema['Functions'][FnName], Args> extends GenericFunction
53-
? ExtractExactFunction<Schema['Functions'][FnName], Args>
54-
: any
39+
? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
40+
// we fallback to the last function definition matched by name
41+
IsNever<ExtractExactFunction<Schema['Functions'][FnName], Args>> extends true
42+
? LastOf<Schema['Functions'][FnName]>
43+
: ExtractExactFunction<Schema['Functions'][FnName], Args>
44+
: Args extends Record<PropertyKey, never>
45+
? LastOf<Schema['Functions'][FnName]>
46+
: // Otherwise, we attempt to match with one of the function definition in the union based
47+
// on the function arguments provided
48+
Args extends GenericFunction['Args']
49+
? // This is for retro compatibility, if the funcition is defined with an single return and an union of Args
50+
// we fallback to the last function definition matched by name
51+
IsNever<
52+
LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
53+
> extends true
54+
? LastOf<Schema['Functions'][FnName]>
55+
: // Otherwise, we use the arguments based function definition narrowing to get the right value
56+
LastOf<FindMatchingFunctionByArgs<Schema['Functions'][FnName], Args>>
57+
: // If we can't find a matching function by args, we try to find one by function name
58+
ExtractExactFunction<Schema['Functions'][FnName], Args> extends GenericFunction
59+
? ExtractExactFunction<Schema['Functions'][FnName], Args>
60+
: any
5561
}[1] extends infer Fn
5662
? // If we are dealing with an non-typed client everything is any
5763
IsAny<Fn> extends true

0 commit comments

Comments
 (0)