Files
tsgo/testdata/tests/cases/compiler/regexNamedGroupDuplicateNestedInGroup.ts
8ffb4ef78a Fix TS1515 not reported when duplicate named group is nested inside a group (#4881)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: RyanCavanaugh <[email protected]>
Co-authored-by: Ryan Cavanaugh <[email protected]>
2026-08-14 19:47:55 +00:00

23 lines
645 B
TypeScript

// @target: esnext
// Duplicate at the top level (already reported prior to this fix).
/(?<a>x)(?<a>y)/;
// Earlier definition nested inside a non-capturing group.
/(?:(?<a>x))(?<a>z)/;
// Earlier definition nested inside a non-capturing group with alternation.
/(?:(?<a>x)|y)(?<a>z)/;
// Earlier definition nested inside a lookahead assertion.
/(?=(?<a>x))(?<a>z)/;
// Earlier definition nested inside a capturing group.
/((?<a>x))(?<a>z)/;
// Legal: duplicate names in different alternatives of the same disjunction.
/(?<a>x)|(?<a>y)/;
// Legal: duplicate names in different alternatives of a nested disjunction.
/(?:(?<a>x)|(?<a>y))/;