MCPcopy Create free account
hub / github.com/microsoft/typescript-go / declareCommonJSVariable

Method declareCommonJSVariable

internal/binder/binder.go:1627–1643  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

1625}
1626
1627func (b *Binder) declareCommonJSVariable(name string) {
1628 locals := ast.GetLocals(b.file.AsNode())
1629 if locals[name] == nil {
1630 symbol := b.newSymbol(ast.SymbolFlagsFunctionScopedVariable|ast.SymbolFlagsModuleExports, name)
1631 symbol.Declarations = b.newSingleDeclaration(b.file.AsNode())
1632 symbol.ValueDeclaration = symbol.Declarations[0]
1633 if name == "module" {
1634 exportsProperty := b.newSymbol(ast.SymbolFlagsModuleExports|ast.SymbolFlagsProperty, "exports")
1635 exportsProperty.Declarations = symbol.Declarations
1636 exportsProperty.ValueDeclaration = symbol.ValueDeclaration
1637 exportsProperty.Parent = symbol
1638 symbol.Members = make(ast.SymbolTable, 1)
1639 symbol.Members["exports"] = exportsProperty
1640 }
1641 locals[name] = symbol
1642 }
1643}
1644
1645func (b *Binder) bindChildren(node *ast.Node) {
1646 saveInAssignmentPattern := b.inAssignmentPattern

Callers 1

bindContainerMethod · 0.95

Calls 5

newSymbolMethod · 0.95
newSingleDeclarationMethod · 0.95
GetLocalsFunction · 0.92
AsNodeMethod · 0.65
makeFunction · 0.50

Tested by

no test coverage detected