Skip to content

Fix intellisense/completions for partial route parameter objects#880

Merged
bakerkretzmar merged 12 commits into
2.xfrom
autocomplete-missing-required
Jun 23, 2026
Merged

Fix intellisense/completions for partial route parameter objects#880
bakerkretzmar merged 12 commits into
2.xfrom
autocomplete-missing-required

Conversation

@bakerkretzmar

@bakerkretzmar bakerkretzmar commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes #803, where route parameter names are not suggested/completed inside route() calls until all the route's required parameters are provided.

There are a few different pieces to this:

  • The core fix was just moving the config-only route(undefined, undefined, ...) overloaded type definition so that's it's defined last. This is enough to make intellisense find the earlier overloads and autocomplete params from them.
  • This stopped basic route name autocomplete from working, so to fix that I added an additional overload at the beginning to match just a route name and no other arguments.
  • When not in strict mode (strict and strictNullChecks missing from tsconfig.json or set to false), calling route(undefined, ...) does match the earlier overloads, and incorrectly appears to return a RouteUrl instead of a Router. Changing the name parameters to T & {} fixes this, preventing undefined from matching those params. This is kinda ugly but improves compatibility and I'm confident the tests we have prove it works fine.
  • Finally, I added an additional very broad overload at the end so that the derived parameter and return types of the route function match everything it actually allows at runtime, so that things like wrapper/helper functions around route can reference its types.

This PR also finally adds real intellisense/autocompletion tests! We spin up a full TypeScript language service, pass it some fixture code, and assert against what completions it says it will generate.

@bakerkretzmar bakerkretzmar merged commit a5b718e into 2.x Jun 23, 2026
34 checks passed
@bakerkretzmar bakerkretzmar deleted the autocomplete-missing-required branch June 23, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

route() calls with missing required parameters have no IDE suggestions/completions on any parameters

1 participant