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 CHANGED
@@ -13848,11 +13848,11 @@ declare var SubmitEvent: {
13848
13848
  * Available only in secure contexts.
13849
13849
  */
13850
13850
  interface SubtleCrypto {
13851
- decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
13851
+ decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
13852
13852
  deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
13853
13853
  deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
13854
13854
  digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
13855
- encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
13855
+ encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
13856
13856
  exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
13857
13857
  exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
13858
13858
  generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
@@ -3008,11 +3008,11 @@ declare var StorageManager: {
3008
3008
  * Available only in secure contexts.
3009
3009
  */
3010
3010
  interface SubtleCrypto {
3011
- decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
3011
+ decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
3012
3012
  deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
3013
3013
  deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
3014
3014
  digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
3015
- encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
3015
+ encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
3016
3016
  exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
3017
3017
  exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
3018
3018
  generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220718";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220721";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -28486,6 +28486,9 @@ var ts;
28486
28486
  var typeArguments = tryParse(parseTypeArgumentsInExpression);
28487
28487
  if (typeArguments !== undefined) {
28488
28488
  parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
28489
+ if (!isTemplateStartOfTaggedTemplate()) {
28490
+ expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
28491
+ }
28489
28492
  }
28490
28493
  }
28491
28494
  if (token() === 20 || token() === 24 || token() === 22) {
@@ -41382,7 +41385,7 @@ var ts;
41382
41385
  }
41383
41386
  }
41384
41387
  function checkAndReportErrorForInvalidInitializer() {
41385
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) {
41388
+ if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9)) {
41386
41389
  error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
41387
41390
  ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
41388
41391
  : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
@@ -49034,6 +49037,9 @@ var ts;
49034
49037
  else if (type.objectFlags & 32) {
49035
49038
  resolveMappedTypeMembers(type);
49036
49039
  }
49040
+ else {
49041
+ ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags));
49042
+ }
49037
49043
  }
49038
49044
  else if (type.flags & 1048576) {
49039
49045
  resolveUnionTypeMembers(type);
@@ -49041,6 +49047,9 @@ var ts;
49041
49047
  else if (type.flags & 2097152) {
49042
49048
  resolveIntersectionTypeMembers(type);
49043
49049
  }
49050
+ else {
49051
+ ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags));
49052
+ }
49044
49053
  }
49045
49054
  return type;
49046
49055
  }
@@ -49710,12 +49719,15 @@ var ts;
49710
49719
  return getApplicableIndexInfo(type, isLateBoundName(name) ? esSymbolType : getStringLiteralType(ts.unescapeLeadingUnderscores(name)));
49711
49720
  }
49712
49721
  function getTypeParametersFromDeclaration(declaration) {
49722
+ var _a;
49713
49723
  var result;
49714
- for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
49715
- var node = _a[_i];
49724
+ for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) {
49725
+ var node = _b[_i];
49716
49726
  result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
49717
49727
  }
49718
- return result;
49728
+ return (result === null || result === void 0 ? void 0 : result.length) ? result
49729
+ : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters
49730
+ : undefined;
49719
49731
  }
49720
49732
  function symbolsToArray(symbols) {
49721
49733
  var result = [];
@@ -57761,15 +57773,11 @@ var ts;
57761
57773
  inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
57762
57774
  }
57763
57775
  else if (source.flags & 4194304 && target.flags & 4194304) {
57764
- contravariant = !contravariant;
57765
- inferFromTypes(source.type, target.type);
57766
- contravariant = !contravariant;
57776
+ inferFromContravariantTypes(source.type, target.type);
57767
57777
  }
57768
57778
  else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
57769
57779
  var empty = createEmptyObjectTypeFromStringLiteral(source);
57770
- contravariant = !contravariant;
57771
- inferWithPriority(empty, target.type, 256);
57772
- contravariant = !contravariant;
57780
+ inferFromContravariantTypesWithPriority(empty, target.type, 256);
57773
57781
  }
57774
57782
  else if (source.flags & 8388608 && target.flags & 8388608) {
57775
57783
  inferFromTypes(source.objectType, target.objectType);
@@ -57782,10 +57790,7 @@ var ts;
57782
57790
  }
57783
57791
  else if (source.flags & 33554432) {
57784
57792
  inferFromTypes(source.baseType, target);
57785
- var oldPriority = priority;
57786
- priority |= 4;
57787
- inferFromTypes(source.substitute, target);
57788
- priority = oldPriority;
57793
+ inferWithPriority(source.substitute, target, 4);
57789
57794
  }
57790
57795
  else if (target.flags & 16777216) {
57791
57796
  invokeOnce(source, target, inferToConditionalType);
@@ -57824,6 +57829,18 @@ var ts;
57824
57829
  inferFromTypes(source, target);
57825
57830
  priority = savePriority;
57826
57831
  }
57832
+ function inferFromContravariantTypesWithPriority(source, target, newPriority) {
57833
+ var savePriority = priority;
57834
+ priority |= newPriority;
57835
+ inferFromContravariantTypes(source, target);
57836
+ priority = savePriority;
57837
+ }
57838
+ function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) {
57839
+ var savePriority = priority;
57840
+ priority |= newPriority;
57841
+ inferToMultipleTypes(source, targets, targetFlags);
57842
+ priority = savePriority;
57843
+ }
57827
57844
  function invokeOnce(source, target, action) {
57828
57845
  var key = source.id + "," + target.id;
57829
57846
  var status = visited && visited.get(key);
@@ -57886,10 +57903,13 @@ var ts;
57886
57903
  }
57887
57904
  }
57888
57905
  function inferFromContravariantTypes(source, target) {
57906
+ contravariant = !contravariant;
57907
+ inferFromTypes(source, target);
57908
+ contravariant = !contravariant;
57909
+ }
57910
+ function inferFromContravariantTypesIfStrictFunctionTypes(source, target) {
57889
57911
  if (strictFunctionTypes || priority & 1024) {
57890
- contravariant = !contravariant;
57891
- inferFromTypes(source, target);
57892
- contravariant = !contravariant;
57912
+ inferFromContravariantTypes(source, target);
57893
57913
  }
57894
57914
  else {
57895
57915
  inferFromTypes(source, target);
@@ -58020,11 +58040,8 @@ var ts;
58020
58040
  inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
58021
58041
  }
58022
58042
  else {
58023
- var savePriority = priority;
58024
- priority |= contravariant ? 64 : 0;
58025
58043
  var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
58026
- inferToMultipleTypes(source, targetTypes, target.flags);
58027
- priority = savePriority;
58044
+ inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 : 0);
58028
58045
  }
58029
58046
  }
58030
58047
  function inferToTemplateLiteralType(source, target) {
@@ -58183,7 +58200,7 @@ var ts;
58183
58200
  var saveBivariant = bivariant;
58184
58201
  var kind = target.declaration ? target.declaration.kind : 0;
58185
58202
  bivariant = bivariant || kind === 169 || kind === 168 || kind === 171;
58186
- applyToParameterTypes(source, target, inferFromContravariantTypes);
58203
+ applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes);
58187
58204
  bivariant = saveBivariant;
58188
58205
  applyToReturnTypes(source, target, inferFromTypes);
58189
58206
  }
@@ -59510,7 +59527,7 @@ var ts;
59510
59527
  return declaredType;
59511
59528
  }
59512
59529
  if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 && isMatchingReference(reference, node.parent.parent.expression)) {
59513
- return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
59530
+ return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))));
59514
59531
  }
59515
59532
  return undefined;
59516
59533
  }
@@ -64226,7 +64243,7 @@ var ts;
64226
64243
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
64227
64244
  var reportErrors = !candidatesOutArray;
64228
64245
  var typeArguments;
