@typescript-deploys/pr-build 4.8.0-pr-49119-45 → 4.8.0-pr-48997-21
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/lib.es5.d.ts +1 -1
- package/lib/protocol.d.ts +1 -0
- package/lib/tsc.js +154 -193
- package/lib/tsserver.js +192 -235
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +192 -235
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +192 -235
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +192 -235
- package/lib/typingsInstaller.js +188 -235
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220525";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -5101,11 +5101,6 @@ var ts;
|
|
|
5101
5101
|
// Flags that require TypeFlags.Union
|
|
5102
5102
|
/* @internal */
|
|
5103
5103
|
ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
5104
|
-
/* @internal */
|
|
5105
|
-
ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
5106
|
-
/* @internal */
|
|
5107
|
-
ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
5108
|
-
/* @internal */
|
|
5109
5104
|
// Flags that require TypeFlags.Intersection
|
|
5110
5105
|
/* @internal */
|
|
5111
5106
|
ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
@@ -6324,7 +6319,7 @@ var ts;
|
|
|
6324
6319
|
*/
|
|
6325
6320
|
/*@internal*/
|
|
6326
6321
|
function createDirectoryWatcherSupportingRecursive(_a) {
|
|
6327
|
-
var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories,
|
|
6322
|
+
var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, fileSystemEntryExists = _a.fileSystemEntryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
|
|
6328
6323
|
var cache = new ts.Map();
|
|
6329
6324
|
var callbackCache = ts.createMultiMap();
|
|
6330
6325
|
var cacheToUpdateChildWatches = new ts.Map();
|
|
@@ -6424,7 +6419,7 @@ var ts;
|
|
|
6424
6419
|
function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
|
|
6425
6420
|
// Iterate through existing children and update the watches if needed
|
|
6426
6421
|
var parentWatcher = cache.get(dirPath);
|
|
6427
|
-
if (parentWatcher &&
|
|
6422
|
+
if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) {
|
|
6428
6423
|
// Schedule the update and postpone invoke for callbacks
|
|
6429
6424
|
scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
|
|
6430
6425
|
return;
|
|
@@ -6497,7 +6492,7 @@ var ts;
|
|
|
6497
6492
|
if (!parentWatcher)
|
|
6498
6493
|
return false;
|
|
6499
6494
|
var newChildWatches;
|
|
6500
|
-
var hasChanges = ts.enumerateInsertsAndDeletes(
|
|
6495
|
+
var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
|
|
6501
6496
|
var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
|
|
6502
6497
|
// Filter our the symbolic link directories since those arent included in recursive watch
|
|
6503
6498
|
// which is same behaviour when recursive: true is passed to fs.watch
|
|
@@ -6543,10 +6538,10 @@ var ts;
|
|
|
6543
6538
|
return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
|
|
6544
6539
|
}
|
|
6545
6540
|
ts.createFileWatcherCallback = createFileWatcherCallback;
|
|
6546
|
-
function createFsWatchCallbackForFileWatcherCallback(fileName, callback,
|
|
6541
|
+
function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists) {
|
|
6547
6542
|
return function (eventName) {
|
|
6548
6543
|
if (eventName === "rename") {
|
|
6549
|
-
callback(fileName,
|
|
6544
|
+
callback(fileName, fileSystemEntryExists(fileName, 0 /* File */) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
|
|
6550
6545
|
}
|
|
6551
6546
|
else {
|
|
6552
6547
|
// Change
|
|
@@ -6574,11 +6569,12 @@ var ts;
|
|
|
6574
6569
|
}
|
|
6575
6570
|
/*@internal*/
|
|
6576
6571
|
function createSystemWatchFunctions(_a) {
|
|
6577
|
-
var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout,
|
|
6572
|
+
var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
|
|
6578
6573
|
var dynamicPollingWatchFile;
|
|
6579
6574
|
var fixedChunkSizePollingWatchFile;
|
|
6580
6575
|
var nonPollingWatchFile;
|
|
6581
6576
|
var hostRecursiveDirectoryWatcher;
|
|
6577
|
+
var hitSystemWatcherLimit = false;
|
|
6582
6578
|
return {
|
|
6583
6579
|
watchFile: watchFile,
|
|
6584
6580
|
watchDirectory: watchDirectory
|
|
@@ -6596,7 +6592,7 @@ var ts;
|
|
|
6596
6592
|
case ts.WatchFileKind.FixedChunkSizePolling:
|
|
6597
6593
|
return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
|
|
6598
6594
|
case ts.WatchFileKind.UseFsEvents:
|
|
6599
|
-
return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback,
|
|
6595
|
+
return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileSystemEntryExists),
|
|
6600
6596
|
/*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
|
|
6601
6597
|
case ts.WatchFileKind.UseFsEventsOnParentDirectory:
|
|
6602
6598
|
if (!nonPollingWatchFile) {
|
|
@@ -6657,7 +6653,7 @@ var ts;
|
|
|
6657
6653
|
hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
|
|
6658
6654
|
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
|
6659
6655
|
getCurrentDirectory: getCurrentDirectory,
|
|
6660
|
-
|
|
6656
|
+
fileSystemEntryExists: fileSystemEntryExists,
|
|
6661
6657
|
getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
|
|
6662
6658
|
watchDirectory: nonRecursiveWatchDirectory,
|
|
6663
6659
|
realpath: realpath,
|
|
@@ -6708,6 +6704,114 @@ var ts;
|
|
|
6708
6704
|
};
|
|
6709
6705
|
}
|
|
6710
6706
|
}
|
|
6707
|
+
function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
|
|
6708
|
+
var lastDirectoryPartWithDirectorySeparator;
|
|
6709
|
+
var lastDirectoryPart;
|
|
6710
|
+
if (inodeWatching) {
|
|
6711
|
+
lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substring(fileOrDirectory.lastIndexOf(ts.directorySeparator));
|
|
6712
|
+
lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
|
|
6713
|
+
}
|
|
6714
|
+
/** Watcher for the file system entry depending on whether it is missing or present */
|
|
6715
|
+
var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
|
6716
|
+
watchMissingFileSystemEntry() :
|
|
6717
|
+
watchPresentFileSystemEntry();
|
|
6718
|
+
return {
|
|
6719
|
+
close: function () {
|
|
6720
|
+
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
6721
|
+
watcher.close();
|
|
6722
|
+
watcher = undefined;
|
|
6723
|
+
}
|
|
6724
|
+
};
|
|
6725
|
+
function updateWatcher(createWatcher) {
|
|
6726
|
+
// If watcher is not closed, update it
|
|
6727
|
+
if (watcher) {
|
|
6728
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
|
|
6729
|
+
watcher.close();
|
|
6730
|
+
watcher = createWatcher();
|
|
6731
|
+
}
|
|
6732
|
+
}
|
|
6733
|
+
/**
|
|
6734
|
+
* Watch the file or directory that is currently present
|
|
6735
|
+
* and when the watched file or directory is deleted, switch to missing file system entry watcher
|
|
6736
|
+
*/
|
|
6737
|
+
function watchPresentFileSystemEntry() {
|
|
6738
|
+
if (hitSystemWatcherLimit) {
|
|
6739
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile");
|
|
6740
|
+
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
6741
|
+
}
|
|
6742
|
+
try {
|
|
6743
|
+
var presentWatcher = fsWatchWorker(fileOrDirectory, recursive, inodeWatching ?
|
|
6744
|
+
callbackChangingToMissingFileSystemEntry :
|
|
6745
|
+
function (eventName, relativeFileName) {
|
|
6746
|
+
sysLog("sysLog:: watchPresentFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
|
|
6747
|
+
callback(eventName, relativeFileName);
|
|
6748
|
+
});
|
|
6749
|
+
// Watch the missing file or directory or error
|
|
6750
|
+
presentWatcher.on("error", function () {
|
|
6751
|
+
sysLog("sysLog:: watchPresentFileSystemEntry:: on Error " + fileOrDirectory + " " + entryKind + " rename, \"\"");
|
|
6752
|
+
callback("rename", "");
|
|
6753
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6754
|
+
});
|
|
6755
|
+
return presentWatcher;
|
|
6756
|
+
}
|
|
6757
|
+
catch (e) {
|
|
6758
|
+
// Catch the exception and use polling instead
|
|
6759
|
+
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
6760
|
+
// so instead of throwing error, use fs.watchFile
|
|
6761
|
+
hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
|
|
6762
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile");
|
|
6763
|
+
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
6764
|
+
}
|
|
6765
|
+
}
|
|
6766
|
+
function callbackChangingToMissingFileSystemEntry(event, relativeName) {
|
|
6767
|
+
sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + event + ":: " + relativeName + " " + inodeWatching + " " + lastDirectoryPart + " " + lastDirectoryPartWithDirectorySeparator);
|
|
6768
|
+
if (relativeName && ts.endsWith(relativeName, "~")) {
|
|
6769
|
+
relativeName = relativeName.slice(0, relativeName.length - 1);
|
|
6770
|
+
sysLog("sysLog:: callbackChangingToMissingFileSystemEntry:: changed the relative name to " + relativeName);
|
|
6771
|
+
}
|
|
6772
|
+
callback(event, relativeName);
|
|
6773
|
+
// because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
|
|
6774
|
+
// Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
|
|
6775
|
+
if (event === "rename" &&
|
|
6776
|
+
(!relativeName ||
|
|
6777
|
+
relativeName === lastDirectoryPart ||
|
|
6778
|
+
ts.endsWith(relativeName, lastDirectoryPartWithDirectorySeparator))) {
|
|
6779
|
+
if (inodeWatching) {
|
|
6780
|
+
updateWatcher(!fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry : watchPresentFileSystemEntry);
|
|
6781
|
+
}
|
|
6782
|
+
else if (!fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6783
|
+
updateWatcher(watchMissingFileSystemEntry);
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
}
|
|
6787
|
+
/**
|
|
6788
|
+
* Watch the file or directory using fs.watchFile since fs.watch threw exception
|
|
6789
|
+
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
6790
|
+
*/
|
|
6791
|
+
function watchPresentFileSystemEntryWithFsWatchFile() {
|
|
6792
|
+
return watchFile(fileOrDirectory, createFileWatcherCallback(function (eventName, relativeFileName) {
|
|
6793
|
+
sysLog("sysLog:: watchPresentFileSystemEntryWithFsWatchFile:: " + fileOrDirectory + " " + entryKind + " " + eventName + ":: " + relativeFileName);
|
|
6794
|
+
callback(eventName, relativeFileName);
|
|
6795
|
+
}), fallbackPollingInterval, fallbackOptions);
|
|
6796
|
+
}
|
|
6797
|
+
/**
|
|
6798
|
+
* Watch the file or directory that is missing
|
|
6799
|
+
* and switch to existing file or directory when the missing filesystem entry is created
|
|
6800
|
+
*/
|
|
6801
|
+
function watchMissingFileSystemEntry() {
|
|
6802
|
+
return watchFile(fileOrDirectory, function (_fileName, eventKind) {
|
|
6803
|
+
sysLog("sysLog:: watchMissingFileSystemEntry:: " + fileOrDirectory + " " + entryKind + " " + _fileName + ":: " + eventKind);
|
|
6804
|
+
if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
6805
|
+
sysLog("sysLog:: watchMissingFileSystemEntry:: Callback :: rename, \"\" and will update the watcher");
|
|
6806
|
+
callback("rename", "");
|
|
6807
|
+
// Call the callback for current file or directory
|
|
6808
|
+
// For now it could be callback for the inner directory creation,
|
|
6809
|
+
// but just return current directory, better than current no-op
|
|
6810
|
+
updateWatcher(watchPresentFileSystemEntry);
|
|
6811
|
+
}
|
|
6812
|
+
}, fallbackPollingInterval, fallbackOptions);
|
|
6813
|
+
}
|
|
6814
|
+
}
|
|
6711
6815
|
}
|
|
6712
6816
|
ts.createSystemWatchFunctions = createSystemWatchFunctions;
|
|
6713
6817
|
/**
|
|
@@ -6760,7 +6864,6 @@ var ts;
|
|
|
6760
6864
|
}
|
|
6761
6865
|
var activeSession;
|
|
6762
6866
|
var profilePath = "./profile.cpuprofile";
|
|
6763
|
-
var hitSystemWatcherLimit = false;
|
|
6764
6867
|
var Buffer = require("buffer").Buffer;
|
|
6765
6868
|
var nodeVersion = getNodeMajorVersion();
|
|
6766
6869
|
var isNode4OrLater = nodeVersion >= 4;
|
|
@@ -6775,20 +6878,21 @@ var ts;
|
|
|
6775
6878
|
getModifiedTime: getModifiedTime,
|
|
6776
6879
|
setTimeout: setTimeout,
|
|
6777
6880
|
clearTimeout: clearTimeout,
|
|
6778
|
-
|
|
6881
|
+
fsWatchWorker: fsWatchWorker,
|
|
6779
6882
|
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
|
6780
6883
|
getCurrentDirectory: getCurrentDirectory,
|
|
6781
|
-
|
|
6884
|
+
fileSystemEntryExists: fileSystemEntryExists,
|
|
6782
6885
|
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
|
6783
6886
|
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
|
6784
6887
|
fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
|
|
6785
|
-
directoryExists: directoryExists,
|
|
6786
6888
|
getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
|
|
6787
6889
|
realpath: realpath,
|
|
6788
6890
|
tscWatchFile: process.env.TSC_WATCHFILE,
|
|
6789
6891
|
useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
|
|
6790
6892
|
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
|
|
6791
6893
|
defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
6894
|
+
inodeWatching: isLinuxOrMacOs,
|
|
6895
|
+
sysLog: sysLog,
|
|
6792
6896
|
}), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
|
|
6793
6897
|
var nodeSystem = {
|
|
6794
6898
|
args: process.argv.slice(2),
|
|
@@ -7041,107 +7145,11 @@ var ts;
|
|
|
7041
7145
|
callback(fileName, eventKind);
|
|
7042
7146
|
}
|
|
7043
7147
|
}
|
|
7044
|
-
function
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
|
|
7050
|
-
lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
|
|
7051
|
-
}
|
|
7052
|
-
/** Watcher for the file system entry depending on whether it is missing or present */
|
|
7053
|
-
var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
|
7054
|
-
watchMissingFileSystemEntry() :
|
|
7055
|
-
watchPresentFileSystemEntry();
|
|
7056
|
-
return {
|
|
7057
|
-
close: function () {
|
|
7058
|
-
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
7059
|
-
watcher.close();
|
|
7060
|
-
watcher = undefined;
|
|
7061
|
-
}
|
|
7062
|
-
};
|
|
7063
|
-
/**
|
|
7064
|
-
* Invoke the callback with rename and update the watcher if not closed
|
|
7065
|
-
* @param createWatcher
|
|
7066
|
-
*/
|
|
7067
|
-
function invokeCallbackAndUpdateWatcher(createWatcher) {
|
|
7068
|
-
sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
|
|
7069
|
-
// Call the callback for current directory
|
|
7070
|
-
callback("rename", "");
|
|
7071
|
-
// If watcher is not closed, update it
|
|
7072
|
-
if (watcher) {
|
|
7073
|
-
watcher.close();
|
|
7074
|
-
watcher = createWatcher();
|
|
7075
|
-
}
|
|
7076
|
-
}
|
|
7077
|
-
/**
|
|
7078
|
-
* Watch the file or directory that is currently present
|
|
7079
|
-
* and when the watched file or directory is deleted, switch to missing file system entry watcher
|
|
7080
|
-
*/
|
|
7081
|
-
function watchPresentFileSystemEntry() {
|
|
7082
|
-
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
|
7083
|
-
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
|
7084
|
-
if (options === undefined) {
|
|
7085
|
-
if (fsSupportsRecursiveFsWatch) {
|
|
7086
|
-
options = { persistent: true, recursive: !!recursive };
|
|
7087
|
-
}
|
|
7088
|
-
else {
|
|
7089
|
-
options = { persistent: true };
|
|
7090
|
-
}
|
|
7091
|
-
}
|
|
7092
|
-
if (hitSystemWatcherLimit) {
|
|
7093
|
-
sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
|
|
7094
|
-
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
7095
|
-
}
|
|
7096
|
-
try {
|
|
7097
|
-
var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
|
|
7098
|
-
callbackChangingToMissingFileSystemEntry :
|
|
7099
|
-
callback);
|
|
7100
|
-
// Watch the missing file or directory or error
|
|
7101
|
-
presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
|
|
7102
|
-
return presentWatcher;
|
|
7103
|
-
}
|
|
7104
|
-
catch (e) {
|
|
7105
|
-
// Catch the exception and use polling instead
|
|
7106
|
-
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
7107
|
-
// so instead of throwing error, use fs.watchFile
|
|
7108
|
-
hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
|
|
7109
|
-
sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
|
|
7110
|
-
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
7111
|
-
}
|
|
7112
|
-
}
|
|
7113
|
-
function callbackChangingToMissingFileSystemEntry(event, relativeName) {
|
|
7114
|
-
// because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
|
|
7115
|
-
// Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
|
|
7116
|
-
return event === "rename" &&
|
|
7117
|
-
(!relativeName ||
|
|
7118
|
-
relativeName === lastDirectoryPart ||
|
|
7119
|
-
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
|
|
7120
|
-
!fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
|
7121
|
-
invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
|
|
7122
|
-
callback(event, relativeName);
|
|
7123
|
-
}
|
|
7124
|
-
/**
|
|
7125
|
-
* Watch the file or directory using fs.watchFile since fs.watch threw exception
|
|
7126
|
-
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
7127
|
-
*/
|
|
7128
|
-
function watchPresentFileSystemEntryWithFsWatchFile() {
|
|
7129
|
-
return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
|
|
7130
|
-
}
|
|
7131
|
-
/**
|
|
7132
|
-
* Watch the file or directory that is missing
|
|
7133
|
-
* and switch to existing file or directory when the missing filesystem entry is created
|
|
7134
|
-
*/
|
|
7135
|
-
function watchMissingFileSystemEntry() {
|
|
7136
|
-
return watchFile(fileOrDirectory, function (_fileName, eventKind) {
|
|
7137
|
-
if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
|
7138
|
-
// Call the callback for current file or directory
|
|
7139
|
-
// For now it could be callback for the inner directory creation,
|
|
7140
|
-
// but just return current directory, better than current no-op
|
|
7141
|
-
invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
|
|
7142
|
-
}
|
|
7143
|
-
}, fallbackPollingInterval, fallbackOptions);
|
|
7144
|
-
}
|
|
7148
|
+
function fsWatchWorker(fileOrDirectory, recursive, callback) {
|
|
7149
|
+
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
|
7150
|
+
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
|
7151
|
+
return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ?
|
|
7152
|
+
{ persistent: true, recursive: !!recursive } : { persistent: true }, callback);
|
|
7145
7153
|
}
|
|
7146
7154
|
function readFileWorker(fileName, _encoding) {
|
|
7147
7155
|
var buffer;
|
|
@@ -42048,7 +42056,7 @@ var ts;
|
|
|
42048
42056
|
}
|
|
42049
42057
|
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
42050
42058
|
return {
|
|
42051
|
-
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
42059
|
+
key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
|
|
42052
42060
|
flags: 1 /* Recursive */
|
|
42053
42061
|
};
|
|
42054
42062
|
}
|
|
@@ -48543,7 +48551,6 @@ var ts;
|
|
|
48543
48551
|
var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
48544
48552
|
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
|
|
48545
48553
|
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
48546
|
-
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
|
|
48547
48554
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
48548
48555
|
emptyGenericType.instantiations = new ts.Map();
|
|
48549
48556
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
@@ -58713,7 +58720,7 @@ var ts;
|
|
|
58713
58720
|
}
|
|
58714
58721
|
}
|
|
58715
58722
|
}
|
|
58716
|
-
else if (t.flags & 469892092 /* DisjointDomains */
|
|
58723
|
+
else if (t.flags & 469892092 /* DisjointDomains */) {
|
|
58717
58724
|
hasDisjointDomainType = true;
|
|
58718
58725
|
}
|
|
58719
58726
|
}
|
|
@@ -58725,7 +58732,7 @@ var ts;
|
|
|
58725
58732
|
// intersection operation to reduce the union constraints.
|
|
58726
58733
|
for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
|
|
58727
58734
|
var t = types_6[_a];
|
|
58728
|
-
if (t.flags & 469892092 /* DisjointDomains */
|
|
58735
|
+
if (t.flags & 469892092 /* DisjointDomains */) {
|
|
58729
58736
|
constraints = ts.append(constraints, t);
|
|
58730
58737
|
}
|
|
58731
58738
|
}
|
|
@@ -61274,7 +61281,7 @@ var ts;
|
|
|
61274
61281
|
}
|
|
61275
61282
|
return includes;
|
|
61276
61283
|
}
|
|
61277
|
-
function
|
|
61284
|
+
function removeRedundantPrimitiveTypes(types, includes) {
|
|
61278
61285
|
var i = types.length;
|
|
61279
61286
|
while (i > 0) {
|
|
61280
61287
|
i--;
|
|
@@ -61282,9 +61289,7 @@ var ts;
|
|
|
61282
61289
|
var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
|
|
61283
61290
|
t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
|
|
61284
61291
|
t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
|
|
61285
|
-
t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol
|
|
61286
|
-
t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ ||
|
|
61287
|
-
isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
|
|
61292
|
+
t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
|
|
61288
61293
|
if (remove) {
|
|
61289
61294
|
ts.orderedRemoveItemAt(types, i);
|
|
61290
61295
|
}
|
|
@@ -61406,7 +61411,7 @@ var ts;
|
|
|
61406
61411
|
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
|
61407
61412
|
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
|
61408
61413
|
// for intersections of types with signatures can be deterministic.
|
|
61409
|
-
function getIntersectionType(types, aliasSymbol, aliasTypeArguments
|
|
61414
|
+
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
61410
61415
|
var typeMembershipMap = new ts.Map();
|
|
61411
61416
|
var includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
61412
61417
|
var typeSet = ts.arrayFrom(typeMembershipMap.values());
|
|
@@ -61443,11 +61448,11 @@ var ts;
|
|
|
61443
61448
|
if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
|
|
61444
61449
|
includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
|
|
61445
61450
|
includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
|
|
61446
|
-
includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */
|
|
61447
|
-
|
|
61448
|
-
|
|
61449
|
-
|
|
61450
|
-
|
|
61451
|
+
includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
|
|
61452
|
+
removeRedundantPrimitiveTypes(typeSet, includes);
|
|
61453
|
+
}
|
|
61454
|
+
if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
|
|
61455
|
+
ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
|
|
61451
61456
|
}
|
|
61452
61457
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
61453
61458
|
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
@@ -61486,9 +61491,8 @@ var ts;
|
|
|
61486
61491
|
}
|
|
61487
61492
|
var constituents = getCrossProductIntersections(typeSet);
|
|
61488
61493
|
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
|
|
61489
|
-
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions)
|
|
61490
|
-
|
|
61491
|
-
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
61494
|
+
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
|
|
61495
|
+
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
61492
61496
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61493
61497
|
}
|
|
61494
61498
|
}
|
|
@@ -61531,21 +61535,11 @@ var ts;
|
|
|
61531
61535
|
}
|
|
61532
61536
|
return intersections;
|
|
61533
61537
|
}
|
|
61534
|
-
function getConstituentCount(type) {
|
|
61535
|
-
return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 :
|
|
61536
|
-
type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) :
|
|
61537
|
-
getConstituentCountOfTypes(type.types);
|
|
61538
|
-
}
|
|
61539
|
-
function getConstituentCountOfTypes(types) {
|
|
61540
|
-
return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0);
|
|
61541
|
-
}
|
|
61542
61538
|
function getTypeFromIntersectionTypeNode(node) {
|
|
61543
61539
|
var links = getNodeLinks(node);
|
|
61544
61540
|
if (!links.resolvedType) {
|
|
61545
61541
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61546
|
-
|
|
61547
|
-
var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType;
|
|
61548
|
-
links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
|
|
61542
|
+
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
61549
61543
|
}
|
|
61550
61544
|
return links.resolvedType;
|
|
61551
61545
|
}
|
|
@@ -64331,17 +64325,6 @@ var ts;
|
|
|
64331
64325
|
return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
|
|
64332
64326
|
type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
|
|
64333
64327
|
}
|
|
64334
|
-
function isUnknownLikeUnionType(type) {
|
|
64335
|
-
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
64336
|
-
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
64337
|
-
var types = type.types;
|
|
64338
|
-
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ &&
|
|
64339
|
-
types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
64340
|
-
}
|
|
64341
|
-
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
64342
|
-
}
|
|
64343
|
-
return false;
|
|
64344
|
-
}
|
|
64345
64328
|
function isStringIndexSignatureOnlyType(type) {
|
|
64346
64329
|
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
|
|
64347
64330
|
type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
|
|
@@ -64421,7 +64404,7 @@ var ts;
|
|
|
64421
64404
|
return true;
|
|
64422
64405
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
64423
64406
|
return true;
|
|
64424
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */
|
|
64407
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
64425
64408
|
return true;
|
|
64426
64409
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
64427
64410
|
if (s & 1 /* Any */)
|
|
@@ -64431,9 +64414,6 @@ var ts;
|
|
|
64431
64414
|
// bit-flag enum types sometimes look like literal enum types with numeric literal values.
|
|
64432
64415
|
if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
|
|
64433
64416
|
return true;
|
|
64434
|
-
// Anything is assignable to a union containing undefined, null, and {}
|
|
64435
|
-
if (isUnknownLikeUnionType(target))
|
|
64436
|
-
return true;
|
|
64437
64417
|
}
|
|
64438
64418
|
return false;
|
|
64439
64419
|
}
|
|
@@ -64476,27 +64456,16 @@ var ts;
|
|
|
64476
64456
|
function getNormalizedType(type, writing) {
|
|
64477
64457
|
while (true) {
|
|
64478
64458
|
var t = isFreshLiteralType(type) ? type.regularType :
|
|
64479
|
-
ts.getObjectFlags(type) & 4 /* Reference */
|
|
64480
|
-
type.flags & 3145728 /* UnionOrIntersection */ ?
|
|
64459
|
+
ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
|
|
64460
|
+
type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
|
|
64481
64461
|
type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
|
|
64482
64462
|
type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
|
|
64483
64463
|
type;
|
|
64464
|
+
t = getSingleBaseForNonAugmentingSubtype(t) || t;
|
|
64484
64465
|
if (t === type)
|
|
64485
|
-
|
|
64466
|
+
break;
|
|
64486
64467
|
type = t;
|
|
64487
64468
|
}
|
|
64488
|
-
}
|
|
64489
|
-
function getNormalizedUnionOrIntersectionType(type, writing) {
|
|
64490
|
-
var reduced = getReducedType(type);
|
|
64491
|
-
if (reduced !== type) {
|
|
64492
|
-
return reduced;
|
|
64493
|
-
}
|
|
64494
|
-
if (type.flags & 2097152 /* Intersection */) {
|
|
64495
|
-
var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); });
|
|
64496
|
-
if (normalizedTypes !== type.types) {
|
|
64497
|
-
return getIntersectionType(normalizedTypes);
|
|
64498
|
-
}
|
|
64499
|
-
}
|
|
64500
64469
|
return type;
|
|
64501
64470
|
}
|
|
64502
64471
|
/**
|
|
@@ -67495,22 +67464,20 @@ var ts;
|
|
|
67495
67464
|
return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
|
|
67496
67465
|
}
|
|
67497
67466
|
function getGlobalNonNullableTypeInstantiation(type) {
|
|
67467
|
+
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
|
67468
|
+
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
|
67469
|
+
// that isn't eliminated by a NonNullable<T> instantiation.
|
|
67470
|
+
var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
67498
67471
|
if (!deferredGlobalNonNullableTypeAlias) {
|
|
67499
67472
|
deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
|
|
67500
67473
|
}
|
|
67474
|
+
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
|
|
67501
67475
|
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
|
|
67502
|
-
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [
|
|
67503
|
-
|
|
67476
|
+
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
|
|
67477
|
+
reducedType;
|
|
67504
67478
|
}
|
|
67505
67479
|
function getNonNullableType(type) {
|
|
67506
|
-
|
|
67507
|
-
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
|
67508
|
-
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
|
67509
|
-
// that isn't eliminated by a NonNullable<T> instantiation.
|
|
67510
|
-
var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
67511
|
-
return maybeTypeOfKind(reducedType, 465829888 /* Instantiable */) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
|
|
67512
|
-
}
|
|
67513
|
-
return type;
|
|
67480
|
+
return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
|
|
67514
67481
|
}
|
|
67515
67482
|
function addOptionalTypeMarker(type) {
|
|
67516
67483
|
return strictNullChecks ? getUnionType([type, optionalType]) : type;
|
|
@@ -69541,24 +69508,6 @@ var ts;
|
|
|
69541
69508
|
function getTypeWithFacts(type, include) {
|
|
69542
69509
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
69543
69510
|
}
|
|
69544
|
-
function getIntersectionWithFacts(type, facts) {
|
|
69545
|
-
var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts));
|
|
69546
|
-
if (strictNullChecks) {
|
|
69547
|
-
switch (facts) {
|
|
69548
|
-
case 524288 /* NEUndefined */:
|
|
69549
|
-
return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; });
|
|
69550
|
-
case 1048576 /* NENull */:
|
|
69551
|
-
return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; });
|
|
69552
|
-
case 2097152 /* NEUndefinedOrNull */:
|
|
69553
|
-
case 4194304 /* Truthy */:
|
|
69554
|
-
return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; });
|
|
69555
|
-
}
|
|
69556
|
-
}
|
|
69557
|
-
return reduced;
|
|
69558
|
-
}
|
|
69559
|
-
function recombineUnknownType(type) {
|
|
69560
|
-
return type === unknownUnionType ? unknownType : type;
|
|
69561
|
-
}
|
|
69562
69511
|
function getTypeWithDefault(type, defaultExpression) {
|
|
69563
69512
|
return defaultExpression ?
|
|
69564
69513
|
getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) :
|
|
@@ -70616,7 +70565,7 @@ var ts;
|
|
|
70616
70565
|
if (isEvolvingArrayTypeList(types)) {
|
|
70617
70566
|
return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
|
|
70618
70567
|
}
|
|
70619
|
-
var result =
|
|
70568
|
+
var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
|
|
70620
70569
|
if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
|
|
70621
70570
|
return declaredType;
|
|
70622
70571
|
}
|
|
@@ -70718,7 +70667,8 @@ var ts;
|
|
|
70718
70667
|
}
|
|
70719
70668
|
function narrowTypeByTruthiness(type, expr, assumeTrue) {
|
|
70720
70669
|
if (isMatchingReference(reference, expr)) {
|
|
70721
|
-
return
|
|
70670
|
+
return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
|
|
70671
|
+
getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
|
|
70722
70672
|
}
|
|
70723
70673
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
|
|
70724
70674
|
type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
@@ -70871,6 +70821,9 @@ var ts;
|
|
|
70871
70821
|
assumeTrue = !assumeTrue;
|
|
70872
70822
|
}
|
|
70873
70823
|
var valueType = getTypeOfExpression(value);
|
|
70824
|
+
if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
|
|
70825
|
+
return getUnionType([nullType, undefinedType]);
|
|
70826
|
+
}
|
|
70874
70827
|
if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
|
|
70875
70828
|
if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
|
|
70876
70829
|
return valueType;
|
|
@@ -70890,7 +70843,7 @@ var ts;
|
|
|
70890
70843
|
valueType.flags & 65536 /* Null */ ?
|
|
70891
70844
|
assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
|
|
70892
70845
|
assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
70893
|
-
return
|
|
70846
|
+
return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
|
|
70894
70847
|
}
|
|
70895
70848
|
if (assumeTrue) {
|
|
70896
70849
|
var filterFn = operator === 34 /* EqualsEqualsToken */ ?
|
|
@@ -70918,11 +70871,17 @@ var ts;
|
|
|
70918
70871
|
if (type.flags & 1 /* Any */ && literal.text === "function") {
|
|
70919
70872
|
return type;
|
|
70920
70873
|
}
|
|
70874
|
+
if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
|
|
70875
|
+
// The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
|
|
70876
|
+
// from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
|
|
70877
|
+
// unknown type, and then narrows that to the non-primitive type.
|
|
70878
|
+
return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
|
|
70879
|
+
}
|
|
70921
70880
|
var facts = assumeTrue ?
|
|
70922
70881
|
typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
|
|
70923
70882
|
typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
|
|
70924
70883
|
var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
|
|
70925
|
-
return getTypeWithFacts(assumeTrue && impliedType ?
|
|
70884
|
+
return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
|
|
70926
70885
|
}
|
|
70927
70886
|
function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
|
|
70928
70887
|
var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
|
|
@@ -70971,10 +70930,10 @@ var ts;
|
|
|
70971
70930
|
}
|
|
70972
70931
|
function getImpliedTypeFromTypeofGuard(type, text) {
|
|
70973
70932
|
switch (text) {
|
|
70974
|
-
case "object":
|
|
70975
|
-
return type.flags & 1 /* Any */ ? type : getUnionType([nullType, nonPrimitiveType]);
|
|
70976
70933
|
case "function":
|
|
70977
70934
|
return type.flags & 1 /* Any */ ? type : globalFunctionType;
|
|
70935
|
+
case "object":
|
|
70936
|
+
return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
|
|
70978
70937
|
default:
|
|
70979
70938
|
return typeofTypesByName.get(text);
|
|
70980
70939
|
}
|
|
@@ -70985,27 +70944,22 @@ var ts;
|
|
|
70985
70944
|
// the guard. For example: narrowing `{} | undefined` by `"boolean"` should produce the type `boolean`, not
|
|
70986
70945
|
// the filtered type `{}`. For this reason we narrow constituents of the union individually, in addition to
|
|
70987
70946
|
// filtering by type-facts.
|
|
70988
|
-
function
|
|
70989
|
-
|
|
70990
|
-
|
|
70991
|
-
|
|
70992
|
-
return mapType(type, function (t) {
|
|
70993
|
-
if (isTypeRelatedTo(t, candidate, strictSubtypeRelation)) {
|
|
70994
|
-
return t;
|
|
70947
|
+
function narrowUnionMemberByTypeof(candidate) {
|
|
70948
|
+
return function (type) {
|
|
70949
|
+
if (isTypeSubtypeOf(type, candidate)) {
|
|
70950
|
+
return type;
|
|
70995
70951
|
}
|
|
70996
|
-
|
|
70997
|
-
|
|
70998
|
-
|
|
70999
|
-
|
|
71000
|
-
|
|
71001
|
-
|
|
71002
|
-
|
|
71003
|
-
if (c === globalFunctionType && isTypeSubtypeOf(c, t)) {
|
|
71004
|
-
return c;
|
|
70952
|
+
if (isTypeSubtypeOf(candidate, type)) {
|
|
70953
|
+
return candidate;
|
|
70954
|
+
}
|
|
70955
|
+
if (type.flags & 465829888 /* Instantiable */) {
|
|
70956
|
+
var constraint = getBaseConstraintOfType(type) || anyType;
|
|
70957
|
+
if (isTypeSubtypeOf(candidate, constraint)) {
|
|
70958
|
+
return getIntersectionType([type, candidate]);
|
|
71005
70959
|
}
|
|
71006
|
-
|
|
71007
|
-
|
|
71008
|
-
}
|
|
70960
|
+
}
|
|
70961
|
+
return type;
|
|
70962
|
+
};
|
|
71009
70963
|
}
|
|
71010
70964
|
function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
71011
70965
|
var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true);
|
|
@@ -71064,7 +71018,7 @@ var ts;
|
|
|
71064
71018
|
because it is caught in the first clause.
|
|
71065
71019
|
*/
|
|
71066
71020
|
var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
|
|
71067
|
-
return getTypeWithFacts(
|
|
71021
|
+
return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
|
|
71068
71022
|
}
|
|
71069
71023
|
function isMatchingConstructorReference(expr) {
|
|
71070
71024
|
return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
|
|
@@ -71368,9 +71322,7 @@ var ts;
|
|
|
71368
71322
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
71369
71323
|
}
|
|
71370
71324
|
function isGenericTypeWithUnionConstraint(type) {
|
|
71371
|
-
return type.flags &
|
|
71372
|
-
ts.some(type.types, isGenericTypeWithUnionConstraint) :
|
|
71373
|
-
!!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
71325
|
+
return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
71374
71326
|
}
|
|
71375
71327
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
71376
71328
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
@@ -71398,7 +71350,7 @@ var ts;
|
|
|
71398
71350
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
71399
71351
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
71400
71352
|
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
71401
|
-
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
71353
|
+
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
|
|
71402
71354
|
}
|
|
71403
71355
|
function isExportOrExportExpression(location) {
|
|
71404
71356
|
return !!ts.findAncestor(location, function (n) {
|
|
@@ -123708,6 +123660,7 @@ var ts;
|
|
|
123708
123660
|
}
|
|
123709
123661
|
function reloadFileNamesFromConfigFile() {
|
|
123710
123662
|
writeLog("Reloading new file names and options");
|
|
123663
|
+
reloadLevel = ts.ConfigFileProgramReloadLevel.None;
|
|
123711
123664
|
rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
|
123712
123665
|
if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
|
|
123713
123666
|
hasChangedConfigFileParsingErrors = true;
|
|
@@ -144026,6 +143979,10 @@ var ts;
|
|
|
144026
143979
|
}
|
|
144027
143980
|
var typeDisplayString = printTypeInSingleLine(declarationType);
|
|
144028
143981
|
if (typeDisplayString) {
|
|
143982
|
+
var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
|
|
143983
|
+
if (isVariableNameMatchesType) {
|
|
143984
|
+
return;
|
|
143985
|
+
}
|
|
144029
143986
|
addTypeHints(typeDisplayString, decl.name.end);
|
|
144030
143987
|
}
|
|
144031
143988
|
}
|