typescript 5.1.0-dev.20230425 → 5.1.0-dev.20230427

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,8 +22,9 @@ declare namespace ts {
22
22
  type EventBeginInstallTypes = "event::beginInstallTypes";
23
23
  type EventEndInstallTypes = "event::endInstallTypes";
24
24
  type EventInitializationFailed = "event::initializationFailed";
25
+ type ActionWatchTypingLocations = "action::watchTypingLocations";
25
26
  interface TypingInstallerResponse {
26
- readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
27
+ readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed | ActionWatchTypingLocations;
27
28
  }
28
29
  interface TypingInstallerRequestWithProjectName {
29
30
  readonly projectName: string;
@@ -32,7 +33,6 @@ declare namespace ts {
32
33
  readonly fileNames: string[];
33
34
  readonly projectRootPath: Path;
34
35
  readonly compilerOptions: CompilerOptions;
35
- readonly watchOptions?: WatchOptions;
36
36
  readonly typeAcquisition: TypeAcquisition;
37
37
  readonly unresolvedImports: SortedReadonlyArray<string>;
38
38
  readonly cachePath?: string;
@@ -84,8 +84,6 @@ declare namespace ts {
84
84
  writeFile(path: string, content: string): void;
85
85
  createDirectory(path: string): void;
86
86
  getCurrentDirectory?(): string;
87
- watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
88
- watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
89
87
  }
90
88
  interface SetTypings extends ProjectResponse {
91
89
  readonly typeAcquisition: TypeAcquisition;
@@ -94,6 +92,11 @@ declare namespace ts {
94
92
  readonly unresolvedImports: SortedReadonlyArray<string>;
95
93
  readonly kind: ActionSet;
96
94
  }
95
+ interface WatchTypingLocations extends ProjectResponse {
96
+ /** if files is undefined, retain same set of watchers */
97
+ readonly files: readonly string[] | undefined;
98
+ readonly kind: ActionWatchTypingLocations;
99
+ }
97
100
  namespace protocol {
98
101
  enum CommandTypes {
99
102
  JsxClosingTag = "jsxClosingTag",
@@ -3044,8 +3047,6 @@ declare namespace ts {
3044
3047
  private readonly knownCachesSet;
3045
3048
  private readonly projectWatchers;
3046
3049
  private safeList;
3047
- private readonly toCanonicalFileName;
3048
- private readonly globalCachePackageJsonPath;
3049
3050
  private installRunCount;
3050
3051
  private inFlightRequestCount;
3051
3052
  abstract readonly typesRegistry: Map<string, MapLike<string>>;
@@ -3064,7 +3065,7 @@ declare namespace ts {
3064
3065
  private installTypingsAsync;
3065
3066
  private executeWithThrottling;
3066
3067
  protected abstract installWorker(requestId: number, packageNames: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
3067
- protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes): void;
3068
+ protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | WatchTypingLocations): void;
3068
3069
  protected readonly latestDistTag = "latest";
3069
3070
  }
3070
3071
  }
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230425`;
38
+ version = `${versionMajorMinor}.0-dev.20230427`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4737,10 +4737,10 @@ ${lanes.join("\n")}
4737
4737
  LanguageVariant4[LanguageVariant4["JSX"] = 1] = "JSX";
4738
4738
  return LanguageVariant4;
4739
4739
  })(LanguageVariant || {});
4740
- WatchDirectoryFlags = /* @__PURE__ */ ((WatchDirectoryFlags4) => {
4741
- WatchDirectoryFlags4[WatchDirectoryFlags4["None"] = 0] = "None";
4742
- WatchDirectoryFlags4[WatchDirectoryFlags4["Recursive"] = 1] = "Recursive";
4743
- return WatchDirectoryFlags4;
4740
+ WatchDirectoryFlags = /* @__PURE__ */ ((WatchDirectoryFlags3) => {
4741
+ WatchDirectoryFlags3[WatchDirectoryFlags3["None"] = 0] = "None";
4742
+ WatchDirectoryFlags3[WatchDirectoryFlags3["Recursive"] = 1] = "Recursive";
4743
+ return WatchDirectoryFlags3;
4744
4744
  })(WatchDirectoryFlags || {});
4745
4745
  CharacterCodes = /* @__PURE__ */ ((CharacterCodes2) => {
4746
4746
  CharacterCodes2[CharacterCodes2["nullCharacter"] = 0] = "nullCharacter";
@@ -51715,7 +51715,7 @@ ${lanes.join("\n")}
51715
51715
  if (symbol.flags & 524288 /* TypeAlias */) {
51716
51716
  serializeTypeAlias(symbol, symbolName2, modifierFlags);
51717
51717
  }
51718
- if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && symbol.escapedName !== "export=" /* ExportEquals */ && !(symbol.flags & 4194304 /* Prototype */) && !(symbol.flags & 32 /* Class */) && !(symbol.flags & 8192 /* Method */) && !isConstMergedWithNSPrintableAsSignatureMerge) {
51718
+ if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */ | 98304 /* Accessor */) && symbol.escapedName !== "export=" /* ExportEquals */ && !(symbol.flags & 4194304 /* Prototype */) && !(symbol.flags & 32 /* Class */) && !(symbol.flags & 8192 /* Method */) && !isConstMergedWithNSPrintableAsSignatureMerge) {
51719
51719
  if (propertyAsAlias) {
51720
51720
  const createdExport = serializeMaybeAliasAssignment(symbol);
51721
51721
  if (createdExport) {
@@ -56982,16 +56982,16 @@ ${lanes.join("\n")}
56982
56982
  if (declaration.kind === 175 /* Constructor */) {
56983
56983
  return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
56984
56984
  }
56985
+ const typeNode = getEffectiveReturnTypeNode(declaration);
56985
56986
  if (isJSDocSignature(declaration)) {
56986
56987
  const root = getJSDocRoot(declaration);
56987
- if (root && isConstructorDeclaration(root.parent)) {
56988
+ if (root && isConstructorDeclaration(root.parent) && !typeNode) {
56988
56989
  return getDeclaredTypeOfClassOrInterface(getMergedSymbol(root.parent.parent.symbol));
56989
56990
  }
56990
56991
  }
56991
56992
  if (isJSDocConstructSignature(declaration)) {
56992
56993
  return getTypeFromTypeNode(declaration.parameters[0].type);
56993
56994
  }
56994
- const typeNode = getEffectiveReturnTypeNode(declaration);
56995
56995
  if (typeNode) {
56996
56996
  return getTypeFromTypeNode(typeNode);
56997
56997
  }
@@ -69418,6 +69418,7 @@ ${lanes.join("\n")}
69418
69418
  );
69419
69419
  }
69420
69420
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
69421
+ const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
69421
69422
  return discriminateTypeByDiscriminableItems(
69422
69423
  contextualType,
69423
69424
  concatenate(
@@ -69428,7 +69429,14 @@ ${lanes.join("\n")}
69428
69429
  map(
69429
69430
  filter(getPropertiesOfType(contextualType), (s) => {
69430
69431
  var _a;
69431
- return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
69432
+ if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
69433
+ return false;
69434
+ }
69435
+ const element = node.parent.parent;
69436
+ if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
69437
+ return false;
69438
+ }
69439
+ return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
69432
69440
  }),
69433
69441
  (s) => [() => undefinedType, s.escapedName]
69434
69442
  )
@@ -106319,6 +106327,8 @@ ${lanes.join("\n")}
106319
106327
  return visitLabeledStatement(node);
106320
106328
  case 253 /* WithStatement */:
106321
106329
  return visitWithStatement(node);
106330
+ case 244 /* IfStatement */:
106331
+ return visitIfStatement(node);
106322
106332
  case 254 /* SwitchStatement */:
106323
106333
  return visitSwitchStatement(node);
106324
106334
  case 268 /* CaseBlock */:
@@ -106424,6 +106434,14 @@ ${lanes.join("\n")}
106424
106434
  Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory2.liftToBlock))
106425
106435
  );
106426
106436
  }
106437
+ function visitIfStatement(node) {
106438
+ return factory2.updateIfStatement(
106439
+ node,
106440
+ visitNode(node.expression, visitor, isExpression),
106441
+ Debug.checkDefined(visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory2.liftToBlock)),
106442
+ visitNode(node.elseStatement, topLevelNestedVisitor, isStatement, factory2.liftToBlock)
106443
+ );
106444
+ }
106427
106445
  function visitSwitchStatement(node) {
106428
106446
  return factory2.updateSwitchStatement(
106429
106447
  node,
@@ -115419,7 +115437,7 @@ ${lanes.join("\n")}
115419
115437
  }
115420
115438
  return program.isEmittedFile(file);
115421
115439
  }
115422
- function getWatchFactory(host, watchLogLevel, log, getDetailWatchInfo3) {
115440
+ function getWatchFactory(host, watchLogLevel, log, getDetailWatchInfo2) {
115423
115441
  setSysLog(watchLogLevel === 2 /* Verbose */ ? log : noop);
115424
115442
  const plainInvokeFactory = {
115425
115443
  watchFile: (file, callback, pollingInterval, options) => host.watchFile(file, callback, pollingInterval, options),
@@ -115457,23 +115475,23 @@ ${lanes.join("\n")}
115457
115475
  return typeof host.useCaseSensitiveFileNames === "boolean" ? host.useCaseSensitiveFileNames : host.useCaseSensitiveFileNames();
115458
115476
  }
115459
115477
  function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) {
115460
- log(`ExcludeWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`);
115478
+ log(`ExcludeWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
115461
115479
  return {
115462
- close: () => log(`ExcludeWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`)
115480
+ close: () => log(`ExcludeWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`)
115463
115481
  };
115464
115482
  }
115465
115483
  function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
115466
- log(`FileWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`);
115484
+ log(`FileWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
115467
115485
  const watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2);
115468
115486
  return {
115469
115487
  close: () => {
115470
- log(`FileWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`);
115488
+ log(`FileWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
115471
115489
  watcher.close();
115472
115490
  }
115473
115491
  };
115474
115492
  }
115475
115493
  function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
115476
- const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`;
115494
+ const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
115477
115495
  log(watchInfo);
115478
115496
  const start = timestamp();
115479
115497
  const watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2);
@@ -115481,7 +115499,7 @@ ${lanes.join("\n")}
115481
115499
  log(`Elapsed:: ${elapsed}ms ${watchInfo}`);
115482
115500
  return {
115483
115501
  close: () => {
115484
- const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`;
115502
+ const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
115485
115503
  log(watchInfo2);
115486
115504
  const start2 = timestamp();
115487
115505
  watcher.close();
@@ -115496,7 +115514,7 @@ ${lanes.join("\n")}
115496
115514
  void 0,
115497
115515
  file,
115498
115516
  (...args) => {
115499
- const triggerredInfo = `${key === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3)}`;
115517
+ const triggerredInfo = `${key === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
115500
115518
  log(triggerredInfo);
115501
115519
  const start = timestamp();
115502
115520
  cb.call(
@@ -115513,8 +115531,8 @@ ${lanes.join("\n")}
115513
115531
  detailInfo2
115514
115532
  );
115515
115533
  }
115516
- function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo4) {
115517
- return `WatchInfo: ${file} ${flags} ${JSON.stringify(options)} ${getDetailWatchInfo4 ? getDetailWatchInfo4(detailInfo1, detailInfo2) : detailInfo2 === void 0 ? detailInfo1 : `${detailInfo1} ${detailInfo2}`}`;
115534
+ function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo3) {
115535
+ return `WatchInfo: ${file} ${flags} ${JSON.stringify(options)} ${getDetailWatchInfo3 ? getDetailWatchInfo3(detailInfo1, detailInfo2) : detailInfo2 === void 0 ? detailInfo1 : `${detailInfo1} ${detailInfo2}`}`;
115518
115536
  }
115519
115537
  }
115520
115538
  function getFallbackOptions(options) {
@@ -122891,7 +122909,9 @@ ${lanes.join("\n")}
122891
122909
  MissingSourceMapFile: "Missing source map file",
122892
122910
  NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root",
122893
122911
  MissingGeneratedFile: "Missing generated file",
122894
- NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation"
122912
+ NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation",
122913
+ TypingInstallerLocationFile: "File location for typing installer",
122914
+ TypingInstallerLocationDirectory: "Directory location for typing installer"
122895
122915
  };
122896
122916
  }
122897
122917
  });
@@ -126108,7 +126128,7 @@ ${lanes.join("\n")}
126108
126128
  const d = /* @__PURE__ */ new Date();
126109
126129
  return `${padLeft(d.getHours().toString(), 2, "0")}:${padLeft(d.getMinutes().toString(), 2, "0")}:${padLeft(d.getSeconds().toString(), 2, "0")}.${padLeft(d.getMilliseconds().toString(), 3, "0")}`;
126110
126130
  }
126111
- var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, Arguments;
126131
+ var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, ActionWatchTypingLocations, Arguments;
126112
126132
  var init_shared = __esm({
126113
126133
  "src/jsTyping/shared.ts"() {
126114
126134
  "use strict";
@@ -126120,6 +126140,7 @@ ${lanes.join("\n")}
126120
126140
  EventBeginInstallTypes = "event::beginInstallTypes";
126121
126141
  EventEndInstallTypes = "event::endInstallTypes";
126122
126142
  EventInitializationFailed = "event::initializationFailed";
126143
+ ActionWatchTypingLocations = "action::watchTypingLocations";
126123
126144
  ((Arguments2) => {
126124
126145
  Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation";
126125
126146
  Arguments2.LogFile = "--logFile";
@@ -168962,19 +168983,6 @@ ${options.prefix}` : "\n" : options.prefix
168962
168983
  }
168963
168984
  return { command, remaining: remaining - toSlice };
168964
168985
  }
168965
- function endsWith2(str, suffix, caseSensitive) {
168966
- const expectedPos = str.length - suffix.length;
168967
- return expectedPos >= 0 && (str.indexOf(suffix, expectedPos) === expectedPos || !caseSensitive && compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* EqualTo */);
168968
- }
168969
- function isPackageOrBowerJson(fileName, caseSensitive) {
168970
- return endsWith2(fileName, "/package.json", caseSensitive) || endsWith2(fileName, "/bower.json", caseSensitive);
168971
- }
168972
- function sameFiles(a, b, caseSensitive) {
168973
- return a === b || !caseSensitive && compareStringsCaseInsensitive(a, b) === 0 /* EqualTo */;
168974
- }
168975
- function getDetailWatchInfo(projectName, watchers) {
168976
- return `Project: ${projectName} watcher already invoked: ${watchers == null ? void 0 : watchers.isInvoked}`;
168977
- }
168978
168986
  function typingsName(packageName) {
168979
168987
  return `@types/${packageName}@ts${versionMajorMinor}`;
168980
168988
  }
@@ -169005,13 +169013,10 @@ ${options.prefix}` : "\n" : options.prefix
169005
169013
  this.installRunCount = 1;
169006
169014
  this.inFlightRequestCount = 0;
169007
169015
  this.latestDistTag = "latest";
169008
- this.toCanonicalFileName = createGetCanonicalFileName(installTypingHost.useCaseSensitiveFileNames);
169009
- this.globalCachePackageJsonPath = combinePaths(globalCachePath, "package.json");
169010
169016
  const isLoggingEnabled = this.log.isEnabled();
169011
169017
  if (isLoggingEnabled) {
169012
169018
  this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}', types map path ${typesMapLocation}`);
