Skip to content

[Bug]: Type of loaderData wrong when returning redirect in the loader (action as well)Β #12335

@rapnuss

Description

@rapnuss

What version of React Router are you using?

7

Steps to Reproduce

export const loader = () => {
  if (Math.random() < 0.5) {
    return redirect('/')
  }
  return {some: 'data'}
}

export default function Home() {
  const data = userLoaderData<typeof loader>()
  return <>{data.some}</> // ERROR: some not in type {headers: ...}
}

Expected Behavior

some should be defined on the loaderData

Actual Behavior

there is a typescript error

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions