* This *just* extracts options/include/exclude/files out of a config file. * It does *not* resolve the included files.
(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache)
| 41641 | * It does *not* resolve the included files. |
| 41642 | */ |
| 41643 | function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) { |
| 41644 | var _a; |
| 41645 | basePath = ts.normalizeSlashes(basePath); |
| 41646 | var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); |
| 41647 | if (resolutionStack.indexOf(resolvedPath) >= 0) { |
| 41648 | errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArray(__spreadArray([], resolutionStack, true), [resolvedPath], false).join(" -> "))); |
| 41649 | return { raw: json || convertToObject(sourceFile, errors) }; |
| 41650 | } |
| 41651 | var ownConfig = json ? |
| 41652 | parseOwnConfigOfJson(json, host, basePath, configFileName, errors) : |
| 41653 | parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors); |
| 41654 | if ((_a = ownConfig.options) === null || _a === void 0 ? void 0 : _a.paths) { |
| 41655 | // If we end up needing to resolve relative paths from 'paths' relative to |
| 41656 | // the config file location, we'll need to know where that config file was. |
| 41657 | // Since 'paths' can be inherited from an extended config in another directory, |
| 41658 | // we wouldn't know which directory to use unless we store it here. |
| 41659 | ownConfig.options.pathsBasePath = basePath; |
| 41660 | } |
| 41661 | if (ownConfig.extendedConfigPath) { |
| 41662 | // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. |
| 41663 | resolutionStack = resolutionStack.concat([resolvedPath]); |
| 41664 | var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); |
| 41665 | if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { |
| 41666 | var baseRaw_1 = extendedConfig.raw; |
| 41667 | var raw_1 = ownConfig.raw; |
| 41668 | var relativeDifference_1; |
| 41669 | var setPropertyInRawIfNotUndefined = function (propertyName) { |
| 41670 | if (!raw_1[propertyName] && baseRaw_1[propertyName]) { |
| 41671 | raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); |
| 41672 | } |
| 41673 | }; |
| 41674 | setPropertyInRawIfNotUndefined("include"); |
| 41675 | setPropertyInRawIfNotUndefined("exclude"); |
| 41676 | setPropertyInRawIfNotUndefined("files"); |
| 41677 | if (raw_1.compileOnSave === undefined) { |
| 41678 | raw_1.compileOnSave = baseRaw_1.compileOnSave; |
| 41679 | } |
| 41680 | ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options); |
| 41681 | ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ? |
| 41682 | ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) : |
| 41683 | ownConfig.watchOptions || extendedConfig.watchOptions; |
| 41684 | // TODO extend type typeAcquisition |
| 41685 | } |
| 41686 | } |
| 41687 | return ownConfig; |
| 41688 | } |
| 41689 | function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) { |
| 41690 | if (ts.hasProperty(json, "excludes")) { |
| 41691 | errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); |
no test coverage detected