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.
@@ -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.20220718";
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) === 99 /* ESNext */ && useDefineForClassFields)) {
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, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
60182
- var node = _a[_i];
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
- contravariant = !contravariant;
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
- contravariant = !contravariant;
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
- var oldPriority = priority;
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
- contravariant = !contravariant;
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
- inferToMultipleTypes(source, targetTypes, target.flags);
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, inferFromContravariantTypes);
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 (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
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
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
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 grandParent = walkUpParentheses(parent.parent);
133136
- switch (grandParent.kind) {
133159
+ var grandParent_1 = walkUpParentheses(parent.parent);
133160
+ switch (grandParent_1.kind) {
133161
+ case 228 /* ExpressionWithTypeArguments */:
133137
133162
  case 178 /* TypeReference */: {
133138
- var typeReference_1 = grandParent;
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 = grandParent, indexType = _a.indexType, objectType = _a.objectType;
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(grandParent.parent)) {
133184
+ if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
133161
133185
  return undefined;
133162
133186
  }
133163
- var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent);
133164
- var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
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 = checker.getSignaturesOfType(type, 0 /* Call */);
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 = 0 /* None */;
162492
+ permittedJumps &= ~4 /* Return */;
162469
162493
  break;
162470
162494
  case 252 /* TryStatement */:
162471
162495
  // forbid all jumps inside try blocks
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220718";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220721";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -13197,6 +13197,12 @@ var ts;
13197
13197
  /**
13198
13198
  * Gets the effective type parameters. If the node was parsed in a
13199
13199
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
13200
+ *
13201
+ * This does *not* return type parameters from a jsdoc reference to a generic type, eg
13202
+ *
13203
+ * type Id = <T>(x: T) => T
13204
+ * /** @type {Id} /
13205
+ * function id(x) { return x }
13200
13206
  */
13201
13207
  function getEffectiveTypeParameterDeclarations(node) {
13202
13208
  if (ts.isJSDocSignature(node)) {
@@ -35457,6 +35463,9 @@ var ts;
35457
35463
  var typeArguments = tryParse(parseTypeArgumentsInExpression);
35458
35464
  if (typeArguments !== undefined) {
35459
35465
  parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
35466
+ if (!isTemplateStartOfTaggedTemplate()) {
35467
+ expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
35468
+ }
35460
35469
  }
35461
35470
  }
35462
35471
  if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) {
@@ -50408,7 +50417,7 @@ var ts;
50408
50417
  // 1. When result is undefined, after checking for a missing "this."
50409
50418
  // 2. When result is defined
50410
50419
  function checkAndReportErrorForInvalidInitializer() {
50411
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50420
+ if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
50412
50421
  // We have a match, but the reference occurred within a property initializer and the identifier also binds
50413
50422
  // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50414
50423
  // with ESNext+useDefineForClassFields because the scope semantics are different.
@@ -59174,6 +59183,9 @@ var ts;
59174
59183
  else if (type.objectFlags & 32 /* Mapped */) {
59175
59184
  resolveMappedTypeMembers(type);
59176
59185
  }
59186
+ else {
59187
+ ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags));
59188
+ }
59177
59189
  }
59178
59190
  else if (type.flags & 1048576 /* Union */) {
59179
59191
  resolveUnionTypeMembers(type);
@@ -59181,6 +59193,9 @@ var ts;
59181
59193
  else if (type.flags & 2097152 /* Intersection */) {
59182
59194
  resolveIntersectionTypeMembers(type);
59183
59195
  }
59196
+ else {
59197
+ ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags));
59198
+ }
59184
59199
  }
59185
59200
  return type;
59186
59201
  }
@@ -59972,12 +59987,15 @@ var ts;
59972
59987
  // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual
59973
59988
  // type checking functions).
59974
59989
  function getTypeParametersFromDeclaration(declaration) {
59990
+ var _a;
59975
59991
  var result;
59976
- for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
59977
- var node = _a[_i];
59992
+ for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) {
59993
+ var node = _b[_i];
59978
59994
  result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
59979
59995
  }
59980
- return result;
59996
+ return (result === null || result === void 0 ? void 0 : result.length) ? result
59997
+ : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters
59998
+ : undefined;
59981
59999
  }
59982
60000
  function symbolsToArray(symbols) {
59983
60001
  var result = [];
@@ -69198,15 +69216,11 @@ var ts;
69198
69216
  inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
69199
69217
  }
69200
69218
  else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
69201
- contravariant = !contravariant;
69202
- inferFromTypes(source.type, target.type);
69203
- contravariant = !contravariant;
69219
+ inferFromContravariantTypes(source.type, target.type);
69204
69220
  }
69205
69221
  else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
69206
69222
  var empty = createEmptyObjectTypeFromStringLiteral(source);
