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

Method checkModuleAugmentationElement

internal/checker/checker.go:5221–5247  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

5219}
5220
5221func (c *Checker) checkModuleAugmentationElement(node *ast.Node) {
5222 switch node.Kind {
5223 case ast.KindVariableStatement:
5224 // error each individual name in variable statement instead of marking the entire variable statement
5225 for _, decl := range node.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes {
5226 c.checkModuleAugmentationElement(decl)
5227 }
5228 case ast.KindExportAssignment, ast.KindExportDeclaration:
5229 c.grammarErrorOnFirstToken(node, diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations)
5230 case ast.KindImportEqualsDeclaration:
5231 // import a = e.x; in module augmentation is ok, but not import a = require('fs)
5232 if ast.IsInternalModuleImportEqualsDeclaration(node) {
5233 break
5234 }
5235 fallthrough
5236 case ast.KindImportDeclaration, ast.KindJSImportDeclaration:
5237 c.grammarErrorOnFirstToken(node, diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module)
5238 case ast.KindBindingElement, ast.KindVariableDeclaration:
5239 name := node.Name()
5240 if ast.IsBindingPattern(name) {
5241 for _, el := range name.Elements() {
5242 // mark individual names in binding pattern
5243 c.checkModuleAugmentationElement(el)
5244 }
5245 }
5246 }
5247}
5248
5249func (c *Checker) checkImportDeclaration(node *ast.ImportDeclarationNode) {
5250 // Grammar checking

Callers 1

Calls 7

IsBindingPatternFunction · 0.92
AsVariableStatementMethod · 0.80
NameMethod · 0.65
ElementsMethod · 0.45

Tested by

no test coverage detected