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
> If the loader you extend has a `transform` function, and you are changing the `queries` function, you might need to do this to resolve the types properly:
227
+
**NOTE**:
228
+
229
+
> If the loader that you _extend from_ has a `transform` function, and you are change the `queries` function in the _extended_ loader, you might need to do the following fix to resolve the types correctly:
228
230
229
231
```typescript
230
232
const baseLoader =createLoader({
231
233
queries: () => [...],
232
234
transform: () => {i_want: "this-format"},
233
235
})
234
236
235
-
const pokemonLoader =baseLoader.extend({
237
+
// This first example is extending a loader that has a transform.
238
+
// It does not supply a new transform function
239
+
const extendedOne =baseLoader.extend(({
240
+
queries: () => [...],
241
+
}))
242
+
243
+
typeTestOne=InferLoaderData<typeofextendedOne>;
244
+
// Resolves to: { i_want: string; }
245
+
// which is incorrect. In reality it defaults to your list of queries.
246
+
247
+
// In this example, we supply a transform function as well:
248
+
const extendedTwo =baseLoader.extend({
236
249
queries: () => [...],
237
-
transform: (q) =>q, //Reapply default transform for query
250
+
transform: (q) =>q, //This is essentially the default value
> This is just a type mistake that will hopefully be fixed in the future. Both `extendedOne` and `extendedTwo` return the same format, but `extendedTwo` has the correct types.
0 commit comments