@@ -180,7 +180,7 @@ const knownFunctionMembers = new Set([
180
180
export function bindSourceFileForDeclarationEmit ( file : SourceFile ) {
181
181
const nodeLinks : EmitDeclarationNodeLinks [ ] = [ ] ;
182
182
function tryGetNodeLinks ( node : Node ) : EmitDeclarationNodeLinks | undefined {
183
- const id = ( node as any ) . id ;
183
+ const id = node . id ;
184
184
if ( ! id ) return undefined ;
185
185
return nodeLinks [ id ] ;
186
186
}
@@ -274,7 +274,7 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
274
274
/* eslint-disable no-var */
275
275
var currentScope : Node = undefined ! ;
276
276
var currentFunctionLocalSymbolTable : EmitDeclarationSymbolTable = undefined ! ;
277
- var currentSymbol : EmitDeclarationSymbol = undefined ! ;
277
+ var currentParent : EmitDeclarationSymbol = undefined ! ;
278
278
var currentLocalSymbolTable : EmitDeclarationSymbolTable = undefined ! ;
279
279
var currentExportsSymbolTable : EmitDeclarationSymbolTable | undefined ;
280
280
var postBindingAction : ( ( ) => void ) [ ] = [ ] ;
@@ -296,7 +296,7 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
296
296
}
297
297
function createEmitSymbol ( ) : EmitDeclarationSymbol {
298
298
return {
299
- parent : currentSymbol ,
299
+ parent : currentParent ,
300
300
declarations : [ ] ,
301
301
flags : 0 ,
302
302
} ;
@@ -353,24 +353,24 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
353
353
return symbol ;
354
354
}
355
355
function withScope ( scope : Node , exports : EmitDeclarationSymbolTable | undefined , fn : ( ) => void ) {
356
- const old = [ currentScope , currentSymbol , currentFunctionLocalSymbolTable , currentLocalSymbolTable , currentExportsSymbolTable ] as const ;
356
+ const old = [ currentScope , currentParent , currentFunctionLocalSymbolTable , currentLocalSymbolTable , currentExportsSymbolTable ] as const ;
357
357
currentScope = scope ;
358
358
const links = getNodeLinks ( scope ) ;
359
359
currentLocalSymbolTable = links . locals ??= new Map ( ) ;
360
- currentSymbol = links . symbol ?? currentSymbol ;
360
+ currentParent = links . symbol ?? currentParent ;
361
361
currentExportsSymbolTable = exports ;
362
362
if ( isBlockScopedContainerTopLevel ( scope ) ) {
363
363
currentFunctionLocalSymbolTable = currentLocalSymbolTable ;
364
364
}
365
365
fn ( ) ;
366
- [ currentScope , currentSymbol , currentFunctionLocalSymbolTable , currentLocalSymbolTable , currentExportsSymbolTable ] = old ;
366
+ [ currentScope , currentParent , currentFunctionLocalSymbolTable , currentLocalSymbolTable , currentExportsSymbolTable ] = old ;
367
367
}
368
- function withMembers ( symbol : EmitDeclarationSymbol , table : "members" | "exports" = "members" , fn : ( ) => void ) {
369
- const old = [ currentLocalSymbolTable , currentSymbol ] as const ;
370
- currentSymbol = symbol ;
371
- currentLocalSymbolTable = symbol [ table ] ??= new Map ( ) ;
368
+ function withMembers ( symbol : EmitDeclarationSymbol , addToExports = false , fn : ( ) => void ) {
369
+ const old = [ currentLocalSymbolTable , currentParent ] as const ;
370
+ currentParent = symbol ;
371
+ currentLocalSymbolTable = addToExports ? symbol . exports ??= new Map ( ) : symbol . members ??= new Map ( ) ;
372
372
fn ( ) ;
373
- [ currentLocalSymbolTable , currentSymbol ] = old ;
373
+ [ currentLocalSymbolTable , currentParent ] = old ;
374
374
}
375
375
376
376
interface LocalAndExportName {
@@ -492,7 +492,7 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
492
492
function bindObjectLiteral ( object : ObjectLiteralExpression ) {
493
493
const objectSymbol = createAnonymousEmitSymbol ( object ) ;
494
494
495
- withMembers ( objectSymbol , "members" , ( ) => {
495
+ withMembers ( objectSymbol , /*addToExports*/ false , ( ) => {
496
496
object . properties . forEach ( m => {
497
497
bindNode ( m ) ;
498
498
} ) ;
@@ -687,7 +687,7 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
687
687
}
688
688
function bindTypeLiteralNode ( node : TypeLiteralNode ) {
689
689
const objectSymbol = createAnonymousEmitSymbol ( node ) ;
690
- withMembers ( objectSymbol , "members" , ( ) => {
690
+ withMembers ( objectSymbol , /*addToExports*/ false , ( ) => {
691
691
node . members . forEach ( bindNode ) ;
692
692
} ) ;
693
693
}
@@ -727,14 +727,14 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
727
727
} ) ;
728
728
} ) ;
729
729
}
730
- elements . forEach ( e => {
730
+ for ( const e of elements ) {
731
731
postBindingAction . push ( ( ) => {
732
732
const resolvedSymbol = resolveName ( e , ( e . propertyName ?? e . name ) . escapedText , ~ 0 ) ;
733
733
if ( resolvedSymbol ) {
734
734
resolvedSymbol . declarations . forEach ( d => getNodeLinks ( d ) . isVisible = true ) ;
735
735
}
736
736
} ) ;
737
- } ) ;
737
+ }
738
738
}
739
739
}
740
740
function bindEnumDeclaration ( node : EnumDeclaration ) {
@@ -777,7 +777,7 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
777
777
withScope ( interfaceDeclaration , /*exports*/ undefined , ( ) => {
778
778
bindTypeParameters ( interfaceDeclaration . typeParameters ) ;
779
779
} ) ;
780
- withMembers ( interfaceSymbol , "members" , ( ) => {
780
+ withMembers ( interfaceSymbol , /*addToExports*/ false , ( ) => {
781
781
interfaceDeclaration . members . forEach ( m => {
782
782
bindNode ( m ) ;
783
783
} ) ;
@@ -790,15 +790,15 @@ export function bindSourceFileForDeclarationEmit(file: SourceFile) {
790
790
withScope ( classDeclaration , /*exports*/ undefined , ( ) => {
791
791
bindTypeParameters ( classDeclaration . typeParameters ) ;
792
792
} ) ;
793
- withMembers ( classSymbol , "members" , ( ) => {
793
+ withMembers ( classSymbol , /*addToExports*/ false , ( ) => {
794
794
classDeclaration . members . forEach ( m => {
795
795
if ( hasSyntacticModifier ( m , ModifierFlags . Static ) ) return ;
796
796
if ( m . kind === SyntaxKind . SemicolonClassElement || m . kind === SyntaxKind . ClassStaticBlockDeclaration ) return ;
797
797
798
798
bindNode ( m ) ;
799
799
} ) ;
800
800
} ) ;
801
- withMembers ( classSymbol , "exports" , ( ) => {
801
+ withMembers ( classSymbol , /*addToExports*/ true , ( ) => {
802
802
classDeclaration . members . forEach ( m => {
803
803
if ( ! hasSyntacticModifier ( m , ModifierFlags . Static ) ) return ;
804
804
if (
0 commit comments