Skip to content

Commit cf9bae5

Browse files
committed
support expando assignments by collecting and emitting merged namespace declarations
1 parent 64d9add commit cf9bae5

File tree

95 files changed

+2510
-802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2510
-802
lines changed

internal/checker/emitresolver.go

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -605,43 +605,8 @@ func (r *emitResolver) IsLiteralConstDeclaration(node *ast.Node) bool {
605605
}
606606

607607
func (r *emitResolver) IsExpandoFunctionDeclaration(node *ast.Node) bool {
608-
if !ast.IsParseTreeNode(node) {
609-
return false
610-
}
611-
612-
r.checkerMu.Lock()
613-
defer r.checkerMu.Unlock()
614-
615-
var declaration *ast.Node
616-
if ast.IsVariableDeclaration(node) {
617-
initializer := node.Initializer()
618-
if node.Type() == nil && (ast.IsInJSFile(node) || ast.IsVarConstLike(node)) && ast.IsExpandoInitializer(initializer) {
619-
declaration = initializer
620-
}
621-
}
622-
623-
if ast.IsFunctionDeclaration(node) {
624-
declaration = node
625-
}
626-
627-
if declaration == nil {
628-
return false
629-
}
630-
631-
symbol := r.checker.getSymbolOfDeclaration(declaration)
632-
if symbol == nil || (symbol.Flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsVariable)) == 0 {
633-
return false
634-
}
635-
636-
exports := r.checker.getExportsOfSymbol(symbol)
637-
for _, p := range exports {
638-
if p.ValueDeclaration == nil || p.Flags&ast.SymbolFlagsValue == 0 || p.Flags&ast.SymbolFlagsAssignment == 0 {
639-
continue
640-
}
641-
if p.ValueDeclaration.Flags&ast.NodeFlagsAmbient == 0 {
642-
return true
643-
}
644-
}
608+
// node = r.emitContext.ParseNode(node)
609+
// !!! TODO: expando function support
645610
return false
646611
}
647612

@@ -882,26 +847,6 @@ func (r *emitResolver) GetReferencedValueDeclarations(node *ast.IdentifierNode)
882847
return r.getReferenceResolver().GetReferencedValueDeclarations(node)
883848
}
884849

885-
func (r *emitResolver) GetPropertiesOfContainerFunction(node *ast.Node) []*ast.Symbol {
886-
props := []*ast.Symbol{}
887-
888-
if !ast.IsParseTreeNode(node) {
889-
return props
890-
}
891-
892-
if ast.IsFunctionDeclaration(node) {
893-
r.checkerMu.Lock()
894-
defer r.checkerMu.Unlock()
895-
896-
symbol := r.checker.getSymbolOfDeclaration(node)
897-
if symbol == nil {
898-
return props
899-
}
900-
props = r.checker.getPropertiesOfType(r.checker.getTypeOfSymbol(symbol))
901-
}
902-
return props
903-
}
904-
905850
// TODO: the emit resolver being responsible for some amount of node construction is a very leaky abstraction,
906851
// and requires giving it access to a lot of context it's otherwise not required to have, which also further complicates the API
907852
// and likely reduces performance. There's probably some refactoring that could be done here to simplify this.

internal/printer/emitresolver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type EmitResolver interface {
3434
GetExternalModuleFileFromDeclaration(node *ast.Node) *ast.SourceFile
3535
GetEffectiveDeclarationFlags(node *ast.Node, flags ast.ModifierFlags) ast.ModifierFlags
3636
GetResolutionModeOverride(node *ast.Node) core.ResolutionMode
37-
GetPropertiesOfContainerFunction(node *ast.Node) []*ast.Symbol
3837

3938
// JSX Emit
4039
GetJsxFactoryEntity(location *ast.Node) *ast.Node

0 commit comments

Comments
 (0)