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
// and by using the indexer P['attributesToRetrieve'], we're able to pick the type of `attributesToRetrieve`
111
+
// and check whether the attribute is a single key present in the generic
112
+
hits: P['attributesToRetrieve']extendskeyofT// `attributesToRetrieve` contains one single key
93
113
? Array<
114
+
// So we return an array of
94
115
Hit<
116
+
// hits
117
+
// We exclude the `attributesToRetrieve` first from the generic, and then we exclude what has been returned to make sure we only Pick the `attributesToRetrieve` on the generic T
: P['attributesToRetrieve']extendsArray<infer K>// Otherwise if P['attributesToRetrieve'] is an array, we use `infer K` to extract the keys in the array in place
122
+
? Array<Hit<Pick<T,Exclude<keyofT,Exclude<keyofT,K>>>>>// Same extraction method as above when we have a single `attributesToRetrieve`
123
+
: Array<Hit<T>>// Finally return the full type as `attributesToRetrieve` is neither a single key nor an array of keys
0 commit comments