Skip to content

Untegged variants support for regular expressions as a payload #6140

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

Closed
DZakh opened this issue Apr 13, 2023 · 6 comments · Fixed by #6296
Closed

Untegged variants support for regular expressions as a payload #6140

DZakh opened this issue Apr 13, 2023 · 6 comments · Fixed by #6296
Milestone

Comments

@DZakh
Copy link
Member

DZakh commented Apr 13, 2023

image

I think it's a pretty common case.

I use [email protected]

@cristianoc
Copy link
Collaborator

What's relatively easy to add, is to consider regexps as object.
Would that work, and be accurate?

  • Work as in: it's typically the only case of object shape (in the example above it's true as the others are float or function)
  • Accurate as in: it's always an object at runtime.

@cristianoc cristianoc added this to the v12 milestone Jun 8, 2023
@DZakh
Copy link
Member Author

DZakh commented Jun 8, 2023

What about /a/ instanceof RegExp? But I agree that typeof === "object" will work in this case.

@cristianoc
Copy link
Collaborator

What about /a/ instanceof RegExp? But I agree that typeof === "object" will work in this case.

Before doing that I'd like to know if the simpler solution would work in most cases.

The RegExp type is a further complication, as there's already overlap between array and object, so with this it would be a 3-way overlap.
Perhaps it's just exactly one more case like the one of array. Need to check.

@cristianoc
Copy link
Collaborator

In this example, what is it binding to? Link?

@DZakh
Copy link
Member Author

DZakh commented Jun 8, 2023

Before doing that I'd like to know if the simpler solution would work in most cases.

It's definitely better than nothing. And in my experience, the regexp is usually overlapped with a string type.

In this example, what is it binding to? Link?

https://github.com/avajs/ava/blob/568fe40c987dd6c593dfbcf4144d1d1627955d46/types/assertions.d.cts#L19-L20

@cristianoc
Copy link
Collaborator

cristianoc commented Jun 8, 2023

@DZakh done in #6296

That's a one-liner change. One can always do something more sophisticated later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants