Skip to content

Commit d92393d

Browse files
committed
fix(types): differentiate symbols from generics
1 parent 93c352c commit d92393d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/core/types/magic-regexp.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const NamedGroups = Symbol('NamedGroups')
2-
const Value = Symbol('Value')
3-
const Flags = Symbol('Flags')
1+
const NamedGroupsS = Symbol('NamedGroups')
2+
const ValueS = Symbol('Value')
3+
const FlagsS = Symbol('Flags')
44

55
export type MagicRegExp<
66
Value extends string,
77
NamedGroups extends string | never = never,
88
Flags extends string | never = never
99
> = RegExp & {
10-
[NamedGroups]: NamedGroups
11-
[Value]: Value
12-
[Flags]: Flags
10+
[NamedGroupsS]: NamedGroups
11+
[ValueS]: Value
12+
[FlagsS]: Flags
1313
}
1414

1515
type ExtractGroups<T extends MagicRegExp<string, string, string>> = T extends MagicRegExp<

test/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('magic-regexp', () => {
2020
expect('thing'.match(regExp)?.[0]).toMatchInlineSnapshot('"in"')
2121
expect(regExp.test('thing')).toBeTruthy()
2222
expect(regExp.lastIndex).toMatchInlineSnapshot('4')
23+
expectTypeOf(regExp).not.toEqualTypeOf(RegExp)
2324
})
2425
it('collects flag type', () => {
2526
const re = createRegExp('.', [global, multiline])

0 commit comments

Comments
 (0)