* Given a set of options, returns the set of type directive names * that should be included for this program automatically. * This list could either come from the config file, * or from enumerating the types root + initial secondary types lookup location. * More type directiv
(options, host)
| 42721 | * this list is only the set of defaults that are implicitly included. |
| 42722 | */ |
| 42723 | function getAutomaticTypeDirectiveNames(options, host) { |
| 42724 | // Use explicit type list from tsconfig.json |
| 42725 | if (options.types) { |
| 42726 | return options.types; |
| 42727 | } |
| 42728 | // Walk the primary type lookup locations |
| 42729 | var result = []; |
| 42730 | if (host.directoryExists && host.getDirectories) { |
| 42731 | var typeRoots = getEffectiveTypeRoots(options, host); |
| 42732 | if (typeRoots) { |
| 42733 | for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { |
| 42734 | var root = typeRoots_1[_i]; |
| 42735 | if (host.directoryExists(root)) { |
| 42736 | for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { |
| 42737 | var typeDirectivePath = _b[_a]; |
| 42738 | var normalized = ts.normalizePath(typeDirectivePath); |
| 42739 | var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); |
| 42740 | // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. |
| 42741 | // See `createNotNeededPackageJSON` in the types-publisher` repo. |
| 42742 | // eslint-disable-next-line no-null/no-null |
| 42743 | var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; |
| 42744 | if (!isNotNeededPackage) { |
| 42745 | var baseFileName = ts.getBaseFileName(normalized); |
| 42746 | // At this stage, skip results with leading dot. |
| 42747 | if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { |
| 42748 | // Return just the type directive names |
| 42749 | result.push(baseFileName); |
| 42750 | } |
| 42751 | } |
| 42752 | } |
| 42753 | } |
| 42754 | } |
| 42755 | } |
| 42756 | } |
| 42757 | return result; |
| 42758 | } |
| 42759 | ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; |
| 42760 | /*@internal*/ |
| 42761 | function createCacheWithRedirects(options) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…