TanStackT
TanStack9mo ago
9 replies
faint-white

Typing a factory function for createFileRoute

Hello everyone, I am trying to create a factory function that returns a createFileRoute with some options predefined, but I am not able to type it correctly with all the generics. Here is an example what I am trying to accomplish:

function customCreateFileRoute(path) {
  return (options) => {
    return createFileRoute(path)({
      ...options,
      staticData: {
        title: 'Test',
        ...options.staticData,
      },
    })
  }
}


Can someone help me with the correct types? Thanks in advance.
Was this page helpful?