question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inferred path parameters fallback to "DefaultParamsType" when specifying "RequestBodyType"

See original GitHub issue

Current behavior

rest.get<never>('/user/:id', (req) => {
  req.params.id // is not an inferred type
  req.params // DefaultParamsType
})

Expected behavior

rest.get<never>('/user/:id', (req) => {
  req.params.id // is an inferred "string"
  req.params // { id: string } (inferred)
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
kettanaitocommented, Apr 18, 2022

I’m sad we didn’t get to ship this to our users. @cmolina, thank you for the fantastic work on this. The change is not forgotten, and I hope once TS will get around generics and we can merge this.

1reaction
kettanaitocommented, Apr 13, 2022

I had a wild thought to try to propagate the path type to the resolver like this:

function createRestHandler(path: PathType) {
  const resolver: Resolver<PathType> = () => {}
  // ...
}

I have doubts this will work but will give it a try in a playground.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describing Parameters - Swagger
In OpenAPI, a path parameter is defined using in: path . The parameter name must be the same as specified in the path....
Read more >
Routing - Ktor
Routing is the core Ktor plugin for handling incoming requests in a server application. When the client makes a request to a specific...
Read more >
Multisite personalization - Globaleaks/GlobaLeaks - IssueHint
Issue Title Created Date Comment Count Updated Date Use another augmented assignment statement 1 2021‑11‑21 2022‑09‑16 Carousel of our supporters 0 2021‑02‑25 2022‑09‑24 Allow removing or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found