64229
- if (!isDecorator) {
64246
+ if (!isDecorator && !ts.isSuperCall(node)) {
64230
64247
  typeArguments = node.typeArguments;
64231
64248
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106) {
64232
64249
  ts.forEach(typeArguments, checkSourceElement);
@@ -66334,7 +66351,7 @@ var ts;
66334
66351
  error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
66335
66352
  }
66336
66353
  if (node.operator === 39) {
66337
- if (maybeTypeOfKind(operandType, 2112)) {
66354
+ if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112)) {
66338
66355
  error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
66339
66356
  }
66340
66357
  return numberType;
@@ -78627,7 +78644,8 @@ var ts;
78627
78644
  else {
78628
78645
  statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
78629
78646
  }
78630
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
78647
+ var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
78648
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
78631
78649
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
78632
78650
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true);
78633
78651
  ts.setTextRange(block, body);
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220718";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220721";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -13217,6 +13217,12 @@ var ts;
13217
13217
  /**
13218
13218
  * Gets the effective type parameters. If the node was parsed in a
13219
13219
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
13220
+ *
13221
+ * This does *not* return type parameters from a jsdoc reference to a generic type, eg
13222
+ *
13223
+ * type Id = <T>(x: T) => T
13224
+ * /** @type {Id} /
13225
+ * function id(x) { return x }
13220
13226
  */
13221
13227
  function getEffectiveTypeParameterDeclarations(node) {
13222
13228
  if (ts.isJSDocSignature(node)) {
@@ -35477,6 +35483,9 @@ var ts;
35477
35483
  var typeArguments = tryParse(parseTypeArgumentsInExpression);
35478
35484
  if (typeArguments !== undefined) {
35479
35485
  parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
35486
+ if (!isTemplateStartOfTaggedTemplate()) {
35487
+ expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
35488
+ }
35480
35489
  }
35481
35490
  }
35482
35491
  if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) {
@@ -50428,7 +50437,7 @@ var ts;
50428
50437
  // 1. When result is undefined, after checking for a missing "this."
50429
50438
  // 2. When result is defined
50430
50439
  function checkAndReportErrorForInvalidInitializer() {
50431
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50440
+ if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
50432
50441
  // We have a match, but the reference occurred within a property initializer and the identifier also binds
50433
50442
  // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50434
50443
  // with ESNext+useDefineForClassFields because the scope semantics are different.
@@ -59194,6 +59203,9 @@ var ts;
59194
59203
  else if (type.objectFlags & 32 /* Mapped */) {
59195
59204
  resolveMappedTypeMembers(type);
59196
59205
  }
59206
+ else {
59207
+ ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags));
59208
+ }
59197
59209
  }
59198
59210
  else if (type.flags & 1048576 /* Union */) {
59199
59211
  resolveUnionTypeMembers(type);
@@ -59201,6 +59213,9 @@ var ts;
59201
59213
  else if (type.flags & 2097152 /* Intersection */) {
59202
59214
  resolveIntersectionTypeMembers(type);
59203
59215
  }
59216
+ else {
59217
+ ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags));
59218
+ }
59204
59219
  }
59205
59220
  return type;
59206
59221
  }
@@ -59992,12 +60007,15 @@ var ts;
59992
60007
  // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual
59993
60008
  // type checking functions).
59994
60009
  function getTypeParametersFromDeclaration(declaration) {
60010
+ var _a;
59995
60011
  var result;
59996
- for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
59997
- var node = _a[_i];
60012
+ for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) {
60013
+ var node = _b[_i];
59998
60014
  result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
59999
60015
  }
60000
- return result;
60016
+ return (result === null || result === void 0 ? void 0 : result.length) ? result
60017
+ : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters
60018
+ : undefined;
60001
60019
  }
60002
60020
  function symbolsToArray(symbols) {
60003
60021
  var result = [];
@@ -69218,15 +69236,11 @@ var ts;
69218
69236
  inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
69219
69237
  }
69220
69238
  else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
69221
- contravariant = !contravariant;
69222
- inferFromTypes(source.type, target.type);
69223
- contravariant = !contravariant;
69239
+ inferFromContravariantTypes(source.type, target.type);
69224
69240
  }
69225
69241
  else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
