@@ -63,7 +63,7 @@ function visitDateType(type: ts.ObjectType, visitorContext: VisitorContext) {
63
63
ts . createIdentifier ( 'nativeDateObject' )
64
64
)
65
65
) ,
66
- ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'date' } ) ) ,
66
+ ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'date' } , visitorContext ) ) ,
67
67
ts . createReturn ( ts . createNull ( ) )
68
68
) ] ,
69
69
true
@@ -131,7 +131,7 @@ function visitTupleObjectType(type: ts.TupleType, visitorContext: VisitorContext
131
131
] ,
132
132
ts . SyntaxKind . BarBarToken
133
133
) ,
134
- ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'tuple' , minLength, maxLength } ) )
134
+ ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'tuple' , minLength, maxLength } , visitorContext ) )
135
135
) ,
136
136
...functionNames . map ( ( functionName , index ) =>
137
137
ts . createBlock ( [
@@ -205,7 +205,7 @@ function visitArrayObjectType(type: ts.ObjectType, visitorContext: VisitorContex
205
205
[ VisitorUtils . objectIdentifier ]
206
206
)
207
207
) ,
208
- ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'array' } ) )
208
+ ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'array' } , visitorContext ) )
209
209
) ,
210
210
ts . createFor (
211
211
ts . createVariableDeclarationList (
@@ -307,7 +307,7 @@ function visitRegularObjectType(type: ts.ObjectType, visitorContext: VisitorCont
307
307
] ,
308
308
ts . SyntaxKind . BarBarToken
309
309
) ,
310
- ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'object' } ) )
310
+ ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'object' } , visitorContext ) )
311
311
) ,
312
312
...propertyInfos . map ( ( propertyInfo ) => {
313
313
if ( propertyInfo . isSymbol ) {
@@ -365,13 +365,13 @@ function visitRegularObjectType(type: ts.ObjectType, visitorContext: VisitorCont
365
365
] ) ,
366
366
propertyInfo . optional
367
367
? undefined
368
- : ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'missing-property' , property : propertyInfo . name } ) )
368
+ : ts . createReturn ( VisitorUtils . createErrorObject ( { type : 'missing-property' , property : propertyInfo . name } , visitorContext ) )
369
369
)
370
370
] ) ;
371
371
} ) ,
372
372
...(
373
373
visitorContext . options . disallowSuperfluousObjectProperties && stringIndexFunctionName === undefined
374
- ? [ VisitorUtils . createSuperfluousPropertiesLoop ( propertyInfos . map ( ( propertyInfo ) => propertyInfo . name ) ) ]
374
+ ? [ VisitorUtils . createSuperfluousPropertiesLoop ( propertyInfos . map ( ( propertyInfo ) => propertyInfo . name ) , visitorContext ) ]
375
375
: [ ]
376
376
) ,
377
377
...(
@@ -518,6 +518,7 @@ function visitLiteralType(type: ts.LiteralType, visitorContext: VisitorContext)
518
518
) ,
519
519
{ type : 'string-literal' , value } ,
520
520
name ,
521
+ visitorContext ,
521
522
VisitorUtils . createStrictNullCheckStatement ( VisitorUtils . objectIdentifier , visitorContext )
522
523
) ;
523
524
} ) ;
@@ -532,6 +533,7 @@ function visitLiteralType(type: ts.LiteralType, visitorContext: VisitorContext)
532
533
) ,
533
534
{ type : 'number-literal' , value } ,
534
535
name ,
536
+ visitorContext ,
535
537
VisitorUtils . createStrictNullCheckStatement ( VisitorUtils . objectIdentifier , visitorContext )
536
538
) ;
537
539
} ) ;
@@ -558,7 +560,7 @@ function visitUnionOrIntersectionType(type: ts.UnionOrIntersectionType, visitorC
558
560
// Check object keys at intersection type level. https://github.com/woutervh-/typescript-is/issues/21
559
561
const keys = VisitorIsStringKeyof . visitType ( type , visitorContext ) ;
560
562
if ( keys instanceof Set ) {
561
- const loop = VisitorUtils . createSuperfluousPropertiesLoop ( sliceSet ( keys ) ) ;
563
+ const loop = VisitorUtils . createSuperfluousPropertiesLoop ( sliceSet ( keys ) , visitorContext ) ;
562
564
return VisitorUtils . createConjunctionFunction ( functionNames , name , [ loop ] ) ;
563
565
}
564
566
}
@@ -580,6 +582,7 @@ function visitBooleanLiteral(type: ts.Type, visitorContext: VisitorContext) {
580
582
) ,
581
583
{ type : 'boolean-literal' , value : true } ,
582
584
name ,
585
+ visitorContext ,
583
586
VisitorUtils . createStrictNullCheckStatement ( VisitorUtils . objectIdentifier , visitorContext )
584
587
) ;
585
588
} ) ;
@@ -593,6 +596,7 @@ function visitBooleanLiteral(type: ts.Type, visitorContext: VisitorContext) {
593
596
) ,
594
597
{ type : 'boolean-literal' , value : false } ,
595
598
name ,
599
+ visitorContext ,
596
600
VisitorUtils . createStrictNullCheckStatement ( VisitorUtils . objectIdentifier , visitorContext )
597
601
) ;
598
602
} ) ;
@@ -633,6 +637,7 @@ function visitNonPrimitiveType(type: ts.Type, visitorContext: VisitorContext) {
633
637
ts . createLogicalNot ( condition ) ,
634
638
{ type : 'non-primitive' } ,
635
639
name ,
640
+ visitorContext ,
636
641
VisitorUtils . createStrictNullCheckStatement ( VisitorUtils . objectIdentifier , visitorContext )
637
642
) ;
638
643
} ) ;
@@ -700,7 +705,7 @@ function visitTemplateLiteralType(type: ts.TemplateLiteralType, visitorContext:
700
705
const templateLiteralTypeError = VisitorUtils . createErrorObject ( {
701
706
type : 'template-literal' ,
702
707
value : typePairs
703
- } )
708
+ } , visitorContext )
704
709
return VisitorUtils . setFunctionIfNotExists ( name , visitorContext , ( ) => ts . factory . createFunctionDeclaration (
705
710
undefined ,
706
711
undefined ,
0 commit comments