-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
add RegExp as typing for target #2457
Conversation
🦋 Changeset detectedLatest commit: b727ac8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b727ac8:
|
Is there already a test that covers a regexp being used as |
yes i believe it's here |
cool! it's good to have this validated |
@@ -43,7 +43,7 @@ function toHaveStyleRule( | |||
received: *, | |||
property: *, | |||
value: *, | |||
options?: { target?: string, media?: string } = {} | |||
options?: { target?: string | RegExp, media?: 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 suspect that you might have wanted to fix in the TS types which are, currently, located here:
emotion/packages/jest/types/index.d.ts
Line 12 in 639b276
target?: string |
You have only changed the Flow type here - and we are in the process of replacing Flow with TS.
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.
changes made!
- With typescript in place, the typing that only allows string will not be able to receive a RegExp. Being able to receive a RegExp will allow target options describe in [this issue](#1875)
What:
Following the conversation described in this issue, the suggested solution is to insert regex patterns to ensure matching criteria
Why:
This quick fix will allow exact matching of pseudo-css selector with
regex patterns
. The existing implementation will rise issues in typesscript type checking where the function is expectingstring
only.How:
Added typing to receive RegExp
Checklist: