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

Method AddVariableDeclaration

internal/printer/emitcontext.go:164–172  ·  view source on GitHub ↗

Adds a `var` declaration to the current VariableEnvironment NOTE: This is the equivalent of `transformContext.hoistVariableDeclaration` in Strada.

(name *ast.IdentifierNode)

Source from the content-addressed store, hash-verified

162//
163// NOTE: This is the equivalent of `transformContext.hoistVariableDeclaration` in Strada.
164func (c *EmitContext) AddVariableDeclaration(name *ast.IdentifierNode) {
165 varDecl := c.Factory.NewVariableDeclaration(name, nil /*exclamationToken*/, nil /*typeNode*/, nil /*initializer*/)
166 c.SetEmitFlags(varDecl, EFNoNestedSourceMaps)
167 scope := c.varScopeStack.Peek()
168 scope.variables = append(scope.variables, varDecl)
169 if scope.flags&environmentFlagsInParameters != 0 {
170 scope.flags |= environmentFlagsVariablesHoistedInParameters
171 }
172}
173
174// Adds a hoisted function declaration to the current VariableEnvironment
175//

Calls 4

SetEmitFlagsMethod · 0.95
PeekMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected