(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly)
| 153371 | return true; |
| 153372 | } |
| 153373 | function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) { |
| 153374 | var isJs = ts.isSourceFileJS(sourceFile); |
| 153375 | var compilerOptions = program.getCompilerOptions(); |
| 153376 | var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); |
| 153377 | var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); }); |
| 153378 | var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions)); |
| 153379 | var getModuleSpecifiers = fromCacheOnly |
| 153380 | ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); } |
| 153381 | : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); }; |
| 153382 | var computedWithoutCacheCount = 0; |
| 153383 | var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { |
| 153384 | var checker = getChecker(exportInfo.isFromPackageJson); |
| 153385 | var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; |
| 153386 | var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); |
| 153387 | var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); |
| 153388 | computedWithoutCacheCount += computedWithoutCache ? 1 : 0; |
| 153389 | return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { |
| 153390 | return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : |
| 153391 | // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. |
| 153392 | !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : |
| 153393 | { |
| 153394 | kind: 3 /* ImportFixKind.AddNew */, |
| 153395 | moduleSpecifier: moduleSpecifier, |
| 153396 | importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), |
| 153397 | useRequire: useRequire, |
| 153398 | addAsTypeOnly: addAsTypeOnly, |
| 153399 | exportInfo: exportInfo, |
| 153400 | isReExport: i > 0, |
| 153401 | }; |
| 153402 | }); |
| 153403 | }); |
| 153404 | return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes }; |
| 153405 | } |
| 153406 | function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) { |
| 153407 | var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); }); |
| 153408 | return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly); |
no test coverage detected