From 9fcd0d6739066e98b8093d05431db7add7d80ee7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 2 Apr 2024 12:12:50 -0700 Subject: [PATCH] Allow $configDir as a string to be substituted in config file options --- src/compiler/commandLineParser.ts | 165 ++++- src/compiler/types.ts | 6 +- src/compiler/watch.ts | 7 +- src/server/editorServices.ts | 38 +- src/testRunner/tests.ts | 1 + .../config/configurationExtension.ts | 43 ++ src/testRunner/unittests/config/showConfig.ts | 15 + .../config/tsconfigParsingWatchOptions.ts | 12 + src/testRunner/unittests/helpers/extends.ts | 68 ++ src/testRunner/unittests/tsbuild/extends.ts | 14 +- .../unittests/tsbuildWatch/extends.ts | 20 + src/testRunner/unittests/tsc/extends.ts | 28 +- src/testRunner/unittests/tscWatch/extends.ts | 19 +- src/testRunner/unittests/tsserver/extends.ts | 25 +- ...only once under a case insensitive host.js | 75 +++ ...y only once under a case sensitive host.js | 75 +++ ...only once under a case insensitive host.js | 75 +++ ...s only once under a case sensitive host.js | 75 +++ ...r a case insensitive host with json api.js | 138 ++++ ...nsensitive host with jsonSourceFile api.js | 138 ++++ ...der a case sensitive host with json api.js | 138 ++++ ... sensitive host with jsonSourceFile api.js | 138 ++++ .../tsconfig.json | 27 + ...ig file with watchOptions with json api.js | 29 + ...th watchOptions with jsonSourceFile api.js | 29 + .../tsbuild/extends/configDir-template.js | 189 ++++++ .../extends/configDir-template.js | 386 +++++++++++ .../extends/configDir-template-showConfig.js | 144 +++++ .../configDir-template-with-commandline.js | 182 ++++++ .../tsc/extends/configDir-template.js | 182 ++++++ .../tscWatch/extends/configDir-template.js | 444 +++++++++++++ .../tsserver/tsserver/configDir-template.js | 598 ++++++++++++++++++ 32 files changed, 3489 insertions(+), 34 deletions(-) create mode 100644 src/testRunner/unittests/tsbuildWatch/extends.ts create mode 100644 tests/baselines/reference/config/showConfig/Show TSConfig with configDir template template/tsconfig.json create mode 100644 tests/baselines/reference/tsbuild/extends/configDir-template.js create mode 100644 tests/baselines/reference/tsbuildWatch/extends/configDir-template.js create mode 100644 tests/baselines/reference/tsc/extends/configDir-template-showConfig.js create mode 100644 tests/baselines/reference/tsc/extends/configDir-template-with-commandline.js create mode 100644 tests/baselines/reference/tsc/extends/configDir-template.js create mode 100644 tests/baselines/reference/tscWatch/extends/configDir-template.js create mode 100644 tests/baselines/reference/tsserver/tsserver/configDir-template.js diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index ade646ba086d0..b14a97dc1a37e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -53,6 +53,7 @@ import { getFileMatcherPatterns, getLocaleSpecificMessage, getNormalizedAbsolutePath, + getOwnKeys, getRegexFromPattern, getRegularExpressionForWildcard, getRegularExpressionsForWildcards, @@ -313,6 +314,7 @@ export const optionsForWatch: CommandLineOption[] = [ isFilePath: true, extraValidation: specToDiagnostic, }, + allowConfigDirTemplateSubstitution: true, category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Remove_a_list_of_directories_from_the_watch_process, }, @@ -325,6 +327,7 @@ export const optionsForWatch: CommandLineOption[] = [ isFilePath: true, extraValidation: specToDiagnostic, }, + allowConfigDirTemplateSubstitution: true, category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing, }, @@ -1033,6 +1036,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ name: "paths", type: "object", affectsModuleResolution: true, + allowConfigDirTemplateSubstitution: true, isTSConfigOnly: true, category: Diagnostics.Modules, description: Diagnostics.Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations, @@ -1050,6 +1054,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ isFilePath: true, }, affectsModuleResolution: true, + allowConfigDirTemplateSubstitution: true, category: Diagnostics.Modules, description: Diagnostics.Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules, transpileOptionValue: undefined, @@ -1064,6 +1069,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ isFilePath: true, }, affectsModuleResolution: true, + allowConfigDirTemplateSubstitution: true, category: Diagnostics.Modules, description: Diagnostics.Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types, }, @@ -1599,6 +1605,15 @@ export const optionsAffectingProgramStructure: readonly CommandLineOption[] = op /** @internal */ export const transpileOptionValueCompilerOptions: readonly CommandLineOption[] = optionDeclarations.filter(option => hasProperty(option, "transpileOptionValue")); +/** @internal */ +export const configDirTemplateSubstitutionOptions: readonly CommandLineOption[] = optionDeclarations.filter( + option => option.allowConfigDirTemplateSubstitution || (!option.isCommandLineOnly && option.isFilePath), +); +/** @internal */ +export const configDirTemplateSubstitutionWatchOptions: readonly CommandLineOption[] = optionsForWatch.filter( + option => option.allowConfigDirTemplateSubstitution || (!option.isCommandLineOnly && option.isFilePath), +); + // Build related options /** @internal */ export const optionsForBuild: CommandLineOption[] = [ @@ -2627,6 +2642,9 @@ function serializeOptionBaseObject( if (pathOptions && optionDefinition.isFilePath) { result.set(name, getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(value as string, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName!)); } + else if (pathOptions && optionDefinition.type === "list" && optionDefinition.element.isFilePath) { + result.set(name, (value as string[]).map(v => getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(v, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName!))); + } else { result.set(name, value); } @@ -2890,16 +2908,17 @@ function parseJsonConfigFileContentWorker( const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache); const { raw } = parsedConfig; const options = extend(existingOptions, parsedConfig.options || {}); - const watchOptions = existingWatchOptions && parsedConfig.watchOptions ? + let watchOptions = existingWatchOptions && parsedConfig.watchOptions ? extend(existingWatchOptions, parsedConfig.watchOptions) : parsedConfig.watchOptions || existingWatchOptions; - + handleOptionConfigDirTemplateSubstitution(options, configDirTemplateSubstitutionOptions, basePath); + watchOptions = handleWatchOptionsConfigDirTemplateSubstitution(watchOptions, basePath, !existingWatchOptions || !parsedConfig.watchOptions); options.configFilePath = configFileName && normalizeSlashes(configFileName); + const basePathForFileNames = normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath); const configFileSpecs = getConfigFileSpecs(); if (sourceFile) sourceFile.configFileSpecs = configFileSpecs; setConfigFileInOptions(options, sourceFile); - const basePathForFileNames = normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath); return { options, watchOptions, @@ -2954,6 +2973,7 @@ function parseJsonConfigFileContentWorker( includeSpecs = [defaultIncludeSpec]; isDefaultIncludeSpec = true; } + let validatedIncludeSpecsBeforeSubstitution: readonly string[] | undefined, validatedExcludeSpecsBeforeSubstitution: readonly string[] | undefined; let validatedIncludeSpecs: readonly string[] | undefined, validatedExcludeSpecs: readonly string[] | undefined; // The exclude spec list is converted into a regular expression, which allows us to quickly @@ -2961,20 +2981,40 @@ function parseJsonConfigFileContentWorker( // file system. if (includeSpecs) { - validatedIncludeSpecs = validateSpecs(includeSpecs, errors, /*disallowTrailingRecursion*/ true, sourceFile, "include"); + validatedIncludeSpecsBeforeSubstitution = validateSpecs(includeSpecs, errors, /*disallowTrailingRecursion*/ true, sourceFile, "include"); + validatedIncludeSpecs = getSubstitutedStringArrayWithConfigDirTemplate( + validatedIncludeSpecsBeforeSubstitution, + basePathForFileNames, + /*createCopyOnSubstitute*/ true, + ) || validatedIncludeSpecsBeforeSubstitution; } if (excludeSpecs) { - validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, /*disallowTrailingRecursion*/ false, sourceFile, "exclude"); + validatedExcludeSpecsBeforeSubstitution = validateSpecs(excludeSpecs, errors, /*disallowTrailingRecursion*/ false, sourceFile, "exclude"); + validatedExcludeSpecs = getSubstitutedStringArrayWithConfigDirTemplate( + validatedExcludeSpecsBeforeSubstitution, + basePathForFileNames, + /*createCopyOnSubstitute*/ true, + ) || validatedExcludeSpecsBeforeSubstitution; } + const validatedFilesSpecBeforeSubstitution = filter(filesSpecs, isString); + const validatedFilesSpec = getSubstitutedStringArrayWithConfigDirTemplate( + validatedFilesSpecBeforeSubstitution, + basePathForFileNames, + /*createCopyOnSubstitute*/ true, + ) || validatedFilesSpecBeforeSubstitution; + return { filesSpecs, includeSpecs, excludeSpecs, - validatedFilesSpec: filter(filesSpecs, isString), + validatedFilesSpec, validatedIncludeSpecs, validatedExcludeSpecs, + validatedFilesSpecBeforeSubstitution, + validatedIncludeSpecsBeforeSubstitution, + validatedExcludeSpecsBeforeSubstitution, pathPatterns: undefined, // Initialized on first use isDefaultIncludeSpec, }; @@ -3042,6 +3082,98 @@ function parseJsonConfigFileContentWorker( } } +/** @internal */ +export function handleWatchOptionsConfigDirTemplateSubstitution( + watchOptions: WatchOptions | undefined, + basePath: string, + createCopyOnSubstitute?: boolean, +) { + return handleOptionConfigDirTemplateSubstitution(watchOptions, configDirTemplateSubstitutionWatchOptions, basePath, createCopyOnSubstitute) as WatchOptions | undefined; +} + +function handleOptionConfigDirTemplateSubstitution( + options: OptionsBase | undefined, + optionDeclarations: readonly CommandLineOption[], + basePath: string, + createCopyOnSubstitute?: boolean, +) { + if (!options) return options; + let result: OptionsBase | undefined; + for (const option of optionDeclarations) { + if (options[option.name] !== undefined) { + const value = options[option.name]; + switch (option.type) { + case "string": + Debug.assert(option.isFilePath); + if (startsWithConfigDirTemplate(value)) { + setOptionValue(option, getSubstitutedPathWithConfigDirTemplate(value, basePath)); + } + break; + case "list": + Debug.assert(option.element.isFilePath); + const listResult = getSubstitutedStringArrayWithConfigDirTemplate(value as string[], basePath, createCopyOnSubstitute); + if (listResult) setOptionValue(option, listResult); + break; + case "object": + Debug.assert(option.name === "paths"); + const objectResult = getSubstitutedMapLikeOfStringArrayWithConfigDirTemplate(value as MapLike, basePath, createCopyOnSubstitute); + if (objectResult) setOptionValue(option, objectResult); + break; + default: + Debug.fail("option type not supported"); + } + } + } + return result || options; + + function setOptionValue(option: CommandLineOption, value: CompilerOptionsValue) { + if (createCopyOnSubstitute) { + if (!result) result = assign({}, options); + result[option.name] = value; + } + else { + options![option.name] = value; + } + } +} + +const configDirTemplate = `\${configDir}`; +function startsWithConfigDirTemplate(value: any): value is string { + return isString(value) && startsWith(value, configDirTemplate, /*ignoreCase*/ true); +} + +function getSubstitutedPathWithConfigDirTemplate(value: string, basePath: string) { + return getNormalizedAbsolutePath(value.replace(configDirTemplate, "./"), basePath); +} + +function getSubstitutedStringArrayWithConfigDirTemplate(list: string[] | undefined, basePath: string, createCopyOnSubstitute?: boolean): string[] | undefined; +function getSubstitutedStringArrayWithConfigDirTemplate(list: readonly string[] | undefined, basePath: string, createCopyOnSubstitute: true): string[] | undefined; +function getSubstitutedStringArrayWithConfigDirTemplate(list: readonly string[] | string[] | undefined, basePath: string, createCopyOnSubstitute?: boolean) { + if (!list) return list; + let result: string[] | undefined; + list.forEach((element, index) => { + if (!startsWithConfigDirTemplate(element)) return; + if (createCopyOnSubstitute) result ??= list.slice(); + else result ??= list as unknown as string[]; + result[index] = getSubstitutedPathWithConfigDirTemplate(element, basePath); + }); + return result; +} + +function getSubstitutedMapLikeOfStringArrayWithConfigDirTemplate(mapLike: MapLike, basePath: string, createCopyOnSubstitute?: boolean) { + let result: MapLike | undefined; + const ownKeys = getOwnKeys(mapLike); + ownKeys.forEach(key => { + if (!isArray(mapLike[key])) return; + const subStitution = getSubstitutedStringArrayWithConfigDirTemplate(mapLike[key], basePath, createCopyOnSubstitute); + if (!subStitution) return; + if (createCopyOnSubstitute) result ??= assign({}, mapLike); + else result ??= mapLike; + mapLike[key] = subStitution; + }); + return result; +} + function isErrorNoInputFiles(error: Diagnostic) { return error.code === Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code; } @@ -3143,9 +3275,10 @@ function parseConfig( else { ownConfig.extendedConfigPath.forEach(extendedConfigPath => applyExtendedConfig(result, extendedConfigPath)); } - if (!ownConfig.raw.include && result.include) ownConfig.raw.include = result.include; - if (!ownConfig.raw.exclude && result.exclude) ownConfig.raw.exclude = result.exclude; - if (!ownConfig.raw.files && result.files) ownConfig.raw.files = result.files; + if (result.include) ownConfig.raw.include = result.include; + if (result.exclude) ownConfig.raw.exclude = result.exclude; + if (result.files) ownConfig.raw.files = result.files; + if (ownConfig.raw.compileOnSave === undefined && result.compileOnSave) ownConfig.raw.compileOnSave = result.compileOnSave; if (sourceFile && result.extendedSourceFiles) sourceFile.extendedSourceFiles = arrayFrom(result.extendedSourceFiles.keys()); @@ -3162,12 +3295,15 @@ function parseConfig( const extendsRaw = extendedConfig.raw; let relativeDifference: string | undefined; const setPropertyInResultIfNotUndefined = (propertyName: "include" | "exclude" | "files") => { + if (ownConfig.raw[propertyName]) return; // No need to calculate if already set in own config if (extendsRaw[propertyName]) { result[propertyName] = map(extendsRaw[propertyName], (path: string) => - isRootedDiskPath(path) ? path : combinePaths( - relativeDifference ||= convertToRelativePath(getDirectoryPath(extendedConfigPath), basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames)), - path, - )); + startsWithConfigDirTemplate(path) || isRootedDiskPath(path) ? + path : + combinePaths( + relativeDifference ||= convertToRelativePath(getDirectoryPath(extendedConfigPath), basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames)), + path, + )); } }; setPropertyInResultIfNotUndefined("include"); @@ -3526,7 +3662,8 @@ export function convertJsonOption( function normalizeNonListOptionValue(option: CommandLineOption, basePath: string, value: any): CompilerOptionsValue { if (option.isFilePath) { - value = getNormalizedAbsolutePath(value, basePath); + value = normalizeSlashes(value); + value = !startsWithConfigDirTemplate(value) ? getNormalizedAbsolutePath(value, basePath) : value; if (value === "") { value = "."; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 63b77f84dbcc9..2c57c8fb69cb6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7360,6 +7360,9 @@ export interface ConfigFileSpecs { validatedFilesSpec: readonly string[] | undefined; validatedIncludeSpecs: readonly string[] | undefined; validatedExcludeSpecs: readonly string[] | undefined; + validatedFilesSpecBeforeSubstitution: readonly string[] | undefined; + validatedIncludeSpecsBeforeSubstitution: readonly string[] | undefined; + validatedExcludeSpecsBeforeSubstitution: readonly string[] | undefined; pathPatterns: readonly (string | Pattern)[] | undefined; isDefaultIncludeSpec: boolean; } @@ -7406,7 +7409,8 @@ export interface CommandLineOptionBase { affectsBuildInfo?: true; // true if this options should be emitted in buildInfo transpileOptionValue?: boolean | undefined; // If set this means that the option should be set to this value when transpiling extraValidation?: (value: CompilerOptionsValue) => [DiagnosticMessage, ...string[]] | undefined; // Additional validation to be performed for the value to be valid - disallowNullOrUndefined?: true; // If set option does not allow setting null + disallowNullOrUndefined?: true; // If set option does not allow setting null + allowConfigDirTemplateSubstitution?: true; // If set option allows substitution of `${configDir}` in the value } /** @internal */ diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 2e89d636e0c71..1b35f1cdb0f54 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -44,6 +44,7 @@ import { FileWatcher, filter, find, + findIndex, flattenDiagnosticMessageText, forEach, forEachEntry, @@ -416,7 +417,8 @@ export function getMatchedFileSpec(program: Program, fileName: string) { const filePath = program.getCanonicalFileName(fileName); const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); - return find(configFile.configFileSpecs.validatedFilesSpec, fileSpec => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath); + const index = findIndex(configFile.configFileSpecs.validatedFilesSpec, fileSpec => program.getCanonicalFileName(getNormalizedAbsolutePath(fileSpec, basePath)) === filePath); + return index !== -1 ? configFile.configFileSpecs.validatedFilesSpecBeforeSubstitution![index] : undefined; } /** @internal */ @@ -430,11 +432,12 @@ export function getMatchedIncludeSpec(program: Program, fileName: string) { const isJsonFile = fileExtensionIs(fileName, Extension.Json); const basePath = getDirectoryPath(getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); const useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); - return find(configFile?.configFileSpecs?.validatedIncludeSpecs, includeSpec => { + const index = findIndex(configFile?.configFileSpecs?.validatedIncludeSpecs, includeSpec => { if (isJsonFile && !endsWith(includeSpec, Extension.Json)) return false; const pattern = getPatternFromSpec(includeSpec, basePath, "files"); return !!pattern && getRegexFromPattern(`(${pattern})$`, useCaseSensitiveFileNames).test(fileName); }); + return index !== -1 ? configFile.configFileSpecs.validatedIncludeSpecsBeforeSubstitution![index] : undefined; } /** @internal */ diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 1a27eae83c1cf..f1721e458bbd1 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -58,6 +58,7 @@ import { getPathComponents, getSnapshotText, getWatchFactory, + handleWatchOptionsConfigDirTemplateSubstitution, hasExtension, hasProperty, hasTSFileExtension, @@ -515,6 +516,7 @@ export interface HostConfiguration { hostInfo: string; extraFileExtensions?: FileExtensionInfo[]; watchOptions?: WatchOptions; + /** @internal */ beforeSubstitution?: WatchOptions; } export interface OpenConfiguredProjectResult { @@ -1721,7 +1723,7 @@ export class ProjectService { }); }, flags, - this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine!.watchOptions), + this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine!.watchOptions, getDirectoryPath(configFileName)), WatchType.WildcardDirectory, configFileName, ); @@ -2058,7 +2060,7 @@ export class ProjectService { configFileName, (_fileName, eventKind) => this.onConfigFileChanged(canonicalConfigFilePath, eventKind), PollingInterval.High, - this.getWatchOptionsFromProjectWatchOptions(configFileExistenceInfo?.config?.parsedCommandLine?.watchOptions), + this.getWatchOptionsFromProjectWatchOptions(configFileExistenceInfo?.config?.parsedCommandLine?.watchOptions, getDirectoryPath(configFileName)), WatchType.ConfigFile, forProject, ); @@ -2581,13 +2583,14 @@ export class ProjectService { const configFile = parseJsonText(configFilename, isString(configFileContent) ? configFileContent : "") as TsConfigSourceFile; const configFileErrors = configFile.parseDiagnostics as Diagnostic[]; if (!isString(configFileContent)) configFileErrors.push(configFileContent); + const configDir = getDirectoryPath(configFilename); const parsedCommandLine = parseJsonSourceFileConfigFileContent( configFile, cachedDirectoryStructureHost, - getDirectoryPath(configFilename), - /*existingOptions*/ {}, + configDir, + /*existingOptions*/ undefined, configFilename, - /*resolutionStack*/ [], + /*resolutionStack*/ undefined, this.hostConfiguration.extraFileExtensions, this.extendedConfigCache, ); @@ -2623,9 +2626,9 @@ export class ProjectService { if ( !oldCommandLine && !isJsonEqual( // Old options - this.getWatchOptionsFromProjectWatchOptions(/*projectOptions*/ undefined), + this.getWatchOptionsFromProjectWatchOptions(/*projectOptions*/ undefined, configDir), // New options - this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions), + this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions, configDir), ) ) { // Reset the config file watcher @@ -3460,7 +3463,10 @@ export class ProjectService { } if (args.watchOptions) { - this.hostConfiguration.watchOptions = convertWatchOptions(args.watchOptions)?.watchOptions; + const watchOptions = convertWatchOptions(args.watchOptions)?.watchOptions; + const substitution = handleWatchOptionsConfigDirTemplateSubstitution(watchOptions, this.currentDirectory, /*createCopyOnSubstitute*/ true); + this.hostConfiguration.watchOptions = substitution; + this.hostConfiguration.beforeSubstitution = substitution === watchOptions ? undefined : watchOptions; this.logger.info(`Host watch options changed to ${JSON.stringify(this.hostConfiguration.watchOptions)}, it will be take effect for next watches.`); } } @@ -3468,14 +3474,20 @@ export class ProjectService { /** @internal */ getWatchOptions(project: Project) { - return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions()); + return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions(), project.getCurrentDirectory()); } /** @internal */ - private getWatchOptionsFromProjectWatchOptions(projectOptions: WatchOptions | undefined) { - return projectOptions && this.hostConfiguration.watchOptions ? - { ...this.hostConfiguration.watchOptions, ...projectOptions } : - projectOptions || this.hostConfiguration.watchOptions; + private getWatchOptionsFromProjectWatchOptions(projectOptions: WatchOptions | undefined, basePath: string) { + const hostWatchOptions = !this.hostConfiguration.beforeSubstitution ? this.hostConfiguration.watchOptions : + handleWatchOptionsConfigDirTemplateSubstitution( + this.hostConfiguration.beforeSubstitution, + basePath, + /*createCopyOnSubstitute*/ true, + ); + return projectOptions && hostWatchOptions ? + { ...hostWatchOptions, ...projectOptions } : + projectOptions || hostWatchOptions; } closeLog() { diff --git a/src/testRunner/tests.ts b/src/testRunner/tests.ts index 9857f6b7fb2d7..fd6f34d435bdb 100644 --- a/src/testRunner/tests.ts +++ b/src/testRunner/tests.ts @@ -98,6 +98,7 @@ import "./unittests/tsbuild/sample"; import "./unittests/tsbuild/transitiveReferences"; import "./unittests/tsbuildWatch/configFileErrors"; import "./unittests/tsbuildWatch/demo"; +import "./unittests/tsbuildWatch/extends"; import "./unittests/tsbuildWatch/libraryResolution"; import "./unittests/tsbuildWatch/moduleResolution"; import "./unittests/tsbuildWatch/noEmit"; diff --git a/src/testRunner/unittests/config/configurationExtension.ts b/src/testRunner/unittests/config/configurationExtension.ts index ce191f5f59ccb..aa1b46beb99c0 100644 --- a/src/testRunner/unittests/config/configurationExtension.ts +++ b/src/testRunner/unittests/config/configurationExtension.ts @@ -253,6 +253,46 @@ function createFileSystem(ignoreCase: boolean, cwd: string, root: string) { }, }), "dev/extendsArrayFails2.json": jsonToReadableText({ extends: [42] }), + "dev/configs/template.json": jsonToReadableText({ + include: ["${configDir}/../supplemental.*"], // eslint-disable-line no-template-curly-in-string + files: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string, + compilerOptions: { + declarationDir: "${configDir}/decls", // eslint-disable-line no-template-curly-in-string + rootDirs: ["root1", "${configDir}/root2", "root3"], // eslint-disable-line no-template-curly-in-string + paths: { + "something": ["${configDir}/something"], // eslint-disable-line no-template-curly-in-string + "something/*": ["${configDir}/something/*"], // eslint-disable-line no-template-curly-in-string + "other/*": ["./other/*"], + }, + }, + }), + + "dev/configs/templateandextends.json": jsonToReadableText({ + extends: "./first/templateextends.json", + compilerOptions: { + strict: true, + baseUrl: "./src", + }, + }), + "dev/configs/first/templateextends.json": jsonToReadableText({ + extends: "../second/templateextends.json", + include: ["${configDir}/../supplemental.*"], // eslint-disable-line no-template-curly-in-string + compilerOptions: { + rootDirs: ["root1", "${configDir}/root2", "root3"], // eslint-disable-line no-template-curly-in-string + }, + }), + "dev/configs/second/templateextends.json": jsonToReadableText({ + files: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string, + compilerOptions: { + outDir: "./insecond", + declarationDir: "${configDir}/decls", // eslint-disable-line no-template-curly-in-string + paths: { + "something": ["${configDir}/something"], // eslint-disable-line no-template-curly-in-string + "something/*": ["${configDir}/something/*"], // eslint-disable-line no-template-curly-in-string + "other/*": ["./other/*"], + }, + }, + }), }, }, }); @@ -302,6 +342,9 @@ describe("unittests:: config:: configurationExtension", () => { baselineParsedCommandLine("can report missing configurations", "extendsArrayFails.json"); baselineParsedCommandLine("can error when 'extends' is not a string or Array2", "extendsArrayFails2.json"); + baselineParsedCommandLine("handle configDir template", "configs/template.json"); + baselineParsedCommandLine("handle configDir template", "configs/templateandextends.json"); + baselineParseConfig({ scenario: "configurationExtension", subScenario: testName, diff --git a/src/testRunner/unittests/config/showConfig.ts b/src/testRunner/unittests/config/showConfig.ts index f870707801cd3..b36023a479eb9 100644 --- a/src/testRunner/unittests/config/showConfig.ts +++ b/src/testRunner/unittests/config/showConfig.ts @@ -115,6 +115,21 @@ describe("unittests:: config:: showConfig", () => { ], }); + showTSConfigCorrectly("Show TSConfig with configDir template template", ["-p", "tsconfig.json"], { + compilerOptions: { + outDir: "${configDir}/outDir", // eslint-disable-line no-template-curly-in-string + typeRoots: ["root1", "${configDir}/root2", "root3"], // eslint-disable-line no-template-curly-in-string + paths: { + "@myscope/*": ["${configDir}/types/*"], // eslint-disable-line no-template-curly-in-string + "other/*": ["other/*"], + }, + }, + include: [ + "${configDir}/src/**/*", // eslint-disable-line no-template-curly-in-string + ], + files: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string + }); + // Bulk validation of all option declarations for (const option of ts.optionDeclarations) { baselineOption(option, /*isCompilerOptions*/ true); diff --git a/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts b/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts index 0474846384905..24837791623a7 100644 --- a/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts +++ b/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts @@ -97,6 +97,18 @@ describe("unittests:: config:: tsconfigParsingWatchOptions:: parseConfigFileText }), }, }, + { + json: { + extends: "./base/tsconfig.json", + }, + additionalFiles: { + "/base/tsconfig.json": jsonToReadableText({ + watchOptions: { + excludeFiles: ["${configDir}/temp/*.ts"], // eslint-disable-line no-template-curly-in-string + }, + }), + }, + }, ]); verifyWatchOptions("different options", () => [ diff --git a/src/testRunner/unittests/helpers/extends.ts b/src/testRunner/unittests/helpers/extends.ts index 0ab23e2bf368c..e9398ab4b4708 100644 --- a/src/testRunner/unittests/helpers/extends.ts +++ b/src/testRunner/unittests/helpers/extends.ts @@ -1,5 +1,6 @@ import { dedent } from "../../_namespaces/Utils"; import { jsonToReadableText } from "../helpers"; +import { FsContents } from "./contents"; import { createServerHost, createWatchedSystem, @@ -31,3 +32,70 @@ export function getSymlinkedExtendsSys(forTsserver?: true): TestServerHost { [libFile.path]: libFile.content, }, { currentDirectory: "/users/user/projects/myproject" }); } + +export function getConfigDirExtendsSys(): FsContents { + return { + "/home/src/projects/configs/first/tsconfig.json": jsonToReadableText({ + extends: "../second/tsconfig.json", + include: ["${configDir}/src"], // eslint-disable-line no-template-curly-in-string + compilerOptions: { + typeRoots: ["root1", "${configDir}/root2", "root3"], // eslint-disable-line no-template-curly-in-string + types: [], + }, + }), + "/home/src/projects/configs/second/tsconfig.json": jsonToReadableText({ + files: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string, + compilerOptions: { + declarationDir: "${configDir}/decls", // eslint-disable-line no-template-curly-in-string + paths: { + "@myscope/*": ["${configDir}/types/*"], // eslint-disable-line no-template-curly-in-string + "other/*": ["other/*"], + }, + baseUrl: "${configDir}", // eslint-disable-line no-template-curly-in-string + }, + watchOptions: { + excludeFiles: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string + }, + }), + "/home/src/projects/myproject/tsconfig.json": jsonToReadableText({ + extends: "../configs/first/tsconfig.json", + compilerOptions: { + declaration: true, + outDir: "outDir", + traceResolution: true, + }, + }), + + "/home/src/projects/myproject/main.ts": dedent` + // some comment + export const y = 10; + import { x } from "@myscope/sometype"; + `, + "/home/src/projects/myproject/src/secondary.ts": dedent` + // some comment + export const z = 10; + import { k } from "other/sometype2"; + `, + "/home/src/projects/myproject/types/sometype.ts": dedent` + export const x = 10; + `, + "/home/src/projects/myproject/root2/other/sometype2/index.d.ts": dedent` + export const k = 10; + `, + [libFile.path]: libFile.content, + }; +} + +export function modifyFirstExtendedConfigOfConfigDirExtendsSys(sys: TestServerHost) { + sys.modifyFile( + "/home/src/projects/configs/first/tsconfig.json", + jsonToReadableText({ + extends: "../second/tsconfig.json", + include: ["${configDir}/src"], // eslint-disable-line no-template-curly-in-string + compilerOptions: { + typeRoots: ["${configDir}/root2"], // eslint-disable-line no-template-curly-in-string + types: [], + }, + }), + ); +} diff --git a/src/testRunner/unittests/tsbuild/extends.ts b/src/testRunner/unittests/tsbuild/extends.ts index dbf2512e7502a..5a2341306ce4a 100644 --- a/src/testRunner/unittests/tsbuild/extends.ts +++ b/src/testRunner/unittests/tsbuild/extends.ts @@ -1,5 +1,10 @@ -import { getSymlinkedExtendsSys } from "../helpers/extends"; +import { + getConfigDirExtendsSys, + getSymlinkedExtendsSys, +} from "../helpers/extends"; +import { verifyTsc } from "../helpers/tsc"; import { verifyTscWatch } from "../helpers/tscWatch"; +import { loadProjectFromFiles } from "../helpers/vfs"; describe("unittests:: tsbuild:: extends::", () => { verifyTscWatch({ @@ -8,4 +13,11 @@ describe("unittests:: tsbuild:: extends::", () => { sys: getSymlinkedExtendsSys, commandLineArgs: ["-b", "src", "--extendedDiagnostics"], }); + + verifyTsc({ + scenario: "extends", + subScenario: "configDir template", + fs: () => loadProjectFromFiles(getConfigDirExtendsSys(), { cwd: "/home/src/projects/myproject" }), + commandLineArgs: ["-b", "/home/src/projects/myproject", "--explainFiles", "--v"], + }); }); diff --git a/src/testRunner/unittests/tsbuildWatch/extends.ts b/src/testRunner/unittests/tsbuildWatch/extends.ts new file mode 100644 index 0000000000000..5fc08c2795b0f --- /dev/null +++ b/src/testRunner/unittests/tsbuildWatch/extends.ts @@ -0,0 +1,20 @@ +import { + getConfigDirExtendsSys, + modifyFirstExtendedConfigOfConfigDirExtendsSys, +} from "../helpers/extends"; +import { verifyTscWatch } from "../helpers/tscWatch"; +import { createWatchedSystem } from "../helpers/virtualFileSystemWithWatch"; + +describe("unittests:: tsbuildWatch:: watchMode:: extends::", () => { + verifyTscWatch({ + scenario: "extends", + subScenario: "configDir template", + sys: () => createWatchedSystem(getConfigDirExtendsSys(), { currentDirectory: "/home/src/projects/myproject" }), + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--explainFiles", "-v"], + edits: [{ + caption: "edit extended config file", + edit: modifyFirstExtendedConfigOfConfigDirExtendsSys, + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }], + }); +}); diff --git a/src/testRunner/unittests/tsc/extends.ts b/src/testRunner/unittests/tsc/extends.ts index d1e8226517076..19cb499db6472 100644 --- a/src/testRunner/unittests/tsc/extends.ts +++ b/src/testRunner/unittests/tsc/extends.ts @@ -1,5 +1,10 @@ -import { getSymlinkedExtendsSys } from "../helpers/extends"; +import { + getConfigDirExtendsSys, + getSymlinkedExtendsSys, +} from "../helpers/extends"; +import { verifyTsc } from "../helpers/tsc"; import { verifyTscWatch } from "../helpers/tscWatch"; +import { loadProjectFromFiles } from "../helpers/vfs"; describe("unittests:: tsc:: extends::", () => { verifyTscWatch({ @@ -8,4 +13,25 @@ describe("unittests:: tsc:: extends::", () => { sys: getSymlinkedExtendsSys, commandLineArgs: ["-p", "src", "--extendedDiagnostics"], }); + + verifyTsc({ + scenario: "extends", + subScenario: "configDir template", + fs: () => loadProjectFromFiles(getConfigDirExtendsSys(), { cwd: "/home/src/projects/myproject" }), + commandLineArgs: ["-p", "/home/src/projects/myproject", "--explainFiles"], + }); + + verifyTsc({ + scenario: "extends", + subScenario: "configDir template showConfig", + fs: () => loadProjectFromFiles(getConfigDirExtendsSys(), { cwd: "/home/src/projects/myproject" }), + commandLineArgs: ["-p", "/home/src/projects/myproject", "--showConfig"], + }); + + verifyTsc({ + scenario: "extends", + subScenario: "configDir template with commandline", + fs: () => loadProjectFromFiles(getConfigDirExtendsSys(), { cwd: "/home/src/projects/myproject" }), + commandLineArgs: ["-p", "/home/src/projects/myproject", "--explainFiles", "--outDir", "${configDir}/outDir"], // eslint-disable-line no-template-curly-in-string + }); }); diff --git a/src/testRunner/unittests/tscWatch/extends.ts b/src/testRunner/unittests/tscWatch/extends.ts index 86d3fdf2c217d..e325aaede2856 100644 --- a/src/testRunner/unittests/tscWatch/extends.ts +++ b/src/testRunner/unittests/tscWatch/extends.ts @@ -1,5 +1,10 @@ -import { getSymlinkedExtendsSys } from "../helpers/extends"; +import { + getConfigDirExtendsSys, + getSymlinkedExtendsSys, + modifyFirstExtendedConfigOfConfigDirExtendsSys, +} from "../helpers/extends"; import { verifyTscWatch } from "../helpers/tscWatch"; +import { createWatchedSystem } from "../helpers/virtualFileSystemWithWatch"; describe("unittests:: tsc-watch:: extends::", () => { verifyTscWatch({ @@ -8,4 +13,16 @@ describe("unittests:: tsc-watch:: extends::", () => { sys: getSymlinkedExtendsSys, commandLineArgs: ["-w", "-p", "src", "--extendedDiagnostics"], }); + + verifyTscWatch({ + scenario: "extends", + subScenario: "configDir template", + sys: () => createWatchedSystem(getConfigDirExtendsSys(), { currentDirectory: "/home/src/projects/myproject" }), + commandLineArgs: ["-w", "--extendedDiagnostics", "--explainFiles"], + edits: [{ + caption: "edit extended config file", + edit: modifyFirstExtendedConfigOfConfigDirExtendsSys, + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }], + }); }); diff --git a/src/testRunner/unittests/tsserver/extends.ts b/src/testRunner/unittests/tsserver/extends.ts index a722c8a0dfb0e..d3ad57a291f72 100644 --- a/src/testRunner/unittests/tsserver/extends.ts +++ b/src/testRunner/unittests/tsserver/extends.ts @@ -1,9 +1,15 @@ -import { getSymlinkedExtendsSys } from "../helpers/extends"; +import * as ts from "../../_namespaces/ts"; +import { + getConfigDirExtendsSys, + getSymlinkedExtendsSys, + modifyFirstExtendedConfigOfConfigDirExtendsSys, +} from "../helpers/extends"; import { baselineTsserverLogs, openFilesForSession, TestSession, } from "../helpers/tsserver"; +import { createServerHost } from "../helpers/virtualFileSystemWithWatch"; describe("unittests:: tsserver:: extends::", () => { it("resolves the symlink path", () => { @@ -12,4 +18,21 @@ describe("unittests:: tsserver:: extends::", () => { openFilesForSession(["/users/user/projects/myproject/src/index.ts"], session); baselineTsserverLogs("tsserver", "resolves the symlink path", session); }); + + it("configDir template", () => { + const host = createServerHost(getConfigDirExtendsSys(), { currentDirectory: "/home/src/projects/myproject" }); + const session = new TestSession(host); + session.executeCommandSeq({ + command: ts.server.protocol.CommandTypes.Configure, + arguments: { + watchOptions: { + excludeDirectories: ["${configDir}/node_modules"], // eslint-disable-line no-template-curly-in-string + }, + }, + }); + openFilesForSession(["/home/src/projects/myproject/src/secondary.ts"], session); + modifyFirstExtendedConfigOfConfigDirExtendsSys(host); + host.runQueuedTimeoutCallbacks(); + baselineTsserverLogs("tsserver", "configDir template", session); + }); }); diff --git a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case insensitive host.js b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case insensitive host.js index 0a5004eb33118..e76ae1fac0957 100644 --- a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case insensitive host.js +++ b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case insensitive host.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [c:/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [c:/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [c:/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [c:/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [c:/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [c:/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [c:/dev/configs/tests.json] { "compilerOptions": { diff --git a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case sensitive host.js b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case sensitive host.js index 7bfedca3af8f4..3746b79c69c4b 100644 --- a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case sensitive host.js +++ b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles from an array only once under a case sensitive host.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [/dev/configs/tests.json] { "compilerOptions": { diff --git a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case insensitive host.js b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case insensitive host.js index 6436a84efb14a..ac5f10fd9f017 100644 --- a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case insensitive host.js +++ b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case insensitive host.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [c:/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [c:/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [c:/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [c:/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [c:/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [c:/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [c:/dev/configs/tests.json] { "compilerOptions": { diff --git a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case sensitive host.js b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case sensitive host.js index 896d69b9586c3..034c82e526941 100644 --- a/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case sensitive host.js +++ b/tests/baselines/reference/config/configurationExtension/adds extendedSourceFiles only once under a case sensitive host.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [/dev/configs/tests.json] { "compilerOptions": { diff --git a/tests/baselines/reference/config/configurationExtension/under a case insensitive host with json api.js b/tests/baselines/reference/config/configurationExtension/under a case insensitive host with json api.js index 6598d8799d7d4..1308bab2636e3 100644 --- a/tests/baselines/reference/config/configurationExtension/under a case insensitive host with json api.js +++ b/tests/baselines/reference/config/configurationExtension/under a case insensitive host with json api.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [c:/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [c:/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [c:/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [c:/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [c:/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [c:/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [c:/dev/configs/tests.json] { "compilerOptions": { @@ -707,3 +782,66 @@ c:/dev/tests/unit/spec.ts Errors:: error TS5024: Compiler option 'extends' requires a value of type string. + +handle configDir template +configFileName:: configs/template.json +CompilerOptions:: +{ + "declarationDir": "c:/dev/configs/decls", + "rootDirs": [ + "c:/dev/configs/root1", + "c:/dev/configs/root2", + "c:/dev/configs/root3" + ], + "paths": { + "something": [ + "c:/dev/configs/something" + ], + "something/*": [ + "c:/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "configFilePath": "c:/dev/configs/template.json", + "pathsBasePath": "c:/dev/configs" +} +FileNames:: +c:/dev/configs/main.ts +c:/dev/supplemental.ts +Errors:: + + +handle configDir template +configFileName:: configs/templateandextends.json +CompilerOptions:: +{ + "outDir": "c:/dev/configs/second/insecond", + "declarationDir": "c:/dev/configs/decls", + "paths": { + "something": [ + "c:/dev/configs/something" + ], + "something/*": [ + "c:/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "pathsBasePath": "c:/dev/configs/second", + "rootDirs": [ + "c:/dev/configs/first/root1", + "c:/dev/configs/root2", + "c:/dev/configs/first/root3" + ], + "strict": true, + "baseUrl": "c:/dev/configs/src", + "configFilePath": "c:/dev/configs/templateandextends.json" +} +FileNames:: +c:/dev/configs/main.ts +c:/dev/supplemental.ts +Errors:: + diff --git a/tests/baselines/reference/config/configurationExtension/under a case insensitive host with jsonSourceFile api.js b/tests/baselines/reference/config/configurationExtension/under a case insensitive host with jsonSourceFile api.js index edfedcd208a18..6ffa29fef1cb1 100644 --- a/tests/baselines/reference/config/configurationExtension/under a case insensitive host with jsonSourceFile api.js +++ b/tests/baselines/reference/config/configurationExtension/under a case insensitive host with jsonSourceFile api.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [c:/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [c:/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [c:/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [c:/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [c:/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [c:/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [c:/dev/configs/tests.json] { "compilerOptions": { @@ -725,3 +800,66 @@ Errors:: 3 42    ~~ + +handle configDir template +configFileName:: configs/template.json +CompilerOptions:: +{ + "declarationDir": "c:/dev/configs/decls", + "rootDirs": [ + "c:/dev/configs/root1", + "c:/dev/configs/root2", + "c:/dev/configs/root3" + ], + "paths": { + "something": [ + "c:/dev/configs/something" + ], + "something/*": [ + "c:/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "pathsBasePath": "c:/dev/configs", + "configFilePath": "c:/dev/configs/template.json" +} +FileNames:: +c:/dev/configs/main.ts +c:/dev/supplemental.ts +Errors:: + + +handle configDir template +configFileName:: configs/templateandextends.json +CompilerOptions:: +{ + "outDir": "c:/dev/configs/second/insecond", + "declarationDir": "c:/dev/configs/decls", + "paths": { + "something": [ + "c:/dev/configs/something" + ], + "something/*": [ + "c:/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "pathsBasePath": "c:/dev/configs/second", + "rootDirs": [ + "c:/dev/configs/first/root1", + "c:/dev/configs/root2", + "c:/dev/configs/first/root3" + ], + "strict": true, + "baseUrl": "c:/dev/configs/src", + "configFilePath": "c:/dev/configs/templateandextends.json" +} +FileNames:: +c:/dev/configs/main.ts +c:/dev/supplemental.ts +Errors:: + diff --git a/tests/baselines/reference/config/configurationExtension/under a case sensitive host with json api.js b/tests/baselines/reference/config/configurationExtension/under a case sensitive host with json api.js index 15d00a7f345b7..750f0993edc33 100644 --- a/tests/baselines/reference/config/configurationExtension/under a case sensitive host with json api.js +++ b/tests/baselines/reference/config/configurationExtension/under a case sensitive host with json api.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [/dev/configs/tests.json] { "compilerOptions": { @@ -707,3 +782,66 @@ FileNames:: Errors:: error TS5024: Compiler option 'extends' requires a value of type string. + +handle configDir template +configFileName:: configs/template.json +CompilerOptions:: +{ + "declarationDir": "/dev/configs/decls", + "rootDirs": [ + "/dev/configs/root1", + "/dev/configs/root2", + "/dev/configs/root3" + ], + "paths": { + "something": [ + "/dev/configs/something" + ], + "something/*": [ + "/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "configFilePath": "/dev/configs/template.json", + "pathsBasePath": "/dev/configs" +} +FileNames:: +/dev/configs/main.ts +/dev/supplemental.ts +Errors:: + + +handle configDir template +configFileName:: configs/templateandextends.json +CompilerOptions:: +{ + "outDir": "/dev/configs/second/insecond", + "declarationDir": "/dev/configs/decls", + "paths": { + "something": [ + "/dev/configs/something" + ], + "something/*": [ + "/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "pathsBasePath": "/dev/configs/second", + "rootDirs": [ + "/dev/configs/first/root1", + "/dev/configs/root2", + "/dev/configs/first/root3" + ], + "strict": true, + "baseUrl": "/dev/configs/src", + "configFilePath": "/dev/configs/templateandextends.json" +} +FileNames:: +/dev/configs/main.ts +/dev/supplemental.ts +Errors:: + diff --git a/tests/baselines/reference/config/configurationExtension/under a case sensitive host with jsonSourceFile api.js b/tests/baselines/reference/config/configurationExtension/under a case sensitive host with jsonSourceFile api.js index 6e7a3c42700a9..551bd5a8d00a2 100644 --- a/tests/baselines/reference/config/configurationExtension/under a case sensitive host with jsonSourceFile api.js +++ b/tests/baselines/reference/config/configurationExtension/under a case sensitive host with jsonSourceFile api.js @@ -87,6 +87,21 @@ Fs:: "files": [] } +//// [/dev/configs/first/templateextends.json] +{ + "extends": "../second/templateextends.json", + "include": [ + "${configDir}/../supplemental.*" + ], + "compilerOptions": { + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ] + } +} + //// [/dev/configs/first.json] { "extends": "./base", @@ -110,6 +125,28 @@ Fs:: ] } +//// [/dev/configs/second/templateextends.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "outDir": "./insecond", + "declarationDir": "${configDir}/decls", + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + //// [/dev/configs/second.json] { "extends": "./base", @@ -121,6 +158,44 @@ Fs:: ] } +//// [/dev/configs/template.json] +{ + "include": [ + "${configDir}/../supplemental.*" + ], + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "rootDirs": [ + "root1", + "${configDir}/root2", + "root3" + ], + "paths": { + "something": [ + "${configDir}/something" + ], + "something/*": [ + "${configDir}/something/*" + ], + "other/*": [ + "./other/*" + ] + } + } +} + +//// [/dev/configs/templateandextends.json] +{ + "extends": "./first/templateextends.json", + "compilerOptions": { + "strict": true, + "baseUrl": "./src" + } +} + //// [/dev/configs/tests.json] { "compilerOptions": { @@ -725,3 +800,66 @@ Errors:: 3 42    ~~ + +handle configDir template +configFileName:: configs/template.json +CompilerOptions:: +{ + "declarationDir": "/dev/configs/decls", + "rootDirs": [ + "/dev/configs/root1", + "/dev/configs/root2", + "/dev/configs/root3" + ], + "paths": { + "something": [ + "/dev/configs/something" + ], + "something/*": [ + "/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "pathsBasePath": "/dev/configs", + "configFilePath": "/dev/configs/template.json" +} +FileNames:: +/dev/configs/main.ts +/dev/supplemental.ts +Errors:: + + +handle configDir template +configFileName:: configs/templateandextends.json +CompilerOptions:: +{ + "outDir": "/dev/configs/second/insecond", + "declarationDir": "/dev/configs/decls", + "paths": { + "something": [ + "/dev/configs/something" + ], + "something/*": [ + "/dev/configs/something/*" + ], + "other/*": [ + "./other/*" + ] + }, + "pathsBasePath": "/dev/configs/second", + "rootDirs": [ + "/dev/configs/first/root1", + "/dev/configs/root2", + "/dev/configs/first/root3" + ], + "strict": true, + "baseUrl": "/dev/configs/src", + "configFilePath": "/dev/configs/templateandextends.json" +} +FileNames:: +/dev/configs/main.ts +/dev/supplemental.ts +Errors:: + diff --git a/tests/baselines/reference/config/showConfig/Show TSConfig with configDir template template/tsconfig.json b/tests/baselines/reference/config/showConfig/Show TSConfig with configDir template template/tsconfig.json new file mode 100644 index 0000000000000..0838d90611258 --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Show TSConfig with configDir template template/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "outDir": "./outDir", + "typeRoots": [ + "./root1", + "./root2", + "./root3" + ], + "paths": { + "@myscope/*": [ + "/Show TSConfig with configDir template template/types/*" + ], + "other/*": [ + "other/*" + ] + } + }, + "files": [ + "./main.ts" + ], + "include": [ + "/Show TSConfig with configDir template template/src/**/*" + ], + "exclude": [ + "/Show TSConfig with configDir template template/outDir" + ] +} diff --git a/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with json api.js b/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with json api.js index b95fe3e4a4aa6..847ca32c2fe7f 100644 --- a/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with json api.js +++ b/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with json api.js @@ -54,3 +54,32 @@ Result: WatchOptions:: } Errors:: + +Fs:: +//// [/a.ts] + + +//// [/base/tsconfig.json] +{ + "watchOptions": { + "excludeFiles": [ + "${configDir}/temp/*.ts" + ] + } +} + +//// [/tsconfig.json] +{ + "extends": "./base/tsconfig.json" +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{ + "excludeFiles": [ + "/temp/*.ts" + ] +} +Errors:: + diff --git a/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with jsonSourceFile api.js b/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with jsonSourceFile api.js index b95fe3e4a4aa6..847ca32c2fe7f 100644 --- a/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with jsonSourceFile api.js +++ b/tests/baselines/reference/config/tsconfigParsingWatchOptions/when extending config file with watchOptions with jsonSourceFile api.js @@ -54,3 +54,32 @@ Result: WatchOptions:: } Errors:: + +Fs:: +//// [/a.ts] + + +//// [/base/tsconfig.json] +{ + "watchOptions": { + "excludeFiles": [ + "${configDir}/temp/*.ts" + ] + } +} + +//// [/tsconfig.json] +{ + "extends": "./base/tsconfig.json" +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{ + "excludeFiles": [ + "/temp/*.ts" + ] +} +Errors:: + diff --git a/tests/baselines/reference/tsbuild/extends/configDir-template.js b/tests/baselines/reference/tsbuild/extends/configDir-template.js new file mode 100644 index 0000000000000..e310d8be8b5b7 --- /dev/null +++ b/tests/baselines/reference/tsbuild/extends/configDir-template.js @@ -0,0 +1,189 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + + + +Output:: +/lib/tsc -b /home/src/projects/myproject --explainFiles --v +[12:00:27 AM] Projects in this build: + * tsconfig.json + +[12:00:28 AM] Project 'tsconfig.json' is out of date because output file 'outDir/main.js' does not exist + +[12:00:29 AM] Building project '/home/src/projects/myproject/tsconfig.json'... + +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/configs/first/root1' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +../../../../lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/home/src/projects/myproject/decls/main.d.ts] +export declare const y = 10; + + +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] +export declare const z = 10; + + +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] +export declare const x = 10; + + +//// [/home/src/projects/myproject/outDir/main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.y = void 0; +// some comment +exports.y = 10; + + +//// [/home/src/projects/myproject/outDir/src/secondary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = void 0; +// some comment +exports.z = 10; + + +//// [/home/src/projects/myproject/outDir/types/sometype.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + + diff --git a/tests/baselines/reference/tsbuildWatch/extends/configDir-template.js b/tests/baselines/reference/tsbuildWatch/extends/configDir-template.js new file mode 100644 index 0000000000000..081d145ad5ec4 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/extends/configDir-template.js @@ -0,0 +1,386 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js -b -w --extendedDiagnostics --explainFiles -v +Output:: +[HH:MM:SS AM] Starting compilation in watch mode... + +[HH:MM:SS AM] Projects in this build: + * tsconfig.json + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file 'outDir/main.js' does not exist + +[HH:MM:SS AM] Building project '/home/src/projects/myproject/tsconfig.json'... + +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/configs/first/root1' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +../../../../a/lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Config file /home/src/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file +FileWatcher:: Added:: WatchInfo: /home/src/projects/configs/second/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Wild card directory /home/src/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Wild card directory /home/src/projects/myproject/tsconfig.json +ExcludeWatcher:: Added:: WatchInfo: /home/src/projects/myproject/main.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file /home/src/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src/secondary.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file /home/src/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2/other/sometype2/package.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} package.json file /home/src/projects/myproject/tsconfig.json + + +//// [/home/src/projects/myproject/outDir/types/sometype.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + + +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] +export declare const x = 10; + + +//// [/home/src/projects/myproject/outDir/main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.y = void 0; +// some comment +exports.y = 10; + + +//// [/home/src/projects/myproject/decls/main.d.ts] +export declare const y = 10; + + +//// [/home/src/projects/myproject/outDir/src/secondary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = void 0; +// some comment +exports.z = 10; + + +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] +export declare const z = 10; + + + +PolledWatches:: +/home/src/projects/myproject/root2/other/sometype2/package.json: *new* + {"pollingInterval":2000} + +FsWatches:: +/home/src/projects/configs/first/tsconfig.json: *new* + {} +/home/src/projects/configs/second/tsconfig.json: *new* + {} +/home/src/projects/myproject/src/secondary.ts: *new* + {} +/home/src/projects/myproject/tsconfig.json: *new* + {} + +FsWatchesRecursive:: +/home/src/projects/myproject/src: *new* + {} + +Program root files: [ + "/home/src/projects/myproject/main.ts", + "/home/src/projects/myproject/src/secondary.ts" +] +Program options: { + "declarationDir": "/home/src/projects/myproject/decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "/home/src/projects/myproject", + "pathsBasePath": "/home/src/projects/configs/second", + "typeRoots": [ + "/home/src/projects/configs/first/root1", + "/home/src/projects/myproject/root2", + "/home/src/projects/configs/first/root3" + ], + "types": [], + "declaration": true, + "outDir": "/home/src/projects/myproject/outDir", + "traceResolution": true, + "watch": true, + "explainFiles": true, + "extendedDiagnostics": true, + "configFilePath": "/home/src/projects/myproject/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/home/src/projects/myproject/types/sometype.ts +/home/src/projects/myproject/main.ts +/home/src/projects/myproject/root2/other/sometype2/index.d.ts +/home/src/projects/myproject/src/secondary.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/home/src/projects/myproject/types/sometype.ts +/home/src/projects/myproject/main.ts +/home/src/projects/myproject/root2/other/sometype2/index.d.ts +/home/src/projects/myproject/src/secondary.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/home/src/projects/myproject/types/sometype.ts (computed .d.ts during emit) +/home/src/projects/myproject/main.ts (computed .d.ts during emit) +/home/src/projects/myproject/root2/other/sometype2/index.d.ts (used version) +/home/src/projects/myproject/src/secondary.ts (computed .d.ts during emit) + +exitCode:: ExitStatus.undefined + +Change:: edit extended config file + +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "${configDir}/root2" + ], + "types": [] + } +} + + +Output:: +FileWatcher:: Triggered with /home/src/projects/configs/first/tsconfig.json 1:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file +Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/configs/first/tsconfig.json 1:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file + + +Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject *new* + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject + +After running Timeout callback:: count: 0 +Output:: +[HH:MM:SS AM] File change detected. Starting incremental compilation... + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output 'outDir/main.js' is older than input '../configs/first/tsconfig.json' + +[HH:MM:SS AM] Building project '/home/src/projects/myproject/tsconfig.json'... + +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +[HH:MM:SS AM] Updating unchanged output timestamps of project '/home/src/projects/myproject/tsconfig.json'... + +../../../../a/lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + + + +//// [/home/src/projects/myproject/outDir/main.js] file changed its modified time +//// [/home/src/projects/myproject/decls/main.d.ts] file changed its modified time +//// [/home/src/projects/myproject/outDir/src/secondary.js] file changed its modified time +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] file changed its modified time + + +Program root files: [ + "/home/src/projects/myproject/main.ts", + "/home/src/projects/myproject/src/secondary.ts" +] +Program options: { + "declarationDir": "/home/src/projects/myproject/decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "/home/src/projects/myproject", + "pathsBasePath": "/home/src/projects/configs/second", + "typeRoots": [ + "/home/src/projects/myproject/root2" + ], + "types": [], + "declaration": true, + "outDir": "/home/src/projects/myproject/outDir", + "traceResolution": true, + "watch": true, + "explainFiles": true, + "extendedDiagnostics": true, + "configFilePath": "/home/src/projects/myproject/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/home/src/projects/myproject/types/sometype.ts +/home/src/projects/myproject/main.ts +/home/src/projects/myproject/root2/other/sometype2/index.d.ts +/home/src/projects/myproject/src/secondary.ts + +Semantic diagnostics in builder refreshed for:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsc/extends/configDir-template-showConfig.js b/tests/baselines/reference/tsc/extends/configDir-template-showConfig.js new file mode 100644 index 0000000000000..3d1415760d93d --- /dev/null +++ b/tests/baselines/reference/tsc/extends/configDir-template-showConfig.js @@ -0,0 +1,144 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + + + +Output:: +/lib/tsc -p /home/src/projects/myproject --showConfig +{ + "compilerOptions": { + "declarationDir": "./decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "./", + "typeRoots": [ + "../configs/first/root1", + "./root2", + "../configs/first/root3" + ], + "types": [], + "declaration": true, + "outDir": "./outDir", + "traceResolution": true + }, + "watchOptions": { + "excludeFiles": [ + "/home/src/projects/myproject/main.ts" + ] + }, + "files": [ + "./main.ts" + ], + "include": [ + "/home/src/projects/myproject/src" + ], + "exclude": [ + "outDir" + ] +} +exitCode:: ExitStatus.Success + + diff --git a/tests/baselines/reference/tsc/extends/configDir-template-with-commandline.js b/tests/baselines/reference/tsc/extends/configDir-template-with-commandline.js new file mode 100644 index 0000000000000..e2da2d7747018 --- /dev/null +++ b/tests/baselines/reference/tsc/extends/configDir-template-with-commandline.js @@ -0,0 +1,182 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + + + +Output:: +/lib/tsc -p /home/src/projects/myproject --explainFiles --outDir ${configDir}/outDir +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/configs/first/root1' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +../../../../lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/home/src/projects/myproject/${configDir}/outDir/main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.y = void 0; +// some comment +exports.y = 10; + + +//// [/home/src/projects/myproject/${configDir}/outDir/src/secondary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = void 0; +// some comment +exports.z = 10; + + +//// [/home/src/projects/myproject/${configDir}/outDir/types/sometype.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + + +//// [/home/src/projects/myproject/decls/main.d.ts] +export declare const y = 10; + + +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] +export declare const z = 10; + + +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] +export declare const x = 10; + + diff --git a/tests/baselines/reference/tsc/extends/configDir-template.js b/tests/baselines/reference/tsc/extends/configDir-template.js new file mode 100644 index 0000000000000..1d9956dd25663 --- /dev/null +++ b/tests/baselines/reference/tsc/extends/configDir-template.js @@ -0,0 +1,182 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + + + +Output:: +/lib/tsc -p /home/src/projects/myproject --explainFiles +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/configs/first/root1' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +../../../../lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/home/src/projects/myproject/decls/main.d.ts] +export declare const y = 10; + + +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] +export declare const z = 10; + + +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] +export declare const x = 10; + + +//// [/home/src/projects/myproject/outDir/main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.y = void 0; +// some comment +exports.y = 10; + + +//// [/home/src/projects/myproject/outDir/src/secondary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = void 0; +// some comment +exports.z = 10; + + +//// [/home/src/projects/myproject/outDir/types/sometype.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + + diff --git a/tests/baselines/reference/tscWatch/extends/configDir-template.js b/tests/baselines/reference/tscWatch/extends/configDir-template.js new file mode 100644 index 0000000000000..6f00b3e8baf60 --- /dev/null +++ b/tests/baselines/reference/tscWatch/extends/configDir-template.js @@ -0,0 +1,444 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js -w --extendedDiagnostics --explainFiles +Output:: +[HH:MM:SS AM] Starting compilation in watch mode... + +Current directory: /home/src/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/home/src/projects/myproject/main.ts","/home/src/projects/myproject/src/secondary.ts"] + options: {"declarationDir":"/home/src/projects/myproject/decls","paths":{"@myscope/*":["/home/src/projects/myproject/types/*"],"other/*":["other/*"]},"baseUrl":"/home/src/projects/myproject","pathsBasePath":"/home/src/projects/configs/second","typeRoots":["/home/src/projects/configs/first/root1","/home/src/projects/myproject/root2","/home/src/projects/configs/first/root3"],"types":[],"declaration":true,"outDir":"/home/src/projects/myproject/outDir","traceResolution":true,"watch":true,"extendedDiagnostics":true,"explainFiles":true,"configFilePath":"/home/src/projects/myproject/tsconfig.json"} +ExcludeWatcher:: Added:: WatchInfo: /home/src/projects/myproject/main.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/types/sometype.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src/secondary.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/configs/first/root1' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2/other/sometype2/index.d.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Source file +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/other 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/other 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/node_modules 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/node_modules 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/configs 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/configs 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +../../../../a/lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Wild card directory +FileWatcher:: Added:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file +FileWatcher:: Added:: WatchInfo: /home/src/projects/configs/second/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file + + +//// [/home/src/projects/myproject/outDir/types/sometype.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +exports.x = 10; + + +//// [/home/src/projects/myproject/decls/types/sometype.d.ts] +export declare const x = 10; + + +//// [/home/src/projects/myproject/outDir/main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.y = void 0; +// some comment +exports.y = 10; + + +//// [/home/src/projects/myproject/decls/main.d.ts] +export declare const y = 10; + + +//// [/home/src/projects/myproject/outDir/src/secondary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = void 0; +// some comment +exports.z = 10; + + +//// [/home/src/projects/myproject/decls/src/secondary.d.ts] +export declare const z = 10; + + + +PolledWatches:: +/home/src/projects/myproject/node_modules: *new* + {"pollingInterval":500} +/home/src/projects/myproject/other: *new* + {"pollingInterval":500} +/home/src/projects/node_modules: *new* + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: *new* + {} +/home/src/projects/configs/first/tsconfig.json: *new* + {} +/home/src/projects/configs/second/tsconfig.json: *new* + {} +/home/src/projects/myproject/root2/other/sometype2/index.d.ts: *new* + {} +/home/src/projects/myproject/src/secondary.ts: *new* + {} +/home/src/projects/myproject/tsconfig.json: *new* + {} +/home/src/projects/myproject/types/sometype.ts: *new* + {} + +FsWatchesRecursive:: +/home/src/projects/configs: *new* + {} +/home/src/projects/myproject/root2: *new* + {} +/home/src/projects/myproject/src: *new* + {} + +Program root files: [ + "/home/src/projects/myproject/main.ts", + "/home/src/projects/myproject/src/secondary.ts" +] +Program options: { + "declarationDir": "/home/src/projects/myproject/decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "/home/src/projects/myproject", + "pathsBasePath": "/home/src/projects/configs/second", + "typeRoots": [ + "/home/src/projects/configs/first/root1", + "/home/src/projects/myproject/root2", + "/home/src/projects/configs/first/root3" + ], + "types": [], + "declaration": true, + "outDir": "/home/src/projects/myproject/outDir", + "traceResolution": true, + "watch": true, + "extendedDiagnostics": true, + "explainFiles": true, + "configFilePath": "/home/src/projects/myproject/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/home/src/projects/myproject/types/sometype.ts +/home/src/projects/myproject/main.ts +/home/src/projects/myproject/root2/other/sometype2/index.d.ts +/home/src/projects/myproject/src/secondary.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/home/src/projects/myproject/types/sometype.ts +/home/src/projects/myproject/main.ts +/home/src/projects/myproject/root2/other/sometype2/index.d.ts +/home/src/projects/myproject/src/secondary.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/home/src/projects/myproject/types/sometype.ts (computed .d.ts during emit) +/home/src/projects/myproject/main.ts (computed .d.ts during emit) +/home/src/projects/myproject/root2/other/sometype2/index.d.ts (used version) +/home/src/projects/myproject/src/secondary.ts (computed .d.ts during emit) + +exitCode:: ExitStatus.undefined + +Change:: edit extended config file + +Input:: +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "${configDir}/root2" + ], + "types": [] + } +} + + +Output:: +FileWatcher:: Triggered with /home/src/projects/configs/first/tsconfig.json 1:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/configs/first/tsconfig.json 1:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Extended config file + + +Timeout callback:: count: 1 +1: timerToUpdateProgram *new* + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram + +After running Timeout callback:: count: 0 +Output:: +Reloading config file: /home/src/projects/myproject/tsconfig.json +Synchronizing program +[HH:MM:SS AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/home/src/projects/myproject/main.ts","/home/src/projects/myproject/src/secondary.ts"] + options: {"declarationDir":"/home/src/projects/myproject/decls","paths":{"@myscope/*":["/home/src/projects/myproject/types/*"],"other/*":["other/*"]},"baseUrl":"/home/src/projects/myproject","pathsBasePath":"/home/src/projects/configs/second","typeRoots":["/home/src/projects/myproject/root2"],"types":[],"declaration":true,"outDir":"/home/src/projects/myproject/outDir","traceResolution":true,"watch":true,"extendedDiagnostics":true,"explainFiles":true,"configFilePath":"/home/src/projects/myproject/tsconfig.json"} +======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Module name '@myscope/sometype', matched pattern '@myscope/*'. +Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Module resolution kind is not specified, using 'Node10'. +'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Module name 'other/sometype2', matched pattern 'other/*'. +Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Directory '/home/node_modules' does not exist, skipping all lookups in it. +Directory '/node_modules' does not exist, skipping all lookups in it. +File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist according to earlier cached lookups. +File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +DirectoryWatcher:: Close:: WatchInfo: /home/src/projects/configs 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /home/src/projects/configs 1 {"excludeFiles":["/home/src/projects/myproject/main.ts"]} Failed Lookup Locations +../../../../a/lib/lib.d.ts + Default library for target 'es5' +types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' +main.ts + Part of 'files' list in tsconfig.json +root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' +src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + + + + +PolledWatches:: +/home/src/projects/myproject/node_modules: + {"pollingInterval":500} +/home/src/projects/myproject/other: + {"pollingInterval":500} +/home/src/projects/node_modules: + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: + {} +/home/src/projects/configs/first/tsconfig.json: + {} +/home/src/projects/configs/second/tsconfig.json: + {} +/home/src/projects/myproject/root2/other/sometype2/index.d.ts: + {} +/home/src/projects/myproject/src/secondary.ts: + {} +/home/src/projects/myproject/tsconfig.json: + {} +/home/src/projects/myproject/types/sometype.ts: + {} + +FsWatchesRecursive:: +/home/src/projects/myproject/root2: + {} +/home/src/projects/myproject/src: + {} + +FsWatchesRecursive *deleted*:: +/home/src/projects/configs: + {} + + +Program root files: [ + "/home/src/projects/myproject/main.ts", + "/home/src/projects/myproject/src/secondary.ts" +] +Program options: { + "declarationDir": "/home/src/projects/myproject/decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "/home/src/projects/myproject", + "pathsBasePath": "/home/src/projects/configs/second", + "typeRoots": [ + "/home/src/projects/myproject/root2" + ], + "types": [], + "declaration": true, + "outDir": "/home/src/projects/myproject/outDir", + "traceResolution": true, + "watch": true, + "extendedDiagnostics": true, + "explainFiles": true, + "configFilePath": "/home/src/projects/myproject/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/home/src/projects/myproject/types/sometype.ts +/home/src/projects/myproject/main.ts +/home/src/projects/myproject/root2/other/sometype2/index.d.ts +/home/src/projects/myproject/src/secondary.ts + +Semantic diagnostics in builder refreshed for:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsserver/tsserver/configDir-template.js b/tests/baselines/reference/tsserver/tsserver/configDir-template.js new file mode 100644 index 0000000000000..e22ebbe6c84cc --- /dev/null +++ b/tests/baselines/reference/tsserver/tsserver/configDir-template.js @@ -0,0 +1,598 @@ +currentDirectory:: /home/src/projects/myproject useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist +Before request +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "root1", + "${configDir}/root2", + "root3" + ], + "types": [] + } +} + +//// [/home/src/projects/configs/second/tsconfig.json] +{ + "files": [ + "${configDir}/main.ts" + ], + "compilerOptions": { + "declarationDir": "${configDir}/decls", + "paths": { + "@myscope/*": [ + "${configDir}/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "${configDir}" + }, + "watchOptions": { + "excludeFiles": [ + "${configDir}/main.ts" + ] + } +} + +//// [/home/src/projects/myproject/tsconfig.json] +{ + "extends": "../configs/first/tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "outDir", + "traceResolution": true + } +} + +//// [/home/src/projects/myproject/main.ts] +// some comment +export const y = 10; +import { x } from "@myscope/sometype"; + + +//// [/home/src/projects/myproject/src/secondary.ts] +// some comment +export const z = 10; +import { k } from "other/sometype2"; + + +//// [/home/src/projects/myproject/types/sometype.ts] +export const x = 10; + + +//// [/home/src/projects/myproject/root2/other/sometype2/index.d.ts] +export const k = 10; + + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +Info seq [hh:mm:ss:mss] request: + { + "command": "configure", + "arguments": { + "watchOptions": { + "excludeDirectories": [ + "${configDir}/node_modules" + ] + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"excludeDirectories":["/home/src/projects/myproject/node_modules"]}, it will be take effect for next watches. +Info seq [hh:mm:ss:mss] response: + { + "seq": 0, + "type": "response", + "command": "configure", + "request_seq": 1, + "success": true + } +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "open", + "arguments": { + "file": "/home/src/projects/myproject/src/secondary.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /home/src/projects/myproject/src +Info seq [hh:mm:ss:mss] For info: /home/src/projects/myproject/src/secondary.ts :: Config file name: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingStart", + "body": { + "projectName": "/home/src/projects/myproject/tsconfig.json", + "reason": "Creating possible configured project for /home/src/projects/myproject/src/secondary.ts to open" + } + } +Info seq [hh:mm:ss:mss] Config: /home/src/projects/myproject/tsconfig.json : { + "rootNames": [ + "/home/src/projects/myproject/main.ts", + "/home/src/projects/myproject/src/secondary.ts" + ], + "options": { + "declarationDir": "/home/src/projects/myproject/decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "/home/src/projects/myproject", + "pathsBasePath": "/home/src/projects/configs/second", + "typeRoots": [ + "/home/src/projects/configs/first/root1", + "/home/src/projects/myproject/root2", + "/home/src/projects/configs/first/root3" + ], + "types": [], + "declaration": true, + "outDir": "/home/src/projects/myproject/outDir", + "traceResolution": true, + "configFilePath": "/home/src/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "excludeFiles": [ + "/home/src/projects/myproject/main.ts" + ] + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /home/src/projects/myproject/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} Config: /home/src/projects/myproject/tsconfig.json WatchType: Extended config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/configs/second/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} Config: /home/src/projects/myproject/tsconfig.json WatchType: Extended config file +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Config: /home/src/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Config: /home/src/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/main.ts 500 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] ======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Info seq [hh:mm:ss:mss] Module resolution kind is not specified, using 'Node10'. +Info seq [hh:mm:ss:mss] 'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +Info seq [hh:mm:ss:mss] 'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Info seq [hh:mm:ss:mss] Module name '@myscope/sometype', matched pattern '@myscope/*'. +Info seq [hh:mm:ss:mss] Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Info seq [hh:mm:ss:mss] Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] ======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/types/sometype.ts 500 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] ======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Info seq [hh:mm:ss:mss] Module resolution kind is not specified, using 'Node10'. +Info seq [hh:mm:ss:mss] 'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +Info seq [hh:mm:ss:mss] 'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Info seq [hh:mm:ss:mss] Module name 'other/sometype2', matched pattern 'other/*'. +Info seq [hh:mm:ss:mss] Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Info seq [hh:mm:ss:mss] Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/configs/first/root1' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +Info seq [hh:mm:ss:mss] ======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2/other/sometype2/index.d.ts 500 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/other 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/other 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/src 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] ExcludeWatcher:: Added:: WatchInfo: /home/src/projects/myproject/node_modules 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/configs 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/configs 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/myproject/root2 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /home/src/projects/myproject/tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/home/src/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (5) + /a/lib/lib.d.ts Text-1 "/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }" + /home/src/projects/myproject/types/sometype.ts Text-1 "export const x = 10;\n" + /home/src/projects/myproject/main.ts Text-1 "// some comment\nexport const y = 10;\nimport { x } from \"@myscope/sometype\";\n" + /home/src/projects/myproject/root2/other/sometype2/index.d.ts Text-1 "export const k = 10;\n" + /home/src/projects/myproject/src/secondary.ts SVC-1-0 "// some comment\nexport const z = 10;\nimport { k } from \"other/sometype2\";\n" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + types/sometype.ts + Imported via "@myscope/sometype" from file 'main.ts' + main.ts + Part of 'files' list in tsconfig.json + root2/other/sometype2/index.d.ts + Imported via "other/sometype2" from file 'src/secondary.ts' + src/secondary.ts + Matched by include pattern '${configDir}/src' in 'tsconfig.json' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingFinish", + "body": { + "projectName": "/home/src/projects/myproject/tsconfig.json" + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "telemetry", + "body": { + "telemetryEventName": "projectInfo", + "payload": { + "projectId": "c082244e14d80420126a10c084f20f9b41809e79e7f5a330fc4d923f1197daa1", + "fileStats": { + "js": 0, + "jsSize": 0, + "jsx": 0, + "jsxSize": 0, + "ts": 3, + "tsSize": 171, + "tsx": 0, + "tsxSize": 0, + "dts": 2, + "dtsSize": 355, + "deferred": 0, + "deferredSize": 0 + }, + "compilerOptions": { + "declarationDir": "", + "paths": "", + "baseUrl": "", + "typeRoots": [ + "", + "", + "" + ], + "types": [], + "declaration": true, + "outDir": "", + "traceResolution": true + }, + "typeAcquisition": { + "enable": false, + "include": false, + "exclude": false + }, + "extends": true, + "files": true, + "include": true, + "exclude": false, + "compileOnSave": false, + "configFileName": "tsconfig.json", + "projectType": "configured", + "languageServiceEnabled": true, + "version": "FakeVersion" + } + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "configFileDiag", + "body": { + "triggerFile": "/home/src/projects/myproject/src/secondary.ts", + "configFile": "/home/src/projects/myproject/tsconfig.json", + "diagnostics": [] + } + } +Info seq [hh:mm:ss:mss] Project '/home/src/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (5) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /home/src/projects/myproject/src/secondary.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +PolledWatches:: +/home/src/projects/myproject/other: *new* + {"pollingInterval":500} +/home/src/projects/node_modules: *new* + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: *new* + {} +/home/src/projects/configs/first/tsconfig.json: *new* + {} +/home/src/projects/configs/second/tsconfig.json: *new* + {} +/home/src/projects/myproject/main.ts: *new* + {} +/home/src/projects/myproject/root2/other/sometype2/index.d.ts: *new* + {} +/home/src/projects/myproject/tsconfig.json: *new* + {} +/home/src/projects/myproject/types/sometype.ts: *new* + {} + +FsWatchesRecursive:: +/home/src/projects/configs: *new* + {} +/home/src/projects/myproject/root2: *new* + {} +/home/src/projects/myproject/src: *new* + {} + +Projects:: +/home/src/projects/myproject/tsconfig.json (Configured) *new* + projectStateVersion: 1 + projectProgramVersion: 1 + +ScriptInfos:: +/a/lib/lib.d.ts *new* + version: Text-1 + containingProjects: 1 + /home/src/projects/myproject/tsconfig.json +/home/src/projects/myproject/main.ts *new* + version: Text-1 + containingProjects: 1 + /home/src/projects/myproject/tsconfig.json +/home/src/projects/myproject/root2/other/sometype2/index.d.ts *new* + version: Text-1 + containingProjects: 1 + /home/src/projects/myproject/tsconfig.json +/home/src/projects/myproject/src/secondary.ts (Open) *new* + version: SVC-1-0 + containingProjects: 1 + /home/src/projects/myproject/tsconfig.json *default* +/home/src/projects/myproject/types/sometype.ts *new* + version: Text-1 + containingProjects: 1 + /home/src/projects/myproject/tsconfig.json + +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /home/src/projects/configs/first/tsconfig.json 1:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} Config: /home/src/projects/myproject/tsconfig.json WatchType: Extended config file +Info seq [hh:mm:ss:mss] Scheduled: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /home/src/projects/configs/first/tsconfig.json 1:: WatchInfo: /home/src/projects/configs/first/tsconfig.json 2000 {"excludeDirectories":["/home/src/projects/myproject/node_modules"]} Config: /home/src/projects/myproject/tsconfig.json WatchType: Extended config file +Before running Timeout callback:: count: 2 +1: /home/src/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* +//// [/home/src/projects/configs/first/tsconfig.json] +{ + "extends": "../second/tsconfig.json", + "include": [ + "${configDir}/src" + ], + "compilerOptions": { + "typeRoots": [ + "${configDir}/root2" + ], + "types": [] + } +} + + +Timeout callback:: count: 2 +1: /home/src/projects/myproject/tsconfig.json *new* +2: *ensureProjectForOpenFiles* *new* + +Projects:: +/home/src/projects/myproject/tsconfig.json (Configured) *changed* + projectStateVersion: 2 *changed* + projectProgramVersion: 1 + dirty: true *changed* + +Info seq [hh:mm:ss:mss] Running: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Reloading configured project /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingStart", + "body": { + "projectName": "/home/src/projects/myproject/tsconfig.json", + "reason": "Change in extended config file /home/src/projects/configs/first/tsconfig.json detected" + } + } +Info seq [hh:mm:ss:mss] Config: /home/src/projects/myproject/tsconfig.json : { + "rootNames": [ + "/home/src/projects/myproject/main.ts", + "/home/src/projects/myproject/src/secondary.ts" + ], + "options": { + "declarationDir": "/home/src/projects/myproject/decls", + "paths": { + "@myscope/*": [ + "/home/src/projects/myproject/types/*" + ], + "other/*": [ + "other/*" + ] + }, + "baseUrl": "/home/src/projects/myproject", + "pathsBasePath": "/home/src/projects/configs/second", + "typeRoots": [ + "/home/src/projects/myproject/root2" + ], + "types": [], + "declaration": true, + "outDir": "/home/src/projects/myproject/outDir", + "traceResolution": true, + "configFilePath": "/home/src/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "excludeFiles": [ + "/home/src/projects/myproject/main.ts" + ] + } +} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] ======== Resolving module '@myscope/sometype' from '/home/src/projects/myproject/main.ts'. ======== +Info seq [hh:mm:ss:mss] Module resolution kind is not specified, using 'Node10'. +Info seq [hh:mm:ss:mss] 'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name '@myscope/sometype'. +Info seq [hh:mm:ss:mss] 'paths' option is specified, looking for a pattern to match module name '@myscope/sometype'. +Info seq [hh:mm:ss:mss] Module name '@myscope/sometype', matched pattern '@myscope/*'. +Info seq [hh:mm:ss:mss] Trying substitution '/home/src/projects/myproject/types/*', candidate module location: '/home/src/projects/myproject/types/sometype'. +Info seq [hh:mm:ss:mss] Loading module as file / folder, candidate module location '/home/src/projects/myproject/types/sometype', target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/types/sometype.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] ======== Module name '@myscope/sometype' was successfully resolved to '/home/src/projects/myproject/types/sometype.ts'. ======== +Info seq [hh:mm:ss:mss] ======== Resolving module 'other/sometype2' from '/home/src/projects/myproject/src/secondary.ts'. ======== +Info seq [hh:mm:ss:mss] Module resolution kind is not specified, using 'Node10'. +Info seq [hh:mm:ss:mss] 'baseUrl' option is set to '/home/src/projects/myproject', using this value to resolve non-relative module name 'other/sometype2'. +Info seq [hh:mm:ss:mss] 'paths' option is specified, looking for a pattern to match module name 'other/sometype2'. +Info seq [hh:mm:ss:mss] Module name 'other/sometype2', matched pattern 'other/*'. +Info seq [hh:mm:ss:mss] Trying substitution 'other/*', candidate module location: 'other/sometype2'. +Info seq [hh:mm:ss:mss] Loading module as file / folder, candidate module location '/home/src/projects/myproject/other/sometype2', target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Loading module 'other/sometype2' from 'node_modules' folder, target file types: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/myproject/src/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/myproject/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/projects/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/src/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/home/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] Directory '/node_modules' does not exist, skipping all lookups in it. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/root2/other/sometype2.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/root2/other/sometype2/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/home/src/projects/myproject/root2/other/sometype2/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/home/src/projects/myproject/root2/other/sometype2/index.d.ts', result '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. +Info seq [hh:mm:ss:mss] ======== Module name 'other/sometype2' was successfully resolved to '/home/src/projects/myproject/root2/other/sometype2/index.d.ts'. ======== +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Close:: WatchInfo: /home/src/projects/configs 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /home/src/projects/configs 1 {"excludeDirectories":["/home/src/projects/myproject/node_modules"],"excludeFiles":["/home/src/projects/myproject/main.ts"]} Project: /home/src/projects/myproject/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /home/src/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/home/src/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (5) + /a/lib/lib.d.ts Text-1 "/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }" + /home/src/projects/myproject/types/sometype.ts Text-1 "export const x = 10;\n" + /home/src/projects/myproject/main.ts Text-1 "// some comment\nexport const y = 10;\nimport { x } from \"@myscope/sometype\";\n" + /home/src/projects/myproject/root2/other/sometype2/index.d.ts Text-1 "export const k = 10;\n" + /home/src/projects/myproject/src/secondary.ts SVC-1-0 "// some comment\nexport const z = 10;\nimport { k } from \"other/sometype2\";\n" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectLoadingFinish", + "body": { + "projectName": "/home/src/projects/myproject/tsconfig.json" + } + } +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "configFileDiag", + "body": { + "triggerFile": "/home/src/projects/myproject/tsconfig.json", + "configFile": "/home/src/projects/myproject/tsconfig.json", + "diagnostics": [] + } + } +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/home/src/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (5) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /home/src/projects/myproject/src/secondary.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/home/src/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (5) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /home/src/projects/myproject/src/secondary.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /home/src/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] got projects updated in background /home/src/projects/myproject/src/secondary.ts +Info seq [hh:mm:ss:mss] event: + { + "seq": 0, + "type": "event", + "event": "projectsUpdatedInBackground", + "body": { + "openFiles": [ + "/home/src/projects/myproject/src/secondary.ts" + ] + } + } +After running Timeout callback:: count: 0 + +PolledWatches:: +/home/src/projects/myproject/other: + {"pollingInterval":500} +/home/src/projects/node_modules: + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: + {} +/home/src/projects/configs/first/tsconfig.json: + {} +/home/src/projects/configs/second/tsconfig.json: + {} +/home/src/projects/myproject/main.ts: + {} +/home/src/projects/myproject/root2/other/sometype2/index.d.ts: + {} +/home/src/projects/myproject/tsconfig.json: + {} +/home/src/projects/myproject/types/sometype.ts: + {} + +FsWatchesRecursive:: +/home/src/projects/myproject/root2: + {} +/home/src/projects/myproject/src: + {} + +FsWatchesRecursive *deleted*:: +/home/src/projects/configs: + {} + +Projects:: +/home/src/projects/myproject/tsconfig.json (Configured) *changed* + projectStateVersion: 2 + projectProgramVersion: 2 *changed* + dirty: false *changed*