169013
169019
  }
169014
- this.watchFactory = getWatchFactory(this.installTypingHost, isLoggingEnabled ? 2 /* Verbose */ : 0 /* None */, (s) => this.log.writeLine(s), getDetailWatchInfo);
169015
169020
  this.processCacheLocation(this.globalCachePath);
169016
169021
  }
169017
169022
  closeProject(req) {
@@ -169028,8 +169033,8 @@ ${options.prefix}` : "\n" : options.prefix
169028
169033
  }
169029
169034
  return;
169030
169035
  }
169031
- clearMap(watchers, closeFileWatcher);
169032
169036
  this.projectWatchers.delete(projectName);
169037
+ this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files: [] });
169033
169038
  if (this.log.isEnabled()) {
169034
169039
  this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`);
169035
169040
  }
@@ -169062,7 +169067,7 @@ ${options.prefix}` : "\n" : options.prefix
169062
169067
  if (this.log.isEnabled()) {
169063
169068
  this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`);
169064
169069
  }
169065
- this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch, req.projectRootPath, req.watchOptions);
169070
+ this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch);
169066
169071
  if (discoverTypingsResult.newTypingNames.length) {
169067
169072
  this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames);
169068
169073
  } else {
@@ -169263,75 +169268,19 @@ ${options.prefix}` : "\n" : options.prefix
169263
169268
  host.createDirectory(directory);
169264
169269
  }
169265
169270
  }
169266
- watchFiles(projectName, files, projectRootPath, options) {
169271
+ watchFiles(projectName, files) {
169267
169272
  if (!files.length) {
169268
169273
  this.closeWatchers(projectName);
169269
169274
  return;
169270
169275
  }
169271
- let watchers = this.projectWatchers.get(projectName);
169272
- const toRemove = /* @__PURE__ */ new Map();
169273
- if (!watchers) {
169274
- watchers = /* @__PURE__ */ new Map();
169275
- this.projectWatchers.set(projectName, watchers);
169276
+ const existing = this.projectWatchers.get(projectName);
169277
+ const newSet = new Set(files);
169278
+ if (!existing || forEachKey(newSet, (s) => !existing.has(s)) || forEachKey(existing, (s) => !newSet.has(s))) {
169279
+ this.projectWatchers.set(projectName, newSet);
169280
+ this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files });
169276
169281
  } else {
169277
- copyEntries(watchers, toRemove);
169282
+ this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files: void 0 });
169278
169283
  }
169279
- watchers.isInvoked = false;
169280
- const isLoggingEnabled = this.log.isEnabled();
169281
- const createProjectWatcher = (path, projectWatcherType) => {
169282
- const canonicalPath = this.toCanonicalFileName(path);
169283
- toRemove.delete(canonicalPath);
169284
- if (watchers.has(canonicalPath)) {
169285
- return;
169286
- }
169287
- if (isLoggingEnabled) {
169288
- this.log.writeLine(`${projectWatcherType}:: Added:: WatchInfo: ${path}`);
169289
- }
169290
- const watcher = projectWatcherType === "FileWatcher" /* FileWatcher */ ? this.watchFactory.watchFile(path, () => {
169291
- if (!watchers.isInvoked) {
169292
- watchers.isInvoked = true;
169293
- this.sendResponse({ projectName, kind: ActionInvalidate });
169294
- }
169295
- }, 2e3 /* High */, options, projectName, watchers) : this.watchFactory.watchDirectory(path, (f) => {
169296
- if (watchers.isInvoked || !fileExtensionIs(f, ".json" /* Json */)) {
169297
- return;
169298
- }
169299
- if (isPackageOrBowerJson(f, this.installTypingHost.useCaseSensitiveFileNames) && !sameFiles(f, this.globalCachePackageJsonPath, this.installTypingHost.useCaseSensitiveFileNames)) {
169300
- watchers.isInvoked = true;
169301
- this.sendResponse({ projectName, kind: ActionInvalidate });
169302
- }
169303
- }, 1 /* Recursive */, options, projectName, watchers);
169304
- watchers.set(canonicalPath, isLoggingEnabled ? {
169305
- close: () => {
169306
- this.log.writeLine(`${projectWatcherType}:: Closed:: WatchInfo: ${path}`);
169307
- watcher.close();
169308
- }
169309
- } : watcher);
169310
- };
169311
- for (const file of files) {
169312
- if (file.endsWith("/package.json") || file.endsWith("/bower.json")) {
169313
- createProjectWatcher(file, "FileWatcher" /* FileWatcher */);
169314
- continue;
169315
- }
169316
- if (containsPath(projectRootPath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
169317
- const subDirectory = file.indexOf(directorySeparator, projectRootPath.length + 1);
169318
- if (subDirectory !== -1) {
169319
- createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* DirectoryWatcher */);
169320
- } else {
169321
- createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
169322
- }
169323
- continue;
169324
- }
169325
- if (containsPath(this.globalCachePath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
169326
- createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* DirectoryWatcher */);
169327
- continue;
169328
- }
169329
- createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
169330
- }
169331
- toRemove.forEach((watch, path) => {
169332
- watch.close();
169333
- watchers.delete(path);
169334
- });
169335
169284
  }
169336
169285
  createSetTypings(request, typings) {
169337
169286
  return {
@@ -169404,7 +169353,6 @@ ${options.prefix}` : "\n" : options.prefix
169404
169353
  true
169405
169354
  ).concat(project.getExcludedFiles()),
