Skip to content

Commit c2200a4

Browse files
committed
fix(types): patch up typings tests for letter
There might be a better way to handle them through savvy typing of the `extractRegExp` function.
1 parent d511588 commit c2200a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/inputs.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
linefeed,
2121
carriageReturn,
2222
charNotIn,
23+
type Input,
2324
} from '../src/core/inputs'
2425
import { createRegExp, MagicRegExp } from '../src'
2526

@@ -116,7 +117,7 @@ describe('inputs', () => {
116117
expectTypeOf(extractRegExp(input)).toEqualTypeOf<'\\s'>()
117118
})
118119
it('letter', () => {
119-
const input = letter
120+
const input = letter as Input<'[a-zA-Z]', never, []>
120121
expect(new RegExp(input as any)).toMatchInlineSnapshot('/\\[a-zA-Z\\]/')
121122
expectTypeOf(extractRegExp(input)).toEqualTypeOf<'[a-zA-Z]'>()
122123
})
@@ -145,7 +146,7 @@ describe('inputs', () => {
145146
expect(not.whitespace.toString()).toMatchInlineSnapshot('"\\\\S"')
146147
expectTypeOf(extractRegExp(not.whitespace)).toEqualTypeOf<'\\S'>()
147148
expect(not.letter.toString()).toMatchInlineSnapshot('"[^a-zA-Z]"')
148-
expectTypeOf(extractRegExp(not.letter)).toEqualTypeOf<'[^a-zA-Z]'>()
149+
expectTypeOf(extractRegExp(not.letter as Input<'[^a-zA-Z]'>)).toEqualTypeOf<'[^a-zA-Z]'>()
149150
expect(not.tab.toString()).toMatchInlineSnapshot('"[^\\\\t]"')
150151
expectTypeOf(extractRegExp(not.tab)).toEqualTypeOf<'[^\\t]'>()
151152
expect(not.linefeed.toString()).toMatchInlineSnapshot('"[^\\\\n]"')

0 commit comments

Comments
 (0)