TanStackT
TanStack12mo ago
2 replies
skinny-azure

type that QueryOptions can be assigned to

Please! I've been stuck on this for far too long.

I want a function to accept queryOptions as an argument.

const options = queryOptions({queryKey: ["test"]});

// Doesn't work
function test(arg: QueryOptions) {}
test(options);

// Doesn't work
function test(arg: Parameters<typeof queryOptions>[0]) {}
test(options);

// Works but ...
function test(arg: QueryOptions<unknown, Error, unknown, any[]>) {
  // Than inside the function I can no longer do this
  let x = queryOptions(arg)
}

// Which is annoying because this works (outside the function):
queryOptions(queryOptions({queryKey: ["test"]))
Was this page helpful?