69207
- contravariant = !contravariant;
69208
- inferWithPriority(empty, target.type, 256 /* LiteralKeyof */);
69209
- contravariant = !contravariant;
69223
+ inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
69210
69224
  }
69211
69225
  else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
69212
69226
  inferFromTypes(source.objectType, target.objectType);
@@ -69219,10 +69233,7 @@ var ts;
69219
69233
  }
69220
69234
  else if (source.flags & 33554432 /* Substitution */) {
69221
69235
  inferFromTypes(source.baseType, target);
69222
- var oldPriority = priority;
69223
- priority |= 4 /* SubstituteSource */;
69224
- inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority
69225
- priority = oldPriority;
69236
+ inferWithPriority(source.substitute, target, 4 /* SubstituteSource */); // Make substitute inference at a lower priority
69226
69237
  }
69227
69238
  else if (target.flags & 16777216 /* Conditional */) {
69228
69239
  invokeOnce(source, target, inferToConditionalType);
@@ -69272,6 +69283,18 @@ var ts;
69272
69283
  inferFromTypes(source, target);
69273
69284
  priority = savePriority;
69274
69285
  }
69286
+ function inferFromContravariantTypesWithPriority(source, target, newPriority) {
69287
+ var savePriority = priority;
69288
+ priority |= newPriority;
69289
+ inferFromContravariantTypes(source, target);
69290
+ priority = savePriority;
69291
+ }
69292
+ function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) {
69293
+ var savePriority = priority;
69294
+ priority |= newPriority;
69295
+ inferToMultipleTypes(source, targets, targetFlags);
69296
+ priority = savePriority;
69297
+ }
69275
69298
  function invokeOnce(source, target, action) {
69276
69299
  var key = source.id + "," + target.id;
69277
69300
  var status = visited && visited.get(key);
@@ -69336,10 +69359,13 @@ var ts;
69336
69359
  }
69337
69360
  }
69338
69361
  function inferFromContravariantTypes(source, target) {
69362
+ contravariant = !contravariant;
69363
+ inferFromTypes(source, target);
69364
+ contravariant = !contravariant;
69365
+ }
69366
+ function inferFromContravariantTypesIfStrictFunctionTypes(source, target) {
69339
69367
  if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) {
69340
- contravariant = !contravariant;
69341
- inferFromTypes(source, target);
69342
- contravariant = !contravariant;
69368
+ inferFromContravariantTypes(source, target);
69343
69369
  }
69344
69370
  else {
69345
69371
  inferFromTypes(source, target);
@@ -69503,11 +69529,8 @@ var ts;
69503
69529
  inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
69504
69530
  }
69505
69531
  else {
69506
- var savePriority = priority;
69507
- priority |= contravariant ? 64 /* ContravariantConditional */ : 0;
69508
69532
  var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
69509
- inferToMultipleTypes(source, targetTypes, target.flags);
69510
- priority = savePriority;
69533
+ inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* ContravariantConditional */ : 0);
69511
69534
  }
69512
69535
  }
69513
69536
  function inferToTemplateLiteralType(source, target) {
@@ -69693,7 +69716,7 @@ var ts;
69693
69716
  var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
69694
69717
  // Once we descend into a bivariant signature we remain bivariant for all nested inferences
69695
69718
  bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
69696
- applyToParameterTypes(source, target, inferFromContravariantTypes);
69719
+ applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes);
69697
69720
  bivariant = saveBivariant;
69698
69721
  applyToReturnTypes(source, target, inferFromTypes);
69699
69722
  }
@@ -71146,7 +71169,7 @@ var ts;
71146
71169
  }
71147
71170
  // for (const _ in ref) acts as a nonnull on ref
71148
71171
  if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) {
71149
- return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
71172
+ return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))));
71150
71173
  }
71151
71174
  // Assignment doesn't affect reference
71152
71175
  return undefined;
@@ -76735,7 +76758,7 @@ var ts;
76735
76758
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
76736
76759
  var reportErrors = !candidatesOutArray;
76737
76760
  var typeArguments;
76738
- if (!isDecorator) {
76761
+ if (!isDecorator && !ts.isSuperCall(node)) {
76739
76762
  typeArguments = node.typeArguments;
76740
76763
  // We already perform checking on the type arguments on the class declaration itself.
76741
76764
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) {
@@ -79151,7 +79174,7 @@ var ts;
79151
79174
  error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
79152
79175
  }
79153
79176
  if (node.operator === 39 /* PlusToken */) {
79154
- if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
79177
+ if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
79155
79178
  error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
79156
79179
  }
79157
79180
  return numberType;
@@ -93469,7 +93492,8 @@ var ts;
93469
93492
  statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
93470
93493
  }
93471
93494
  // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
93472
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
93495
+ var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
93496
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
93473
93497
  // End the lexical environment.
93474
93498
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
93475
93499
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.8.0-dev.20220718",
5
+ "version": "4.8.0-dev.20220721",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [