Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DependsOnMethod is not assignable to the Routing type #2465

Closed
LufyCZ opened this issue Mar 9, 2025 · 2 comments
Closed

DependsOnMethod is not assignable to the Routing type #2465

LufyCZ opened this issue Mar 9, 2025 · 2 comments
Labels
not an issue Irreproducible or unrelated

Comments

@LufyCZ
Copy link

LufyCZ commented Mar 9, 2025

Description

DependsOnMethod is not assignable to the Routing type. At runtime, this is completely valid, so it's purely a type issue.

export const plans: Routing = new DependsOnMethod({
  get: getPlansEndpoint,
})

Workaround

Adding a .nest({}) fixes the issue.

export const plans: Routing = new DependsOnMethod({
  get: getPlansEndpoint,
}).nest({})

Reproduction

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgEQKZlQOwCYGcDymAsqjABYTYA0cMAnhnAEoQCuMwmA5nAL5wAzKBBBwA5KgAeYKKly4AtAC9KCgIZhgYgFDapkWHADGETLngCIEAFzM2HbnAC8cTKgDuKdFjyES5SgAKBF4ASl19aHgTM3gAIzUoWxZ2Th4XN080DBwCYlIKbGCwgDo3c2LQoA

@LufyCZ LufyCZ added the bug Something isn't working label Mar 9, 2025
@RobinTail
Copy link
Owner

DependsOnMethod is not supposed to be assignable to Routing, because

export interface Routing {
  [SEGMENT: string]: Routing | DependsOnMethod | AbstractEndpoint | ServeStatic;
}

meaning, that DependsOnMethod should be assigned to a property of Routing.

In case you mean the root route /, that property should be an empty string

const routing: Routing = {
  "": new DependsOnMethod()
}

, @LufyCZ

@RobinTail RobinTail added unclear Is it a bug or a feature? and removed bug Something isn't working labels Mar 9, 2025
@RobinTail
Copy link
Owner

I've been thinking if I could make it easier for the root route...
But generally speaking, .nest() does exactly the same thing — it wraps and assigns DependsOnMethod to the empty string route.

@RobinTail RobinTail added not an issue Irreproducible or unrelated and removed unclear Is it a bug or a feature? labels Mar 10, 2025
@RobinTail RobinTail closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not an issue Irreproducible or unrelated
Projects
None yet
Development

No branches or pull requests

2 participants