MCPcopy Create free account
hub / github.com/nodejs/node / getImport

Function getImport

test/fixtures/snapshot/typescript.js:136677–136698  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136675 }
136676 }
136677 function getImport() {
136678 var isImport = isNodeImport(node);
136679 if (!isImport)
136680 return undefined;
136681 // A symbol being imported is always an alias. So get what that aliases to find the local symbol.
136682 var importedSymbol = checker.getImmediateAliasedSymbol(symbol);
136683 if (!importedSymbol)
136684 return undefined;
136685 // Search on the local symbol in the exporting module, not the exported symbol.
136686 importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker);
136687 // Similarly, skip past the symbol for 'export ='
136688 if (importedSymbol.escapedName === "export=") {
136689 importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker);
136690 }
136691 // If the import has a different name than the export, do not continue searching.
136692 // If `importedName` is undefined, do continue searching as the export is anonymous.
136693 // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.)
136694 var importedName = ts.symbolEscapedNameNoDefault(importedSymbol);
136695 if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) {
136696 return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol };
136697 }
136698 }
136699 function exportInfo(symbol, kind) {
136700 var exportInfo = getExportInfo(symbol, kind, checker);
136701 return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo };

Callers 1

getImportOrExportSymbolFunction · 0.85

Calls 3

isNodeImportFunction · 0.85

Tested by

no test coverage detected