@typescript-deploys/pr-build 5.4.0-pr-56467-3 → 5.4.0-pr-56506-20
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 +208 -63
- package/lib/tsserver.js +263 -101
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +263 -101
- package/lib/typingsInstaller.js +5 -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.20231205`;
|
|
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) => {
|
|
@@ -33126,6 +33128,8 @@ var Parser;
|
|
|
33126
33128
|
break;
|
|
33127
33129
|
case "template":
|
|
33128
33130
|
return parseTemplateTag(start2, tagName, indent2, indentText);
|
|
33131
|
+
case "this":
|
|
33132
|
+
return parseThisTag(start2, tagName, indent2, indentText);
|
|
33129
33133
|
default:
|
|
33130
33134
|
return false;
|
|
33131
33135
|
}
|
|
@@ -44705,7 +44709,7 @@ function createTypeChecker(host) {
|
|
|
44705
44709
|
return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, 260 /* VariableDeclaration */), usage);
|
|
44706
44710
|
} else if (declaration.kind === 260 /* VariableDeclaration */) {
|
|
44707
44711
|
return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
|
|
44708
|
-
} else if (
|
|
44712
|
+
} else if (isClassLike(declaration)) {
|
|
44709
44713
|
return !findAncestor(usage, (n) => isComputedPropertyName(n) && n.parent.parent === declaration);
|
|
44710
44714
|
} else if (isPropertyDeclaration(declaration)) {
|
|
44711
44715
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
@@ -46974,6 +46978,10 @@ function createTypeChecker(host) {
|
|
|
46974
46978
|
function getParentOfSymbol(symbol) {
|
|
46975
46979
|
return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
|
|
46976
46980
|
}
|
|
46981
|
+
function getFunctionExpressionParentSymbolOrSymbol(symbol) {
|
|
46982
|
+
var _a, _b;
|
|
46983
|
+
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;
|
|
46984
|
+
}
|
|
46977
46985
|
function getAlternativeContainingModules(symbol, enclosingDeclaration) {
|
|
46978
46986
|
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
|
46979
46987
|
const id = getNodeId(containingFile);
|
|
@@ -52197,11 +52205,14 @@ function createTypeChecker(host) {
|
|
|
52197
52205
|
}
|
|
52198
52206
|
}
|
|
52199
52207
|
if ((_a = symbol.parent) == null ? void 0 : _a.valueDeclaration) {
|
|
52200
|
-
const
|
|
52201
|
-
if (
|
|
52202
|
-
const
|
|
52203
|
-
if (
|
|
52204
|
-
|
|
52208
|
+
const possiblyAnnotatedSymbol = getFunctionExpressionParentSymbolOrSymbol(symbol.parent);
|
|
52209
|
+
if (possiblyAnnotatedSymbol.valueDeclaration) {
|
|
52210
|
+
const typeNode2 = getEffectiveTypeAnnotationNode(possiblyAnnotatedSymbol.valueDeclaration);
|
|
52211
|
+
if (typeNode2) {
|
|
52212
|
+
const annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode2), symbol.escapedName);
|
|
52213
|
+
if (annotationSymbol) {
|
|
52214
|
+
return getNonMissingTypeOfSymbol(annotationSymbol);
|
|
52215
|
+
}
|
|
52205
52216
|
}
|
|
52206
52217
|
}
|
|
52207
52218
|
}
|
|
@@ -53501,7 +53512,6 @@ function createTypeChecker(host) {
|
|
|
53501
53512
|
return links.resolvedSymbol;
|
|
53502
53513
|
}
|
|
53503
53514
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
53504
|
-
var _a, _b, _c;
|
|
53505
53515
|
const links = getSymbolLinks(symbol);
|
|
53506
53516
|
if (!links[resolutionKind]) {
|
|
53507
53517
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -53520,7 +53530,7 @@ function createTypeChecker(host) {
|
|
|
53520
53530
|
}
|
|
53521
53531
|
}
|
|
53522
53532
|
}
|
|
53523
|
-
const assignments = (
|
|
53533
|
+
const assignments = getFunctionExpressionParentSymbolOrSymbol(symbol).assignmentDeclarationMembers;
|
|
53524
53534
|
if (assignments) {
|
|
53525
53535
|
const decls = arrayFrom(assignments.values());
|
|
53526
53536
|
for (const member of decls) {
|
|
@@ -53817,6 +53827,15 @@ function createTypeChecker(host) {
|
|
|
53817
53827
|
let result;
|
|
53818
53828
|
for (let i = 0; i < signatureLists.length; i++) {
|
|
53819
53829
|
const match = i === listIndex ? signature : findMatchingSignature(
|
|
53830
|
+
signatureLists[i],
|
|
53831
|
+
signature,
|
|
53832
|
+
/*partialMatch*/
|
|
53833
|
+
false,
|
|
53834
|
+
/*ignoreThisTypes*/
|
|
53835
|
+
false,
|
|
53836
|
+
/*ignoreReturnTypes*/
|
|
53837
|
+
true
|
|
53838
|
+
) || findMatchingSignature(
|
|
53820
53839
|
signatureLists[i],
|
|
53821
53840
|
signature,
|
|
53822
53841
|
/*partialMatch*/
|
|
@@ -54190,6 +54209,18 @@ function createTypeChecker(host) {
|
|
|
54190
54209
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
54191
54210
|
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
|
|
54192
54211
|
}
|
|
54212
|
+
function getLimitedConstraint(type) {
|
|
54213
|
+
const constraint = getConstraintTypeFromMappedType(type.mappedType);
|
|
54214
|
+
if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
|
|
54215
|
+
return;
|
|
54216
|
+
}
|
|
54217
|
+
const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
|
|
54218
|
+
if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
|
|
54219
|
+
return;
|
|
54220
|
+
}
|
|
54221
|
+
const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
|
|
54222
|
+
return limitedConstraint !== neverType ? limitedConstraint : void 0;
|
|
54223
|
+
}
|
|
54193
54224
|
function resolveReverseMappedTypeMembers(type) {
|
|
54194
54225
|
const indexInfo = getIndexInfoOfType(type.source, stringType);
|
|
54195
54226
|
const modifiers = getMappedTypeModifiers(type.mappedType);
|
|
@@ -54197,7 +54228,14 @@ function createTypeChecker(host) {
|
|
|
54197
54228
|
const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
|
|
54198
54229
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
54199
54230
|
const members = createSymbolTable();
|
|
54231
|
+
const limitedConstraint = getLimitedConstraint(type);
|
|
54200
54232
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
54233
|
+
if (limitedConstraint) {
|
|
54234
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
54235
|
+
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
54236
|
+
continue;
|
|
54237
|
+
}
|
|
54238
|
+
}
|
|
54201
54239
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
54202
54240
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
54203
54241
|
inferredProp.declarations = prop.declarations;
|
|
@@ -54278,7 +54316,7 @@ function createTypeChecker(host) {
|
|
|
54278
54316
|
const constraintType = getConstraintTypeFromMappedType(type);
|
|
54279
54317
|
const mappedType = type.target || type;
|
|
54280
54318
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
54281
|
-
const shouldLinkPropDeclarations =
|
|
54319
|
+
const shouldLinkPropDeclarations = getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */;
|
|
54282
54320
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
54283
54321
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
54284
54322
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
@@ -54420,9 +54458,12 @@ function createTypeChecker(host) {
|
|
|
54420
54458
|
}
|
|
54421
54459
|
return false;
|
|
54422
54460
|
}
|
|
54423
|
-
function
|
|
54461
|
+
function getMappedTypeNameTypeKind(type) {
|
|
54424
54462
|
const nameType = getNameTypeFromMappedType(type);
|
|
54425
|
-
|
|
54463
|
+
if (!nameType) {
|
|
54464
|
+
return 0 /* None */;
|
|
54465
|
+
}
|
|
54466
|
+
return isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)) ? 1 /* Filtering */ : 2 /* Remapping */;
|
|
54426
54467
|
}
|
|
54427
54468
|
function resolveStructuredTypeMembers(type) {
|
|
54428
54469
|
if (!type.members) {
|
|
@@ -54471,7 +54512,12 @@ function createTypeChecker(host) {
|
|
|
54471
54512
|
for (const current of type.types) {
|
|
54472
54513
|
for (const prop of getPropertiesOfType(current)) {
|
|
54473
54514
|
if (!members.has(prop.escapedName)) {
|
|
54474
|
-
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
54515
|
+
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
54516
|
+
type,
|
|
54517
|
+
prop.escapedName,
|
|
54518
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
54519
|
+
!!(type.flags & 2097152 /* Intersection */)
|
|
54520
|
+
);
|
|
54475
54521
|
if (combinedProp) {
|
|
54476
54522
|
members.set(prop.escapedName, combinedProp);
|
|
54477
54523
|
}
|
|
@@ -54961,13 +55007,17 @@ function createTypeChecker(host) {
|
|
|
54961
55007
|
return result;
|
|
54962
55008
|
}
|
|
54963
55009
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
54964
|
-
var _a, _b;
|
|
55010
|
+
var _a, _b, _c;
|
|
54965
55011
|
let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
|
|
54966
55012
|
if (!property) {
|
|
54967
55013
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
54968
55014
|
if (property) {
|
|
54969
55015
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
54970
55016
|
properties.set(name, property);
|
|
55017
|
+
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
55018
|
+
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
55019
|
+
properties2.set(name, property);
|
|
55020
|
+
}
|
|
54971
55021
|
}
|
|
54972
55022
|
}
|
|
54973
55023
|
return property;
|
|
@@ -55077,7 +55127,22 @@ function createTypeChecker(host) {
|
|
|
55077
55127
|
}
|
|
55078
55128
|
return getPropertyOfObjectType(globalObjectType, name);
|
|
55079
55129
|
}
|
|
55080
|
-
if (type.flags &
|
|
55130
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
55131
|
+
const prop = getPropertyOfUnionOrIntersectionType(
|
|
55132
|
+
type,
|
|
55133
|
+
name,
|
|
55134
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
55135
|
+
true
|
|
55136
|
+
);
|
|
55137
|
+
if (prop) {
|
|
55138
|
+
return prop;
|
|
55139
|
+
}
|
|
55140
|
+
if (!skipObjectFunctionPropertyAugment) {
|
|
55141
|
+
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
55142
|
+
}
|
|
55143
|
+
return void 0;
|
|
55144
|
+
}
|
|
55145
|
+
if (type.flags & 1048576 /* Union */) {
|
|
55081
55146
|
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
55082
55147
|
}
|
|
55083
55148
|
return void 0;
|
|
@@ -55262,6 +55327,7 @@ function createTypeChecker(host) {
|
|
|
55262
55327
|
let flags = 0 /* None */;
|
|
55263
55328
|
let minArgumentCount = 0;
|
|
55264
55329
|
let thisParameter;
|
|
55330
|
+
let thisTag = isInJSFile(declaration) ? getJSDocThisTag(declaration) : void 0;
|
|
55265
55331
|
let hasThisParameter = false;
|
|
55266
55332
|
const iife = getImmediatelyInvokedFunctionExpression(declaration);
|
|
55267
55333
|
const isJSConstructSignature = isJSDocConstructSignature(declaration);
|
|
@@ -55271,6 +55337,10 @@ function createTypeChecker(host) {
|
|
|
55271
55337
|
}
|
|
55272
55338
|
for (let i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
|
|
55273
55339
|
const param = declaration.parameters[i];
|
|
55340
|
+
if (isInJSFile(param) && isJSDocThisTag(param)) {
|
|
55341
|
+
thisTag = param;
|
|
55342
|
+
continue;
|
|
55343
|
+
}
|
|
55274
55344
|
let paramSymbol = param.symbol;
|
|
55275
55345
|
const type = isJSDocParameterTag(param) ? param.typeExpression && param.typeExpression.type : param.type;
|
|
55276
55346
|
if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !isBindingPattern(param.name)) {
|
|
@@ -55308,11 +55378,8 @@ function createTypeChecker(host) {
|
|
|
55308
55378
|
thisParameter = getAnnotatedAccessorThisParameter(other);
|
|
55309
55379
|
}
|
|
55310
55380
|
}
|
|
55311
|
-
if (
|
|
55312
|
-
|
|
55313
|
-
if (thisTag && thisTag.typeExpression) {
|
|
55314
|
-
thisParameter = createSymbolWithType(createSymbol(1 /* FunctionScopedVariable */, "this" /* This */), getTypeFromTypeNode(thisTag.typeExpression));
|
|
55315
|
-
}
|
|
55381
|
+
if (thisTag && thisTag.typeExpression) {
|
|
55382
|
+
thisParameter = createSymbolWithType(createSymbol(1 /* FunctionScopedVariable */, "this" /* This */), getTypeFromTypeNode(thisTag.typeExpression));
|
|
55316
55383
|
}
|
|
55317
55384
|
const hostDeclaration = isJSDocSignature(declaration) ? getEffectiveJSDocHost(declaration) : declaration;
|
|
55318
55385
|
const classType = hostDeclaration && isConstructorDeclaration(hostDeclaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(hostDeclaration.parent.symbol)) : void 0;
|
|
@@ -56934,6 +57001,8 @@ function createTypeChecker(host) {
|
|
|
56934
57001
|
includes |= flags & 473694207 /* IncludesMask */;
|
|
56935
57002
|
if (flags & 465829888 /* Instantiable */)
|
|
56936
57003
|
includes |= 33554432 /* IncludesInstantiable */;
|
|
57004
|
+
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
|
|
57005
|
+
includes |= 268435456 /* IncludesConstrainedTypeVariable */;
|
|
56937
57006
|
if (type === wildcardType)
|
|
56938
57007
|
includes |= 8388608 /* IncludesWildcard */;
|
|
56939
57008
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -57038,6 +57107,41 @@ function createTypeChecker(host) {
|
|
|
57038
57107
|
}
|
|
57039
57108
|
}
|
|
57040
57109
|
}
|
|
57110
|
+
function removeConstrainedTypeVariables(types) {
|
|
57111
|
+
const typeVariables = [];
|
|
57112
|
+
for (const type of types) {
|
|
57113
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57114
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57115
|
+
pushIfUnique(typeVariables, type.types[index]);
|
|
57116
|
+
}
|
|
57117
|
+
}
|
|
57118
|
+
for (const typeVariable of typeVariables) {
|
|
57119
|
+
const primitives = [];
|
|
57120
|
+
for (const type of types) {
|
|
57121
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57122
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57123
|
+
if (type.types[index] === typeVariable) {
|
|
57124
|
+
insertType(primitives, type.types[1 - index]);
|
|
57125
|
+
}
|
|
57126
|
+
}
|
|
57127
|
+
}
|
|
57128
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57129
|
+
if (everyType(constraint, (t) => containsType(primitives, t))) {
|
|
57130
|
+
let i = types.length;
|
|
57131
|
+
while (i > 0) {
|
|
57132
|
+
i--;
|
|
57133
|
+
const type = types[i];
|
|
57134
|
+
if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
|
|
57135
|
+
const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57136
|
+
if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
|
|
57137
|
+
orderedRemoveItemAt(types, i);
|
|
57138
|
+
}
|
|
57139
|
+
}
|
|
57140
|
+
}
|
|
57141
|
+
insertType(types, typeVariable);
|
|
57142
|
+
}
|
|
57143
|
+
}
|
|
57144
|
+
}
|
|
57041
57145
|
function isNamedUnionType(type) {
|
|
57042
57146
|
return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
|
|
57043
57147
|
}
|
|
@@ -57103,6 +57207,9 @@ function createTypeChecker(host) {
|
|
|
57103
57207
|
if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
|
|
57104
57208
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
57105
57209
|
}
|
|
57210
|
+
if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
|
|
57211
|
+
removeConstrainedTypeVariables(typeSet);
|
|
57212
|
+
}
|
|
57106
57213
|
if (unionReduction === 2 /* Subtype */) {
|
|
57107
57214
|
typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
|
|
57108
57215
|
if (!typeSet) {
|
|
@@ -57315,9 +57422,9 @@ function createTypeChecker(host) {
|
|
|
57315
57422
|
types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
|
|
57316
57423
|
return true;
|
|
57317
57424
|
}
|
|
57318
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
57425
|
+
function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
|
|
57319
57426
|
const result = createType(2097152 /* Intersection */);
|
|
57320
|
-
result.objectFlags = getPropagatingFlagsOfTypes(
|
|
57427
|
+
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
57321
57428
|
types,
|
|
57322
57429
|
/*excludeKinds*/
|
|
57323
57430
|
98304 /* Nullable */
|
|
@@ -57331,6 +57438,7 @@ function createTypeChecker(host) {
|
|
|
57331
57438
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
57332
57439
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
57333
57440
|
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
57441
|
+
let objectFlags = 0 /* None */;
|
|
57334
57442
|
if (includes & 131072 /* Never */) {
|
|
57335
57443
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
57336
57444
|
}
|
|
@@ -57359,6 +57467,25 @@ function createTypeChecker(host) {
|
|
|
57359
57467
|
if (typeSet.length === 1) {
|
|
57360
57468
|
return typeSet[0];
|
|
57361
57469
|
}
|
|
57470
|
+
if (typeSet.length === 2) {
|
|
57471
|
+
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57472
|
+
const typeVariable = typeSet[typeVarIndex];
|
|
57473
|
+
const primitiveType = typeSet[1 - typeVarIndex];
|
|
57474
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57475
|
+
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57476
|
+
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
57477
|
+
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
57478
|
+
return typeVariable;
|
|
57479
|
+
}
|
|
57480
|
+
if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
|
|
57481
|
+
if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
|
|
57482
|
+
return neverType;
|
|
57483
|
+
}
|
|
57484
|
+
}
|
|
57485
|
+
objectFlags = 67108864 /* IsConstrainedTypeVariable */;
|
|
57486
|
+
}
|
|
57487
|
+
}
|
|
57488
|
+
}
|
|
57362
57489
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
57363
57490
|
let result = intersectionTypes.get(id);
|
|
57364
57491
|
if (!result) {
|
|
@@ -57381,7 +57508,7 @@ function createTypeChecker(host) {
|
|
|
57381
57508
|
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
57382
57509
|
}
|
|
57383
57510
|
} else {
|
|
57384
|
-
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
57511
|
+
result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
|
|
57385
57512
|
}
|
|
57386
57513
|
intersectionTypes.set(id, result);
|
|
57387
57514
|
}
|
|
@@ -57538,7 +57665,7 @@ function createTypeChecker(host) {
|
|
|
57538
57665
|
);
|
|
57539
57666
|
}
|
|
57540
57667
|
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));
|
|
57668
|
+
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
57669
|
}
|
|
57543
57670
|
function getIndexType(type, indexFlags = defaultIndexFlags) {
|
|
57544
57671
|
type = getReducedType(type);
|
|
@@ -58022,7 +58149,7 @@ function createTypeChecker(host) {
|
|
|
58022
58149
|
}
|
|
58023
58150
|
}
|
|
58024
58151
|
if (isGenericMappedType(objectType)) {
|
|
58025
|
-
if (
|
|
58152
|
+
if (getMappedTypeNameTypeKind(objectType) !== 2 /* Remapping */) {
|
|
58026
58153
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
|
|
58027
58154
|
}
|
|
58028
58155
|
}
|
|
@@ -60051,8 +60178,8 @@ function createTypeChecker(host) {
|
|
|
60051
60178
|
const sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
|
|
60052
60179
|
const targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
|
|
60053
60180
|
if (sourceType && targetType) {
|
|
60054
|
-
const sourceSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
60055
|
-
const targetSig = checkMode & 3 /* Callback */ ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
60181
|
+
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
60182
|
+
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
60056
60183
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
60057
60184
|
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
60058
60185
|
sourceType,
|
|
@@ -63930,12 +64057,12 @@ function createTypeChecker(host) {
|
|
|
63930
64057
|
return false;
|
|
63931
64058
|
}
|
|
63932
64059
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
63933
|
-
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
63934
|
-
return true;
|
|
63935
|
-
}
|
|
63936
64060
|
if (target.flags & 2097152 /* Intersection */) {
|
|
63937
64061
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
63938
64062
|
}
|
|
64063
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
64064
|
+
return true;
|
|
64065
|
+
}
|
|
63939
64066
|
if (source.flags & 128 /* StringLiteral */) {
|
|
63940
64067
|
const value = source.value;
|
|
63941
64068
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
@@ -63952,7 +64079,7 @@ function createTypeChecker(host) {
|
|
|
63952
64079
|
const texts = source.texts;
|
|
63953
64080
|
return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target);
|
|
63954
64081
|
}
|
|
63955
|
-
return
|
|
64082
|
+
return false;
|
|
63956
64083
|
}
|
|
63957
64084
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
63958
64085
|
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 +64201,8 @@ function createTypeChecker(host) {
|
|
|
64074
64201
|
source = getIntersectionType(sources);
|
|
64075
64202
|
target = getIntersectionType(targets);
|
|
64076
64203
|
}
|
|
64077
|
-
}
|
|
64204
|
+
}
|
|
64205
|
+
if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
|
|
64078
64206
|
target = getActualTypeVariable(target);
|
|
64079
64207
|
}
|
|
64080
64208
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
@@ -64349,7 +64477,7 @@ function createTypeChecker(host) {
|
|
|
64349
64477
|
}
|
|
64350
64478
|
}
|
|
64351
64479
|
function inferToMappedType(source, target, constraintType) {
|
|
64352
|
-
if (constraintType.flags & 1048576 /* Union */) {
|
|
64480
|
+
if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
|
|
64353
64481
|
let result = false;
|
|
64354
64482
|
for (const type of constraintType.types) {
|
|
64355
64483
|
result = inferToMappedType(source, target, type) || result;
|
|
@@ -70601,6 +70729,10 @@ function createTypeChecker(host) {
|
|
|
70601
70729
|
const minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
|
|
70602
70730
|
return !some(typeArguments) || typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters;
|
|
70603
70731
|
}
|
|
70732
|
+
function isInstantiatedGenericParameter(signature, pos) {
|
|
70733
|
+
let type;
|
|
70734
|
+
return !!(signature.target && (type = tryGetTypeAtPosition(signature.target, pos)) && isGenericType(type));
|
|
70735
|
+
}
|
|
70604
70736
|
function getSingleCallSignature(type) {
|
|
70605
70737
|
return getSingleSignature(
|
|
70606
70738
|
type,
|
|
@@ -71091,19 +71223,9 @@ function createTypeChecker(host) {
|
|
|
71091
71223
|
return Debug.fail();
|
|
71092
71224
|
}
|
|
71093
71225
|
}
|
|
71094
|
-
function getDiagnosticSpanForCallNode(node
|
|
71095
|
-
let start;
|
|
71096
|
-
let length2;
|
|
71226
|
+
function getDiagnosticSpanForCallNode(node) {
|
|
71097
71227
|
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
|
-
}
|
|
71228
|
+
const { start, length: length2 } = getErrorSpanForNode(sourceFile, isPropertyAccessExpression(node.expression) ? node.expression.name : node.expression);
|
|
71107
71229
|
return { start, length: length2, sourceFile };
|
|
71108
71230
|
}
|
|
71109
71231
|
function getDiagnosticForCallNode(node, message, ...args) {
|
|
@@ -71120,6 +71242,18 @@ function createTypeChecker(host) {
|
|
|
71120
71242
|
return createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, message);
|
|
71121
71243
|
}
|
|
71122
71244
|
}
|
|
71245
|
+
function getErrorNodeForCallNode(callLike) {
|
|
71246
|
+
if (isCallOrNewExpression(callLike)) {
|
|
71247
|
+
return isPropertyAccessExpression(callLike.expression) ? callLike.expression.name : callLike.expression;
|
|
71248
|
+
}
|
|
71249
|
+
if (isTaggedTemplateExpression(callLike)) {
|
|
71250
|
+
return isPropertyAccessExpression(callLike.tag) ? callLike.tag.name : callLike.tag;
|
|
71251
|
+
}
|
|
71252
|
+
if (isJsxOpeningLikeElement(callLike)) {
|
|
71253
|
+
return callLike.tagName;
|
|
71254
|
+
}
|
|
71255
|
+
return callLike;
|
|
71256
|
+
}
|
|
71123
71257
|
function isPromiseResolveArityError(node) {
|
|
71124
71258
|
if (!isCallExpression(node) || !isIdentifier(node.expression))
|
|
71125
71259
|
return false;
|
|
@@ -71421,7 +71555,7 @@ function createTypeChecker(host) {
|
|
|
71421
71555
|
const { file, start, length: length2 } = diags[0];
|
|
71422
71556
|
diag2 = { file, start, length: length2, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
|
|
71423
71557
|
} else {
|
|
71424
|
-
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), node, chain, related);
|
|
71558
|
+
diag2 = createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(node), getErrorNodeForCallNode(node), chain, related);
|
|
71425
71559
|
}
|
|
71426
71560
|
addImplementationSuccessElaboration(candidatesForArgumentError[0], diag2);
|
|
71427
71561
|
diagnostics.add(diag2);
|
|
@@ -71741,7 +71875,7 @@ function createTypeChecker(host) {
|
|
|
71741
71875
|
}
|
|
71742
71876
|
return resolveErrorCall(node);
|
|
71743
71877
|
}
|
|
71744
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
71878
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunctionOrConstructor)) {
|
|
71745
71879
|
skippedGenericFunction(node, checkMode);
|
|
71746
71880
|
return resolvingSignature;
|
|
71747
71881
|
}
|
|
@@ -71751,8 +71885,12 @@ function createTypeChecker(host) {
|
|
|
71751
71885
|
}
|
|
71752
71886
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
71753
71887
|
}
|
|
71754
|
-
function
|
|
71755
|
-
|
|
71888
|
+
function isGenericFunctionReturningFunctionOrConstructor(signature) {
|
|
71889
|
+
if (!signature.typeParameters) {
|
|
71890
|
+
return false;
|
|
71891
|
+
}
|
|
71892
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
71893
|
+
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
71756
71894
|
}
|
|
71757
71895
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
71758
71896
|
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 +72087,7 @@ function createTypeChecker(host) {
|
|
|
71949
72087
|
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
|
71950
72088
|
}
|
|
71951
72089
|
if (isCallExpression(errorTarget.parent)) {
|
|
71952
|
-
const { start, length: length2 } = getDiagnosticSpanForCallNode(
|
|
71953
|
-
errorTarget.parent,
|
|
71954
|
-
/*doNotIncludeArguments*/
|
|
71955
|
-
true
|
|
71956
|
-
);
|
|
72090
|
+
const { start, length: length2 } = getDiagnosticSpanForCallNode(errorTarget.parent);
|
|
71957
72091
|
diagnostic.start = start;
|
|
71958
72092
|
diagnostic.length = length2;
|
|
71959
72093
|
}
|
|
@@ -73014,9 +73148,16 @@ function createTypeChecker(host) {
|
|
|
73014
73148
|
const len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
73015
73149
|
for (let i = 0; i < len; i++) {
|
|
73016
73150
|
const parameter = signature.parameters[i];
|
|
73017
|
-
|
|
73018
|
-
|
|
73019
|
-
|
|
73151
|
+
const declaration = parameter.valueDeclaration;
|
|
73152
|
+
if (!getEffectiveTypeAnnotationNode(declaration)) {
|
|
73153
|
+
let type = tryGetTypeAtPosition(context, i);
|
|
73154
|
+
if (type && declaration.initializer) {
|
|
73155
|
+
let initializerType = checkDeclarationInitializer(declaration, 0 /* Normal */);
|
|
73156
|
+
if (!isTypeAssignableTo(initializerType, type) && isTypeAssignableTo(type, initializerType = widenTypeInferredFromInitializer(declaration, initializerType))) {
|
|
73157
|
+
type = initializerType;
|
|
73158
|
+
}
|
|
73159
|
+
}
|
|
73160
|
+
assignParameterType(parameter, type);
|
|
73020
73161
|
}
|
|
73021
73162
|
}
|
|
73022
73163
|
if (signatureHasRestParameter(signature)) {
|
|
@@ -75323,16 +75464,19 @@ function createTypeChecker(host) {
|
|
|
75323
75464
|
}
|
|
75324
75465
|
}
|
|
75325
75466
|
}
|
|
75326
|
-
function
|
|
75467
|
+
function getNonGenericReturnTypeOfSingleCallSignature(funcType) {
|
|
75327
75468
|
const signature = getSingleCallSignature(funcType);
|
|
75328
|
-
if (signature
|
|
75329
|
-
|
|
75469
|
+
if (signature) {
|
|
75470
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
75471
|
+
if (!signature.typeParameters || !couldContainTypeVariables(returnType)) {
|
|
75472
|
+
return returnType;
|
|
75473
|
+
}
|
|
75330
75474
|
}
|
|
75331
75475
|
}
|
|
75332
75476
|
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
|
|
75333
75477
|
const funcType = checkExpression(expr.expression);
|
|
75334
75478
|
const nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
|
|
75335
|
-
const returnType =
|
|
75479
|
+
const returnType = getNonGenericReturnTypeOfSingleCallSignature(funcType);
|
|
75336
75480
|
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
|
|
75337
75481
|
}
|
|
75338
75482
|
function getTypeOfExpression(node) {
|
|
@@ -75377,7 +75521,7 @@ function createTypeChecker(host) {
|
|
|
75377
75521
|
/*requireStringLiteralLikeArgument*/
|
|
75378
75522
|
true
|
|
75379
75523
|
) && !isSymbolOrSymbolForCall(expr)) {
|
|
75380
|
-
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
|
75524
|
+
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getNonGenericReturnTypeOfSingleCallSignature(checkNonNullExpression(expr.expression));
|
|
75381
75525
|
} else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
|
|
75382
75526
|
return getTypeFromTypeNode(expr.type);
|
|
75383
75527
|
} else if (isLiteralExpression(node) || isBooleanLiteral(node)) {
|
|
@@ -76249,7 +76393,8 @@ function createTypeChecker(host) {
|
|
|
76249
76393
|
}
|
|
76250
76394
|
const objectType = type.objectType;
|
|
76251
76395
|
const indexType = type.indexType;
|
|
76252
|
-
|
|
76396
|
+
const objectIndexType = isGenericMappedType(objectType) && getMappedTypeNameTypeKind(objectType) === 2 /* Remapping */ ? getIndexTypeForMappedType(objectType, 0 /* None */) : getIndexType(objectType, 0 /* None */);
|
|
76397
|
+
if (isTypeAssignableTo(indexType, objectIndexType)) {
|
|
76253
76398
|
if (accessNode.kind === 212 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
76254
76399
|
error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
76255
76400
|
}
|