typescript 5.4.0-dev.20231129 → 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.es2018.intl.d.ts +4 -3
- package/lib/lib.es2020.intl.d.ts +36 -16
- package/lib/lib.es2020.string.d.ts +15 -1
- package/lib/lib.es2021.intl.d.ts +2 -2
- package/lib/lib.es2022.intl.d.ts +2 -2
- package/lib/lib.es5.d.ts +15 -6
- package/lib/lib.esnext.d.ts +1 -0
- package/lib/lib.esnext.promise.d.ts +35 -0
- package/lib/tsc.js +185 -55
- package/lib/tsserver.js +197 -56
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +197 -56
- package/lib/typingsInstaller.js +4 -2
- package/package.json +2 -2
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) => {
|
|
@@ -33897,7 +33899,7 @@ var libEntries = [
|
|
|
33897
33899
|
["esnext.disposable", "lib.esnext.disposable.d.ts"],
|
|
33898
33900
|
["esnext.bigint", "lib.es2020.bigint.d.ts"],
|
|
33899
33901
|
["esnext.string", "lib.es2022.string.d.ts"],
|
|
33900
|
-
["esnext.promise", "lib.
|
|
33902
|
+
["esnext.promise", "lib.esnext.promise.d.ts"],
|
|
33901
33903
|
["esnext.weakref", "lib.es2021.weakref.d.ts"],
|
|
33902
33904
|
["esnext.decorators", "lib.esnext.decorators.d.ts"],
|
|
33903
33905
|
["decorators", "lib.decorators.d.ts"],
|
|
@@ -41785,7 +41787,7 @@ function createBinder() {
|
|
|
41785
41787
|
}
|
|
41786
41788
|
function bindSpecialPropertyAssignment(node) {
|
|
41787
41789
|
var _a;
|
|
41788
|
-
const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression,
|
|
41790
|
+
const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer) || lookupSymbolForPropertyAccess(node.left.expression, container);
|
|
41789
41791
|
if (!isInJSFile(node) && !isFunctionSymbol(parentSymbol)) {
|
|
41790
41792
|
return;
|
|
41791
41793
|
}
|
|
@@ -41883,7 +41885,7 @@ function createBinder() {
|
|
|
41883
41885
|
return isBinaryExpression(propertyAccess.parent) ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 312 /* SourceFile */ : propertyAccess.parent.parent.kind === 312 /* SourceFile */;
|
|
41884
41886
|
}
|
|
41885
41887
|
function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
|
|
41886
|
-
let namespaceSymbol = lookupSymbolForPropertyAccess(name,
|
|
41888
|
+
let namespaceSymbol = lookupSymbolForPropertyAccess(name, blockScopeContainer) || lookupSymbolForPropertyAccess(name, container);
|
|
41887
41889
|
const isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
|
|
41888
41890
|
namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
|
|
41889
41891
|
bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
|
|
@@ -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) {
|
|
@@ -54471,7 +54510,12 @@ function createTypeChecker(host) {
|
|
|
54471
54510
|
for (const current of type.types) {
|
|
54472
54511
|
for (const prop of getPropertiesOfType(current)) {
|
|
54473
54512
|
if (!members.has(prop.escapedName)) {
|
|
54474
|
-
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
54513
|
+
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
54514
|
+
type,
|
|
54515
|
+
prop.escapedName,
|
|
54516
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
54517
|
+
!!(type.flags & 2097152 /* Intersection */)
|
|
54518
|
+
);
|
|
54475
54519
|
if (combinedProp) {
|
|
54476
54520
|
members.set(prop.escapedName, combinedProp);
|
|
54477
54521
|
}
|
|
@@ -54961,13 +55005,17 @@ function createTypeChecker(host) {
|
|
|
54961
55005
|
return result;
|
|
54962
55006
|
}
|
|
54963
55007
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
54964
|
-
var _a, _b;
|
|
55008
|
+
var _a, _b, _c;
|
|
54965
55009
|
let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
|
|
54966
55010
|
if (!property) {
|
|
54967
55011
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
54968
55012
|
if (property) {
|
|
54969
55013
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
54970
55014
|
properties.set(name, property);
|
|
55015
|
+
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
55016
|
+
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
55017
|
+
properties2.set(name, property);
|
|
55018
|
+
}
|
|
54971
55019
|
}
|
|
54972
55020
|
}
|
|
54973
55021
|
return property;
|
|
@@ -55077,7 +55125,22 @@ function createTypeChecker(host) {
|
|
|
55077
55125
|
}
|
|
55078
55126
|
return getPropertyOfObjectType(globalObjectType, name);
|
|
55079
55127
|
}
|
|
55080
|
-
if (type.flags &
|
|
55128
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
55129
|
+
const prop = getPropertyOfUnionOrIntersectionType(
|
|
55130
|
+
type,
|
|
55131
|
+
name,
|
|
55132
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
55133
|
+
true
|
|
55134
|
+
);
|
|
55135
|
+
if (prop) {
|
|
55136
|
+
return prop;
|
|
55137
|
+
}
|
|
55138
|
+
if (!skipObjectFunctionPropertyAugment) {
|
|
55139
|
+
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
55140
|
+
}
|
|
55141
|
+
return void 0;
|
|
55142
|
+
}
|
|
55143
|
+
if (type.flags & 1048576 /* Union */) {
|
|
55081
55144
|
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
55082
55145
|
}
|
|
55083
55146
|
return void 0;
|
|
@@ -56934,6 +56997,8 @@ function createTypeChecker(host) {
|
|
|
56934
56997
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
56935
56998
|
if (flags & 465829888 /* Instantiable */)
|
|
56936
56999
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
57000
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
57001
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
56937
57002
|
if (type === wildcardType)
|
|
56938
57003
|
includes |= 8388608 /* IncludesWildcard */;
|
|
56939
57004
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -57038,6 +57103,41 @@ function createTypeChecker(host) {
|
|
|
57038
57103
|
}
|
|
57039
57104
|
}
|
|
57040
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
|
+
}
|
|
57041
57141
|
function isNamedUnionType(type) {
|
|
57042
57142
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
57043
57143
|
}
|
|
@@ -57103,6 +57203,9 @@ function createTypeChecker(host) {
|
|
|
57103
57203
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
57104
57204
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
57105
57205
|
}
|
|
57206
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
57207
|
+
removeConstrainedTypeVariables(typeSet);
|
|
57208
|
+
}
|
|
57106
57209
|
if (unionReduction === 2 /* Subtype */) {
|
|
57107
57210
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
57108
57211
|
if (!typeSet) {
|
|
@@ -57315,9 +57418,9 @@ function createTypeChecker(host) {
|
|
|
57315
57418
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
57316
57419
|
return true;
|
|
57317
57420
|
}
|
|
57318
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
57421
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
57319
57422
|
const result = createType(2097152 /* Intersection */);
|
|
57320
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
57423
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
57321
57424
|
types,
|
|
57322
57425
|
/*excludeKinds*/
|
|
57323
57426
|
98304 /* Nullable */
|
|
@@ -57331,6 +57434,7 @@ function createTypeChecker(host) {
|
|
|
57331
57434
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
57332
57435
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
57333
57436
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
57437
|
+
let objectFlags = 0 /* None */;
|
|
57334
57438
|
if (includes & 131072 /* Never */) {
|
|
57335
57439
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
57336
57440
|
}
|
|
@@ -57359,6 +57463,25 @@ function createTypeChecker(host) {
|
|
|
57359
57463
|
if (typeSet.length === 1) {
|
|
57360
57464
|
return typeSet[0];
|
|
57361
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
|
+
}
|
|
57362
57485
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
57363
57486
|
let result = intersectionTypes.get(id);
|
|
57364
57487
|
if (!result) {
|
|
@@ -57381,7 +57504,7 @@ function createTypeChecker(host) {
|
|
|
57381
57504
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
57382
57505
|
}
|
|
57383
57506
|
} else {
|
|
57384
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
57507
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
57385
57508
|
}
|
|
57386
57509
|
intersectionTypes.set(id, result);
|
|
57387
57510
|
}
|
|
@@ -57538,7 +57661,7 @@ function createTypeChecker(host) {
|
|
|
57538
57661
|
);
|
|
57539
57662
|
}
|
|
57540
57663
|
function shouldDeferIndexType(type, indexFlags = 0 /* None */) {
|
|
57541
|
-
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));
|
|
57542
57665
|
}
|
|
57543
57666
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
57544
57667
|
type = getReducedType(type);
|
|
@@ -58022,7 +58145,7 @@ function createTypeChecker(host) {
|
|
|
58022
58145
|
}
|
|
58023
58146
|
}
|
|
58024
58147
|
if (isGenericMappedType(objectType)) {
|
|
58025
|
-
if (
|
|
58148
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
58026
58149
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
58027
58150
|
}
|
|
58028
58151
|
}
|
|
@@ -63930,12 +64053,12 @@ function createTypeChecker(host) {
|
|
|
63930
64053
|
return false;
|
|
63931
64054
|
}
|
|
63932
64055
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
63933
|
-
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
63934
|
-
return true;
|
|
63935
|
-
}
|
|
63936
64056
|
if (target.flags & 2097152 /* Intersection */) {
|
|
63937
64057
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
63938
64058
|
}
|
|
64059
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
64060
|
+
return true;
|
|
64061
|
+
}
|
|
63939
64062
|
if (source.flags & 128 /* StringLiteral */) {
|
|
63940
64063
|
const value = source.value;
|
|
63941
64064
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
@@ -63952,7 +64075,7 @@ function createTypeChecker(host) {
|
|
|
63952
64075
|
const texts = source.texts;
|
|
63953
64076
|
return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target);
|
|
63954
64077
|
}
|
|
63955
|
-
return
|
|
64078
|
+
return false;
|
|
63956
64079
|
}
|
|
63957
64080
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
63958
64081
|
return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arraysEqual(source.texts, target.texts) ? map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
@@ -64074,7 +64197,8 @@ function createTypeChecker(host) {
|
|
|
64074
64197
|
source = getIntersectionType(sources);
|
|
64075
64198
|
target = getIntersectionType(targets);
|
|
64076
64199
|
}
|
|
64077
|
-
}
|
|
64200
|
+
}
|
|
64201
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
64078
64202
|
target = getActualTypeVariable(target);
|
|
64079
64203
|
}
|
|
64080
64204
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -64349,7 +64473,7 @@ function createTypeChecker(host) {
|
|
|
64349
64473
|
}
|
|
64350
64474
|
}
|
|
64351
64475
|
function inferToMappedType(source, target, constraintType) {
|
|
64352
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
64476
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
64353
64477
|
let result = false;
|
|
64354
64478
|
for (const type of constraintType.types) {
|
|
64355
64479
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -71091,19 +71215,9 @@ function createTypeChecker(host) {
|
|
|
71091
71215
|
return Debug.fail();
|
|
71092
71216
|
}
|
|
71093
71217
|
}
|
|
71094
|
-
function getDiagnosticSpanForCallNode(node
|
|
71095
|
-
let start;
|
|
71096
|
-
let length2;
|
|
71218
|
+
function getDiagnosticSpanForCallNode(node) {
|
|
71097
71219
|
const sourceFile = getSourceFileOfNode(node);
|
|
71098
|
-
|
|
71099
|
-
const nameSpan = getErrorSpanForNode(sourceFile, node.expression.name);
|
|
71100
|
-
start = nameSpan.start;
|
|
71101
|
-
length2 = doNotIncludeArguments ? nameSpan.length : node.end - start;
|
|
71102
|
-
} else {
|
|
71103
|
-
const expressionSpan = getErrorSpanForNode(sourceFile, node.expression);
|
|
71104
|
-
start = expressionSpan.start;
|
|
71105
|
-
length2 = doNotIncludeArguments ? expressionSpan.length : node.end - start;
|
|
71106
|
-
}
|
|
71220
|
+
const { start, length: length2 } = getErrorSpanForNode(sourceFile, isPropertyAccessExpression(node.expression) ? node.expression.name : node.expression);
|
|
71107
71221
|
return { start, length: length2, sourceFile };
|
|
71108
71222
|
}
|
|
71109
71223
|
function getDiagnosticForCallNode(node, message, ...args) {
|
|
@@ -71120,6 +71234,18 @@ function createTypeChecker(host) {
|
|
|
71120
71234
|
return createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, message);
|
|
71121
71235
|
}
|
|
71122
71236
|
}
|
|
71237
|
+
function getErrorNodeForCallNode(callLike) {
|
|
71238
|
+
if (isCallOrNewExpression(callLike)) {
|
|
71239
|
+
return isPropertyAccessExpression(callLike.expression) ? callLike.expression.name : callLike.expression;
|
|
71240
|
+
}
|
|
71241
|
+
if (isTaggedTemplateExpression(callLike)) {
|
|
71242
|
+
return isPropertyAccessExpression(callLike.tag) ? callLike.tag.name : callLike.tag;
|
|
71243
|
+
}
|
|
71244
|
+
if (isJsxOpeningLikeElement(callLike)) {
|
|
71245
|
+
return callLike.tagName;
|
|
71246
|
+
}
|
|
71247
|
+
return callLike;
|
|
71248
|
+
}
|
|
71123
71249
|
function isPromiseResolveArityError(node) {
|
|
71124
71250
|
if (!isCallExpression(node) || !isIdentifier(node.expression))
|
|
71125
71251
|
return false;
|
|
@@ -71421,7 +71547,7 @@ function createTypeChecker(host) {
|
|
|
71421
71547
|
const { file, start, length: length2 } = diags[0];
|
|
71422
71548
|
diag2 = { file, start, length: length2, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
|
|
71423
71549
|
} else {
|
|
71424
|
-
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, chain, related);
|
|
71550
|
+
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), getErrorNodeForCallNode(node), chain, related);
|
|
71425
71551
|
}
|
|
71426
71552
|
addImplementationSuccessElaboration(candidatesForArgumentError[0], diag2);
|
|
71427
71553
|
diagnostics.add(diag2);
|
|
@@ -71741,7 +71867,7 @@ function createTypeChecker(host) {
|
|
|
71741
71867
|
}
|
|
71742
71868
|
return resolveErrorCall(node);
|
|
71743
71869
|
}
|
|
71744
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
71870
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
71745
71871
|
skippedGenericFunction(node, checkMode);
|
|
71746
71872
|
return resolvingSignature;
|
|
71747
71873
|
}
|
|
@@ -71751,8 +71877,12 @@ function createTypeChecker(host) {
|
|
|
71751
71877
|
}
|
|
71752
71878
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
71753
71879
|
}
|
|
71754
|
-
function
|
|
71755
|
-
|
|
71880
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
71881
|
+
if (!signature.typeParameters) {
|
|
71882
|
+
return false;
|
|
71883
|
+
}
|
|
71884
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
71885
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
71756
71886
|
}
|
|
71757
71887
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
71758
71888
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -71949,11 +72079,7 @@ function createTypeChecker(host) {
|
|
|
71949
72079
|
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
|
71950
72080
|
}
|
|
71951
72081
|
if (isCallExpression(errorTarget.parent)) {
|
|
71952
|
-
const { start, length: length2 } = getDiagnosticSpanForCallNode(
|
|
71953
|
-
errorTarget.parent,
|
|
71954
|
-
/*doNotIncludeArguments*/
|
|
71955
|
-
true
|
|
71956
|
-
);
|
|
72082
|
+
const { start, length: length2 } = getDiagnosticSpanForCallNode(errorTarget.parent);
|
|
71957
72083
|
diagnostic.start = start;
|
|
71958
72084
|
diagnostic.length = length2;
|
|
71959
72085
|
}
|
|
@@ -75323,16 +75449,19 @@ function createTypeChecker(host) {
|
|
|
75323
75449
|
}
|
|
75324
75450
|
}
|
|
75325
75451
|
}
|
|
75326
|
-
function
|
|
75452
|
+
function getNonGenericReturnTypeOfSingleCallSignature(funcType) {
|
|
75327
75453
|
const signature = getSingleCallSignature(funcType);
|
|
75328
|
-
if (signature
|
|
75329
|
-
|
|
75454
|
+
if (signature) {
|
|
75455
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
75456
|
+
if (!signature.typeParameters || !couldContainTypeVariables(returnType)) {
|
|
75457
|
+
return returnType;
|
|
75458
|
+
}
|
|
75330
75459
|
}
|
|
75331
75460
|
}
|
|
75332
75461
|
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
|
|
75333
75462
|
const funcType = checkExpression(expr.expression);
|
|
75334
75463
|
const nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
|
|
75335
|
-
const returnType =
|
|
75464
|
+
const returnType = getNonGenericReturnTypeOfSingleCallSignature(funcType);
|
|
75336
75465
|
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
|
|
75337
75466
|
}
|
|
75338
75467
|
function getTypeOfExpression(node) {
|
|
@@ -75377,7 +75506,7 @@ function createTypeChecker(host) {
|
|
|
75377
75506
|
/*requireStringLiteralLikeArgument*/
|
|
75378
75507
|
true
|
|
75379
75508
|
) && !isSymbolOrSymbolForCall(expr)) {
|
|
75380
|
-
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
|
75509
|
+
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getNonGenericReturnTypeOfSingleCallSignature(checkNonNullExpression(expr.expression));
|
|
75381
75510
|
} else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
|
|
75382
75511
|
return getTypeFromTypeNode(expr.type);
|
|
75383
75512
|
} else if (isLiteralExpression(node) || isBooleanLiteral(node)) {
|
|
@@ -76249,7 +76378,8 @@ function createTypeChecker(host) {
|
|
|
76249
76378
|
}
|
|
76250
76379
|
const objectType = type.objectType;
|
|
76251
76380
|
const indexType = type.indexType;
|
|
76252
|
-
|
|
76381
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
76382
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
76253
76383
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
76254
76384
|
error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
76255
76385
|
}
|