Skip to content

Extending transform only works if it is in the end of the chain #12

@imp-dance

Description

@imp-dance

Describe the bug
When using .extend, if you transform the data, and then extend onwards afterwards, the return type will be wrong.

To Reproduce

const test = createLoader({
  useQueries: () => ({
    queries: {
      query1: useCreateQuery(async () => "foo" as const),
    }
  }),
}).extend({
  transform: (data) => data.queries.query1.data,
}).extend({
  onLoading: () => <div>Loading...</div>,
})

// Resolves to useQueries return instead of transform, which is incorrect
type Data = Types.InferLoaderData<typeof test>;

Expected behavior
createLoader.extend should always resolve to correct return types.

Actual behavior
createLoader.extend does not resolve to correct return types when using transform in a .extend-chain, but not in the end of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions