MCPcopy Index your code
hub / github.com/nodejs/node / checkImportDeclaration

Function checkImportDeclaration

test/fixtures/snapshot/typescript.js:85271–85303  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

85269 }
85270 }
85271 function checkImportDeclaration(node) {
85272 if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
85273 // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
85274 return;
85275 }
85276 if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
85277 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
85278 }
85279 if (checkExternalImportOrExportDeclaration(node)) {
85280 var importClause = node.importClause;
85281 if (importClause && !checkGrammarImportClause(importClause)) {
85282 if (importClause.name) {
85283 checkImportBinding(importClause);
85284 }
85285 if (importClause.namedBindings) {
85286 if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
85287 checkImportBinding(importClause.namedBindings);
85288 if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) {
85289 // import * as ns from "foo";
85290 checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */);
85291 }
85292 }
85293 else {
85294 var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
85295 if (moduleExisted) {
85296 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
85297 }
85298 }
85299 }
85300 }
85301 }
85302 checkAssertClause(node);
85303 }
85304 function checkImportEqualsDeclaration(node) {
85305 if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
85306 // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.

Callers 1

checkSourceElementWorkerFunction · 0.85

Calls 10

grammarErrorOnFirstTokenFunction · 0.85
checkGrammarImportClauseFunction · 0.85
checkImportBindingFunction · 0.85
checkExternalEmitHelpersFunction · 0.85
checkAssertClauseFunction · 0.85
forEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…