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

update ConstraintStrategy typing #180

merged 5 commits into from
Mar 29, 2021

Conversation

matthyk
Copy link
Contributor

@matthyk matthyk commented Feb 12, 2021

In #179 it was asked whether it is possible to use objects as values in custom constraints. After looking through the code, this should not be a problem. Only the typings have to be updated.
The default value of the generic could be string or any.

any would match the typing of the RouteOption.

interface RouteOptions {
    constraints?: { [key: string]: any }
  }

But string would provide a backwards compatibility.

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Please update the tests as well.

@matthyk
Copy link
Contributor Author

matthyk commented Feb 13, 2021

Which tests exactly need to be updated? For me it looks like it would make most sense to add a new tests for custom constraints with objects. ( like constraint.custom-with-objects.test )

@mcollina
Copy link
Collaborator

Adding new tests is totally fine

@mcollina
Copy link
Collaborator

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@airhorns airhorns left a comment

Choose a reason for hiding this comment

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

LGTM, nice change!

index.d.ts Outdated
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!!

Copy link
Owner

@delvedor delvedor left a comment

Choose a reason for hiding this comment

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

LGTM

@delvedor delvedor merged commit bfe4a02 into delvedor:master Mar 29, 2021
@matthyk matthyk deleted the constraint-strategy-typing branch April 19, 2021 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants