You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Preserve the optionality of the result if the overriden type is an object (case of chaining with `maybeSingle`)
105
-
ContainsNull<Result>extendstrue
106
-
? Ok|null
107
-
: Ok
108
-
104
+
true
109
105
/**
110
106
* Utility type to check if array types match between Result and NewResult.
111
107
* Returns either the valid NewResult type or an error message type.
@@ -117,33 +113,49 @@ export type CheckMatchingArrayTypes<Result, NewResult> =
117
113
: IsValidResultOverride<
118
114
Result,
119
115
NewResult,
120
-
NewResult,
121
116
{
122
117
Error: 'Type mismatch: Cannot cast array result to a single object. Use .returns<Array<YourType>> for array results or .single() to convert the result to a single object'
123
118
},
124
119
{
125
120
Error: 'Type mismatch: Cannot cast single object to array type. Remove Array wrapper from return type or make sure you are not using .single() up in the calling chain'
126
121
}
127
-
>
122
+
>extends infer ValidationResult
123
+
? ValidationResultextendstrue
124
+
? // Preserve the optionality of the result if the overriden type is an object (case of chaining with `maybeSingle`)
125
+
ContainsNull<Result>extendstrue
126
+
? NewResult|null
127
+
: NewResult
128
+
: // contains the error
129
+
ValidationResult
130
+
: never
128
131
129
132
typeSimplify<T>=Textendsobject ? {[KinkeyofT]: T[K]} : T
130
133
131
-
typeMergeDeep<New,Row>={
132
-
[KinkeyofNew|keyofRow]: KextendskeyofNew
134
+
// Extract only explicit (non-index-signature) keys.
135
+
typeExplicitKeys<T>={
136
+
[KinkeyofT]: stringextendsK ? never : K
137
+
}[keyofT]
138
+
139
+
typeMergeExplicit<New,Row>={
140
+
// We merge all the explicit keys which allows merge and override of types like
0 commit comments