@@ -472,28 +472,35 @@ func (r *emitResolver) IsImportRequiredByAugmentation(decl *ast.ImportDeclaratio
472
472
}
473
473
474
474
func (r * emitResolver ) RequiresAddingImplicitUndefined (declaration * ast.Node , symbol * ast.Symbol , enclosingDeclaration * ast.Node ) bool {
475
+ if ! ast .IsParseTreeNode (declaration ) {
476
+ return false
477
+ }
478
+ r .checkerMu .Lock ()
479
+ defer r .checkerMu .Unlock ()
480
+ return r .requiresAddingImplicitUndefined (declaration , symbol , enclosingDeclaration )
481
+ }
482
+
483
+ func (r * emitResolver ) requiresAddingImplicitUndefined (declaration * ast.Node , symbol * ast.Symbol , enclosingDeclaration * ast.Node ) bool {
475
484
// node = r.emitContext.ParseNode(node)
476
485
if ! ast .IsParseTreeNode (declaration ) {
477
486
return false
478
487
}
479
488
switch declaration .Kind {
480
489
case ast .KindPropertyDeclaration , ast .KindPropertySignature , ast .KindJSDocPropertyTag :
481
- r .checkerMu .Lock ()
482
- defer r .checkerMu .Unlock ()
483
490
if symbol == nil {
484
491
symbol = r .checker .getSymbolOfDeclaration (declaration )
485
492
}
486
493
t := r .checker .getTypeOfSymbol (symbol )
487
494
r .checker .mappedSymbolLinks .Has (symbol )
488
495
return ! ! ((symbol .Flags & ast .SymbolFlagsProperty != 0 ) && (symbol .Flags & ast .SymbolFlagsOptional != 0 ) && isOptionalDeclaration (declaration ) && r .checker .ReverseMappedSymbolLinks .Has (symbol ) && r .checker .ReverseMappedSymbolLinks .Get (symbol ).mappedType != nil && containsNonMissingUndefinedType (r .checker , t ))
489
496
case ast .KindParameter , ast .KindJSDocParameterTag :
490
- return r .requiresAddingImplicitUndefined (declaration , enclosingDeclaration )
497
+ return r .requiresAddingImplicitUndefinedWorker (declaration , enclosingDeclaration )
491
498
default :
492
499
panic ("Node cannot possibly require adding undefined" )
493
500
}
494
501
}
495
502
496
- func (r * emitResolver ) requiresAddingImplicitUndefined (parameter * ast.Node , enclosingDeclaration * ast.Node ) bool {
503
+ func (r * emitResolver ) requiresAddingImplicitUndefinedWorker (parameter * ast.Node , enclosingDeclaration * ast.Node ) bool {
497
504
return (r .isRequiredInitializedParameter (parameter , enclosingDeclaration ) || r .isOptionalUninitializedParameterProperty (parameter )) && ! r .declaredParameterTypeContainsUndefined (parameter )
498
505
}
499
506
0 commit comments