typescript 5.1.0-dev.20230502 → 5.1.0-dev.20230506
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +91 -39
- package/lib/tsserver.js +93 -41
- package/lib/tsserverlibrary.js +93 -41
- package/lib/typescript.js +92 -40
- package/lib/typingsInstaller.js +38 -12
- 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.1";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20230506`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -7450,6 +7450,7 @@ var Diagnostics = {
|
|
|
7450
7450
|
You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, 1 /* Error */, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
|
|
7451
7451
|
Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files: diag(8037, 1 /* Error */, "Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files_8037", "Type satisfaction expressions can only be used in TypeScript files."),
|
|
7452
7452
|
Decorators_may_not_appear_after_export_or_export_default_if_they_also_appear_before_export: diag(8038, 1 /* Error */, "Decorators_may_not_appear_after_export_or_export_default_if_they_also_appear_before_export_8038", "Decorators may not appear after 'export' or 'export default' if they also appear before 'export'."),
|
|
7453
|
+
A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag: diag(8039, 1 /* Error */, "A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag_8039", "A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag"),
|
|
7453
7454
|
Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, 1 /* Error */, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
|
|
7454
7455
|
Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, 1 /* Error */, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
|
|
7455
7456
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
@@ -27168,8 +27169,13 @@ var Parser;
|
|
|
27168
27169
|
return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
|
|
27169
27170
|
case 14 /* JsxChildren */:
|
|
27170
27171
|
return true;
|
|
27172
|
+
case 25 /* JSDocComment */:
|
|
27173
|
+
return true;
|
|
27174
|
+
case 26 /* Count */:
|
|
27175
|
+
return Debug.fail("ParsingContext.Count used as a context");
|
|
27176
|
+
default:
|
|
27177
|
+
Debug.assertNever(parsingContext2, "Non-exhaustive case in 'isListElement'.");
|
|
27171
27178
|
}
|
|
27172
|
-
return Debug.fail("Non-exhaustive case in 'isListElement'.");
|
|
27173
27179
|
}
|
|
27174
27180
|
function isValidHeritageClauseObjectLiteral() {
|
|
27175
27181
|
Debug.assert(token() === 19 /* OpenBraceToken */);
|
|
@@ -27263,7 +27269,8 @@ var Parser;
|
|
|
27263
27269
|
return false;
|
|
27264
27270
|
}
|
|
27265
27271
|
function isInSomeParsingContext() {
|
|
27266
|
-
|
|
27272
|
+
Debug.assert(parsingContext, "Missing parsing context");
|
|
27273
|
+
for (let kind = 0; kind < 26 /* Count */; kind++) {
|
|
27267
27274
|
if (parsingContext & 1 << kind) {
|
|
27268
27275
|
if (isListElement(
|
|
27269
27276
|
kind,
|
|
@@ -27522,7 +27529,9 @@ var Parser;
|
|
|
27522
27529
|
return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
|
27523
27530
|
case 24 /* AssertEntries */:
|
|
27524
27531
|
return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected);
|
|
27525
|
-
case 25 /*
|
|
27532
|
+
case 25 /* JSDocComment */:
|
|
27533
|
+
return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
|
27534
|
+
case 26 /* Count */:
|
|
27526
27535
|
return Debug.fail("ParsingContext.Count used as a context");
|
|
27527
27536
|
default:
|
|
27528
27537
|
Debug.assertNever(context);
|
|
@@ -31654,7 +31663,8 @@ var Parser;
|
|
|
31654
31663
|
ParsingContext2[ParsingContext2["HeritageClauses"] = 22] = "HeritageClauses";
|
|
31655
31664
|
ParsingContext2[ParsingContext2["ImportOrExportSpecifiers"] = 23] = "ImportOrExportSpecifiers";
|
|
31656
31665
|
ParsingContext2[ParsingContext2["AssertEntries"] = 24] = "AssertEntries";
|
|
31657
|
-
ParsingContext2[ParsingContext2["
|
|
31666
|
+
ParsingContext2[ParsingContext2["JSDocComment"] = 25] = "JSDocComment";
|
|
31667
|
+
ParsingContext2[ParsingContext2["Count"] = 26] = "Count";
|
|
31658
31668
|
})(ParsingContext || (ParsingContext = {}));
|
|
31659
31669
|
let Tristate;
|
|
31660
31670
|
((Tristate2) => {
|
|
@@ -31776,6 +31786,8 @@ var Parser;
|
|
|
31776
31786
|
PropertyLikeParse2[PropertyLikeParse2["CallbackParameter"] = 4] = "CallbackParameter";
|
|
31777
31787
|
})(PropertyLikeParse || (PropertyLikeParse = {}));
|
|
31778
31788
|
function parseJSDocCommentWorker(start = 0, length2) {
|
|
31789
|
+
const saveParsingContext = parsingContext;
|
|
31790
|
+
parsingContext |= 1 << 25 /* JSDocComment */;
|
|
31779
31791
|
const content = sourceText;
|
|
31780
31792
|
const end = length2 === void 0 ? content.length : start + length2;
|
|
31781
31793
|
length2 = end - start;
|
|
@@ -31792,7 +31804,10 @@ var Parser;
|
|
|
31792
31804
|
let commentsPos;
|
|
31793
31805
|
let comments = [];
|
|
31794
31806
|
const parts = [];
|
|
31795
|
-
|
|
31807
|
+
const result = scanner.scanRange(start + 3, length2 - 5, doJSDocScan);
|
|
31808
|
+
parsingContext = saveParsingContext;
|
|
31809
|
+
return result;
|
|
31810
|
+
function doJSDocScan() {
|
|
31796
31811
|
let state = 1 /* SawAsterisk */;
|
|
31797
31812
|
let margin;
|
|
31798
31813
|
let indent2 = start - (content.lastIndexOf("\n", start) + 1) + 4;
|
|
@@ -31888,7 +31903,7 @@ var Parser;
|
|
|
31888
31903
|
Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set");
|
|
31889
31904
|
const tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd);
|
|
31890
31905
|
return finishNode(factory2.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : trimmedComments.length ? trimmedComments : void 0, tagsArray), start, end);
|
|
31891
|
-
}
|
|
31906
|
+
}
|
|
31892
31907
|
function removeLeadingNewlines(comments2) {
|
|
31893
31908
|
while (comments2.length && (comments2[0] === "\n" || comments2[0] === "\r")) {
|
|
31894
31909
|
comments2.shift();
|
|
@@ -32247,8 +32262,8 @@ var Parser;
|
|
|
32247
32262
|
typeExpression = nestedTypeLiteral;
|
|
32248
32263
|
isNameFirst = true;
|
|
32249
32264
|
}
|
|
32250
|
-
const
|
|
32251
|
-
return finishNode(
|
|
32265
|
+
const result2 = target === 1 /* Property */ ? factory2.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory2.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
|
|
32266
|
+
return finishNode(result2, start2);
|
|
32252
32267
|
}
|
|
32253
32268
|
function parseNestedTypeLiteral(typeExpression, name, target, indent2) {
|
|
32254
32269
|
if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
|
@@ -32258,6 +32273,8 @@ var Parser;
|
|
|
32258
32273
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent2, name))) {
|
|
32259
32274
|
if (child.kind === 347 /* JSDocParameterTag */ || child.kind === 354 /* JSDocPropertyTag */) {
|
|
32260
32275
|
children = append(children, child);
|
|
32276
|
+
} else if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
32277
|
+
parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
|
|
32261
32278
|
}
|
|
32262
32279
|
}
|
|
32263
32280
|
if (children) {
|
|
@@ -32396,6 +32413,9 @@ var Parser;
|
|
|
32396
32413
|
let jsDocPropertyTags;
|
|
32397
32414
|
let hasChildren = false;
|
|
32398
32415
|
while (child = tryParse(() => parseChildPropertyTag(indent2))) {
|
|
32416
|
+
if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
32417
|
+
break;
|
|
32418
|
+
}
|
|
32399
32419
|
hasChildren = true;
|
|
32400
32420
|
if (child.kind === 350 /* JSDocTypeTag */) {
|
|
32401
32421
|
if (childTypeTag) {
|
|
@@ -32455,6 +32475,10 @@ var Parser;
|
|
|
32455
32475
|
let child;
|
|
32456
32476
|
let parameters;
|
|
32457
32477
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent2))) {
|
|
32478
|
+
if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
32479
|
+
parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
|
|
32480
|
+
break;
|
|
32481
|
+
}
|
|
32458
32482
|
parameters = append(parameters, child);
|
|
32459
32483
|
}
|
|
32460
32484
|
return createNodeArray(parameters || [], pos);
|
|
@@ -32549,7 +32573,7 @@ var Parser;
|
|
|
32549
32573
|
const start2 = scanner.getTokenFullStart();
|
|
32550
32574
|
nextTokenJSDoc();
|
|
32551
32575
|
const tagName = parseJSDocIdentifierName();
|
|
32552
|
-
|
|
32576
|
+
const indentText = skipWhitespaceOrAsterisk();
|
|
32553
32577
|
let t;
|
|
32554
32578
|
switch (tagName.escapedText) {
|
|
32555
32579
|
case "type":
|
|
@@ -32563,6 +32587,8 @@ var Parser;
|
|
|
32563
32587
|
case "param":
|
|
32564
32588
|
t = 2 /* Parameter */ | 4 /* CallbackParameter */;
|
|
32565
32589
|
break;
|
|
32590
|
+
case "template":
|
|
32591
|
+
return parseTemplateTag(start2, tagName, indent2, indentText);
|
|
32566
32592
|
default:
|
|
32567
32593
|
return false;
|
|
32568
32594
|
}
|
|
@@ -32650,9 +32676,9 @@ var Parser;
|
|
|
32650
32676
|
const end2 = scanner.getTokenEnd();
|
|
32651
32677
|
const originalKeywordKind = token();
|
|
32652
32678
|
const text = internIdentifier(scanner.getTokenValue());
|
|
32653
|
-
const
|
|
32679
|
+
const result2 = finishNode(factoryCreateIdentifier(text, originalKeywordKind), start2, end2);
|
|
32654
32680
|
nextTokenJSDoc();
|
|
32655
|
-
return
|
|
32681
|
+
return result2;
|
|
32656
32682
|
}
|
|
32657
32683
|
}
|
|
32658
32684
|
})(JSDocParser = Parser2.JSDocParser || (Parser2.JSDocParser = {}));
|
|
@@ -43360,7 +43386,7 @@ function createTypeChecker(host) {
|
|
|
43360
43386
|
getGlobalIterableType: getGlobalAsyncIterableType,
|
|
43361
43387
|
getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
|
|
43362
43388
|
getGlobalGeneratorType: getGlobalAsyncGeneratorType,
|
|
43363
|
-
resolveIterationType: getAwaitedType,
|
|
43389
|
+
resolveIterationType: (type, errorNode) => getAwaitedType(type, errorNode, Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member),
|
|
43364
43390
|
mustHaveANextMethodDiagnostic: Diagnostics.An_async_iterator_must_have_a_next_method,
|
|
43365
43391
|
mustBeAMethodDiagnostic: Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
|
|
43366
43392
|
mustHaveAValueDiagnostic: Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property
|
|
@@ -44003,7 +44029,7 @@ function createTypeChecker(host) {
|
|
|
44003
44029
|
return true;
|
|
44004
44030
|
}
|
|
44005
44031
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
44006
|
-
if (getEmitScriptTarget(compilerOptions)
|
|
44032
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
44007
44033
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
44008
44034
|
declaration,
|
|
44009
44035
|
usage,
|
|
@@ -49693,7 +49719,7 @@ function createTypeChecker(host) {
|
|
|
49693
49719
|
context.enclosingDeclaration = originalDecl || oldEnclosing;
|
|
49694
49720
|
const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
|
|
49695
49721
|
const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
|
|
49696
|
-
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
49722
|
+
const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
|
|
49697
49723
|
const baseTypes = getBaseTypes(classType);
|
|
49698
49724
|
const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
|
|
49699
49725
|
const implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || mapDefined(getImplementsTypes(classType), serializeImplementedType);
|
|
@@ -50892,7 +50918,7 @@ function createTypeChecker(host) {
|
|
|
50892
50918
|
const elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern);
|
|
50893
50919
|
const index = pattern.elements.indexOf(declaration);
|
|
50894
50920
|
if (declaration.dotDotDotToken) {
|
|
50895
|
-
const baseConstraint =
|
|
50921
|
+
const baseConstraint = mapType(parentType, (t) => t.flags & 58982400 /* InstantiableNonPrimitive */ ? getBaseConstraintOrType(t) : t);
|
|
50896
50922
|
type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
|
|
50897
50923
|
} else if (isArrayLikeType(parentType)) {
|
|
50898
50924
|
const indexType = getNumberLiteralType(index);
|
|
@@ -52620,6 +52646,9 @@ function createTypeChecker(host) {
|
|
|
52620
52646
|
}
|
|
52621
52647
|
return needApparentType ? getApparentType(type) : type;
|
|
52622
52648
|
}
|
|
52649
|
+
function getThisArgument(type) {
|
|
52650
|
+
return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
|
|
52651
|
+
}
|
|
52623
52652
|
function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
|
|
52624
52653
|
let mapper;
|
|
52625
52654
|
let members;
|
|
@@ -52750,7 +52779,7 @@ function createTypeChecker(host) {
|
|
|
52750
52779
|
}
|
|
52751
52780
|
return [sig.parameters];
|
|
52752
52781
|
function expandSignatureParametersWithTupleMembers(restType, restIndex) {
|
|
52753
|
-
const elementTypes =
|
|
52782
|
+
const elementTypes = getElementTypes(restType);
|
|
52754
52783
|
const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
|
|
52755
52784
|
const restParams = map(elementTypes, (t, i) => {
|
|
52756
52785
|
const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
|
|
@@ -53566,7 +53595,7 @@ function createTypeChecker(host) {
|
|
|
53566
53595
|
}
|
|
53567
53596
|
function isConstTypeVariable(type) {
|
|
53568
53597
|
var _a;
|
|
53569
|
-
return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(
|
|
53598
|
+
return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
|
|
53570
53599
|
}
|
|
53571
53600
|
function getConstraintOfIndexedAccess(type) {
|
|
53572
53601
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
@@ -53668,7 +53697,7 @@ function createTypeChecker(host) {
|
|
|
53668
53697
|
return void 0;
|
|
53669
53698
|
}
|
|
53670
53699
|
function getBaseConstraintOfType(type) {
|
|
53671
|
-
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
53700
|
+
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || isGenericTupleType(type)) {
|
|
53672
53701
|
const constraint = getResolvedBaseConstraint(type);
|
|
53673
53702
|
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : void 0;
|
|
53674
53703
|
}
|
|
@@ -53685,7 +53714,7 @@ function createTypeChecker(host) {
|
|
|
53685
53714
|
return type.resolvedBaseConstraint;
|
|
53686
53715
|
}
|
|
53687
53716
|
const stack = [];
|
|
53688
|
-
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
|
|
53717
|
+
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
|
|
53689
53718
|
function getImmediateBaseConstraint(t) {
|
|
53690
53719
|
if (!t.immediateBaseConstraint) {
|
|
53691
53720
|
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
|
|
@@ -53775,6 +53804,13 @@ function createTypeChecker(host) {
|
|
|
53775
53804
|
if (t.flags & 33554432 /* Substitution */) {
|
|
53776
53805
|
return getBaseConstraint(getSubstitutionIntersection(t));
|
|
53777
53806
|
}
|
|
53807
|
+
if (isGenericTupleType(t)) {
|
|
53808
|
+
const newElements = map(getElementTypes(t), (v, i) => {
|
|
53809
|
+
const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
53810
|
+
return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
53811
|
+
});
|
|
53812
|
+
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
53813
|
+
}
|
|
53778
53814
|
return t;
|
|
53779
53815
|
}
|
|
53780
53816
|
}
|
|
@@ -55829,7 +55865,7 @@ function createTypeChecker(host) {
|
|
|
55829
55865
|
if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
|
|
55830
55866
|
addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
|
|
55831
55867
|
} else if (isTupleType(type)) {
|
|
55832
|
-
const elements =
|
|
55868
|
+
const elements = getElementTypes(type);
|
|
55833
55869
|
if (elements.length + expandedTypes.length >= 1e4) {
|
|
55834
55870
|
error(currentNode, isPartOfTypeNode(currentNode) ? Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent : Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent);
|
|
55835
55871
|
return errorType;
|
|
@@ -55907,6 +55943,11 @@ function createTypeChecker(host) {
|
|
|
55907
55943
|
function getEndElementCount(type, flags) {
|
|
55908
55944
|
return type.elementFlags.length - findLastIndex(type.elementFlags, (f) => !(f & flags)) - 1;
|
|
55909
55945
|
}
|
|
55946
|
+
function getElementTypes(type) {
|
|
55947
|
+
const typeArguments = getTypeArguments(type);
|
|
55948
|
+
const arity = getTypeReferenceArity(type);
|
|
55949
|
+
return typeArguments.length === arity ? typeArguments : typeArguments.slice(0, arity);
|
|
55950
|
+
}
|
|
55910
55951
|
function getTypeFromOptionalTypeNode(node) {
|
|
55911
55952
|
return addOptionality(
|
|
55912
55953
|
getTypeFromTypeNode(node.type),
|
|
@@ -57157,7 +57198,7 @@ function createTypeChecker(host) {
|
|
|
57157
57198
|
return isTupleTypeNode(node) && length(node.elements) > 0 && !some(node.elements, (e) => isOptionalTypeNode(e) || isRestTypeNode(e) || isNamedTupleMember(e) && !!(e.questionToken || e.dotDotDotToken));
|
|
57158
57199
|
}
|
|
57159
57200
|
function isDeferredType(type, checkTuples) {
|
|
57160
|
-
return isGenericType(type) || checkTuples && isTupleType(type) && some(
|
|
57201
|
+
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
57161
57202
|
}
|
|
57162
57203
|
function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
|
|
57163
57204
|
let result;
|
|
@@ -58092,7 +58133,7 @@ function createTypeChecker(host) {
|
|
|
58092
58133
|
}
|
|
58093
58134
|
function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
|
|
58094
58135
|
const elementFlags = tupleType.target.elementFlags;
|
|
58095
|
-
const elementTypes = map(
|
|
58136
|
+
const elementTypes = map(getElementTypes(tupleType), (t, i) => {
|
|
58096
58137
|
const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
|
|
58097
58138
|
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
58098
58139
|
});
|
|
@@ -58111,7 +58152,7 @@ function createTypeChecker(host) {
|
|
|
58111
58152
|
}
|
|
58112
58153
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
58113
58154
|
const elementFlags = tupleType.target.elementFlags;
|
|
58114
|
-
const elementTypes = map(
|
|
58155
|
+
const elementTypes = map(getElementTypes(tupleType), (_, i) => instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper));
|
|
58115
58156
|
const modifiers = getMappedTypeModifiers(mappedType);
|
|
58116
58157
|
const newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? map(elementFlags, (f) => f & 1 /* Required */ ? 2 /* Optional */ : f) : modifiers & 8 /* ExcludeOptional */ ? map(elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : elementFlags;
|
|
58117
58158
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
|
|
@@ -59297,7 +59338,7 @@ function createTypeChecker(host) {
|
|
|
59297
59338
|
return type;
|
|
59298
59339
|
}
|
|
59299
59340
|
function getNormalizedTupleType(type, writing) {
|
|
59300
|
-
const elements =
|
|
59341
|
+
const elements = getElementTypes(type);
|
|
59301
59342
|
const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
|
|
59302
59343
|
return elements !== normalizedElements ? createNormalizedTupleType(type.target, normalizedElements) : type;
|
|
59303
59344
|
}
|
|
@@ -59586,6 +59627,8 @@ function createTypeChecker(host) {
|
|
|
59586
59627
|
return isRelatedTo(source2, target2, 3 /* Both */, reportErrors2);
|
|
59587
59628
|
}
|
|
59588
59629
|
function isRelatedTo(originalSource, originalTarget, recursionFlags = 3 /* Both */, reportErrors2 = false, headMessage2, intersectionState = 0 /* None */) {
|
|
59630
|
+
if (originalSource === originalTarget)
|
|
59631
|
+
return -1 /* True */;
|
|
59589
59632
|
if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 402784252 /* Primitive */) {
|
|
59590
59633
|
if (relation === comparableRelation && !(originalTarget.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(originalTarget, originalSource, relation) || isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors2 ? reportError : void 0)) {
|
|
59591
59634
|
return -1 /* True */;
|
|
@@ -60804,6 +60847,11 @@ function createTypeChecker(host) {
|
|
|
60804
60847
|
} else {
|
|
60805
60848
|
return 0 /* False */;
|
|
60806
60849
|
}
|
|
60850
|
+
} else if (isGenericTupleType(source2) && isTupleType(target2) && !isGenericTupleType(target2)) {
|
|
60851
|
+
const constraint = getBaseConstraintOrType(source2);
|
|
60852
|
+
if (constraint !== source2) {
|
|
60853
|
+
return isRelatedTo(constraint, target2, 1 /* Source */, reportErrors2);
|
|
60854
|
+
}
|
|
60807
60855
|
} else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target2) && getObjectFlags(target2) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source2)) {
|
|
60808
60856
|
return 0 /* False */;
|
|
60809
60857
|
}
|
|
@@ -62719,7 +62767,7 @@ function createTypeChecker(host) {
|
|
|
62719
62767
|
return type;
|
|
62720
62768
|
}
|
|
62721
62769
|
function isPartiallyInferableType(type) {
|
|
62722
|
-
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(
|
|
62770
|
+
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
|
|
62723
62771
|
}
|
|
62724
62772
|
function createReverseMappedType(source, target, constraint) {
|
|
62725
62773
|
if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
|
|
@@ -62729,7 +62777,7 @@ function createTypeChecker(host) {
|
|
|
62729
62777
|
return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
|
|
62730
62778
|
}
|
|
62731
62779
|
if (isTupleType(source)) {
|
|
62732
|
-
const elementTypes = map(
|
|
62780
|
+
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
|
|
62733
62781
|
const elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? sameMap(source.target.elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : source.target.elementFlags;
|
|
62734
62782
|
return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
|
|
62735
62783
|
}
|
|
@@ -63565,14 +63613,14 @@ function createTypeChecker(host) {
|
|
|
63565
63613
|
const inference = context.inferences[index];
|
|
63566
63614
|
if (!inference.inferredType) {
|
|
63567
63615
|
let inferredType;
|
|
63568
|
-
|
|
63569
|
-
if (signature) {
|
|
63570
|
-
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : void 0;
|
|
63571
|
-
|
|
63572
|
-
|
|
63573
|
-
|
|
63574
|
-
|
|
63575
|
-
|
|
63616
|
+
let fallbackType;
|
|
63617
|
+
if (context.signature) {
|
|
63618
|
+
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, context.signature) : void 0;
|
|
63619
|
+
const inferredContravariantType = inference.contraCandidates ? getContravariantInference(inference) : void 0;
|
|
63620
|
+
if (inferredCovariantType || inferredContravariantType) {
|
|
63621
|
+
const preferCovariantType = inferredCovariantType && (!inferredContravariantType || !(inferredCovariantType.flags & 131072 /* Never */) && some(inference.contraCandidates, (t) => isTypeSubtypeOf(inferredCovariantType, t)) && every(context.inferences, (other) => other !== inference && getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeSubtypeOf(t, inferredCovariantType))));
|
|
63622
|
+
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
63623
|
+
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
63576
63624
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
63577
63625
|
inferredType = silentNeverType;
|
|
63578
63626
|
} else {
|
|
@@ -63589,7 +63637,7 @@ function createTypeChecker(host) {
|
|
|
63589
63637
|
if (constraint) {
|
|
63590
63638
|
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
|
|
63591
63639
|
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
|
63592
|
-
inference.inferredType =
|
|
63640
|
+
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
|
|
63593
63641
|
}
|
|
63594
63642
|
}
|
|
63595
63643
|
}
|
|
@@ -69510,7 +69558,7 @@ function createTypeChecker(host) {
|
|
|
69510
69558
|
}
|
|
69511
69559
|
function getMutableArrayOrTupleType(type) {
|
|
69512
69560
|
return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(
|
|
69513
|
-
|
|
69561
|
+
getElementTypes(type),
|
|
69514
69562
|
type.target.elementFlags,
|
|
69515
69563
|
/*readonly*/
|
|
69516
69564
|
false,
|
|
@@ -69824,7 +69872,7 @@ function createTypeChecker(host) {
|
|
|
69824
69872
|
const arg = args[i];
|
|
69825
69873
|
const spreadType = arg.kind === 229 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
69826
69874
|
if (spreadType && isTupleType(spreadType)) {
|
|
69827
|
-
forEach(
|
|
69875
|
+
forEach(getElementTypes(spreadType), (t, i2) => {
|
|
69828
69876
|
var _a;
|
|
69829
69877
|
const flags = spreadType.target.elementFlags[i2];
|
|
69830
69878
|
const syntheticArg = createSyntheticExpression(
|
|
@@ -72338,6 +72386,10 @@ function createTypeChecker(host) {
|
|
|
72338
72386
|
forEachReturnStatement(func.body, (returnStatement) => {
|
|
72339
72387
|
const expr = returnStatement.expression;
|
|
72340
72388
|
if (expr) {
|
|
72389
|
+
if (expr.kind === 212 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
|
|
72390
|
+
hasReturnOfTypeNever = true;
|
|
72391
|
+
return;
|
|
72392
|
+
}
|
|
72341
72393
|
let type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
|
|
72342
72394
|
if (functionFlags & 2 /* Async */) {
|
|
72343
72395
|
type = unwrapAwaitedType(checkAwaitedType(
|
|
@@ -73818,7 +73870,7 @@ function createTypeChecker(host) {
|
|
|
73818
73870
|
}
|
|
73819
73871
|
function padTupleType(type, pattern) {
|
|
73820
73872
|
const patternElements = pattern.elements;
|
|
73821
|
-
const elementTypes =
|
|
73873
|
+
const elementTypes = getElementTypes(type).slice();
|
|
73822
73874
|
const elementFlags = type.target.elementFlags.slice();
|
|
73823
73875
|
for (let i = getTypeReferenceArity(type); i < patternElements.length; i++) {
|
|
73824
73876
|
const e = patternElements[i];
|