Skip to content

[fetch-router] Params are not typed correctly in RouteHandlers object (re-open) #10847

@GuptaSiddhant

Description

@GuptaSiddhant

Hi, great work on Remix 3 and thanks for publishing individual packages which can be used as needed.

I ran into some typescript troubles using the new fetch-router package. I created a small reproduction repo: https://github.com/GuptaSiddhant/fetch-router-test, and added a item resources.

In VSCode, the intellisence cannot infer type of the default id param in the RouteHandlers object.

  • The params object has type
    (parameter) params: Simplify<ParamsFromTokens<A["protocol"], false> & ParamsFromTokens<A["hostname"], false> & ParamsFromTokens<A["pathname"], false>>
    
  • and the params.id has type any (see attached screenshot)
    Image
  • The result is same whether I use either
    • const handlers: RouteHandlers<typeof routes> = {...}
    • const handlers = {...} satisfies RouteHandlers<typeof routes>

Env config:

  • Editor: VSCode with 0 extensions enabled
  • The reproduction project has only 2 dependencies - @remix-run/fetch-router@^0.8.0 and typescript@^5.9.0. (VSCode uses typescript from repo's node_modules)
  • There are no errors while running typecheck and node-test (router works).
  • Device: MacBook Pro M2-Pro 32GB RAM

This issue is re-opened since the last issue #10772 was resolved for me. Thanks in advance.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions