typescript 5.1.0-dev.20230501 → 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 +99 -65
- package/lib/tsserver.js +101 -67
- package/lib/tsserverlibrary.js +101 -67
- package/lib/typescript.js +100 -66
- package/lib/typingsInstaller.js +38 -12
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -2303,7 +2303,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2303
2303
|
|
|
2304
2304
|
// src/compiler/corePublic.ts
|
|
2305
2305
|
var versionMajorMinor = "5.1";
|
|
2306
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2306
|
+
var version = `${versionMajorMinor}.0-dev.20230506`;
|
|
2307
2307
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2308
2308
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2309
2309
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -10957,6 +10957,7 @@ var Diagnostics = {
|
|
|
10957
10957
|
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."),
|
|
10958
10958
|
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."),
|
|
10959
10959
|
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'."),
|
|
10960
|
+
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"),
|
|
10960
10961
|
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."),
|
|
10961
10962
|
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."),
|
|
10962
10963
|
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'."),
|
|
@@ -31552,8 +31553,13 @@ var Parser;
|
|
|
31552
31553
|
return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
|
|
31553
31554
|
case 14 /* JsxChildren */:
|
|
31554
31555
|
return true;
|
|
31556
|
+
case 25 /* JSDocComment */:
|
|
31557
|
+
return true;
|
|
31558
|
+
case 26 /* Count */:
|
|
31559
|
+
return Debug.fail("ParsingContext.Count used as a context");
|
|
31560
|
+
default:
|
|
31561
|
+
Debug.assertNever(parsingContext2, "Non-exhaustive case in 'isListElement'.");
|
|
31555
31562
|
}
|
|
31556
|
-
return Debug.fail("Non-exhaustive case in 'isListElement'.");
|
|
31557
31563
|
}
|
|
31558
31564
|
function isValidHeritageClauseObjectLiteral() {
|
|
31559
31565
|
Debug.assert(token() === 19 /* OpenBraceToken */);
|
|
@@ -31647,7 +31653,8 @@ var Parser;
|
|
|
31647
31653
|
return false;
|
|
31648
31654
|
}
|
|
31649
31655
|
function isInSomeParsingContext() {
|
|
31650
|
-
|
|
31656
|
+
Debug.assert(parsingContext, "Missing parsing context");
|
|
31657
|
+
for (let kind = 0; kind < 26 /* Count */; kind++) {
|
|
31651
31658
|
if (parsingContext & 1 << kind) {
|
|
31652
31659
|
if (isListElement2(
|
|
31653
31660
|
kind,
|
|
@@ -31906,7 +31913,9 @@ var Parser;
|
|
|
31906
31913
|
return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
|
31907
31914
|
case 24 /* AssertEntries */:
|
|
31908
31915
|
return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected);
|
|
31909
|
-
case 25 /*
|
|
31916
|
+
case 25 /* JSDocComment */:
|
|
31917
|
+
return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
|
|
31918
|
+
case 26 /* Count */:
|
|
31910
31919
|
return Debug.fail("ParsingContext.Count used as a context");
|
|
31911
31920
|
default:
|
|
31912
31921
|
Debug.assertNever(context);
|
|
@@ -36038,7 +36047,8 @@ var Parser;
|
|
|
36038
36047
|
ParsingContext2[ParsingContext2["HeritageClauses"] = 22] = "HeritageClauses";
|
|
36039
36048
|
ParsingContext2[ParsingContext2["ImportOrExportSpecifiers"] = 23] = "ImportOrExportSpecifiers";
|
|
36040
36049
|
ParsingContext2[ParsingContext2["AssertEntries"] = 24] = "AssertEntries";
|
|
36041
|
-
ParsingContext2[ParsingContext2["
|
|
36050
|
+
ParsingContext2[ParsingContext2["JSDocComment"] = 25] = "JSDocComment";
|
|
36051
|
+
ParsingContext2[ParsingContext2["Count"] = 26] = "Count";
|
|
36042
36052
|
})(ParsingContext || (ParsingContext = {}));
|
|
36043
36053
|
let Tristate;
|
|
36044
36054
|
((Tristate2) => {
|
|
@@ -36160,6 +36170,8 @@ var Parser;
|
|
|
36160
36170
|
PropertyLikeParse2[PropertyLikeParse2["CallbackParameter"] = 4] = "CallbackParameter";
|
|
36161
36171
|
})(PropertyLikeParse || (PropertyLikeParse = {}));
|
|
36162
36172
|
function parseJSDocCommentWorker(start2 = 0, length2) {
|
|
36173
|
+
const saveParsingContext = parsingContext;
|
|
36174
|
+
parsingContext |= 1 << 25 /* JSDocComment */;
|
|
36163
36175
|
const content = sourceText;
|
|
36164
36176
|
const end = length2 === void 0 ? content.length : start2 + length2;
|
|
36165
36177
|
length2 = end - start2;
|
|
@@ -36176,7 +36188,10 @@ var Parser;
|
|
|
36176
36188
|
let commentsPos;
|
|
36177
36189
|
let comments = [];
|
|
36178
36190
|
const parts = [];
|
|
36179
|
-
|
|
36191
|
+
const result = scanner2.scanRange(start2 + 3, length2 - 5, doJSDocScan);
|
|
36192
|
+
parsingContext = saveParsingContext;
|
|
36193
|
+
return result;
|
|
36194
|
+
function doJSDocScan() {
|
|
36180
36195
|
let state = 1 /* SawAsterisk */;
|
|
36181
36196
|
let margin;
|
|
36182
36197
|
let indent3 = start2 - (content.lastIndexOf("\n", start2) + 1) + 4;
|
|
@@ -36272,7 +36287,7 @@ var Parser;
|
|
|
36272
36287
|
Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set");
|
|
36273
36288
|
const tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd);
|
|
36274
36289
|
return finishNode(factory2.createJSDocComment(parts.length ? createNodeArray(parts, start2, commentsPos) : trimmedComments.length ? trimmedComments : void 0, tagsArray), start2, end);
|
|
36275
|
-
}
|
|
36290
|
+
}
|
|
36276
36291
|
function removeLeadingNewlines(comments2) {
|
|
36277
36292
|
while (comments2.length && (comments2[0] === "\n" || comments2[0] === "\r")) {
|
|
36278
36293
|
comments2.shift();
|
|
@@ -36631,8 +36646,8 @@ var Parser;
|
|
|
36631
36646
|
typeExpression = nestedTypeLiteral;
|
|
36632
36647
|
isNameFirst = true;
|
|
36633
36648
|
}
|
|
36634
|
-
const
|
|
36635
|
-
return finishNode(
|
|
36649
|
+
const result2 = target === 1 /* Property */ ? factory2.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory2.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
|
|
36650
|
+
return finishNode(result2, start3);
|
|
36636
36651
|
}
|
|
36637
36652
|
function parseNestedTypeLiteral(typeExpression, name, target, indent3) {
|
|
36638
36653
|
if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
|
@@ -36642,6 +36657,8 @@ var Parser;
|
|
|
36642
36657
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent3, name))) {
|
|
36643
36658
|
if (child.kind === 347 /* JSDocParameterTag */ || child.kind === 354 /* JSDocPropertyTag */) {
|
|
36644
36659
|
children = append(children, child);
|
|
36660
|
+
} else if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
36661
|
+
parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
|
|
36645
36662
|
}
|
|
36646
36663
|
}
|
|
36647
36664
|
if (children) {
|
|
@@ -36780,6 +36797,9 @@ var Parser;
|
|
|
36780
36797
|
let jsDocPropertyTags;
|
|
36781
36798
|
let hasChildren = false;
|
|
36782
36799
|
while (child = tryParse(() => parseChildPropertyTag(indent3))) {
|
|
36800
|
+
if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
36801
|
+
break;
|
|
36802
|
+
}
|
|
36783
36803
|
hasChildren = true;
|
|
36784
36804
|
if (child.kind === 350 /* JSDocTypeTag */) {
|
|
36785
36805
|
if (childTypeTag) {
|
|
@@ -36839,6 +36859,10 @@ var Parser;
|
|
|
36839
36859
|
let child;
|
|
36840
36860
|
let parameters;
|
|
36841
36861
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent3))) {
|
|
36862
|
+
if (child.kind === 351 /* JSDocTemplateTag */) {
|
|
36863
|
+
parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
|
|
36864
|
+
break;
|
|
36865
|
+
}
|
|
36842
36866
|
parameters = append(parameters, child);
|
|
36843
36867
|
}
|
|
36844
36868
|
return createNodeArray(parameters || [], pos);
|
|
@@ -36933,7 +36957,7 @@ var Parser;
|
|
|
36933
36957
|
const start3 = scanner2.getTokenFullStart();
|
|
36934
36958
|
nextTokenJSDoc();
|
|
36935
36959
|
const tagName = parseJSDocIdentifierName();
|
|
36936
|
-
|
|
36960
|
+
const indentText = skipWhitespaceOrAsterisk();
|
|
36937
36961
|
let t;
|
|
36938
36962
|
switch (tagName.escapedText) {
|
|
36939
36963
|
case "type":
|
|
@@ -36947,6 +36971,8 @@ var Parser;
|
|
|
36947
36971
|
case "param":
|
|
36948
36972
|
t = 2 /* Parameter */ | 4 /* CallbackParameter */;
|
|
36949
36973
|
break;
|
|
36974
|
+
case "template":
|
|
36975
|
+
return parseTemplateTag(start3, tagName, indent3, indentText);
|
|
36950
36976
|
default:
|
|
36951
36977
|
return false;
|
|
36952
36978
|
}
|
|
@@ -37034,9 +37060,9 @@ var Parser;
|
|
|
37034
37060
|
const end2 = scanner2.getTokenEnd();
|
|
37035
37061
|
const originalKeywordKind = token();
|
|
37036
37062
|
const text = internIdentifier(scanner2.getTokenValue());
|
|
37037
|
-
const
|
|
37063
|
+
const result2 = finishNode(factoryCreateIdentifier(text, originalKeywordKind), start3, end2);
|
|
37038
37064
|
nextTokenJSDoc();
|
|
37039
|
-
return
|
|
37065
|
+
return result2;
|
|
37040
37066
|
}
|
|
37041
37067
|
}
|
|
37042
37068
|
})(JSDocParser = Parser2.JSDocParser || (Parser2.JSDocParser = {}));
|
|
@@ -48010,7 +48036,7 @@ function createTypeChecker(host) {
|
|
|
48010
48036
|
getGlobalIterableType: getGlobalAsyncIterableType,
|
|
48011
48037
|
getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
|
|
48012
48038
|
getGlobalGeneratorType: getGlobalAsyncGeneratorType,
|
|
48013
|
-
resolveIterationType: getAwaitedType,
|
|
48039
|
+
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),
|
|
48014
48040
|
mustHaveANextMethodDiagnostic: Diagnostics.An_async_iterator_must_have_a_next_method,
|
|
48015
48041
|
mustBeAMethodDiagnostic: Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
|
|
48016
48042
|
mustHaveAValueDiagnostic: Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property
|
|
@@ -48653,7 +48679,7 @@ function createTypeChecker(host) {
|
|
|
48653
48679
|
return true;
|
|
48654
48680
|
}
|
|
48655
48681
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
48656
|
-
if (getEmitScriptTarget(compilerOptions)
|
|
48682
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
48657
48683
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
48658
48684
|
declaration,
|
|
48659
48685
|
usage,
|
|
@@ -54343,7 +54369,7 @@ function createTypeChecker(host) {
|
|
|
54343
54369
|
context.enclosingDeclaration = originalDecl || oldEnclosing;
|
|
54344
54370
|
const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
|
|
54345
54371
|
const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
|
|
54346
|
-
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
54372
|
+
const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
|
|
54347
54373
|
const baseTypes = getBaseTypes(classType);
|
|
54348
54374
|
const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
|
|
54349
54375
|
const implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || mapDefined(getImplementsTypes(classType), serializeImplementedType);
|
|
@@ -55542,7 +55568,7 @@ function createTypeChecker(host) {
|
|
|
55542
55568
|
const elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern);
|
|
55543
55569
|
const index = pattern.elements.indexOf(declaration);
|
|
55544
55570
|
if (declaration.dotDotDotToken) {
|
|
55545
|
-
const baseConstraint =
|
|
55571
|
+
const baseConstraint = mapType(parentType, (t) => t.flags & 58982400 /* InstantiableNonPrimitive */ ? getBaseConstraintOrType(t) : t);
|
|
55546
55572
|
type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
|
|
55547
55573
|
} else if (isArrayLikeType(parentType)) {
|
|
55548
55574
|
const indexType = getNumberLiteralType(index);
|
|
@@ -57270,6 +57296,9 @@ function createTypeChecker(host) {
|
|
|
57270
57296
|
}
|
|
57271
57297
|
return needApparentType ? getApparentType(type) : type;
|
|
57272
57298
|
}
|
|
57299
|
+
function getThisArgument(type) {
|
|
57300
|
+
return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
|
|
57301
|
+
}
|
|
57273
57302
|
function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
|
|
57274
57303
|
let mapper;
|
|
57275
57304
|
let members;
|
|
@@ -57400,7 +57429,7 @@ function createTypeChecker(host) {
|
|
|
57400
57429
|
}
|
|
57401
57430
|
return [sig.parameters];
|
|
57402
57431
|
function expandSignatureParametersWithTupleMembers(restType, restIndex) {
|
|
57403
|
-
const elementTypes =
|
|
57432
|
+
const elementTypes = getElementTypes(restType);
|
|
57404
57433
|
const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
|
|
57405
57434
|
const restParams = map(elementTypes, (t, i) => {
|
|
57406
57435
|
const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
|
|
@@ -58216,7 +58245,7 @@ function createTypeChecker(host) {
|
|
|
58216
58245
|
}
|
|
58217
58246
|
function isConstTypeVariable(type) {
|
|
58218
58247
|
var _a;
|
|
58219
|
-
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(
|
|
58248
|
+
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));
|
|
58220
58249
|
}
|
|
58221
58250
|
function getConstraintOfIndexedAccess(type) {
|
|
58222
58251
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
@@ -58318,7 +58347,7 @@ function createTypeChecker(host) {
|
|
|
58318
58347
|
return void 0;
|
|
58319
58348
|
}
|
|
58320
58349
|
function getBaseConstraintOfType(type) {
|
|
58321
|
-
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
58350
|
+
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || isGenericTupleType(type)) {
|
|
58322
58351
|
const constraint = getResolvedBaseConstraint(type);
|
|
58323
58352
|
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : void 0;
|
|
58324
58353
|
}
|
|
@@ -58335,7 +58364,7 @@ function createTypeChecker(host) {
|
|
|
58335
58364
|
return type.resolvedBaseConstraint;
|
|
58336
58365
|
}
|
|
58337
58366
|
const stack = [];
|
|
58338
|
-
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
|
|
58367
|
+
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
|
|
58339
58368
|
function getImmediateBaseConstraint(t) {
|
|
58340
58369
|
if (!t.immediateBaseConstraint) {
|
|
58341
58370
|
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
|
|
@@ -58425,6 +58454,13 @@ function createTypeChecker(host) {
|
|
|
58425
58454
|
if (t.flags & 33554432 /* Substitution */) {
|
|
58426
58455
|
return getBaseConstraint(getSubstitutionIntersection(t));
|
|
58427
58456
|
}
|
|
58457
|
+
if (isGenericTupleType(t)) {
|
|
58458
|
+
const newElements = map(getElementTypes(t), (v, i) => {
|
|
58459
|
+
const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
58460
|
+
return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
58461
|
+
});
|
|
58462
|
+
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
58463
|
+
}
|
|
58428
58464
|
return t;
|
|
58429
58465
|
}
|
|
58430
58466
|
}
|
|
@@ -60479,7 +60515,7 @@ function createTypeChecker(host) {
|
|
|
60479
60515
|
if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
|
|
60480
60516
|
addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
|
|
60481
60517
|
} else if (isTupleType(type)) {
|
|
60482
|
-
const elements =
|
|
60518
|
+
const elements = getElementTypes(type);
|
|
60483
60519
|
if (elements.length + expandedTypes.length >= 1e4) {
|
|
60484
60520
|
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);
|
|
60485
60521
|
return errorType;
|
|
@@ -60557,6 +60593,11 @@ function createTypeChecker(host) {
|
|
|
60557
60593
|
function getEndElementCount(type, flags) {
|
|
60558
60594
|
return type.elementFlags.length - findLastIndex(type.elementFlags, (f) => !(f & flags)) - 1;
|
|
60559
60595
|
}
|
|
60596
|
+
function getElementTypes(type) {
|
|
60597
|
+
const typeArguments = getTypeArguments(type);
|
|
60598
|
+
const arity = getTypeReferenceArity(type);
|
|
60599
|
+
return typeArguments.length === arity ? typeArguments : typeArguments.slice(0, arity);
|
|
60600
|
+
}
|
|
60560
60601
|
function getTypeFromOptionalTypeNode(node) {
|
|
60561
60602
|
return addOptionality(
|
|
60562
60603
|
getTypeFromTypeNode(node.type),
|
|
@@ -61807,7 +61848,7 @@ function createTypeChecker(host) {
|
|
|
61807
61848
|
return isTupleTypeNode(node) && length(node.elements) > 0 && !some(node.elements, (e) => isOptionalTypeNode(e) || isRestTypeNode(e) || isNamedTupleMember(e) && !!(e.questionToken || e.dotDotDotToken));
|
|
61808
61849
|
}
|
|
61809
61850
|
function isDeferredType(type, checkTuples) {
|
|
61810
|
-
return isGenericType(type) || checkTuples && isTupleType(type) && some(
|
|
61851
|
+
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
61811
61852
|
}
|
|
61812
61853
|
function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
|
|
61813
61854
|
let result;
|
|
@@ -62742,7 +62783,7 @@ function createTypeChecker(host) {
|
|
|
62742
62783
|
}
|
|
62743
62784
|
function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
|
|
62744
62785
|
const elementFlags = tupleType.target.elementFlags;
|
|
62745
|
-
const elementTypes = map(
|
|
62786
|
+
const elementTypes = map(getElementTypes(tupleType), (t, i) => {
|
|
62746
62787
|
const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
|
|
62747
62788
|
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
62748
62789
|
});
|
|
@@ -62761,7 +62802,7 @@ function createTypeChecker(host) {
|
|
|
62761
62802
|
}
|
|
62762
62803
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
62763
62804
|
const elementFlags = tupleType.target.elementFlags;
|
|
62764
|
-
const elementTypes = map(
|
|
62805
|
+
const elementTypes = map(getElementTypes(tupleType), (_, i) => instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper));
|
|
62765
62806
|
const modifiers = getMappedTypeModifiers(mappedType);
|
|
62766
62807
|
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;
|
|
62767
62808
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
|
|
@@ -63947,7 +63988,7 @@ function createTypeChecker(host) {
|
|
|
63947
63988
|
return type;
|
|
63948
63989
|
}
|
|
63949
63990
|
function getNormalizedTupleType(type, writing) {
|
|
63950
|
-
const elements =
|
|
63991
|
+
const elements = getElementTypes(type);
|
|
63951
63992
|
const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
|
|
63952
63993
|
return elements !== normalizedElements ? createNormalizedTupleType(type.target, normalizedElements) : type;
|
|
63953
63994
|
}
|
|
@@ -64236,6 +64277,8 @@ function createTypeChecker(host) {
|
|
|
64236
64277
|
return isRelatedTo(source2, target2, 3 /* Both */, reportErrors2);
|
|
64237
64278
|
}
|
|
64238
64279
|
function isRelatedTo(originalSource, originalTarget, recursionFlags = 3 /* Both */, reportErrors2 = false, headMessage2, intersectionState = 0 /* None */) {
|
|
64280
|
+
if (originalSource === originalTarget)
|
|
64281
|
+
return -1 /* True */;
|
|
64239
64282
|
if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 402784252 /* Primitive */) {
|
|
64240
64283
|
if (relation === comparableRelation && !(originalTarget.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(originalTarget, originalSource, relation) || isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors2 ? reportError : void 0)) {
|
|
64241
64284
|
return -1 /* True */;
|
|
@@ -65454,6 +65497,11 @@ function createTypeChecker(host) {
|
|
|
65454
65497
|
} else {
|
|
65455
65498
|
return 0 /* False */;
|
|
65456
65499
|
}
|
|
65500
|
+
} else if (isGenericTupleType(source2) && isTupleType(target2) && !isGenericTupleType(target2)) {
|
|
65501
|
+
const constraint = getBaseConstraintOrType(source2);
|
|
65502
|
+
if (constraint !== source2) {
|
|
65503
|
+
return isRelatedTo(constraint, target2, 1 /* Source */, reportErrors2);
|
|
65504
|
+
}
|
|
65457
65505
|
} else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target2) && getObjectFlags(target2) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source2)) {
|
|
65458
65506
|
return 0 /* False */;
|
|
65459
65507
|
}
|
|
@@ -67369,7 +67417,7 @@ function createTypeChecker(host) {
|
|
|
67369
67417
|
return type;
|
|
67370
67418
|
}
|
|
67371
67419
|
function isPartiallyInferableType(type) {
|
|
67372
|
-
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(
|
|
67420
|
+
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType2(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
|
|
67373
67421
|
}
|
|
67374
67422
|
function createReverseMappedType(source, target, constraint) {
|
|
67375
67423
|
if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
|
|
@@ -67379,7 +67427,7 @@ function createTypeChecker(host) {
|
|
|
67379
67427
|
return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
|
|
67380
67428
|
}
|
|
67381
67429
|
if (isTupleType(source)) {
|
|
67382
|
-
const elementTypes = map(
|
|
67430
|
+
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
|
|
67383
67431
|
const elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? sameMap(source.target.elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : source.target.elementFlags;
|
|
67384
67432
|
return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
|
|
67385
67433
|
}
|
|
@@ -68215,14 +68263,14 @@ function createTypeChecker(host) {
|
|
|
68215
68263
|
const inference = context.inferences[index];
|
|
68216
68264
|
if (!inference.inferredType) {
|
|
68217
68265
|
let inferredType;
|
|
68218
|
-
|
|
68219
|
-
if (signature) {
|
|
68220
|
-
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : void 0;
|
|
68221
|
-
|
|
68222
|
-
|
|
68223
|
-
|
|
68224
|
-
|
|
68225
|
-
|
|
68266
|
+
let fallbackType;
|
|
68267
|
+
if (context.signature) {
|
|
68268
|
+
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, context.signature) : void 0;
|
|
68269
|
+
const inferredContravariantType = inference.contraCandidates ? getContravariantInference(inference) : void 0;
|
|
68270
|
+
if (inferredCovariantType || inferredContravariantType) {
|
|
68271
|
+
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))));
|
|
68272
|
+
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
68273
|
+
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
68226
68274
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
68227
68275
|
inferredType = silentNeverType;
|
|
68228
68276
|
} else {
|
|
@@ -68239,7 +68287,7 @@ function createTypeChecker(host) {
|
|
|
68239
68287
|
if (constraint) {
|
|
68240
68288
|
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
|
|
68241
68289
|
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
|
68242
|
-
inference.inferredType =
|
|
68290
|
+
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
|
|
68243
68291
|
}
|
|
68244
68292
|
}
|
|
68245
68293
|
}
|
|
@@ -74160,7 +74208,7 @@ function createTypeChecker(host) {
|
|
|
74160
74208
|
}
|
|
74161
74209
|
function getMutableArrayOrTupleType(type) {
|
|
74162
74210
|
return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(
|
|
74163
|
-
|
|
74211
|
+
getElementTypes(type),
|
|
74164
74212
|
type.target.elementFlags,
|
|
74165
74213
|
/*readonly*/
|
|
74166
74214
|
false,
|
|
@@ -74474,7 +74522,7 @@ function createTypeChecker(host) {
|
|
|
74474
74522
|
const arg = args[i];
|
|
74475
74523
|
const spreadType = arg.kind === 229 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
74476
74524
|
if (spreadType && isTupleType(spreadType)) {
|
|
74477
|
-
forEach(
|
|
74525
|
+
forEach(getElementTypes(spreadType), (t, i2) => {
|
|
74478
74526
|
var _a;
|
|
74479
74527
|
const flags = spreadType.target.elementFlags[i2];
|
|
74480
74528
|
const syntheticArg = createSyntheticExpression(
|
|
@@ -76988,6 +77036,10 @@ function createTypeChecker(host) {
|
|
|
76988
77036
|
forEachReturnStatement(func.body, (returnStatement) => {
|
|
76989
77037
|
const expr = returnStatement.expression;
|
|
76990
77038
|
if (expr) {
|
|
77039
|
+
if (expr.kind === 212 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
|
|
77040
|
+
hasReturnOfTypeNever = true;
|
|
77041
|
+
return;
|
|
77042
|
+
}
|
|
76991
77043
|
let type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
|
|
76992
77044
|
if (functionFlags & 2 /* Async */) {
|
|
76993
77045
|
type = unwrapAwaitedType(checkAwaitedType(
|
|
@@ -78468,7 +78520,7 @@ function createTypeChecker(host) {
|
|
|
78468
78520
|
}
|
|
78469
78521
|
function padTupleType(type, pattern) {
|
|
78470
78522
|
const patternElements = pattern.elements;
|
|
78471
|
-
const elementTypes =
|
|
78523
|
+
const elementTypes = getElementTypes(type).slice();
|
|
78472
78524
|
const elementFlags = type.target.elementFlags.slice();
|
|
78473
78525
|
for (let i = getTypeReferenceArity(type); i < patternElements.length; i++) {
|
|
78474
78526
|
const e = patternElements[i];
|
|
@@ -98612,10 +98664,7 @@ function transformES2018(context) {
|
|
|
98612
98664
|
const exitNonUserCodeExpression = factory2.createAssignment(nonUserCode, factory2.createFalse());
|
|
98613
98665
|
const exitNonUserCodeStatement = factory2.createExpressionStatement(exitNonUserCodeExpression);
|
|
98614
98666
|
setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
|
98615
|
-
const
|
|
98616
|
-
const enterNonUserCodeStatement = factory2.createExpressionStatement(enterNonUserCodeExpression);
|
|
98617
|
-
setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
|
98618
|
-
const statements = [];
|
|
98667
|
+
const statements = [iteratorValueStatement, exitNonUserCodeStatement];
|
|
98619
98668
|
const binding = createForOfBindingStatement(factory2, node.initializer, value);
|
|
98620
98669
|
statements.push(visitNode(binding, visitor, isStatement));
|
|
98621
98670
|
let bodyLocation;
|
|
@@ -98628,29 +98677,14 @@ function transformES2018(context) {
|
|
|
98628
98677
|
} else {
|
|
98629
98678
|
statements.push(statement);
|
|
98630
98679
|
}
|
|
98631
|
-
|
|
98632
|
-
|
|
98633
|
-
factory2.
|
|
98634
|
-
|
|
98635
|
-
|
|
98636
|
-
true
|
|
98637
|
-
),
|
|
98638
|
-
bodyLocation
|
|
98680
|
+
return setTextRange(
|
|
98681
|
+
factory2.createBlock(
|
|
98682
|
+
setTextRange(factory2.createNodeArray(statements), statementsLocation),
|
|
98683
|
+
/*multiLine*/
|
|
98684
|
+
true
|
|
98639
98685
|
),
|
|
98640
|
-
|
|
98686
|
+
bodyLocation
|
|
98641
98687
|
);
|
|
98642
|
-
return factory2.createBlock([
|
|
98643
|
-
iteratorValueStatement,
|
|
98644
|
-
exitNonUserCodeStatement,
|
|
98645
|
-
factory2.createTryStatement(
|
|
98646
|
-
body,
|
|
98647
|
-
/*catchClause*/
|
|
98648
|
-
void 0,
|
|
98649
|
-
factory2.createBlock([
|
|
98650
|
-
enterNonUserCodeStatement
|
|
98651
|
-
])
|
|
98652
|
-
)
|
|
98653
|
-
]);
|
|
98654
98688
|
}
|
|
98655
98689
|
function createDownlevelAwait(expression) {
|
|
98656
98690
|
return enclosingFunctionFlags & 1 /* Generator */ ? factory2.createYieldExpression(
|
|
@@ -98729,7 +98763,7 @@ function transformES2018(context) {
|
|
|
98729
98763
|
factory2.createLogicalNot(done)
|
|
98730
98764
|
]),
|
|
98731
98765
|
/*incrementor*/
|
|
98732
|
-
|
|
98766
|
+
factory2.createAssignment(nonUserCode, factory2.createTrue()),
|
|
98733
98767
|
/*statement*/
|
|
98734
98768
|
convertForOfStatementHead(node, getValue, nonUserCode)
|
|
98735
98769
|
),
|
|
@@ -165033,7 +165067,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
165033
165067
|
displayParts.push(spacePart());
|
|
165034
165068
|
displayParts.push(operatorPart(64 /* EqualsToken */));
|
|
165035
165069
|
displayParts.push(spacePart());
|
|
165036
|
-
addRange(displayParts, typeToDisplayParts(typeChecker, isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
|
165070
|
+
addRange(displayParts, typeToDisplayParts(typeChecker, location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
|
|
165037
165071
|
}
|
|
165038
165072
|
if (symbolFlags & 384 /* Enum */) {
|
|
165039
165073
|
prefixNextMeaning();
|
|
@@ -179118,7 +179152,7 @@ function formatMessage2(msg, logger, byteLength, newLine) {
|
|
|
179118
179152
|
const verboseLogging = logger.hasLevel(3 /* verbose */);
|
|
179119
179153
|
const json = JSON.stringify(msg);
|
|
179120
179154
|
if (verboseLogging) {
|
|
179121
|
-
logger.info(`${msg.type}:${indent2(
|
|
179155
|
+
logger.info(`${msg.type}:${indent2(JSON.stringify(msg, void 0, " "))}`);
|
|
179122
179156
|
}
|
|
179123
179157
|
const len = byteLength(json, "utf8");
|
|
179124
179158
|
return `Content-Length: ${1 + len}\r
|