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

add RegExp as typing for target #2457

Merged
merged 3 commits into from
Oct 8, 2021
Merged

add RegExp as typing for target #2457

merged 3 commits into from
Oct 8, 2021

Conversation

jcleefw
Copy link
Contributor

@jcleefw jcleefw commented Aug 17, 2021

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 expecting string only.

How:
Added typing to receive RegExp

Checklist:

  • Documentation N/A
  • Tests N/A
  • Code complete
  • Changeset

@changeset-bot
Copy link

changeset-bot bot commented Aug 17, 2021

🦋 Changeset detected

Latest commit: b727ac8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@emotion/jest Patch

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 17, 2021

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:

Sandbox Source
Emotion Configuration

@Andarist
Copy link
Member

Is there already a test that covers a regexp being used as target?

@jcleefw
Copy link
Contributor Author

jcleefw commented Aug 18, 2021

Is there already a test that covers a regexp being used as target?

yes i believe it's here

@Andarist
Copy link
Member

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 } = {}
Copy link
Member

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:

target?: string

You have only changed the Flow type here - and we are in the process of replacing Flow with TS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made!

JC Lee and others added 2 commits August 19, 2021 09:36
- 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)
@Andarist Andarist merged commit 218e4f7 into emotion-js:main Oct 8, 2021
This was referenced Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants