Skip to content

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

@Nokel81

Description

@Nokel81

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions