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

Function checkExternalImportOrExportDeclaration

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

Source from the content-addressed store, hash-verified

85090 }
85091 }
85092 function checkExternalImportOrExportDeclaration(node) {
85093 var moduleName = ts.getExternalModuleName(node);
85094 if (!moduleName || ts.nodeIsMissing(moduleName)) {
85095 // Should be a parse error.
85096 return false;
85097 }
85098 if (!ts.isStringLiteral(moduleName)) {
85099 error(moduleName, ts.Diagnostics.String_literal_expected);
85100 return false;
85101 }
85102 var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
85103 if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) {
85104 error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ?
85105 ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
85106 ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
85107 return false;
85108 }
85109 if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
85110 // we have already reported errors on top level imports/exports in external module augmentations in checkModuleDeclaration
85111 // no need to do this again.
85112 if (!isTopLevelInExternalModuleAugmentation(node)) {
85113 // TypeScript 1.0 spec (April 2013): 12.1.6
85114 // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference
85115 // other external modules only through top - level external module names.
85116 // Relative external module names are not permitted.
85117 error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
85118 return false;
85119 }
85120 }
85121 if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
85122 var hasError = false;
85123 for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
85124 var clause = _a[_i];
85125 if (!ts.isStringLiteral(clause.value)) {
85126 hasError = true;
85127 error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
85128 }
85129 }
85130 return !hasError;
85131 }
85132 return true;
85133 }
85134 function checkAliasSymbol(node) {
85135 var symbol = getSymbolOfNode(node);
85136 var target = resolveAlias(symbol);

Callers 3

checkImportDeclarationFunction · 0.85
checkExportDeclarationFunction · 0.85

Calls 2

errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…