69226
69242
  var empty = createEmptyObjectTypeFromStringLiteral(source);
69227
- contravariant = !contravariant;
69228
- inferWithPriority(empty, target.type, 256 /* LiteralKeyof */);
69229
- contravariant = !contravariant;
69243
+ inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
69230
69244
  }
69231
69245
  else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
69232
69246
  inferFromTypes(source.objectType, target.objectType);
@@ -69239,10 +69253,7 @@ var ts;
69239
69253
  }
69240
69254
  else if (source.flags & 33554432 /* Substitution */) {
69241
69255
  inferFromTypes(source.baseType, target);
69242
- var oldPriority = priority;
69243
- priority |= 4 /* SubstituteSource */;
69244
- inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority
69245
- priority = oldPriority;
69256
+ inferWithPriority(source.substitute, target, 4 /* SubstituteSource */); // Make substitute inference at a lower priority
69246
69257
  }
69247
69258
  else if (target.flags & 16777216 /* Conditional */) {
69248
69259
  invokeOnce(source, target, inferToConditionalType);
@@ -69292,6 +69303,18 @@ var ts;
69292
69303
  inferFromTypes(source, target);
69293
69304
  priority = savePriority;
69294
69305
  }
69306
+ function inferFromContravariantTypesWithPriority(source, target, newPriority) {
69307
+ var savePriority = priority;
69308
+ priority |= newPriority;
69309
+ inferFromContravariantTypes(source, target);
69310
+ priority = savePriority;
69311
+ }
69312
+ function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) {
69313
+ var savePriority = priority;
69314
+ priority |= newPriority;
69315
+ inferToMultipleTypes(source, targets, targetFlags);
69316
+ priority = savePriority;
69317
+ }
69295
69318
  function invokeOnce(source, target, action) {
69296
69319
  var key = source.id + "," + target.id;
69297
69320
  var status = visited && visited.get(key);
@@ -69356,10 +69379,13 @@ var ts;
69356
69379
  }
69357
69380
  }
69358
69381
  function inferFromContravariantTypes(source, target) {
69382
+ contravariant = !contravariant;
69383
+ inferFromTypes(source, target);
69384
+ contravariant = !contravariant;
69385
+ }
69386
+ function inferFromContravariantTypesIfStrictFunctionTypes(source, target) {
69359
69387
  if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) {
69360
- contravariant = !contravariant;
69361
- inferFromTypes(source, target);
69362
- contravariant = !contravariant;
69388
+ inferFromContravariantTypes(source, target);
69363
69389
  }
69364
69390
  else {
69365
69391
  inferFromTypes(source, target);
@@ -69523,11 +69549,8 @@ var ts;
69523
69549
  inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
69524
69550
  }
69525
69551
  else {
69526
- var savePriority = priority;
69527
- priority |= contravariant ? 64 /* ContravariantConditional */ : 0;
69528
69552
  var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
69529
- inferToMultipleTypes(source, targetTypes, target.flags);
69530
- priority = savePriority;
69553
+ inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* ContravariantConditional */ : 0);
69531
69554
  }
69532
69555
  }
69533
69556
  function inferToTemplateLiteralType(source, target) {
@@ -69713,7 +69736,7 @@ var ts;
69713
69736
  var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
69714
69737
  // Once we descend into a bivariant signature we remain bivariant for all nested inferences
69715
69738
  bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
69716
- applyToParameterTypes(source, target, inferFromContravariantTypes);
69739
+ applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes);
69717
69740
  bivariant = saveBivariant;
69718
69741
  applyToReturnTypes(source, target, inferFromTypes);
69719
69742
  }
@@ -71166,7 +71189,7 @@ var ts;
71166
71189
  }
71167
71190
  // for (const _ in ref) acts as a nonnull on ref
71168
71191
  if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) {
71169
- return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
71192
+ return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))));
71170
71193
  }
71171
71194
  // Assignment doesn't affect reference
71172
71195
  return undefined;
@@ -76755,7 +76778,7 @@ var ts;
76755
76778
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
76756
76779
  var reportErrors = !candidatesOutArray;
