typescript 4.8.0-dev.20220718 → 4.8.0-dev.20220721
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.dom.d.ts +2 -2
- package/lib/lib.webworker.d.ts +2 -2
- package/lib/tsc.js +45 -27
- package/lib/tsserver.js +63 -37
- package/lib/tsserverlibrary.d.ts +6 -0
- package/lib/tsserverlibrary.js +63 -37
- package/lib/typescript.d.ts +6 -0
- package/lib/typescript.js +61 -37
- package/lib/typescriptServices.d.ts +6 -0
- package/lib/typescriptServices.js +61 -37
- package/lib/typingsInstaller.js +51 -27
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -303,7 +303,7 @@ var ts;
|
|
|
303
303
|
// The following is baselined as a literal template type without intervention
|
|
304
304
|
/** The version of the TypeScript compiler release */
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
306
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220721";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -13411,6 +13411,12 @@ var ts;
|
|
|
13411
13411
|
/**
|
|
13412
13412
|
* Gets the effective type parameters. If the node was parsed in a
|
|
13413
13413
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
13414
|
+
*
|
|
13415
|
+
* This does *not* return type parameters from a jsdoc reference to a generic type, eg
|
|
13416
|
+
*
|
|
13417
|
+
* type Id = <T>(x: T) => T
|
|
13418
|
+
* /** @type {Id} /
|
|
13419
|
+
* function id(x) { return x }
|
|
13414
13420
|
*/
|
|
13415
13421
|
function getEffectiveTypeParameterDeclarations(node) {
|
|
13416
13422
|
if (ts.isJSDocSignature(node)) {
|
|
@@ -35671,6 +35677,9 @@ var ts;
|
|
|
35671
35677
|
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
35672
35678
|
if (typeArguments !== undefined) {
|
|
35673
35679
|
parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
|
|
35680
|
+
if (!isTemplateStartOfTaggedTemplate()) {
|
|
35681
|
+
expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
|
|
35682
|
+
}
|
|
35674
35683
|
}
|
|
35675
35684
|
}
|
|
35676
35685
|
if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) {
|
|
@@ -50622,7 +50631,7 @@ var ts;
|
|
|
50622
50631
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50623
50632
|
// 2. When result is defined
|
|
50624
50633
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50625
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50634
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50626
50635
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50627
50636
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50628
50637
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -59388,6 +59397,9 @@ var ts;
|
|
|
59388
59397
|
else if (type.objectFlags & 32 /* Mapped */) {
|
|
59389
59398
|
resolveMappedTypeMembers(type);
|
|
59390
59399
|
}
|
|
59400
|
+
else {
|
|
59401
|
+
ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags));
|
|
59402
|
+
}
|
|
59391
59403
|
}
|
|
59392
59404
|
else if (type.flags & 1048576 /* Union */) {
|
|
59393
59405
|
resolveUnionTypeMembers(type);
|
|
@@ -59395,6 +59407,9 @@ var ts;
|
|
|
59395
59407
|
else if (type.flags & 2097152 /* Intersection */) {
|
|
59396
59408
|
resolveIntersectionTypeMembers(type);
|
|
59397
59409
|
}
|
|
59410
|
+
else {
|
|
59411
|
+
ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags));
|
|
59412
|
+
}
|
|
59398
59413
|
}
|
|
59399
59414
|
return type;
|
|
59400
59415
|
}
|
|
@@ -60186,12 +60201,15 @@ var ts;
|
|
|
60186
60201
|
// Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual
|
|
60187
60202
|
// type checking functions).
|
|
60188
60203
|
function getTypeParametersFromDeclaration(declaration) {
|
|
60204
|
+
var _a;
|
|
60189
60205
|
var result;
|
|
60190
|
-
for (var _i = 0,
|
|
60191
|
-
var node =
|
|
60206
|
+
for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) {
|
|
60207
|
+
var node = _b[_i];
|
|
60192
60208
|
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
|
|
60193
60209
|
}
|
|
60194
|
-
return result
|
|
60210
|
+
return (result === null || result === void 0 ? void 0 : result.length) ? result
|
|
60211
|
+
: ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters
|
|
60212
|
+
: undefined;
|
|
60195
60213
|
}
|
|
60196
60214
|
function symbolsToArray(symbols) {
|
|
60197
60215
|
var result = [];
|
|
@@ -69412,15 +69430,11 @@ var ts;
|
|
|
69412
69430
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
69413
69431
|
}
|
|
69414
69432
|
else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
69415
|
-
|
|
69416
|
-
inferFromTypes(source.type, target.type);
|
|
69417
|
-
contravariant = !contravariant;
|
|
69433
|
+
inferFromContravariantTypes(source.type, target.type);
|
|
69418
69434
|
}
|
|
69419
69435
|
else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
|
|
69420
69436
|
var empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
69421
|
-
|
|
69422
|
-
inferWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
69423
|
-
contravariant = !contravariant;
|
|
69437
|
+
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
69424
69438
|
}
|
|
69425
69439
|
else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
69426
69440
|
inferFromTypes(source.objectType, target.objectType);
|
|
@@ -69433,10 +69447,7 @@ var ts;
|
|
|
69433
69447
|
}
|
|
69434
69448
|
else if (source.flags & 33554432 /* Substitution */) {
|
|
69435
69449
|
inferFromTypes(source.baseType, target);
|
|
69436
|
-
|
|
69437
|
-
priority |= 4 /* SubstituteSource */;
|
|
69438
|
-
inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority
|
|
69439
|
-
priority = oldPriority;
|
|
69450
|
+
inferWithPriority(source.substitute, target, 4 /* SubstituteSource */); // Make substitute inference at a lower priority
|
|
69440
69451
|
}
|
|
69441
69452
|
else if (target.flags & 16777216 /* Conditional */) {
|
|
69442
69453
|
invokeOnce(source, target, inferToConditionalType);
|
|
@@ -69486,6 +69497,18 @@ var ts;
|
|
|
69486
69497
|
inferFromTypes(source, target);
|
|
69487
69498
|
priority = savePriority;
|
|
69488
69499
|
}
|
|
69500
|
+
function inferFromContravariantTypesWithPriority(source, target, newPriority) {
|
|
69501
|
+
var savePriority = priority;
|
|
69502
|
+
priority |= newPriority;
|
|
69503
|
+
inferFromContravariantTypes(source, target);
|
|
69504
|
+
priority = savePriority;
|
|
69505
|
+
}
|
|
69506
|
+
function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) {
|
|
69507
|
+
var savePriority = priority;
|
|
69508
|
+
priority |= newPriority;
|
|
69509
|
+
inferToMultipleTypes(source, targets, targetFlags);
|
|
69510
|
+
priority = savePriority;
|
|
69511
|
+
}
|
|
69489
69512
|
function invokeOnce(source, target, action) {
|
|
69490
69513
|
var key = source.id + "," + target.id;
|
|
69491
69514
|
var status = visited && visited.get(key);
|
|
@@ -69550,10 +69573,13 @@ var ts;
|
|
|
69550
69573
|
}
|
|
69551
69574
|
}
|
|
69552
69575
|
function inferFromContravariantTypes(source, target) {
|
|
69576
|
+
contravariant = !contravariant;
|
|
69577
|
+
inferFromTypes(source, target);
|
|
69578
|
+
contravariant = !contravariant;
|
|
69579
|
+
}
|
|
69580
|
+
function inferFromContravariantTypesIfStrictFunctionTypes(source, target) {
|
|
69553
69581
|
if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) {
|
|
69554
|
-
|
|
69555
|
-
inferFromTypes(source, target);
|
|
69556
|
-
contravariant = !contravariant;
|
|
69582
|
+
inferFromContravariantTypes(source, target);
|
|
69557
69583
|
}
|
|
69558
69584
|
else {
|
|
69559
69585
|
inferFromTypes(source, target);
|
|
@@ -69717,11 +69743,8 @@ var ts;
|
|
|
69717
69743
|
inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
|
|
69718
69744
|
}
|
|
69719
69745
|
else {
|
|
69720
|
-
var savePriority = priority;
|
|
69721
|
-
priority |= contravariant ? 64 /* ContravariantConditional */ : 0;
|
|
69722
69746
|
var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
|
|
69723
|
-
|
|
69724
|
-
priority = savePriority;
|
|
69747
|
+
inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* ContravariantConditional */ : 0);
|
|
69725
69748
|
}
|
|
69726
69749
|
}
|
|
69727
69750
|
function inferToTemplateLiteralType(source, target) {
|
|
@@ -69907,7 +69930,7 @@ var ts;
|
|
|
69907
69930
|
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
69908
69931
|
// Once we descend into a bivariant signature we remain bivariant for all nested inferences
|
|
69909
69932
|
bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
|
|
69910
|
-
applyToParameterTypes(source, target,
|
|
69933
|
+
applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes);
|
|
69911
69934
|
bivariant = saveBivariant;
|
|
69912
69935
|
applyToReturnTypes(source, target, inferFromTypes);
|
|
69913
69936
|
}
|
|
@@ -71360,7 +71383,7 @@ var ts;
|
|
|
71360
71383
|
}
|
|
71361
71384
|
// for (const _ in ref) acts as a nonnull on ref
|
|
71362
71385
|
if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) {
|
|
71363
|
-
return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
|
|
71386
|
+
return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))));
|
|
71364
71387
|
}
|
|
71365
71388
|
// Assignment doesn't affect reference
|
|
71366
71389
|
return undefined;
|
|
@@ -76949,7 +76972,7 @@ var ts;
|
|
|
76949
76972
|
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
|
|
76950
76973
|
var reportErrors = !candidatesOutArray;
|
|
76951
76974
|
var typeArguments;
|
|
76952
|
-
if (!isDecorator) {
|
|
76975
|
+
if (!isDecorator && !ts.isSuperCall(node)) {
|
|
76953
76976
|
typeArguments = node.typeArguments;
|
|
76954
76977
|
// We already perform checking on the type arguments on the class declaration itself.
|
|
76955
76978
|
if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) {
|
|
@@ -79365,7 +79388,7 @@ var ts;
|
|
|
79365
79388
|
error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
|
|
79366
79389
|
}
|
|
79367
79390
|
if (node.operator === 39 /* PlusToken */) {
|
|
79368
|
-
if (
|
|
79391
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
|
|
79369
79392
|
error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
79370
79393
|
}
|
|
79371
79394
|
return numberType;
|
|
@@ -93683,7 +93706,8 @@ var ts;
|
|
|
93683
93706
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93684
93707
|
}
|
|
93685
93708
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93686
|
-
|
|
93709
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93710
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93687
93711
|
// End the lexical environment.
|
|
93688
93712
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93689
93713
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -133141,11 +133165,11 @@ var ts;
|
|
|
133141
133165
|
var parent = walkUpParentheses(node.parent);
|
|
133142
133166
|
switch (parent.kind) {
|
|
133143
133167
|
case 196 /* LiteralType */: {
|
|
133144
|
-
var
|
|
133145
|
-
switch (
|
|
133168
|
+
var grandParent_1 = walkUpParentheses(parent.parent);
|
|
133169
|
+
switch (grandParent_1.kind) {
|
|
133170
|
+
case 228 /* ExpressionWithTypeArguments */:
|
|
133146
133171
|
case 178 /* TypeReference */: {
|
|
133147
|
-
var
|
|
133148
|
-
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; });
|
|
133172
|
+
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; });
|
|
133149
133173
|
if (typeArgument) {
|
|
133150
133174
|
return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
|
|
133151
133175
|
}
|
|
@@ -133158,7 +133182,7 @@ var ts;
|
|
|
133158
133182
|
// bar: string;
|
|
133159
133183
|
// }
|
|
133160
133184
|
// let x: Foo["/*completion position*/"]
|
|
133161
|
-
var _a =
|
|
133185
|
+
var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType;
|
|
133162
133186
|
if (!ts.rangeContainsPosition(indexType, position)) {
|
|
133163
133187
|
return undefined;
|
|
133164
133188
|
}
|
|
@@ -133166,11 +133190,11 @@ var ts;
|
|
|
133166
133190
|
case 200 /* ImportType */:
|
|
133167
133191
|
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
|
|
133168
133192
|
case 187 /* UnionType */: {
|
|
133169
|
-
if (!ts.isTypeReferenceNode(
|
|
133193
|
+
if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
|
|
133170
133194
|
return undefined;
|
|
133171
133195
|
}
|
|
133172
|
-
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(
|
|
133173
|
-
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(
|
|
133196
|
+
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent);
|
|
133197
|
+
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
|
|
133174
133198
|
return { kind: 2 /* Types */, types: types, isNewIdentifier: false };
|
|
133175
133199
|
}
|
|
133176
133200
|
default:
|
|
@@ -159781,7 +159805,7 @@ var ts;
|
|
|
159781
159805
|
// If there is more than one overload but no implementation signature
|
|
159782
159806
|
// (eg: an abstract method or interface declaration), there is a 1-1
|
|
159783
159807
|
// correspondence of declarations and signatures.
|
|
159784
|
-
var signatures =
|
|
159808
|
+
var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
|
|
159785
159809
|
if (!ts.some(signatures)) {
|
|
159786
159810
|
break;
|
|
159787
159811
|
}
|
|
@@ -162474,7 +162498,7 @@ var ts;
|
|
|
162474
162498
|
var savedPermittedJumps = permittedJumps;
|
|
162475
162499
|
switch (node.kind) {
|
|
162476
162500
|
case 239 /* IfStatement */:
|
|
162477
|
-
permittedJumps
|
|
162501
|
+
permittedJumps &= ~4 /* Return */;
|
|
162478
162502
|
break;
|
|
162479
162503
|
case 252 /* TryStatement */:
|
|
162480
162504
|
// forbid all jumps inside try blocks
|
|
@@ -177188,6 +177212,8 @@ var ts;
|
|
|
177188
177212
|
function getDefinitionLocation(defaultProject, initialLocation, isForRename) {
|
|
177189
177213
|
var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
|
|
177190
177214
|
var info = infos && ts.firstOrUndefined(infos);
|
|
177215
|
+
// Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file
|
|
177216
|
+
// (implying that FAR cascading behavior may depend on request order)
|
|
177191
177217
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
177192
177218
|
}
|
|
177193
177219
|
function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
|
package/lib/typescript.d.ts
CHANGED
|
@@ -4464,6 +4464,12 @@ declare namespace ts {
|
|
|
4464
4464
|
/**
|
|
4465
4465
|
* Gets the effective type parameters. If the node was parsed in a
|
|
4466
4466
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
4467
|
+
*
|
|
4468
|
+
* This does *not* return type parameters from a jsdoc reference to a generic type, eg
|
|
4469
|
+
*
|
|
4470
|
+
* type Id = <T>(x: T) => T
|
|
4471
|
+
* /** @type {Id} /
|
|
4472
|
+
* function id(x) { return x }
|
|
4467
4473
|
*/
|
|
4468
4474
|
function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[];
|
|
4469
4475
|
function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined;
|
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220721";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -13402,6 +13402,12 @@ var ts;
|
|
|
13402
13402
|
/**
|
|
13403
13403
|
* Gets the effective type parameters. If the node was parsed in a
|
|
13404
13404
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
13405
|
+
*
|
|
13406
|
+
* This does *not* return type parameters from a jsdoc reference to a generic type, eg
|
|
13407
|
+
*
|
|
13408
|
+
* type Id = <T>(x: T) => T
|
|
13409
|
+
* /** @type {Id} /
|
|
13410
|
+
* function id(x) { return x }
|
|
13405
13411
|
*/
|
|
13406
13412
|
function getEffectiveTypeParameterDeclarations(node) {
|
|
13407
13413
|
if (ts.isJSDocSignature(node)) {
|
|
@@ -35662,6 +35668,9 @@ var ts;
|
|
|
35662
35668
|
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
35663
35669
|
if (typeArguments !== undefined) {
|
|
35664
35670
|
parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
|
|
35671
|
+
if (!isTemplateStartOfTaggedTemplate()) {
|
|
35672
|
+
expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
|
|
35673
|
+
}
|
|
35665
35674
|
}
|
|
35666
35675
|
}
|
|
35667
35676
|
if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) {
|
|
@@ -50613,7 +50622,7 @@ var ts;
|
|
|
50613
50622
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50614
50623
|
// 2. When result is defined
|
|
50615
50624
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50616
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50625
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50617
50626
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50618
50627
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50619
50628
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -59379,6 +59388,9 @@ var ts;
|
|
|
59379
59388
|
else if (type.objectFlags & 32 /* Mapped */) {
|
|
59380
59389
|
resolveMappedTypeMembers(type);
|
|
59381
59390
|
}
|
|
59391
|
+
else {
|
|
59392
|
+
ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags));
|
|
59393
|
+
}
|
|
59382
59394
|
}
|
|
59383
59395
|
else if (type.flags & 1048576 /* Union */) {
|
|
59384
59396
|
resolveUnionTypeMembers(type);
|
|
@@ -59386,6 +59398,9 @@ var ts;
|
|
|
59386
59398
|
else if (type.flags & 2097152 /* Intersection */) {
|
|
59387
59399
|
resolveIntersectionTypeMembers(type);
|
|
59388
59400
|
}
|
|
59401
|
+
else {
|
|
59402
|
+
ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags));
|
|
59403
|
+
}
|
|
59389
59404
|
}
|
|
59390
59405
|
return type;
|
|
59391
59406
|
}
|
|
@@ -60177,12 +60192,15 @@ var ts;
|
|
|
60177
60192
|
// Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual
|
|
60178
60193
|
// type checking functions).
|
|
60179
60194
|
function getTypeParametersFromDeclaration(declaration) {
|
|
60195
|
+
var _a;
|
|
60180
60196
|
var result;
|
|
60181
|
-
for (var _i = 0,
|
|
60182
|
-
var node =
|
|
60197
|
+
for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) {
|
|
60198
|
+
var node = _b[_i];
|
|
60183
60199
|
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
|
|
60184
60200
|
}
|
|
60185
|
-
return result
|
|
60201
|
+
return (result === null || result === void 0 ? void 0 : result.length) ? result
|
|
60202
|
+
: ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters
|
|
60203
|
+
: undefined;
|
|
60186
60204
|
}
|
|
60187
60205
|
function symbolsToArray(symbols) {
|
|
60188
60206
|
var result = [];
|
|
@@ -69403,15 +69421,11 @@ var ts;
|
|
|
69403
69421
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
69404
69422
|
}
|
|
69405
69423
|
else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
69406
|
-
|
|
69407
|
-
inferFromTypes(source.type, target.type);
|
|
69408
|
-
contravariant = !contravariant;
|
|
69424
|
+
inferFromContravariantTypes(source.type, target.type);
|
|
69409
69425
|
}
|
|
69410
69426
|
else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
|
|
69411
69427
|
var empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
69412
|
-
|
|
69413
|
-
inferWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
69414
|
-
contravariant = !contravariant;
|
|
69428
|
+
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
69415
69429
|
}
|
|
69416
69430
|
else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
69417
69431
|
inferFromTypes(source.objectType, target.objectType);
|
|
@@ -69424,10 +69438,7 @@ var ts;
|
|
|
69424
69438
|
}
|
|
69425
69439
|
else if (source.flags & 33554432 /* Substitution */) {
|
|
69426
69440
|
inferFromTypes(source.baseType, target);
|
|
69427
|
-
|
|
69428
|
-
priority |= 4 /* SubstituteSource */;
|
|
69429
|
-
inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority
|
|
69430
|
-
priority = oldPriority;
|
|
69441
|
+
inferWithPriority(source.substitute, target, 4 /* SubstituteSource */); // Make substitute inference at a lower priority
|
|
69431
69442
|
}
|
|
69432
69443
|
else if (target.flags & 16777216 /* Conditional */) {
|
|
69433
69444
|
invokeOnce(source, target, inferToConditionalType);
|
|
@@ -69477,6 +69488,18 @@ var ts;
|
|
|
69477
69488
|
inferFromTypes(source, target);
|
|
69478
69489
|
priority = savePriority;
|
|
69479
69490
|
}
|
|
69491
|
+
function inferFromContravariantTypesWithPriority(source, target, newPriority) {
|
|
69492
|
+
var savePriority = priority;
|
|
69493
|
+
priority |= newPriority;
|
|
69494
|
+
inferFromContravariantTypes(source, target);
|
|
69495
|
+
priority = savePriority;
|
|
69496
|
+
}
|
|
69497
|
+
function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) {
|
|
69498
|
+
var savePriority = priority;
|
|
69499
|
+
priority |= newPriority;
|
|
69500
|
+
inferToMultipleTypes(source, targets, targetFlags);
|
|
69501
|
+
priority = savePriority;
|
|
69502
|
+
}
|
|
69480
69503
|
function invokeOnce(source, target, action) {
|
|
69481
69504
|
var key = source.id + "," + target.id;
|
|
69482
69505
|
var status = visited && visited.get(key);
|
|
@@ -69541,10 +69564,13 @@ var ts;
|
|
|
69541
69564
|
}
|
|
69542
69565
|
}
|
|
69543
69566
|
function inferFromContravariantTypes(source, target) {
|
|
69567
|
+
contravariant = !contravariant;
|
|
69568
|
+
inferFromTypes(source, target);
|
|
69569
|
+
contravariant = !contravariant;
|
|
69570
|
+
}
|
|
69571
|
+
function inferFromContravariantTypesIfStrictFunctionTypes(source, target) {
|
|
69544
69572
|
if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) {
|
|
69545
|
-
|
|
69546
|
-
inferFromTypes(source, target);
|
|
69547
|
-
contravariant = !contravariant;
|
|
69573
|
+
inferFromContravariantTypes(source, target);
|
|
69548
69574
|
}
|
|
69549
69575
|
else {
|
|
69550
69576
|
inferFromTypes(source, target);
|
|
@@ -69708,11 +69734,8 @@ var ts;
|
|
|
69708
69734
|
inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
|
|
69709
69735
|
}
|
|
69710
69736
|
else {
|
|
69711
|
-
var savePriority = priority;
|
|
69712
|
-
priority |= contravariant ? 64 /* ContravariantConditional */ : 0;
|
|
69713
69737
|
var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
|
|
69714
|
-
|
|
69715
|
-
priority = savePriority;
|
|
69738
|
+
inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* ContravariantConditional */ : 0);
|
|
69716
69739
|
}
|
|
69717
69740
|
}
|
|
69718
69741
|
function inferToTemplateLiteralType(source, target) {
|
|
@@ -69898,7 +69921,7 @@ var ts;
|
|
|
69898
69921
|
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
69899
69922
|
// Once we descend into a bivariant signature we remain bivariant for all nested inferences
|
|
69900
69923
|
bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
|
|
69901
|
-
applyToParameterTypes(source, target,
|
|
69924
|
+
applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes);
|
|
69902
69925
|
bivariant = saveBivariant;
|
|
69903
69926
|
applyToReturnTypes(source, target, inferFromTypes);
|
|
69904
69927
|
}
|
|
@@ -71351,7 +71374,7 @@ var ts;
|
|
|
71351
71374
|
}
|
|
71352
71375
|
// for (const _ in ref) acts as a nonnull on ref
|
|
71353
71376
|
if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) {
|
|
71354
|
-
return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
|
|
71377
|
+
return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))));
|
|
71355
71378
|
}
|
|
71356
71379
|
// Assignment doesn't affect reference
|
|
71357
71380
|
return undefined;
|
|
@@ -76940,7 +76963,7 @@ var ts;
|
|
|
76940
76963
|
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
|
|
76941
76964
|
var reportErrors = !candidatesOutArray;
|
|
76942
76965
|
var typeArguments;
|
|
76943
|
-
if (!isDecorator) {
|
|
76966
|
+
if (!isDecorator && !ts.isSuperCall(node)) {
|
|
76944
76967
|
typeArguments = node.typeArguments;
|
|
76945
76968
|
// We already perform checking on the type arguments on the class declaration itself.
|
|
76946
76969
|
if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) {
|
|
@@ -79356,7 +79379,7 @@ var ts;
|
|
|
79356
79379
|
error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
|
|
79357
79380
|
}
|
|
79358
79381
|
if (node.operator === 39 /* PlusToken */) {
|
|
79359
|
-
if (
|
|
79382
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
|
|
79360
79383
|
error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
79361
79384
|
}
|
|
79362
79385
|
return numberType;
|
|
@@ -93674,7 +93697,8 @@ var ts;
|
|
|
93674
93697
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93675
93698
|
}
|
|
93676
93699
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93677
|
-
|
|
93700
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93701
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93678
93702
|
// End the lexical environment.
|
|
93679
93703
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93680
93704
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -133132,11 +133156,11 @@ var ts;
|
|
|
133132
133156
|
var parent = walkUpParentheses(node.parent);
|
|
133133
133157
|
switch (parent.kind) {
|
|
133134
133158
|
case 196 /* LiteralType */: {
|
|
133135
|
-
var
|
|
133136
|
-
switch (
|
|
133159
|
+
var grandParent_1 = walkUpParentheses(parent.parent);
|
|
133160
|
+
switch (grandParent_1.kind) {
|
|
133161
|
+
case 228 /* ExpressionWithTypeArguments */:
|
|
133137
133162
|
case 178 /* TypeReference */: {
|
|
133138
|
-
var
|
|
133139
|
-
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; });
|
|
133163
|
+
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; });
|
|
133140
133164
|
if (typeArgument) {
|
|
133141
133165
|
return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
|
|
133142
133166
|
}
|
|
@@ -133149,7 +133173,7 @@ var ts;
|
|
|
133149
133173
|
// bar: string;
|
|
133150
133174
|
// }
|
|
133151
133175
|
// let x: Foo["/*completion position*/"]
|
|
133152
|
-
var _a =
|
|
133176
|
+
var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType;
|
|
133153
133177
|
if (!ts.rangeContainsPosition(indexType, position)) {
|
|
133154
133178
|
return undefined;
|
|
133155
133179
|
}
|
|
@@ -133157,11 +133181,11 @@ var ts;
|
|
|
133157
133181
|
case 200 /* ImportType */:
|
|
133158
133182
|
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
|
|
133159
133183
|
case 187 /* UnionType */: {
|
|
133160
|
-
if (!ts.isTypeReferenceNode(
|
|
133184
|
+
if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
|
|
133161
133185
|
return undefined;
|
|
133162
133186
|
}
|
|
133163
|
-
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(
|
|
133164
|
-
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(
|
|
133187
|
+
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent);
|
|
133188
|
+
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
|
|
133165
133189
|
return { kind: 2 /* Types */, types: types, isNewIdentifier: false };
|
|
133166
133190
|
}
|
|
133167
133191
|
default:
|
|
@@ -159772,7 +159796,7 @@ var ts;
|
|
|
159772
159796
|
// If there is more than one overload but no implementation signature
|
|
159773
159797
|
// (eg: an abstract method or interface declaration), there is a 1-1
|
|
159774
159798
|
// correspondence of declarations and signatures.
|
|
159775
|
-
var signatures =
|
|
159799
|
+
var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
|
|
159776
159800
|
if (!ts.some(signatures)) {
|
|
159777
159801
|
break;
|
|
159778
159802
|
}
|
|
@@ -162465,7 +162489,7 @@ var ts;
|
|
|
162465
162489
|
var savedPermittedJumps = permittedJumps;
|
|
162466
162490
|
switch (node.kind) {
|
|
162467
162491
|
case 239 /* IfStatement */:
|
|
162468
|
-
permittedJumps
|
|
162492
|
+
permittedJumps &= ~4 /* Return */;
|
|
162469
162493
|
break;
|
|
162470
162494
|
case 252 /* TryStatement */:
|
|
162471
162495
|
// forbid all jumps inside try blocks
|
|
@@ -4464,6 +4464,12 @@ declare namespace ts {
|
|
|
4464
4464
|
/**
|
|
4465
4465
|
* Gets the effective type parameters. If the node was parsed in a
|
|
4466
4466
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
4467
|
+
*
|
|
4468
|
+
* This does *not* return type parameters from a jsdoc reference to a generic type, eg
|
|
4469
|
+
*
|
|
4470
|
+
* type Id = <T>(x: T) => T
|
|
4471
|
+
* /** @type {Id} /
|
|
4472
|
+
* function id(x) { return x }
|
|
4467
4473
|
*/
|
|
4468
4474
|
function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[];
|
|
4469
4475
|
function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined;
|