typescript 5.4.2 → 5.4.4
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 +114 -84
- package/lib/tsserver.js +184 -138
- package/lib/typescript.d.ts +5 -3
- package/lib/typescript.js +184 -138
- package/lib/typingsInstaller.js +28 -8
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -2340,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2340
2340
|
|
|
2341
2341
|
// src/compiler/corePublic.ts
|
|
2342
2342
|
var versionMajorMinor = "5.4";
|
|
2343
|
-
var version = "5.4.
|
|
2343
|
+
var version = "5.4.4";
|
|
2344
2344
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2345
2345
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2346
2346
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -7688,14 +7688,17 @@ function createDynamicPriorityPollingWatchFile(host) {
|
|
|
7688
7688
|
pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === 250 /* Low */ ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
|
|
7689
7689
|
}
|
|
7690
7690
|
}
|
|
7691
|
-
function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2) {
|
|
7691
|
+
function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp) {
|
|
7692
7692
|
const fileWatcherCallbacks = createMultiMap();
|
|
7693
|
+
const fileTimestamps = fsWatchWithTimestamp ? /* @__PURE__ */ new Map() : void 0;
|
|
7693
7694
|
const dirWatchers = /* @__PURE__ */ new Map();
|
|
7694
7695
|
const toCanonicalName = createGetCanonicalFileName(useCaseSensitiveFileNames2);
|
|
7695
7696
|
return nonPollingWatchFile;
|
|
7696
7697
|
function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
|
|
7697
7698
|
const filePath = toCanonicalName(fileName);
|
|
7698
|
-
fileWatcherCallbacks.add(filePath, callback)
|
|
7699
|
+
if (fileWatcherCallbacks.add(filePath, callback).length === 1 && fileTimestamps) {
|
|
7700
|
+
fileTimestamps.set(filePath, getModifiedTime3(fileName) || missingFileModifiedTime);
|
|
7701
|
+
}
|
|
7699
7702
|
const dirPath = getDirectoryPath(filePath) || ".";
|
|
7700
7703
|
const watcher = dirWatchers.get(dirPath) || createDirectoryWatcher(getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
|
|
7701
7704
|
watcher.referenceCount++;
|
|
@@ -7715,14 +7718,31 @@ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFi
|
|
|
7715
7718
|
const watcher = fsWatch(
|
|
7716
7719
|
dirName,
|
|
7717
7720
|
1 /* Directory */,
|
|
7718
|
-
(
|
|
7721
|
+
(eventName, relativeFileName) => {
|
|
7719
7722
|
if (!isString(relativeFileName))
|
|
7720
7723
|
return;
|
|
7721
7724
|
const fileName = getNormalizedAbsolutePath(relativeFileName, dirName);
|
|
7722
|
-
const
|
|
7725
|
+
const filePath = toCanonicalName(fileName);
|
|
7726
|
+
const callbacks = fileName && fileWatcherCallbacks.get(filePath);
|
|
7723
7727
|
if (callbacks) {
|
|
7728
|
+
let currentModifiedTime;
|
|
7729
|
+
let eventKind = 1 /* Changed */;
|
|
7730
|
+
if (fileTimestamps) {
|
|
7731
|
+
const existingTime = fileTimestamps.get(filePath);
|
|
7732
|
+
if (eventName === "change") {
|
|
7733
|
+
currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime;
|
|
7734
|
+
if (currentModifiedTime.getTime() === existingTime.getTime())
|
|
7735
|
+
return;
|
|
7736
|
+
}
|
|
7737
|
+
currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime);
|
|
7738
|
+
fileTimestamps.set(filePath, currentModifiedTime);
|
|
7739
|
+
if (existingTime === missingFileModifiedTime)
|
|
7740
|
+
eventKind = 0 /* Created */;
|
|
7741
|
+
else if (currentModifiedTime === missingFileModifiedTime)
|
|
7742
|
+
eventKind = 2 /* Deleted */;
|
|
7743
|
+
}
|
|
7724
7744
|
for (const fileCallback of callbacks) {
|
|
7725
|
-
fileCallback(fileName,
|
|
7745
|
+
fileCallback(fileName, eventKind, currentModifiedTime);
|
|
7726
7746
|
}
|
|
7727
7747
|
}
|
|
7728
7748
|
},
|
|
@@ -8121,7 +8141,7 @@ function createSystemWatchFunctions({
|
|
|
8121
8141
|
);
|
|
8122
8142
|
case 5 /* UseFsEventsOnParentDirectory */:
|
|
8123
8143
|
if (!nonPollingWatchFile) {
|
|
8124
|
-
nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2);
|
|
8144
|
+
nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp);
|
|
8125
8145
|
}
|
|
8126
8146
|
return nonPollingWatchFile(fileName, callback, pollingInterval, getFallbackOptions(options));
|
|
8127
8147
|
default:
|
|
@@ -8296,7 +8316,7 @@ function createSystemWatchFunctions({
|
|
|
8296
8316
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
8297
8317
|
}
|
|
8298
8318
|
try {
|
|
8299
|
-
const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
|
|
8319
|
+
const presentWatcher = (entryKind === 1 /* Directory */ || !fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
|
|
8300
8320
|
fileOrDirectory,
|
|
8301
8321
|
recursive,
|
|
8302
8322
|
inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
|
|
@@ -47606,13 +47626,21 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
47606
47626
|
}
|
|
47607
47627
|
const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
|
|
47608
47628
|
const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
|
|
47609
|
-
|
|
47629
|
+
const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
|
|
47630
|
+
if (!packageJsonPathsAreEqual(nearestTargetPackageJson, nearestSourcePackageJson, ignoreCase)) {
|
|
47610
47631
|
return maybeNonRelative;
|
|
47611
47632
|
}
|
|
47612
47633
|
return relativePath;
|
|
47613
47634
|
}
|
|
47614
47635
|
return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
|
|
47615
47636
|
}
|
|
47637
|
+
function packageJsonPathsAreEqual(a, b, ignoreCase) {
|
|
47638
|
+
if (a === b)
|
|
47639
|
+
return true;
|
|
47640
|
+
if (a === void 0 || b === void 0)
|
|
47641
|
+
return false;
|
|
47642
|
+
return comparePaths(a, b, ignoreCase) === 0 /* EqualTo */;
|
|
47643
|
+
}
|
|
47616
47644
|
function countPathComponents(path) {
|
|
47617
47645
|
let count = 0;
|
|
47618
47646
|
for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
|
|
@@ -52261,13 +52289,6 @@ function createTypeChecker(host) {
|
|
|
52261
52289
|
});
|
|
52262
52290
|
}
|
|
52263
52291
|
function getSymbolIfSameReference(s1, s2) {
|
|
52264
|
-
var _a, _b;
|
|
52265
|
-
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
52266
|
-
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
52267
|
-
}
|
|
52268
|
-
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
52269
|
-
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
52270
|
-
}
|
|
52271
52292
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
52272
52293
|
return s1;
|
|
52273
52294
|
}
|
|
@@ -52747,15 +52768,19 @@ function createTypeChecker(host) {
|
|
|
52747
52768
|
return true;
|
|
52748
52769
|
}
|
|
52749
52770
|
}
|
|
52750
|
-
function
|
|
52771
|
+
function getMeaningOfEntityNameReference(entityName) {
|
|
52751
52772
|
let meaning;
|
|
52752
52773
|
if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
|
|
52753
52774
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
52754
|
-
} else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */) {
|
|
52775
|
+
} else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */ || entityName.parent.kind === 166 /* QualifiedName */ && entityName.parent.left === entityName || entityName.parent.kind === 211 /* PropertyAccessExpression */ && entityName.parent.expression === entityName || entityName.parent.kind === 212 /* ElementAccessExpression */ && entityName.parent.expression === entityName) {
|
|
52755
52776
|
meaning = 1920 /* Namespace */;
|
|
52756
52777
|
} else {
|
|
52757
52778
|
meaning = 788968 /* Type */;
|
|
52758
52779
|
}
|
|
52780
|
+
return meaning;
|
|
52781
|
+
}
|
|
52782
|
+
function isEntityNameVisible(entityName, enclosingDeclaration) {
|
|
52783
|
+
const meaning = getMeaningOfEntityNameReference(entityName);
|
|
52759
52784
|
const firstIdentifier = getFirstIdentifier(entityName);
|
|
52760
52785
|
const symbol = resolveName(
|
|
52761
52786
|
enclosingDeclaration,
|
|
@@ -54816,9 +54841,10 @@ function createTypeChecker(host) {
|
|
|
54816
54841
|
introducesError = true;
|
|
54817
54842
|
return { introducesError, node };
|
|
54818
54843
|
}
|
|
54844
|
+
const meaning = getMeaningOfEntityNameReference(node);
|
|
54819
54845
|
const sym = resolveEntityName(
|
|
54820
54846
|
leftmost,
|
|
54821
|
-
|
|
54847
|
+
meaning,
|
|
54822
54848
|
/*ignoreErrors*/
|
|
54823
54849
|
true,
|
|
54824
54850
|
/*dontResolveAlias*/
|
|
@@ -54828,13 +54854,13 @@ function createTypeChecker(host) {
|
|
|
54828
54854
|
if (isSymbolAccessible(
|
|
54829
54855
|
sym,
|
|
54830
54856
|
context.enclosingDeclaration,
|
|
54831
|
-
|
|
54857
|
+
meaning,
|
|
54832
54858
|
/*shouldComputeAliasesToMakeVisible*/
|
|
54833
54859
|
false
|
|
54834
54860
|
).accessibility !== 0 /* Accessible */) {
|
|
54835
54861
|
introducesError = true;
|
|
54836
54862
|
} else {
|
|
54837
|
-
context.tracker.trackSymbol(sym, context.enclosingDeclaration,
|
|
54863
|
+
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
54838
54864
|
includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
|
|
54839
54865
|
}
|
|
54840
54866
|
if (isIdentifier(node)) {
|
|
@@ -60065,13 +60091,16 @@ function createTypeChecker(host) {
|
|
|
60065
60091
|
const constraint = getConstraintTypeFromMappedType(type);
|
|
60066
60092
|
if (constraint.flags & 4194304 /* Index */) {
|
|
60067
60093
|
const baseConstraint = getBaseConstraintOfType(constraint.type);
|
|
60068
|
-
if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
|
|
60094
|
+
if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
|
|
60069
60095
|
return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
|
|
60070
60096
|
}
|
|
60071
60097
|
}
|
|
60072
60098
|
}
|
|
60073
60099
|
return type;
|
|
60074
60100
|
}
|
|
60101
|
+
function isArrayOrTupleOrIntersection(type) {
|
|
60102
|
+
return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
|
|
60103
|
+
}
|
|
60075
60104
|
function isMappedTypeGenericIndexedAccess(type) {
|
|
60076
60105
|
let objectType;
|
|
60077
60106
|
return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
|
|
@@ -62710,7 +62739,7 @@ function createTypeChecker(host) {
|
|
|
62710
62739
|
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
62711
62740
|
const typeVariable = typeSet[typeVarIndex];
|
|
62712
62741
|
const primitiveType = typeSet[1 - typeVarIndex];
|
|
62713
|
-
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62742
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62714
62743
|
const constraint = getBaseConstraintOfType(typeVariable);
|
|
62715
62744
|
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
62716
62745
|
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
@@ -62738,6 +62767,9 @@ function createTypeChecker(host) {
|
|
|
62738
62767
|
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
62739
62768
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
62740
62769
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
62770
|
+
} else if (typeSet.length >= 4) {
|
|
62771
|
+
const middle = Math.floor(typeSet.length / 2);
|
|
62772
|
+
result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle)), getIntersectionType(typeSet.slice(middle))], aliasSymbol, aliasTypeArguments);
|
|
62741
62773
|
} else {
|
|
62742
62774
|
if (!checkCrossProductUnion(typeSet)) {
|
|
62743
62775
|
return errorType;
|
|
@@ -63318,6 +63350,9 @@ function createTypeChecker(host) {
|
|
|
63318
63350
|
function isPatternLiteralType(type) {
|
|
63319
63351
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
63320
63352
|
}
|
|
63353
|
+
function isGenericStringLikeType(type) {
|
|
63354
|
+
return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
|
|
63355
|
+
}
|
|
63321
63356
|
function isGenericType(type) {
|
|
63322
63357
|
return !!getGenericObjectFlags(type);
|
|
63323
63358
|
}
|
|
@@ -63340,7 +63375,7 @@ function createTypeChecker(host) {
|
|
|
63340
63375
|
}
|
|
63341
63376
|
return type.objectFlags & 12582912 /* IsGenericType */;
|
|
63342
63377
|
}
|
|
63343
|
-
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */
|
|
63378
|
+
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
63344
63379
|
}
|
|
63345
63380
|
function getSimplifiedType(type, writing) {
|
|
63346
63381
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
|
|
@@ -64439,29 +64474,28 @@ function createTypeChecker(host) {
|
|
|
64439
64474
|
if (typeVariable) {
|
|
64440
64475
|
const mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
64441
64476
|
if (typeVariable !== mappedTypeVariable) {
|
|
64442
|
-
return mapTypeWithAlias(
|
|
64443
|
-
getReducedType(mappedTypeVariable),
|
|
64444
|
-
(t) => {
|
|
64445
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
64446
|
-
if (!type.declaration.nameType) {
|
|
64447
|
-
let constraint;
|
|
64448
|
-
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
|
|
64449
|
-
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
64450
|
-
}
|
|
64451
|
-
if (isTupleType(t)) {
|
|
64452
|
-
return instantiateMappedTupleType(t, type, typeVariable, mapper);
|
|
64453
|
-
}
|
|
64454
|
-
}
|
|
64455
|
-
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
64456
|
-
}
|
|
64457
|
-
return t;
|
|
64458
|
-
},
|
|
64459
|
-
aliasSymbol,
|
|
64460
|
-
aliasTypeArguments
|
|
64461
|
-
);
|
|
64477
|
+
return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
|
|
64462
64478
|
}
|
|
64463
64479
|
}
|
|
64464
64480
|
return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
|
|
64481
|
+
function instantiateConstituent(t) {
|
|
64482
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
64483
|
+
if (!type.declaration.nameType) {
|
|
64484
|
+
let constraint;
|
|
64485
|
+
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
|
|
64486
|
+
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
64487
|
+
}
|
|
64488
|
+
if (isTupleType(t)) {
|
|
64489
|
+
return instantiateMappedTupleType(t, type, typeVariable, mapper);
|
|
64490
|
+
}
|
|
64491
|
+
if (isArrayOrTupleOrIntersection(t)) {
|
|
64492
|
+
return getIntersectionType(map(t.types, instantiateConstituent));
|
|
64493
|
+
}
|
|
64494
|
+
}
|
|
64495
|
+
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
64496
|
+
}
|
|
64497
|
+
return t;
|
|
64498
|
+
}
|
|
64465
64499
|
}
|
|
64466
64500
|
function getModifiedReadonlyState(state, modifiers) {
|
|
64467
64501
|
return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
|
|
@@ -70388,7 +70422,7 @@ function createTypeChecker(host) {
|
|
|
70388
70422
|
function hasMatchingArgument(expression, reference) {
|
|
70389
70423
|
if (expression.arguments) {
|
|
70390
70424
|
for (const argument of expression.arguments) {
|
|
70391
|
-
if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)
|
|
70425
|
+
if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
|
|
70392
70426
|
return true;
|
|
70393
70427
|
}
|
|
70394
70428
|
}
|
|
@@ -70398,36 +70432,6 @@ function createTypeChecker(host) {
|
|
|
70398
70432
|
}
|
|
70399
70433
|
return false;
|
|
70400
70434
|
}
|
|
70401
|
-
function getCandidateDiscriminantPropertyAccess(expr, reference) {
|
|
70402
|
-
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
|
|
70403
|
-
if (isIdentifier(expr)) {
|
|
70404
|
-
const symbol = getResolvedSymbol(expr);
|
|
70405
|
-
const declaration = symbol.valueDeclaration;
|
|
70406
|
-
if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
70407
|
-
return declaration;
|
|
70408
|
-
}
|
|
70409
|
-
}
|
|
70410
|
-
} else if (isAccessExpression(expr)) {
|
|
70411
|
-
if (isMatchingReference(reference, expr.expression)) {
|
|
70412
|
-
return expr;
|
|
70413
|
-
}
|
|
70414
|
-
} else if (isIdentifier(expr)) {
|
|
70415
|
-
const symbol = getResolvedSymbol(expr);
|
|
70416
|
-
if (isConstantVariable(symbol)) {
|
|
70417
|
-
const declaration = symbol.valueDeclaration;
|
|
70418
|
-
if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
|
|
70419
|
-
return declaration.initializer;
|
|
70420
|
-
}
|
|
70421
|
-
if (isBindingElement(declaration) && !declaration.initializer) {
|
|
70422
|
-
const parent2 = declaration.parent.parent;
|
|
70423
|
-
if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
|
|
70424
|
-
return declaration;
|
|
70425
|
-
}
|
|
70426
|
-
}
|
|
70427
|
-
}
|
|
70428
|
-
}
|
|
70429
|
-
return void 0;
|
|
70430
|
-
}
|
|
70431
70435
|
function getFlowNodeId(flow) {
|
|
70432
70436
|
if (!flow.id || flow.id < 0) {
|
|
70433
70437
|
flow.id = nextFlowId;
|
|
@@ -71527,9 +71531,39 @@ function createTypeChecker(host) {
|
|
|
71527
71531
|
}
|
|
71528
71532
|
return result;
|
|
71529
71533
|
}
|
|
71534
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
71535
|
+
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
|
|
71536
|
+
if (isIdentifier(expr)) {
|
|
71537
|
+
const symbol = getResolvedSymbol(expr);
|
|
71538
|
+
const declaration = symbol.valueDeclaration;
|
|
71539
|
+
if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
71540
|
+
return declaration;
|
|
71541
|
+
}
|
|
71542
|
+
}
|
|
71543
|
+
} else if (isAccessExpression(expr)) {
|
|
71544
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
71545
|
+
return expr;
|
|
71546
|
+
}
|
|
71547
|
+
} else if (isIdentifier(expr)) {
|
|
71548
|
+
const symbol = getResolvedSymbol(expr);
|
|
71549
|
+
if (isConstantVariable(symbol)) {
|
|
71550
|
+
const declaration = symbol.valueDeclaration;
|
|
71551
|
+
if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
|
|
71552
|
+
return declaration.initializer;
|
|
71553
|
+
}
|
|
71554
|
+
if (isBindingElement(declaration) && !declaration.initializer) {
|
|
71555
|
+
const parent2 = declaration.parent.parent;
|
|
71556
|
+
if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
|
|
71557
|
+
return declaration;
|
|
71558
|
+
}
|
|
71559
|
+
}
|
|
71560
|
+
}
|
|
71561
|
+
}
|
|
71562
|
+
return void 0;
|
|
71563
|
+
}
|
|
71530
71564
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
71531
71565
|
if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
|
|
71532
|
-
const access = getCandidateDiscriminantPropertyAccess(expr
|
|
71566
|
+
const access = getCandidateDiscriminantPropertyAccess(expr);
|
|
71533
71567
|
if (access) {
|
|
71534
71568
|
const name = getAccessedPropertyName(access);
|
|
71535
71569
|
if (name) {
|
|
@@ -77250,7 +77284,7 @@ function createTypeChecker(host) {
|
|
|
77250
77284
|
}
|
|
77251
77285
|
return resolveErrorCall(node);
|
|
77252
77286
|
}
|
|
77253
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
77287
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
77254
77288
|
skippedGenericFunction(node, checkMode);
|
|
77255
77289
|
return resolvingSignature;
|
|
77256
77290
|
}
|
|
@@ -77260,12 +77294,8 @@ function createTypeChecker(host) {
|
|
|
77260
77294
|
}
|
|
77261
77295
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
77262
77296
|
}
|
|
77263
|
-
function
|
|
77264
|
-
|
|
77265
|
-
return false;
|
|
77266
|
-
}
|
|
77267
|
-
const returnType = getReturnTypeOfSignature(signature);
|
|
77268
|
-
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
77297
|
+
function isGenericFunctionReturningFunction(signature) {
|
|
77298
|
+
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
77269
77299
|
}
|
|
77270
77300
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
77271
77301
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -85422,7 +85452,7 @@ function createTypeChecker(host) {
|
|
|
85422
85452
|
error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
85423
85453
|
} else {
|
|
85424
85454
|
const text = getTextOfPropertyName(member.name);
|
|
85425
|
-
if (isNumericLiteralName(text)) {
|
|
85455
|
+
if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
|
|
85426
85456
|
error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
85427
85457
|
}
|
|
85428
85458
|
}
|
|
@@ -160734,10 +160764,7 @@ function getContextualType(previousToken, position, sourceFile, checker) {
|
|
|
160734
160764
|
return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
|
|
160735
160765
|
default:
|
|
160736
160766
|
const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
|
|
160737
|
-
return argInfo ? (
|
|
160738
|
-
// At `,`, treat this as the next argument after the comma.
|
|
160739
|
-
checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
|
|
160740
|
-
) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
|
|
160767
|
+
return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
|
|
160741
160768
|
// completion at `x ===/**/` should be for the right side
|
|
160742
160769
|
checker.getTypeAtLocation(parent2.left)
|
|
160743
160770
|
) : checker.getContextualType(previousToken, 4 /* Completions */) || checker.getContextualType(previousToken);
|
|
@@ -169105,12 +169132,7 @@ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
|
|
|
169105
169132
|
if (!info)
|
|
169106
169133
|
return void 0;
|
|
169107
169134
|
const { list, argumentIndex } = info;
|
|
169108
|
-
const argumentCount = getArgumentCount(
|
|
169109
|
-
list,
|
|
169110
|
-
/*ignoreTrailingComma*/
|
|
169111
|
-
isInString(sourceFile, position, node),
|
|
169112
|
-
checker
|
|
169113
|
-
);
|
|
169135
|
+
const argumentCount = getArgumentCount(checker, list);
|
|
169114
169136
|
if (argumentIndex !== 0) {
|
|
169115
169137
|
Debug.assertLessThan(argumentIndex, argumentCount);
|
|
169116
169138
|
}
|
|
@@ -169122,7 +169144,7 @@ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
|
|
|
169122
169144
|
return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
|
|
169123
169145
|
} else {
|
|
169124
169146
|
const list = findContainingList(node);
|
|
169125
|
-
return list && { list, argumentIndex: getArgumentIndex(list, node
|
|
169147
|
+
return list && { list, argumentIndex: getArgumentIndex(checker, list, node) };
|
|
169126
169148
|
}
|
|
169127
169149
|
}
|
|
169128
169150
|
function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
|
|
@@ -169252,24 +169274,6 @@ function chooseBetterSymbol(s) {
|
|
|
169252
169274
|
return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
|
|
169253
169275
|
}) || s : s;
|
|
169254
169276
|
}
|
|
169255
|
-
function getArgumentIndex(argumentsList, node, checker) {
|
|
169256
|
-
const args = argumentsList.getChildren();
|
|
169257
|
-
let argumentIndex = 0;
|
|
169258
|
-
for (let pos = 0; pos < length(args); pos++) {
|
|
169259
|
-
const child = args[pos];
|
|
169260
|
-
if (child === node) {
|
|
169261
|
-
break;
|
|
169262
|
-
}
|
|
169263
|
-
if (isSpreadElement(child)) {
|
|
169264
|
-
argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
|
|
169265
|
-
} else {
|
|
169266
|
-
if (child.kind !== 28 /* CommaToken */) {
|
|
169267
|
-
argumentIndex++;
|
|
169268
|
-
}
|
|
169269
|
-
}
|
|
169270
|
-
}
|
|
169271
|
-
return argumentIndex;
|
|
169272
|
-
}
|
|
169273
169277
|
function getSpreadElementCount(node, checker) {
|
|
169274
169278
|
const spreadType = checker.getTypeAtLocation(node.expression);
|
|
169275
169279
|
if (checker.isTupleType(spreadType)) {
|
|
@@ -169282,19 +169286,48 @@ function getSpreadElementCount(node, checker) {
|
|
|
169282
169286
|
}
|
|
169283
169287
|
return 0;
|
|
169284
169288
|
}
|
|
169285
|
-
function
|
|
169286
|
-
|
|
169287
|
-
|
|
169288
|
-
|
|
169289
|
+
function getArgumentIndex(checker, argumentsList, node) {
|
|
169290
|
+
return getArgumentIndexOrCount(checker, argumentsList, node);
|
|
169291
|
+
}
|
|
169292
|
+
function getArgumentCount(checker, argumentsList) {
|
|
169293
|
+
return getArgumentIndexOrCount(
|
|
169294
|
+
checker,
|
|
169295
|
+
argumentsList,
|
|
169296
|
+
/*node*/
|
|
169297
|
+
void 0
|
|
169298
|
+
);
|
|
169299
|
+
}
|
|
169300
|
+
function getArgumentIndexOrCount(checker, argumentsList, node) {
|
|
169301
|
+
const args = argumentsList.getChildren();
|
|
169302
|
+
let argumentIndex = 0;
|
|
169303
|
+
let skipComma = false;
|
|
169304
|
+
for (const child of args) {
|
|
169305
|
+
if (node && child === node) {
|
|
169306
|
+
if (!skipComma && child.kind === 28 /* CommaToken */) {
|
|
169307
|
+
argumentIndex++;
|
|
169308
|
+
}
|
|
169309
|
+
return argumentIndex;
|
|
169310
|
+
}
|
|
169289
169311
|
if (isSpreadElement(child)) {
|
|
169290
|
-
|
|
169312
|
+
argumentIndex += getSpreadElementCount(child, checker);
|
|
169313
|
+
skipComma = true;
|
|
169314
|
+
continue;
|
|
169315
|
+
}
|
|
169316
|
+
if (child.kind !== 28 /* CommaToken */) {
|
|
169317
|
+
argumentIndex++;
|
|
169318
|
+
skipComma = true;
|
|
169319
|
+
continue;
|
|
169291
169320
|
}
|
|
169321
|
+
if (skipComma) {
|
|
169322
|
+
skipComma = false;
|
|
169323
|
+
continue;
|
|
169324
|
+
}
|
|
169325
|
+
argumentIndex++;
|
|
169292
169326
|
}
|
|
169293
|
-
|
|
169294
|
-
|
|
169295
|
-
argumentCount++;
|
|
169327
|
+
if (node) {
|
|
169328
|
+
return argumentIndex;
|
|
169296
169329
|
}
|
|
169297
|
-
return
|
|
169330
|
+
return args.length && last(args).kind === 28 /* CommaToken */ ? argumentIndex + 1 : argumentIndex;
|
|
169298
169331
|
}
|
|
169299
169332
|
function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) {
|
|
169300
169333
|
Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
|
|
@@ -181094,7 +181127,16 @@ function createWatchFactoryHostUsingWatchEvents(service, canUseWatchEvents) {
|
|
|
181094
181127
|
recursive ? watchedDirectoriesRecursive : watchedDirectories,
|
|
181095
181128
|
path,
|
|
181096
181129
|
callback,
|
|
181097
|
-
(id) => ({
|
|
181130
|
+
(id) => ({
|
|
181131
|
+
eventName: CreateDirectoryWatcherEvent,
|
|
181132
|
+
data: {
|
|
181133
|
+
id,
|
|
181134
|
+
path,
|
|
181135
|
+
recursive: !!recursive,
|
|
181136
|
+
// Special case node_modules as we watch it for changes to closed script infos as well
|
|
181137
|
+
ignoreUpdate: !path.endsWith("/node_modules") ? true : void 0
|
|
181138
|
+
}
|
|
181139
|
+
})
|
|
181098
181140
|
);
|
|
181099
181141
|
}
|
|
181100
181142
|
function getOrCreateFileWatcher({ pathToId, idToCallbacks }, path, callback, event) {
|
|
@@ -181121,24 +181163,28 @@ function createWatchFactoryHostUsingWatchEvents(service, canUseWatchEvents) {
|
|
|
181121
181163
|
}
|
|
181122
181164
|
};
|
|
181123
181165
|
}
|
|
181124
|
-
function onWatchChange(
|
|
181125
|
-
|
|
181126
|
-
|
|
181127
|
-
|
|
181166
|
+
function onWatchChange(args) {
|
|
181167
|
+
if (isArray(args))
|
|
181168
|
+
args.forEach(onWatchChangeRequestArgs);
|
|
181169
|
+
else
|
|
181170
|
+
onWatchChangeRequestArgs(args);
|
|
181128
181171
|
}
|
|
181129
|
-
function
|
|
181130
|
-
|
|
181131
|
-
(
|
|
181132
|
-
|
|
181133
|
-
callback(eventPath, eventKind);
|
|
181134
|
-
});
|
|
181172
|
+
function onWatchChangeRequestArgs({ id, created, deleted, updated }) {
|
|
181173
|
+
onWatchEventType(id, created, 0 /* Created */);
|
|
181174
|
+
onWatchEventType(id, deleted, 2 /* Deleted */);
|
|
181175
|
+
onWatchEventType(id, updated, 1 /* Changed */);
|
|
181135
181176
|
}
|
|
181136
|
-
function
|
|
181137
|
-
|
|
181138
|
-
if (eventType === "update")
|
|
181177
|
+
function onWatchEventType(id, paths, eventKind) {
|
|
181178
|
+
if (!(paths == null ? void 0 : paths.length))
|
|
181139
181179
|
return;
|
|
181140
|
-
(
|
|
181141
|
-
|
|
181180
|
+
forEachCallback(watchedFiles, id, paths, (callback, eventPath) => callback(eventPath, eventKind));
|
|
181181
|
+
forEachCallback(watchedDirectories, id, paths, (callback, eventPath) => callback(eventPath));
|
|
181182
|
+
forEachCallback(watchedDirectoriesRecursive, id, paths, (callback, eventPath) => callback(eventPath));
|
|
181183
|
+
}
|
|
181184
|
+
function forEachCallback(hostWatcherMap, id, eventPaths, cb) {
|
|
181185
|
+
var _a;
|
|
181186
|
+
(_a = hostWatcherMap.idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
|
|
181187
|
+
eventPaths.forEach((eventPath) => cb(callback, normalizeSlashes(eventPath)));
|
|
181142
181188
|
});
|
|
181143
181189
|
}
|
|
181144
181190
|
}
|
package/lib/typescript.d.ts
CHANGED
|
@@ -1510,12 +1510,13 @@ declare namespace ts {
|
|
|
1510
1510
|
}
|
|
1511
1511
|
interface WatchChangeRequest extends Request {
|
|
1512
1512
|
command: CommandTypes.WatchChange;
|
|
1513
|
-
arguments: WatchChangeRequestArgs;
|
|
1513
|
+
arguments: WatchChangeRequestArgs | readonly WatchChangeRequestArgs[];
|
|
1514
1514
|
}
|
|
1515
1515
|
interface WatchChangeRequestArgs {
|
|
1516
1516
|
id: number;
|
|
1517
|
-
|
|
1518
|
-
|
|
1517
|
+
created?: string[];
|
|
1518
|
+
deleted?: string[];
|
|
1519
|
+
updated?: string[];
|
|
1519
1520
|
}
|
|
1520
1521
|
/**
|
|
1521
1522
|
* Request to obtain the list of files that should be regenerated if target file is recompiled.
|
|
@@ -2452,6 +2453,7 @@ declare namespace ts {
|
|
|
2452
2453
|
readonly id: number;
|
|
2453
2454
|
readonly path: string;
|
|
2454
2455
|
readonly recursive: boolean;
|
|
2456
|
+
readonly ignoreUpdate?: boolean;
|
|
2455
2457
|
}
|
|
2456
2458
|
type CloseFileWatcherEventName = "closeFileWatcher";
|
|
2457
2459
|
interface CloseFileWatcherEvent extends Event {
|