Skip to content

Start: TypeScript errors when having head and beforeLoad with parameters #6325

@MaxAltena

Description

@MaxAltena

Which project does this relate to?

Start

Describe the bug

If both head and beforeLoad have parameters, the beforeLoad returns type never:

Type '({}: BeforeLoadContextOptions<Register, any, undefined, {}, {}, AnyContext, unknown, undefined>) => {}' is not assignable to type '((ctx: BeforeLoadContextOptions<Register, any, undefined, {}, {}, AnyContext, unknown, undefined>) => never) | ((ctx: BeforeLoadContextOptions<Register, ... 6 more ..., undefined>) => never) | undefined'.
  Type '({}: BeforeLoadContextOptions<Register, any, undefined, {}, {}, AnyContext, unknown, undefined>) => {}' is not assignable to type '(ctx: BeforeLoadContextOptions<Register, any, undefined, {}, {}, AnyContext, unknown, undefined>) => never'.
    Type '{}' is not assignable to type 'never'.(2322)

This only seems to happen when using TanStack Start and not with TanStack Router.

Your Example Website or App

https://stackblitz.com/edit/github-bp351gyj?file=src%2Froutes%2F__root.tsx&view=editor

Steps to Reproduce the Bug or Issue

  1. Install packages
  2. Run npm run typecheck

Expected behavior

As a developer, I don't expect to have any type-errors

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.145.10
  • OS: macOS
  • Bundler: vite
  • Bundler Version: 7.1.7

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions