@@ -6,6 +6,7 @@ var test = require('tape');
66var isRegex = require ( '..' ) ;
77
88test ( 'not regexes' , function ( t ) {
9+ // @ts -expect-error
910 t . notOk ( isRegex ( ) , 'undefined is not regex' ) ;
1011 t . notOk ( isRegex ( null ) , 'null is not regex' ) ;
1112 t . notOk ( isRegex ( false ) , 'false is not regex' ) ;
@@ -20,6 +21,7 @@ test('not regexes', function (t) {
2021
2122test ( '@@toStringTag' , { skip : ! hasToStringTag } , function ( t ) {
2223 var regex = / a / g;
24+ /** @type {{ toString(): string, valueOf(): RegExp, [Symbol.toStringTag]?: string} } */
2325 var fakeRegex = {
2426 toString : function ( ) { return String ( regex ) ; } ,
2527 valueOf : function ( ) { return regex ; }
@@ -39,6 +41,7 @@ test('does not mutate regexes', function (t) {
3941 t . test ( 'lastIndex is a marker object' , function ( st ) {
4042 var regex = / a / ;
4143 var marker = { } ;
44+ // @ts -expect-error
4245 regex . lastIndex = marker ;
4346 st . equal ( regex . lastIndex , marker , 'lastIndex is the marker object' ) ;
4447 st . ok ( isRegex ( regex ) , 'is regex' ) ;
@@ -59,11 +62,14 @@ test('does not mutate regexes', function (t) {
5962} ) ;
6063
6164test ( 'does not perform operations observable to Proxies' , { skip : typeof Proxy !== 'function' } , function ( t ) {
62- var Handler = function ( ) {
65+ /** @constructor */
66+ function Handler ( ) {
67+ /** @type (keyof Reflect)[]} */
6368 this . trapCalls = [ ] ;
64- } ;
69+ }
6570
66- forEach ( [
71+ // eslint-disable-next-line no-extra-parens
72+ forEach ( /** @const @type {(keyof Reflect)[] } */ ( [
6773 'defineProperty' ,
6874 'deleteProperty' ,
6975 'get' ,
@@ -75,15 +81,17 @@ test('does not perform operations observable to Proxies', { skip: typeof Proxy !
7581 'preventExtensions' ,
7682 'set' ,
7783 'setPrototypeOf'
78- ] , function ( trapName ) {
84+ ] ) , function ( trapName ) {
7985 Handler . prototype [ trapName ] = function ( ) {
8086 this . trapCalls . push ( trapName ) ;
87+ // @ts -expect-error TODO: not sure why this is erroring
8188 return Reflect [ trapName ] . apply ( Reflect , arguments ) ;
8289 } ;
8390 } ) ;
8491
8592 t . test ( 'proxy of object' , function ( st ) {
8693 var handler = new Handler ( ) ;
94+ // @ts -expect-error Proxy handlers can be any object
8795 var proxy = new Proxy ( { lastIndex : 0 } , handler ) ;
8896
8997 st . equal ( isRegex ( proxy ) , false , 'proxy of plain object is not regex' ) ;
@@ -97,6 +105,7 @@ test('does not perform operations observable to Proxies', { skip: typeof Proxy !
97105
98106 t . test ( 'proxy of RegExp instance' , function ( st ) {
99107 var handler = new Handler ( ) ;
108+ // @ts -expect-error Proxy handlers can be any object
100109 var proxy = new Proxy ( / a / , handler ) ;
101110
102111 st . equal ( isRegex ( proxy ) , false , 'proxy of RegExp instance is not regex' ) ;
0 commit comments