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 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:
254
-
255
-
```typescript
256
-
const baseLoader =createLoader({
257
-
queries: () => [...],
258
-
transform: () => {i_want: "this-format"},
259
-
})
260
-
261
-
// This first example is extending a loader that has a transform.
262
-
// It does not supply a new transform function
263
-
const extendedOne =baseLoader.extend(({
264
-
queries: () => [...],
265
-
}))
266
-
267
-
typeTestOne=InferLoaderData<typeofextendedOne>;
268
-
// Resolves to: { i_want: string; }
269
-
// which is incorrect. In reality it defaults to your list of queries.
270
-
271
-
// In this example, we supply a transform function as well:
272
-
const extendedTwo =baseLoader.extend({
273
-
queries: () => [...],
274
-
transform: (q) =>q, // This is essentially the default value
275
-
});
276
-
277
-
typeTestTwo=InferLoaderData<typeofextendedTwo>;
278
-
// Resolves to: readonly [UseQueryResult<...>]
279
-
// which is correct.
280
-
```
281
-
282
-
> 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