typescript 5.4.0-dev.20231130 → 5.4.0-dev.20231201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.es2020.string.d.ts +1 -1
- package/lib/tsc.js +127 -22
- package/lib/tsserver.js +128 -23
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +128 -23
- package/lib/typingsInstaller.js +3 -1
- package/package.json +2 -2
|
@@ -24,7 +24,7 @@ interface String {
|
|
|
24
24
|
* containing the results of that search.
|
|
25
25
|
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
|
|
26
26
|
*/
|
|
27
|
-
matchAll(regexp: RegExp): IterableIterator<
|
|
27
|
+
matchAll(regexp: RegExp): IterableIterator<RegExpExecArray>;
|
|
28
28
|
|
|
29
29
|
/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
|
|
30
30
|
toLocaleLowerCase(locales?: Intl.LocalesArgument): string;
|
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 = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20231201`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -3671,6 +3671,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3671
3671
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
3672
3672
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
3673
3673
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
3674
|
+
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
|
|
3674
3675
|
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
3675
3676
|
return TypeFlags2;
|
|
3676
3677
|
})(TypeFlags || {});
|
|
@@ -3717,6 +3718,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
3717
3718
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
3718
3719
|
ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
3719
3720
|
ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
|
|
3721
|
+
ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
|
|
3720
3722
|
return ObjectFlags3;
|
|
3721
3723
|
})(ObjectFlags || {});
|
|
3722
3724
|
var SignatureFlags = /* @__PURE__ */ ((SignatureFlags4) => {
|
|
@@ -46974,6 +46976,10 @@ function createTypeChecker(host) {
|
|
|
46974
46976
|
function getParentOfSymbol(symbol) {
|
|
46975
46977
|
return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
|
|
46976
46978
|
}
|
|
46979
|
+
function getFunctionExpressionParentSymbolOrSymbol(symbol) {
|
|
46980
|
+
var _a, _b;
|
|
46981
|
+
return ((_a = symbol.valueDeclaration) == null ? void 0 : _a.kind) === 219 /* ArrowFunction */ || ((_b = symbol.valueDeclaration) == null ? void 0 : _b.kind) === 218 /* FunctionExpression */ ? getSymbolOfNode(symbol.valueDeclaration.parent) || symbol : symbol;
|
|
46982
|
+
}
|
|
46977
46983
|
function getAlternativeContainingModules(symbol, enclosingDeclaration) {
|
|
46978
46984
|
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
|
46979
46985
|
const id = getNodeId(containingFile);
|
|
@@ -52197,11 +52203,14 @@ function createTypeChecker(host) {
|
|
|
52197
52203
|
}
|
|
52198
52204
|
}
|
|
52199
52205
|
if ((_a = symbol.parent) == null ? void 0 : _a.valueDeclaration) {
|
|
52200
|
-
const
|
|
52201
|
-
if (
|
|
52202
|
-
const
|
|
52203
|
-
if (
|
|
52204
|
-
|
|
52206
|
+
const possiblyAnnotatedSymbol = getFunctionExpressionParentSymbolOrSymbol(symbol.parent);
|
|
52207
|
+
if (possiblyAnnotatedSymbol.valueDeclaration) {
|
|
52208
|
+
const typeNode2 = getEffectiveTypeAnnotationNode(possiblyAnnotatedSymbol.valueDeclaration);
|
|
52209
|
+
if (typeNode2) {
|
|
52210
|
+
const annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode2), symbol.escapedName);
|
|
52211
|
+
if (annotationSymbol) {
|
|
52212
|
+
return getNonMissingTypeOfSymbol(annotationSymbol);
|
|
52213
|
+
}
|
|
52205
52214
|
}
|
|
52206
52215
|
}
|
|
52207
52216
|
}
|
|
@@ -53501,7 +53510,6 @@ function createTypeChecker(host) {
|
|
|
53501
53510
|
return links.resolvedSymbol;
|
|
53502
53511
|
}
|
|
53503
53512
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
53504
|
-
var _a, _b, _c;
|
|
53505
53513
|
const links = getSymbolLinks(symbol);
|
|
53506
53514
|
if (!links[resolutionKind]) {
|
|
53507
53515
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -53520,7 +53528,7 @@ function createTypeChecker(host) {
|
|
|
53520
53528
|
}
|
|
53521
53529
|
}
|
|
53522
53530
|
}
|
|
53523
|
-
const assignments = (
|
|
53531
|
+
const assignments = getFunctionExpressionParentSymbolOrSymbol(symbol).assignmentDeclarationMembers;
|
|
53524
53532
|
if (assignments) {
|
|
53525
53533
|
const decls = arrayFrom(assignments.values());
|
|
53526
53534
|
for (const member of decls) {
|
|
@@ -53817,6 +53825,15 @@ function createTypeChecker(host) {
|
|
|
53817
53825
|
let result;
|
|
53818
53826
|
for (let i = 0; i < signatureLists.length; i++) {
|
|
53819
53827
|
const match = i === listIndex ? signature : findMatchingSignature(
|
|
53828
|
+
signatureLists[i],
|
|
53829
|
+
signature,
|
|
53830
|
+
/*partialMatch*/
|
|
53831
|
+
false,
|
|
53832
|
+
/*ignoreThisTypes*/
|
|
53833
|
+
false,
|
|
53834
|
+
/*ignoreReturnTypes*/
|
|
53835
|
+
true
|
|
53836
|
+
) || findMatchingSignature(
|
|
53820
53837
|
signatureLists[i],
|
|
53821
53838
|
signature,
|
|
53822
53839
|
/*partialMatch*/
|
|
@@ -54190,6 +54207,18 @@ function createTypeChecker(host) {
|
|
|
54190
54207
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
54191
54208
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
54192
54209
|
}
|
|
54210
|
+
function getLimitedConstraint(type) {
|
|
54211
|
+
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
54212
|
+
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
54213
|
+
return;
|
|
54214
|
+
}
|
|
54215
|
+
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
54216
|
+
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
54217
|
+
return;
|
|
54218
|
+
}
|
|
54219
|
+
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
54220
|
+
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
54221
|
+
}
|
|
54193
54222
|
function resolveReverseMappedTypeMembers(type) {
|
|
54194
54223
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
54195
54224
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -54197,7 +54226,14 @@ function createTypeChecker(host) {
|
|
|
54197
54226
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
54198
54227
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
54199
54228
|
const members = createSymbolTable();
|
|
54229
|
+
const limitedConstraint = getLimitedConstraint(type);
|
|
54200
54230
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
54231
|
+
if (limitedConstraint) {
|
|
54232
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
54233
|
+
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
54234
|
+
continue;
|
|
54235
|
+
}
|
|
54236
|
+
}
|
|
54201
54237
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
54202
54238
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
54203
54239
|
inferredProp.declarations = prop.declarations;
|
|
@@ -54278,7 +54314,7 @@ function createTypeChecker(host) {
|
|
|
54278
54314
|
const constraintType = getConstraintTypeFromMappedType(type);
|
|
54279
54315
|
const mappedType = type.target || type;
|
|
54280
54316
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
54281
|
-
const shouldLinkPropDeclarations =
|
|
54317
|
+
const shouldLinkPropDeclarations = getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */;
|
|
54282
54318
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
54283
54319
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
54284
54320
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
@@ -54420,9 +54456,12 @@ function createTypeChecker(host) {
|
|
|
54420
54456
|
}
|
|
54421
54457
|
return false;
|
|
54422
54458
|
}
|
|
54423
|
-
function
|
|
54459
|
+
function getMappedTypeNameTypeKind(type) {
|
|
54424
54460
|
const nameType = getNameTypeFromMappedType(type);
|
|
54425
|
-
|
|
54461
|
+
if (!nameType) {
|
|
54462
|
+
return 0 /* None */;
|
|
54463
|
+
}
|
|
54464
|
+
return isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)) ? 1 /* Filtering */ : 2 /* Remapping */;
|
|
54426
54465
|
}
|
|
54427
54466
|
function resolveStructuredTypeMembers(type) {
|
|
54428
54467
|
if (!type.members) {
|
|
@@ -56958,6 +56997,8 @@ function createTypeChecker(host) {
|
|
|
56958
56997
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
56959
56998
|
if (flags & 465829888 /* Instantiable */)
|
|
56960
56999
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
57000
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
57001
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
56961
57002
|
if (type === wildcardType)
|
|
56962
57003
|
includes |= 8388608 /* IncludesWildcard */;
|
|
56963
57004
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -57062,6 +57103,41 @@ function createTypeChecker(host) {
|
|
|
57062
57103
|
}
|
|
57063
57104
|
}
|
|
57064
57105
|
}
|
|
57106
|
+
function removeConstrainedTypeVariables(types) {
|
|
57107
|
+
const typeVariables = [];
|
|
57108
|
+
for (const type of types) {
|
|
57109
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57110
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57111
|
+
pushIfUnique(typeVariables, type.types[index]);
|
|
57112
|
+
}
|
|
57113
|
+
}
|
|
57114
|
+
for (const typeVariable of typeVariables) {
|
|
57115
|
+
const primitives = [];
|
|
57116
|
+
for (const type of types) {
|
|
57117
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57118
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57119
|
+
if (type.types[index] === typeVariable) {
|
|
57120
|
+
insertType(primitives, type.types[1 - index]);
|
|
57121
|
+
}
|
|
57122
|
+
}
|
|
57123
|
+
}
|
|
57124
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57125
|
+
if (everyType(constraint, (t) => containsType(primitives, t))) {
|
|
57126
|
+
let i = types.length;
|
|
57127
|
+
while (i > 0) {
|
|
57128
|
+
i--;
|
|
57129
|
+
const type = types[i];
|
|
57130
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57131
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57132
|
+
if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
|
|
57133
|
+
orderedRemoveItemAt(types, i);
|
|
57134
|
+
}
|
|
57135
|
+
}
|
|
57136
|
+
}
|
|
57137
|
+
insertType(types, typeVariable);
|
|
57138
|
+
}
|
|
57139
|
+
}
|
|
57140
|
+
}
|
|
57065
57141
|
function isNamedUnionType(type) {
|
|
57066
57142
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
57067
57143
|
}
|
|
@@ -57127,6 +57203,9 @@ function createTypeChecker(host) {
|
|
|
57127
57203
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
57128
57204
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
57129
57205
|
}
|
|
57206
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
57207
|
+
removeConstrainedTypeVariables(typeSet);
|
|
57208
|
+
}
|
|
57130
57209
|
if (unionReduction === 2 /* Subtype */) {
|
|
57131
57210
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
57132
57211
|
if (!typeSet) {
|
|
@@ -57339,9 +57418,9 @@ function createTypeChecker(host) {
|
|
|
57339
57418
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
57340
57419
|
return true;
|
|
57341
57420
|
}
|
|
57342
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
57421
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
57343
57422
|
const result = createType(2097152 /* Intersection */);
|
|
57344
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
57423
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
57345
57424
|
types,
|
|
57346
57425
|
/*excludeKinds*/
|
|
57347
57426
|
98304 /* Nullable */
|
|
@@ -57355,6 +57434,7 @@ function createTypeChecker(host) {
|
|
|
57355
57434
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
57356
57435
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
57357
57436
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
57437
|
+
let objectFlags = 0 /* None */;
|
|
57358
57438
|
if (includes & 131072 /* Never */) {
|
|
57359
57439
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
57360
57440
|
}
|
|
@@ -57383,6 +57463,25 @@ function createTypeChecker(host) {
|
|
|
57383
57463
|
if (typeSet.length === 1) {
|
|
57384
57464
|
return typeSet[0];
|
|
57385
57465
|
}
|
|
57466
|
+
if (typeSet.length === 2) {
|
|
57467
|
+
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57468
|
+
const typeVariable = typeSet[typeVarIndex];
|
|
57469
|
+
const primitiveType = typeSet[1 - typeVarIndex];
|
|
57470
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57471
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57472
|
+
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
57473
|
+
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
57474
|
+
return typeVariable;
|
|
57475
|
+
}
|
|
57476
|
+
if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
|
|
57477
|
+
if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
|
|
57478
|
+
return neverType;
|
|
57479
|
+
}
|
|
57480
|
+
}
|
|
57481
|
+
objectFlags = 67108864 /* IsConstrainedTypeVariable */;
|
|
57482
|
+
}
|
|
57483
|
+
}
|
|
57484
|
+
}
|
|
57386
57485
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
57387
57486
|
let result = intersectionTypes.get(id);
|
|
57388
57487
|
if (!result) {
|
|
@@ -57405,7 +57504,7 @@ function createTypeChecker(host) {
|
|
|
57405
57504
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
57406
57505
|
}
|
|
57407
57506
|
} else {
|
|
57408
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
57507
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
57409
57508
|
}
|
|
57410
57509
|
intersectionTypes.set(id, result);
|
|
57411
57510
|
}
|
|
@@ -57562,7 +57661,7 @@ function createTypeChecker(host) {
|
|
|
57562
57661
|
);
|
|
57563
57662
|
}
|
|
57564
57663
|
function shouldDeferIndexType(type, indexFlags = 0 /* None */) {
|
|
57565
|
-
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
57664
|
+
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && (!hasDistributiveNameType(type) || getMappedTypeNameTypeKind(type) === 2 /* Remapping */) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
57566
57665
|
}
|
|
57567
57666
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
57568
57667
|
type = getReducedType(type);
|
|
@@ -58046,7 +58145,7 @@ function createTypeChecker(host) {
|
|
|
58046
58145
|
}
|
|
58047
58146
|
}
|
|
58048
58147
|
if (isGenericMappedType(objectType)) {
|
|
58049
|
-
if (
|
|
58148
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
58050
58149
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
58051
58150
|
}
|
|
58052
58151
|
}
|
|
@@ -64098,7 +64197,8 @@ function createTypeChecker(host) {
|
|
|
64098
64197
|
source = getIntersectionType(sources);
|
|
64099
64198
|
target = getIntersectionType(targets);
|
|
64100
64199
|
}
|
|
64101
|
-
}
|
|
64200
|
+
}
|
|
64201
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
64102
64202
|
target = getActualTypeVariable(target);
|
|
64103
64203
|
}
|
|
64104
64204
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -64373,7 +64473,7 @@ function createTypeChecker(host) {
|
|
|
64373
64473
|
}
|
|
64374
64474
|
}
|
|
64375
64475
|
function inferToMappedType(source, target, constraintType) {
|
|
64376
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
64476
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
64377
64477
|
let result = false;
|
|
64378
64478
|
for (const type of constraintType.types) {
|
|
64379
64479
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -71767,7 +71867,7 @@ function createTypeChecker(host) {
|
|
|
71767
71867
|
}
|
|
71768
71868
|
return resolveErrorCall(node);
|
|
71769
71869
|
}
|
|
71770
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
71870
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
71771
71871
|
skippedGenericFunction(node, checkMode);
|
|
71772
71872
|
return resolvingSignature;
|
|
71773
71873
|
}
|
|
@@ -71777,8 +71877,12 @@ function createTypeChecker(host) {
|
|
|
71777
71877
|
}
|
|
71778
71878
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
71779
71879
|
}
|
|
71780
|
-
function
|
|
71781
|
-
|
|
71880
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
71881
|
+
if (!signature.typeParameters) {
|
|
71882
|
+
return false;
|
|
71883
|
+
}
|
|
71884
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
71885
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
71782
71886
|
}
|
|
71783
71887
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
71784
71888
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -76274,7 +76378,8 @@ function createTypeChecker(host) {
|
|
|
76274
76378
|
}
|
|
76275
76379
|
const objectType = type.objectType;
|
|
76276
76380
|
const indexType = type.indexType;
|
|
76277
|
-
|
|
76381
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
76382
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
76278
76383
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
76279
76384
|
error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
76280
76385
|
}
|
package/lib/tsserver.js
CHANGED
|
@@ -2332,7 +2332,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2332
2332
|
|
|
2333
2333
|
// src/compiler/corePublic.ts
|
|
2334
2334
|
var versionMajorMinor = "5.4";
|
|
2335
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2335
|
+
var version = `${versionMajorMinor}.0-dev.20231201`;
|
|
2336
2336
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2337
2337
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2338
2338
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6686,6 +6686,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6686
6686
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
6687
6687
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
6688
6688
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
6689
|
+
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
|
|
6689
6690
|
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
6690
6691
|
return TypeFlags2;
|
|
6691
6692
|
})(TypeFlags || {});
|
|
@@ -6732,6 +6733,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6732
6733
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
6733
6734
|
ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
6734
6735
|
ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
|
|
6736
|
+
ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
|
|
6735
6737
|
return ObjectFlags3;
|
|
6736
6738
|
})(ObjectFlags || {});
|
|
6737
6739
|
var VarianceFlags = /* @__PURE__ */ ((VarianceFlags2) => {
|
|
@@ -51701,6 +51703,10 @@ function createTypeChecker(host) {
|
|
|
51701
51703
|
function getParentOfSymbol(symbol) {
|
|
51702
51704
|
return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
|
|
51703
51705
|
}
|
|
51706
|
+
function getFunctionExpressionParentSymbolOrSymbol(symbol) {
|
|
51707
|
+
var _a, _b;
|
|
51708
|
+
return ((_a = symbol.valueDeclaration) == null ? void 0 : _a.kind) === 219 /* ArrowFunction */ || ((_b = symbol.valueDeclaration) == null ? void 0 : _b.kind) === 218 /* FunctionExpression */ ? getSymbolOfNode(symbol.valueDeclaration.parent) || symbol : symbol;
|
|
51709
|
+
}
|
|
51704
51710
|
function getAlternativeContainingModules(symbol, enclosingDeclaration) {
|
|
51705
51711
|
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
|
51706
51712
|
const id = getNodeId(containingFile);
|
|
@@ -56924,11 +56930,14 @@ function createTypeChecker(host) {
|
|
|
56924
56930
|
}
|
|
56925
56931
|
}
|
|
56926
56932
|
if ((_a = symbol.parent) == null ? void 0 : _a.valueDeclaration) {
|
|
56927
|
-
const
|
|
56928
|
-
if (
|
|
56929
|
-
const
|
|
56930
|
-
if (
|
|
56931
|
-
|
|
56933
|
+
const possiblyAnnotatedSymbol = getFunctionExpressionParentSymbolOrSymbol(symbol.parent);
|
|
56934
|
+
if (possiblyAnnotatedSymbol.valueDeclaration) {
|
|
56935
|
+
const typeNode2 = getEffectiveTypeAnnotationNode(possiblyAnnotatedSymbol.valueDeclaration);
|
|
56936
|
+
if (typeNode2) {
|
|
56937
|
+
const annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode2), symbol.escapedName);
|
|
56938
|
+
if (annotationSymbol) {
|
|
56939
|
+
return getNonMissingTypeOfSymbol(annotationSymbol);
|
|
56940
|
+
}
|
|
56932
56941
|
}
|
|
56933
56942
|
}
|
|
56934
56943
|
}
|
|
@@ -58228,7 +58237,6 @@ function createTypeChecker(host) {
|
|
|
58228
58237
|
return links.resolvedSymbol;
|
|
58229
58238
|
}
|
|
58230
58239
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
58231
|
-
var _a, _b, _c;
|
|
58232
58240
|
const links = getSymbolLinks(symbol);
|
|
58233
58241
|
if (!links[resolutionKind]) {
|
|
58234
58242
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -58247,7 +58255,7 @@ function createTypeChecker(host) {
|
|
|
58247
58255
|
}
|
|
58248
58256
|
}
|
|
58249
58257
|
}
|
|
58250
|
-
const assignments = (
|
|
58258
|
+
const assignments = getFunctionExpressionParentSymbolOrSymbol(symbol).assignmentDeclarationMembers;
|
|
58251
58259
|
if (assignments) {
|
|
58252
58260
|
const decls = arrayFrom(assignments.values());
|
|
58253
58261
|
for (const member of decls) {
|
|
@@ -58544,6 +58552,15 @@ function createTypeChecker(host) {
|
|
|
58544
58552
|
let result;
|
|
58545
58553
|
for (let i = 0; i < signatureLists.length; i++) {
|
|
58546
58554
|
const match = i === listIndex ? signature : findMatchingSignature(
|
|
58555
|
+
signatureLists[i],
|
|
58556
|
+
signature,
|
|
58557
|
+
/*partialMatch*/
|
|
58558
|
+
false,
|
|
58559
|
+
/*ignoreThisTypes*/
|
|
58560
|
+
false,
|
|
58561
|
+
/*ignoreReturnTypes*/
|
|
58562
|
+
true
|
|
58563
|
+
) || findMatchingSignature(
|
|
58547
58564
|
signatureLists[i],
|
|
58548
58565
|
signature,
|
|
58549
58566
|
/*partialMatch*/
|
|
@@ -58917,6 +58934,18 @@ function createTypeChecker(host) {
|
|
|
58917
58934
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
58918
58935
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
58919
58936
|
}
|
|
58937
|
+
function getLimitedConstraint(type) {
|
|
58938
|
+
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
58939
|
+
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
58940
|
+
return;
|
|
58941
|
+
}
|
|
58942
|
+
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
58943
|
+
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
58944
|
+
return;
|
|
58945
|
+
}
|
|
58946
|
+
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
58947
|
+
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
58948
|
+
}
|
|
58920
58949
|
function resolveReverseMappedTypeMembers(type) {
|
|
58921
58950
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
58922
58951
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -58924,7 +58953,14 @@ function createTypeChecker(host) {
|
|
|
58924
58953
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
58925
58954
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
58926
58955
|
const members = createSymbolTable();
|
|
58956
|
+
const limitedConstraint = getLimitedConstraint(type);
|
|
58927
58957
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
58958
|
+
if (limitedConstraint) {
|
|
58959
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
58960
|
+
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
58961
|
+
continue;
|
|
58962
|
+
}
|
|
58963
|
+
}
|
|
58928
58964
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
58929
58965
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
58930
58966
|
inferredProp.declarations = prop.declarations;
|
|
@@ -59005,7 +59041,7 @@ function createTypeChecker(host) {
|
|
|
59005
59041
|
const constraintType = getConstraintTypeFromMappedType(type);
|
|
59006
59042
|
const mappedType = type.target || type;
|
|
59007
59043
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
59008
|
-
const shouldLinkPropDeclarations =
|
|
59044
|
+
const shouldLinkPropDeclarations = getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */;
|
|
59009
59045
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
59010
59046
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
59011
59047
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
@@ -59147,9 +59183,12 @@ function createTypeChecker(host) {
|
|
|
59147
59183
|
}
|
|
59148
59184
|
return false;
|
|
59149
59185
|
}
|
|
59150
|
-
function
|
|
59186
|
+
function getMappedTypeNameTypeKind(type) {
|
|
59151
59187
|
const nameType = getNameTypeFromMappedType(type);
|
|
59152
|
-
|
|
59188
|
+
if (!nameType) {
|
|
59189
|
+
return 0 /* None */;
|
|
59190
|
+
}
|
|
59191
|
+
return isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)) ? 1 /* Filtering */ : 2 /* Remapping */;
|
|
59153
59192
|
}
|
|
59154
59193
|
function resolveStructuredTypeMembers(type) {
|
|
59155
59194
|
if (!type.members) {
|
|
@@ -61685,6 +61724,8 @@ function createTypeChecker(host) {
|
|
|
61685
61724
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
61686
61725
|
if (flags & 465829888 /* Instantiable */)
|
|
61687
61726
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
61727
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
61728
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
61688
61729
|
if (type === wildcardType)
|
|
61689
61730
|
includes |= 8388608 /* IncludesWildcard */;
|
|
61690
61731
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -61789,6 +61830,41 @@ function createTypeChecker(host) {
|
|
|
61789
61830
|
}
|
|
61790
61831
|
}
|
|
61791
61832
|
}
|
|
61833
|
+
function removeConstrainedTypeVariables(types) {
|
|
61834
|
+
const typeVariables = [];
|
|
61835
|
+
for (const type of types) {
|
|
61836
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
61837
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
61838
|
+
pushIfUnique(typeVariables, type.types[index]);
|
|
61839
|
+
}
|
|
61840
|
+
}
|
|
61841
|
+
for (const typeVariable of typeVariables) {
|
|
61842
|
+
const primitives = [];
|
|
61843
|
+
for (const type of types) {
|
|
61844
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
61845
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
61846
|
+
if (type.types[index] === typeVariable) {
|
|
61847
|
+
insertType(primitives, type.types[1 - index]);
|
|
61848
|
+
}
|
|
61849
|
+
}
|
|
61850
|
+
}
|
|
61851
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
61852
|
+
if (everyType(constraint, (t) => containsType(primitives, t))) {
|
|
61853
|
+
let i = types.length;
|
|
61854
|
+
while (i > 0) {
|
|
61855
|
+
i--;
|
|
61856
|
+
const type = types[i];
|
|
61857
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
61858
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
61859
|
+
if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
|
|
61860
|
+
orderedRemoveItemAt(types, i);
|
|
61861
|
+
}
|
|
61862
|
+
}
|
|
61863
|
+
}
|
|
61864
|
+
insertType(types, typeVariable);
|
|
61865
|
+
}
|
|
61866
|
+
}
|
|
61867
|
+
}
|
|
61792
61868
|
function isNamedUnionType(type) {
|
|
61793
61869
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
61794
61870
|
}
|
|
@@ -61854,6 +61930,9 @@ function createTypeChecker(host) {
|
|
|
61854
61930
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
61855
61931
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
61856
61932
|
}
|
|
61933
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
61934
|
+
removeConstrainedTypeVariables(typeSet);
|
|
61935
|
+
}
|
|
61857
61936
|
if (unionReduction === 2 /* Subtype */) {
|
|
61858
61937
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
61859
61938
|
if (!typeSet) {
|
|
@@ -62066,9 +62145,9 @@ function createTypeChecker(host) {
|
|
|
62066
62145
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
62067
62146
|
return true;
|
|
62068
62147
|
}
|
|
62069
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
62148
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
62070
62149
|
const result = createType(2097152 /* Intersection */);
|
|
62071
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
62150
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
62072
62151
|
types,
|
|
62073
62152
|
/*excludeKinds*/
|
|
62074
62153
|
98304 /* Nullable */
|
|
@@ -62082,6 +62161,7 @@ function createTypeChecker(host) {
|
|
|
62082
62161
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
62083
62162
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
62084
62163
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
62164
|
+
let objectFlags = 0 /* None */;
|
|
62085
62165
|
if (includes & 131072 /* Never */) {
|
|
62086
62166
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
62087
62167
|
}
|
|
@@ -62110,6 +62190,25 @@ function createTypeChecker(host) {
|
|
|
62110
62190
|
if (typeSet.length === 1) {
|
|
62111
62191
|
return typeSet[0];
|
|
62112
62192
|
}
|
|
62193
|
+
if (typeSet.length === 2) {
|
|
62194
|
+
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
62195
|
+
const typeVariable = typeSet[typeVarIndex];
|
|
62196
|
+
const primitiveType = typeSet[1 - typeVarIndex];
|
|
62197
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62198
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
62199
|
+
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
62200
|
+
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
62201
|
+
return typeVariable;
|
|
62202
|
+
}
|
|
62203
|
+
if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
|
|
62204
|
+
if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
|
|
62205
|
+
return neverType;
|
|
62206
|
+
}
|
|
62207
|
+
}
|
|
62208
|
+
objectFlags = 67108864 /* IsConstrainedTypeVariable */;
|
|
62209
|
+
}
|
|
62210
|
+
}
|
|
62211
|
+
}
|
|
62113
62212
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
62114
62213
|
let result = intersectionTypes.get(id);
|
|
62115
62214
|
if (!result) {
|
|
@@ -62132,7 +62231,7 @@ function createTypeChecker(host) {
|
|
|
62132
62231
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
62133
62232
|
}
|
|
62134
62233
|
} else {
|
|
62135
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
62234
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
62136
62235
|
}
|
|
62137
62236
|
intersectionTypes.set(id, result);
|
|
62138
62237
|
}
|
|
@@ -62289,7 +62388,7 @@ function createTypeChecker(host) {
|
|
|
62289
62388
|
);
|
|
62290
62389
|
}
|
|
62291
62390
|
function shouldDeferIndexType(type, indexFlags = 0 /* None */) {
|
|
62292
|
-
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
62391
|
+
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && (!hasDistributiveNameType(type) || getMappedTypeNameTypeKind(type) === 2 /* Remapping */) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
62293
62392
|
}
|
|
62294
62393
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
62295
62394
|
type = getReducedType(type);
|
|
@@ -62773,7 +62872,7 @@ function createTypeChecker(host) {
|
|
|
62773
62872
|
}
|
|
62774
62873
|
}
|
|
62775
62874
|
if (isGenericMappedType(objectType)) {
|
|
62776
|
-
if (
|
|
62875
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
62777
62876
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
62778
62877
|
}
|
|
62779
62878
|
}
|
|
@@ -68825,7 +68924,8 @@ function createTypeChecker(host) {
|
|
|
68825
68924
|
source = getIntersectionType(sources);
|
|
68826
68925
|
target = getIntersectionType(targets);
|
|
68827
68926
|
}
|
|
68828
|
-
}
|
|
68927
|
+
}
|
|
68928
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
68829
68929
|
target = getActualTypeVariable(target);
|
|
68830
68930
|
}
|
|
68831
68931
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -69100,7 +69200,7 @@ function createTypeChecker(host) {
|
|
|
69100
69200
|
}
|
|
69101
69201
|
}
|
|
69102
69202
|
function inferToMappedType(source, target, constraintType) {
|
|
69103
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
69203
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
69104
69204
|
let result = false;
|
|
69105
69205
|
for (const type of constraintType.types) {
|
|
69106
69206
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -76494,7 +76594,7 @@ function createTypeChecker(host) {
|
|
|
76494
76594
|
}
|
|
76495
76595
|
return resolveErrorCall(node);
|
|
76496
76596
|
}
|
|
76497
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
76597
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
76498
76598
|
skippedGenericFunction(node, checkMode);
|
|
76499
76599
|
return resolvingSignature;
|
|
76500
76600
|
}
|
|
@@ -76504,8 +76604,12 @@ function createTypeChecker(host) {
|
|
|
76504
76604
|
}
|
|
76505
76605
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
76506
76606
|
}
|
|
76507
|
-
function
|
|
76508
|
-
|
|
76607
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
76608
|
+
if (!signature.typeParameters) {
|
|
76609
|
+
return false;
|
|
76610
|
+
}
|
|
76611
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
76612
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
76509
76613
|
}
|
|
76510
76614
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
76511
76615
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -81001,7 +81105,8 @@ function createTypeChecker(host) {
|
|
|
81001
81105
|
}
|
|
81002
81106
|
const objectType = type.objectType;
|
|
81003
81107
|
const indexType = type.indexType;
|
|
81004
|
-
|
|
81108
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
81109
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
81005
81110
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
81006
81111
|
error2(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
81007
81112
|
}
|
|
@@ -137710,7 +137815,7 @@ function transpileModule(input, transpileOptions) {
|
|
|
137710
137815
|
options
|
|
137711
137816
|
),
|
|
137712
137817
|
setExternalModuleIndicator: getSetExternalModuleIndicator(options),
|
|
137713
|
-
jsDocParsingMode: 1 /* ParseNone */
|
|
137818
|
+
jsDocParsingMode: transpileOptions.jsDocParsingMode ?? 1 /* ParseNone */
|
|
137714
137819
|
}
|
|
137715
137820
|
);
|
|
137716
137821
|
if (transpileOptions.moduleName) {
|
package/lib/typescript.d.ts
CHANGED
|
@@ -11618,6 +11618,7 @@ declare namespace ts {
|
|
|
11618
11618
|
moduleName?: string;
|
|
11619
11619
|
renamedDependencies?: MapLike<string>;
|
|
11620
11620
|
transformers?: CustomTransformers;
|
|
11621
|
+
jsDocParsingMode?: JSDocParsingMode;
|
|
11621
11622
|
}
|
|
11622
11623
|
interface TranspileOutput {
|
|
11623
11624
|
outputText: string;
|
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.4";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20231201`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -4447,6 +4447,7 @@ ${lanes.join("\n")}
|
|
|
4447
4447
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
4448
4448
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
4449
4449
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
4450
|
+
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
|
|
4450
4451
|
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
4451
4452
|
return TypeFlags2;
|
|
4452
4453
|
})(TypeFlags || {});
|
|
@@ -4493,6 +4494,7 @@ ${lanes.join("\n")}
|
|
|
4493
4494
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
4494
4495
|
ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
4495
4496
|
ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
|
|
4497
|
+
ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
|
|
4496
4498
|
return ObjectFlags3;
|
|
4497
4499
|
})(ObjectFlags || {});
|
|
4498
4500
|
VarianceFlags = /* @__PURE__ */ ((VarianceFlags2) => {
|
|
@@ -49464,6 +49466,10 @@ ${lanes.join("\n")}
|
|
|
49464
49466
|
function getParentOfSymbol(symbol) {
|
|
49465
49467
|
return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
|
|
49466
49468
|
}
|
|
49469
|
+
function getFunctionExpressionParentSymbolOrSymbol(symbol) {
|
|
49470
|
+
var _a, _b;
|
|
49471
|
+
return ((_a = symbol.valueDeclaration) == null ? void 0 : _a.kind) === 219 /* ArrowFunction */ || ((_b = symbol.valueDeclaration) == null ? void 0 : _b.kind) === 218 /* FunctionExpression */ ? getSymbolOfNode(symbol.valueDeclaration.parent) || symbol : symbol;
|
|
49472
|
+
}
|
|
49467
49473
|
function getAlternativeContainingModules(symbol, enclosingDeclaration) {
|
|
49468
49474
|
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
|
49469
49475
|
const id = getNodeId(containingFile);
|
|
@@ -54687,11 +54693,14 @@ ${lanes.join("\n")}
|
|
|
54687
54693
|
}
|
|
54688
54694
|
}
|
|
54689
54695
|
if ((_a = symbol.parent) == null ? void 0 : _a.valueDeclaration) {
|
|
54690
|
-
const
|
|
54691
|
-
if (
|
|
54692
|
-
const
|
|
54693
|
-
if (
|
|
54694
|
-
|
|
54696
|
+
const possiblyAnnotatedSymbol = getFunctionExpressionParentSymbolOrSymbol(symbol.parent);
|
|
54697
|
+
if (possiblyAnnotatedSymbol.valueDeclaration) {
|
|
54698
|
+
const typeNode2 = getEffectiveTypeAnnotationNode(possiblyAnnotatedSymbol.valueDeclaration);
|
|
54699
|
+
if (typeNode2) {
|
|
54700
|
+
const annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode2), symbol.escapedName);
|
|
54701
|
+
if (annotationSymbol) {
|
|
54702
|
+
return getNonMissingTypeOfSymbol(annotationSymbol);
|
|
54703
|
+
}
|
|
54695
54704
|
}
|
|
54696
54705
|
}
|
|
54697
54706
|
}
|
|
@@ -55991,7 +56000,6 @@ ${lanes.join("\n")}
|
|
|
55991
56000
|
return links.resolvedSymbol;
|
|
55992
56001
|
}
|
|
55993
56002
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
55994
|
-
var _a, _b, _c;
|
|
55995
56003
|
const links = getSymbolLinks(symbol);
|
|
55996
56004
|
if (!links[resolutionKind]) {
|
|
55997
56005
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -56010,7 +56018,7 @@ ${lanes.join("\n")}
|
|
|
56010
56018
|
}
|
|
56011
56019
|
}
|
|
56012
56020
|
}
|
|
56013
|
-
const assignments = (
|
|
56021
|
+
const assignments = getFunctionExpressionParentSymbolOrSymbol(symbol).assignmentDeclarationMembers;
|
|
56014
56022
|
if (assignments) {
|
|
56015
56023
|
const decls = arrayFrom(assignments.values());
|
|
56016
56024
|
for (const member of decls) {
|
|
@@ -56307,6 +56315,15 @@ ${lanes.join("\n")}
|
|
|
56307
56315
|
let result;
|
|
56308
56316
|
for (let i = 0; i < signatureLists.length; i++) {
|
|
56309
56317
|
const match = i === listIndex ? signature : findMatchingSignature(
|
|
56318
|
+
signatureLists[i],
|
|
56319
|
+
signature,
|
|
56320
|
+
/*partialMatch*/
|
|
56321
|
+
false,
|
|
56322
|
+
/*ignoreThisTypes*/
|
|
56323
|
+
false,
|
|
56324
|
+
/*ignoreReturnTypes*/
|
|
56325
|
+
true
|
|
56326
|
+
) || findMatchingSignature(
|
|
56310
56327
|
signatureLists[i],
|
|
56311
56328
|
signature,
|
|
56312
56329
|
/*partialMatch*/
|
|
@@ -56680,6 +56697,18 @@ ${lanes.join("\n")}
|
|
|
56680
56697
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
56681
56698
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
56682
56699
|
}
|
|
56700
|
+
function getLimitedConstraint(type) {
|
|
56701
|
+
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
56702
|
+
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
56703
|
+
return;
|
|
56704
|
+
}
|
|
56705
|
+
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
56706
|
+
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
56707
|
+
return;
|
|
56708
|
+
}
|
|
56709
|
+
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
56710
|
+
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
56711
|
+
}
|
|
56683
56712
|
function resolveReverseMappedTypeMembers(type) {
|
|
56684
56713
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
56685
56714
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -56687,7 +56716,14 @@ ${lanes.join("\n")}
|
|
|
56687
56716
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
56688
56717
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
56689
56718
|
const members = createSymbolTable();
|
|
56719
|
+
const limitedConstraint = getLimitedConstraint(type);
|
|
56690
56720
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
56721
|
+
if (limitedConstraint) {
|
|
56722
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
56723
|
+
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
56724
|
+
continue;
|
|
56725
|
+
}
|
|
56726
|
+
}
|
|
56691
56727
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
56692
56728
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
56693
56729
|
inferredProp.declarations = prop.declarations;
|
|
@@ -56768,7 +56804,7 @@ ${lanes.join("\n")}
|
|
|
56768
56804
|
const constraintType = getConstraintTypeFromMappedType(type);
|
|
56769
56805
|
const mappedType = type.target || type;
|
|
56770
56806
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
56771
|
-
const shouldLinkPropDeclarations =
|
|
56807
|
+
const shouldLinkPropDeclarations = getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */;
|
|
56772
56808
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
56773
56809
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
56774
56810
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
@@ -56910,9 +56946,12 @@ ${lanes.join("\n")}
|
|
|
56910
56946
|
}
|
|
56911
56947
|
return false;
|
|
56912
56948
|
}
|
|
56913
|
-
function
|
|
56949
|
+
function getMappedTypeNameTypeKind(type) {
|
|
56914
56950
|
const nameType = getNameTypeFromMappedType(type);
|
|
56915
|
-
|
|
56951
|
+
if (!nameType) {
|
|
56952
|
+
return 0 /* None */;
|
|
56953
|
+
}
|
|
56954
|
+
return isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)) ? 1 /* Filtering */ : 2 /* Remapping */;
|
|
56916
56955
|
}
|
|
56917
56956
|
function resolveStructuredTypeMembers(type) {
|
|
56918
56957
|
if (!type.members) {
|
|
@@ -59448,6 +59487,8 @@ ${lanes.join("\n")}
|
|
|
59448
59487
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
59449
59488
|
if (flags & 465829888 /* Instantiable */)
|
|
59450
59489
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
59490
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
59491
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
59451
59492
|
if (type === wildcardType)
|
|
59452
59493
|
includes |= 8388608 /* IncludesWildcard */;
|
|
59453
59494
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -59552,6 +59593,41 @@ ${lanes.join("\n")}
|
|
|
59552
59593
|
}
|
|
59553
59594
|
}
|
|
59554
59595
|
}
|
|
59596
|
+
function removeConstrainedTypeVariables(types) {
|
|
59597
|
+
const typeVariables = [];
|
|
59598
|
+
for (const type of types) {
|
|
59599
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
59600
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
59601
|
+
pushIfUnique(typeVariables, type.types[index]);
|
|
59602
|
+
}
|
|
59603
|
+
}
|
|
59604
|
+
for (const typeVariable of typeVariables) {
|
|
59605
|
+
const primitives = [];
|
|
59606
|
+
for (const type of types) {
|
|
59607
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
59608
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
59609
|
+
if (type.types[index] === typeVariable) {
|
|
59610
|
+
insertType(primitives, type.types[1 - index]);
|
|
59611
|
+
}
|
|
59612
|
+
}
|
|
59613
|
+
}
|
|
59614
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
59615
|
+
if (everyType(constraint, (t) => containsType(primitives, t))) {
|
|
59616
|
+
let i = types.length;
|
|
59617
|
+
while (i > 0) {
|
|
59618
|
+
i--;
|
|
59619
|
+
const type = types[i];
|
|
59620
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
59621
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
59622
|
+
if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
|
|
59623
|
+
orderedRemoveItemAt(types, i);
|
|
59624
|
+
}
|
|
59625
|
+
}
|
|
59626
|
+
}
|
|
59627
|
+
insertType(types, typeVariable);
|
|
59628
|
+
}
|
|
59629
|
+
}
|
|
59630
|
+
}
|
|
59555
59631
|
function isNamedUnionType(type) {
|
|
59556
59632
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
59557
59633
|
}
|
|
@@ -59617,6 +59693,9 @@ ${lanes.join("\n")}
|
|
|
59617
59693
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
59618
59694
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
59619
59695
|
}
|
|
59696
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
59697
|
+
removeConstrainedTypeVariables(typeSet);
|
|
59698
|
+
}
|
|
59620
59699
|
if (unionReduction === 2 /* Subtype */) {
|
|
59621
59700
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
59622
59701
|
if (!typeSet) {
|
|
@@ -59829,9 +59908,9 @@ ${lanes.join("\n")}
|
|
|
59829
59908
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
59830
59909
|
return true;
|
|
59831
59910
|
}
|
|
59832
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
59911
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
59833
59912
|
const result = createType(2097152 /* Intersection */);
|
|
59834
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
59913
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
59835
59914
|
types,
|
|
59836
59915
|
/*excludeKinds*/
|
|
59837
59916
|
98304 /* Nullable */
|
|
@@ -59845,6 +59924,7 @@ ${lanes.join("\n")}
|
|
|
59845
59924
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
59846
59925
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
59847
59926
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
59927
|
+
let objectFlags = 0 /* None */;
|
|
59848
59928
|
if (includes & 131072 /* Never */) {
|
|
59849
59929
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
59850
59930
|
}
|
|
@@ -59873,6 +59953,25 @@ ${lanes.join("\n")}
|
|
|
59873
59953
|
if (typeSet.length === 1) {
|
|
59874
59954
|
return typeSet[0];
|
|
59875
59955
|
}
|
|
59956
|
+
if (typeSet.length === 2) {
|
|
59957
|
+
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
59958
|
+
const typeVariable = typeSet[typeVarIndex];
|
|
59959
|
+
const primitiveType = typeSet[1 - typeVarIndex];
|
|
59960
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
59961
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
59962
|
+
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
59963
|
+
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
59964
|
+
return typeVariable;
|
|
59965
|
+
}
|
|
59966
|
+
if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
|
|
59967
|
+
if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
|
|
59968
|
+
return neverType;
|
|
59969
|
+
}
|
|
59970
|
+
}
|
|
59971
|
+
objectFlags = 67108864 /* IsConstrainedTypeVariable */;
|
|
59972
|
+
}
|
|
59973
|
+
}
|
|
59974
|
+
}
|
|
59876
59975
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
59877
59976
|
let result = intersectionTypes.get(id);
|
|
59878
59977
|
if (!result) {
|
|
@@ -59895,7 +59994,7 @@ ${lanes.join("\n")}
|
|
|
59895
59994
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
59896
59995
|
}
|
|
59897
59996
|
} else {
|
|
59898
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
59997
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
59899
59998
|
}
|
|
59900
59999
|
intersectionTypes.set(id, result);
|
|
59901
60000
|
}
|
|
@@ -60052,7 +60151,7 @@ ${lanes.join("\n")}
|
|
|
60052
60151
|
);
|
|
60053
60152
|
}
|
|
60054
60153
|
function shouldDeferIndexType(type, indexFlags = 0 /* None */) {
|
|
60055
|
-
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
60154
|
+
return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && (!hasDistributiveNameType(type) || getMappedTypeNameTypeKind(type) === 2 /* Remapping */) || type.flags & 1048576 /* Union */ && !(indexFlags & 4 /* NoReducibleCheck */) && isGenericReducibleType(type) || type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && some(type.types, isEmptyAnonymousObjectType));
|
|
60056
60155
|
}
|
|
60057
60156
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
60058
60157
|
type = getReducedType(type);
|
|
@@ -60536,7 +60635,7 @@ ${lanes.join("\n")}
|
|
|
60536
60635
|
}
|
|
60537
60636
|
}
|
|
60538
60637
|
if (isGenericMappedType(objectType)) {
|
|
60539
|
-
if (
|
|
60638
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
60540
60639
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
60541
60640
|
}
|
|
60542
60641
|
}
|
|
@@ -66588,7 +66687,8 @@ ${lanes.join("\n")}
|
|
|
66588
66687
|
source = getIntersectionType(sources);
|
|
66589
66688
|
target = getIntersectionType(targets);
|
|
66590
66689
|
}
|
|
66591
|
-
}
|
|
66690
|
+
}
|
|
66691
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
66592
66692
|
target = getActualTypeVariable(target);
|
|
66593
66693
|
}
|
|
66594
66694
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -66863,7 +66963,7 @@ ${lanes.join("\n")}
|
|
|
66863
66963
|
}
|
|
66864
66964
|
}
|
|
66865
66965
|
function inferToMappedType(source, target, constraintType) {
|
|
66866
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
66966
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
66867
66967
|
let result = false;
|
|
66868
66968
|
for (const type of constraintType.types) {
|
|
66869
66969
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -74257,7 +74357,7 @@ ${lanes.join("\n")}
|
|
|
74257
74357
|
}
|
|
74258
74358
|
return resolveErrorCall(node);
|
|
74259
74359
|
}
|
|
74260
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
74360
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
74261
74361
|
skippedGenericFunction(node, checkMode);
|
|
74262
74362
|
return resolvingSignature;
|
|
74263
74363
|
}
|
|
@@ -74267,8 +74367,12 @@ ${lanes.join("\n")}
|
|
|
74267
74367
|
}
|
|
74268
74368
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
74269
74369
|
}
|
|
74270
|
-
function
|
|
74271
|
-
|
|
74370
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
74371
|
+
if (!signature.typeParameters) {
|
|
74372
|
+
return false;
|
|
74373
|
+
}
|
|
74374
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
74375
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
74272
74376
|
}
|
|
74273
74377
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
74274
74378
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -78764,7 +78868,8 @@ ${lanes.join("\n")}
|
|
|
78764
78868
|
}
|
|
78765
78869
|
const objectType = type.objectType;
|
|
78766
78870
|
const indexType = type.indexType;
|
|
78767
|
-
|
|
78871
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
78872
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
78768
78873
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
78769
78874
|
error2(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
78770
78875
|
}
|
|
@@ -136075,7 +136180,7 @@ ${lanes.join("\n")}
|
|
|
136075
136180
|
options
|
|
136076
136181
|
),
|
|
136077
136182
|
setExternalModuleIndicator: getSetExternalModuleIndicator(options),
|
|
136078
|
-
jsDocParsingMode: 1 /* ParseNone */
|
|
136183
|
+
jsDocParsingMode: transpileOptions.jsDocParsingMode ?? 1 /* ParseNone */
|
|
136079
136184
|
}
|
|
136080
136185
|
);
|
|
136081
136186
|
if (transpileOptions.moduleName) {
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
|
|
|
54
54
|
|
|
55
55
|
// src/compiler/corePublic.ts
|
|
56
56
|
var versionMajorMinor = "5.4";
|
|
57
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
57
|
+
var version = `${versionMajorMinor}.0-dev.20231201`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -3105,6 +3105,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3105
3105
|
TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
|
|
3106
3106
|
TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
|
|
3107
3107
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
3108
|
+
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
|
|
3108
3109
|
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
3109
3110
|
return TypeFlags2;
|
|
3110
3111
|
})(TypeFlags || {});
|
|
@@ -3151,6 +3152,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
3151
3152
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
3152
3153
|
ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
|
|
3153
3154
|
ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
|
|
3155
|
+
ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
|
|
3154
3156
|
return ObjectFlags3;
|
|
3155
3157
|
})(ObjectFlags || {});
|
|
3156
3158
|
var SignatureFlags = /* @__PURE__ */ ((SignatureFlags4) => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.4.0-dev.
|
|
5
|
+
"version": "5.4.0-dev.20231201",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"node": "20.1.0",
|
|
115
115
|
"npm": "8.19.4"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "5bc66177388247d3e270653f94d82a8dabd56d69"
|
|
118
118
|
}
|