Skip to content

Commit ed6e33f

Browse files
authored
Don't add export modifier to KindCommonJSExport reparsed nodes (#2066)
1 parent b17a2c6 commit ed6e33f

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

internal/ast/parseoptions.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ func isFileProbablyExternalModule(sourceFile *SourceFile) *Node {
112112
}
113113

114114
func isAnExternalModuleIndicatorNode(node *Node) bool {
115-
if node.Flags&NodeFlagsReparsed != 0 {
116-
return false
117-
}
118115
return HasSyntacticModifier(node, ModifierFlagsExport) ||
119116
IsImportEqualsDeclaration(node) && IsExternalModuleReference(node.AsImportEqualsDeclaration().ModuleReference) ||
120117
IsImportDeclaration(node) || IsExportAssignment(node) || IsExportDeclaration(node)

internal/binder/binder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func GetSymbolNameForPrivateIdentifier(containingClassSymbol *ast.Symbol, descri
377377

378378
func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags) *ast.Symbol {
379379
container := b.container
380-
if node.Kind == ast.KindCommonJSExport {
380+
if ast.IsCommonJSExport(node) {
381381
container = b.file.AsNode()
382382
}
383383
hasExportModifier := ast.GetCombinedModifierFlags(node)&ast.ModifierFlagsExport != 0 || ast.IsImplicitlyExportedJSTypeAlias(node)
@@ -402,7 +402,7 @@ func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags
402402
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
403403
// and this case is specially handled. Module augmentations should only be merged with original module definition
404404
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
405-
if !ast.IsAmbientModule(node) && (hasExportModifier || container.Flags&ast.NodeFlagsExportContext != 0) {
405+
if !ast.IsAmbientModule(node) && (hasExportModifier || ast.IsCommonJSExport(node) || container.Flags&ast.NodeFlagsExportContext != 0) {
406406
if !ast.IsLocalsContainer(container) || (ast.HasSyntacticModifier(node, ast.ModifierFlagsDefault) && b.getDeclarationName(node) == ast.InternalSymbolNameMissing) || ast.IsCommonJSExport(node) {
407407
return b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes)
408408
// No local symbol for an unnamed default!

internal/parser/reparser.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) {
2929
case ast.JSDeclarationKindModuleExports:
3030
export = p.factory.NewJSExportAssignment(nil, p.factory.DeepCloneReparse(bin.Right))
3131
case ast.JSDeclarationKindExportsProperty:
32-
mod := p.factory.NewModifier(ast.KindExportKeyword)
33-
mod.Flags = p.contextFlags | ast.NodeFlagsReparsed
34-
mod.Loc = bin.Loc
3532
// TODO: Name can sometimes be a string literal, so downstream code needs to handle this
3633
export = p.factory.NewCommonJSExport(
37-
p.newModifierList(bin.Loc, p.nodeSlicePool.NewSlice1(mod)),
34+
nil,
3835
p.factory.DeepCloneReparse(ast.GetElementOrPropertyAccessName(bin.Left)),
3936
nil, /*typeNode*/
4037
p.factory.DeepCloneReparse(bin.Right))

0 commit comments

Comments
 (0)