@typescript-deploys/pr-build 5.5.0-pr-57421-17 → 5.5.0-pr-57403-34

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 CHANGED
@@ -15,35 +15,6 @@ and limitations under the License.
15
15
 
16
16
 
17
17
  "use strict";
18
- var __defProp = Object.defineProperty;
19
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20
- var __decorateClass = (decorators, target, key, kind) => {
21
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
22
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
23
- if (decorator = decorators[i])
24
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
25
- if (kind && result)
26
- __defProp(target, key, result);
27
- return result;
28
- };
29
- var __accessCheck = (obj, member, msg) => {
30
- if (!member.has(obj))
31
- throw TypeError("Cannot " + msg);
32
- };
33
- var __privateGet = (obj, member, getter) => {
34
- __accessCheck(obj, member, "read from private field");
35
- return getter ? getter.call(obj) : member.get(obj);
36
- };
37
- var __privateAdd = (obj, member, value) => {
38
- if (member.has(obj))
39
- throw TypeError("Cannot add the same private member more than once");
40
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
41
- };
42
- var __privateSet = (obj, member, value, setter) => {
43
- __accessCheck(obj, member, "write to private field");
44
- setter ? setter.call(obj, value) : member.set(obj, value);
45
- return value;
46
- };
47
18
 
48
19
  // src/compiler/corePublic.ts
49
20
  var versionMajorMinor = "5.5";
@@ -3721,6 +3692,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
3721
3692
  ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
3722
3693
  ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
3723
3694
  ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
3695
+ ObjectFlags3[ObjectFlags3["SingleSignatureType"] = 134217728] = "SingleSignatureType";
3724
3696
  ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
3725
3697
  ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
3726
3698
  ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
