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

Function checkImportEqualsDeclaration

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

Source from the content-addressed store, hash-verified

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.
85307 return;
85308 }
85309 checkGrammarDecoratorsAndModifiers(node);
85310 if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
85311 checkImportBinding(node);
85312 if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
85313 markExportAsReferenced(node);
85314 }
85315 if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) {
85316 var target = resolveAlias(getSymbolOfNode(node));
85317 if (target !== unknownSymbol) {
85318 if (target.flags & 111551 /* SymbolFlags.Value */) {
85319 // Target is a value symbol, check that it is not hidden by a local declaration with the same name
85320 var moduleName = ts.getFirstIdentifier(node.moduleReference);
85321 if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
85322 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
85323 }
85324 }
85325 if (target.flags & 788968 /* SymbolFlags.Type */) {
85326 checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
85327 }
85328 }
85329 if (node.isTypeOnly) {
85330 grammarErrorOnNode(node, ts.Diagnostics.An_import_alias_cannot_use_import_type);
85331 }
85332 }
85333 else {
85334 if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
85335 // Import equals declaration is deprecated in es6 or above
85336 grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
85337 }
85338 }
85339 }
85340 }
85341 function checkExportDeclaration(node) {
85342 if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
85343 // If we hit an export in an illegal context, just bail out to avoid cascading errors.

Callers 1

checkSourceElementWorkerFunction · 0.85

Calls 11

checkImportBindingFunction · 0.85
markExportAsReferencedFunction · 0.85
resolveAliasFunction · 0.85
getSymbolOfNodeFunction · 0.85
resolveEntityNameFunction · 0.85
checkTypeNameIsReservedFunction · 0.85
grammarErrorOnNodeFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…