169406
169355
  compilerOptions: project.getCompilationSettings(),
169407
- watchOptions: project.projectService.getWatchOptions(project),
169408
169356
  typeAcquisition,
169409
169357
  unresolvedImports,
169410
169358
  projectRootPath: project.getCurrentDirectory(),
@@ -171116,6 +171064,8 @@ ${options.prefix}` : "\n" : options.prefix
171116
171064
  return path === options.configFilePath ? options.configFile : this.getSourceFile(path);
171117
171065
  }
171118
171066
  close() {
171067
+ this.projectService.typingsCache.onProjectClosed(this);
171068
+ this.closeWatchingTypingLocations();
171119
171069
  if (this.program) {
171120
171070
  for (const f of this.program.getSourceFiles()) {
171121
171071
  this.detachScriptInfoIfNotRoot(f.fileName);
@@ -171406,6 +171356,89 @@ ${options.prefix}` : "\n" : options.prefix
171406
171356
  }
171407
171357
  }
171408
171358
  /** @internal */
171359
+ closeWatchingTypingLocations() {
171360
+ if (this.typingWatchers)
171361
+ clearMap(this.typingWatchers, closeFileWatcher);
171362
+ this.typingWatchers = void 0;
171363
+ }
171364
+ /** @internal */
171365
+ onTypingInstallerWatchInvoke() {
171366
+ this.typingWatchers.isInvoked = true;
171367
+ this.projectService.updateTypingsForProject({ projectName: this.getProjectName(), kind: ActionInvalidate });
171368
+ }
171369
+ /** @internal */
171370
+ watchTypingLocations(files) {
171371
+ if (!files) {
171372
+ this.typingWatchers.isInvoked = false;
171373
+ return;
171374
+ }
171375
+ if (!files.length) {
171376
+ this.closeWatchingTypingLocations();
171377
+ return;
171378
+ }
171379
+ const toRemove = new Map(this.typingWatchers);
171380
+ if (!this.typingWatchers)
171381
+ this.typingWatchers = /* @__PURE__ */ new Map();
171382
+ this.typingWatchers.isInvoked = false;
171383
+ const createProjectWatcher = (path, typingsWatcherType) => {
171384
+ const canonicalPath = this.toPath(path);
171385
+ toRemove.delete(canonicalPath);
171386
+ if (!this.typingWatchers.has(canonicalPath)) {
171387
+ this.typingWatchers.set(
171388
+ canonicalPath,
171389
+ typingsWatcherType === "FileWatcher" /* FileWatcher */ ? this.projectService.watchFactory.watchFile(
171390
+ path,
171391
+ () => !this.typingWatchers.isInvoked ? this.onTypingInstallerWatchInvoke() : this.writeLog(`TypingWatchers already invoked`),
171392
+ 2e3 /* High */,
171393
+ this.projectService.getWatchOptions(this),
171394
+ WatchType.TypingInstallerLocationFile,
171395
+ this
171396
+ ) : this.projectService.watchFactory.watchDirectory(
171397
+ path,
171398
+ (f) => {
171399
+ if (this.typingWatchers.isInvoked)
171400
+ return this.writeLog(`TypingWatchers already invoked`);
171401
+ if (!fileExtensionIs(f, ".json" /* Json */))
171402
+ return this.writeLog(`Ignoring files that are not *.json`);
171403
+ if (comparePaths(f, combinePaths(this.projectService.typingsInstaller.globalTypingsCacheLocation, "package.json"), !this.useCaseSensitiveFileNames()))
171404
+ return this.writeLog(`Ignoring package.json change at global typings location`);
171405
+ this.onTypingInstallerWatchInvoke();
171406
+ },
171407
+ 1 /* Recursive */,
171408
+ this.projectService.getWatchOptions(this),
171409
+ WatchType.TypingInstallerLocationDirectory,
171410
+ this
171411
+ )
171412
+ );
171413
+ }
171414
+ };
171415
+ for (const file of files) {
171416
+ const basename = getBaseFileName(file);
171417
+ if (basename === "package.json" || basename === "bower.json") {
171418
+ createProjectWatcher(file, "FileWatcher" /* FileWatcher */);
171419
+ continue;
171420
+ }
171421
+ if (containsPath(this.currentDirectory, file, this.currentDirectory, !this.useCaseSensitiveFileNames())) {
171422
+ const subDirectory = file.indexOf(directorySeparator, this.currentDirectory.length + 1);
171423
+ if (subDirectory !== -1) {
171424
+ createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* DirectoryWatcher */);
171425
+ } else {
171426
+ createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
171427
+ }
171428
+ continue;
171429
+ }
171430
+ if (containsPath(this.projectService.typingsInstaller.globalTypingsCacheLocation, file, this.currentDirectory, !this.useCaseSensitiveFileNames())) {
171431
+ createProjectWatcher(this.projectService.typingsInstaller.globalTypingsCacheLocation, "DirectoryWatcher" /* DirectoryWatcher */);
171432
+ continue;
171433
+ }
171434
+ createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
171435
+ }
171436
+ toRemove.forEach((watch, path) => {
171437
+ watch.close();
171438
+ this.typingWatchers.delete(path);
171439
+ });
171440
+ }
171441
+ /** @internal */
171409
171442
  getCurrentProgram() {
171410
171443
  return this.program;
171411
171444
  }
