typescript 4.8.0-dev.20220717 → 4.8.0-dev.20220720
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 +42 -25
- package/lib/tsserver.js +60 -35
- package/lib/tsserverlibrary.d.ts +6 -0
- package/lib/tsserverlibrary.js +60 -35
- package/lib/typescript.d.ts +6 -0
- package/lib/typescript.js +58 -35
- package/lib/typescriptServices.d.ts +6 -0
- package/lib/typescriptServices.js +58 -35
- package/lib/typingsInstaller.js +48 -25
- 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.20220720";
|
|
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 */) {
|
|
@@ -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;
|
|
@@ -133141,11 +133164,11 @@ var ts;
|
|
|
133141
133164
|
var parent = walkUpParentheses(node.parent);
|
|
133142
133165
|
switch (parent.kind) {
|
|
133143
133166
|
case 196 /* LiteralType */: {
|
|
133144
|
-
var
|
|
133145
|
-
switch (
|
|
133167
|
+
var grandParent_1 = walkUpParentheses(parent.parent);
|
|
133168
|
+
switch (grandParent_1.kind) {
|
|
133169
|
+
case 228 /* ExpressionWithTypeArguments */:
|
|
133146
133170
|
case 178 /* TypeReference */: {
|
|
133147
|
-
var
|
|
133148
|
-
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; });
|
|
133171
|
+
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; });
|
|
133149
133172
|
if (typeArgument) {
|
|
133150
133173
|
return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
|
|
133151
133174
|
}
|
|
@@ -133158,7 +133181,7 @@ var ts;
|
|
|
133158
133181
|
// bar: string;
|
|
133159
133182
|
// }
|
|
133160
133183
|
// let x: Foo["/*completion position*/"]
|
|
133161
|
-
var _a =
|
|
133184
|
+
var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType;
|
|
133162
133185
|
if (!ts.rangeContainsPosition(indexType, position)) {
|
|
133163
133186
|
return undefined;
|
|
133164
133187
|
}
|
|
@@ -133166,11 +133189,11 @@ var ts;
|
|
|
133166
133189
|
case 200 /* ImportType */:
|
|
133167
133190
|
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
|
|
133168
133191
|
case 187 /* UnionType */: {
|
|
133169
|
-
if (!ts.isTypeReferenceNode(
|
|
133192
|
+
if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
|
|
133170
133193
|
return undefined;
|
|
133171
133194
|
}
|
|
133172
|
-
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(
|
|
133173
|
-
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(
|
|
133195
|
+
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent);
|
|
133196
|
+
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
|
|
133174
133197
|
return { kind: 2 /* Types */, types: types, isNewIdentifier: false };
|
|
133175
133198
|
}
|
|
133176
133199
|
default:
|
|
@@ -159781,7 +159804,7 @@ var ts;
|
|
|
159781
159804
|
// If there is more than one overload but no implementation signature
|
|
159782
159805
|
// (eg: an abstract method or interface declaration), there is a 1-1
|
|
159783
159806
|
// correspondence of declarations and signatures.
|
|
159784
|
-
var signatures =
|
|
159807
|
+
var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
|
|
159785
159808
|
if (!ts.some(signatures)) {
|
|
159786
159809
|
break;
|
|
159787
159810
|
}
|
|
@@ -162474,7 +162497,7 @@ var ts;
|
|
|
162474
162497
|
var savedPermittedJumps = permittedJumps;
|
|
162475
162498
|
switch (node.kind) {
|
|
162476
162499
|
case 239 /* IfStatement */:
|
|
162477
|
-
permittedJumps
|
|
162500
|
+
permittedJumps &= ~4 /* Return */;
|
|
162478
162501
|
break;
|
|
162479
162502
|
case 252 /* TryStatement */:
|
|
162480
162503
|
// forbid all jumps inside try blocks
|
|
@@ -177188,6 +177211,8 @@ var ts;
|
|
|
177188
177211
|
function getDefinitionLocation(defaultProject, initialLocation, isForRename) {
|
|
177189
177212
|
var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
|
|
177190
177213
|
var info = infos && ts.firstOrUndefined(infos);
|
|
177214
|
+
// Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file
|
|
177215
|
+
// (implying that FAR cascading behavior may depend on request order)
|
|
177191
177216
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
177192
177217
|
}
|
|
177193
177218
|
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.20220720";
|
|
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 */) {
|
|
@@ -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;
|
|
@@ -133132,11 +133155,11 @@ var ts;
|
|
|
133132
133155
|
var parent = walkUpParentheses(node.parent);
|
|
133133
133156
|
switch (parent.kind) {
|
|
133134
133157
|
case 196 /* LiteralType */: {
|
|
133135
|
-
var
|
|
133136
|
-
switch (
|
|
133158
|
+
var grandParent_1 = walkUpParentheses(parent.parent);
|
|
133159
|
+
switch (grandParent_1.kind) {
|
|
133160
|
+
case 228 /* ExpressionWithTypeArguments */:
|
|
133137
133161
|
case 178 /* TypeReference */: {
|
|
133138
|
-
var
|
|
133139
|
-
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; });
|
|
133162
|
+
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; });
|
|
133140
133163
|
if (typeArgument) {
|
|
133141
133164
|
return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
|
|
133142
133165
|
}
|
|
@@ -133149,7 +133172,7 @@ var ts;
|
|
|
133149
133172
|
// bar: string;
|
|
133150
133173
|
// }
|
|
133151
133174
|
// let x: Foo["/*completion position*/"]
|
|
133152
|
-
var _a =
|
|
133175
|
+
var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType;
|
|
133153
133176
|
if (!ts.rangeContainsPosition(indexType, position)) {
|
|
133154
133177
|
return undefined;
|
|
133155
133178
|
}
|
|
@@ -133157,11 +133180,11 @@ var ts;
|
|
|
133157
133180
|
case 200 /* ImportType */:
|
|
133158
133181
|
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
|
|
133159
133182
|
case 187 /* UnionType */: {
|
|
133160
|
-
if (!ts.isTypeReferenceNode(
|
|
133183
|
+
if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
|
|
133161
133184
|
return undefined;
|
|
133162
133185
|
}
|
|
133163
|
-
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(
|
|
133164
|
-
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(
|
|
133186
|
+
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent);
|
|
133187
|
+
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
|
|
133165
133188
|
return { kind: 2 /* Types */, types: types, isNewIdentifier: false };
|
|
133166
133189
|
}
|
|
133167
133190
|
default:
|
|
@@ -159772,7 +159795,7 @@ var ts;
|
|
|
159772
159795
|
// If there is more than one overload but no implementation signature
|
|
159773
159796
|
// (eg: an abstract method or interface declaration), there is a 1-1
|
|
159774
159797
|
// correspondence of declarations and signatures.
|
|
159775
|
-
var signatures =
|
|
159798
|
+
var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
|
|
159776
159799
|
if (!ts.some(signatures)) {
|
|
159777
159800
|
break;
|
|
159778
159801
|
}
|
|
@@ -162465,7 +162488,7 @@ var ts;
|
|
|
162465
162488
|
var savedPermittedJumps = permittedJumps;
|
|
162466
162489
|
switch (node.kind) {
|
|
162467
162490
|
case 239 /* IfStatement */:
|
|
162468
|
-
permittedJumps
|
|
162491
|
+
permittedJumps &= ~4 /* Return */;
|
|
162469
162492
|
break;
|
|
162470
162493
|
case 252 /* TryStatement */:
|
|
162471
162494
|
// 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;
|