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

Bug: If part of a capture group is optional then the typing assumes that the whole is optional #6

Open
Nokel81 opened this issue Mar 29, 2022 · 0 comments

Comments

@Nokel81
Copy link

Nokel81 commented Mar 29, 2022

Description:

If a named capture group has some optional grouping itself then the whole group is optional.

Test case:

Current:

const regex = TypedRegEx("^(?<name>((@\\w[-\\w]*\\/)?\\w[-\\w]*))$", "gi");
const captures = regex.captures(...) // { name?: string | undefined } | undefined;

Expected:

const regex = TypedRegEx("^(?<name>((@\\w[-\\w]*\\/)?\\w[-\\w]*))$", "gi");
const captures = regex.captures(...) // { name: string } | undefined;
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

No branches or pull requests

1 participant