typescript 5.1.0-dev.20230426 → 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.
- package/lib/tsc.js +15 -5
- package/lib/tsserver.js +136 -103
- package/lib/tsserverlibrary.d.ts +8 -7
- package/lib/tsserverlibrary.js +134 -104
- package/lib/typescript.d.ts +7 -4
- package/lib/typescript.js +18 -6
- package/lib/typingsInstaller.js +20 -194
- package/package.json +2 -2
package/lib/tsserverlibrary.js
CHANGED
|
@@ -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.
|
|
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__ */ ((
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
return
|
|
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";
|
|
@@ -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
|
-
|
|
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
|
)
|
|
@@ -115429,7 +115437,7 @@ ${lanes.join("\n")}
|
|
|
115429
115437
|
}
|
|
115430
115438
|
return program.isEmittedFile(file);
|
|
115431
115439
|
}
|
|
115432
|
-
function getWatchFactory(host, watchLogLevel, log,
|
|
115440
|
+
function getWatchFactory(host, watchLogLevel, log, getDetailWatchInfo2) {
|
|
115433
115441
|
setSysLog(watchLogLevel === 2 /* Verbose */ ? log : noop);
|
|
115434
115442
|
const plainInvokeFactory = {
|
|
115435
115443
|
watchFile: (file, callback, pollingInterval, options) => host.watchFile(file, callback, pollingInterval, options),
|
|
@@ -115467,23 +115475,23 @@ ${lanes.join("\n")}
|
|
|
115467
115475
|
return typeof host.useCaseSensitiveFileNames === "boolean" ? host.useCaseSensitiveFileNames : host.useCaseSensitiveFileNames();
|
|
115468
115476
|
}
|
|
115469
115477
|
function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) {
|
|
115470
|
-
log(`ExcludeWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115478
|
+
log(`ExcludeWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
|
|
115471
115479
|
return {
|
|
115472
|
-
close: () => log(`ExcludeWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115480
|
+
close: () => log(`ExcludeWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`)
|
|
115473
115481
|
};
|
|
115474
115482
|
}
|
|
115475
115483
|
function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
|
|
115476
|
-
log(`FileWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115484
|
+
log(`FileWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
|
|
115477
115485
|
const watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2);
|
|
115478
115486
|
return {
|
|
115479
115487
|
close: () => {
|
|
115480
|
-
log(`FileWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115488
|
+
log(`FileWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
|
|
115481
115489
|
watcher.close();
|
|
115482
115490
|
}
|
|
115483
115491
|
};
|
|
115484
115492
|
}
|
|
115485
115493
|
function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
|
|
115486
|
-
const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115494
|
+
const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
|
|
115487
115495
|
log(watchInfo);
|
|
115488
115496
|
const start = timestamp();
|
|
115489
115497
|
const watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2);
|
|
@@ -115491,7 +115499,7 @@ ${lanes.join("\n")}
|
|
|
115491
115499
|
log(`Elapsed:: ${elapsed}ms ${watchInfo}`);
|
|
115492
115500
|
return {
|
|
115493
115501
|
close: () => {
|
|
115494
|
-
const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115502
|
+
const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
|
|
115495
115503
|
log(watchInfo2);
|
|
115496
115504
|
const start2 = timestamp();
|
|
115497
115505
|
watcher.close();
|
|
@@ -115506,7 +115514,7 @@ ${lanes.join("\n")}
|
|
|
115506
115514
|
void 0,
|
|
115507
115515
|
file,
|
|
115508
115516
|
(...args) => {
|
|
115509
|
-
const triggerredInfo = `${key === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115517
|
+
const triggerredInfo = `${key === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
|
|
115510
115518
|
log(triggerredInfo);
|
|
115511
115519
|
const start = timestamp();
|
|
115512
115520
|
cb.call(
|
|
@@ -115523,8 +115531,8 @@ ${lanes.join("\n")}
|
|
|
115523
115531
|
detailInfo2
|
|
115524
115532
|
);
|
|
115525
115533
|
}
|
|
115526
|
-
function getWatchInfo(file, flags, options, detailInfo1, detailInfo2,
|
|
115527
|
-
return `WatchInfo: ${file} ${flags} ${JSON.stringify(options)} ${
|
|
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}`}`;
|
|
115528
115536
|
}
|
|
115529
115537
|
}
|
|
115530
115538
|
function getFallbackOptions(options) {
|
|
@@ -122901,7 +122909,9 @@ ${lanes.join("\n")}
|
|
|
122901
122909
|
MissingSourceMapFile: "Missing source map file",
|
|
122902
122910
|
NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root",
|
|
122903
122911
|
MissingGeneratedFile: "Missing generated file",
|
|
122904
|
-
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"
|
|
122905
122915
|
};
|
|
122906
122916
|
}
|
|
122907
122917
|
});
|
|
@@ -126118,7 +126128,7 @@ ${lanes.join("\n")}
|
|
|
126118
126128
|
const d = /* @__PURE__ */ new Date();
|
|
126119
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")}`;
|
|
126120
126130
|
}
|
|
126121
|
-
var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, Arguments;
|
|
126131
|
+
var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, ActionWatchTypingLocations, Arguments;
|
|
126122
126132
|
var init_shared = __esm({
|
|
126123
126133
|
"src/jsTyping/shared.ts"() {
|
|
126124
126134
|
"use strict";
|
|
@@ -126130,6 +126140,7 @@ ${lanes.join("\n")}
|
|
|
126130
126140
|
EventBeginInstallTypes = "event::beginInstallTypes";
|
|
126131
126141
|
EventEndInstallTypes = "event::endInstallTypes";
|
|
126132
126142
|
EventInitializationFailed = "event::initializationFailed";
|
|
126143
|
+
ActionWatchTypingLocations = "action::watchTypingLocations";
|
|
126133
126144
|
((Arguments2) => {
|
|
126134
126145
|
Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation";
|
|
126135
126146
|
Arguments2.LogFile = "--logFile";
|
|
@@ -168972,19 +168983,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168972
168983
|
}
|
|
168973
168984
|
return { command, remaining: remaining - toSlice };
|
|
168974
168985
|
}
|
|
168975
|
-
function endsWith2(str, suffix, caseSensitive) {
|
|
168976
|
-
const expectedPos = str.length - suffix.length;
|
|
168977
|
-
return expectedPos >= 0 && (str.indexOf(suffix, expectedPos) === expectedPos || !caseSensitive && compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* EqualTo */);
|
|
168978
|
-
}
|
|
168979
|
-
function isPackageOrBowerJson(fileName, caseSensitive) {
|
|
168980
|
-
return endsWith2(fileName, "/package.json", caseSensitive) || endsWith2(fileName, "/bower.json", caseSensitive);
|
|
168981
|
-
}
|
|
168982
|
-
function sameFiles(a, b, caseSensitive) {
|
|
168983
|
-
return a === b || !caseSensitive && compareStringsCaseInsensitive(a, b) === 0 /* EqualTo */;
|
|
168984
|
-
}
|
|
168985
|
-
function getDetailWatchInfo(projectName, watchers) {
|
|
168986
|
-
return `Project: ${projectName} watcher already invoked: ${watchers == null ? void 0 : watchers.isInvoked}`;
|
|
168987
|
-
}
|
|
168988
168986
|
function typingsName(packageName) {
|
|
168989
168987
|
return `@types/${packageName}@ts${versionMajorMinor}`;
|
|
168990
168988
|
}
|
|
@@ -169015,13 +169013,10 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169015
169013
|
this.installRunCount = 1;
|
|
169016
169014
|
this.inFlightRequestCount = 0;
|
|
169017
169015
|
this.latestDistTag = "latest";
|
|
169018
|
-
this.toCanonicalFileName = createGetCanonicalFileName(installTypingHost.useCaseSensitiveFileNames);
|
|
169019
|
-
this.globalCachePackageJsonPath = combinePaths(globalCachePath, "package.json");
|
|
169020
169016
|
const isLoggingEnabled = this.log.isEnabled();
|
|
169021
169017
|
if (isLoggingEnabled) {
|
|
169022
169018
|
this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}', types map path ${typesMapLocation}`);
|
|
169023
169019
|
}
|
|
169024
|
-
this.watchFactory = getWatchFactory(this.installTypingHost, isLoggingEnabled ? 2 /* Verbose */ : 0 /* None */, (s) => this.log.writeLine(s), getDetailWatchInfo);
|
|
169025
169020
|
this.processCacheLocation(this.globalCachePath);
|
|
169026
169021
|
}
|
|
169027
169022
|
closeProject(req) {
|
|
@@ -169038,8 +169033,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169038
169033
|
}
|
|
169039
169034
|
return;
|
|
169040
169035
|
}
|
|
169041
|
-
clearMap(watchers, closeFileWatcher);
|
|
169042
169036
|
this.projectWatchers.delete(projectName);
|
|
169037
|
+
this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files: [] });
|
|
169043
169038
|
if (this.log.isEnabled()) {
|
|
169044
169039
|
this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`);
|
|
169045
169040
|
}
|
|
@@ -169072,7 +169067,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169072
169067
|
if (this.log.isEnabled()) {
|
|
169073
169068
|
this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`);
|
|
169074
169069
|
}
|
|
169075
|
-
this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch
|
|
169070
|
+
this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch);
|
|
169076
169071
|
if (discoverTypingsResult.newTypingNames.length) {
|
|
169077
169072
|
this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames);
|
|
169078
169073
|
} else {
|
|
@@ -169273,75 +169268,19 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169273
169268
|
host.createDirectory(directory);
|
|
169274
169269
|
}
|
|
169275
169270
|
}
|
|
169276
|
-
watchFiles(projectName, files
|
|
169271
|
+
watchFiles(projectName, files) {
|
|
169277
169272
|
if (!files.length) {
|
|
169278
169273
|
this.closeWatchers(projectName);
|
|
169279
169274
|
return;
|
|
169280
169275
|
}
|
|
169281
|
-
|
|
169282
|
-
const
|
|
169283
|
-
if (!
|
|
169284
|
-
|
|
169285
|
-
this.
|
|
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 });
|
|
169286
169281
|
} else {
|
|
169287
|
-
|
|
169288
|
-
}
|
|
169289
|
-
watchers.isInvoked = false;
|
|
169290
|
-
const isLoggingEnabled = this.log.isEnabled();
|
|
169291
|
-
const createProjectWatcher = (path, projectWatcherType) => {
|
|
169292
|
-
const canonicalPath = this.toCanonicalFileName(path);
|
|
169293
|
-
toRemove.delete(canonicalPath);
|
|
169294
|
-
if (watchers.has(canonicalPath)) {
|
|
169295
|
-
return;
|
|
169296
|
-
}
|
|
169297
|
-
if (isLoggingEnabled) {
|
|
169298
|
-
this.log.writeLine(`${projectWatcherType}:: Added:: WatchInfo: ${path}`);
|
|
169299
|
-
}
|
|
169300
|
-
const watcher = projectWatcherType === "FileWatcher" /* FileWatcher */ ? this.watchFactory.watchFile(path, () => {
|
|
169301
|
-
if (!watchers.isInvoked) {
|
|
169302
|
-
watchers.isInvoked = true;
|
|
169303
|
-
this.sendResponse({ projectName, kind: ActionInvalidate });
|
|
169304
|
-
}
|
|
169305
|
-
}, 2e3 /* High */, options, projectName, watchers) : this.watchFactory.watchDirectory(path, (f) => {
|
|
169306
|
-
if (watchers.isInvoked || !fileExtensionIs(f, ".json" /* Json */)) {
|
|
169307
|
-
return;
|
|
169308
|
-
}
|
|
169309
|
-
if (isPackageOrBowerJson(f, this.installTypingHost.useCaseSensitiveFileNames) && !sameFiles(f, this.globalCachePackageJsonPath, this.installTypingHost.useCaseSensitiveFileNames)) {
|
|
169310
|
-
watchers.isInvoked = true;
|
|
169311
|
-
this.sendResponse({ projectName, kind: ActionInvalidate });
|
|
169312
|
-
}
|
|
169313
|
-
}, 1 /* Recursive */, options, projectName, watchers);
|
|
169314
|
-
watchers.set(canonicalPath, isLoggingEnabled ? {
|
|
169315
|
-
close: () => {
|
|
169316
|
-
this.log.writeLine(`${projectWatcherType}:: Closed:: WatchInfo: ${path}`);
|
|
169317
|
-
watcher.close();
|
|
169318
|
-
}
|
|
169319
|
-
} : watcher);
|
|
169320
|
-
};
|
|
169321
|
-
for (const file of files) {
|
|
169322
|
-
if (file.endsWith("/package.json") || file.endsWith("/bower.json")) {
|
|
169323
|
-
createProjectWatcher(file, "FileWatcher" /* FileWatcher */);
|
|
169324
|
-
continue;
|
|
169325
|
-
}
|
|
169326
|
-
if (containsPath(projectRootPath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
|
|
169327
|
-
const subDirectory = file.indexOf(directorySeparator, projectRootPath.length + 1);
|
|
169328
|
-
if (subDirectory !== -1) {
|
|
169329
|
-
createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* DirectoryWatcher */);
|
|
169330
|
-
} else {
|
|
169331
|
-
createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
|
|
169332
|
-
}
|
|
169333
|
-
continue;
|
|
169334
|
-
}
|
|
169335
|
-
if (containsPath(this.globalCachePath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) {
|
|
169336
|
-
createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* DirectoryWatcher */);
|
|
169337
|
-
continue;
|
|
169338
|
-
}
|
|
169339
|
-
createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */);
|
|
169282
|
+
this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files: void 0 });
|
|
169340
169283
|
}
|
|
169341
|
-
toRemove.forEach((watch, path) => {
|
|
169342
|
-
watch.close();
|
|
169343
|
-
watchers.delete(path);
|
|
169344
|
-
});
|
|
169345
169284
|
}
|
|
169346
169285
|
createSetTypings(request, typings) {
|
|
169347
169286
|
return {
|
|
@@ -169414,7 +169353,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169414
169353
|
true
|
|
169415
169354
|
).concat(project.getExcludedFiles()),
|
|
169416
169355
|
compilerOptions: project.getCompilationSettings(),
|
|
169417
|
-
watchOptions: project.projectService.getWatchOptions(project),
|
|
169418
169356
|
typeAcquisition,
|
|
169419
169357
|
unresolvedImports,
|
|
169420
169358
|
projectRootPath: project.getCurrentDirectory(),
|
|
@@ -171126,6 +171064,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
171126
171064
|
return path === options.configFilePath ? options.configFile : this.getSourceFile(path);
|
|
171127
171065
|
}
|
|
171128
171066
|
close() {
|
|
171067
|
+
this.projectService.typingsCache.onProjectClosed(this);
|
|
171068
|
+
this.closeWatchingTypingLocations();
|
|
171129
171069
|
if (this.program) {
|
|
171130
171070
|
for (const f of this.program.getSourceFiles()) {
|
|
171131
171071
|
this.detachScriptInfoIfNotRoot(f.fileName);
|
|
@@ -171416,6 +171356,89 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
171416
171356
|
}
|
|
171417
171357
|
}
|
|
171418
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 */
|
|
171419
171442
|
getCurrentProgram() {
|
|
171420
171443
|
return this.program;
|
|
171421
171444
|
}
|
|
@@ -172865,7 +172888,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
172865
172888
|
(potentialProjectRef) => callbackRefProject(project, cb, potentialProjectRef)
|
|
172866
172889
|
);
|
|
172867
172890
|
}
|
|
172868
|
-
function
|
|
172891
|
+
function getDetailWatchInfo(watchType, project) {
|
|
172869
172892
|
return `${isString(project) ? `Config: ${project} ` : project ? `Project: ${project.getProjectName()} ` : ""}WatchType: ${watchType}`;
|
|
172870
172893
|
}
|
|
172871
172894
|
function isScriptInfoWatchedFromNodeModules(info) {
|
|
@@ -173130,7 +173153,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
173130
173153
|
this.watchFactory = this.serverMode !== 0 /* Semantic */ ? {
|
|
173131
173154
|
watchFile: returnNoopFileWatcher,
|
|
173132
173155
|
watchDirectory: returnNoopFileWatcher
|
|
173133
|
-
} : getWatchFactory(this.host, watchLogLevel, log,
|
|
173156
|
+
} : getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
|
|
173134
173157
|
}
|
|
173135
173158
|
toPath(fileName) {
|
|
173136
173159
|
return toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
|
|
@@ -173216,6 +173239,11 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
173216
173239
|
}
|
|
173217
173240
|
}
|
|
173218
173241
|
/** @internal */
|
|
173242
|
+
watchTypingLocations(response) {
|
|
173243
|
+
var _a;
|
|
173244
|
+
(_a = this.findProject(response.projectName)) == null ? void 0 : _a.watchTypingLocations(response.files);
|
|
173245
|
+
}
|
|
173246
|
+
/** @internal */
|
|
173219
173247
|
delayEnsureProjectForOpenFiles() {
|
|
173220
173248
|
if (!this.openFiles.size)
|
|
173221
173249
|
return;
|
|
@@ -180179,6 +180207,7 @@ ${e.message}`;
|
|
|
180179
180207
|
ActionInvalidate: () => ActionInvalidate,
|
|
180180
180208
|
ActionPackageInstalled: () => ActionPackageInstalled,
|
|
180181
180209
|
ActionSet: () => ActionSet,
|
|
180210
|
+
ActionWatchTypingLocations: () => ActionWatchTypingLocations,
|
|
180182
180211
|
Arguments: () => Arguments,
|
|
180183
180212
|
AutoImportProviderProject: () => AutoImportProviderProject,
|
|
180184
180213
|
CharRangeSection: () => CharRangeSection,
|
|
@@ -182568,6 +182597,7 @@ ${e.message}`;
|
|
|
182568
182597
|
ActionInvalidate: () => ActionInvalidate,
|
|
182569
182598
|
ActionPackageInstalled: () => ActionPackageInstalled,
|
|
182570
182599
|
ActionSet: () => ActionSet,
|
|
182600
|
+
ActionWatchTypingLocations: () => ActionWatchTypingLocations,
|
|
182571
182601
|
Arguments: () => Arguments,
|
|
182572
182602
|
AutoImportProviderProject: () => AutoImportProviderProject,
|
|
182573
182603
|
CharRangeSection: () => CharRangeSection,
|
package/lib/typescript.d.ts
CHANGED
|
@@ -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
|
/**
|
package/lib/typescript.js
CHANGED
|
@@ -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.
|
|
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";
|
|
@@ -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
|
-
|
|
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
|
)
|
|
@@ -122901,7 +122909,9 @@ ${lanes.join("\n")}
|
|
|
122901
122909
|
MissingSourceMapFile: "Missing source map file",
|
|
122902
122910
|
NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root",
|
|
122903
122911
|
MissingGeneratedFile: "Missing generated file",
|
|
122904
|
-
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"
|
|
122905
122915
|
};
|
|
122906
122916
|
}
|
|
122907
122917
|
});
|
|
@@ -126118,7 +126128,7 @@ ${lanes.join("\n")}
|
|
|
126118
126128
|
const d = /* @__PURE__ */ new Date();
|
|
126119
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")}`;
|
|
126120
126130
|
}
|
|
126121
|
-
var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, Arguments;
|
|
126131
|
+
var ActionSet, ActionInvalidate, ActionPackageInstalled, EventTypesRegistry, EventBeginInstallTypes, EventEndInstallTypes, EventInitializationFailed, ActionWatchTypingLocations, Arguments;
|
|
126122
126132
|
var init_shared = __esm({
|
|
126123
126133
|
"src/jsTyping/shared.ts"() {
|
|
126124
126134
|
"use strict";
|
|
@@ -126130,6 +126140,7 @@ ${lanes.join("\n")}
|
|
|
126130
126140
|
EventBeginInstallTypes = "event::beginInstallTypes";
|
|
126131
126141
|
EventEndInstallTypes = "event::endInstallTypes";
|
|
126132
126142
|
EventInitializationFailed = "event::initializationFailed";
|
|
126143
|
+
ActionWatchTypingLocations = "action::watchTypingLocations";
|
|
126133
126144
|
((Arguments2) => {
|
|
126134
126145
|
Arguments2.GlobalCacheLocation = "--globalTypingsCacheLocation";
|
|
126135
126146
|
Arguments2.LogFile = "--logFile";
|
|
@@ -126155,6 +126166,7 @@ ${lanes.join("\n")}
|
|
|
126155
126166
|
ActionInvalidate: () => ActionInvalidate,
|
|
126156
126167
|
ActionPackageInstalled: () => ActionPackageInstalled,
|
|
126157
126168
|
ActionSet: () => ActionSet,
|
|
126169
|
+
ActionWatchTypingLocations: () => ActionWatchTypingLocations,
|
|
126158
126170
|
Arguments: () => Arguments,
|
|
126159
126171
|
EventBeginInstallTypes: () => EventBeginInstallTypes,
|
|
126160
126172
|
EventEndInstallTypes: () => EventEndInstallTypes,
|