@@ -172855,7 +172888,7 @@ ${options.prefix}` : "\n" : options.prefix
172855
172888
  (potentialProjectRef) => callbackRefProject(project, cb, potentialProjectRef)
172856
172889
  );
172857
172890
  }
172858
- function getDetailWatchInfo2(watchType, project) {
172891
+ function getDetailWatchInfo(watchType, project) {
172859
172892
  return `${isString(project) ? `Config: ${project} ` : project ? `Project: ${project.getProjectName()} ` : ""}WatchType: ${watchType}`;
172860
172893
  }
172861
172894
  function isScriptInfoWatchedFromNodeModules(info) {
@@ -173120,7 +173153,7 @@ ${options.prefix}` : "\n" : options.prefix
173120
173153
  this.watchFactory = this.serverMode !== 0 /* Semantic */ ? {
173121
173154
  watchFile: returnNoopFileWatcher,
173122
173155
  watchDirectory: returnNoopFileWatcher
173123
- } : getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo2);
173156
+ } : getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
173124
173157
  }
173125
173158
  toPath(fileName) {
173126
173159
  return toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
@@ -173206,6 +173239,11 @@ ${options.prefix}` : "\n" : options.prefix
173206
173239
  }
173207
173240
  }
173208
173241
  /** @internal */
173242
+ watchTypingLocations(response) {
173243
+ var _a;
173244
+ (_a = this.findProject(response.projectName)) == null ? void 0 : _a.watchTypingLocations(response.files);
173245
+ }
173246
+ /** @internal */
173209
173247
  delayEnsureProjectForOpenFiles() {
173210
173248
  if (!this.openFiles.size)
173211
173249
  return;
@@ -180169,6 +180207,7 @@ ${e.message}`;
180169
180207
  ActionInvalidate: () => ActionInvalidate,
180170
180208
  ActionPackageInstalled: () => ActionPackageInstalled,
180171
180209
  ActionSet: () => ActionSet,
180210
+ ActionWatchTypingLocations: () => ActionWatchTypingLocations,
180172
180211
  Arguments: () => Arguments,
180173
180212
  AutoImportProviderProject: () => AutoImportProviderProject,
180174
180213
  CharRangeSection: () => CharRangeSection,
@@ -182558,6 +182597,7 @@ ${e.message}`;
182558
182597
  ActionInvalidate: () => ActionInvalidate,
182559
182598
  ActionPackageInstalled: () => ActionPackageInstalled,
182560
182599
  ActionSet: () => ActionSet,
182600
+ ActionWatchTypingLocations: () => ActionWatchTypingLocations,
182561
182601
  Arguments: () => Arguments,
182562
182602
  AutoImportProviderProject: () => AutoImportProviderProject,
182563
182603
  CharRangeSection: () => CharRangeSection,
@@ -5893,8 +5893,9 @@ declare namespace ts {
5893
5893
  type EventBeginInstallTypes = "event::beginInstallTypes";
5894
5894
  type EventEndInstallTypes = "event::endInstallTypes";
5895
5895
  type EventInitializationFailed = "event::initializationFailed";
5896
+ type ActionWatchTypingLocations = "action::watchTypingLocations";
5896
5897
  interface TypingInstallerResponse {
5897
- readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
5898
+ readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed | ActionWatchTypingLocations;
5898
5899
  }
5899
5900
  interface TypingInstallerRequestWithProjectName {
5900
5901
  readonly projectName: string;
@@ -5903,7 +5904,6 @@ declare namespace ts {
5903
5904
  readonly fileNames: string[];
5904
5905
  readonly projectRootPath: Path;
5905
5906
  readonly compilerOptions: CompilerOptions;
5906
- readonly watchOptions?: WatchOptions;
5907
5907
  readonly typeAcquisition: TypeAcquisition;
5908
5908
  readonly unresolvedImports: SortedReadonlyArray<string>;
5909
5909
  readonly cachePath?: string;
@@ -5955,8 +5955,6 @@ declare namespace ts {
5955
5955
  writeFile(path: string, content: string): void;
5956
5956
  createDirectory(path: string): void;
5957
5957
  getCurrentDirectory?(): string;
5958
- watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
5959
- watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
5960
5958
  }
5961
5959
  interface SetTypings extends ProjectResponse {
5962
5960
  readonly typeAcquisition: TypeAcquisition;
@@ -5965,6 +5963,11 @@ declare namespace ts {
5965
5963
  readonly unresolvedImports: SortedReadonlyArray<string>;
5966
5964
  readonly kind: ActionSet;
5967
5965
  }
5966
+ interface WatchTypingLocations extends ProjectResponse {
5967
+ /** if files is undefined, retain same set of watchers */
5968
+ readonly files: readonly string[] | undefined;
5969
+ readonly kind: ActionWatchTypingLocations;
5970
+ }
5968
5971
  }
5969
5972
  function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings;
5970
5973
  /**