@typescript-deploys/pr-build 5.4.0-pr-56467-3 → 5.4.0-pr-56626-8
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 +186 -57
- package/lib/tsserver.js +190 -74
- package/lib/typescript.js +190 -74
- 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-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20231130`;
|
|
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) {
|
|
@@ -53613,11 +53621,10 @@ function createTypeChecker(host) {
|
|
|
53613
53621
|
const baseTypes = getBaseTypes(source);
|
|
53614
53622
|
if (baseTypes.length) {
|
|
53615
53623
|
if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
|
|
53616
|
-
const symbolTable = createSymbolTable();
|
|
53617
|
-
|
|
53618
|
-
|
|
53619
|
-
|
|
53620
|
-
}
|
|
53624
|
+
const symbolTable = createSymbolTable(source.declaredProperties);
|
|
53625
|
+
const sourceIndex = getIndexSymbol(source.symbol);
|
|
53626
|
+
if (sourceIndex) {
|
|
53627
|
+
symbolTable.set("__index" /* Index */, sourceIndex);
|
|
53621
53628
|
}
|
|
53622
53629
|
members = symbolTable;
|
|
53623
53630
|
}
|
|
@@ -53817,6 +53824,15 @@ function createTypeChecker(host) {
|
|
|
53817
53824
|
let result;
|
|
53818
53825
|
for (let i = 0; i < signatureLists.length; i++) {
|
|
53819
53826
|
const match = i === listIndex ? signature : findMatchingSignature(
|
|
53827
|
+
signatureLists[i],
|
|
53828
|
+
signature,
|
|
53829
|
+
/*partialMatch*/
|
|
53830
|
+
false,
|
|
53831
|
+
/*ignoreThisTypes*/
|
|
53832
|
+
false,
|
|
53833
|
+
/*ignoreReturnTypes*/
|
|
53834
|
+
true
|
|
53835
|
+
) || findMatchingSignature(
|
|
53820
53836
|
signatureLists[i],
|
|
53821
53837
|
signature,
|
|
53822
53838
|
/*partialMatch*/
|
|
@@ -54190,6 +54206,18 @@ function createTypeChecker(host) {
|
|
|
54190
54206
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
54191
54207
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
54192
54208
|
}
|
|
54209
|
+
function getLimitedConstraint(type) {
|
|
54210
|
+
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
54211
|
+
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
54212
|
+
return;
|
|
54213
|
+
}
|
|
54214
|
+
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
54215
|
+
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
54216
|
+
return;
|
|
54217
|
+
}
|
|
54218
|
+
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
54219
|
+
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
54220
|
+
}
|
|
54193
54221
|
function resolveReverseMappedTypeMembers(type) {
|
|
54194
54222
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
54195
54223
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -54197,7 +54225,14 @@ function createTypeChecker(host) {
|
|
|
54197
54225
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
54198
54226
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
54199
54227
|
const members = createSymbolTable();
|
|
54228
|
+
const limitedConstraint = getLimitedConstraint(type);
|
|
54200
54229
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
54230
|
+
if (limitedConstraint) {
|
|
54231
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
54232
|
+
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
54233
|
+
continue;
|
|
54234
|
+
}
|
|
54235
|
+
}
|
|
54201
54236
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
54202
54237
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
54203
54238
|
inferredProp.declarations = prop.declarations;
|
|
@@ -54278,7 +54313,7 @@ function createTypeChecker(host) {
|
|
|
54278
54313
|
const constraintType = getConstraintTypeFromMappedType(type);
|
|
54279
54314
|
const mappedType = type.target || type;
|
|
54280
54315
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
54281
|
-
const shouldLinkPropDeclarations =
|
|
54316
|
+
const shouldLinkPropDeclarations = getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */;
|
|
54282
54317
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
54283
54318
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
54284
54319
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
@@ -54420,9 +54455,12 @@ function createTypeChecker(host) {
|
|
|
54420
54455
|
}
|
|
54421
54456
|
return false;
|
|
54422
54457
|
}
|
|
54423
|
-
function
|
|
54458
|
+
function getMappedTypeNameTypeKind(type) {
|
|
54424
54459
|
const nameType = getNameTypeFromMappedType(type);
|
|
54425
|
-
|
|
54460
|
+
if (!nameType) {
|
|
54461
|
+
return 0 /* None */;
|
|
54462
|
+
}
|
|
54463
|
+
return isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)) ? 1 /* Filtering */ : 2 /* Remapping */;
|
|
54426
54464
|
}
|
|
54427
54465
|
function resolveStructuredTypeMembers(type) {
|
|
54428
54466
|
if (!type.members) {
|
|
@@ -54471,7 +54509,12 @@ function createTypeChecker(host) {
|
|
|
54471
54509
|
for (const current of type.types) {
|
|
54472
54510
|
for (const prop of getPropertiesOfType(current)) {
|
|
54473
54511
|
if (!members.has(prop.escapedName)) {
|
|
54474
|
-
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
54512
|
+
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
54513
|
+
type,
|
|
54514
|
+
prop.escapedName,
|
|
54515
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
54516
|
+
!!(type.flags & 2097152 /* Intersection */)
|
|
54517
|
+
);
|
|
54475
54518
|
if (combinedProp) {
|
|
54476
54519
|
members.set(prop.escapedName, combinedProp);
|
|
54477
54520
|
}
|
|
@@ -54961,13 +55004,17 @@ function createTypeChecker(host) {
|
|
|
54961
55004
|
return result;
|
|
54962
55005
|
}
|
|
54963
55006
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
54964
|
-
var _a, _b;
|
|
55007
|
+
var _a, _b, _c;
|
|
54965
55008
|
let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
|
|
54966
55009
|
if (!property) {
|
|
54967
55010
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
54968
55011
|
if (property) {
|
|
54969
55012
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
54970
55013
|
properties.set(name, property);
|
|
55014
|
+
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
55015
|
+
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
55016
|
+
properties2.set(name, property);
|
|
55017
|
+
}
|
|
54971
55018
|
}
|
|
54972
55019
|
}
|
|
54973
55020
|
return property;
|
|
@@ -55077,7 +55124,22 @@ function createTypeChecker(host) {
|
|
|
55077
55124
|
}
|
|
55078
55125
|
return getPropertyOfObjectType(globalObjectType, name);
|
|
55079
55126
|
}
|
|
55080
|
-
if (type.flags &
|
|
55127
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
55128
|
+
const prop = getPropertyOfUnionOrIntersectionType(
|
|
55129
|
+
type,
|
|
55130
|
+
name,
|
|
55131
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
55132
|
+
true
|
|
55133
|
+
);
|
|
55134
|
+
if (prop) {
|
|
55135
|
+
return prop;
|
|
55136
|
+
}
|
|
55137
|
+
if (!skipObjectFunctionPropertyAugment) {
|
|
55138
|
+
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
55139
|
+
}
|
|
55140
|
+
return void 0;
|
|
55141
|
+
}
|
|
55142
|
+
if (type.flags & 1048576 /* Union */) {
|
|
55081
55143
|
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
55082
55144
|
}
|
|
55083
55145
|
return void 0;
|
|
@@ -56934,6 +56996,8 @@ function createTypeChecker(host) {
|
|
|
56934
56996
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
56935
56997
|
if (flags & 465829888 /* Instantiable */)
|
|
56936
56998
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
56999
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
57000
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
56937
57001
|
if (type === wildcardType)
|
|
56938
57002
|
includes |= 8388608 /* IncludesWildcard */;
|
|
56939
57003
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -57038,6 +57102,41 @@ function createTypeChecker(host) {
|
|
|
57038
57102
|
}
|
|
57039
57103
|
}
|
|
57040
57104
|
}
|
|
57105
|
+
function removeConstrainedTypeVariables(types) {
|
|
57106
|
+
const typeVariables = [];
|
|
57107
|
+
for (const type of types) {
|
|
57108
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57109
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57110
|
+
pushIfUnique(typeVariables, type.types[index]);
|
|
57111
|
+
}
|
|
57112
|
+
}
|
|
57113
|
+
for (const typeVariable of typeVariables) {
|
|
57114
|
+
const primitives = [];
|
|
57115
|
+
for (const type of types) {
|
|
57116
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57117
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57118
|
+
if (type.types[index] === typeVariable) {
|
|
57119
|
+
insertType(primitives, type.types[1 - index]);
|
|
57120
|
+
}
|
|
57121
|
+
}
|
|
57122
|
+
}
|
|
57123
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57124
|
+
if (everyType(constraint, (t) => containsType(primitives, t))) {
|
|
57125
|
+
let i = types.length;
|
|
57126
|
+
while (i > 0) {
|
|
57127
|
+
i--;
|
|
57128
|
+
const type = types[i];
|
|
57129
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57130
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57131
|
+
if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
|
|
57132
|
+
orderedRemoveItemAt(types, i);
|
|
57133
|
+
}
|
|
57134
|
+
}
|
|
57135
|
+
}
|
|
57136
|
+
insertType(types, typeVariable);
|
|
57137
|
+
}
|
|
57138
|
+
}
|
|
57139
|
+
}
|
|
57041
57140
|
function isNamedUnionType(type) {
|
|
57042
57141
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
57043
57142
|
}
|
|
@@ -57103,6 +57202,9 @@ function createTypeChecker(host) {
|
|
|
57103
57202
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
57104
57203
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
57105
57204
|
}
|
|
57205
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
57206
|
+
removeConstrainedTypeVariables(typeSet);
|
|
57207
|
+
}
|
|
57106
57208
|
if (unionReduction === 2 /* Subtype */) {
|
|
57107
57209
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
57108
57210
|
if (!typeSet) {
|
|
@@ -57315,9 +57417,9 @@ function createTypeChecker(host) {
|
|
|
57315
57417
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
57316
57418
|
return true;
|
|
57317
57419
|
}
|
|
57318
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
57420
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
57319
57421
|
const result = createType(2097152 /* Intersection */);
|
|
57320
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
57422
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
57321
57423
|
types,
|
|
57322
57424
|
/*excludeKinds*/
|
|
57323
57425
|
98304 /* Nullable */
|
|
@@ -57331,6 +57433,7 @@ function createTypeChecker(host) {
|
|
|
57331
57433
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
57332
57434
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
57333
57435
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
57436
|
+
let objectFlags = 0 /* None */;
|
|
57334
57437
|
if (includes & 131072 /* Never */) {
|
|
57335
57438
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
57336
57439
|
}
|
|
@@ -57359,6 +57462,25 @@ function createTypeChecker(host) {
|
|
|
57359
57462
|
if (typeSet.length === 1) {
|
|
57360
57463
|
return typeSet[0];
|
|
57361
57464
|
}
|
|
57465
|
+
if (typeSet.length === 2) {
|
|
57466
|
+
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57467
|
+
const typeVariable = typeSet[typeVarIndex];
|
|
57468
|
+
const primitiveType = typeSet[1 - typeVarIndex];
|
|
57469
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57470
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57471
|
+
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
57472
|
+
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
57473
|
+
return typeVariable;
|
|
57474
|
+
}
|
|
57475
|
+
if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
|
|
57476
|
+
if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
|
|
57477
|
+
return neverType;
|
|
57478
|
+
}
|
|
57479
|
+
}
|
|
57480
|
+
objectFlags = 67108864 /* IsConstrainedTypeVariable */;
|
|
57481
|
+
}
|
|
57482
|
+
}
|
|
57483
|
+
}
|
|
57362
57484
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
57363
57485
|
let result = intersectionTypes.get(id);
|
|
57364
57486
|
if (!result) {
|
|
@@ -57381,7 +57503,7 @@ function createTypeChecker(host) {
|
|
|
57381
57503
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
57382
57504
|
}
|
|
57383
57505
|
} else {
|
|
57384
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
57506
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
57385
57507
|
}
|
|
57386
57508
|
intersectionTypes.set(id, result);
|
|
57387
57509
|
}
|
|
@@ -57538,7 +57660,7 @@ function createTypeChecker(host) {
|
|
|
57538
57660
|
);
|
|
57539
57661
|
}
|
|
57540
57662
|
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));
|
|
57663
|
+
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
57664
|
}
|
|
57543
57665
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
57544
57666
|
type = getReducedType(type);
|
|
@@ -58022,7 +58144,7 @@ function createTypeChecker(host) {
|
|
|
58022
58144
|
}
|
|
58023
58145
|
}
|
|
58024
58146
|
if (isGenericMappedType(objectType)) {
|
|
58025
|
-
if (
|
|
58147
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
58026
58148
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
58027
58149
|
}
|
|
58028
58150
|
}
|
|
@@ -63930,12 +64052,12 @@ function createTypeChecker(host) {
|
|
|
63930
64052
|
return false;
|
|
63931
64053
|
}
|
|
63932
64054
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
63933
|
-
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
63934
|
-
return true;
|
|
63935
|
-
}
|
|
63936
64055
|
if (target.flags & 2097152 /* Intersection */) {
|
|
63937
64056
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
63938
64057
|
}
|
|
64058
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
64059
|
+
return true;
|
|
64060
|
+
}
|
|
63939
64061
|
if (source.flags & 128 /* StringLiteral */) {
|
|
63940
64062
|
const value = source.value;
|
|
63941
64063
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
@@ -63952,7 +64074,7 @@ function createTypeChecker(host) {
|
|
|
63952
64074
|
const texts = source.texts;
|
|
63953
64075
|
return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target);
|
|
63954
64076
|
}
|
|
63955
|
-
return
|
|
64077
|
+
return false;
|
|
63956
64078
|
}
|
|
63957
64079
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
63958
64080
|
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 +64196,8 @@ function createTypeChecker(host) {
|
|
|
64074
64196
|
source = getIntersectionType(sources);
|
|
64075
64197
|
target = getIntersectionType(targets);
|
|
64076
64198
|
}
|
|
64077
|
-
}
|
|
64199
|
+
}
|
|
64200
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
64078
64201
|
target = getActualTypeVariable(target);
|
|
64079
64202
|
}
|
|
64080
64203
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -64349,7 +64472,7 @@ function createTypeChecker(host) {
|
|
|
64349
64472
|
}
|
|
64350
64473
|
}
|
|
64351
64474
|
function inferToMappedType(source, target, constraintType) {
|
|
64352
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
64475
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
64353
64476
|
let result = false;
|
|
64354
64477
|
for (const type of constraintType.types) {
|
|
64355
64478
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -71091,19 +71214,9 @@ function createTypeChecker(host) {
|
|
|
71091
71214
|
return Debug.fail();
|
|
71092
71215
|
}
|
|
71093
71216
|
}
|
|
71094
|
-
function getDiagnosticSpanForCallNode(node
|
|
71095
|
-
let start;
|
|
71096
|
-
let length2;
|
|
71217
|
+
function getDiagnosticSpanForCallNode(node) {
|
|
71097
71218
|
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
|
-
}
|
|
71219
|
+
const { start, length: length2 } = getErrorSpanForNode(sourceFile, isPropertyAccessExpression(node.expression) ? node.expression.name : node.expression);
|
|
71107
71220
|
return { start, length: length2, sourceFile };
|
|
71108
71221
|
}
|
|
71109
71222
|
function getDiagnosticForCallNode(node, message, ...args) {
|
|
@@ -71120,6 +71233,18 @@ function createTypeChecker(host) {
|
|
|
71120
71233
|
return createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, message);
|
|
71121
71234
|
}
|
|
71122
71235
|
}
|
|
71236
|
+
function getErrorNodeForCallNode(callLike) {
|
|
71237
|
+
if (isCallOrNewExpression(callLike)) {
|
|
71238
|
+
return isPropertyAccessExpression(callLike.expression) ? callLike.expression.name : callLike.expression;
|
|
71239
|
+
}
|
|
71240
|
+
if (isTaggedTemplateExpression(callLike)) {
|
|
71241
|
+
return isPropertyAccessExpression(callLike.tag) ? callLike.tag.name : callLike.tag;
|
|
71242
|
+
}
|
|
71243
|
+
if (isJsxOpeningLikeElement(callLike)) {
|
|
71244
|
+
return callLike.tagName;
|
|
71245
|
+
}
|
|
71246
|
+
return callLike;
|
|
71247
|
+
}
|
|
71123
71248
|
function isPromiseResolveArityError(node) {
|
|
71124
71249
|
if (!isCallExpression(node) || !isIdentifier(node.expression))
|
|
71125
71250
|
return false;
|
|
@@ -71421,7 +71546,7 @@ function createTypeChecker(host) {
|
|
|
71421
71546
|
const { file, start, length: length2 } = diags[0];
|
|
71422
71547
|
diag2 = { file, start, length: length2, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
|
|
71423
71548
|
} else {
|
|
71424
|
-
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, chain, related);
|
|
71549
|
+
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), getErrorNodeForCallNode(node), chain, related);
|
|
71425
71550
|
}
|
|
71426
71551
|
addImplementationSuccessElaboration(candidatesForArgumentError[0], diag2);
|
|
71427
71552
|
diagnostics.add(diag2);
|
|
@@ -71741,7 +71866,7 @@ function createTypeChecker(host) {
|
|
|
71741
71866
|
}
|
|
71742
71867
|
return resolveErrorCall(node);
|
|
71743
71868
|
}
|
|
71744
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
71869
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
71745
71870
|
skippedGenericFunction(node, checkMode);
|
|
71746
71871
|
return resolvingSignature;
|
|
71747
71872
|
}
|
|
@@ -71751,8 +71876,12 @@ function createTypeChecker(host) {
|
|
|
71751
71876
|
}
|
|
71752
71877
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
71753
71878
|
}
|
|
71754
|
-
function
|
|
71755
|
-
|
|
71879
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
71880
|
+
if (!signature.typeParameters) {
|
|
71881
|
+
return false;
|
|
71882
|
+
}
|
|
71883
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
71884
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
71756
71885
|
}
|
|
71757
71886
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
71758
71887
|
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 +72078,7 @@ function createTypeChecker(host) {
|
|
|
71949
72078
|
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
|
71950
72079
|
}
|
|
71951
72080
|
if (isCallExpression(errorTarget.parent)) {
|
|
71952
|
-
const { start, length: length2 } = getDiagnosticSpanForCallNode(
|
|
71953
|
-
errorTarget.parent,
|
|
71954
|
-
/*doNotIncludeArguments*/
|
|
71955
|
-
true
|
|
71956
|
-
);
|
|
72081
|
+
const { start, length: length2 } = getDiagnosticSpanForCallNode(errorTarget.parent);
|
|
71957
72082
|
diagnostic.start = start;
|
|
71958
72083
|
diagnostic.length = length2;
|
|
71959
72084
|
}
|
|
@@ -75323,16 +75448,19 @@ function createTypeChecker(host) {
|
|
|
75323
75448
|
}
|
|
75324
75449
|
}
|
|
75325
75450
|
}
|
|
75326
|
-
function
|
|
75451
|
+
function getNonGenericReturnTypeOfSingleCallSignature(funcType) {
|
|
75327
75452
|
const signature = getSingleCallSignature(funcType);
|
|
75328
|
-
if (signature
|
|
75329
|
-
|
|
75453
|
+
if (signature) {
|
|
75454
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
75455
|
+
if (!signature.typeParameters || !couldContainTypeVariables(returnType)) {
|
|
75456
|
+
return returnType;
|
|
75457
|
+
}
|
|
75330
75458
|
}
|
|
75331
75459
|
}
|
|
75332
75460
|
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
|
|
75333
75461
|
const funcType = checkExpression(expr.expression);
|
|
75334
75462
|
const nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
|
|
75335
|
-
const returnType =
|
|
75463
|
+
const returnType = getNonGenericReturnTypeOfSingleCallSignature(funcType);
|
|
75336
75464
|
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
|
|
75337
75465
|
}
|
|
75338
75466
|
function getTypeOfExpression(node) {
|
|
@@ -75377,7 +75505,7 @@ function createTypeChecker(host) {
|
|
|
75377
75505
|
/*requireStringLiteralLikeArgument*/
|
|
75378
75506
|
true
|
|
75379
75507
|
) && !isSymbolOrSymbolForCall(expr)) {
|
|
75380
|
-
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
|
75508
|
+
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getNonGenericReturnTypeOfSingleCallSignature(checkNonNullExpression(expr.expression));
|
|
75381
75509
|
} else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
|
|
75382
75510
|
return getTypeFromTypeNode(expr.type);
|
|
75383
75511
|
} else if (isLiteralExpression(node) || isBooleanLiteral(node)) {
|
|
@@ -76249,7 +76377,8 @@ function createTypeChecker(host) {
|
|
|
76249
76377
|
}
|
|
76250
76378
|
const objectType = type.objectType;
|
|
76251
76379
|
const indexType = type.indexType;
|
|
76252
|
-
|
|
76380
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
76381
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
76253
76382
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
76254
76383
|
error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
76255
76384
|
}
|