(file)
| 117969 | return externalHelpersModuleReference; |
| 117970 | } |
| 117971 | function collectExternalModuleReferences(file) { |
| 117972 | if (file.imports) { |
| 117973 | return; |
| 117974 | } |
| 117975 | var isJavaScriptFile = ts.isSourceFileJS(file); |
| 117976 | var isExternalModuleFile = ts.isExternalModule(file); |
| 117977 | // file.imports may not be undefined if there exists dynamic import |
| 117978 | var imports; |
| 117979 | var moduleAugmentations; |
| 117980 | var ambientModules; |
| 117981 | // If we are importing helpers, we need to add a synthetic reference to resolve the |
| 117982 | // helpers library. |
| 117983 | if ((options.isolatedModules || isExternalModuleFile) |
| 117984 | && !file.isDeclarationFile) { |
| 117985 | if (options.importHelpers) { |
| 117986 | // synthesize 'import "tslib"' declaration |
| 117987 | imports = [createSyntheticImport(ts.externalHelpersModuleNameText, file)]; |
| 117988 | } |
| 117989 | var jsxImport = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(options, file), options); |
| 117990 | if (jsxImport) { |
| 117991 | // synthesize `import "base/jsx-runtime"` declaration |
| 117992 | (imports || (imports = [])).push(createSyntheticImport(jsxImport, file)); |
| 117993 | } |
| 117994 | } |
| 117995 | for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { |
| 117996 | var node = _a[_i]; |
| 117997 | collectModuleReferences(node, /*inAmbientModule*/ false); |
| 117998 | } |
| 117999 | if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { |
| 118000 | collectDynamicImportOrRequireCalls(file); |
| 118001 | } |
| 118002 | file.imports = imports || ts.emptyArray; |
| 118003 | file.moduleAugmentations = moduleAugmentations || ts.emptyArray; |
| 118004 | file.ambientModuleNames = ambientModules || ts.emptyArray; |
| 118005 | return; |
| 118006 | function collectModuleReferences(node, inAmbientModule) { |
| 118007 | if (ts.isAnyImportOrReExport(node)) { |
| 118008 | var moduleNameExpr = ts.getExternalModuleName(node); |
| 118009 | // TypeScript 1.0 spec (April 2014): 12.1.6 |
| 118010 | // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules |
| 118011 | // only through top - level external module names. Relative external module names are not permitted. |
| 118012 | if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) { |
| 118013 | ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here |
| 118014 | imports = ts.append(imports, moduleNameExpr); |
| 118015 | if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) { |
| 118016 | usesUriStyleNodeCoreModules = ts.startsWith(moduleNameExpr.text, "node:"); |
| 118017 | } |
| 118018 | } |
| 118019 | } |
| 118020 | else if (ts.isModuleDeclaration(node)) { |
| 118021 | if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { |
| 118022 | node.name.parent = node; |
| 118023 | var nameText = ts.getTextOfIdentifierOrLiteral(node.name); |
| 118024 | // Ambient module declarations can be interpreted as augmentations for some existing external modules. |
| 118025 | // This will happen in two cases: |
| 118026 | // - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope |
| 118027 | // - if current file is not external module then module augmentation is an ambient module declaration with non-relative module name |
| 118028 | // immediately nested in top level ambient module declaration . |
no test coverage detected
searching dependent graphs…