diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 3b2120d258c8c..3e233f4928598 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -12,6 +12,7 @@ import { CommandLineOption, CommandLineOptionOfCustomType, CommandLineOptionOfListType, + CommandLineOptionOfObjectType, CompilerOptions, CompilerOptionsValue, ConfigFileSpecs, @@ -22,6 +23,7 @@ import { createGetCanonicalFileName, Debug, Diagnostic, + DiagnosticAndArguments, DiagnosticArguments, DiagnosticMessage, Diagnostics, @@ -45,6 +47,7 @@ import { flatten, forEach, forEachEntry, + forEachPropertyAssignment, forEachTsConfigPropArray, getBaseFileName, getDirectoryPath, @@ -59,9 +62,11 @@ import { getSupportedExtensions, getSupportedExtensionsWithJsonIfResolveJsonModule, getTextOfPropertyName, + getTsConfigObjectLiteralExpression, getTsConfigPropArrayElementValue, hasExtension, hasProperty, + identity, ImportsNotUsedAsValues, isArray, isArrayLiteralExpression, @@ -93,7 +98,9 @@ import { ParseConfigHost, ParsedCommandLine, parseJsonText, + parsePackageName, Path, + PluginImport, PollingWatchKind, PrefixUnaryExpression, ProjectReference, @@ -111,7 +118,6 @@ import { toPath, tracing, trimString, - TsConfigOnlyOption, TsConfigSourceFile, TypeAcquisition, unescapeLeadingUnderscores, @@ -312,8 +318,31 @@ export const optionsForWatch: CommandLineOption[] = [ category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing, }, + { + name: "watchFactory", + type: "string | object", + category: Diagnostics.Watch_and_Build_Modes, + description: Diagnostics.Specify_which_factory_to_invoke_watchFile_and_watchDirectory_on, + extraValidation: watchFactoryToDiagnostic, + elementOptions: commandLineOptionsToMap([ + { + name: "name", + type: "string", + description: Diagnostics.Specify_which_factory_to_invoke_watchFile_and_watchDirectory_on, + }, + ]), + }, ]; +function watchFactoryToDiagnostic(watchFactory: CompilerOptionsValue, valueExpression: Expression | undefined) { + const watchFactoryName = isString(watchFactory) ? watchFactory : (watchFactory as PluginImport).name; + if (watchFactoryName && !parsePackageName(watchFactoryName).rest) return undefined; + const diagnostics: DiagnosticAndArguments = [Diagnostics.watchFactory_name_can_only_be_a_package_name]; + if (!valueExpression || !isObjectLiteralExpression(valueExpression)) return diagnostics; + const errorNode = forEachPropertyAssignment(valueExpression, "name", prop => prop.initializer); + return errorNode ? { diagnostics, errorNode } : diagnostics; +} + /** @internal */ export const commonOptionsWithBuild: CommandLineOption[] = [ { @@ -500,6 +529,14 @@ export const commonOptionsWithBuild: CommandLineOption[] = [ description: Diagnostics.Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit, defaultValueDescription: Diagnostics.Platform_specific }, + { + name: "allowPlugins", + type: "boolean", + category: Diagnostics.Command_line_Options, + isCommandLineOnly: true, + description: Diagnostics.Allow_running_plugins, + defaultValueDescription: false, + }, ]; /** @internal */ @@ -1725,12 +1762,32 @@ export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "" return mapDefined(values, v => validateJsonOptionValue(opt.element, v || "", errors)); case "boolean": case "object": + case "string | object": return Debug.fail(`List of ${opt.element.type} is not yet supported.`); default: return mapDefined(values, v => parseCustomTypeOption(opt.element as CommandLineOptionOfCustomType, v, errors)); } } +/** @internal */ +export function parseObjectTypeOption(opt: CommandLineOptionOfObjectType, value: string | undefined, errors: Diagnostic[]): { value: CompilerOptionsValue | undefined } | undefined { + if (value === undefined) return undefined; + value = trimString(value); + if (startsWith(value, "-")) return undefined; + if (opt.type === "string | object" && !startsWith(value, "{")) { + return { value: validateJsonOptionValue(opt, value, errors) }; + } + try { + const parsedValue = JSON.parse(value); + if (typeof parsedValue === "object") { + return { value: validateJsonOptionValue(opt, parsedValue, errors) }; + } + } + catch { } // eslint-disable-line no-empty + errors.push(createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, opt.name, getCompilerOptionValueTypeString(opt))); + return { value: undefined }; +} + /** @internal */ export interface OptionsBase { [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; @@ -1774,6 +1831,10 @@ export function parseCommandLineWorker( const errors: Diagnostic[] = []; parseStrings(commandLine); + if (options.watch && watchOptions?.watchFactory && !options.allowPlugins) { + errors.push(createCompilerDiagnostic(Diagnostics.Option_watchFactory_cannot_be_specified_without_passing_allowPlugins_on_command_line)); + watchOptions.watchFactory = undefined; + } return { options, watchOptions, @@ -1908,9 +1969,15 @@ function parseOptionValue( case "listOrElement": Debug.fail("listOrElement not supported here"); break; + case "object": + case "string | object": + const objectResult = parseObjectTypeOption(opt, args[i], errors); + options[opt.name] = objectResult?.value; + if (objectResult) i++; + break; // If not a primitive, the possible types are specified in what is effectively a map of options. default: - options[opt.name] = parseCustomTypeOption(opt as CommandLineOptionOfCustomType, args[i], errors); + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); i++; break; } @@ -2045,6 +2112,7 @@ export function getParsedCommandLineOfConfigFile( extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[], + checkAllowPlugins?: boolean, ): ParsedCommandLine | undefined { const configFileText = tryReadFile(configFileName, fileName => host.readFile(fileName)); if (!isString(configFileText)) { @@ -2066,7 +2134,8 @@ export function getParsedCommandLineOfConfigFile( /*resolutionStack*/ undefined, extraFileExtensions, extendedConfigCache, - watchOptionsToExtend + watchOptionsToExtend, + checkAllowPlugins, ); } @@ -2153,30 +2222,30 @@ const extendsOptionDeclaration: CommandLineOptionOfListType = { type: "listOrElement", element: { name: "extends", - type: "string" + type: "string", }, category: Diagnostics.File_Management, disallowNullOrUndefined: true, }; -const compilerOptionsDeclaration: TsConfigOnlyOption = { +const compilerOptionsDeclaration: CommandLineOptionOfObjectType = { name: "compilerOptions", type: "object", elementOptions: getCommandLineCompilerOptionsMap(), extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics, }; -const watchOptionsDeclaration: TsConfigOnlyOption = { +const watchOptionsDeclaration: CommandLineOptionOfObjectType = { name: "watchOptions", type: "object", elementOptions: getCommandLineWatchOptionsMap(), extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics, }; -const typeAcquisitionDeclaration: TsConfigOnlyOption = { +const typeAcquisitionDeclaration: CommandLineOptionOfObjectType = { name: "typeAcquisition", type: "object", elementOptions: getCommandLineTypeAcquisitionMap(), extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics }; -let _tsconfigRootOptions: TsConfigOnlyOption; +let _tsconfigRootOptions: CommandLineOptionOfObjectType; function getTsconfigRootOptionsMap() { if (_tsconfigRootOptions === undefined) { _tsconfigRootOptions = { @@ -2234,12 +2303,12 @@ function getTsconfigRootOptionsMap() { /** @internal */ export interface JsonConversionNotifier { - rootOptions: TsConfigOnlyOption; + rootOptions: CommandLineOptionOfObjectType; onPropertySet( keyText: string, value: any, propertyAssignment: PropertyAssignment, - parentOption: TsConfigOnlyOption | undefined, + parentOption: CommandLineOptionOfObjectType | undefined, option: CommandLineOption | undefined, ): void; } @@ -2300,7 +2369,7 @@ export function convertToJson( function convertObjectLiteralExpressionToJson( node: ObjectLiteralExpression, - objectOption: TsConfigOnlyOption | undefined, + objectOption: CommandLineOptionOfObjectType | undefined, ): any { const result: any = returnValue ? {} : undefined; for (const element of node.properties) { @@ -2380,7 +2449,7 @@ export function convertToJson( // that satifies it and need it to modify options set in them (for normalizing file paths) // vs what we set in the json // If need arises, we can modify this interface and callbacks as needed - return convertObjectLiteralExpressionToJson(objectLiteralExpression, option as TsConfigOnlyOption); + return convertObjectLiteralExpressionToJson(objectLiteralExpression, option as CommandLineOptionOfObjectType); case SyntaxKind.ArrayLiteralExpression: return convertArrayLiteralExpressionToJson( @@ -2421,6 +2490,9 @@ function isCompilerOptionsValue(option: CommandLineOption | undefined, value: an if (option.type === "listOrElement") { return isArray(value) || isCompilerOptionsValue(option.element, value); } + if (option.type === "string | object") { + return isString(value) || typeof value === "object"; + } const expectedType = isString(option.type) ? option.type : "string"; return typeof value === expectedType; } @@ -2530,6 +2602,7 @@ function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption case "number": case "boolean": case "object": + case "string | object": // this is of a type CommandLineOptionOfPrimitiveType return undefined; case "list": @@ -2797,15 +2870,26 @@ export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, bas * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ -export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine { +export function parseJsonSourceFileConfigFileContent( + sourceFile: TsConfigSourceFile, + host: ParseConfigHost, + basePath: string, + existingOptions?: CompilerOptions, + configFileName?: string, + resolutionStack?: Path[], + extraFileExtensions?: readonly FileExtensionInfo[], + extendedConfigCache?: Map, + existingWatchOptions?: WatchOptions, + checkAllowPlugins?: boolean, +): ParsedCommandLine { tracing?.push(tracing.Phase.Parse, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); - const result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); + const result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, checkAllowPlugins); tracing?.pop(); return result; } /** @internal */ -export function setConfigFileInOptions(options: CompilerOptions, configFile: TsConfigSourceFile | undefined) { +export function setConfigFileInOptions(options: CompilerOptions | WatchOptions, configFile: TsConfigSourceFile | undefined) { if (configFile) { Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile }); } @@ -2843,7 +2927,8 @@ function parseJsonConfigFileContentWorker( configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: readonly FileExtensionInfo[] = [], - extendedConfigCache?: Map + extendedConfigCache?: Map, + checkAllowPlugins?: boolean, ): ParsedCommandLine { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; @@ -2851,9 +2936,24 @@ 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 ? - extend(existingWatchOptions, parsedConfig.watchOptions) : - parsedConfig.watchOptions || existingWatchOptions; + const watchOptions = existingWatchOptions || parsedConfig.watchOptions ? + extend(existingWatchOptions || {}, parsedConfig.watchOptions || {}) : + undefined; + + if (options.watch && watchOptions?.watchFactory && checkAllowPlugins && !options.allowPlugins) { + const watchFactoryNameProp = forEachPropertyAssignment( + getTsConfigObjectLiteralExpression(sourceFile), + "watchOptions", + prop => isObjectLiteralExpression(prop.initializer) ? + forEachPropertyAssignment(prop.initializer, "watchFactory", watchFactoryProp => isObjectLiteralExpression(watchFactoryProp.initializer) ? + forEachPropertyAssignment(watchFactoryProp.initializer, "name", identity) || watchFactoryProp : + watchFactoryProp + ) : + undefined + ); + errors.push(createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, watchFactoryNameProp?.name, Diagnostics.Option_watchFactory_cannot_be_specified_without_passing_allowPlugins_on_command_line)); + watchOptions.watchFactory = undefined; + } options.configFilePath = configFileName && normalizeSlashes(configFileName); const configFileSpecs = getConfigFileSpecs(); @@ -3096,7 +3196,7 @@ function parseConfig( if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - const result: ExtendsResult = { options:{} }; + const result: ExtendsResult = { options: {} }; if (isString(ownConfig.extendedConfigPath)) { applyExtendedConfig(result, ownConfig.extendedConfigPath); } @@ -3110,17 +3210,17 @@ function parseConfig( if (sourceFile && result.extendedSourceFiles) sourceFile.extendedSourceFiles = arrayFrom(result.extendedSourceFiles.keys()); ownConfig.options = assign(result.options, ownConfig.options); - ownConfig.watchOptions = ownConfig.watchOptions && result.watchOptions ? - assign(result.watchOptions, ownConfig.watchOptions) : - ownConfig.watchOptions || result.watchOptions; - } + ownConfig.watchOptions = ownConfig.watchOptions || result.watchOptions ? + assign(result.watchOptions || {}, ownConfig.watchOptions) : + undefined; + } return ownConfig; function applyExtendedConfig(result: ExtendsResult, extendedConfigPath: string){ const extendedConfig = getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache, result); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { const extendsRaw = extendedConfig.raw; - let relativeDifference: string | undefined ; + let relativeDifference: string | undefined; const setPropertyInResultIfNotUndefined = (propertyName: "include" | "exclude" | "files") => { if (extendsRaw[propertyName]) { result[propertyName] = map(extendsRaw[propertyName], (path: string) => isRootedDiskPath(path) ? path : combinePaths( @@ -3136,9 +3236,9 @@ function parseConfig( result.compileOnSave = extendsRaw.compileOnSave; } assign(result.options, extendedConfig.options); - result.watchOptions = result.watchOptions && extendedConfig.watchOptions ? - assign({}, result.watchOptions, extendedConfig.watchOptions) : - result.watchOptions || extendedConfig.watchOptions; + result.watchOptions = result.watchOptions || extendedConfig.watchOptions ? + assign(result.watchOptions || {}, extendedConfig.watchOptions) : + undefined; // TODO extend type typeAcquisition } } @@ -3246,7 +3346,7 @@ function parseOwnConfigOfJsonSourceFile( keyText: string, value: any, propertyAssignment: PropertyAssignment, - parentOption: TsConfigOnlyOption | undefined, + parentOption: CommandLineOptionOfObjectType | undefined, option: CommandLineOption | undefined, ) { // Ensure value is verified except for extends which is handled in its own way for error reporting @@ -3257,7 +3357,8 @@ function parseOwnConfigOfJsonSourceFile( if (parentOption === compilerOptionsDeclaration) currentOption = options; else if (parentOption === watchOptionsDeclaration) currentOption = watchOptions ??= {}; else if (parentOption === typeAcquisitionDeclaration) currentOption = typeAcquisition ??= getDefaultTypeAcquisition(configFileName); - else Debug.fail("Unknown option"); + // Ignore anything other option that comes through as parent is not from root + else return; currentOption[option.name] = value; } else if (keyText && parentOption?.extraKeyDiagnostics) { @@ -3469,16 +3570,19 @@ export function convertJsonOption( return undefined; } if (isCompilerOptionsValue(opt, value)) { - const optType = opt.type; - if ((optType === "list") && isArray(value)) { + if ((opt.type === "list") && isArray(value)) { return convertJsonOptionOfListType(opt, value, basePath, errors, propertyAssignment, valueExpression as ArrayLiteralExpression | undefined, sourceFile); } - else if (optType === "listOrElement") { + else if (opt.type === "listOrElement") { return isArray(value) ? convertJsonOptionOfListType(opt, value, basePath, errors, propertyAssignment, valueExpression as ArrayLiteralExpression | undefined, sourceFile) : convertJsonOption(opt.element, value, basePath, errors, propertyAssignment, valueExpression, sourceFile); } - else if (!isString(opt.type)) { + if (opt.isCommandLineOnly) { + errors.push(createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, valueExpression, Diagnostics.Option_0_can_only_be_specified_on_command_line, opt.name)); + return; + } + if (!isString(opt.type)) { return convertJsonOptionOfCustomType(opt as CommandLineOptionOfCustomType, value as string, errors, valueExpression, sourceFile); } const validatedValue = validateJsonOptionValue(opt, value, errors, valueExpression, sourceFile); @@ -3507,9 +3611,11 @@ function validateJsonOptionValue( sourceFile?: TsConfigSourceFile, ): T | undefined { if (isNullOrUndefined(value)) return undefined; - const d = opt.extraValidation?.(value); + const d = opt.extraValidation?.(value, valueExpression); if (!d) return value; - errors.push(createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, valueExpression, ...d)); + const diagnostics = isArray(d) ? d : d.diagnostics; + const errorNode = isArray(d) ? valueExpression : d.errorNode; + errors.push(createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, errorNode, ...diagnostics)); return undefined; } @@ -3740,20 +3846,16 @@ function matchesExcludeWorker( function validateSpecs(specs: readonly string[], errors: Diagnostic[], disallowTrailingRecursion: boolean, jsonSourceFile: TsConfigSourceFile | undefined, specKey: string): readonly string[] { return specs.filter(spec => { if (!isString(spec)) return false; - const diag = specToDiagnostic(spec, disallowTrailingRecursion); + const diag = specToDiagnostic(spec, /*_valueExpresion*/ undefined, disallowTrailingRecursion); if (diag !== undefined) { - errors.push(createDiagnostic(...diag)); + const element = getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec); + errors.push(createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(jsonSourceFile, element, ...diag)); } return diag === undefined; }); - - function createDiagnostic(message: DiagnosticMessage, spec: string): Diagnostic { - const element = getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec); - return createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(jsonSourceFile, element, message, spec); - } } -function specToDiagnostic(spec: CompilerOptionsValue, disallowTrailingRecursion?: boolean): [DiagnosticMessage, string] | undefined { +function specToDiagnostic(spec: CompilerOptionsValue, _valueExpresion?: Expression, disallowTrailingRecursion?: boolean): DiagnosticAndArguments | undefined { Debug.assert(typeof spec === "string"); if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; @@ -3918,6 +4020,7 @@ function getOptionValueWithEmptyStrings(value: any, option: CommandLineOption): if (value === undefined) return value; switch (option.type) { case "object": // "paths". Can't get any useful information from the value since we blank out strings, so just return "". + case "string | object": return ""; case "string": // Could be any arbitrary string -- use empty string instead. return ""; @@ -3948,6 +4051,7 @@ function getDefaultValueForOption(option: CommandLineOption): {} { case "boolean": return true; case "string": + case "string | object": const defaultValue = option.defaultValueDescription; return option.isFilePath ? `./${defaultValue && typeof defaultValue === "string" ? defaultValue : ""}` : ""; case "list": diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 804ffeeff8ffa..8260eb8636139 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4333,6 +4333,14 @@ "category": "Error", "code": 5108 }, + "'watchFactory' name can only be a package name.": { + "category": "Error", + "code": 5109 + }, + "Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line.": { + "category": "Error", + "code": 5110 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", @@ -6091,6 +6099,10 @@ "category": "Message", "code": 6718 }, + "Specify which factory to invoke 'watchFile' and 'watchDirectory' on.": { + "category": "Message", + "code": 6719 + }, "Default catch clause variables as 'unknown' instead of 'any'.": { "category": "Message", "code": 6803 @@ -6099,6 +6111,10 @@ "category": "Message", "code": 6804 }, + "Allow running plugins.": { + "category": "Message", + "code": 6805 + }, "one of:": { "category": "Message", diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 50e7076774c3b..c142e5278732c 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -15,6 +15,7 @@ import { endsWith, enumerateInsertsAndDeletes, FileSystemEntries, + forEach, getDirectoryPath, getFallbackOptions, getNormalizedAbsolutePath, @@ -28,20 +29,25 @@ import { matchesExclude, matchFiles, memoize, + ModuleImportResult, noop, normalizePath, normalizeSlashes, orderedRemoveItem, + parsePackageName, Path, perfLogger, + PluginImport, PollingWatchKind, - RequireResult, resolveJSModule, + returnUndefined, some, startsWith, stringContains, timestamp, unorderedRemoveItem, + UserWatchFactory, + UserWatchFactoryModule, WatchDirectoryKind, WatchFileKind, WatchOptions, @@ -469,7 +475,7 @@ function createFixedChunkSizePollingWatchFile(host: { } } -interface SingleFileWatcher{ +interface SingleFileWatcher { watcher: FileWatcher; callbacks: T[]; } @@ -827,6 +833,11 @@ export const enum FileSystemEntryKind { Directory, } +/** @internal */ +export function setWatchOptionInternalProperty(options: WatchOptions, key: K, value: WatchOptions[K]) { + Object.defineProperty(options, key, { configurable: false, enumerable: false, value }); +} + function createFileWatcherCallback(callback: FsWatchCallback): FileWatcherCallback { return (_fileName, eventKind, modifiedTime) => callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime); } @@ -882,6 +893,36 @@ function createFsWatchCallbackForDirectoryWatcherCallback( }; } +/** @internal */ +export interface ImportPluginResult { + pluginConfigEntry: PluginImport; + resolvedModule: T | undefined; + errorLogs: string[] | undefined; +} +/** @internal */ +export function resolveModule( + pluginConfigEntry: PluginImport, + searchPaths: readonly string[], + host: Pick, + log: (message: string) => void, +): ImportPluginResult { + Debug.assertIsDefined(host.require); + let errorLogs: string[] | undefined; + let resolvedModule: T | undefined; + for (const initialDir of searchPaths) { + const resolvedPath = normalizeSlashes(host.resolvePath(combinePaths(initialDir, "node_modules"))); + log(`Loading ${pluginConfigEntry.name} from ${initialDir} (resolved to ${resolvedPath})`); + const result = host.require(resolvedPath, pluginConfigEntry.name); // TODO: GH#18217 + if (!result.error) { + resolvedModule = result.module as T; + break; + } + const err = result.error.stack || result.error.message || JSON.stringify(result.error); + (errorLogs ??= []).push(`Failed to load module '${pluginConfigEntry.name}' from ${resolvedPath}: ${err}`); + } + return { pluginConfigEntry, resolvedModule, errorLogs }; +} + /** @internal */ export type FileSystemEntryExists = (fileorDirectrory: string, entryKind: FileSystemEntryKind) => boolean; @@ -907,6 +948,7 @@ export interface CreateSystemWatchFunctions { tscWatchDirectory: string | undefined; inodeWatching: boolean; sysLog: (s: string) => void; + getSystem: () => System; } /** @internal */ @@ -927,6 +969,7 @@ export function createSystemWatchFunctions({ tscWatchDirectory, inodeWatching, sysLog, + getSystem, }: CreateSystemWatchFunctions): { watchFile: HostWatchFile; watchDirectory: HostWatchDirectory; } { const pollingWatches = new Map>(); const fsWatches = new Map>(); @@ -936,12 +979,67 @@ export function createSystemWatchFunctions({ let nonPollingWatchFile: HostWatchFile | undefined; let hostRecursiveDirectoryWatcher: HostWatchDirectory | undefined; let hitSystemWatcherLimit = false; + let reportErrorOnMissingRequire = true; + return { watchFile, - watchDirectory + watchDirectory, }; + function getUserWatchFactory(options: WatchOptions | undefined): UserWatchFactory | undefined { + if (!options?.watchFactory) return undefined; + // Look if we alaready have this factory resolved + if (options.getResolvedWatchFactory) return options.getResolvedWatchFactory(); + const system = getSystem(); + if (!system.require) { + if (reportErrorOnMissingRequire) sysLog(`Custom watchFactory is ignored because of not running in environment that supports 'require'. Watches will defualt to builtin.`); + reportErrorOnMissingRequire = false; + return setUserWatchFactory(options, /*userWatchFactory*/ undefined); + } + const factoryName = isString(options.watchFactory) ? options.watchFactory : options.watchFactory.name; + if (!factoryName || parsePackageName(factoryName).rest) { + sysLog(`Skipped loading watchFactory ${isString(options.watchFactory) ? options.watchFactory : JSON.stringify(options.watchFactory)} because it can be named with only package name`); + return setUserWatchFactory(options, /*userWatchFactory*/ undefined); + } + const host = options.getHost?.(); + const searchPaths = host ? + host.searchPaths : + [ + combinePaths(system.getExecutingFilePath(), "../../..") + ]; + sysLog(`Enabling watchFactory ${isString(options.watchFactory) ? options.watchFactory : JSON.stringify(options.watchFactory)} from candidate paths: ${searchPaths.join(",")}`); + const { resolvedModule, errorLogs, pluginConfigEntry } = resolveModule( + getWatchFactoryPlugin(options), + searchPaths, + getSystem(), + sysLog + ); + if (typeof resolvedModule === "function") { + return setUserWatchFactory(options, resolvedModule({ typescript: { sys, FileWatcherEventKind }, options, config: pluginConfigEntry })); + } + else if (!resolvedModule) { + forEach(errorLogs, sysLog); + sysLog(`Couldn't find ${pluginConfigEntry.name}`); + } + else { + sysLog(`Skipped loading plugin ${pluginConfigEntry.name} because it did not expose a proper factory function`); + } + return setUserWatchFactory(options, /*userWatchFactory*/ undefined); + } + + function getWatchFactoryPlugin(options: WatchOptions) { + const plugin = isString(options.watchFactory) ? { name: options.watchFactory } : options.watchFactory!; + return options.getHost?.().getPluginWithConfigOverride(plugin) || plugin; + } + + function setUserWatchFactory(options: WatchOptions, userWatchFactory: UserWatchFactory | undefined) { + setWatchOptionInternalProperty(options, "getResolvedWatchFactory", userWatchFactory ? () => userWatchFactory : returnUndefined); + return userWatchFactory; + } + function watchFile(fileName: string, callback: FileWatcherCallback, pollingInterval: PollingInterval, options: WatchOptions | undefined): FileWatcher { + const userWatchFactory = getUserWatchFactory(options); + if (typeof userWatchFactory?.watchFile === "function") return userWatchFactory.watchFile(fileName, callback, pollingInterval, options); options = updateOptionsForWatchFile(options, useNonPollingWatchers); const watchFileKind = Debug.checkDefined(options.watchFile); switch (watchFileKind) { @@ -1022,6 +1120,8 @@ export function createSystemWatchFunctions({ } function watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher { + const userWatchFactory = getUserWatchFactory(options); + if (typeof userWatchFactory?.watchDirectory === "function") return userWatchFactory.watchDirectory(directoryName, callback, recursive, options); if (fsSupportsRecursiveFsWatch) { return fsWatch( directoryName, @@ -1428,7 +1528,7 @@ export interface System { base64decode?(input: string): string; base64encode?(input: string): string; /** @internal */ bufferFrom?(input: string, encoding?: string): Buffer; - /** @internal */ require?(baseDir: string, moduleName: string): RequireResult; + /** @internal */ require?(baseDir: string, moduleName: string): ModuleImportResult; // For testing /** @internal */ now?(): Date; @@ -1467,7 +1567,7 @@ export let sys: System = (() => { let profilePath = "./profile.cpuprofile"; const Buffer: { - new (input: string, encoding?: string): any; + new(input: string, encoding?: string): any; from?(input: string, encoding?: string): any; } = require("buffer").Buffer; @@ -1505,6 +1605,7 @@ export let sys: System = (() => { tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, inodeWatching: isLinuxOrMacOs, sysLog, + getSystem: () => nodeSystem, }); const nodeSystem: System = { args: process.argv.slice(2), @@ -1513,7 +1614,7 @@ export let sys: System = (() => { write(s: string): void { process.stdout.write(s); }, - getWidthOfTerminal(){ + getWidthOfTerminal() { return process.stdout.columns; }, writeOutputIsTTY() { diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index 95668468d36f0..b0b45c00aafae 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -161,6 +161,7 @@ export interface BuildOptions { /** @internal */ locale?: string; /** @internal */ generateCpuProfile?: string; /** @internal */ generateTrace?: string; + /** @internal */ allowPlugins?: boolean; [option: string]: CompilerOptionsValue | undefined; } @@ -567,7 +568,7 @@ function parseConfigFile(state: SolutionBuilderState diagnostic = d; - parsed = getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions); + parsed = getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions, /*extraFileExtensions*/ undefined, state.hostWithWatch.checkAllowPlugins); parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = noop; } configFileCache.set(configFilePath, parsed || diagnostic!); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b97d9becc8f68..caa029b0d65fc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,7 +1,11 @@ import { BaseNodeFactory, CreateSourceFileOptions, + DirectoryWatcherCallback, EmitHelperFactory, + FileWatcher, + FileWatcherCallback, + FileWatcherEventKind, GetCanonicalFileName, MapLike, ModeAwareCache, @@ -15,6 +19,7 @@ import { Pattern, ProgramBuildInfo, SymlinkCache, + System, ThisContainer, } from "./_namespaces/ts"; @@ -6942,7 +6947,7 @@ export interface Diagnostic extends DiagnosticRelatedInformation { export type DiagnosticArguments = (string | number)[]; /** @internal */ -export type DiagnosticAndArguments = [message: DiagnosticMessage, ...args: DiagnosticArguments]; +export type DiagnosticAndArguments = readonly [message: DiagnosticMessage, ...args: DiagnosticArguments]; export interface DiagnosticRelatedInformation { category: DiagnosticCategory; @@ -7051,7 +7056,7 @@ export enum PollingWatchKind { FixedChunkSize, } -export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; +export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { /** @internal */ all?: boolean; @@ -7153,6 +7158,7 @@ export interface CompilerOptions { */ pathsBasePath?: string; /** @internal */ plugins?: PluginImport[]; + /** @internal */ allowPlugins?: boolean; preserveConstEnums?: boolean; noImplicitOverride?: boolean; preserveSymlinks?: boolean; @@ -7202,6 +7208,26 @@ export interface CompilerOptions { [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } +export interface TypeScriptSubsetForWatchFactory { + sys: System; + FileWatcherEventKind: typeof FileWatcherEventKind; +} + +export type UserWatchFactoryModule = (mod: { + typescript: TypeScriptSubsetForWatchFactory; + options: WatchOptions; + config: any; +}) => UserWatchFactory; +export interface UserWatchFactory { + watchFile?(fileName: string, callback: FileWatcherCallback, pollingInterval: number, options: WatchOptions | undefined): FileWatcher; + watchDirectory?(fileName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher; + onConfigurationChanged?(config: any): void; +} +/**@internal*/ +export interface WatchOptionsFactoryHost { + searchPaths: readonly string[]; + getPluginWithConfigOverride(plugin: PluginImport): PluginImport; +} export interface WatchOptions { watchFile?: WatchFileKind; watchDirectory?: WatchDirectoryKind; @@ -7209,8 +7235,13 @@ export interface WatchOptions { synchronousWatchDirectory?: boolean; excludeDirectories?: string[]; excludeFiles?: string[]; + watchFactory?: string | PluginImport; - [option: string]: CompilerOptionsValue | undefined; + // All the internal properties are set as non enumerable and non configurable so that they arenot enumerated when checking if options have changed + /** @internal */ getResolvedWatchFactory?(): UserWatchFactory | undefined; + /** @internal */ getHost?(): WatchOptionsFactoryHost; + + [option: string]: CompilerOptionsValue | Function | undefined; } export interface TypeAcquisition { @@ -7343,7 +7374,7 @@ export interface ConfigFileSpecs { } /** @internal */ -export type RequireResult = +export type ModuleImportResult = | { module: T, modulePath?: string, error: undefined } | { module: undefined, modulePath?: undefined, error: { stack?: string, message?: string } }; @@ -7358,10 +7389,16 @@ export interface CreateProgramOptions { typeScriptVersion?: string; } + /** @internal */ +export type CommandLineOptionExtraValidation = (value: CompilerOptionsValue, valueExpression?: Expression) => + DiagnosticAndArguments | + { diagnostics: DiagnosticAndArguments; errorNode: Expression; } | + undefined; + /** @internal */ export interface CommandLineOptionBase { name: string; - type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | Map; // a value of a primitive type, or an object literal mapping named values to actual values + type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | "string | object" | Map; // a value of a primitive type, or an object literal mapping named values to actual values isFilePath?: boolean; // True if option value is a path or fileName shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does. @@ -7381,8 +7418,8 @@ export interface CommandLineOptionBase { affectsDeclarationPath?: true; // true if the options affects declaration file path computed 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 + extraValidation?: CommandLineOptionExtraValidation; // Additional validation to be performed for the value to be valid + disallowNullOrUndefined?: true; // If set option does not allow setting null } /** @internal */ @@ -7425,8 +7462,8 @@ export interface DidYouMeanOptionsDiagnostics { } /** @internal */ -export interface TsConfigOnlyOption extends CommandLineOptionBase { - type: "object"; +export interface CommandLineOptionOfObjectType extends CommandLineOptionBase { + type: "object" | "string | object"; elementOptions?: Map; extraKeyDiagnostics?: DidYouMeanOptionsDiagnostics; } @@ -7434,12 +7471,12 @@ export interface TsConfigOnlyOption extends CommandLineOptionBase { /** @internal */ export interface CommandLineOptionOfListType extends CommandLineOptionBase { type: "list" | "listOrElement"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption; + element: CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | CommandLineOptionOfObjectType; listPreserveFalsyValues?: boolean; } /** @internal */ -export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption | CommandLineOptionOfListType; +export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | CommandLineOptionOfObjectType | CommandLineOptionOfListType; /** @internal */ export const enum CharacterCodes { diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 682430f0776f0..1dc381bb71599 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -213,10 +213,18 @@ export function createWatchStatusReporter(system: System, pretty?: boolean): Wat * * @internal */ -export function parseConfigFileWithSystem(configFileName: string, optionsToExtend: CompilerOptions, extendedConfigCache: Map | undefined, watchOptionsToExtend: WatchOptions | undefined, system: System, reportDiagnostic: DiagnosticReporter): ParsedCommandLine | undefined { +export function parseConfigFileWithSystem( + configFileName: string, + optionsToExtend: CompilerOptions, + extendedConfigCache: Map | undefined, + watchOptionsToExtend: WatchOptions | undefined, + system: System, + reportDiagnostic: DiagnosticReporter, + checkAllowPlugins: boolean, +): ParsedCommandLine | undefined { const host: ParseConfigFileHost = system as any; host.onUnRecoverableConfigFileDiagnostic = diagnostic => reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); - const result = getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); + const result = getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, /*extraFileExtensions*/ undefined, checkAllowPlugins); host.onUnRecoverableConfigFileDiagnostic = undefined!; // TODO: GH#18217 return result; } diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index fec0b5e34611b..332dc64b7d246 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -161,6 +161,7 @@ export interface WatchHost { setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; /** If provided, will be used to reset existing delayed compilation */ clearTimeout?(timeoutId: any): void; + /** @internal */ checkAllowPlugins?: boolean; } export interface ProgramHost { /** @@ -902,7 +903,8 @@ export function createWatchProgram(host: WatchCompiler parseConfigFileHost, extendedConfigCache ||= new Map(), watchOptionsToExtend, - extraFileExtensions + extraFileExtensions, + host.checkAllowPlugins, )!); // TODO: GH#18217 } @@ -962,7 +964,9 @@ export function createWatchProgram(host: WatchCompiler /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache ||= new Map(), - watchOptionsToExtend + watchOptionsToExtend, + host.extraFileExtensions, + host.checkAllowPlugins, ); parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; return parsedCommandLine; diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index b6f1d1ddedd7c..5608376411d7e 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -370,6 +370,7 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign case "string": case "number": case "boolean": + case "string | object": return getDiagnosticText(Diagnostics.type_Colon); case "list": return getDiagnosticText(Diagnostics.one_or_more_Colon); @@ -390,6 +391,9 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign case "listOrElement": possibleValues = getPossibleValues(option.element); break; + case "string | object": + possibleValues = "string"; + break; case "object": possibleValues = ""; break; @@ -641,7 +645,7 @@ function executeCommandLineWorker( ); if (configFileName) { const extendedConfigCache = new Map(); - const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, extendedConfigCache, commandLine.watchOptions, sys, reportDiagnostic)!; // TODO: GH#18217 + const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, extendedConfigCache, commandLine.watchOptions, sys, reportDiagnostic, /*checkAllowPlugins*/ true)!; // TODO: GH#18217 if (commandLineOptions.showConfig) { if (configParseResult.errors.length !== 0) { reportDiagnostic = updateReportDiagnostic( @@ -843,6 +847,7 @@ function performBuild( ); const solutionPerformance = enableSolutionPerformance(sys, buildOptions); updateSolutionBuilderHost(sys, cb, buildHost, solutionPerformance); + buildHost.checkAllowPlugins = true; const onWatchStatusChange = buildHost.onWatchStatusChange; let reportBuildStatistics = false; buildHost.onWatchStatusChange = (d, newLine, options, errorCount) => { @@ -975,6 +980,7 @@ function updateWatchCompilationHost( cb: ExecuteCommandLineCallbacks, watchCompilerHost: WatchCompilerHost, ) { + watchCompilerHost.checkAllowPlugins = true; updateCreateProgram(sys, watchCompilerHost, /*isBuildMode*/ false); const emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate!; // TODO: GH#18217 watchCompilerHost.afterProgramCreate = builderProgram => { diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index f49eda407ffec..397021dfd0747 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -385,8 +385,11 @@ export namespace Compiler { case "list": case "listOrElement": return ts.parseListTypeOption(option, value, errors); + case "object": + case "string | object": + return ts.parseObjectTypeOption(option, value, errors)?.value; default: - return ts.parseCustomTypeOption(option as ts.CommandLineOptionOfCustomType, value, errors); + return ts.parseCustomTypeOption(option, value, errors); } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a8c854325a266..d8b7e5eb9a415 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -885,7 +885,7 @@ class SessionServerHost implements ts.server.ServerHost, ts.server.Logger { return mockHash(s); } - require(_initialDir: string, _moduleName: string): ts.RequireResult { + require(_initialDir: string, _moduleName: string): ts.ModuleImportResult { switch (_moduleName) { // Adds to the Quick Info a fixed string and a string from the config file // and replaces the first display part diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 8e4443e22086d..8ca8811e9b11a 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -46,6 +46,7 @@ import { forEachKey, forEachResolvedProjectReference, FormatCodeSettings, + formatDiagnostics, getAnyExtensionFromPath, getBaseFileName, getDefaultFormatCodeSettings, @@ -76,6 +77,7 @@ import { map, mapDefinedEntries, mapDefinedIterator, + memoize, missingFileModifiedTime, MultiMap, noop, @@ -100,10 +102,12 @@ import { removeIgnoredPath, removeMinAndVersionNumbers, ResolvedProjectReference, + resolveModule, resolveProjectReferencePath, returnNoopFileWatcher, returnTrue, ScriptKind, + setWatchOptionInternalProperty, SharedExtendedConfigFileWatcher, some, SourceFile, @@ -807,6 +811,10 @@ function setProjectOptionsUsed(project: ConfiguredProject | ExternalProject) { } } +function onWachOptionsFactoryConfigurationChanged(watchOptions: WatchOptions, pluginName: string, configuration: any) { + if (watchOptions.watchFactory === pluginName) watchOptions.getResolvedWatchFactory?.()?.onConfigurationChanged?.(configuration); +} + /** @internal */ export interface OpenFileArguments { fileName: string; @@ -828,7 +836,7 @@ export interface WatchOptionsAndErrors { } /** @internal */ -export interface ParsedConfig{ +export interface ParsedConfig { cachedDirectoryStructureHost: CachedDirectoryStructureHost; /** * The map contains @@ -938,6 +946,7 @@ export class ProjectService { /** @internal */ readonly throttledOperations: ThrottledOperations; private readonly hostConfiguration: HostConfiguration; + /** @internal */ private readonly projectWatchOptions = new Map(); private safelist: SafeList = defaultTypeSafeList; private readonly legacySafelist = new Map(); @@ -962,6 +971,7 @@ export class ProjectService { public readonly globalPlugins: readonly string[]; public readonly pluginProbeLocations: readonly string[]; public readonly allowLocalPluginLoads: boolean; + /** @internal */ private currentPluginConfigOverrides: Map | undefined; public readonly typesMapLocation: string | undefined; @@ -1306,6 +1316,7 @@ export class ProjectService { !project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) { project.setCompilerOptions(compilerOptions); project.setTypeAcquisition(typeAcquisition); + this.clearWatchOptionsFromProjectWatchOptions(project.getWatchOptions()); project.setWatchOptions(watchOptions?.watchOptions); project.setProjectErrors(watchOptions?.errors); project.compileOnSaveEnabled = compilerOptions.compileOnSave!; @@ -1486,7 +1497,7 @@ export class ProjectService { * * @internal */ - private watchWildcardDirectory(directory: Path, flags: WatchDirectoryFlags, configFileName: NormalizedPath, config: ParsedConfig) { + private watchWildcardDirectory(directory: Path, flags: WatchDirectoryFlags, configFileName: NormalizedPath, canonicalConfigFilePath: NormalizedPath, config: ParsedConfig) { return this.watchFactory.watchDirectory( directory, fileOrDirectory => { @@ -1545,7 +1556,7 @@ export class ProjectService { }); }, flags, - this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine!.watchOptions), + this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine!.watchOptions, canonicalConfigFilePath), WatchType.WildcardDirectory, configFileName ); @@ -1859,7 +1870,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, canonicalConfigFilePath), WatchType.ConfigFile, forProject ); @@ -1884,6 +1895,7 @@ export class ProjectService { // If there are still projects watching this config file existence and config, there is nothing to do if (configFileExistenceInfo.config?.projects.size) return; + this.clearWatchOptionsFromProjectWatchOptions(configFileExistenceInfo.config.parsedCommandLine?.watchOptions); configFileExistenceInfo.config = undefined; clearSharedExtendedConfigFileWatcher(canonicalConfigFilePath, this.sharedExtendedConfigFileWatchers); Debug.checkDefined(configFileExistenceInfo.watcher); @@ -2189,7 +2201,6 @@ export class ProjectService { /*lastFileExceededProgramSize*/ this.getFilenameForExceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave, /*projectFilePath*/ undefined, - this.currentPluginConfigOverrides, watchOptionsAndErrors?.watchOptions ); project.setProjectErrors(watchOptionsAndErrors?.errors); @@ -2354,7 +2365,7 @@ export class ProjectService { project.enableLanguageService(); this.watchWildcards(configFilename, configFileExistenceInfo, project); } - project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); + project.enablePluginsWithOptions(compilerOptions); const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition!, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions); tracing?.pop(); @@ -2402,6 +2413,7 @@ export class ProjectService { }, /*replacer*/ undefined, " ")}`); const oldCommandLine = configFileExistenceInfo.config?.parsedCommandLine; + this.clearWatchOptionsFromProjectWatchOptions(oldCommandLine?.watchOptions); if (!configFileExistenceInfo.config) { configFileExistenceInfo.config = { parsedCommandLine, cachedDirectoryStructureHost, projects: new Map() }; } @@ -2414,9 +2426,9 @@ export class ProjectService { // If watch options different than older options when setting for the first time, update the config file watcher if (!oldCommandLine && !isJsonEqual( // Old options - this.getWatchOptionsFromProjectWatchOptions(/*projectOptions*/ undefined), + this.getWatchOptionsFromProjectWatchOptions(/*projectOptions*/ undefined, canonicalConfigFilePath), // New options - this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions) + this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions, canonicalConfigFilePath) )) { // Reset the config file watcher configFileExistenceInfo.watcher?.close(); @@ -2462,7 +2474,7 @@ export class ProjectService { config!.watchedDirectories ||= new Map(), new Map(Object.entries(config!.parsedCommandLine!.wildcardDirectories!)), // Create new directory watcher - (directory, flags) => this.watchWildcardDirectory(directory as Path, flags, configFileName, config!), + (directory, flags) => this.watchWildcardDirectory(directory as Path, flags, configFileName, forProject.canonicalConfigFilePath, config!), ); } else { @@ -2737,7 +2749,7 @@ export class ProjectService { typeAcquisition = this.typeAcquisitionForInferredProjects; } watchOptionsAndErrors = watchOptionsAndErrors || undefined; - const project = new InferredProject(this, this.documentRegistry, compilerOptions, watchOptionsAndErrors?.watchOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides, typeAcquisition); + const project = new InferredProject(this, this.documentRegistry, compilerOptions, watchOptionsAndErrors?.watchOptions, projectRootPath, currentDirectory, typeAcquisition); project.setProjectErrors(watchOptionsAndErrors?.errors); if (isSingleInferredProject) { this.inferredProjects.unshift(project); @@ -3223,22 +3235,54 @@ export class ProjectService { } if (args.watchOptions) { - this.hostConfiguration.watchOptions = convertWatchOptions(args.watchOptions)?.watchOptions; + const result = convertWatchOptions(args.watchOptions); + this.hostConfiguration.watchOptions = result?.watchOptions; + if (this.hostConfiguration.watchOptions?.watchFactory) { + this.setWatchOptionsFactoryHost(this.hostConfiguration.watchOptions, /*canonicalConfigFilePath*/ undefined); + } + this.projectWatchOptions.clear(); this.logger.info(`Host watch options changed to ${JSON.stringify(this.hostConfiguration.watchOptions)}, it will be take effect for next watches.`); + if (result?.errors?.length) { + this.logger.info(`Watch options supplied had errors: Supplied options: ${JSON.stringify(args.watchOptions)}`); + this.logger.info(`Diagnostics:: ${formatDiagnostics(result.errors, { + getCurrentDirectory: () => this.host.getCurrentDirectory(), + getNewLine: () => this.host.newLine, + getCanonicalFileName: createGetCanonicalFileName(this.host.useCaseSensitiveFileNames), + })}`); + } } } } /** @internal */ - getWatchOptions(project: Project) { - return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions()); + getWatchOptions(project: Project): WatchOptions | undefined { + return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions(), isConfiguredProject(project) ? project.canonicalConfigFilePath : undefined); } /** @internal */ - private getWatchOptionsFromProjectWatchOptions(projectOptions: WatchOptions | undefined) { - return projectOptions && this.hostConfiguration.watchOptions ? + private getWatchOptionsFromProjectWatchOptions(projectOptions: WatchOptions | undefined, canonicalConfigFilePath: NormalizedPath | undefined) { + if (!projectOptions) return this.hostConfiguration.watchOptions; + let options = this.projectWatchOptions.get(projectOptions); + if (options) return options; + this.projectWatchOptions.set(projectOptions, options = this.hostConfiguration.watchOptions ? { ...this.hostConfiguration.watchOptions, ...projectOptions } : - projectOptions || this.hostConfiguration.watchOptions; + projectOptions + ); + this.setWatchOptionsFactoryHost(options, canonicalConfigFilePath); + return options; + } + + /** @internal */ + private setWatchOptionsFactoryHost(options: WatchOptions, canonicalConfigFilePath: NormalizedPath | undefined) { + setWatchOptionInternalProperty(options, "getHost", memoize(() => ({ + searchPaths: this.getProjectPluginSearchPaths(canonicalConfigFilePath), + getPluginWithConfigOverride: plugin => this.getPluginWithConfigOverride(plugin), + }))); + } + + /** @internal */ + clearWatchOptionsFromProjectWatchOptions(projectOptions: WatchOptions | undefined) { + if (projectOptions) this.projectWatchOptions.delete(projectOptions); } closeLog() { @@ -3870,7 +3914,7 @@ export class ProjectService { currentProjects: Iterable, includeProjectReferenceRedirectInfo: boolean | undefined, result: ProjectFilesWithTSDiagnostics[] - ): void { + ): void { for (const proj of currentProjects) { const knownProject = find(lastKnownProjectVersions, p => p.projectName === proj.getProjectName()); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version, includeProjectReferenceRedirectInfo)); @@ -4161,6 +4205,7 @@ export class ProjectService { externalProject.enableLanguageService(); } externalProject.setProjectErrors(watchOptionsAndErrors?.errors); + this.clearWatchOptionsFromProjectWatchOptions(externalProject.getWatchOptions()); // external project already exists and not config files were added - update the project and return; // The graph update here isnt postponed since any file open operation needs all updated external projects this.updateRootAndOptionsOfNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, watchOptionsAndErrors?.watchOptions); @@ -4243,7 +4288,40 @@ export class ProjectService { } /** @internal */ - requestEnablePlugin(project: Project, pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined) { + getGlobalPluginSearchPaths() { + // Search any globally-specified probe paths, then our peer node_modules + return [ + ...this.pluginProbeLocations, + // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ + combinePaths(this.getExecutingFilePath(), "../../.."), + ]; + } + + /** @internal */ + getProjectPluginSearchPaths(canonicalConfigFilePath: string | undefined) { + const searchPaths = this.getGlobalPluginSearchPaths(); + if (canonicalConfigFilePath && this.allowLocalPluginLoads) { + const local = getDirectoryPath(canonicalConfigFilePath); + this.logger.info(`Local plugin loading enabled; adding ${local} to search paths`); + searchPaths.unshift(local); + } + return searchPaths; + } + + /** @internal */ + getPluginWithConfigOverride(pluginConfigEntry: PluginImport) { + const configurationOverride = this.currentPluginConfigOverrides?.get(pluginConfigEntry.name); + if (configurationOverride) { + // Preserve the name property since it's immutable + const pluginName = pluginConfigEntry.name; + pluginConfigEntry = configurationOverride; + pluginConfigEntry.name = pluginName; + } + return pluginConfigEntry; + } + + /** @internal */ + requestEnablePlugin(project: Project, pluginConfigEntry: PluginImport, searchPaths: string[]) { if (!this.host.importPlugin && !this.host.require) { this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; @@ -4257,7 +4335,12 @@ export class ProjectService { // If the host supports dynamic import, begin enabling the plugin asynchronously. if (this.host.importPlugin) { - const importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides); + const importPromise: Promise = Project.importServicePluginAsync( + pluginConfigEntry, + searchPaths, + this.host, + s => this.logger.info(s), + ); this.pendingPluginEnablements ??= new Map(); let promises = this.pendingPluginEnablements.get(project); if (!promises) this.pendingPluginEnablements.set(project, promises = []); @@ -4266,7 +4349,12 @@ export class ProjectService { } // Otherwise, load the plugin using `require` - project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides)); + project.endEnablePlugin(resolveModule( + pluginConfigEntry, + searchPaths, + this.host, + s => this.logger.info(s), + )); } /** @internal */ @@ -4355,6 +4443,9 @@ export class ProjectService { configurePlugin(args: protocol.ConfigurePluginRequestArguments) { // For any projects that already have the plugin loaded, configure the plugin this.forEachEnabledProject(project => project.onPluginConfigurationChanged(args.pluginName, args.configuration)); + this.projectWatchOptions.forEach(options => + onWachOptionsFactoryConfigurationChanged(options, args.pluginName, args.configuration)); + if (this.hostConfiguration.watchOptions) onWachOptionsFactoryConfigurationChanged(this.hostConfiguration.watchOptions, args.pluginName, args.configuration); // Also save the current configuration to pass on to any projects that are yet to be loaded. // If a plugin is configured twice, only the latest configuration will be remembered. diff --git a/src/server/project.ts b/src/server/project.ts index f05f4d4ae8fc6..33cc686faf95e 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -38,7 +38,6 @@ import { FileWatcherCallback, FileWatcherEventKind, filter, - firstDefined, flatMap, forEach, forEachEntry, @@ -60,6 +59,7 @@ import { getStringComparer, HasInvalidatedResolutions, HostCancellationToken, + ImportPluginResult, inferredTypesContainingFile, InstallPackageOptions, IScriptSnapshot, @@ -99,6 +99,7 @@ import { ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, ResolvedTypeReferenceDirectiveWithFailedLookupLocations, + resolveModule, resolvePackageNameToPackageJson, returnFalse, returnTrue, @@ -252,12 +253,7 @@ export interface PluginModuleWithName { export type PluginModuleFactory = (mod: { typescript: typeof ts }) => PluginModule; /** @internal */ -export interface BeginEnablePluginResult { - pluginConfigEntry: PluginImport; - pluginConfigOverrides: Map | undefined; - resolvedModule: PluginModuleFactory | undefined; - errorLogs: string[] | undefined; -} +export type BeginEnablePluginResult = ImportPluginResult; /** * The project root can be script info - if root is present, @@ -394,36 +390,38 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo return hasOneOrMoreJsAndNoTsFiles(this); } - public static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): {} | undefined { - const resolvedPath = normalizeSlashes(host.resolvePath(combinePaths(initialDir, "node_modules"))); - log(`Loading ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`); - const result = host.require!(resolvedPath, moduleName); // TODO: GH#18217 - if (result.error) { - const err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)(`Failed to load module '${moduleName}' from ${resolvedPath}: ${err}`); - return undefined; - } - return result.module; + public static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined { + return resolveModule({ name: moduleName }, [initialDir], host, log).resolvedModule; } /** @internal */ - public static async importServicePluginAsync(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): Promise<{} | undefined> { + public static async importServicePluginAsync( + pluginConfigEntry: PluginImport, + searchPaths: string[], + host: ServerHost, + log: (message: string) => void, + ): Promise> { Debug.assertIsDefined(host.importPlugin); - const resolvedPath = combinePaths(initialDir, "node_modules"); - log(`Dynamically importing ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`); - let result: ModuleImportResult; - try { - result = await host.importPlugin(resolvedPath, moduleName); - } - catch (e) { - result = { module: undefined, error: e }; - } - if (result.error) { + let errorLogs: string[] | undefined; + let resolvedModule: T | undefined; + for (const initialDir of searchPaths) { + const resolvedPath = combinePaths(initialDir, "node_modules"); + log(`Dynamically importing ${pluginConfigEntry.name} from ${initialDir} (resolved to ${resolvedPath})`); + let result: ModuleImportResult; + try { + result = await host.importPlugin(resolvedPath, pluginConfigEntry.name); + } + catch (e) { + result = { module: undefined, error: e }; + } + if (!result.error) { + resolvedModule = result.module as T; + break; + } const err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)(`Failed to dynamically import module '${moduleName}' from ${resolvedPath}: ${err}`); - return undefined; + (errorLogs ??= []).push(`Failed to dynamically import module '${pluginConfigEntry.name}' from ${resolvedPath}: ${err}`); } - return result.module; + return { pluginConfigEntry, resolvedModule, errorLogs }; } /** @internal */ @@ -1788,15 +1786,10 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo /** @internal */ protected getGlobalPluginSearchPaths() { - // Search any globally-specified probe paths, then our peer node_modules - return [ - ...this.projectService.pluginProbeLocations, - // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - combinePaths(this.projectService.getExecutingFilePath(), "../../.."), - ]; + return this.projectService.getProjectPluginSearchPaths(/*canonicalConfigFilePath*/ undefined); } - protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined): void { + protected enableGlobalPlugins(options: CompilerOptions): void { if (!this.projectService.globalPlugins.length) return; const host = this.projectService.host; @@ -1806,7 +1799,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo } // Enable global plugins with synthetic configuration entries - const searchPaths = this.getGlobalPluginSearchPaths(); + const searchPaths = this.projectService.getGlobalPluginSearchPaths(); for (const globalPluginName of this.projectService.globalPlugins) { // Skip empty names from odd commandline parses if (!globalPluginName) continue; @@ -1817,68 +1810,18 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo // Provide global: true so plugins can detect why they can't find their config this.projectService.logger.info(`Loading global plugin ${globalPluginName}`); - this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths, pluginConfigOverrides); + this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths); } } - /** - * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'. - * - * @internal - */ - beginEnablePluginSync(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): BeginEnablePluginResult { - Debug.assertIsDefined(this.projectService.host.require); - - let errorLogs: string[] | undefined; - const log = (message: string) => this.projectService.logger.info(message); - const logError = (message: string) => { - (errorLogs ??= []).push(message); - }; - const resolvedModule = firstDefined(searchPaths, searchPath => - Project.resolveModule(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError) as PluginModuleFactory | undefined); - return { pluginConfigEntry, pluginConfigOverrides, resolvedModule, errorLogs }; - } - - /** - * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`. - * - * @internal - */ - async beginEnablePluginAsync(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): Promise { - Debug.assertIsDefined(this.projectService.host.importPlugin); - - let errorLogs: string[] | undefined; - const log = (message: string) => this.projectService.logger.info(message); - const logError = (message: string) => { - (errorLogs ??= []).push(message); - }; - - let resolvedModule: PluginModuleFactory | undefined; - for (const searchPath of searchPaths) { - resolvedModule = await Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError) as PluginModuleFactory | undefined; - if (resolvedModule !== undefined) { - break; - } - } - return { pluginConfigEntry, pluginConfigOverrides, resolvedModule, errorLogs }; - } - /** * Performs the remaining steps of enabling a plugin after its module has been instantiated. * * @internal */ - endEnablePlugin({ pluginConfigEntry, pluginConfigOverrides, resolvedModule, errorLogs }: BeginEnablePluginResult) { + endEnablePlugin({ pluginConfigEntry, resolvedModule, errorLogs }: BeginEnablePluginResult) { if (resolvedModule) { - const configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); - if (configurationOverride) { - // Preserve the name property since it's immutable - const pluginName = pluginConfigEntry.name; - pluginConfigEntry = configurationOverride; - pluginConfigEntry.name = pluginName; - } - - this.enableProxy(resolvedModule, pluginConfigEntry); + this.enableProxy(resolvedModule, this.projectService.getPluginWithConfigOverride(pluginConfigEntry)); } else { forEach(errorLogs, message => this.projectService.logger.info(message)); @@ -1886,8 +1829,8 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo } } - protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): void { - this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides); + protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void { + this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths); } private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) { @@ -1926,8 +1869,8 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo /** @internal */ onPluginConfigurationChanged(pluginName: string, configuration: any) { - this.plugins.filter(plugin => plugin.name === pluginName).forEach(plugin => { - if (plugin.module.onConfigurationChanged) { + this.plugins.forEach(plugin => { + if (plugin.name === pluginName && plugin.module.onConfigurationChanged) { plugin.module.onConfigurationChanged(configuration); } }); @@ -2177,7 +2120,6 @@ export class InferredProject extends Project { watchOptions: WatchOptions | undefined, projectRootPath: NormalizedPath | undefined, currentDirectory: string, - pluginConfigOverrides: Map | undefined, typeAcquisition: TypeAcquisition | undefined) { super(projectService.newInferredProjectName(), ProjectKind.Inferred, @@ -2196,7 +2138,7 @@ export class InferredProject extends Project { if (!projectRootPath && !projectService.useSingleInferredProject) { this.canonicalCurrentDirectory = projectService.toCanonicalFileName(this.currentDirectory); } - this.enableGlobalPlugins(this.getCompilerOptions(), pluginConfigOverrides); + this.enableGlobalPlugins(this.getCompilerOptions()); } override addRoot(info: ScriptInfo) { @@ -2233,6 +2175,7 @@ export class InferredProject extends Project { override close() { forEach(this.getRootScriptInfos(), info => this.projectService.stopWatchingConfigFilesForInferredProjectRoot(info)); + this.projectService.clearWatchOptionsFromProjectWatchOptions(this.watchOptions); super.close(); } @@ -2714,7 +2657,12 @@ export class ConfiguredProject extends Project { } /** @internal */ - enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: Map | undefined): void { + protected getProjectPluginSearchPaths() { + return this.projectService.getProjectPluginSearchPaths(this.canonicalConfigFilePath); + } + + /** @internal */ + enablePluginsWithOptions(options: CompilerOptions): void { this.plugins.length = 0; if (!options.plugins?.length && !this.projectService.globalPlugins.length) return; const host = this.projectService.host; @@ -2723,21 +2671,15 @@ export class ConfiguredProject extends Project { return; } - const searchPaths = this.getGlobalPluginSearchPaths(); - if (this.projectService.allowLocalPluginLoads) { - const local = getDirectoryPath(this.canonicalConfigFilePath); - this.projectService.logger.info(`Local plugin loading enabled; adding ${local} to search paths`); - searchPaths.unshift(local); - } - // Enable tsconfig-specified plugins + const searchPaths = this.getProjectPluginSearchPaths(); if (options.plugins) { for (const pluginConfigEntry of options.plugins) { - this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides); + this.enablePlugin(pluginConfigEntry, searchPaths); } } - return this.enableGlobalPlugins(options, pluginConfigOverrides); + return this.enableGlobalPlugins(options); } /** @@ -2869,7 +2811,6 @@ export class ExternalProject extends Project { lastFileExceededProgramSize: string | undefined, public override compileOnSaveEnabled: boolean, projectFilePath?: string, - pluginConfigOverrides?: Map, watchOptions?: WatchOptions) { super(externalProjectName, ProjectKind.External, @@ -2882,7 +2823,7 @@ export class ExternalProject extends Project { watchOptions, projectService.host, getDirectoryPath(projectFilePath || normalizeSlashes(externalProjectName))); - this.enableGlobalPlugins(this.getCompilerOptions(), pluginConfigOverrides); + this.enableGlobalPlugins(this.getCompilerOptions()); } override updateGraph() { @@ -2894,6 +2835,11 @@ export class ExternalProject extends Project { override getExcludedFiles() { return this.excludedFiles; } + + override close() { + this.projectService.clearWatchOptionsFromProjectWatchOptions(this.watchOptions); + super.close(); + } } /** @internal */ diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 819c4797084fc..19d428354650c 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1600,6 +1600,7 @@ export interface WatchOptions { synchronousWatchDirectory?: boolean; excludeDirectories?: string[]; excludeFiles?: string[]; + watchFactory?: string | PluginImport; [option: string]: CompilerOptionsValue | undefined; } diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 33a6ad5c24db9..a1b109e775345 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -189,6 +189,11 @@ describe("unittests:: config:: commandLineParsing:: parseCommandLine", () => { assertParseResult("errors on invalid excludeDirectories", ["--excludeDirectories", "**/../*", "0.ts"]); assertParseResult("parse --excludeFiles", ["--excludeFiles", "**/temp/*.ts", "0.ts"]); assertParseResult("errors on invalid excludeFiles", ["--excludeFiles", "**/../*", "0.ts"]); + assertParseResult("parse --watchFactory", ["--watchFactory", "somefactory", "0.ts"]); + assertParseResult("errors on invalid watchFactory", ["--watchFactory", "somefactory/../malicious", "0.ts"]); + assertParseResult("parse --watchFactory object", ["--watchFactory", "{\"name\":\"somefactory\",\"myconfig\":\"somethingelse\"}", "0.ts"]); + assertParseResult("errors on invalid watchFactory name", ["--watchFactory", "{\"name\":\"somefactory/../malicious\"}", "0.ts"]); + assertParseResult("errors on invalid watchFactory object", ["--watchFactory", "{\"name\":\"myplugin\"", "0.ts"]); }); }); @@ -243,6 +248,11 @@ describe("unittests:: config:: commandLineParsing:: parseBuildOptions", () => { assertParseResult("errors on invalid excludeDirectories", ["--excludeDirectories", "**/../*"]); assertParseResult("parse --excludeFiles", ["--excludeFiles", "**/temp/*.ts"]); assertParseResult("errors on invalid excludeFiles", ["--excludeFiles", "**/../*"]); + assertParseResult("parse --watchFactory", ["--watchFactory", "somefactory"]); + assertParseResult("errors on invalid watchFactory", ["--watchFactory", "somefactory/../malicious"]); + assertParseResult("parse --watchFactory object", ["--watchFactory", `{"name":"somefactory","myconfig":"somethingelse"}`]); + assertParseResult("errors on invalid watchFactory name", ["--watchFactory", "{\"name\":\"somefactory/../malicious\"}"]); + assertParseResult("errors on invalid watchFactory object", ["--watchFactory", "{\"name\":\"myplugin\""]); }); }); diff --git a/src/testRunner/unittests/config/showConfig.ts b/src/testRunner/unittests/config/showConfig.ts index 5b5a7bc12c4bc..8fa821007a7fa 100644 --- a/src/testRunner/unittests/config/showConfig.ts +++ b/src/testRunner/unittests/config/showConfig.ts @@ -126,6 +126,24 @@ describe("unittests:: config:: showConfig", () => { if (option.name === "project") return; let args: string[]; let optionValue: object | undefined; + if (option.type === "string | object") { + if (option.isTSConfigOnly) { + showTSConfigCorrectly( + `Shows tsconfig for single option/${option.name}WithStringValue`, + ["-p", "tsconfig.json"], + isCompilerOptions ? + { compilerOptions: { [option.name]: "someString" } } : + { watchOptions: { [option.name]: "someString" } } + ); + } + else { + showTSConfigCorrectly( + `Shows tsconfig for single option/${option.name}WithStringValue`, + [`--${option.name}`, "someString"], + /*configJson*/ undefined, + ); + } + } switch (option.type) { case "boolean": { if (option.isTSConfigOnly) { @@ -171,6 +189,7 @@ describe("unittests:: config:: showConfig", () => { } break; } + case "string | object": case "object": { args = ["-p", "tsconfig.json"]; optionValue = { [option.name]: {} }; diff --git a/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts b/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts index e87053dd5f546..ebdd6bf455121 100644 --- a/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts +++ b/src/testRunner/unittests/config/tsconfigParsingWatchOptions.ts @@ -121,6 +121,18 @@ describe("unittests:: config:: tsconfigParsingWatchOptions:: parseConfigFileText { json: { watchOptions: { excludeFiles: ["**/../*"] } }, }, + { + json: { watchOptions: { watchFactory: "somefactory" } }, + }, + { + json: { watchOptions: { watchFactory: "somefactory/../malicious" } }, + }, + { + json: { watchOptions: { watchFactory: { name: "somefactory", myconfig: "somethingelse" } } }, + }, + { + json: { watchOptions: { watchFactory: { name: "somefactory/../malicious" } } }, + }, ]); verifyWatchOptions("watch options extending passed in watch options", () => [ diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts index e987263cd81c3..d1d46a01f3e35 100644 --- a/src/testRunner/unittests/reuseProgramStructure.ts +++ b/src/testRunner/unittests/reuseProgramStructure.ts @@ -586,7 +586,7 @@ describe("unittests:: Reuse program structure:: isProgramUptoDate", () => { configFileName, system })).getCurrentProgram().getProgram(); - const { fileNames, options } = ts.parseConfigFileWithSystem(configFileName, {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, ts.notImplemented)!; // TODO: GH#18217 + const { fileNames, options } = ts.parseConfigFileWithSystem(configFileName, {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, ts.notImplemented, /*checkAllowPlugins*/ true)!; // TODO: GH#18217 verifyProgramIsUptoDate(program, fileNames, options); } diff --git a/src/testRunner/unittests/tsbuild/outputPaths.ts b/src/testRunner/unittests/tsbuild/outputPaths.ts index 9623743ed4de3..261d373df98d9 100644 --- a/src/testRunner/unittests/tsbuild/outputPaths.ts +++ b/src/testRunner/unittests/tsbuild/outputPaths.ts @@ -32,7 +32,7 @@ describe("unittests:: tsbuild - output file paths", () => { assert.deepEqual( ts.getOutputFileNames( - ts.parseConfigFileWithSystem("/src/tsconfig.json", {}, /*extendedConfigCache*/ undefined, {}, sys, ts.noop)!, + ts.parseConfigFileWithSystem("/src/tsconfig.json", {}, /*extendedConfigCache*/ undefined, {}, sys, ts.noop, /*checkAllowPlugins*/ true)!, "/src/src/index.ts", /*ignoreCase*/ false ), diff --git a/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts b/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts index 792a1f9ff4850..80ee8b8f1af22 100644 --- a/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts +++ b/src/testRunner/unittests/tsbuildWatch/watchEnvironment.ts @@ -2,7 +2,12 @@ import * as ts from "../../_namespaces/ts"; import { createBaseline, createSolutionBuilderWithWatchHostForBaseline, + createWatchFactorySystem, + implementRequireForWatchFactorySystem, runWatchBaseline, + VerifyTscWatch, + verifyTscWatch, + WatchFactorySystem, } from "../tscWatch/helpers"; import { createWatchedSystem, @@ -119,4 +124,227 @@ describe("unittests:: tsbuildWatch:: watchEnvironment:: tsbuild:: watchMode:: wi })); } }); + + describe("watchFactory", () => { + verifyWatchFactory({ + subScenario: `watchFactory/in config file`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--allowPlugins"], + sys: createSystemWithFactory, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Invoke plugin watches", + edit: sys => (sys as WatchFactorySystem).factoryData.watchedFiles.get(`/user/username/projects/myproject/b.ts`)!.forEach(({ callback }) => callback(`/user/username/projects/myproject/b.ts`, ts.FileWatcherEventKind.Changed)), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/in config file with error`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--allowPlugins"], + sys: createSystemWithFactory, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin/../malicious"); + + verifyWatchFactoryCommandLine({ + subScenario: `watchFactory/through commandline`, + sys: () => createSystemWithFactory(), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Invoke plugin watches", + edit: sys => (sys as WatchFactorySystem).factoryData.watchedFiles.get(`/user/username/projects/myproject/b.ts`)!.forEach(({ callback }) => callback(`/user/username/projects/myproject/b.ts`, ts.FileWatcherEventKind.Changed)), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactoryCommandLine({ + subScenario: `watchFactory/through commandline with error`, + sys: () => { + // Patch to not throw exception so the tests can run and baseline + const sys = createSystem(); + sys.exit = exitCode => sys.exitCode = exitCode; + return sys; + }, + }, "myplugin/../malicious"); + + verifyWatchFactory({ + subScenario: `watchFactory/when plugin not found`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--allowPlugins"], + sys: watchOptions => { + const system = createSystem(watchOptions); + system.require = (initialPath, moduleName) => { + system.write(`Require:: Resolving ${moduleName} from ${initialPath}\n`); + return { + module: undefined, + error: { message: `Cannot find module myPlugin at ${initialPath}` } + }; + }; + return system; + }, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/when plugin does not implements watchFile`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--allowPlugins"], + sys: watchOptions => createSystemWithFactory(watchOptions, /*compilerOptions*/ undefined, /*excludeWatchFile*/ true), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Add file", + edit: sys => sys.writeFile(`/user/username/projects/myproject/c.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Invoke plugin watches", + edit: sys => (sys as WatchFactorySystem).factoryData.watchedDirectoriesRecursive.get("/user/username/projects/myproject")!.forEach(({ callback }) => callback(`/user/username/projects/myproject/c.ts`)), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/when plugin doesnt return factory function`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--allowPlugins"], + sys: watchOptions => { + const system = createSystem(watchOptions); + system.require = (initialPath, moduleName) => { + system.write(`Require:: Resolving ${moduleName} from ${initialPath}\n`); + return { + module: { watchDirectory: system.factoryData.watchDirectory }, + error: undefined + }; + }; + return system; + }, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/when host does not implement require`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--allowPlugins"], + sys: createSystem, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/without allowPlugins`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics"], + sys: () => createSystemWithFactory({ watchFactory: "myplugin" }), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/allowPlugins is in tsconfig`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics"], + sys: watchOptions => createSystemWithFactory(watchOptions, { allowPlugins: true }), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + function createSystem(watchOptions?: ts.WatchOptions, compilerOptions?: ts.CompilerOptions) { + const configFile: File = { + path: `/user/username/projects/myproject/tsconfig.json`, + content: JSON.stringify({ watchOptions, compilerOptions }) + }; + const aTs: File = { + path: `/user/username/projects/myproject/a.ts`, + content: `export class a { prop = "hello"; foo() { return this.prop; } }` + }; + const bTs: File = { + path: `/user/username/projects/myproject/b.ts`, + content: `export class b { prop = "hello"; foo() { return this.prop; } }` + }; + + return createWatchFactorySystem(createWatchedSystem([aTs, bTs, configFile, libFile], { currentDirectory: "/user/username/projects/myproject" })); + } + + function createSystemWithFactory(watchOptions?: ts.WatchOptions, compilerOptions?: ts.CompilerOptions, excludeWatchFile?: boolean) { + return implementRequireForWatchFactorySystem(createSystem(watchOptions, compilerOptions), !!excludeWatchFile); + } + + function verifyWatchFactory( + input: Omit & { sys: (watchOptions?: ts.WatchOptions) => TestServerHost; }, + watchFactory: string, + ) { + verifyTscWatch({ + scenario: "watchEnvironment", + ...input, + sys: () => input.sys({ watchFactory }), + }); + verifyTscWatch({ + scenario: "watchEnvironment", + ...input, + subScenario: `${input.subScenario} object`, + sys: () => input.sys({ watchFactory: { name: watchFactory, myconfig: "somethingelse" } as ts.PluginImport }), + }); + } + + function verifyWatchFactoryCommandLine( + input: Omit, + watchFactory: string, + ) { + verifyTscWatch({ + scenario: "watchEnvironment", + ...input, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--watchFactory", watchFactory, "--allowPlugins"], + }); + verifyTscWatch({ + scenario: "watchEnvironment", + ...input, + subScenario: `${input.subScenario} object`, + commandLineArgs: ["-b", "-w", "--extendedDiagnostics", "--watchFactory", JSON.stringify({ name: watchFactory, myconfig: "somethingelse" }), "--allowPlugins"], + }); + } + }); }); diff --git a/src/testRunner/unittests/tsc/cancellationToken.ts b/src/testRunner/unittests/tsc/cancellationToken.ts index 04eeb68ebbad0..fdb399e0252bd 100644 --- a/src/testRunner/unittests/tsc/cancellationToken.ts +++ b/src/testRunner/unittests/tsc/cancellationToken.ts @@ -61,10 +61,11 @@ describe("unittests:: tsc:: builder cancellationToken", () => { const parsedConfig = ts.parseConfigFileWithSystem( "tsconfig.json", {}, - /*extendedConfigCache*/ undefined, - /*watchOptionsToExtend*/ undefined, + /*extendedConfigCache*/ undefined, + /*watchOptionsToExtend*/ undefined, sys, - reportDiagnostic + reportDiagnostic, + /*checkAllowPlugins*/ true, )!; const host = ts.createIncrementalCompilerHost(parsedConfig.options, sys); let programs: CommandLineProgram[] = ts.emptyArray; diff --git a/src/testRunner/unittests/tscWatch/helpers.ts b/src/testRunner/unittests/tscWatch/helpers.ts index e864b976277ba..22053ed80c2b3 100644 --- a/src/testRunner/unittests/tscWatch/helpers.ts +++ b/src/testRunner/unittests/tscWatch/helpers.ts @@ -15,6 +15,7 @@ import { File, FileOrFolderOrSymLink, FileOrFolderOrSymLinkMap, + serializeMultiMap, TestServerHost, TestServerHostCreationParameters, TestServerHostTrackingWrittenFiles, @@ -327,3 +328,83 @@ export function solutionBuildWithBaseline(sys: TestServerHost, solutionRoots: re export function createSystemWithSolutionBuild(solutionRoots: readonly string[], files: FileOrFolderOrSymLinkMap | readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters) { return solutionBuildWithBaseline(createWatchedSystem(files, params), solutionRoots); } + +interface WatchedFileCallback { + callback: ts.FileWatcherCallback; + pollingInterval: number | undefined; + options: ts.WatchOptions | undefined; +} +interface WatchedDirectoryCallback { + callback: ts.DirectoryWatcherCallback; + options: ts.WatchOptions | undefined; +} +export type WatchFactorySystem = TscWatchSystem & { + factoryData: { + watchedFiles: ts.MultiMap; + watchedDirectories: ts.MultiMap; + watchedDirectoriesRecursive: ts.MultiMap; + watchFile(path: string, callback: ts.FileWatcherCallback, pollingInterval?: ts.PollingInterval, options?: ts.WatchOptions): ts.FileWatcher; + watchDirectory(path: string, callback: ts.DirectoryWatcherCallback, recursive?: boolean, options?: ts.WatchOptions): ts.FileWatcher; + onConfigurationChanged(config: any): void; + } +}; + +export function createWatchFactorySystem(inputSystem: TestServerHost, log: (s: string) => void = s => inputSystem.write(s + "\n"), pluginName?: string): WatchFactorySystem { + const watchedFiles = ts.createMultiMap(); + const watchedDirectories = ts.createMultiMap(); + const watchedDirectoriesRecursive = ts.createMultiMap(); + let serializedWatchedFiles: Map | undefined; + let serializedWatchedDirectories: Map | undefined; + let serializedWatchedDirectoriesRecursive: Map | undefined; + const system = inputSystem as WatchFactorySystem; + const originalSerializeWatches = system.serializeWatches; + system.serializeWatches = serializeWatches; + system.factoryData = { watchedFiles, watchedDirectories, watchedDirectoriesRecursive, watchFile, watchDirectory, onConfigurationChanged }; + return system; + + function watchFile(path: string, callback: ts.FileWatcherCallback, pollingInterval?: ts.PollingInterval, options?: ts.WatchOptions) { + log(`Custom ${pluginName || ""}watchFile: ${path} ${pollingInterval} ${JSON.stringify(options)}`); + const watchedFileCallback: WatchedFileCallback = { callback, pollingInterval, options }; + watchedFiles.add(path, watchedFileCallback); + system.hasWatchChanges = true; + return { close: () => watchedFiles.remove(path, watchedFileCallback) }; + } + + function watchDirectory(path: string, callback: ts.DirectoryWatcherCallback, recursive?: boolean, options?: ts.WatchOptions) { + log(`Custom ${pluginName || ""}watchDirectory: ${path} ${recursive} ${JSON.stringify(options)}`); + const watchedDirectoryCallback: WatchedDirectoryCallback = { callback, options }; + (recursive ? watchedDirectoriesRecursive : watchedDirectories).add(path, watchedDirectoryCallback); + system.hasWatchChanges = true; + return { close: () => (recursive ? watchedDirectoriesRecursive : watchedDirectories).remove(path, watchedDirectoryCallback) }; + } + + function onConfigurationChanged(config: any) { + log(`Custom:: ${pluginName || ""}onConfigurationChanged:: ${JSON.stringify(config)}`); + } + + function serializeWatches(baseline: string[] = []) { + const hasWatchChanges = system.hasWatchChanges; + originalSerializeWatches.call(system, baseline); + if (!hasWatchChanges) return baseline; + serializedWatchedFiles = serializeMultiMap(baseline, `${pluginName || ""}Plugin WatchedFiles`, watchedFiles, serializedWatchedFiles); + serializedWatchedDirectories = serializeMultiMap(baseline, `${pluginName || ""}Plugin WatchedDirectories:Recursive`, watchedDirectoriesRecursive, serializedWatchedDirectories); + serializedWatchedDirectoriesRecursive = serializeMultiMap(baseline, `${pluginName || ""}Plugin WatchedDirectories`, watchedDirectories, serializedWatchedDirectoriesRecursive); + return baseline; + } +} + +export function implementRequireForWatchFactorySystem(system: WatchFactorySystem, excludeWatchFile: boolean) { + system.require = (initialPath, moduleName) => { + system.write(`Require:: Resolving ${moduleName} from ${initialPath}\n`); + return { + module: (({ options, config }) => { + system.write(`Require:: Module ${moduleName} created with config: ${JSON.stringify(config)} and options: ${JSON.stringify(options)}\n`); + return !excludeWatchFile ? + system.factoryData : + { watchDirectory: system.factoryData.watchDirectory }; + }) as ts.UserWatchFactoryModule, + error: undefined + }; + }; + return system; +} \ No newline at end of file diff --git a/src/testRunner/unittests/tscWatch/incremental.ts b/src/testRunner/unittests/tscWatch/incremental.ts index bc73995f46282..7888a4277ba04 100644 --- a/src/testRunner/unittests/tscWatch/incremental.ts +++ b/src/testRunner/unittests/tscWatch/incremental.ts @@ -154,7 +154,7 @@ describe("unittests:: tsc-watch:: emit file --incremental", () => { it("verify that state is read correctly", () => { const system = createWatchedSystem([libFile, file1, fileModified, config], { currentDirectory: project }); const reportDiagnostic = ts.createDiagnosticReporter(system); - const parsedConfig = ts.parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, reportDiagnostic)!; + const parsedConfig = ts.parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, reportDiagnostic, /*checkAllowPlugins*/ true)!; ts.performIncrementalCompilation({ rootNames: parsedConfig.fileNames, options: parsedConfig.options, @@ -164,7 +164,7 @@ describe("unittests:: tsc-watch:: emit file --incremental", () => { system }); - const command = ts.parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, ts.noop)!; + const command = ts.parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, ts.noop, /*checkAllowPlugins*/ true)!; const builderProgram = ts.createIncrementalProgram({ rootNames: command.fileNames, options: command.options, diff --git a/src/testRunner/unittests/tscWatch/watchEnvironment.ts b/src/testRunner/unittests/tscWatch/watchEnvironment.ts index 3d3506b248355..a8978ab548d5a 100644 --- a/src/testRunner/unittests/tscWatch/watchEnvironment.ts +++ b/src/testRunner/unittests/tscWatch/watchEnvironment.ts @@ -11,8 +11,12 @@ import { import { commonFile1, commonFile2, + createWatchFactorySystem, + implementRequireForWatchFactorySystem, noopChange, + VerifyTscWatch, verifyTscWatch, + WatchFactorySystem, } from "./helpers"; describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different polling/non polling options", () => { @@ -710,4 +714,227 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po } ] }); + + describe("watchFactory", () => { + verifyWatchFactory({ + subScenario: `watchFactory/in config file`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--allowPlugins"], + sys: createSystemWithFactory, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Invoke plugin watches", + edit: sys => (sys as WatchFactorySystem).factoryData.watchedFiles.get(`/user/username/projects/myproject/b.ts`)!.forEach(({ callback }) => callback(`/user/username/projects/myproject/b.ts`, ts.FileWatcherEventKind.Changed)), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/in config file with error`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--allowPlugins"], + sys: createSystemWithFactory, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin/../malicious"); + + verifyWatchFactoryCommandLine({ + subScenario: `watchFactory/through commandline`, + sys: () => createSystemWithFactory(), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Invoke plugin watches", + edit: sys => (sys as WatchFactorySystem).factoryData.watchedFiles.get(`/user/username/projects/myproject/b.ts`)!.forEach(({ callback }) => callback(`/user/username/projects/myproject/b.ts`, ts.FileWatcherEventKind.Changed)), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactoryCommandLine({ + subScenario: `watchFactory/through commandline with error`, + sys: () => { + // Patch to not throw exception so the tests can run and baseline + const sys = createSystem(); + sys.exit = exitCode => sys.exitCode = exitCode; + return sys; + }, + }, "myplugin/../malicious"); + + verifyWatchFactory({ + subScenario: `watchFactory/when plugin not found`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--allowPlugins"], + sys: watchOptions => { + const system = createSystem(watchOptions); + system.require = (initialPath, moduleName) => { + system.write(`Require:: Resolving ${moduleName} from ${initialPath}\n`); + return { + module: undefined, + error: { message: `Cannot find module myPlugin at ${initialPath}` } + }; + }; + return system; + }, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/when plugin does not implements watchFile`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--allowPlugins"], + sys: watchOptions => createSystemWithFactory(watchOptions, /*compilerOptions*/ undefined, /*excludeWatchFile*/ true), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Add file", + edit: sys => sys.writeFile(`/user/username/projects/myproject/c.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "Invoke plugin watches", + edit: sys => (sys as WatchFactorySystem).factoryData.watchedDirectoriesRecursive.get("/user/username/projects/myproject")!.forEach(({ callback }) => callback(`/user/username/projects/myproject/c.ts`)), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/when plugin doesnt return factory function`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--allowPlugins"], + sys: watchOptions => { + const system = createSystem(watchOptions); + system.require = (initialPath, moduleName) => { + system.write(`Require:: Resolving ${moduleName} from ${initialPath}\n`); + return { + module: { watchDirectory: system.factoryData.watchDirectory }, + error: undefined + }; + }; + return system; + }, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/when host does not implement require`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--allowPlugins"], + sys: createSystem, + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/without allowPlugins`, + commandLineArgs: ["-w", "--extendedDiagnostics"], + sys: () => createSystemWithFactory({ watchFactory: "myplugin" }), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + verifyWatchFactory({ + subScenario: `watchFactory/allowPlugins is in tsconfig`, + commandLineArgs: ["-w", "--extendedDiagnostics"], + sys: watchOptions => createSystemWithFactory(watchOptions, { allowPlugins: true }), + edits: [ + { + caption: "Change file", + edit: sys => sys.appendFile(`/user/username/projects/myproject/b.ts`, "export function foo() { }"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ] + }, "myplugin"); + + function createSystem(watchOptions?: ts.WatchOptions, compilerOptions?: ts.CompilerOptions) { + const configFile: File = { + path: `/user/username/projects/myproject/tsconfig.json`, + content: JSON.stringify({ watchOptions, compilerOptions }) + }; + const aTs: File = { + path: `/user/username/projects/myproject/a.ts`, + content: `export class a { prop = "hello"; foo() { return this.prop; } }` + }; + const bTs: File = { + path: `/user/username/projects/myproject/b.ts`, + content: `export class b { prop = "hello"; foo() { return this.prop; } }` + }; + + return createWatchFactorySystem(createWatchedSystem([aTs, bTs, configFile, libFile], { currentDirectory: "/user/username/projects/myproject" })); + } + + function createSystemWithFactory(watchOptions?: ts.WatchOptions, compilerOptions?: ts.CompilerOptions, excludeWatchFile?: boolean) { + return implementRequireForWatchFactorySystem(createSystem(watchOptions, compilerOptions), !!excludeWatchFile); + } + + function verifyWatchFactory( + input: Omit & { sys: (watchOptions?: ts.WatchOptions) => TestServerHost; }, + watchFactory: string, + ) { + verifyTscWatch({ + scenario, + ...input, + sys: () => input.sys({ watchFactory }), + }); + verifyTscWatch({ + scenario, + ...input, + subScenario: `${input.subScenario} object`, + sys: () => input.sys({ watchFactory: { name: watchFactory, myconfig: "somethingelse" } as ts.PluginImport }), + }); + } + + function verifyWatchFactoryCommandLine( + input: Omit, + watchFactory: string, + ) { + verifyTscWatch({ + scenario, + ...input, + commandLineArgs: ["-w", "--extendedDiagnostics", "--watchFactory", watchFactory, "--allowPlugins"], + }); + verifyTscWatch({ + scenario, + ...input, + subScenario: `${input.subScenario} object`, + commandLineArgs: ["-w", "--extendedDiagnostics", "--watchFactory", JSON.stringify({ name: watchFactory, myconfig: "somethingelse" }), "--allowPlugins"], + }); + } + }); }); diff --git a/src/testRunner/unittests/tsserver/watchEnvironment.ts b/src/testRunner/unittests/tsserver/watchEnvironment.ts index ea7e84cf4c54a..81b8c906bd941 100644 --- a/src/testRunner/unittests/tsserver/watchEnvironment.ts +++ b/src/testRunner/unittests/tsserver/watchEnvironment.ts @@ -2,6 +2,8 @@ import * as ts from "../../_namespaces/ts"; import { commonFile1, commonFile2, + createWatchFactorySystem, + WatchFactorySystem, } from "../tscWatch/helpers"; import { createServerHost, @@ -20,6 +22,7 @@ import { protocolFileLocationFromSubstring, setCompilerOptionsForInferredProjectsRequestForSession, TestSession, + TestSessionOptions, toExternalFiles, } from "./helpers"; @@ -495,3 +498,239 @@ describe("unittests:: tsserver:: watchEnvironment:: watchFile is single watcher baselineTsserverLogs("watchEnvironment", "when watchFile is single watcher per file", session); }); }); + +describe("unittests:: tsserver:: watchEnvironment:: watchFactory", () => { + it("plugin overriding watch", () => { + const { host, session, plugin, aTs, bTs, } = createHostForPlugins({ globalPlugins: ["myplugin"] }); + const existingWatchFile = host.watchFile; + const existingWatchDirectory = host.watchDirectory; + host.require = (initialPath, moduleName) => { + session.logger.log(`CustomRequire:: Resolving ${moduleName} from ${initialPath}`); + return { + module: (): ts.server.PluginModule => ({ + create: info => { + info.serverHost.watchFile = plugin.watchFile; + info.serverHost.watchDirectory = plugin.watchDirectory; + return info.languageService; + } + }), + error: undefined + }; + }; + openFilesForSession([aTs], session); + session.logger.log(`Host watchFile expected to be patched. Actual: ${host.watchFile !== existingWatchFile}`); + session.logger.log(`Host watchDirectory expected to be patched. Actual: ${host.watchDirectory !== existingWatchDirectory}`); + + // Change b.ts + session.logger.log("Change file"); + host.writeFile(bTs.path, aTs.content); + // Since we have overriden watch, this shouldnt do anything + host.runQueuedTimeoutCallbacks(); + + // Actually invoke watches + session.logger.log("Invoke plugin watches"); + plugin.watchedFiles.get(bTs.path)!.forEach(({ callback }) => callback(bTs.path, ts.FileWatcherEventKind.Changed)); + // Host should have updates queued + host.runQueuedTimeoutCallbacks(); + + baselineTsserverLogs("watchEnvironment", "plugin overriding watch", session); + }); + + function verifyWatchFactory(pluginOverride: boolean, allowLocalPluginLoads: boolean, useObject: boolean) { + it(scenarioName("watchFactory in config file", pluginOverride, allowLocalPluginLoads, useObject), () => { + const { host, session, plugin, aTs } = createHostForPlugins( + { allowLocalPluginLoads }, + { watchFactory: getWatchFactory("myplugin", useObject) } + ); + host.require = requireReturningWatchFactory(session, plugin); + if (pluginOverride) configurePlugin(session, "myplugin", { init: "initialConfig" }); + openFilesForSession([aTs], session); + + // Add c.ts + session.logger.log("Add a file"); + host.writeFile(`/user/username/projects/myproject/c.ts`, aTs.content); + // Since we have overriden watch, this shouldnt do anything + host.runQueuedTimeoutCallbacks(); + + // Actually invoke watches + session.logger.log("Invoke plugin watches"); + plugin.watchedDirectoriesRecursive.get("/user/username/projects/myproject")!.forEach(({ callback }) => callback(`/user/username/projects/myproject/c.ts`)); + // Host should have updates queued + host.runQueuedTimeoutCallbacks(); + + // Configuration changed + configurePlugin(session, "myplugin"); + configurePlugin(session, "randomplugin"); + + baselineTsserverLogs("watchEnvironment", scenarioName("watchFactory in config file", pluginOverride, allowLocalPluginLoads, useObject), session); + }); + + it(scenarioName("watchFactory as configuration of host", pluginOverride, allowLocalPluginLoads, useObject), () => { + const { host, session, plugin, aTs, bTs, } = createHostForPlugins({ allowLocalPluginLoads }); + host.require = requireReturningWatchFactory(session, plugin); + configureGlobalWatchOptions(session, "myplugin", useObject); + if (pluginOverride) configurePlugin(session, "myplugin", { init: "initialConfig" }); + openFilesForSession([aTs], session); + + // Change b.ts + session.logger.log("Change file"); + host.writeFile(bTs.path, aTs.content); + // Since we have overriden watch, this shouldnt do anything + host.runQueuedTimeoutCallbacks(); + + // Actually invoke watches + session.logger.log("Invoke plugin watches"); + plugin.watchedFiles.get(bTs.path)!.forEach(({ callback }) => callback(bTs.path, ts.FileWatcherEventKind.Changed)); + // Host should have updates queued + host.runQueuedTimeoutCallbacks(); + + // Configuration changed + configurePlugin(session, "myplugin"); + configurePlugin(session, "randomplugin"); + + baselineTsserverLogs("watchEnvironment", scenarioName("watchFactory as configuration of host", pluginOverride, allowLocalPluginLoads, useObject), session); + }); + + it(scenarioName("watchFactory in config as well as configuration of host", pluginOverride, allowLocalPluginLoads, useObject), () => { + const { host, session, plugin, aTs, bTs, } = createHostForPlugins( + { allowLocalPluginLoads }, + { watchFactory: getWatchFactory("myplugin", useObject) } + ); + const plugin2 = createFactoryFunctions(session, "myplugin2"); + host.require = requireReturningWatchFactory(session, plugin, plugin2); + configureGlobalWatchOptions(session, "myplugin2", useObject); + if (pluginOverride) { + configurePlugin(session, "myplugin", { init: "initialConfig" }); + configurePlugin(session, "myplugin2", { init2: "initialConfig2" }); + } + openFilesForSession([aTs], session); + + // Add c.ts + session.logger.log("Add a file"); + host.writeFile(`/user/username/projects/myproject/c.ts`, aTs.content); + // Since we have overriden watch, this shouldnt do anything + host.runQueuedTimeoutCallbacks(); + + // Actually invoke watches + session.logger.log("Invoke plugin watches"); + plugin.watchedDirectoriesRecursive.get("/user/username/projects/myproject")!.forEach(({ callback }) => callback(`/user/username/projects/myproject/c.ts`)); + // Host should have updates queued + host.runQueuedTimeoutCallbacks(); + + // Change b.ts + session.logger.log("Change file"); + host.writeFile(bTs.path, aTs.content); + // Since we have overriden watch, this shouldnt do anything + host.runQueuedTimeoutCallbacks(); + + // Actually invoke watches + session.logger.log("Invoke plugin watches"); + plugin2.watchedFiles.get(bTs.path)!.forEach(({ callback }) => callback(bTs.path, ts.FileWatcherEventKind.Changed)); + // Host should have updates queued + host.runQueuedTimeoutCallbacks(); + + // Configuration changed + configurePlugin(session, "myplugin"); + configurePlugin(session, "myplugin2"); + configurePlugin(session, "randomplugin"); + + baselineTsserverLogs("watchEnvironment", scenarioName("watchFactory in config as well as configuration of host", pluginOverride, allowLocalPluginLoads, useObject), session); + }); + + if (allowLocalPluginLoads || pluginOverride) return; + it(scenarioName("watchFactory as configuration of host with errors", pluginOverride, allowLocalPluginLoads, useObject), () => { + const { host, session, aTs, bTs, } = createHostForPlugins(); + host.require = ts.notImplemented; // Should throw if called + configureGlobalWatchOptions(session, "myplugin/../malicious", useObject); + openFilesForSession([aTs], session); + + // Change b.ts + session.logger.log("Change file"); + host.writeFile(bTs.path, aTs.content); + host.runQueuedTimeoutCallbacks(); + + baselineTsserverLogs("watchEnvironment", scenarioName("watchFactory as configuration of host with errors", pluginOverride, allowLocalPluginLoads, useObject), session); + }); + } + verifyWatchFactory(/*pluginOverride*/ false, /*allowLocalPluginLoads*/ false, /*useObject*/ false); + verifyWatchFactory(/*pluginOverride*/ false, /*allowLocalPluginLoads*/ true, /*useObject*/ false); + verifyWatchFactory(/*pluginOverride*/ false, /*allowLocalPluginLoads*/ false, /*useObject*/ true); + verifyWatchFactory(/*pluginOverride*/ false, /*allowLocalPluginLoads*/ true, /*useObject*/ true); + verifyWatchFactory(/*pluginOverride*/ true, /*allowLocalPluginLoads*/ false, /*useObject*/ false); + verifyWatchFactory(/*pluginOverride*/ true, /*allowLocalPluginLoads*/ true, /*useObject*/ false); + verifyWatchFactory(/*pluginOverride*/ true, /*allowLocalPluginLoads*/ false, /*useObject*/ true); + verifyWatchFactory(/*pluginOverride*/ true, /*allowLocalPluginLoads*/ true, /*useObject*/ true); + + function createHostForPlugins(opts?: Partial, watchOptions?: ts.WatchOptions) { + const configFile: File = { + path: `/user/username/projects/myproject/tsconfig.json`, + content: JSON.stringify({ watchOptions }) + }; + const aTs: File = { + path: `/user/username/projects/myproject/a.ts`, + content: `export class a { prop = "hello"; foo() { return this.prop; } }` + }; + const bTs: File = { + path: `/user/username/projects/myproject/b.ts`, + content: `export class b { prop = "hello"; foo() { return this.prop; } }` + }; + const host = createServerHost([aTs, bTs, configFile, libFile]); + const session = createSession(host, { + ...opts, + logger: createLoggerWithInMemoryLogs(host), + pluginProbeLocations: ["/a/pluginprobe1", "/a/pluginprobe2"], + }); + return { host, session, aTs, bTs, plugin: createFactoryFunctions(session) }; + } + + function createFactoryFunctions(session: TestSession, pluginName?: string) { + return createWatchFactorySystem(session.testhost, s => session.logger.log(s), pluginName).factoryData; + } + + function scenarioName(scenario: string, pluginOverride: boolean, allowLocalPluginLoads: boolean, useObject: boolean) { + return `${scenario}${pluginOverride ? " with pluginOverride" : ""}${allowLocalPluginLoads ? " allowLocalPluginLoads" : ""}${useObject ? " object" : ""}`; + } + + interface PluginImport extends ts.PluginImport { + myconfig: "somethingelse"; + } + function getWatchFactory(watchFactory: string, useObject: boolean): PluginImport | string { + return useObject ? { name: watchFactory, myconfig: "somethingelse" } : watchFactory; + } + + function configureGlobalWatchOptions(session: TestSession, watchFactory: string, useObject: boolean) { + session.executeCommandSeq({ + command: ts.server.protocol.CommandTypes.Configure, + arguments: { watchOptions: { watchFactory: getWatchFactory(watchFactory, useObject) } } + }); + } + + function configurePlugin(session: TestSession, pluginName: string, configuration?: any) { + session.executeCommandSeq({ + command: ts.server.protocol.CommandTypes.ConfigurePlugin, + arguments: { + pluginName, + configuration: configuration || { extraData: "myData" } + } + }); + } + + function requireReturningWatchFactory( + session: TestSession, + plugin: WatchFactorySystem["factoryData"], + plugin2?: WatchFactorySystem["factoryData"], + ): ts.System["require"] { + return (initialPath, moduleName) => { + session.logger.log(`CustomRequire:: Resolving ${moduleName} from ${initialPath}`); + return { + module: (({ options, config }) => { + session.logger.log(`Require:: Module ${moduleName} created with config: ${JSON.stringify(config)} and options: ${JSON.stringify(options)}`); + return !plugin2 || moduleName === "myplugin" ? + plugin : + plugin2; + }) as ts.UserWatchFactoryModule, + error: undefined + }; + }; + } +}); diff --git a/src/testRunner/unittests/virtualFileSystemWithWatch.ts b/src/testRunner/unittests/virtualFileSystemWithWatch.ts index 3873a36051c85..a495a3ec65ebe 100644 --- a/src/testRunner/unittests/virtualFileSystemWithWatch.ts +++ b/src/testRunner/unittests/virtualFileSystemWithWatch.ts @@ -31,13 +31,13 @@ import { isString, mapDefined, matchFiles, + ModuleImportResult, ModuleResolutionHost, MultiMap, noop, patchWriteFileEnsuringDirectory, Path, PollingInterval, - RequireResult, server, SortedArray, sys, @@ -292,7 +292,7 @@ export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost, private readonly environmentVariables?: Map; private readonly executingFilePath: string; private readonly currentDirectory: string; - public require: ((initialPath: string, moduleName: string) => RequireResult) | undefined; + public require: ((initialPath: string, moduleName: string) => ModuleImportResult) | undefined; public storeFilesChangingSignatureDuringEmit = true; watchFile: HostWatchFile; private inodeWatching: boolean | undefined; @@ -342,6 +342,7 @@ export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost, tscWatchDirectory, inodeWatching: !!this.inodeWatching, sysLog: s => this.write(s + this.newLine), + getSystem: () => this, }); this.watchFile = watchFile; this.watchDirectory = watchDirectory; @@ -610,7 +611,7 @@ export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost, this.removeFileOrFolder(currentEntry); } - private hasWatchChanges?: boolean; + hasWatchChanges?: boolean; private createWatcher(map: MultiMap, path: Path, callback: T): FileWatcher { this.hasWatchChanges = true; map.add(path, callback); @@ -1102,7 +1103,7 @@ function diffFsEntry(baseline: string[], oldFsEntry: FSEntry | undefined, newFsE } } -function serializeMultiMap(baseline: string[], caption: string, multiMap: MultiMap, serialized: Map | undefined) { +export function serializeMultiMap(baseline: string[], caption: string, multiMap: MultiMap, serialized: Map | undefined) { let hasChange = diffMap(baseline, caption, multiMap, serialized, /*deleted*/ false); hasChange = diffMap(baseline, caption, serialized, multiMap, /*deleted*/ true) || hasChange; if (hasChange) { diff --git a/src/tsserver/nodeServer.ts b/src/tsserver/nodeServer.ts index ce3a0c2d682ab..1154b4d5ec0d0 100644 --- a/src/tsserver/nodeServer.ts +++ b/src/tsserver/nodeServer.ts @@ -20,7 +20,6 @@ import { normalizePath, normalizeSlashes, perfLogger, - resolveJSModule, SortedReadonlyArray, startTracing, stripQuotes, @@ -57,7 +56,6 @@ import { ITypingsInstaller, Logger, LogLevel, - ModuleImportResult, Msg, nowString, nullCancellationToken, @@ -381,15 +379,6 @@ export function initializeNodeSystem(): StartInput { sys.gc = () => global.gc?.(); } - sys.require = (initialDir: string, moduleName: string): ModuleImportResult => { - try { - return { module: require(resolveJSModule(moduleName, initialDir, sys)), error: undefined }; - } - catch (error) { - return { module: undefined, error }; - } - }; - let cancellationToken: ServerCancellationToken; try { const factory = require("./cancellationToken"); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 4bf70d659b1ff..864fd0ad78316 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1236,6 +1236,7 @@ declare namespace ts { synchronousWatchDirectory?: boolean; excludeDirectories?: string[]; excludeFiles?: string[]; + watchFactory?: string | PluginImport; [option: string]: CompilerOptionsValue | undefined; } /** @@ -3241,7 +3242,7 @@ declare namespace ts { private readonly cancellationToken; isNonTsProject(): boolean; isJsOnlyProject(): boolean; - static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): {} | undefined; + static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined; isKnownTypesPackageName(name: string): boolean; installPackage(options: InstallPackageOptions): Promise; private get typingsCache(); @@ -3328,8 +3329,8 @@ declare namespace ts { setTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined): void; getTypeAcquisition(): ts.TypeAcquisition; protected removeRoot(info: ScriptInfo): void; - protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined): void; - protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): void; + protected enableGlobalPlugins(options: CompilerOptions): void; + protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void; private enableProxy; /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ refreshDiagnostics(): void; @@ -3403,6 +3404,7 @@ declare namespace ts { excludedFiles: readonly NormalizedPath[]; updateGraph(): boolean; getExcludedFiles(): readonly ts.server.NormalizedPath[]; + close(): void; } function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; @@ -3631,7 +3633,6 @@ declare namespace ts { readonly globalPlugins: readonly string[]; readonly pluginProbeLocations: readonly string[]; readonly allowLocalPluginLoads: boolean; - private currentPluginConfigOverrides; readonly typesMapLocation: string | undefined; readonly serverMode: LanguageServiceMode; /** Tracks projects that we have already sent telemetry for. */ @@ -7119,7 +7120,7 @@ declare namespace ts { DynamicPriority = 2, FixedChunkSize = 3 } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport | PluginImport[] | ProjectReference[] | null | undefined; interface CompilerOptions { allowImportingTsExtensions?: boolean; allowJs?: boolean; @@ -7226,6 +7227,20 @@ declare namespace ts { useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } + interface TypeScriptSubsetForWatchFactory { + sys: System; + FileWatcherEventKind: typeof FileWatcherEventKind; + } + type UserWatchFactoryModule = (mod: { + typescript: TypeScriptSubsetForWatchFactory; + options: WatchOptions; + config: any; + }) => UserWatchFactory; + interface UserWatchFactory { + watchFile?(fileName: string, callback: FileWatcherCallback, pollingInterval: number, options: WatchOptions | undefined): FileWatcher; + watchDirectory?(fileName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher; + onConfigurationChanged?(config: any): void; + } interface WatchOptions { watchFile?: WatchFileKind; watchDirectory?: WatchDirectoryKind; @@ -7233,7 +7248,8 @@ declare namespace ts { synchronousWatchDirectory?: boolean; excludeDirectories?: string[]; excludeFiles?: string[]; - [option: string]: CompilerOptionsValue | undefined; + watchFactory?: string | PluginImport; + [option: string]: CompilerOptionsValue | Function | undefined; } interface TypeAcquisition { enable?: boolean; @@ -9125,7 +9141,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[], checkAllowPlugins?: boolean): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -9167,7 +9183,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions, checkAllowPlugins?: boolean): ParsedCommandLine; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6acc0c5bc906e..4167b0e63c089 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3107,7 +3107,7 @@ declare namespace ts { DynamicPriority = 2, FixedChunkSize = 3 } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport | PluginImport[] | ProjectReference[] | null | undefined; interface CompilerOptions { allowImportingTsExtensions?: boolean; allowJs?: boolean; @@ -3214,6 +3214,20 @@ declare namespace ts { useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } + interface TypeScriptSubsetForWatchFactory { + sys: System; + FileWatcherEventKind: typeof FileWatcherEventKind; + } + type UserWatchFactoryModule = (mod: { + typescript: TypeScriptSubsetForWatchFactory; + options: WatchOptions; + config: any; + }) => UserWatchFactory; + interface UserWatchFactory { + watchFile?(fileName: string, callback: FileWatcherCallback, pollingInterval: number, options: WatchOptions | undefined): FileWatcher; + watchDirectory?(fileName: string, callback: DirectoryWatcherCallback, recursive: boolean, options: WatchOptions | undefined): FileWatcher; + onConfigurationChanged?(config: any): void; + } interface WatchOptions { watchFile?: WatchFileKind; watchDirectory?: WatchDirectoryKind; @@ -3221,7 +3235,8 @@ declare namespace ts { synchronousWatchDirectory?: boolean; excludeDirectories?: string[]; excludeFiles?: string[]; - [option: string]: CompilerOptionsValue | undefined; + watchFactory?: string | PluginImport; + [option: string]: CompilerOptionsValue | Function | undefined; } interface TypeAcquisition { enable?: boolean; @@ -5113,7 +5128,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[], checkAllowPlugins?: boolean): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -5155,7 +5170,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions, checkAllowPlugins?: boolean): ParsedCommandLine; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory name.js b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory name.js new file mode 100644 index 0000000000000..baf455141ed21 --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory name.js @@ -0,0 +1,9 @@ +--watchFactory {"name":"somefactory/../malicious"} +buildOptions:: +{} +WatchOptions:: +{} +Projects:: +. +Errors:: +error TS5109: 'watchFactory' name can only be a package name. diff --git a/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory object.js b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory object.js new file mode 100644 index 0000000000000..e2c185a51913f --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory object.js @@ -0,0 +1,9 @@ +--watchFactory {"name":"myplugin" +buildOptions:: +{} +WatchOptions:: +{} +Projects:: +. +Errors:: +error TS6046: Argument for 'watchFactory' option must be: string | object. diff --git a/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory.js b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory.js new file mode 100644 index 0000000000000..5204dec29797d --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/errors on invalid watchFactory.js @@ -0,0 +1,9 @@ +--watchFactory somefactory/../malicious +buildOptions:: +{} +WatchOptions:: +{} +Projects:: +. +Errors:: +error TS5109: 'watchFactory' name can only be a package name. diff --git a/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/parse --watchFactory object.js b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/parse --watchFactory object.js new file mode 100644 index 0000000000000..97e664854a992 --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/parse --watchFactory object.js @@ -0,0 +1,13 @@ +--watchFactory {"name":"somefactory","myconfig":"somethingelse"} +buildOptions:: +{} +WatchOptions:: +{ + "watchFactory": { + "name": "somefactory", + "myconfig": "somethingelse" + } +} +Projects:: +. +Errors:: diff --git a/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/parse --watchFactory.js b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/parse --watchFactory.js new file mode 100644 index 0000000000000..e347456bb182b --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseBuildOptions/parse --watchFactory.js @@ -0,0 +1,10 @@ +--watchFactory somefactory +buildOptions:: +{} +WatchOptions:: +{ + "watchFactory": "somefactory" +} +Projects:: +. +Errors:: diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory name.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory name.js new file mode 100644 index 0000000000000..211bb43079c26 --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory name.js @@ -0,0 +1,9 @@ +--watchFactory {"name":"somefactory/../malicious"} 0.ts +CompilerOptions:: +{} +WatchOptions:: +{} +FileNames:: +0.ts +Errors:: +error TS5109: 'watchFactory' name can only be a package name. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory object.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory object.js new file mode 100644 index 0000000000000..8ae1826e41414 --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory object.js @@ -0,0 +1,9 @@ +--watchFactory {"name":"myplugin" 0.ts +CompilerOptions:: +{} +WatchOptions:: +{} +FileNames:: +0.ts +Errors:: +error TS6046: Argument for 'watchFactory' option must be: string | object. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory.js new file mode 100644 index 0000000000000..b8fb8bc4e0be5 --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/errors on invalid watchFactory.js @@ -0,0 +1,9 @@ +--watchFactory somefactory/../malicious 0.ts +CompilerOptions:: +{} +WatchOptions:: +{} +FileNames:: +0.ts +Errors:: +error TS5109: 'watchFactory' name can only be a package name. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/parse --watchFactory object.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/parse --watchFactory object.js new file mode 100644 index 0000000000000..c6e8e235efcdc --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/parse --watchFactory object.js @@ -0,0 +1,13 @@ +--watchFactory {"name":"somefactory","myconfig":"somethingelse"} 0.ts +CompilerOptions:: +{} +WatchOptions:: +{ + "watchFactory": { + "name": "somefactory", + "myconfig": "somethingelse" + } +} +FileNames:: +0.ts +Errors:: diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/parse --watchFactory.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/parse --watchFactory.js new file mode 100644 index 0000000000000..e71412f5e45a7 --- /dev/null +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/parse --watchFactory.js @@ -0,0 +1,10 @@ +--watchFactory somefactory 0.ts +CompilerOptions:: +{} +WatchOptions:: +{ + "watchFactory": "somefactory" +} +FileNames:: +0.ts +Errors:: diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowPlugins/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowPlugins/tsconfig.json new file mode 100644 index 0000000000000..6e51943502d7d --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowPlugins/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "allowPlugins": true + } +} diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/watchFactory/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/watchFactory/tsconfig.json new file mode 100644 index 0000000000000..684a17d81ab60 --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/watchFactory/tsconfig.json @@ -0,0 +1,4 @@ +{ + "compilerOptions": {}, + "watchOptions": {} +} diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/watchFactoryWithStringValue/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/watchFactoryWithStringValue/tsconfig.json new file mode 100644 index 0000000000000..ef316c37ec59c --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/watchFactoryWithStringValue/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": {}, + "watchOptions": { + "watchFactory": "someString" + } +} diff --git a/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with json api.js b/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with json api.js index 10368b04e7c7f..fb2a1021c2fa0 100644 --- a/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with json api.js +++ b/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with json api.js @@ -171,3 +171,89 @@ Result: WatchOptions:: Errors:: error TS5065: File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '**/../*'. + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": "somefactory" + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{ + "watchFactory": "somefactory" +} +Errors:: + + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": "somefactory/../malicious" + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{} +Errors:: +error TS5109: 'watchFactory' name can only be a package name. + + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": { + "name": "somefactory", + "myconfig": "somethingelse" + } + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{ + "watchFactory": { + "name": "somefactory", + "myconfig": "somethingelse" + } +} +Errors:: + + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": { + "name": "somefactory/../malicious" + } + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{} +Errors:: +error TS5109: 'watchFactory' name can only be a package name. + diff --git a/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with jsonSourceFile api.js b/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with jsonSourceFile api.js index 7748786348fe6..99a0cb9e5d076 100644 --- a/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/tsconfigParsingWatchOptions/different options with jsonSourceFile api.js @@ -177,3 +177,95 @@ Errors:: 4 "**/../*"    ~~~~~~~~~ + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": "somefactory" + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{ + "watchFactory": "somefactory" +} +Errors:: + + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": "somefactory/../malicious" + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{} +Errors:: +tsconfig.json:3:19 - error TS5109: 'watchFactory' name can only be a package name. + +3 "watchFactory": "somefactory/../malicious" +   ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": { + "name": "somefactory", + "myconfig": "somethingelse" + } + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{ + "watchFactory": { + "name": "somefactory", + "myconfig": "somethingelse" + } +} +Errors:: + + +Fs:: +//// [/a.ts] + + +//// [/tsconfig.json] +{ + "watchOptions": { + "watchFactory": { + "name": "somefactory/../malicious" + } + } +} + + +configFileName:: tsconfig.json +Result: WatchOptions:: +{} +Errors:: +tsconfig.json:4:12 - error TS5109: 'watchFactory' name can only be a package name. + +4 "name": "somefactory/../malicious" +   ~~~~~~~~~~~~~~~~~~~~~~~~~~ + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig-object.js new file mode 100644 index 0000000000000..abadd6496be9f --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig-object.js @@ -0,0 +1,118 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +tsconfig.json:1:100 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +tsconfig.json:1:34 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~ + +[12:00:24 AM] Found 2 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file /user/username/projects/myproject/tsconfig.json +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +[12:00:27 AM] File change detected. Starting incremental compilation... + +tsconfig.json:1:100 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +tsconfig.json:1:34 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~ + +[12:00:28 AM] Found 2 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig.js new file mode 100644 index 0000000000000..7cbb8a22c1aa2 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig.js @@ -0,0 +1,118 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +tsconfig.json:1:64 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +[12:00:24 AM] Found 2 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file /user/username/projects/myproject/tsconfig.json +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +[12:00:27 AM] File change detected. Starting incremental compilation... + +tsconfig.json:1:64 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 2 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-object.js new file mode 100644 index 0000000000000..c6cffd0505c8e --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-object.js @@ -0,0 +1,170 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-with-error-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-with-error-object.js new file mode 100644 index 0000000000000..a8e94ccfedbcb --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-with-error-object.js @@ -0,0 +1,108 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +tsconfig.json:1:41 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:24 AM] Found 1 error. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file /user/username/projects/myproject/tsconfig.json +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +[12:00:27 AM] File change detected. Starting incremental compilation... + +tsconfig.json:1:41 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-with-error.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-with-error.js new file mode 100644 index 0000000000000..51f9c8e85f3a4 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file-with-error.js @@ -0,0 +1,108 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin/../malicious"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +tsconfig.json:1:33 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":"myplugin/../malicious"}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:24 AM] Found 1 error. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file /user/username/projects/myproject/tsconfig.json +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +[12:00:27 AM] File change detected. Starting incremental compilation... + +tsconfig.json:1:33 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":"myplugin/../malicious"}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file.js new file mode 100644 index 0000000000000..7581ad5133b43 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/in-config-file.js @@ -0,0 +1,170 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-object.js new file mode 100644 index 0000000000000..0061f33fe3c51 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-object.js @@ -0,0 +1,170 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory {"name":"myplugin","myconfig":"somethingelse"} --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-with-error-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-with-error-object.js new file mode 100644 index 0000000000000..b001646297e2f --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-with-error-object.js @@ -0,0 +1,33 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory {"name":"myplugin/../malicious","myconfig":"somethingelse"} --allowPlugins +Output:: +error TS5109: 'watchFactory' name can only be a package name. + + + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-with-error.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-with-error.js new file mode 100644 index 0000000000000..27736fbbd7da0 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline-with-error.js @@ -0,0 +1,33 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory myplugin/../malicious --allowPlugins +Output:: +error TS5109: 'watchFactory' name can only be a package name. + + + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline.js new file mode 100644 index 0000000000000..a657d8ee58464 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/through-commandline.js @@ -0,0 +1,170 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory myplugin --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require-object.js new file mode 100644 index 0000000000000..6a3a05031bb50 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require-object.js @@ -0,0 +1,152 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file /user/username/projects/myproject/tsconfig.json +Custom watchFactory is ignored because of not running in environment that supports 'require'. Watches will defualt to builtin. +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require.js new file mode 100644 index 0000000000000..c23b964949afa --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require.js @@ -0,0 +1,152 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file /user/username/projects/myproject/tsconfig.json +Custom watchFactory is ignored because of not running in environment that supports 'require'. Watches will defualt to builtin. +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile-object.js new file mode 100644 index 0000000000000..c0875bb5a7ee1 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile-object.js @@ -0,0 +1,229 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + + +Change:: Add file + +Input:: +//// [/user/username/projects/myproject/c.ts] +export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +2: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +[12:00:41 AM] File change detected. Starting incremental compilation... + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:46 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts","/user/username/projects/myproject/c.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts +/user/username/projects/myproject/c.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/c.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/c.ts (computed .d.ts) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/a.ts: + {} +/user/username/projects/myproject/b.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] file changed its modified time +//// [/user/username/projects/myproject/c.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile.js new file mode 100644 index 0000000000000..a82db309f4512 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile.js @@ -0,0 +1,229 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + + +Change:: Add file + +Input:: +//// [/user/username/projects/myproject/c.ts] +export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +2: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +[12:00:41 AM] File change detected. Starting incremental compilation... + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:46 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts","/user/username/projects/myproject/c.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts +/user/username/projects/myproject/c.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/c.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/c.ts (computed .d.ts) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/a.ts: + {} +/user/username/projects/myproject/b.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] file changed its modified time +//// [/user/username/projects/myproject/c.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function-object.js new file mode 100644 index 0000000000000..74f57bb66aa87 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function-object.js @@ -0,0 +1,155 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Skipped loading plugin myplugin because it did not expose a proper factory function +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function.js new file mode 100644 index 0000000000000..5dcff669a6366 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function.js @@ -0,0 +1,155 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Skipped loading plugin myplugin because it did not expose a proper factory function +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-not-found-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-not-found-object.js new file mode 100644 index 0000000000000..f0c43c5c263e6 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-not-found-object.js @@ -0,0 +1,156 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Failed to load module 'myplugin' from /a/lib/tsc.js/../../../node_modules: Cannot find module myPlugin at /a/lib/tsc.js/../../../node_modules +Couldn't find myplugin +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-not-found.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-not-found.js new file mode 100644 index 0000000000000..e3f3462695255 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/when-plugin-not-found.js @@ -0,0 +1,156 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +[12:00:29 AM] Found 0 errors. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file /user/username/projects/myproject/tsconfig.json +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Failed to load module 'myplugin' from /a/lib/tsc.js/../../../node_modules: Cannot find module myPlugin at /a/lib/tsc.js/../../../node_modules +Couldn't find myplugin +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file /user/username/projects/myproject/tsconfig.json +[12:00:32 AM] File change detected. Starting incremental compilation... + +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] file changed its modified time +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/without-allowPlugins-object.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/without-allowPlugins-object.js new file mode 100644 index 0000000000000..5dd855ddd5b20 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/without-allowPlugins-object.js @@ -0,0 +1,108 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:24 AM] Found 1 error. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file /user/username/projects/myproject/tsconfig.json +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +[12:00:27 AM] File change detected. Starting incremental compilation... + +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + diff --git a/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/without-allowPlugins.js b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/without-allowPlugins.js new file mode 100644 index 0000000000000..5dd855ddd5b20 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/watchEnvironment/watchFactory/without-allowPlugins.js @@ -0,0 +1,108 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:24 AM] Found 1 error. Watching for file changes. + +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file /user/username/projects/myproject/tsconfig.json +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToBuildInvalidatedProject +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file /user/username/projects/myproject/tsconfig.json +[12:00:27 AM] File change detected. Starting incremental compilation... + +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig-object.js new file mode 100644 index 0000000000000..ce902dce96e2c --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig-object.js @@ -0,0 +1,189 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +tsconfig.json:1:34 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~ + +tsconfig.json:1:100 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 2 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +tsconfig.json:1:34 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~ + +tsconfig.json:1:100 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +[12:00:35 AM] Found 2 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig.js new file mode 100644 index 0000000000000..804232b163ae7 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/allowPlugins-is-in-tsconfig.js @@ -0,0 +1,189 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +tsconfig.json:1:64 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 2 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +tsconfig.json:1:64 - error TS6266: Option 'allowPlugins' can only be specified on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"},"compilerOptions":{"allowPlugins":true}} +   ~~~~~~~~~~~~~~ + +[12:00:35 AM] Found 2 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-object.js new file mode 100644 index 0000000000000..cd7e5eff59e8c --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-object.js @@ -0,0 +1,188 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Custom watchFile: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-with-error-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-with-error-object.js new file mode 100644 index 0000000000000..118552ac68deb --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-with-error-object.js @@ -0,0 +1,179 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +tsconfig.json:1:41 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +tsconfig.json:1:41 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:35 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-with-error.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-with-error.js new file mode 100644 index 0000000000000..0ef4517da3b4a --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file-with-error.js @@ -0,0 +1,179 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin/../malicious"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +tsconfig.json:1:33 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":"myplugin/../malicious"}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +tsconfig.json:1:33 - error TS5109: 'watchFactory' name can only be a package name. + +1 {"watchOptions":{"watchFactory":"myplugin/../malicious"}} +   ~~~~~~~~~~~~~~~~~~~~~~~ + +[12:00:35 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file.js new file mode 100644 index 0000000000000..6eb3c85cd063a --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/in-config-file.js @@ -0,0 +1,188 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} Source file +Custom watchFile: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-object.js new file mode 100644 index 0000000000000..c8a2808a85912 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-object.js @@ -0,0 +1,188 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory {"name":"myplugin","myconfig":"somethingelse"} --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Custom watchFile: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-with-error-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-with-error-object.js new file mode 100644 index 0000000000000..7f546dddc7404 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-with-error-object.js @@ -0,0 +1,32 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory {"name":"myplugin/../malicious","myconfig":"somethingelse"} --allowPlugins +Output:: +error TS5109: 'watchFactory' name can only be a package name. + + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-with-error.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-with-error.js new file mode 100644 index 0000000000000..d0af41748424a --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline-with-error.js @@ -0,0 +1,32 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory myplugin/../malicious --allowPlugins +Output:: +error TS5109: 'watchFactory' name can only be a package name. + + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline.js new file mode 100644 index 0000000000000..962863958da89 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/through-commandline.js @@ -0,0 +1,188 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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 --watchFactory myplugin --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file +Custom watchFile: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Custom watchFile: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} Source file +Custom watchFile: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/a.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":250,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require-object.js new file mode 100644 index 0000000000000..6f35cfe8b6e8f --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require-object.js @@ -0,0 +1,170 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file +Custom watchFactory is ignored because of not running in environment that supports 'require'. Watches will defualt to builtin. +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require.js new file mode 100644 index 0000000000000..f5eab72f79521 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-host-does-not-implement-require.js @@ -0,0 +1,170 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file +Custom watchFactory is ignored because of not running in environment that supports 'require'. Watches will defualt to builtin. +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile-object.js new file mode 100644 index 0000000000000..2bdc3dd66b3e0 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile-object.js @@ -0,0 +1,254 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + + +Change:: Add file + +Input:: +//// [/user/username/projects/myproject/c.ts] +export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +2: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Scheduling update +Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Reloading new file names and options +Synchronizing program +[12:00:38 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts","/user/username/projects/myproject/c.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +[12:00:41 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts","/user/username/projects/myproject/c.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts +/user/username/projects/myproject/c.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/c.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/c.ts (computed .d.ts) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/a.ts: + {} +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/c.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile.js new file mode 100644 index 0000000000000..92303e0bc92bc --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-does-not-implements-watchFile.js @@ -0,0 +1,254 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + + +Change:: Add file + +Input:: +//// [/user/username/projects/myproject/c.ts] +export function foo() { } + + +Before running Timeout callback:: count: 0 +After running Timeout callback:: count: 0 +Output:: + +exitCode:: ExitStatus.undefined + + +Change:: Invoke plugin watches + +Input:: + +Before running Timeout callback:: count: 1 +2: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Scheduling update +Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Reloading new file names and options +Synchronizing program +[12:00:38 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts","/user/username/projects/myproject/c.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 250 {"watchFactory":"myplugin"} Source file +[12:00:41 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts","/user/username/projects/myproject/c.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts +/user/username/projects/myproject/c.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/c.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/c.ts (computed .d.ts) + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/a.ts: + {} +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/c.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = void 0; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function-object.js new file mode 100644 index 0000000000000..f37c2b12aff42 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function-object.js @@ -0,0 +1,173 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Skipped loading plugin myplugin because it did not expose a proper factory function +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function.js new file mode 100644 index 0000000000000..0d975ba18f444 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-doesnt-return-factory-function.js @@ -0,0 +1,173 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Skipped loading plugin myplugin because it did not expose a proper factory function +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-not-found-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-not-found-object.js new file mode 100644 index 0000000000000..786b6f584c390 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-not-found-object.js @@ -0,0 +1,174 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config file +Enabling watchFactory {"name":"myplugin","myconfig":"somethingelse"} from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Failed to load module 'myplugin' from /a/lib/tsc.js/../../../node_modules: Cannot find module myPlugin at /a/lib/tsc.js/../../../node_modules +Couldn't find myplugin +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-not-found.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-not-found.js new file mode 100644 index 0000000000000..553485e3aa33a --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/when-plugin-not-found.js @@ -0,0 +1,174 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 --allowPlugins +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Config file +Enabling watchFactory myplugin from candidate paths: /a/lib/tsc.js/../../.. +Loading myplugin from /a/lib/tsc.js/../../.. (resolved to /a/lib/tsc.js/../../../node_modules) +Require:: Resolving myplugin from /a/lib/tsc.js/../../../node_modules +Failed to load module 'myplugin' from /a/lib/tsc.js/../../../node_modules: Cannot find module myPlugin at /a/lib/tsc.js/../../../node_modules +Couldn't find myplugin +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFactory":"myplugin"} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Type roots +[12:00:28 AM] Found 0 errors. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {"watchFactory":"myplugin"} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:35 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"allowPlugins":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/without-allowPlugins-object.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/without-allowPlugins-object.js new file mode 100644 index 0000000000000..6d993c66f8747 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/without-allowPlugins-object.js @@ -0,0 +1,179 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:35 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/without-allowPlugins.js b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/without-allowPlugins.js new file mode 100644 index 0000000000000..6d993c66f8747 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/watchFactory/without-allowPlugins.js @@ -0,0 +1,179 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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 +Output:: +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {} Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Type roots +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:28 AM] Found 1 error. Watching for file changes. + +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Wild card directory + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) +/user/username/projects/myproject/b.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +var a = /** @class */ (function () { + function a() { + this.prop = "hello"; + } + a.prototype.foo = function () { return this.prop; }; + return a; +}()); +exports.a = a; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; + + + +Change:: Change file + +Input:: +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } }export function foo() { } + + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram +After running Timeout callback:: count: 0 +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 250 {} Source file +Synchronizing program +[12:00:31 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] + options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +tsconfig.json:1:18 - error TS5110: Option 'watchFactory' cannot be specified without passing '--allowPlugins' on command line. + +1 {"watchOptions":{"watchFactory":"myplugin"}} +   ~~~~~~~~~~~~~~ + +[12:00:35 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/b.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/b.ts (computed .d.ts) + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/b.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = exports.b = void 0; +var b = /** @class */ (function () { + function b() { + this.prop = "hello"; + } + b.prototype.foo = function () { return this.prop; }; + return b; +}()); +exports.b = b; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tsserver/watchEnvironment/plugin-overriding-watch.js b/tests/baselines/reference/tsserver/watchEnvironment/plugin-overriding-watch.js new file mode 100644 index 0000000000000..459958c216fc4 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/plugin-overriding-watch.js @@ -0,0 +1,157 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": "open", + "arguments": { + "file": "/user/username/projects/myproject/a.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Loading global plugin myplugin +Info seq [hh:mm:ss:mss] Enabling plugin myplugin from candidate paths: /a/pluginprobe1,/a/pluginprobe2,/a/lib/tsc.js/../../.. +Info seq [hh:mm:ss:mss] Loading myplugin from /a/pluginprobe1 (resolved to /a/pluginprobe1/node_modules) +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Info seq [hh:mm:ss:mss] Plugin validation succeeded +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 undefined +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 undefined +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true undefined +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject/node_modules/@types: *new* + {} + +Host watchFile expected to be patched. Actual: true +Host watchDirectory expected to be patched. Actual: true +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-allowLocalPluginLoads-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-allowLocalPluginLoads-object.js new file mode 100644 index 0000000000000..36e79cb26636b --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-allowLocalPluginLoads-object.js @@ -0,0 +1,219 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-allowLocalPluginLoads.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-allowLocalPluginLoads.js new file mode 100644 index 0000000000000..a4bde0c5107ba --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-allowLocalPluginLoads.js @@ -0,0 +1,217 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": "myplugin" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin"}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-object.js new file mode 100644 index 0000000000000..36e79cb26636b --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-object.js @@ -0,0 +1,219 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-errors-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-errors-object.js new file mode 100644 index 0000000000000..3669b7fe608c9 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-errors-object.js @@ -0,0 +1,168 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": { + "name": "myplugin/../malicious", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {}, it will be take effect for next watches. +Info seq [hh:mm:ss:mss] Watch options supplied had errors: Supplied options: {"watchFactory":{"name":"myplugin/../malicious","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Diagnostics:: error TS5109: 'watchFactory' name can only be a package name. + +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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +Change file +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-errors.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-errors.js new file mode 100644 index 0000000000000..528e0903ebca8 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-errors.js @@ -0,0 +1,165 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": "myplugin/../malicious" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {}, it will be take effect for next watches. +Info seq [hh:mm:ss:mss] Watch options supplied had errors: Supplied options: {"watchFactory":"myplugin/../malicious"} +Info seq [hh:mm:ss:mss] Diagnostics:: error TS5109: 'watchFactory' name can only be a package name. + +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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: *new* + {} +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +Change file +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads-object.js new file mode 100644 index 0000000000000..f24019ab6f786 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads-object.js @@ -0,0 +1,241 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads.js new file mode 100644 index 0000000000000..3126d8ecc3136 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads.js @@ -0,0 +1,239 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": "myplugin" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin"}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-object.js new file mode 100644 index 0000000000000..f24019ab6f786 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride-object.js @@ -0,0 +1,241 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride.js new file mode 100644 index 0000000000000..3126d8ecc3136 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host-with-pluginOverride.js @@ -0,0 +1,239 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": "myplugin" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin"}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host.js new file mode 100644 index 0000000000000..a4bde0c5107ba --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-as-configuration-of-host.js @@ -0,0 +1,217 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{} + +//// [/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": { + "watchFactory": "myplugin" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin"}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + } +} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Custom watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-allowLocalPluginLoads-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-allowLocalPluginLoads-object.js new file mode 100644 index 0000000000000..63f70befccd2b --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-allowLocalPluginLoads-object.js @@ -0,0 +1,333 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": { + "watchFactory": { + "name": "myplugin2", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"name":"myplugin2","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-allowLocalPluginLoads.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-allowLocalPluginLoads.js new file mode 100644 index 0000000000000..a90b8ec9832d8 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-allowLocalPluginLoads.js @@ -0,0 +1,329 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": { + "watchFactory": "myplugin2" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin2"}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"name":"myplugin2"} and options: {"watchFactory":"myplugin2"} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Custom:: myplugin2onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-object.js new file mode 100644 index 0000000000000..326abc365efb6 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-object.js @@ -0,0 +1,332 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": { + "watchFactory": { + "name": "myplugin2", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"name":"myplugin2","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads-object.js new file mode 100644 index 0000000000000..1d647c4f0b8fa --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads-object.js @@ -0,0 +1,377 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": { + "watchFactory": { + "name": "myplugin2", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "init2": "initialConfig2" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"init2":"initialConfig2","name":"myplugin2"} and options: {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 6, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":6,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 7, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":7,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads.js new file mode 100644 index 0000000000000..aa970505adb3f --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-allowLocalPluginLoads.js @@ -0,0 +1,373 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": { + "watchFactory": "myplugin2" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin2"}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "init2": "initialConfig2" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"init2":"initialConfig2","name":"myplugin2"} and options: {"watchFactory":"myplugin2"} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 6, + "type": "request" + } +Custom:: myplugin2onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":6,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 7, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":7,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-object.js new file mode 100644 index 0000000000000..30c56e20e583e --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride-object.js @@ -0,0 +1,376 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": { + "watchFactory": { + "name": "myplugin2", + "myconfig": "somethingelse" + } + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "init2": "initialConfig2" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"init2":"initialConfig2","name":"myplugin2"} and options: {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":{"name":"myplugin2","myconfig":"somethingelse"}} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 6, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":6,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 7, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":7,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride.js new file mode 100644 index 0000000000000..b995c8af7b01b --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host-with-pluginOverride.js @@ -0,0 +1,372 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": { + "watchFactory": "myplugin2" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin2"}, 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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "init2": "initialConfig2" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"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": "/user/username/projects/myproject/a.ts" + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"init2":"initialConfig2","name":"myplugin2"} and options: {"watchFactory":"myplugin2"} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 6, + "type": "request" + } +Custom:: myplugin2onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":6,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 7, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":7,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host.js new file mode 100644 index 0000000000000..183db597ed048 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-as-well-as-configuration-of-host.js @@ -0,0 +1,328 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": { + "watchFactory": "myplugin2" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Host watch options changed to {"watchFactory":"myplugin2"}, 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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin2 from /a/pluginprobe1/node_modules +Require:: Module myplugin2 created with config: {"name":"myplugin2"} and options: {"watchFactory":"myplugin2"} +Custom myplugin2watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin2"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /a/lib/lib.d.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Custom myplugin2watchFile: /user/username/projects/myproject/c.ts 500 {"watchFactory":"myplugin2"} +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +myplugin2Plugin WatchedFiles:: +/user/username/projects/myproject/b.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/a/lib/lib.d.ts: + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} +/user/username/projects/myproject/c.ts: *new* + {"pollingInterval":500,"options":{"watchFactory":"myplugin2"}} + +Change file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/b.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/b.ts 1:: WatchInfo: /user/username/projects/myproject/b.ts 500 {"watchFactory":"myplugin2"} WatchType: Closed Script info +Before running Timeout callback:: count: 2 +3: /user/username/projects/myproject/tsconfig.json +4: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-2 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin2", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Custom:: myplugin2onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 5, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":5,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-allowLocalPluginLoads-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-allowLocalPluginLoads-object.js new file mode 100644 index 0000000000000..0a009348244fe --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-allowLocalPluginLoads-object.js @@ -0,0 +1,233 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": "open", + "arguments": { + "file": "/user/username/projects/myproject/a.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-allowLocalPluginLoads.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-allowLocalPluginLoads.js new file mode 100644 index 0000000000000..501aaa8b52f41 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-allowLocalPluginLoads.js @@ -0,0 +1,231 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": "open", + "arguments": { + "file": "/user/username/projects/myproject/a.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 2, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-object.js new file mode 100644 index 0000000000000..db7c25155b215 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-object.js @@ -0,0 +1,232 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": "open", + "arguments": { + "file": "/user/username/projects/myproject/a.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin","myconfig":"somethingelse"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-allowLocalPluginLoads-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-allowLocalPluginLoads-object.js new file mode 100644 index 0000000000000..4cfb466240d87 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-allowLocalPluginLoads-object.js @@ -0,0 +1,255 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-allowLocalPluginLoads.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-allowLocalPluginLoads.js new file mode 100644 index 0000000000000..ddf990f11eef3 --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-allowLocalPluginLoads.js @@ -0,0 +1,253 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Local plugin loading enabled; adding /user/username/projects/myproject to search paths +CustomRequire:: Resolving myplugin from /user/username/projects/myproject/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-object.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-object.js new file mode 100644 index 0000000000000..3d5535d9371cb --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride-object.js @@ -0,0 +1,254 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +//// [/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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": { + "name": "myplugin", + "myconfig": "somethingelse" + } + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":{"name":"myplugin","myconfig":"somethingelse"}}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride.js new file mode 100644 index 0000000000000..cd5ebd315564a --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file-with-pluginOverride.js @@ -0,0 +1,252 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "init": "initialConfig" + } + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","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": "/user/username/projects/myproject/a.ts" + }, + "seq": 2, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"init":"initialConfig","name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 4, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":4,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request diff --git a/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file.js b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file.js new file mode 100644 index 0000000000000..d2a06c7a9040b --- /dev/null +++ b/tests/baselines/reference/tsserver/watchEnvironment/watchFactory-in-config-file.js @@ -0,0 +1,230 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Info seq [hh:mm:ss:mss] Provided types map file "/a/lib/typesMap.json" doesn't exist +Before request +//// [/user/username/projects/myproject/a.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/b.ts] +export class b { prop = "hello"; foo() { return this.prop; } } + +//// [/user/username/projects/myproject/tsconfig.json] +{"watchOptions":{"watchFactory":"myplugin"}} + +//// [/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": "open", + "arguments": { + "file": "/user/username/projects/myproject/a.ts" + }, + "seq": 1, + "type": "request" + } +Info seq [hh:mm:ss:mss] Search path: /user/username/projects/myproject +Info seq [hh:mm:ss:mss] For info: /user/username/projects/myproject/a.ts :: Config file name: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Creating configuration project /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json : { + "rootNames": [ + "/user/username/projects/myproject/a.ts", + "/user/username/projects/myproject/b.ts" + ], + "options": { + "configFilePath": "/user/username/projects/myproject/tsconfig.json" + }, + "watchOptions": { + "watchFactory": "myplugin" + } +} +Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Config file +CustomRequire:: Resolving myplugin from /a/pluginprobe1/node_modules +Require:: Module myplugin created with config: {"name":"myplugin"} and options: {"watchFactory":"myplugin"} +Custom watchFile: /user/username/projects/myproject/tsconfig.json 2000 {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Custom watchDirectory: /user/username/projects/myproject true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Custom watchDirectory: /user/username/projects/myproject/node_modules/@types true {"watchFactory":"myplugin"} +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFactory":"myplugin"} Project: /user/username/projects/myproject/tsconfig.json WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (3) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +FsWatches:: +/user/username/projects/myproject/b.ts: *new* + {} +/a/lib/lib.d.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: *new* + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: *new* + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: *new* + {"options":{"watchFactory":"myplugin"}} + +Add a file +Before running Timeout callback:: count: 0 +//// [/user/username/projects/myproject/c.ts] +export class a { prop = "hello"; foo() { return this.prop; } } + + +After running Timeout callback:: count: 0 + +Invoke plugin watches +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Scheduled: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/c.ts :: WatchInfo: /user/username/projects/myproject 1 {"watchFactory":"myplugin"} Config: /user/username/projects/myproject/tsconfig.json WatchType: Wild card directory +Before running Timeout callback:: count: 2 +1: /user/username/projects/myproject/tsconfig.json +2: *ensureProjectForOpenFiles* + +Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/c.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + /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; }" + /user/username/projects/myproject/a.ts SVC-1-0 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/b.ts Text-1 "export class b { prop = \"hello\"; foo() { return this.prop; } }" + /user/username/projects/myproject/c.ts Text-1 "export class a { prop = \"hello\"; foo() { return this.prop; } }" + + + ../../../../a/lib/lib.d.ts + Default library for target 'es5' + a.ts + Matched by default include pattern '**/*' + b.ts + Matched by default include pattern '**/*' + c.ts + Matched by default include pattern '**/*' + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles* +Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +Info seq [hh:mm:ss:mss] After ensureProjectForOpenFiles: +Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /user/username/projects/myproject/a.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /user/username/projects/myproject/tsconfig.json +After running Timeout callback:: count: 0 + +FsWatches:: +/user/username/projects/myproject/b.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/c.ts: *new* + {} + +Plugin WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":2000,"options":{"watchFactory":"myplugin"}} + +Plugin WatchedDirectories:Recursive:: +/user/username/projects/myproject: + {"options":{"watchFactory":"myplugin"}} +/user/username/projects/myproject/node_modules/@types: + {"options":{"watchFactory":"myplugin"}} + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "myplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 2, + "type": "request" + } +Custom:: onConfigurationChanged:: {"extraData":"myData"} +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":2,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request + +Before request + +Info seq [hh:mm:ss:mss] request: + { + "command": "configurePlugin", + "arguments": { + "pluginName": "randomplugin", + "configuration": { + "extraData": "myData" + } + }, + "seq": 3, + "type": "request" + } +Info seq [hh:mm:ss:mss] response: + {"seq":0,"type":"response","command":"configurePlugin","request_seq":3,"success":true,"performanceData":{"updateGraphDurationMs":*}} +Info seq [hh:mm:ss:mss] response: + { + "responseRequired": false + } +After request