typescript 5.4.2 → 5.4.5
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 +119 -91
- package/lib/tsserver.js +191 -146
- package/lib/typescript.d.ts +5 -3
- package/lib/typescript.js +191 -146
- 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.5";
|
|
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)) {
|
|
@@ -60062,16 +60088,17 @@ function createTypeChecker(host) {
|
|
|
60062
60088
|
const target = type.target ?? type;
|
|
60063
60089
|
const typeVariable = getHomomorphicTypeVariable(target);
|
|
60064
60090
|
if (typeVariable && !target.declaration.nameType) {
|
|
60065
|
-
const
|
|
60066
|
-
|
|
60067
|
-
|
|
60068
|
-
|
|
60069
|
-
return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
|
|
60070
|
-
}
|
|
60091
|
+
const modifiersType = getModifiersTypeFromMappedType(type);
|
|
60092
|
+
const baseConstraint = isGenericMappedType(modifiersType) ? getApparentTypeOfMappedType(modifiersType) : getBaseConstraintOfType(modifiersType);
|
|
60093
|
+
if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
|
|
60094
|
+
return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
|
|
60071
60095
|
}
|
|
60072
60096
|
}
|
|
60073
60097
|
return type;
|
|
60074
60098
|
}
|
|
60099
|
+
function isArrayOrTupleOrIntersection(type) {
|
|
60100
|
+
return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
|
|
60101
|
+
}
|
|
60075
60102
|
function isMappedTypeGenericIndexedAccess(type) {
|
|
60076
60103
|
let objectType;
|
|
60077
60104
|
return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
|
|
@@ -60225,13 +60252,13 @@ function createTypeChecker(host) {
|
|
|
60225
60252
|
}
|
|
60226
60253
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
60227
60254
|
var _a, _b, _c;
|
|
60228
|
-
let property = (
|
|
60255
|
+
let property = skipObjectFunctionPropertyAugment ? (_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name) : (_b = type.propertyCache) == null ? void 0 : _b.get(name);
|
|
60229
60256
|
if (!property) {
|
|
60230
60257
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
60231
60258
|
if (property) {
|
|
60232
60259
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
60233
60260
|
properties.set(name, property);
|
|
60234
|
-
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
60261
|
+
if (skipObjectFunctionPropertyAugment && !(getCheckFlags(property) & 48 /* Partial */) && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
60235
60262
|
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
60236
60263
|
properties2.set(name, property);
|
|
60237
60264
|
}
|
|
@@ -62710,7 +62737,7 @@ function createTypeChecker(host) {
|
|
|
62710
62737
|
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
62711
62738
|
const typeVariable = typeSet[typeVarIndex];
|
|
62712
62739
|
const primitiveType = typeSet[1 - typeVarIndex];
|
|
62713
|
-
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62740
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62714
62741
|
const constraint = getBaseConstraintOfType(typeVariable);
|
|
62715
62742
|
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
62716
62743
|
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
@@ -62738,6 +62765,9 @@ function createTypeChecker(host) {
|
|
|
62738
62765
|
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
62739
62766
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
62740
62767
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
62768
|
+
} else if (typeSet.length >= 4) {
|
|
62769
|
+
const middle = Math.floor(typeSet.length / 2);
|
|
62770
|
+
result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle)), getIntersectionType(typeSet.slice(middle))], aliasSymbol, aliasTypeArguments);
|
|
62741
62771
|
} else {
|
|
62742
62772
|
if (!checkCrossProductUnion(typeSet)) {
|
|
62743
62773
|
return errorType;
|
|
@@ -63318,6 +63348,9 @@ function createTypeChecker(host) {
|
|
|
63318
63348
|
function isPatternLiteralType(type) {
|
|
63319
63349
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
63320
63350
|
}
|
|
63351
|
+
function isGenericStringLikeType(type) {
|
|
63352
|
+
return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
|
|
63353
|
+
}
|
|
63321
63354
|
function isGenericType(type) {
|
|
63322
63355
|
return !!getGenericObjectFlags(type);
|
|
63323
63356
|
}
|
|
@@ -63340,7 +63373,7 @@ function createTypeChecker(host) {
|
|
|
63340
63373
|
}
|
|
63341
63374
|
return type.objectFlags & 12582912 /* IsGenericType */;
|
|
63342
63375
|
}
|
|
63343
|
-
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */
|
|
63376
|
+
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
63344
63377
|
}
|
|
63345
63378
|
function getSimplifiedType(type, writing) {
|
|
63346
63379
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
|
|
@@ -64439,29 +64472,28 @@ function createTypeChecker(host) {
|
|
|
64439
64472
|
if (typeVariable) {
|
|
64440
64473
|
const mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
64441
64474
|
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
|
-
);
|
|
64475
|
+
return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
|
|
64462
64476
|
}
|
|
64463
64477
|
}
|
|
64464
64478
|
return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
|
|
64479
|
+
function instantiateConstituent(t) {
|
|
64480
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
64481
|
+
if (!type.declaration.nameType) {
|
|
64482
|
+
let constraint;
|
|
64483
|
+
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
|
|
64484
|
+
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
64485
|
+
}
|
|
64486
|
+
if (isTupleType(t)) {
|
|
64487
|
+
return instantiateMappedTupleType(t, type, typeVariable, mapper);
|
|
64488
|
+
}
|
|
64489
|
+
if (isArrayOrTupleOrIntersection(t)) {
|
|
64490
|
+
return getIntersectionType(map(t.types, instantiateConstituent));
|
|
64491
|
+
}
|
|
64492
|
+
}
|
|
64493
|
+
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
64494
|
+
}
|
|
64495
|
+
return t;
|
|
64496
|
+
}
|
|
64465
64497
|
}
|
|
64466
64498
|
function getModifiedReadonlyState(state, modifiers) {
|
|
64467
64499
|
return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
|
|
@@ -70388,7 +70420,7 @@ function createTypeChecker(host) {
|
|
|
70388
70420
|
function hasMatchingArgument(expression, reference) {
|
|
70389
70421
|
if (expression.arguments) {
|
|
70390
70422
|
for (const argument of expression.arguments) {
|
|
70391
|
-
if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)
|
|
70423
|
+
if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
|
|
70392
70424
|
return true;
|
|
70393
70425
|
}
|
|
70394
70426
|
}
|
|
@@ -70398,36 +70430,6 @@ function createTypeChecker(host) {
|
|
|
70398
70430
|
}
|
|
70399
70431
|
return false;
|
|
70400
70432
|
}
|
|
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
70433
|
function getFlowNodeId(flow) {
|
|
70432
70434
|
if (!flow.id || flow.id < 0) {
|
|
70433
70435
|
flow.id = nextFlowId;
|
|
@@ -71527,9 +71529,39 @@ function createTypeChecker(host) {
|
|
|
71527
71529
|
}
|
|
71528
71530
|
return result;
|
|
71529
71531
|
}
|
|
71532
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
71533
|
+
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
|
|
71534
|
+
if (isIdentifier(expr)) {
|
|
71535
|
+
const symbol = getResolvedSymbol(expr);
|
|
71536
|
+
const declaration = symbol.valueDeclaration;
|
|
71537
|
+
if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
71538
|
+
return declaration;
|
|
71539
|
+
}
|
|
71540
|
+
}
|
|
71541
|
+
} else if (isAccessExpression(expr)) {
|
|
71542
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
71543
|
+
return expr;
|
|
71544
|
+
}
|
|
71545
|
+
} else if (isIdentifier(expr)) {
|
|
71546
|
+
const symbol = getResolvedSymbol(expr);
|
|
71547
|
+
if (isConstantVariable(symbol)) {
|
|
71548
|
+
const declaration = symbol.valueDeclaration;
|
|
71549
|
+
if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
|
|
71550
|
+
return declaration.initializer;
|
|
71551
|
+
}
|
|
71552
|
+
if (isBindingElement(declaration) && !declaration.initializer) {
|
|
71553
|
+
const parent2 = declaration.parent.parent;
|
|
71554
|
+
if (isVariableDeclaration(parent2) && !parent2.type && parent2.initializer && (isIdentifier(parent2.initializer) || isAccessExpression(parent2.initializer)) && isMatchingReference(reference, parent2.initializer)) {
|
|
71555
|
+
return declaration;
|
|
71556
|
+
}
|
|
71557
|
+
}
|
|
71558
|
+
}
|
|
71559
|
+
}
|
|
71560
|
+
return void 0;
|
|
71561
|
+
}
|
|
71530
71562
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
71531
71563
|
if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
|
|
71532
|
-
const access = getCandidateDiscriminantPropertyAccess(expr
|
|
71564
|
+
const access = getCandidateDiscriminantPropertyAccess(expr);
|
|
71533
71565
|
if (access) {
|
|
71534
71566
|
const name = getAccessedPropertyName(access);
|
|
71535
71567
|
if (name) {
|
|
@@ -77250,7 +77282,7 @@ function createTypeChecker(host) {
|
|
|
77250
77282
|
}
|
|
77251
77283
|
return resolveErrorCall(node);
|
|
77252
77284
|
}
|
|
77253
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
77285
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
77254
77286
|
skippedGenericFunction(node, checkMode);
|
|
77255
77287
|
return resolvingSignature;
|
|
77256
77288
|
}
|
|
@@ -77260,12 +77292,8 @@ function createTypeChecker(host) {
|
|
|
77260
77292
|
}
|
|
77261
77293
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
77262
77294
|
}
|
|
77263
|
-
function
|
|
77264
|
-
|
|
77265
|
-
return false;
|
|
77266
|
-
}
|
|
77267
|
-
const returnType = getReturnTypeOfSignature(signature);
|
|
77268
|
-
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
77295
|
+
function isGenericFunctionReturningFunction(signature) {
|
|
77296
|
+
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
77269
77297
|
}
|
|
77270
77298
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
77271
77299
|
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 +85450,7 @@ function createTypeChecker(host) {
|
|
|
85422
85450
|
error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
85423
85451
|
} else {
|
|
85424
85452
|
const text = getTextOfPropertyName(member.name);
|
|
85425
|
-
if (isNumericLiteralName(text)) {
|
|
85453
|
+
if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
|
|
85426
85454
|
error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
85427
85455
|
}
|
|
85428
85456
|
}
|
|
@@ -160429,7 +160457,8 @@ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, con
|
|
|
160429
160457
|
}
|
|
160430
160458
|
function symbolAppearsToBeTypeOnly(symbol) {
|
|
160431
160459
|
var _a;
|
|
160432
|
-
|
|
160460
|
+
const flags = getCombinedLocalAndExportSymbolFlags(skipAlias(symbol, typeChecker));
|
|
160461
|
+
return !(flags & 111551 /* Value */) && (!isInJSFile((_a = symbol.declarations) == null ? void 0 : _a[0]) || !!(flags & 788968 /* Type */));
|
|
160433
160462
|
}
|
|
160434
160463
|
}
|
|
160435
160464
|
function getLabelCompletionAtPosition(node) {
|
|
@@ -160734,10 +160763,7 @@ function getContextualType(previousToken, position, sourceFile, checker) {
|
|
|
160734
160763
|
return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
|
|
160735
160764
|
default:
|
|
160736
160765
|
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) ? (
|
|
160766
|
+
return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
|
|
160741
160767
|
// completion at `x ===/**/` should be for the right side
|
|
160742
160768
|
checker.getTypeAtLocation(parent2.left)
|
|
160743
160769
|
) : checker.getContextualType(previousToken, 4 /* Completions */) || checker.getContextualType(previousToken);
|
|
@@ -169105,12 +169131,7 @@ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
|
|
|
169105
169131
|
if (!info)
|
|
169106
169132
|
return void 0;
|
|
169107
169133
|
const { list, argumentIndex } = info;
|
|
169108
|
-
const argumentCount = getArgumentCount(
|
|
169109
|
-
list,
|
|
169110
|
-
/*ignoreTrailingComma*/
|
|
169111
|
-
isInString(sourceFile, position, node),
|
|
169112
|
-
checker
|
|
169113
|
-
);
|
|
169134
|
+
const argumentCount = getArgumentCount(checker, list);
|
|
169114
169135
|
if (argumentIndex !== 0) {
|
|
169115
169136
|
Debug.assertLessThan(argumentIndex, argumentCount);
|
|
169116
169137
|
}
|
|
@@ -169122,7 +169143,7 @@ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
|
|
|
169122
169143
|
return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
|
|
169123
169144
|
} else {
|
|
169124
169145
|
const list = findContainingList(node);
|
|
169125
|
-
return list && { list, argumentIndex: getArgumentIndex(list, node
|
|
169146
|
+
return list && { list, argumentIndex: getArgumentIndex(checker, list, node) };
|
|
169126
169147
|
}
|
|
169127
169148
|
}
|
|
169128
169149
|
function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
|
|
@@ -169252,24 +169273,6 @@ function chooseBetterSymbol(s) {
|
|
|
169252
169273
|
return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
|
|
169253
169274
|
}) || s : s;
|
|
169254
169275
|
}
|
|
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
169276
|
function getSpreadElementCount(node, checker) {
|
|
169274
169277
|
const spreadType = checker.getTypeAtLocation(node.expression);
|
|
169275
169278
|
if (checker.isTupleType(spreadType)) {
|
|
@@ -169282,19 +169285,48 @@ function getSpreadElementCount(node, checker) {
|
|
|
169282
169285
|
}
|
|
169283
169286
|
return 0;
|
|
169284
169287
|
}
|
|
169285
|
-
function
|
|
169286
|
-
|
|
169287
|
-
|
|
169288
|
-
|
|
169288
|
+
function getArgumentIndex(checker, argumentsList, node) {
|
|
169289
|
+
return getArgumentIndexOrCount(checker, argumentsList, node);
|
|
169290
|
+
}
|
|
169291
|
+
function getArgumentCount(checker, argumentsList) {
|
|
169292
|
+
return getArgumentIndexOrCount(
|
|
169293
|
+
checker,
|
|
169294
|
+
argumentsList,
|
|
169295
|
+
/*node*/
|
|
169296
|
+
void 0
|
|
169297
|
+
);
|
|
169298
|
+
}
|
|
169299
|
+
function getArgumentIndexOrCount(checker, argumentsList, node) {
|
|
169300
|
+
const args = argumentsList.getChildren();
|
|
169301
|
+
let argumentIndex = 0;
|
|
169302
|
+
let skipComma = false;
|
|
169303
|
+
for (const child of args) {
|
|
169304
|
+
if (node && child === node) {
|
|
169305
|
+
if (!skipComma && child.kind === 28 /* CommaToken */) {
|
|
169306
|
+
argumentIndex++;
|
|
169307
|
+
}
|
|
169308
|
+
return argumentIndex;
|
|
169309
|
+
}
|
|
169289
169310
|
if (isSpreadElement(child)) {
|
|
169290
|
-
|
|
169311
|
+
argumentIndex += getSpreadElementCount(child, checker);
|
|
169312
|
+
skipComma = true;
|
|
169313
|
+
continue;
|
|
169314
|
+
}
|
|
169315
|
+
if (child.kind !== 28 /* CommaToken */) {
|
|
169316
|
+
argumentIndex++;
|
|
169317
|
+
skipComma = true;
|
|
169318
|
+
continue;
|
|
169319
|
+
}
|
|
169320
|
+
if (skipComma) {
|
|
169321
|
+
skipComma = false;
|
|
169322
|
+
continue;
|
|
169291
169323
|
}
|
|
169324
|
+
argumentIndex++;
|
|
169292
169325
|
}
|
|
169293
|
-
|
|
169294
|
-
|
|
169295
|
-
argumentCount++;
|
|
169326
|
+
if (node) {
|
|
169327
|
+
return argumentIndex;
|
|
169296
169328
|
}
|
|
169297
|
-
return
|
|
169329
|
+
return args.length && last(args).kind === 28 /* CommaToken */ ? argumentIndex + 1 : argumentIndex;
|
|
169298
169330
|
}
|
|
169299
169331
|
function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) {
|
|
169300
169332
|
Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
|
|
@@ -181094,7 +181126,16 @@ function createWatchFactoryHostUsingWatchEvents(service, canUseWatchEvents) {
|
|
|
181094
181126
|
recursive ? watchedDirectoriesRecursive : watchedDirectories,
|
|
181095
181127
|
path,
|
|
181096
181128
|
callback,
|
|
181097
|
-
(id) => ({
|
|
181129
|
+
(id) => ({
|
|
181130
|
+
eventName: CreateDirectoryWatcherEvent,
|
|
181131
|
+
data: {
|
|
181132
|
+
id,
|
|
181133
|
+
path,
|
|
181134
|
+
recursive: !!recursive,
|
|
181135
|
+
// Special case node_modules as we watch it for changes to closed script infos as well
|
|
181136
|
+
ignoreUpdate: !path.endsWith("/node_modules") ? true : void 0
|
|
181137
|
+
}
|
|
181138
|
+
})
|
|
181098
181139
|
);
|
|
181099
181140
|
}
|
|
181100
181141
|
function getOrCreateFileWatcher({ pathToId, idToCallbacks }, path, callback, event) {
|
|
@@ -181121,24 +181162,28 @@ function createWatchFactoryHostUsingWatchEvents(service, canUseWatchEvents) {
|
|
|
181121
181162
|
}
|
|
181122
181163
|
};
|
|
181123
181164
|
}
|
|
181124
|
-
function onWatchChange(
|
|
181125
|
-
|
|
181126
|
-
|
|
181127
|
-
|
|
181165
|
+
function onWatchChange(args) {
|
|
181166
|
+
if (isArray(args))
|
|
181167
|
+
args.forEach(onWatchChangeRequestArgs);
|
|
181168
|
+
else
|
|
181169
|
+
onWatchChangeRequestArgs(args);
|
|
181128
181170
|
}
|
|
181129
|
-
function
|
|
181130
|
-
|
|
181131
|
-
(
|
|
181132
|
-
|
|
181133
|
-
callback(eventPath, eventKind);
|
|
181134
|
-
});
|
|
181171
|
+
function onWatchChangeRequestArgs({ id, created, deleted, updated }) {
|
|
181172
|
+
onWatchEventType(id, created, 0 /* Created */);
|
|
181173
|
+
onWatchEventType(id, deleted, 2 /* Deleted */);
|
|
181174
|
+
onWatchEventType(id, updated, 1 /* Changed */);
|
|
181135
181175
|
}
|
|
181136
|
-
function
|
|
181137
|
-
|
|
181138
|
-
if (eventType === "update")
|
|
181176
|
+
function onWatchEventType(id, paths, eventKind) {
|
|
181177
|
+
if (!(paths == null ? void 0 : paths.length))
|
|
181139
181178
|
return;
|
|
181140
|
-
(
|
|
181141
|
-
|
|
181179
|
+
forEachCallback(watchedFiles, id, paths, (callback, eventPath) => callback(eventPath, eventKind));
|
|
181180
|
+
forEachCallback(watchedDirectories, id, paths, (callback, eventPath) => callback(eventPath));
|
|
181181
|
+
forEachCallback(watchedDirectoriesRecursive, id, paths, (callback, eventPath) => callback(eventPath));
|
|
181182
|
+
}
|
|
181183
|
+
function forEachCallback(hostWatcherMap, id, eventPaths, cb) {
|
|
181184
|
+
var _a;
|
|
181185
|
+
(_a = hostWatcherMap.idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
|
|
181186
|
+
eventPaths.forEach((eventPath) => cb(callback, normalizeSlashes(eventPath)));
|
|
181142
181187
|
});
|
|
181143
181188
|
}
|
|
181144
181189
|
}
|
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 {
|