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/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.4";
|
|
21
|
-
var version = "5.4.
|
|
21
|
+
var version = "5.4.5";
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -4145,14 +4145,17 @@ function createDynamicPriorityPollingWatchFile(host) {
|
|
|
4145
4145
|
pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === 250 /* Low */ ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === 250 /* Low */ ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
|
|
4146
4146
|
}
|
|
4147
4147
|
}
|
|
4148
|
-
function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2) {
|
|
4148
|
+
function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp) {
|
|
4149
4149
|
const fileWatcherCallbacks = createMultiMap();
|
|
4150
|
+
const fileTimestamps = fsWatchWithTimestamp ? /* @__PURE__ */ new Map() : void 0;
|
|
4150
4151
|
const dirWatchers = /* @__PURE__ */ new Map();
|
|
4151
4152
|
const toCanonicalName = createGetCanonicalFileName(useCaseSensitiveFileNames2);
|
|
4152
4153
|
return nonPollingWatchFile;
|
|
4153
4154
|
function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
|
|
4154
4155
|
const filePath = toCanonicalName(fileName);
|
|
4155
|
-
fileWatcherCallbacks.add(filePath, callback)
|
|
4156
|
+
if (fileWatcherCallbacks.add(filePath, callback).length === 1 && fileTimestamps) {
|
|
4157
|
+
fileTimestamps.set(filePath, getModifiedTime3(fileName) || missingFileModifiedTime);
|
|
4158
|
+
}
|
|
4156
4159
|
const dirPath = getDirectoryPath(filePath) || ".";
|
|
4157
4160
|
const watcher = dirWatchers.get(dirPath) || createDirectoryWatcher(getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
|
|
4158
4161
|
watcher.referenceCount++;
|
|
@@ -4172,14 +4175,31 @@ function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFi
|
|
|
4172
4175
|
const watcher = fsWatch(
|
|
4173
4176
|
dirName,
|
|
4174
4177
|
1 /* Directory */,
|
|
4175
|
-
(
|
|
4178
|
+
(eventName, relativeFileName) => {
|
|
4176
4179
|
if (!isString(relativeFileName))
|
|
4177
4180
|
return;
|
|
4178
4181
|
const fileName = getNormalizedAbsolutePath(relativeFileName, dirName);
|
|
4179
|
-
const
|
|
4182
|
+
const filePath = toCanonicalName(fileName);
|
|
4183
|
+
const callbacks = fileName && fileWatcherCallbacks.get(filePath);
|
|
4180
4184
|
if (callbacks) {
|
|
4185
|
+
let currentModifiedTime;
|
|
4186
|
+
let eventKind = 1 /* Changed */;
|
|
4187
|
+
if (fileTimestamps) {
|
|
4188
|
+
const existingTime = fileTimestamps.get(filePath);
|
|
4189
|
+
if (eventName === "change") {
|
|
4190
|
+
currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime;
|
|
4191
|
+
if (currentModifiedTime.getTime() === existingTime.getTime())
|
|
4192
|
+
return;
|
|
4193
|
+
}
|
|
4194
|
+
currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileName) || missingFileModifiedTime);
|
|
4195
|
+
fileTimestamps.set(filePath, currentModifiedTime);
|
|
4196
|
+
if (existingTime === missingFileModifiedTime)
|
|
4197
|
+
eventKind = 0 /* Created */;
|
|
4198
|
+
else if (currentModifiedTime === missingFileModifiedTime)
|
|
4199
|
+
eventKind = 2 /* Deleted */;
|
|
4200
|
+
}
|
|
4181
4201
|
for (const fileCallback of callbacks) {
|
|
4182
|
-
fileCallback(fileName,
|
|
4202
|
+
fileCallback(fileName, eventKind, currentModifiedTime);
|
|
4183
4203
|
}
|
|
4184
4204
|
}
|
|
4185
4205
|
},
|
|
@@ -4573,7 +4593,7 @@ function createSystemWatchFunctions({
|
|
|
4573
4593
|
);
|
|
4574
4594
|
case 5 /* UseFsEventsOnParentDirectory */:
|
|
4575
4595
|
if (!nonPollingWatchFile) {
|
|
4576
|
-
nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2);
|
|
4596
|
+
nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames2, getModifiedTime3, fsWatchWithTimestamp);
|
|
4577
4597
|
}
|
|
4578
4598
|
return nonPollingWatchFile(fileName, callback, pollingInterval, getFallbackOptions(options));
|
|
4579
4599
|
default:
|
|
@@ -4748,7 +4768,7 @@ function createSystemWatchFunctions({
|
|
|
4748
4768
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
4749
4769
|
}
|
|
4750
4770
|
try {
|
|
4751
|
-
const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
|
|
4771
|
+
const presentWatcher = (entryKind === 1 /* Directory */ || !fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
|
|
4752
4772
|
fileOrDirectory,
|
|
4753
4773
|
recursive,
|
|
4754
4774
|
inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
|
|
@@ -42862,13 +42882,21 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
42862
42882
|
}
|
|
42863
42883
|
const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
|
|
42864
42884
|
const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
|
|
42865
|
-
|
|
42885
|
+
const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
|
|
42886
|
+
if (!packageJsonPathsAreEqual(nearestTargetPackageJson, nearestSourcePackageJson, ignoreCase)) {
|
|
42866
42887
|
return maybeNonRelative;
|
|
42867
42888
|
}
|
|
42868
42889
|
return relativePath;
|
|
42869
42890
|
}
|
|
42870
42891
|
return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
|
|
42871
42892
|
}
|
|
42893
|
+
function packageJsonPathsAreEqual(a, b, ignoreCase) {
|
|
42894
|
+
if (a === b)
|
|
42895
|
+
return true;
|
|
42896
|
+
if (a === void 0 || b === void 0)
|
|
42897
|
+
return false;
|
|
42898
|
+
return comparePaths(a, b, ignoreCase) === 0 /* EqualTo */;
|
|
42899
|
+
}
|
|
42872
42900
|
function countPathComponents(path) {
|
|
42873
42901
|
let count = 0;
|
|
42874
42902
|
for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
|
|
@@ -47517,13 +47545,6 @@ function createTypeChecker(host) {
|
|
|
47517
47545
|
});
|
|
47518
47546
|
}
|
|
47519
47547
|
function getSymbolIfSameReference(s1, s2) {
|
|
47520
|
-
var _a, _b;
|
|
47521
|
-
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
47522
|
-
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
47523
|
-
}
|
|
47524
|
-
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
47525
|
-
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
47526
|
-
}
|
|
47527
47548
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
47528
47549
|
return s1;
|
|
47529
47550
|
}
|
|
@@ -48003,15 +48024,19 @@ function createTypeChecker(host) {
|
|
|
48003
48024
|
return true;
|
|
48004
48025
|
}
|
|
48005
48026
|
}
|
|
48006
|
-
function
|
|
48027
|
+
function getMeaningOfEntityNameReference(entityName) {
|
|
48007
48028
|
let meaning;
|
|
48008
48029
|
if (entityName.parent.kind === 186 /* TypeQuery */ || entityName.parent.kind === 233 /* ExpressionWithTypeArguments */ && !isPartOfTypeNode(entityName.parent) || entityName.parent.kind === 167 /* ComputedPropertyName */) {
|
|
48009
48030
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
48010
|
-
} else if (entityName.kind === 166 /* QualifiedName */ || entityName.kind === 211 /* PropertyAccessExpression */ || entityName.parent.kind === 271 /* ImportEqualsDeclaration */) {
|
|
48031
|
+
} 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) {
|
|
48011
48032
|
meaning = 1920 /* Namespace */;
|
|
48012
48033
|
} else {
|
|
48013
48034
|
meaning = 788968 /* Type */;
|
|
48014
48035
|
}
|
|
48036
|
+
return meaning;
|
|
48037
|
+
}
|
|
48038
|
+
function isEntityNameVisible(entityName, enclosingDeclaration) {
|
|
48039
|
+
const meaning = getMeaningOfEntityNameReference(entityName);
|
|
48015
48040
|
const firstIdentifier = getFirstIdentifier(entityName);
|
|
48016
48041
|
const symbol = resolveName(
|
|
48017
48042
|
enclosingDeclaration,
|
|
@@ -50072,9 +50097,10 @@ function createTypeChecker(host) {
|
|
|
50072
50097
|
introducesError = true;
|
|
50073
50098
|
return { introducesError, node };
|
|
50074
50099
|
}
|
|
50100
|
+
const meaning = getMeaningOfEntityNameReference(node);
|
|
50075
50101
|
const sym = resolveEntityName(
|
|
50076
50102
|
leftmost,
|
|
50077
|
-
|
|
50103
|
+
meaning,
|
|
50078
50104
|
/*ignoreErrors*/
|
|
50079
50105
|
true,
|
|
50080
50106
|
/*dontResolveAlias*/
|
|
@@ -50084,13 +50110,13 @@ function createTypeChecker(host) {
|
|
|
50084
50110
|
if (isSymbolAccessible(
|
|
50085
50111
|
sym,
|
|
50086
50112
|
context.enclosingDeclaration,
|
|
50087
|
-
|
|
50113
|
+
meaning,
|
|
50088
50114
|
/*shouldComputeAliasesToMakeVisible*/
|
|
50089
50115
|
false
|
|
50090
50116
|
).accessibility !== 0 /* Accessible */) {
|
|
50091
50117
|
introducesError = true;
|
|
50092
50118
|
} else {
|
|
50093
|
-
context.tracker.trackSymbol(sym, context.enclosingDeclaration,
|
|
50119
|
+
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
50094
50120
|
includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
|
|
50095
50121
|
}
|
|
50096
50122
|
if (isIdentifier(node)) {
|
|
@@ -55318,16 +55344,17 @@ function createTypeChecker(host) {
|
|
|
55318
55344
|
const target = type.target ?? type;
|
|
55319
55345
|
const typeVariable = getHomomorphicTypeVariable(target);
|
|
55320
55346
|
if (typeVariable && !target.declaration.nameType) {
|
|
55321
|
-
const
|
|
55322
|
-
|
|
55323
|
-
|
|
55324
|
-
|
|
55325
|
-
return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
|
|
55326
|
-
}
|
|
55347
|
+
const modifiersType = getModifiersTypeFromMappedType(type);
|
|
55348
|
+
const baseConstraint = isGenericMappedType(modifiersType) ? getApparentTypeOfMappedType(modifiersType) : getBaseConstraintOfType(modifiersType);
|
|
55349
|
+
if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
|
|
55350
|
+
return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
|
|
55327
55351
|
}
|
|
55328
55352
|
}
|
|
55329
55353
|
return type;
|
|
55330
55354
|
}
|
|
55355
|
+
function isArrayOrTupleOrIntersection(type) {
|
|
55356
|
+
return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
|
|
55357
|
+
}
|
|
55331
55358
|
function isMappedTypeGenericIndexedAccess(type) {
|
|
55332
55359
|
let objectType;
|
|
55333
55360
|
return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
|
|
@@ -55481,13 +55508,13 @@ function createTypeChecker(host) {
|
|
|
55481
55508
|
}
|
|
55482
55509
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
55483
55510
|
var _a, _b, _c;
|
|
55484
|
-
let property = (
|
|
55511
|
+
let property = skipObjectFunctionPropertyAugment ? (_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name) : (_b = type.propertyCache) == null ? void 0 : _b.get(name);
|
|
55485
55512
|
if (!property) {
|
|
55486
55513
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
55487
55514
|
if (property) {
|
|
55488
55515
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
55489
55516
|
properties.set(name, property);
|
|
55490
|
-
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
55517
|
+
if (skipObjectFunctionPropertyAugment && !(getCheckFlags(property) & 48 /* Partial */) && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
55491
55518
|
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
55492
55519
|
properties2.set(name, property);
|
|
55493
55520
|
}
|
|
@@ -57966,7 +57993,7 @@ function createTypeChecker(host) {
|
|
|
57966
57993
|
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57967
57994
|
const typeVariable = typeSet[typeVarIndex];
|
|
57968
57995
|
const primitiveType = typeSet[1 - typeVarIndex];
|
|
57969
|
-
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57996
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57970
57997
|
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57971
57998
|
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
57972
57999
|
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
@@ -57994,6 +58021,9 @@ function createTypeChecker(host) {
|
|
|
57994
58021
|
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
57995
58022
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
57996
58023
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58024
|
+
} else if (typeSet.length >= 4) {
|
|
58025
|
+
const middle = Math.floor(typeSet.length / 2);
|
|
58026
|
+
result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle)), getIntersectionType(typeSet.slice(middle))], aliasSymbol, aliasTypeArguments);
|
|
57997
58027
|
} else {
|
|
57998
58028
|
if (!checkCrossProductUnion(typeSet)) {
|
|
57999
58029
|
return errorType;
|
|
@@ -58574,6 +58604,9 @@ function createTypeChecker(host) {
|
|
|
58574
58604
|
function isPatternLiteralType(type) {
|
|
58575
58605
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
58576
58606
|
}
|
|
58607
|
+
function isGenericStringLikeType(type) {
|
|
58608
|
+
return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
|
|
58609
|
+
}
|
|
58577
58610
|
function isGenericType(type) {
|
|
58578
58611
|
return !!getGenericObjectFlags(type);
|
|
58579
58612
|
}
|
|
@@ -58596,7 +58629,7 @@ function createTypeChecker(host) {
|
|
|
58596
58629
|
}
|
|
58597
58630
|
return type.objectFlags & 12582912 /* IsGenericType */;
|
|
58598
58631
|
}
|
|
58599
|
-
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */
|
|
58632
|
+
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
58600
58633
|
}
|
|
58601
58634
|
function getSimplifiedType(type, writing) {
|
|
58602
58635
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
|
|
@@ -59695,29 +59728,28 @@ function createTypeChecker(host) {
|
|
|
59695
59728
|
if (typeVariable) {
|
|
59696
59729
|
const mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
59697
59730
|
if (typeVariable !== mappedTypeVariable) {
|
|
59698
|
-
return mapTypeWithAlias(
|
|
59699
|
-
getReducedType(mappedTypeVariable),
|
|
59700
|
-
(t) => {
|
|
59701
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
59702
|
-
if (!type.declaration.nameType) {
|
|
59703
|
-
let constraint;
|
|
59704
|
-
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
|
|
59705
|
-
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
59706
|
-
}
|
|
59707
|
-
if (isTupleType(t)) {
|
|
59708
|
-
return instantiateMappedTupleType(t, type, typeVariable, mapper);
|
|
59709
|
-
}
|
|
59710
|
-
}
|
|
59711
|
-
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
59712
|
-
}
|
|
59713
|
-
return t;
|
|
59714
|
-
},
|
|
59715
|
-
aliasSymbol,
|
|
59716
|
-
aliasTypeArguments
|
|
59717
|
-
);
|
|
59731
|
+
return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
|
|
59718
59732
|
}
|
|
59719
59733
|
}
|
|
59720
59734
|
return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
|
|
59735
|
+
function instantiateConstituent(t) {
|
|
59736
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
59737
|
+
if (!type.declaration.nameType) {
|
|
59738
|
+
let constraint;
|
|
59739
|
+
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
|
|
59740
|
+
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
59741
|
+
}
|
|
59742
|
+
if (isTupleType(t)) {
|
|
59743
|
+
return instantiateMappedTupleType(t, type, typeVariable, mapper);
|
|
59744
|
+
}
|
|
59745
|
+
if (isArrayOrTupleOrIntersection(t)) {
|
|
59746
|
+
return getIntersectionType(map(t.types, instantiateConstituent));
|
|
59747
|
+
}
|
|
59748
|
+
}
|
|
59749
|
+
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
59750
|
+
}
|
|
59751
|
+
return t;
|
|
59752
|
+
}
|
|
59721
59753
|
}
|
|
59722
59754
|
function getModifiedReadonlyState(state, modifiers) {
|
|
59723
59755
|
return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
|
|
@@ -65644,7 +65676,7 @@ function createTypeChecker(host) {
|
|
|
65644
65676
|
function hasMatchingArgument(expression, reference) {
|
|
65645
65677
|
if (expression.arguments) {
|
|
65646
65678
|
for (const argument of expression.arguments) {
|
|
65647
|
-
if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)
|
|
65679
|
+
if (isOrContainsMatchingReference(reference, argument) || optionalChainContainsReference(argument, reference)) {
|
|
65648
65680
|
return true;
|
|
65649
65681
|
}
|
|
65650
65682
|
}
|
|
@@ -65654,36 +65686,6 @@ function createTypeChecker(host) {
|
|
|
65654
65686
|
}
|
|
65655
65687
|
return false;
|
|
65656
65688
|
}
|
|
65657
|
-
function getCandidateDiscriminantPropertyAccess(expr, reference) {
|
|
65658
|
-
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
|
|
65659
|
-
if (isIdentifier(expr)) {
|
|
65660
|
-
const symbol = getResolvedSymbol(expr);
|
|
65661
|
-
const declaration = symbol.valueDeclaration;
|
|
65662
|
-
if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
65663
|
-
return declaration;
|
|
65664
|
-
}
|
|
65665
|
-
}
|
|
65666
|
-
} else if (isAccessExpression(expr)) {
|
|
65667
|
-
if (isMatchingReference(reference, expr.expression)) {
|
|
65668
|
-
return expr;
|
|
65669
|
-
}
|
|
65670
|
-
} else if (isIdentifier(expr)) {
|
|
65671
|
-
const symbol = getResolvedSymbol(expr);
|
|
65672
|
-
if (isConstantVariable(symbol)) {
|
|
65673
|
-
const declaration = symbol.valueDeclaration;
|
|
65674
|
-
if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
|
|
65675
|
-
return declaration.initializer;
|
|
65676
|
-
}
|
|
65677
|
-
if (isBindingElement(declaration) && !declaration.initializer) {
|
|
65678
|
-
const parent = declaration.parent.parent;
|
|
65679
|
-
if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
|
|
65680
|
-
return declaration;
|
|
65681
|
-
}
|
|
65682
|
-
}
|
|
65683
|
-
}
|
|
65684
|
-
}
|
|
65685
|
-
return void 0;
|
|
65686
|
-
}
|
|
65687
65689
|
function getFlowNodeId(flow) {
|
|
65688
65690
|
if (!flow.id || flow.id < 0) {
|
|
65689
65691
|
flow.id = nextFlowId;
|
|
@@ -66783,9 +66785,39 @@ function createTypeChecker(host) {
|
|
|
66783
66785
|
}
|
|
66784
66786
|
return result;
|
|
66785
66787
|
}
|
|
66788
|
+
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
66789
|
+
if (isBindingPattern(reference) || isFunctionExpressionOrArrowFunction(reference) || isObjectLiteralMethod(reference)) {
|
|
66790
|
+
if (isIdentifier(expr)) {
|
|
66791
|
+
const symbol = getResolvedSymbol(expr);
|
|
66792
|
+
const declaration = symbol.valueDeclaration;
|
|
66793
|
+
if (declaration && (isBindingElement(declaration) || isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
66794
|
+
return declaration;
|
|
66795
|
+
}
|
|
66796
|
+
}
|
|
66797
|
+
} else if (isAccessExpression(expr)) {
|
|
66798
|
+
if (isMatchingReference(reference, expr.expression)) {
|
|
66799
|
+
return expr;
|
|
66800
|
+
}
|
|
66801
|
+
} else if (isIdentifier(expr)) {
|
|
66802
|
+
const symbol = getResolvedSymbol(expr);
|
|
66803
|
+
if (isConstantVariable(symbol)) {
|
|
66804
|
+
const declaration = symbol.valueDeclaration;
|
|
66805
|
+
if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && isMatchingReference(reference, declaration.initializer.expression)) {
|
|
66806
|
+
return declaration.initializer;
|
|
66807
|
+
}
|
|
66808
|
+
if (isBindingElement(declaration) && !declaration.initializer) {
|
|
66809
|
+
const parent = declaration.parent.parent;
|
|
66810
|
+
if (isVariableDeclaration(parent) && !parent.type && parent.initializer && (isIdentifier(parent.initializer) || isAccessExpression(parent.initializer)) && isMatchingReference(reference, parent.initializer)) {
|
|
66811
|
+
return declaration;
|
|
66812
|
+
}
|
|
66813
|
+
}
|
|
66814
|
+
}
|
|
66815
|
+
}
|
|
66816
|
+
return void 0;
|
|
66817
|
+
}
|
|
66786
66818
|
function getDiscriminantPropertyAccess(expr, computedType) {
|
|
66787
66819
|
if (declaredType.flags & 1048576 /* Union */ || computedType.flags & 1048576 /* Union */) {
|
|
66788
|
-
const access = getCandidateDiscriminantPropertyAccess(expr
|
|
66820
|
+
const access = getCandidateDiscriminantPropertyAccess(expr);
|
|
66789
66821
|
if (access) {
|
|
66790
66822
|
const name = getAccessedPropertyName(access);
|
|
66791
66823
|
if (name) {
|
|
@@ -72506,7 +72538,7 @@ function createTypeChecker(host) {
|
|
|
72506
72538
|
}
|
|
72507
72539
|
return resolveErrorCall(node);
|
|
72508
72540
|
}
|
|
72509
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
72541
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
72510
72542
|
skippedGenericFunction(node, checkMode);
|
|
72511
72543
|
return resolvingSignature;
|
|
72512
72544
|
}
|
|
@@ -72516,12 +72548,8 @@ function createTypeChecker(host) {
|
|
|
72516
72548
|
}
|
|
72517
72549
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
72518
72550
|
}
|
|
72519
|
-
function
|
|
72520
|
-
|
|
72521
|
-
return false;
|
|
72522
|
-
}
|
|
72523
|
-
const returnType = getReturnTypeOfSignature(signature);
|
|
72524
|
-
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
72551
|
+
function isGenericFunctionReturningFunction(signature) {
|
|
72552
|
+
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
72525
72553
|
}
|
|
72526
72554
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
72527
72555
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -80678,7 +80706,7 @@ function createTypeChecker(host) {
|
|
|
80678
80706
|
error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
80679
80707
|
} else {
|
|
80680
80708
|
const text = getTextOfPropertyName(member.name);
|
|
80681
|
-
if (isNumericLiteralName(text)) {
|
|
80709
|
+
if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
|
|
80682
80710
|
error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
80683
80711
|
}
|
|
80684
80712
|
}
|