@@ -4863,7 +4835,7 @@ var sys = (() => {
4863
4835
  }
4864
4836
  let activeSession;
4865
4837
  let profilePath = "./profile.cpuprofile";
4866
- const Buffer2 = require("buffer").Buffer;
4838
+ const Buffer = require("buffer").Buffer;
4867
4839
  const isMacOs = process.platform === "darwin";
4868
4840
  const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
4869
4841
  const platform = _os.platform();
@@ -5073,7 +5045,7 @@ var sys = (() => {
5073
5045
  }
5074
5046
  }
5075
5047
  function bufferFrom(input, encoding) {
5076
- return Buffer2.from && Buffer2.from !== Int8Array.from ? Buffer2.from(input, encoding) : new Buffer2(input, encoding);
5048
+ return Buffer.from && Buffer.from !== Int8Array.from ? Buffer.from(input, encoding) : new Buffer(input, encoding);
5077
5049
  }
5078
5050
  function isFileSystemCaseSensitive() {
5079
5051
  if (platform === "win32" || platform === "win64") {
@@ -14651,34 +14623,15 @@ function getSemanticJsxChildren(children) {
14651
14623
  }
14652
14624
  function createDiagnosticCollection() {
14653
14625
  let nonFileDiagnostics = [];
14654
- let filesWithDiagnostics = [];
14655
- let fileDiagnostics = /* @__PURE__ */ new Map();
14626
+ const filesWithDiagnostics = [];
14627
+ const fileDiagnostics = /* @__PURE__ */ new Map();
14656
14628
  let hasReadNonFileDiagnostics = false;
14657
14629
  return {
14658
14630
  add,
14659
14631
  lookup,
14660
14632
  getGlobalDiagnostics,
14661
- getDiagnostics,
14662
- checkpoint,
14663
- revert
14633
+ getDiagnostics
14664
14634
  };
14665
- function checkpoint() {
14666
- const c = {
14667
- nonFileDiagnostics: nonFileDiagnostics.slice(),
14668
- filesWithDiagnostics: filesWithDiagnostics.slice(),
14669
- fileDiagnostics: new Map(map(arrayFrom(fileDiagnostics.entries()), ([k, v]) => [k, v.slice()])),
14670
- hasReadNonFileDiagnostics
14671
- };
14672
- return c;
14673
- }
14674
- function revert(checkpoint2) {
14675
- ({
14676
- nonFileDiagnostics,
14677
- filesWithDiagnostics,
14678
- fileDiagnostics,
14679
- hasReadNonFileDiagnostics
14680
- } = checkpoint2);
14681
- }
14682
14635
  function lookup(diagnostic) {
14683
14636
  let diagnostics;
14684
14637
  if (diagnostic.file) {
@@ -16284,17 +16237,6 @@ function createCompilerDiagnosticFromMessageChain(chain, relatedInformation) {
16284
16237
  relatedInformation
16285
16238
  };
16286
16239
  }
16287
- function prefixDiagnosticWithMessageChain(base, chain) {
16288
- if (!chain)
16289
- return base;
16290
- concatenateDiagnosticMessageChains(chain, createDiagnosticMessageChainFromDiagnostic(base));
16291
- return {
16292
- ...base,
16293
- code: chain.code,
16294
- category: chain.category,
16295
- messageText: chain.next ? chain : chain.messageText
16296
- };
16297
- }
16298
16240
  function chainDiagnosticMessages(details, message, ...args) {
16299
16241
  let text = getLocaleSpecificMessage(message);
16300
16242
  if (some(args)) {
@@ -43252,226 +43194,11 @@ var intrinsicTypeKinds = new Map(Object.entries({
43252
43194
  Uncapitalize: 3 /* Uncapitalize */,
43253
43195
  NoInfer: 4 /* NoInfer */
43254
43196
  }));
43255
- var SpeculatableCache = (valueOrTarget, _contextOrPropertyKey, descriptor) => {
43256
- const baseGet = descriptor ? descriptor.get : valueOrTarget.get;
43257
- const baseSet = descriptor ? descriptor.set : valueOrTarget.set;
43258
- return {
43259
- ...descriptor,
43260
- get: readValue,
43261
- set: setValue,
43262
- init(v) {
43263
- const epoch = this.host.getCurrentSpeculativeEpoch();
43264
- const values = [];
43265
- const writtenEpochs = [epoch];
43266
- values[epoch] = v;
43267
- return {
43268
- values,
43269
- writtenEpochs
43270
- };
43271
- }
43272
- };
43273
- function readValue() {
43274
- const internals = baseGet.call(this);
43275
- if (!internals)
43276
- return void 0;
43277
- const {
43278
- values,
43279
- writtenEpochs
43280
- } = internals;
43281
- const discardedSpeculativeEpochs = this.host.getDiscardedSpeculativeEpochs();
43282
- const hostEpoch = this instanceof SymbolLinks ? this.symbolEpoch : 0;
43283
- const symbolDiscarded = discardedSpeculativeEpochs.has(hostEpoch);
43284
- for (let i = writtenEpochs.length - 1; i >= 0; i--) {
43285
- if (!symbolDiscarded && discardedSpeculativeEpochs.has(writtenEpochs[i])) {
43286
- delete values[writtenEpochs[i]];
43287
- writtenEpochs.splice(i, 1);
43288
- continue;
43289
- }
43290
- return values[writtenEpochs[i]];
43291
- }
43292
- return void 0;
43293
- }
43294
- function setValue(value) {
43295
- const internals = baseGet.call(this);
43296
- const currentSpeculativeEpoch = this.host.getCurrentSpeculativeEpoch();
43297
- if (!internals) {
43298
- const values2 = [];
43299
- const writtenEpochs2 = [];
43300
- writtenEpochs2.push(currentSpeculativeEpoch);
43301
- values2[currentSpeculativeEpoch] = value;
43302
- baseSet.call(this, { values: values2, writtenEpochs: writtenEpochs2 });
43303
- return value;
43304
- }
43305
- const {
43306
- values,
43307
- writtenEpochs
43308
- } = internals;
43309
- writtenEpochs.push(currentSpeculativeEpoch);
43310
- values[currentSpeculativeEpoch] = value;
43311
- return value;
43312
- }
43197
+ var SymbolLinks = class {
43313
43198
  };
43314
- var SpeculatableLinks = class {
43315
- constructor(host) {
43316
- this.host = host;
43317
- }
43318
- };
43319
- var _type, _writeType, _nameType;
43320
- var SymbolLinks = class extends SpeculatableLinks {
43321
- constructor(host, symbolEpoch = 0) {
43322
- super(host);
43323
- this.symbolEpoch = symbolEpoch;
43324
- __privateAdd(this, _type, void 0);
43325
- __privateAdd(this, _writeType, void 0);
43326
- __privateAdd(this, _nameType, void 0);
43327
- }
43328
- get type() {
43329
- return __privateGet(this, _type);
43330
- }
43331
- set type(_) {
43332
- __privateSet(this, _type, _);
43333
- }
43334
- get writeType() {
43335
- return __privateGet(this, _writeType);
43336
- }
43337
- set writeType(_) {
43338
- __privateSet(this, _writeType, _);
43339
- }
43340
- get nameType() {
43341
- return __privateGet(this, _nameType);
43342
- }
43343
- set nameType(_) {
43344
- __privateSet(this, _nameType, _);
43345
- }
43346
- };
43347
- _type = new WeakMap();
43348
- _writeType = new WeakMap();
43349
- _nameType = new WeakMap();
43350
- __decorateClass([
43351
- SpeculatableCache
43352
- ], SymbolLinks.prototype, "type", 1);
43353
- __decorateClass([
43354
- SpeculatableCache
43355
- ], SymbolLinks.prototype, "writeType", 1);
43356
- __decorateClass([
43357
- SpeculatableCache
43358
- ], SymbolLinks.prototype, "nameType", 1);
43359
- var _flags, _resolvedType, _resolvedEnumType, _resolvedSignature, _resolvedSymbol, _resolvedIndexInfo, _effectsSignature, _switchTypes, _contextFreeType, _assertionExpressionType;
43360
- var NodeLinks = class extends SpeculatableLinks {
43361
- constructor() {
43362
- super(...arguments);
43363
- __privateAdd(this, _flags, 0 /* None */);
43364
- __privateAdd(this, _resolvedType, void 0);
43365
- __privateAdd(this, _resolvedEnumType, void 0);
43366
- __privateAdd(this, _resolvedSignature, void 0);
43367
- __privateAdd(this, _resolvedSymbol, void 0);
43368
- __privateAdd(this, _resolvedIndexInfo, void 0);
43369
- __privateAdd(this, _effectsSignature, void 0);
43370
- __privateAdd(this, _switchTypes, void 0);
43371
- __privateAdd(this, _contextFreeType, void 0);
43372
- __privateAdd(this, _assertionExpressionType, void 0);
43373
- }
43374
- get flags() {
43375
- return __privateGet(this, _flags);
43376
- }
43377
- set flags(_) {
43378
- __privateSet(this, _flags, _);
43379
- }
43380
- get resolvedType() {
43381
- return __privateGet(this, _resolvedType);
43382
- }
43383
- set resolvedType(_) {
43384
- __privateSet(this, _resolvedType, _);
43385
- }
43386
- get resolvedEnumType() {
43387
- return __privateGet(this, _resolvedEnumType);
43388
- }
43389
- set resolvedEnumType(_) {
43390
- __privateSet(this, _resolvedEnumType, _);
43391
- }
43392
- get resolvedSignature() {
43393
- return __privateGet(this, _resolvedSignature);
43394
- }
43395
- set resolvedSignature(_) {
43396
- __privateSet(this, _resolvedSignature, _);
43397
- }
43398
- get resolvedSymbol() {
43399
- return __privateGet(this, _resolvedSymbol);
43400
- }
43401
- set resolvedSymbol(_) {
43402
- __privateSet(this, _resolvedSymbol, _);
43403
- }
43404
- get resolvedIndexInfo() {
43405
- return __privateGet(this, _resolvedIndexInfo);
43406
- }
43407
- set resolvedIndexInfo(_) {
43408
- __privateSet(this, _resolvedIndexInfo, _);
43409
- }
43410
- get effectsSignature() {
43411
- return __privateGet(this, _effectsSignature);
43412
- }
43413
- set effectsSignature(_) {
43414
- __privateSet(this, _effectsSignature, _);
43415
- }
43416
- get switchTypes() {
43417
- return __privateGet(this, _switchTypes);
43418
- }
43419
- set switchTypes(_) {
43420
- __privateSet(this, _switchTypes, _);
43421
- }
43422
- get contextFreeType() {
43423
- return __privateGet(this, _contextFreeType);
43424
- }
43425
- set contextFreeType(_) {
43426
- __privateSet(this, _contextFreeType, _);
43427
- }
43428
- get assertionExpressionType() {
43429
- return __privateGet(this, _assertionExpressionType);
43430
- }
43431
- set assertionExpressionType(_) {
43432
- __privateSet(this, _assertionExpressionType, _);
43433
- }
43434
- };
43435
- _flags = new WeakMap();
43436
- _resolvedType = new WeakMap();
43437
- _resolvedEnumType = new WeakMap();
43438
- _resolvedSignature = new WeakMap();
43439
- _resolvedSymbol = new WeakMap();
43440
- _resolvedIndexInfo = new WeakMap();
43441
- _effectsSignature = new WeakMap();
43442
- _switchTypes = new WeakMap();
43443
- _contextFreeType = new WeakMap();
43444
- _assertionExpressionType = new WeakMap();
43445
- __decorateClass([
43446
- SpeculatableCache
43447
- ], NodeLinks.prototype, "flags", 1);
43448
- __decorateClass([
43449
- SpeculatableCache
43450
- ], NodeLinks.prototype, "resolvedType", 1);
43451
- __decorateClass([
43452
- SpeculatableCache
43453
- ], NodeLinks.prototype, "resolvedEnumType", 1);
43454
- __decorateClass([
43455
- SpeculatableCache
43456
- ], NodeLinks.prototype, "resolvedSignature", 1);
43457
- __decorateClass([
43458
- SpeculatableCache
43459
- ], NodeLinks.prototype, "resolvedSymbol", 1);
43460
- __decorateClass([
43461
- SpeculatableCache
43462
- ], NodeLinks.prototype, "resolvedIndexInfo", 1);
43463
- __decorateClass([
43464
- SpeculatableCache
43465
- ], NodeLinks.prototype, "effectsSignature", 1);
43466
- __decorateClass([
43467
- SpeculatableCache
43468
- ], NodeLinks.prototype, "switchTypes", 1);
43469
- __decorateClass([
43470
- SpeculatableCache
43471
- ], NodeLinks.prototype, "contextFreeType", 1);
43472
- __decorateClass([
43473
- SpeculatableCache
43474
- ], NodeLinks.prototype, "assertionExpressionType", 1);
43199
+ function NodeLinks() {
43200
+ this.flags = 0 /* None */;
43201
+ }
43475
43202
  function getNodeId(node) {
43476
43203
  if (!node.id) {
43477
43204
  node.id = nextNodeId;
@@ -43491,18 +43218,7 @@ function isInstantiatedModule(node, preserveConstEnums) {
43491
43218
  return moduleState === 1 /* Instantiated */ || preserveConstEnums && moduleState === 2 /* ConstEnumOnly */;
43492
43219
  }
43493
43220
  function createTypeChecker(host) {
43494
- var speculativeCaches = [];
43495
- var currentSpeculativeEpoch = 0;
43496
- var discardedSpeculativeEpochs = /* @__PURE__ */ new Set();
43497
- var speculationHost = {
43498
- getCurrentSpeculativeEpoch() {
43499
- return currentSpeculativeEpoch;
43500
- },
43501
- getDiscardedSpeculativeEpochs() {
43502
- return discardedSpeculativeEpochs;
43503
- }
43504
- };
43505
- var deferredDiagnosticsCallbacks = registerSpeculativeCache([]);
43221
+ var deferredDiagnosticsCallbacks = [];
43506
43222
  var addLazyDiagnostic = (arg) => {
43507
43223
  deferredDiagnosticsCallbacks.push(arg);
43508
43224
  };
@@ -44438,12 +44154,12 @@ function createTypeChecker(host) {
44438
44154
  var mergedSymbols = [];
44439
44155
  var symbolLinks = [];
44440
44156
  var nodeLinks = [];
44441
- var flowLoopCaches = registerSpeculativeCache([]);
44442
- var flowLoopNodes = registerSpeculativeCache([]);
44443
- var flowLoopKeys = registerSpeculativeCache([]);
44444
- var flowLoopTypes = registerSpeculativeCache([]);
44445
- var sharedFlowNodes = registerSpeculativeCache([]);
44446
- var sharedFlowTypes = registerSpeculativeCache([]);
44157
+ var flowLoopCaches = [];
44158
+ var flowLoopNodes = [];
44159
+ var flowLoopKeys = [];
44160
+ var flowLoopTypes = [];
44161
+ var sharedFlowNodes = [];
44162
+ var sharedFlowTypes = [];
44447
44163
  var flowNodeReachable = [];
44448
44164
  var flowNodePostSuper = [];
44449
44165
  var potentialThisCollisions = [];
@@ -44452,17 +44168,17 @@ function createTypeChecker(host) {
44452
44168
  var potentialReflectCollisions = [];
44453
44169
  var potentialUnusedRenamedBindingElementsInTypes = [];
44454
44170
  var awaitedTypeStack = [];
44455
- var diagnostics = registerSpeculativeCache(createDiagnosticCollection());
44456
- var suggestionDiagnostics = registerSpeculativeCache(createDiagnosticCollection());
44171
+ var diagnostics = createDiagnosticCollection();
44172
+ var suggestionDiagnostics = createDiagnosticCollection();
44457
44173
  var typeofType = createTypeofType();
44458
44174
  var _jsxNamespace;
44459
44175
  var _jsxFactoryEntity;
44460
- var subtypeRelation = registerSpeculativeCache(/* @__PURE__ */ new Map());
44461
- var strictSubtypeRelation = registerSpeculativeCache(/* @__PURE__ */ new Map());
44462
- var assignableRelation = registerSpeculativeCache(/* @__PURE__ */ new Map());
44463
- var comparableRelation = registerSpeculativeCache(/* @__PURE__ */ new Map());
44464
- var identityRelation = registerSpeculativeCache(/* @__PURE__ */ new Map());
44465
- var enumRelation = registerSpeculativeCache(/* @__PURE__ */ new Map());
44176
+ var subtypeRelation = /* @__PURE__ */ new Map();
44177
+ var strictSubtypeRelation = /* @__PURE__ */ new Map();
44178
+ var assignableRelation = /* @__PURE__ */ new Map();
44179
+ var comparableRelation = /* @__PURE__ */ new Map();
44180
+ var identityRelation = /* @__PURE__ */ new Map();
44181
+ var enumRelation = /* @__PURE__ */ new Map();
44466
44182
  var builtinGlobals = createSymbolTable();
44467
44183
  builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
44468
44184
  var suggestedExtensions = [
@@ -44641,8 +44357,7 @@ function createTypeChecker(host) {
44641
44357
  function createSymbol(flags, name, checkFlags) {
44642
44358
  symbolCount++;
44643
44359
  const symbol = new Symbol12(flags | 33554432 /* Transient */, name);
44644
- symbol.epoch = currentSpeculativeEpoch;
44645
- symbol.links = new SymbolLinks(speculationHost, symbol.epoch);
44360
+ symbol.links = new SymbolLinks();
44646
44361
  symbol.links.checkFlags = checkFlags || 0 /* None */;
44647
44362
  return symbol;
44648
44363
  }
@@ -44900,11 +44615,11 @@ function createTypeChecker(host) {
44900
44615
  if (symbol.flags & 33554432 /* Transient */)
44901
44616
  return symbol.links;
44902
44617
  const id = getSymbolId(symbol);
44903
- return symbolLinks[id] ?? (symbolLinks[id] = new SymbolLinks(speculationHost));
44618
+ return symbolLinks[id] ?? (symbolLinks[id] = new SymbolLinks());
44904
44619
  }
44905
44620
  function getNodeLinks(node) {
44906
44621
  const nodeId = getNodeId(node);
44907
- return nodeLinks[nodeId] ?? (nodeLinks[nodeId] = new NodeLinks(speculationHost));
44622
+ return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
44908
44623
  }
44909
44624
  function isGlobalSourceFile(node) {
44910
44625
  return node.kind === 307 /* SourceFile */ && !isExternalOrCommonJsModule(node);
@@ -48663,7 +48378,7 @@ function createTypeChecker(host) {
48663
48378
  }
48664
48379
  const abstractSignatures = filter(resolved.constructSignatures, (signature) => !!(signature.flags & 4 /* Abstract */));
48665
48380
  if (some(abstractSignatures)) {
48666
- const types = map(abstractSignatures, getOrCreateTypeFromSignature);
48381
+ const types = map(abstractSignatures, (s) => getOrCreateTypeFromSignature(s));
48667
48382
  const typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per
48668
48383
  // the logic in `createTypeNodesFromResolvedType`.
48669
48384
  (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? countWhere(resolved.properties, (p) => !(p.flags & 4194304 /* Prototype */)) : length(resolved.properties));
@@ -56064,6 +55779,12 @@ function createTypeChecker(host) {
56064
55779
  isInJSFile(signature.declaration)
56065
55780
  );
56066
55781
  }
55782
+ function getImplementationSignature(signature) {
55783
+ return signature.typeParameters ? signature.implementationSignatureCache || (signature.implementationSignatureCache = createImplementationSignature(signature)) : signature;
55784
+ }
55785
+ function createImplementationSignature(signature) {
55786
+ return signature.typeParameters ? instantiateSignature(signature, createTypeMapper([], [])) : signature;
55787
+ }
56067
55788
  function getBaseSignature(signature) {
56068
55789
  const typeParameters = signature.typeParameters;
56069
55790
  if (typeParameters) {
@@ -56086,12 +55807,22 @@ function createTypeChecker(host) {
56086
55807
  }
56087
55808
  return signature;
56088
55809
  }
56089
- function getOrCreateTypeFromSignature(signature) {
55810
+ function getOrCreateTypeFromSignature(signature, outerTypeParameters) {
56090
55811
  var _a;
56091
55812
  if (!signature.isolatedSignatureType) {
56092
55813
  const kind = (_a = signature.declaration) == null ? void 0 : _a.kind;
56093
55814
  const isConstructor = kind === void 0 || kind === 176 /* Constructor */ || kind === 180 /* ConstructSignature */ || kind === 185 /* ConstructorType */;
56094
- const type = createObjectType(16 /* Anonymous */);
55815
+ const type = createObjectType(16 /* Anonymous */ | 134217728 /* SingleSignatureType */, createSymbol(16 /* Function */, "__function" /* Function */));
55816
+ if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
55817
+ type.symbol.declarations = [signature.declaration];
55818
+ type.symbol.valueDeclaration = signature.declaration;
55819
+ }
55820
+ outerTypeParameters || (outerTypeParameters = signature.declaration && getOuterTypeParameters(
55821
+ signature.declaration,
55822
+ /*includeThisTypes*/
55823
+ true
55824
+ ));
55825
+ type.outerTypeParameters = outerTypeParameters;
56095
55826
  type.members = emptySymbols;
56096
55827
  type.properties = emptyArray;
56097
55828
  type.callSignatures = !isConstructor ? [signature] : emptyArray;
@@ -59486,8 +59217,8 @@ function createTypeChecker(host) {
59486
59217
  function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
59487
59218
  const declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : type.symbol.declarations[0];
59488
59219
  const links = getNodeLinks(declaration);
59489
- const target = type.objectFlags & 4 /* Reference */ ? getTypeFromTypeNode(declaration) : type.objectFlags & 64 /* Instantiated */ ? type.target : type;
59490
- let typeParameters = links.outerTypeParameters;
59220
+ const target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : type.objectFlags & 64 /* Instantiated */ ? type.target : type;
59221
+ let typeParameters = type.objectFlags & 134217728 /* SingleSignatureType */ ? type.outerTypeParameters : links.outerTypeParameters;
59491
59222
  if (!typeParameters) {
59492
59223
  let outerTypeParameters = getOuterTypeParameters(
59493
59224
  declaration,
@@ -59668,6 +59399,9 @@ function createTypeChecker(host) {
59668
59399
  if (type.objectFlags & 8388608 /* InstantiationExpressionType */) {
59669
59400
  result.node = type.node;
59670
59401
  }
59402
+ if (type.objectFlags & 134217728 /* SingleSignatureType */) {
59403
+ result.outerTypeParameters = type.outerTypeParameters;
59404
+ }
59671
59405
  result.target = type;
59672
59406
  result.mapper = mapper;
59673
59407
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
@@ -64288,7 +64022,7 @@ function createTypeChecker(host) {
64288
64022
  if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
64289
64023
  return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
64290
64024
  }
64291
- const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
64025
+ const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
64292
64026
  if (type.flags & 3899393 /* ObjectFlagsType */) {
64293
64027
  type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
64294
64028
  }
@@ -64570,6 +64304,9 @@ function createTypeChecker(host) {
64570
64304
  pos = p;
64571
64305
  }
64572
64306
  }
64307
+ function isTupleOfSelf(typeParameter, type) {
64308
+ return isTupleType(type) && getTupleElementType(type, 0) === getIndexedAccessType(typeParameter, getNumberLiteralType(0)) && !getTypeOfPropertyOfType(type, "1");
64309
+ }
64573
64310
  function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
64574
64311
  let bivariant = false;
64575
64312
  let propagationType;
@@ -64655,6 +64392,9 @@ function createTypeChecker(host) {
64655
64392
  inference.priority = priority;
64656
64393
  }
64657
64394
  if (priority === inference.priority) {
64395
+ if (isTupleOfSelf(inference.typeParameter, candidate)) {
64396
+ return;
64397
+ }
64658
64398
  if (contravariant && !bivariant) {
64659
64399
  if (!contains(inference.contraCandidates, candidate)) {
64660
64400
  inference.contraCandidates = append(inference.contraCandidates, candidate);
@@ -71577,7 +71317,7 @@ function createTypeChecker(host) {
71577
71317
  argument = skipParentheses(argument);
71578
71318
  return isSatisfiesExpression(argument) ? skipParentheses(argument.expression) : argument;
71579
71319
  }
71580
- function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain) {
71320
+ function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
71581
71321
  const errorOutputContainer = { errors: void 0, skipLogging: true };
71582
71322
  if (isJsxOpeningLikeElement(node)) {
71583
71323
  if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer)) {
@@ -71611,7 +71351,8 @@ function createTypeChecker(host) {
71611
71351
  void 0,
71612
71352
  checkMode
71613
71353
  );
71614
- const checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
71354
+ const regularArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
71355
+ const checkArgType = inferenceContext ? instantiateType(regularArgType, inferenceContext.nonFixingMapper) : regularArgType;
71615
71356
  const effectiveCheckArgumentNode = getEffectiveCheckNode(arg);
71616
71357
  if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors2 ? effectiveCheckArgumentNode : void 0, effectiveCheckArgumentNode, headMessage, containingMessageChain, errorOutputContainer)) {
71617
71358
  Debug.assert(!reportErrors2 || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
@@ -71980,8 +71721,8 @@ function createTypeChecker(host) {
71980
71721
  Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
71981
71722
  const args = getEffectiveCallArguments(node);
71982
71723
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
71724
+ let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
71983
71725
  let candidatesForArgumentError;
71984
- let candidateArgumentErrors;
71985
71726
  let candidateForArgumentArityError;
71986
71727
  let candidateForTypeArgumentError;
71987
71728
  let result;
@@ -72012,10 +71753,20 @@ function createTypeChecker(host) {
72012
71753
  if (headMessage) {
72013
71754
  chain = chainDiagnosticMessages(chain, headMessage);
72014
71755
  }
72015
- const diags = candidateArgumentErrors[candidateArgumentErrors.length - 1];
71756
+ const diags = getSignatureApplicabilityError(
71757
+ node,
71758
+ args,
71759
+ last2,
71760
+ assignableRelation,
71761
+ 0 /* Normal */,
71762
+ /*reportErrors*/
71763
+ true,
71764
+ () => chain,
71765
+ /*inferenceContext*/
71766
+ void 0
71767
+ );
72016
71768
  if (diags) {
72017
- for (let d of diags) {
72018
- d = prefixDiagnosticWithMessageChain(d, chain);
71769
+ for (const d of diags) {
72019
71770
  if (last2.declaration && candidatesForArgumentError.length > 3) {
72020
71771
  addRelatedInfo(d, createDiagnosticForNode(last2.declaration, Diagnostics.The_last_overload_is_declared_here));
72021
71772
  }
@@ -72040,14 +71791,25 @@ function createTypeChecker(host) {
72040
71791
  candidates.length,
72041
71792
  signatureToString(c)
72042
71793
  );
72043
- const diags2 = candidateArgumentErrors[i];
71794
+ const diags2 = getSignatureApplicabilityError(
71795
+ node,
71796
+ args,
71797
+ c,
71798
+ assignableRelation,
71799
+ 0 /* Normal */,
71800
+ /*reportErrors*/
71801
+ true,
71802
+ chain2,
71803
+ /*inferenceContext*/
71804
+ void 0
71805
+ );
72044
71806
  if (diags2) {
72045
71807
  if (diags2.length <= min2) {
72046
71808
  min2 = diags2.length;
72047
71809
  minIndex = i;
72048
71810
  }
72049
71811
  max = Math.max(max, diags2.length);
72050
- allDiagnostics.push(map(diags2, (d) => prefixDiagnosticWithMessageChain(d, chain2())));
71812
+ allDiagnostics.push(diags2);
72051
71813
  } else {
72052
71814
  Debug.fail("No error for 3 or fewer overload signatures");
72053
71815
  }
@@ -72096,7 +71858,6 @@ function createTypeChecker(host) {
72096
71858
  function addImplementationSuccessElaboration(failed, diagnostic) {
72097
71859
  var _a, _b;
72098
71860
  const oldCandidatesForArgumentError = candidatesForArgumentError;
72099
- const oldCandidateArgumentErrors = candidateArgumentErrors;
72100
71861
  const oldCandidateForArgumentArityError = candidateForArgumentArityError;
72101
71862
  const oldCandidateForTypeArgumentError = candidateForTypeArgumentError;
72102
71863
  const failedSignatureDeclarations = ((_b = (_a = failed.declaration) == null ? void 0 : _a.symbol) == null ? void 0 : _b.declarations) || emptyArray;
@@ -72110,13 +71871,11 @@ function createTypeChecker(host) {
72110
71871
  }
72111
71872
  }
72112
71873
  candidatesForArgumentError = oldCandidatesForArgumentError;
72113
- candidateArgumentErrors = oldCandidateArgumentErrors;
72114
71874
  candidateForArgumentArityError = oldCandidateForArgumentArityError;
72115
71875
  candidateForTypeArgumentError = oldCandidateForTypeArgumentError;
72116
71876
  }
72117
71877
  function chooseOverload(candidates2, relation, isSingleNonGenericCandidate2, signatureHelpTrailingComma2 = false) {
72118
71878
  candidatesForArgumentError = void 0;
72119
- candidateArgumentErrors = void 0;
72120
71879
  candidateForArgumentArityError = void 0;
72121
71880
  candidateForTypeArgumentError = void 0;
72122
71881
  if (isSingleNonGenericCandidate2) {
@@ -72124,113 +71883,108 @@ function createTypeChecker(host) {
72124
71883
  if (some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma2)) {
72125
71884
  return void 0;
72126
71885
  }
72127
- let diags;
72128
- if (diags = getSignatureApplicabilityError(
71886
+ if (getSignatureApplicabilityError(
72129
71887
  node,
72130
71888
  args,
72131
71889
  candidate,
72132
71890
  relation,
72133
71891
  0 /* Normal */,
72134
71892
  /*reportErrors*/
72135
- relation === assignableRelation,
71893
+ false,
72136
71894
  /*containingMessageChain*/
71895
+ void 0,
71896
+ /*inferenceContext*/
72137
71897
  void 0
72138
71898
  )) {
72139
71899
  candidatesForArgumentError = [candidate];
72140
- candidateArgumentErrors = [diags];
72141
71900
  return void 0;
72142
71901
  }
72143
71902
  return candidate;
72144
71903
  }
72145
- const initialCheckMode = !isDecorator2 && !isSingleNonGenericCandidate2 && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
72146
71904
  for (let candidateIndex = 0; candidateIndex < candidates2.length; candidateIndex++) {
72147
- const candidate = candidates2[candidateIndex];
71905
+ let candidate = candidates2[candidateIndex];
72148
71906
  if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma2)) {
72149
71907
  continue;
72150
71908
  }
72151
- const result2 = speculate(() => {
72152
- let argCheckMode = initialCheckMode;
72153
- let checkCandidate;
72154
- let inferenceContext;
72155
- if (candidate.typeParameters) {
72156
- let typeArgumentTypes;
72157
- if (some(typeArguments)) {
72158
- typeArgumentTypes = checkTypeArguments(
72159
- candidate,
72160
- typeArguments,
72161
- /*reportErrors*/
72162
- false
72163
- );
72164
- if (!typeArgumentTypes) {
72165
- candidateForTypeArgumentError = candidate;
72166
- return false;
72167
- }
72168
- } else {
72169
- inferenceContext = createInferenceContext(
72170
- candidate.typeParameters,
72171
- candidate,
72172
- /*flags*/
72173
- isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */
72174
- );
72175
- typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext);
72176
- argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */;
71909
+ let checkCandidate;
71910
+ let inferenceContext;
71911
+ if (candidate.typeParameters) {
71912
+ if (candidate.declaration && findAncestor(node, (a) => a === candidate.declaration)) {
71913
+ candidate = getImplementationSignature(candidate);
71914
+ }
71915
+ let typeArgumentTypes;
71916
+ if (some(typeArguments)) {
71917
+ typeArgumentTypes = checkTypeArguments(
71918
+ candidate,
71919
+ typeArguments,
71920
+ /*reportErrors*/
71921
+ false
71922
+ );
71923
+ if (!typeArgumentTypes) {
71924
+ candidateForTypeArgumentError = candidate;
71925
+ continue;
72177
71926
  }
72178
- checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
71927
+ } else {
71928
+ inferenceContext = createInferenceContext(
71929
+ candidate.typeParameters,
71930
+ candidate,
71931
+ /*flags*/
71932
+ isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */
71933
+ );
71934
+ typeArgumentTypes = instantiateTypes(inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext), inferenceContext.nonFixingMapper);
71935
+ argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */;
71936
+ }
71937
+ checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
71938
+ if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma2)) {
71939
+ candidateForArgumentArityError = checkCandidate;
71940
+ continue;
71941
+ }
71942
+ } else {
71943
+ checkCandidate = candidate;
71944
+ }
71945
+ if (getSignatureApplicabilityError(
71946
+ node,
71947
+ args,
71948
+ checkCandidate,
71949
+ relation,
71950
+ argCheckMode,
71951
+ /*reportErrors*/
71952
+ false,
71953
+ /*containingMessageChain*/
71954
+ void 0,
71955
+ inferenceContext
71956
+ )) {
71957
+ (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
71958
+ continue;
71959
+ }
71960
+ if (argCheckMode) {
71961
+ argCheckMode = 0 /* Normal */;
71962
+ if (inferenceContext) {
71963
+ const typeArgumentTypes = instantiateTypes(inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext), inferenceContext.mapper);
71964
+ checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
72179
71965
  if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma2)) {
72180
71966
  candidateForArgumentArityError = checkCandidate;
72181
- return false;
71967
+ continue;
72182
71968
  }
72183
- } else {
72184
- checkCandidate = candidate;
72185
71969
  }
72186
- let diags;
72187
- if (diags = getSignatureApplicabilityError(
71970
+ if (getSignatureApplicabilityError(
72188
71971
  node,
72189
71972
  args,
72190
71973
  checkCandidate,
72191
71974
  relation,
72192
71975
  argCheckMode,
72193
71976
  /*reportErrors*/
72194
- relation === assignableRelation,
71977
+ false,
72195
71978
  /*containingMessageChain*/
72196
- void 0
71979
+ void 0,
71980
+ inferenceContext
72197
71981
  )) {
72198
71982
  (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
72199
- (candidateArgumentErrors || (candidateArgumentErrors = [])).push(diags);
72200
- return false;
72201
- }
72202
- if (argCheckMode) {
72203
- argCheckMode = 0 /* Normal */;
72204
- if (inferenceContext) {
72205
- const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
72206
- checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
72207
- if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma2)) {
72208
- candidateForArgumentArityError = checkCandidate;
72209
- return false;
72210
- }
72211
- }
72212
- if (diags = getSignatureApplicabilityError(
72213
- node,
72214
- args,
72215
- checkCandidate,
72216
- relation,
72217
- argCheckMode,
72218
- /*reportErrors*/
72219
- relation === assignableRelation,
72220
- /*containingMessageChain*/
72221
- void 0
72222
- )) {
72223
- (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
72224
- (candidateArgumentErrors || (candidateArgumentErrors = [])).push(diags);
72225
- return false;
72226
- }
71983
+ continue;
72227
71984
  }
72228
- candidates2[candidateIndex] = checkCandidate;
72229
- return checkCandidate;
72230
- });
72231
- if (result2) {
72232
- return result2;
72233
71985
  }
71986
+ candidates2[candidateIndex] = checkCandidate;
71987
+ return checkCandidate;
72234
71988
  }
72235
71989
  return void 0;
72236
71990
  }
@@ -75920,7 +75674,7 @@ function createTypeChecker(host) {
75920
75674
  }
75921
75675
  }
75922
75676
  }
75923
- return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
75677
+ return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context), flatMap(inferenceContexts, (c) => c && map(c.inferences, (i) => i.typeParameter)).slice());
75924
75678
  }
75925
75679
  }
75926
75680
  }
@@ -83416,78 +83170,6 @@ function createTypeChecker(host) {
83416
83170
  }
83417
83171
  return getDeclarationOfKind(moduleSymbol, 307 /* SourceFile */);
83418
83172
  }
83419
- function speculate(cb) {
83420
- currentSpeculativeEpoch++;
83421
- const startEpoch = currentSpeculativeEpoch;
83422
- const initialState = snapshotCheckerState();
83423
- const result = cb();
83424
- const endEpoch = currentSpeculativeEpoch;
83425
- currentSpeculativeEpoch++;
83426
- if (!result) {
83427
- for (let i = startEpoch; i <= endEpoch; i++) {
83428
- discardedSpeculativeEpochs.add(i);
83429
- }
83430
- restoreCheckerState(initialState);
83431
- return void 0;
83432
- }
83433
- return result;
83434
- }
83435
- function registerSpeculativeCache(collection) {
83436
- speculativeCaches.push(collection);
83437
- return collection;
83438
- }
83439
- function snapshotCheckerState() {
83440
- const state = { restores: map(speculativeCaches, save) };
83441
- return state;
83442
- function save(cache) {
83443
- if (Array.isArray(cache)) {
83444
- return saveArray(cache);
83445
- } else if (cache instanceof Map) {
83446
- return saveMap(cache);
83447
- } else if (cache instanceof Set) {
83448
- return saveSet(cache);
83449
- } else if (cache.add && cache.getDiagnostics) {
83450
- return saveDiagnosticCollection(cache);
83451
- }
83452
- return Debug.fail("Unknown speculative cache type");
83453
- }
83454
- function saveArray(cache) {
83455
- const original = cache.slice();
83456
- return () => {
83457
- cache.length = 0;
83458
- cache.push(...original);
83459
- };
83460
- }
83461
- function saveMap(cache) {
83462
- const original = arrayFrom(cache.entries());
83463
- return () => {
83464
- cache.clear();
83465
- for (const [k, v] of original) {
83466
- cache.set(k, v);
83467
- }
83468
- };
83469
- }
83470
- function saveSet(cache) {
83471
- const original = arrayFrom(cache.entries());
83472
- return () => {
83473
- cache.clear();
83474
- for (const [_, v] of original) {
83475
- cache.add(v);
83476
- }
83477
- };
83478
- }
83479
- function saveDiagnosticCollection(cache) {
83480
- const c = cache.checkpoint();
83481
- return () => {
83482
- cache.revert(c);
83483
- };
83484
- }
83485
- }
83486
- function restoreCheckerState(state) {
83487
- for (const restore of state.restores) {
83488
- restore();
83489
- }
83490
- }
83491
83173
  function initializeTypeChecker() {
83492
83174
  for (const file of host.getSourceFiles()) {
83493
83175
  bindSourceFile(file, compilerOptions);