typescript 5.1.0-dev.20230502 → 5.1.0-dev.20230507
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/tsserverlibrary.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.1";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230507`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -8764,6 +8764,7 @@ ${lanes.join("\n")}
|
|
|
8764
8764
|
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."),
|
|
8765
8765
|
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."),
|
|
8766
8766
|
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'."),
|
|
8767
|
+
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"),
|
|
8767
8768
|
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."),
|
|
8768
8769
|
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."),
|
|
8769
8770
|
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'."),
|
|
@@ -29649,8 +29650,13 @@ ${lanes.join("\n")}
|
|
|
29649
29650
|
return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
|
|
29650
29651
|
case 14 /* JsxChildren */:
|
|
29651
29652
|
return true;
|
|
29653
|
+
case 25 /* JSDocComment */:
|
|
29654
|
+
return true;
|
|
29655
|
+
case 26 /* Count */:
|
|
29656
|
+
return Debug.fail("ParsingContext.Count used as a context");
|
|
29657
|
+
default:
|
|
29658
|
+
Debug.assertNever(parsingContext2, "Non-exhaustive case in 'isListElement'.");
|
|
29652
29659
|
}
|
|
29653
|
-
return Debug.fail("Non-exhaustive case in 'isListElement'.");
|
|
29654
29660
|
}
|
|
29655
29661
|
function isValidHeritageClauseObjectLiteral() {
|
|
29656
29662
|
Debug.assert(token() === 19 /* OpenBraceToken */);
|
|
@@ -29744,7 +29750,8 @@ ${lanes.join("\n")}
|
|
|
29744
29750
|
return false;
|
|
29745
29751
|
}
|
|
29746
29752
|
function isInSomeParsingContext() {
|
|
29747
|
-
|
|
29753
|
+
Debug.assert(parsingContext, "Missing parsing context");
|
|
29754
|
+
for (let kind = 0; kind < 26 /* Count */; kind++) {
|
|
29748
29755
|
if (parsingContext & 1 << kind) {
|
|
29749
29756
|
if (isListElement2(
|
|
29750
29757
|
kind,
|
|
@@ -30003,7 +30010,9 @@ ${lanes.join("\n")}
|
|
|
30003
30010
|
return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
|
30004
30011
|
case 24 /* AssertEntries */:
|
|
30005
30012
|
return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected);
|
|
30006
|
-
case 25 /*
|
|
30013
|
+
case 25 /* JSDocComment */:
|
|
30014
|
+
return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
|
30015
|
+
case 26 /* Count */:
|
|
30007
30016
|
return Debug.fail("ParsingContext.Count used as a context");
|
|
30008
30017
|
default:
|
|
30009
30018
|
Debug.assertNever(context);
|
|
@@ -34135,7 +34144,8 @@ ${lanes.join("\n")}
|
|
|
34135
34144
|
ParsingContext2[ParsingContext2["HeritageClauses"] = 22] = "HeritageClauses";
|
|
34136
34145
|
ParsingContext2[ParsingContext2["ImportOrExportSpecifiers"] = 23] = "ImportOrExportSpecifiers";
|
|
34137
34146
|
ParsingContext2[ParsingContext2["AssertEntries"] = 24] = "AssertEntries";
|
|
34138
|
-
ParsingContext2[ParsingContext2["
|
|
34147
|
+
ParsingContext2[ParsingContext2["JSDocComment"] = 25] = "JSDocComment";
|
|
34148
|
+
ParsingContext2[ParsingContext2["Count"] = 26] = "Count";
|
|
34139
34149
|
})(ParsingContext || (ParsingContext = {}));
|
|
34140
34150
|
let Tristate;
|
|
34141
34151
|
((Tristate2) => {
|
|
@@ -34257,6 +34267,8 @@ ${lanes.join("\n")}
|
|
|
34257
34267
|
PropertyLikeParse2[PropertyLikeParse2["CallbackParameter"] = 4] = "CallbackParameter";
|
|
34258
34268
|
})(PropertyLikeParse || (PropertyLikeParse = {}));
|
|
34259
34269
|
function parseJSDocCommentWorker(start = 0, length2) {
|
|
34270
|
+
const saveParsingContext = parsingContext;
|
|
34271
|
+
parsingContext |= 1 << 25 /* JSDocComment */;
|
|
34260
34272
|
const content = sourceText;
|
|
34261
34273
|
const end = length2 === void 0 ? content.length : start + length2;
|
|
34262
34274
|
length2 = end - start;
|
|
@@ -34273,7 +34285,10 @@ ${lanes.join("\n")}
|
|
|
34273
34285
|
let commentsPos;
|
|
34274
34286
|
let comments = [];
|
|
34275
34287
|
const parts = [];
|
|
34276
|
-
|
|
34288
|
+
const result = scanner2.scanRange(start + 3, length2 - 5, doJSDocScan);
|
|
34289
|
+
parsingContext = saveParsingContext;
|
|
34290
|
+
return result;
|
|
34291
|
+
function doJSDocScan() {
|
|
34277
34292
|
let state = 1 /* SawAsterisk */;
|
|
34278
34293
|
let margin;
|
|
34279
34294
|
let indent3 = start - (content.lastIndexOf("\n", start) + 1) + 4;
|
|
@@ -34369,7 +34384,7 @@ ${lanes.join("\n")}
|
|
|
34369
34384
|
Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set");
|
|
34370
34385
|
const tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd);
|
|
34371
34386
|
return finishNode(factory2.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : trimmedComments.length ? trimmedComments : void 0, tagsArray), start, end);
|
|
34372
|
-
}
|
|
34387
|
+
}
|
|
34373
34388
|
function removeLeadingNewlines(comments2) {
|
|
34374
34389
|
while (comments2.length && (comments2[0] === "\n" || comments2[0] === "\r")) {
|
|
34375
34390
|
comments2.shift();
|
|
@@ -34728,8 +34743,8 @@ ${lanes.join("\n")}
|
|
|
34728
34743
|
typeExpression = nestedTypeLiteral;
|
|
34729
34744
|
isNameFirst = true;
|
|
34730
34745
|
}
|
|
34731
|
-
const
|
|
34732
|
-
return finishNode(
|
|
34746
|
+
const result2 = target === 1 /* Property */ ? factory2.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory2.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
|
|
34747
|
+
return finishNode(result2, start2);
|
|
34733
34748
|
}
|
|
34734
34749
|
function parseNestedTypeLiteral(typeExpression, name, target, indent3) {
|
|
34735
34750
|
if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
|
@@ -34739,6 +34754,8 @@ ${lanes.join("\n")}
|
|
|
34739
34754
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent3, name))) {
|
|
34740
34755
|
if (child.kind === 347 /* JSDocParameterTag */ || child.kind === 354 /* JSDocPropertyTag */) {
|
|
34741
34756
|
children = append(children, child);
|
|
34757
|
+
} else if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
34758
|
+
parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
|
|
34742
34759
|
}
|
|
34743
34760
|
}
|
|
34744
34761
|
if (children) {
|
|
@@ -34877,6 +34894,9 @@ ${lanes.join("\n")}
|
|
|
34877
34894
|
let jsDocPropertyTags;
|
|
34878
34895
|
let hasChildren = false;
|
|
34879
34896
|
while (child = tryParse(() => parseChildPropertyTag(indent3))) {
|
|
34897
|
+
if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
34898
|
+
break;
|
|
34899
|
+
}
|
|
34880
34900
|
hasChildren = true;
|
|
34881
34901
|
if (child.kind === 350 /* JSDocTypeTag */) {
|
|
34882
34902
|
if (childTypeTag) {
|
|
@@ -34936,6 +34956,10 @@ ${lanes.join("\n")}
|
|
|
34936
34956
|
let child;
|
|
34937
34957
|
let parameters;
|
|
34938
34958
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent3))) {
|
|
34959
|
+
if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
34960
|
+
parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
|
|
34961
|
+
break;
|
|
34962
|
+
}
|
|
34939
34963
|
parameters = append(parameters, child);
|
|
34940
34964
|
}
|
|
34941
34965
|
return createNodeArray(parameters || [], pos);
|
|
@@ -35030,7 +35054,7 @@ ${lanes.join("\n")}
|
|
|
35030
35054
|
const start2 = scanner2.getTokenFullStart();
|
|
35031
35055
|
nextTokenJSDoc();
|
|
35032
35056
|
const tagName = parseJSDocIdentifierName();
|
|
35033
|
-
|
|
35057
|
+
const indentText = skipWhitespaceOrAsterisk();
|
|
35034
35058
|
let t;
|
|
35035
35059
|
switch (tagName.escapedText) {
|
|
35036
35060
|
case "type":
|
|
@@ -35044,6 +35068,8 @@ ${lanes.join("\n")}
|
|
|
35044
35068
|
case "param":
|
|
35045
35069
|
t = 2 /* Parameter */ | 4 /* CallbackParameter */;
|
|
35046
35070
|
break;
|
|
35071
|
+
case "template":
|
|
35072
|
+
return parseTemplateTag(start2, tagName, indent3, indentText);
|
|
35047
35073
|
default:
|
|
35048
35074
|
return false;
|
|
35049
35075
|
}
|
|
@@ -35131,9 +35157,9 @@ ${lanes.join("\n")}
|
|
|
35131
35157
|
const end2 = scanner2.getTokenEnd();
|
|
35132
35158
|
const originalKeywordKind = token();
|
|
35133
35159
|
const text = internIdentifier(scanner2.getTokenValue());
|
|
35134
|
-
const
|
|
35160
|
+
const result2 = finishNode(factoryCreateIdentifier(text, originalKeywordKind), start2, end2);
|
|
35135
35161
|
nextTokenJSDoc();
|
|
35136
|
-
return
|
|
35162
|
+
return result2;
|
|
35137
35163
|
}
|
|
35138
35164
|
}
|
|
35139
35165
|
})(JSDocParser = Parser2.JSDocParser || (Parser2.JSDocParser = {}));
|
|
@@ -45802,7 +45828,7 @@ ${lanes.join("\n")}
|
|
|
45802
45828
|
getGlobalIterableType: getGlobalAsyncIterableType,
|
|
45803
45829
|
getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
|
|
45804
45830
|
getGlobalGeneratorType: getGlobalAsyncGeneratorType,
|
|
45805
|
-
resolveIterationType: getAwaitedType,
|
|
45831
|
+
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),
|
|
45806
45832
|
mustHaveANextMethodDiagnostic: Diagnostics.An_async_iterator_must_have_a_next_method,
|
|
45807
45833
|
mustBeAMethodDiagnostic: Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
|
|
45808
45834
|
mustHaveAValueDiagnostic: Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property
|
|
@@ -46445,7 +46471,7 @@ ${lanes.join("\n")}
|
|
|
46445
46471
|
return true;
|
|
46446
46472
|
}
|
|
46447
46473
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
46448
|
-
if (getEmitScriptTarget(compilerOptions)
|
|
46474
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
46449
46475
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
46450
46476
|
declaration,
|
|
46451
46477
|
usage,
|
|
@@ -52135,7 +52161,7 @@ ${lanes.join("\n")}
|
|
|
52135
52161
|
context.enclosingDeclaration = originalDecl || oldEnclosing;
|
|
52136
52162
|
const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
|
|
52137
52163
|
const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
|
|
52138
|
-
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
52164
|
+
const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
|
|
52139
52165
|
const baseTypes = getBaseTypes(classType);
|
|
52140
52166
|
const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
|
|
52141
52167
|
const implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || mapDefined(getImplementsTypes(classType), serializeImplementedType);
|
|
@@ -53334,7 +53360,7 @@ ${lanes.join("\n")}
|
|
|
53334
53360
|
const elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern);
|
|
53335
53361
|
const index = pattern.elements.indexOf(declaration);
|
|
53336
53362
|
if (declaration.dotDotDotToken) {
|
|
53337
|
-
const baseConstraint =
|
|
53363
|
+
const baseConstraint = mapType(parentType, (t) => t.flags & 58982400 /* InstantiableNonPrimitive */ ? getBaseConstraintOrType(t) : t);
|
|
53338
53364
|
type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
|
|
53339
53365
|
} else if (isArrayLikeType(parentType)) {
|
|
53340
53366
|
const indexType = getNumberLiteralType(index);
|
|
@@ -55062,6 +55088,9 @@ ${lanes.join("\n")}
|
|
|
55062
55088
|
}
|
|
55063
55089
|
return needApparentType ? getApparentType(type) : type;
|
|
55064
55090
|
}
|
|
55091
|
+
function getThisArgument(type) {
|
|
55092
|
+
return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
|
|
55093
|
+
}
|
|
55065
55094
|
function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
|
|
55066
55095
|
let mapper;
|
|
55067
55096
|
let members;
|
|
@@ -55192,7 +55221,7 @@ ${lanes.join("\n")}
|
|
|
55192
55221
|
}
|
|
55193
55222
|
return [sig.parameters];
|
|
55194
55223
|
function expandSignatureParametersWithTupleMembers(restType, restIndex) {
|
|
55195
|
-
const elementTypes =
|
|
55224
|
+
const elementTypes = getElementTypes(restType);
|
|
55196
55225
|
const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
|
|
55197
55226
|
const restParams = map(elementTypes, (t, i) => {
|
|
55198
55227
|
const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
|
|
@@ -56008,7 +56037,7 @@ ${lanes.join("\n")}
|
|
|
56008
56037
|
}
|
|
56009
56038
|
function isConstTypeVariable(type) {
|
|
56010
56039
|
var _a;
|
|
56011
|
-
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(
|
|
56040
|
+
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));
|
|
56012
56041
|
}
|
|
56013
56042
|
function getConstraintOfIndexedAccess(type) {
|
|
56014
56043
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
@@ -56110,7 +56139,7 @@ ${lanes.join("\n")}
|
|
|
56110
56139
|
return void 0;
|
|
56111
56140
|
}
|
|
56112
56141
|
function getBaseConstraintOfType(type) {
|
|
56113
|
-
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
56142
|
+
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || isGenericTupleType(type)) {
|
|
56114
56143
|
const constraint = getResolvedBaseConstraint(type);
|
|
56115
56144
|
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : void 0;
|
|
56116
56145
|
}
|
|
@@ -56127,7 +56156,7 @@ ${lanes.join("\n")}
|
|
|
56127
56156
|
return type.resolvedBaseConstraint;
|
|
56128
56157
|
}
|
|
56129
56158
|
const stack = [];
|
|
56130
|
-
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
|
|
56159
|
+
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
|
|
56131
56160
|
function getImmediateBaseConstraint(t) {
|
|
56132
56161
|
if (!t.immediateBaseConstraint) {
|
|
56133
56162
|
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
|
|
@@ -56217,6 +56246,13 @@ ${lanes.join("\n")}
|
|
|
56217
56246
|
if (t.flags & 33554432 /* Substitution */) {
|
|
56218
56247
|
return getBaseConstraint(getSubstitutionIntersection(t));
|
|
56219
56248
|
}
|
|
56249
|
+
if (isGenericTupleType(t)) {
|
|
56250
|
+
const newElements = map(getElementTypes(t), (v, i) => {
|
|
56251
|
+
const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
56252
|
+
return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
56253
|
+
});
|
|
56254
|
+
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
56255
|
+
}
|
|
56220
56256
|
return t;
|
|
56221
56257
|
}
|
|
56222
56258
|
}
|
|
@@ -58271,7 +58307,7 @@ ${lanes.join("\n")}
|
|
|
58271
58307
|
if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
|
|
58272
58308
|
addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
|
|
58273
58309
|
} else if (isTupleType(type)) {
|
|
58274
|
-
const elements =
|
|
58310
|
+
const elements = getElementTypes(type);
|
|
58275
58311
|
if (elements.length + expandedTypes.length >= 1e4) {
|
|
58276
58312
|
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);
|
|
58277
58313
|
return errorType;
|
|
@@ -58349,6 +58385,11 @@ ${lanes.join("\n")}
|
|
|
58349
58385
|
function getEndElementCount(type, flags) {
|
|
58350
58386
|
return type.elementFlags.length - findLastIndex(type.elementFlags, (f) => !(f & flags)) - 1;
|
|
58351
58387
|
}
|
|
58388
|
+
function getElementTypes(type) {
|
|
58389
|
+
const typeArguments = getTypeArguments(type);
|
|
58390
|
+
const arity = getTypeReferenceArity(type);
|
|
58391
|
+
return typeArguments.length === arity ? typeArguments : typeArguments.slice(0, arity);
|
|
58392
|
+
}
|
|
58352
58393
|
function getTypeFromOptionalTypeNode(node) {
|
|
58353
58394
|
return addOptionality(
|
|
58354
58395
|
getTypeFromTypeNode(node.type),
|
|
@@ -59599,7 +59640,7 @@ ${lanes.join("\n")}
|
|
|
59599
59640
|
return isTupleTypeNode(node) && length(node.elements) > 0 && !some(node.elements, (e) => isOptionalTypeNode(e) || isRestTypeNode(e) || isNamedTupleMember(e) && !!(e.questionToken || e.dotDotDotToken));
|
|
59600
59641
|
}
|
|
59601
59642
|
function isDeferredType(type, checkTuples) {
|
|
59602
|
-
return isGenericType(type) || checkTuples && isTupleType(type) && some(
|
|
59643
|
+
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
59603
59644
|
}
|
|
59604
59645
|
function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
|
|
59605
59646
|
let result;
|
|
@@ -60534,7 +60575,7 @@ ${lanes.join("\n")}
|
|
|
60534
60575
|
}
|
|
60535
60576
|
function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
|
|
60536
60577
|
const elementFlags = tupleType.target.elementFlags;
|
|
60537
|
-
const elementTypes = map(
|
|
60578
|
+
const elementTypes = map(getElementTypes(tupleType), (t, i) => {
|
|
60538
60579
|
const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
|
|
60539
60580
|
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
60540
60581
|
});
|
|
@@ -60553,7 +60594,7 @@ ${lanes.join("\n")}
|
|
|
60553
60594
|
}
|
|
60554
60595
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
60555
60596
|
const elementFlags = tupleType.target.elementFlags;
|
|
60556
|
-
const elementTypes = map(
|
|
60597
|
+
const elementTypes = map(getElementTypes(tupleType), (_, i) => instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper));
|
|
60557
60598
|
const modifiers = getMappedTypeModifiers(mappedType);
|
|
60558
60599
|
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;
|
|
60559
60600
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
|
|
@@ -61739,7 +61780,7 @@ ${lanes.join("\n")}
|
|
|
61739
61780
|
return type;
|
|
61740
61781
|
}
|
|
61741
61782
|
function getNormalizedTupleType(type, writing) {
|
|
61742
|
-
const elements =
|
|
61783
|
+
const elements = getElementTypes(type);
|
|
61743
61784
|
const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
|
|
61744
61785
|
return elements !== normalizedElements ? createNormalizedTupleType(type.target, normalizedElements) : type;
|
|
61745
61786
|
}
|
|
@@ -62028,6 +62069,8 @@ ${lanes.join("\n")}
|
|
|
62028
62069
|
return isRelatedTo(source2, target2, 3 /* Both */, reportErrors2);
|
|
62029
62070
|
}
|
|
62030
62071
|
function isRelatedTo(originalSource, originalTarget, recursionFlags = 3 /* Both */, reportErrors2 = false, headMessage2, intersectionState = 0 /* None */) {
|
|
62072
|
+
if (originalSource === originalTarget)
|
|
62073
|
+
return -1 /* True */;
|
|
62031
62074
|
if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 402784252 /* Primitive */) {
|
|
62032
62075
|
if (relation === comparableRelation && !(originalTarget.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(originalTarget, originalSource, relation) || isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors2 ? reportError : void 0)) {
|
|
62033
62076
|
return -1 /* True */;
|
|
@@ -63246,6 +63289,11 @@ ${lanes.join("\n")}
|
|
|
63246
63289
|
} else {
|
|
63247
63290
|
return 0 /* False */;
|
|
63248
63291
|
}
|
|
63292
|
+
} else if (isGenericTupleType(source2) && isTupleType(target2) && !isGenericTupleType(target2)) {
|
|
63293
|
+
const constraint = getBaseConstraintOrType(source2);
|
|
63294
|
+
if (constraint !== source2) {
|
|
63295
|
+
return isRelatedTo(constraint, target2, 1 /* Source */, reportErrors2);
|
|
63296
|
+
}
|
|
63249
63297
|
} else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target2) && getObjectFlags(target2) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source2)) {
|
|
63250
63298
|
return 0 /* False */;
|
|
63251
63299
|
}
|
|
@@ -65161,7 +65209,7 @@ ${lanes.join("\n")}
|
|
|
65161
65209
|
return type;
|
|
65162
65210
|
}
|
|
65163
65211
|
function isPartiallyInferableType(type) {
|
|
65164
|
-
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(
|
|
65212
|
+
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
|
|
65165
65213
|
}
|
|
65166
65214
|
function createReverseMappedType(source, target, constraint) {
|
|
65167
65215
|
if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
|
|
@@ -65171,7 +65219,7 @@ ${lanes.join("\n")}
|
|
|
65171
65219
|
return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
|
|
65172
65220
|
}
|
|
65173
65221
|
if (isTupleType(source)) {
|
|
65174
|
-
const elementTypes = map(
|
|
65222
|
+
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
|
|
65175
65223
|
const elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? sameMap(source.target.elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : source.target.elementFlags;
|
|
65176
65224
|
return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
|
|
65177
65225
|
}
|
|
@@ -66007,14 +66055,14 @@ ${lanes.join("\n")}
|
|
|
66007
66055
|
const inference = context.inferences[index];
|
|
66008
66056
|
if (!inference.inferredType) {
|
|
66009
66057
|
let inferredType;
|
|
66010
|
-
|
|
66011
|
-
if (signature) {
|
|
66012
|
-
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : void 0;
|
|
66013
|
-
|
|
66014
|
-
|
|
66015
|
-
|
|
66016
|
-
|
|
66017
|
-
|
|
66058
|
+
let fallbackType;
|
|
66059
|
+
if (context.signature) {
|
|
66060
|
+
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, context.signature) : void 0;
|
|
66061
|
+
const inferredContravariantType = inference.contraCandidates ? getContravariantInference(inference) : void 0;
|
|
66062
|
+
if (inferredCovariantType || inferredContravariantType) {
|
|
66063
|
+
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))));
|
|
66064
|
+
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
66065
|
+
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
66018
66066
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
66019
66067
|
inferredType = silentNeverType;
|
|
66020
66068
|
} else {
|
|
@@ -66031,7 +66079,7 @@ ${lanes.join("\n")}
|
|
|
66031
66079
|
if (constraint) {
|
|
66032
66080
|
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
|
|
66033
66081
|
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
|
66034
|
-
inference.inferredType =
|
|
66082
|
+
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
|
|
66035
66083
|
}
|
|
66036
66084
|
}
|
|
66037
66085
|
}
|
|
@@ -71952,7 +72000,7 @@ ${lanes.join("\n")}
|
|
|
71952
72000
|
}
|
|
71953
72001
|
function getMutableArrayOrTupleType(type) {
|
|
71954
72002
|
return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(
|
|
71955
|
-
|
|
72003
|
+
getElementTypes(type),
|
|
71956
72004
|
type.target.elementFlags,
|
|
71957
72005
|
/*readonly*/
|
|
71958
72006
|
false,
|
|
@@ -72266,7 +72314,7 @@ ${lanes.join("\n")}
|
|
|
72266
72314
|
const arg = args[i];
|
|
72267
72315
|
const spreadType = arg.kind === 229 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
72268
72316
|
if (spreadType && isTupleType(spreadType)) {
|
|
72269
|
-
forEach(
|
|
72317
|
+
forEach(getElementTypes(spreadType), (t, i2) => {
|
|
72270
72318
|
var _a;
|
|
72271
72319
|
const flags = spreadType.target.elementFlags[i2];
|
|
72272
72320
|
const syntheticArg = createSyntheticExpression(
|
|
@@ -74780,6 +74828,10 @@ ${lanes.join("\n")}
|
|
|
74780
74828
|
forEachReturnStatement(func.body, (returnStatement) => {
|
|
74781
74829
|
const expr = returnStatement.expression;
|
|
74782
74830
|
if (expr) {
|
|
74831
|
+
if (expr.kind === 212 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
|
|
74832
|
+
hasReturnOfTypeNever = true;
|
|
74833
|
+
return;
|
|
74834
|
+
}
|
|
74783
74835
|
let type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
|
|
74784
74836
|
if (functionFlags & 2 /* Async */) {
|
|
74785
74837
|
type = unwrapAwaitedType(checkAwaitedType(
|
|
@@ -76260,7 +76312,7 @@ ${lanes.join("\n")}
|
|
|
76260
76312
|
}
|
|
76261
76313
|
function padTupleType(type, pattern) {
|
|
76262
76314
|
const patternElements = pattern.elements;
|
|
76263
|
-
const elementTypes =
|
|
76315
|
+
const elementTypes = getElementTypes(type).slice();
|
|
76264
76316
|
const elementFlags = type.target.elementFlags.slice();
|
|
76265
76317
|
for (let i = getTypeReferenceArity(type); i < patternElements.length; i++) {
|
|
76266
76318
|
const e = patternElements[i];
|
|
@@ -164455,7 +164507,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164455
164507
|
displayParts.push(spacePart());
|
|
164456
164508
|
displayParts.push(operatorPart(64 /* EqualsToken */));
|
|
164457
164509
|
displayParts.push(spacePart());
|
|
164458
|
-
addRange(displayParts, typeToDisplayParts(typeChecker, isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
|
164510
|
+
addRange(displayParts, typeToDisplayParts(typeChecker, location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
|
164459
164511
|
}
|
|
164460
164512
|
if (symbolFlags & 384 /* Enum */) {
|
|
164461
164513
|
prefixNextMeaning();
|
|
@@ -176451,7 +176503,7 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
176451
176503
|
const verboseLogging = logger.hasLevel(3 /* verbose */);
|
|
176452
176504
|
const json = JSON.stringify(msg);
|
|
176453
176505
|
if (verboseLogging) {
|
|
176454
|
-
logger.info(`${msg.type}:${indent2(
|
|
176506
|
+
logger.info(`${msg.type}:${indent2(JSON.stringify(msg, void 0, " "))}`);
|
|
176455
176507
|
}
|
|
176456
176508
|
const len = byteLength(json, "utf8");
|
|
176457
176509
|
return `Content-Length: ${1 + len}\r
|