Skip to content

[Bug?]: Remove index signature on AvailableRoutes #8908

@orta

Description

@orta

What's not working?

In @redwoodjs/router there is this export:

export interface AvailableRoutes {
    [key: string]: (args?: Record<string | number, string | number | boolean>) => string;
}

Which is responsible for almost all of my broken web deploys, because it allows for any possible named function and TypeScript cannot check for whether this is correct - meaning if you ever rename/remove a route then you get a runtime crash and it is not detectable via a build nor type check.

Given that you get a runtime error if it is not the type shape explicitly added in .redwood/types/includes/web-routerRoutes then it should really default to an empty object:

export interface AvailableRoutes {}

How do we reproduce the bug?

Make a typo on the routes object in web

What's your environment? (If it applies)

N/A

Are you interested in working on this?

  • I'm interested in working on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/needs-infoMore information is needed for reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions