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

update ConstraintStrategy typing #180

Merged
merged 5 commits into from
Mar 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ declare namespace Router {
store: any
) => void;

interface ConstraintStrategy<V extends HTTPVersion> {
interface ConstraintStrategy<V extends HTTPVersion, T = string> {
name: string,
mustMatchWhenDerived?: boolean,
storage() : {
get(version: String) : Handler<V> | null,
set(version: String, store: Handler<V>) : void,
del(version: String) : void,
get(version: T) : Handler<V> | null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind updating this variable to be named value or something less version specific? Not strictly a result of your change but it is a bit more confusing now that the type of this piece is generic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the name of the store variable should also be changed, as this has simply been taken over from the semver-store?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh -- yep definitely, that's a handler not a store. Thanks for leaving it better than you found it!!

set(version: T, store: Handler<V>) : void,
del(version: T) : void,
empty() : void
},
validate(value: unknown): void,
deriveConstraint<Context>(req: Req<V>, ctx?: Context) : String,
deriveConstraint<Context>(req: Req<V>, ctx?: Context) : T,
}

interface Config<V extends HTTPVersion> {
Expand Down