-
Notifications
You must be signed in to change notification settings - Fork 140
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
Widen type defs to allow for nonstring version constraints #183
Conversation
cf68a71
to
d291da2
Compare
can you add a test for the type in test/types/router.test-d.ts? |
good work! |
d291da2
to
f0383e5
Compare
Thanks! I've added some type tests. I'm new to type-testing, so any feedback you have on it would be great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -57,17 +57,17 @@ declare namespace Router { | |||
store: any | |||
) => void; | |||
|
|||
interface ConstraintStrategy<V extends HTTPVersion> { | |||
interface ConstraintStrategy<V extends HTTPVersion, ConstraintVersion = string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might make more sense to call this property ConstraintValue
or something like that. I know it says version
in all the types below, but these strategies can actually be used for other constraints than version, like host
or maybe the Accept
header someday. I think the name of that argument in the types should be changed too.
@@ -91,7 +91,7 @@ declare namespace Router { | |||
): void; | |||
|
|||
constraints? : { | |||
[key: string]: ConstraintStrategy<V> | |||
[key: string]: ConstraintStrategy<V, unknown> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it might be a breaking change, do the fastify type tests still pass with this in place?
I guess it was implemented here #180. We can close it. |
find-my-way's design makes it agnostic as to the specific type and shape of a version, however the bundled types constrain versions to a string. This PR does three things:
validate
as optional, because it is.