76757
76780
  var typeArguments;
76758
- if (!isDecorator) {
76781
+ if (!isDecorator && !ts.isSuperCall(node)) {
76759
76782
  typeArguments = node.typeArguments;
76760
76783
  // We already perform checking on the type arguments on the class declaration itself.
76761
76784
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) {
@@ -79171,7 +79194,7 @@ var ts;
79171
79194
  error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
79172
79195
  }
79173
79196
  if (node.operator === 39 /* PlusToken */) {
79174
- if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
79197
+ if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
79175
79198
  error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
79176
79199
  }
79177
79200
  return numberType;
@@ -93489,7 +93512,8 @@ var ts;
93489
93512
  statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
93490
93513
  }
93491
93514
  // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
93492
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
93515
+ var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
93516
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
93493
93517
  // End the lexical environment.
93494
93518
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
93495
93519
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -132528,11 +132552,11 @@ var ts;
132528
132552
  var parent = walkUpParentheses(node.parent);
132529
132553
  switch (parent.kind) {
132530
132554
  case 196 /* LiteralType */: {
132531
- var grandParent = walkUpParentheses(parent.parent);
132532
- switch (grandParent.kind) {
132555
+ var grandParent_1 = walkUpParentheses(parent.parent);
132556
+ switch (grandParent_1.kind) {
132557
+ case 228 /* ExpressionWithTypeArguments */:
132533
132558
  case 178 /* TypeReference */: {
132534
- var typeReference_1 = grandParent;
132535
- var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; });
132559
+ var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; });
132536
132560
  if (typeArgument) {
132537
132561
  return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
132538
132562
  }
@@ -132545,7 +132569,7 @@ var ts;
132545
132569
  // bar: string;
132546
132570
  // }
132547
132571
  // let x: Foo["/*completion position*/"]
132548
- var _a = grandParent, indexType = _a.indexType, objectType = _a.objectType;
132572
+ var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType;
132549
132573
  if (!ts.rangeContainsPosition(indexType, position)) {
132550
132574
  return undefined;
132551
132575
  }
@@ -132553,11 +132577,11 @@ var ts;
132553
132577
  case 200 /* ImportType */:
132554
132578
  return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
132555
132579
  case 187 /* UnionType */: {
132556
- if (!ts.isTypeReferenceNode(grandParent.parent)) {
132580
+ if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
132557
132581
  return undefined;
132558
132582
  }
132559
- var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent);
132560
- var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
132583
+ var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent);
132584
+ var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
132561
132585
  return { kind: 2 /* Types */, types: types, isNewIdentifier: false };
132562
132586
  }
132563
132587
  default:
@@ -159168,7 +159192,7 @@ var ts;
159168
159192
  // If there is more than one overload but no implementation signature
159169
159193
  // (eg: an abstract method or interface declaration), there is a 1-1
159170
159194
  // correspondence of declarations and signatures.
159171
- var signatures = checker.getSignaturesOfType(type, 0 /* Call */);
159195
+ var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
159172
159196
  if (!ts.some(signatures)) {
159173
159197
  break;
159174
159198
  }
@@ -161861,7 +161885,7 @@ var ts;
161861
161885
  var savedPermittedJumps = permittedJumps;
161862
161886
  switch (node.kind) {
161863
161887
  case 239 /* IfStatement */:
161864
- permittedJumps = 0 /* None */;
161888
+ permittedJumps &= ~4 /* Return */;
161865
161889
  break;
161866
161890
  case 252 /* TryStatement */:
161867
161891
  // forbid all jumps inside try blocks
@@ -176994,6 +177018,8 @@ var ts;
176994
177018
  function getDefinitionLocation(defaultProject, initialLocation, isForRename) {
176995
177019
  var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
176996
177020
  var info = infos && ts.firstOrUndefined(infos);
177021
+ // Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file
177022
+ // (implying that FAR cascading behavior may depend on request order)
176997
177023
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
176998
177024
  }
176999
177025
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
@@ -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;