typescript 5.6.0-dev.20240618 → 5.6.0-dev.20240619

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
@@ -18,16 +18,16 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-dev.20240618`;
21
+ var version = `${versionMajorMinor}.0-dev.20240619`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
25
25
  var emptyMap = /* @__PURE__ */ new Map();
26
26
  function length(array) {
27
- return array ? array.length : 0;
27
+ return array !== void 0 ? array.length : 0;
28
28
  }
29
29
  function forEach(array, callback) {
30
- if (array) {
30
+ if (array !== void 0) {
31
31
  for (let i = 0; i < array.length; i++) {
32
32
  const result = callback(array[i], i);
33
33
  if (result) {
@@ -78,7 +78,7 @@ function zipWith(arrayA, arrayB, callback) {
78
78
  return result;
79
79
  }
80
80
  function every(array, callback) {
81
- if (array) {
81
+ if (array !== void 0) {
82
82
  for (let i = 0; i < array.length; i++) {
83
83
  if (!callback(array[i], i)) {
84
84
  return false;
@@ -126,20 +126,17 @@ function findLastIndex(array, predicate, startIndex) {
126
126
  return -1;
127
127
  }
128
128
  function contains(array, value, equalityComparer = equateValues) {
129
- if (array) {
130
- for (const v of array) {
131
- if (equalityComparer(v, value)) {
129
+ if (array !== void 0) {
130
+ for (let i = 0; i < array.length; i++) {
131
+ if (equalityComparer(array[i], value)) {
132
132
  return true;
133
133
  }
134
134
  }
135
135
  }
136
136
  return false;
137
137
  }
138
- function arraysEqual(a, b, equalityComparer = equateValues) {
139
- return a.length === b.length && a.every((x, i) => equalityComparer(x, b[i]));
140
- }
141
138
  function indexOfAnyCharCode(text, charCodes, start) {
142
- for (let i = start || 0; i < text.length; i++) {
139
+ for (let i = start ?? 0; i < text.length; i++) {
143
140
  if (contains(charCodes, text.charCodeAt(i))) {
144
141
  return i;
145
142
  }
@@ -148,7 +145,7 @@ function indexOfAnyCharCode(text, charCodes, start) {
148
145
  }
149
146
  function countWhere(array, predicate) {
150
147
  let count = 0;
151
- if (array) {
148
+ if (array !== void 0) {
152
149
  for (let i = 0; i < array.length; i++) {
153
150
  const v = array[i];
154
151
  if (predicate(v, i)) {
@@ -159,7 +156,7 @@ function countWhere(array, predicate) {
159
156
  return count;
160
157
  }
161
158
  function filter(array, f) {
162
- if (array) {
159
+ if (array !== void 0) {
163
160
  const len = array.length;
164
161
  let i = 0;
165
162
  while (i < len && f(array[i])) i++;
@@ -193,7 +190,7 @@ function clear(array) {
193
190
  }
194
191
  function map(array, f) {
195
192
  let result;
196
- if (array) {
193
+ if (array !== void 0) {
197
194
  result = [];
198
195
  for (let i = 0; i < array.length; i++) {
199
196
  result.push(f(array[i], i));
@@ -207,7 +204,7 @@ function* mapIterator(iter, mapFn) {
207
204
  }
208
205
  }
209
206
  function sameMap(array, f) {
210
- if (array) {
207
+ if (array !== void 0) {
211
208
  for (let i = 0; i < array.length; i++) {
212
209
  const item = array[i];
213
210
  const mapped = f(item, i);
@@ -225,7 +222,8 @@ function sameMap(array, f) {
225
222
  }
226
223
  function flatten(array) {
227
224
  const result = [];
228
- for (const v of array) {
225
+ for (let i = 0; i < array.length; i++) {
226
+ const v = array[i];
229
227
  if (v) {
230
228
  if (isArray(v)) {
231
229
  addRange(result, v);
@@ -238,7 +236,7 @@ function flatten(array) {
238
236
  }
239
237
  function flatMap(array, mapfn) {
240
238
  let result;
241
- if (array) {
239
+ if (array !== void 0) {
242
240
  for (let i = 0; i < array.length; i++) {
243
241
  const v = mapfn(array[i], i);
244
242
  if (v) {
@@ -250,11 +248,11 @@ function flatMap(array, mapfn) {
250
248
  }
251
249
  }
252
250
  }
253
- return result || emptyArray;
251
+ return result ?? emptyArray;
254
252
  }
255
253
  function flatMapToMutable(array, mapfn) {
256
254
  const result = [];
257
- if (array) {
255
+ if (array !== void 0) {
258
256
  for (let i = 0; i < array.length; i++) {
259
257
  const v = mapfn(array[i], i);
260
258
  if (v) {
@@ -270,7 +268,7 @@ function flatMapToMutable(array, mapfn) {
270
268
  }
271
269
  function sameFlatMap(array, mapfn) {
272
270
  let result;
273
- if (array) {
271
+ if (array !== void 0) {
274
272
  for (let i = 0; i < array.length; i++) {
275
273
  const item = array[i];
276
274
  const mapped = mapfn(item, i);
@@ -286,11 +284,11 @@ function sameFlatMap(array, mapfn) {
286
284
  }
287
285
  }
288
286
  }
289
- return result || array;
287
+ return result ?? array;
290
288
  }
291
289
  function mapDefined(array, mapFn) {
292
290
  const result = [];
293
- if (array) {
291
+ if (array !== void 0) {
294
292
  for (let i = 0; i < array.length; i++) {
295
293
  const mapped = mapFn(array[i], i);
296
294
  if (mapped !== void 0) {
@@ -325,7 +323,7 @@ function tryAddToSet(set, value) {
325
323
  }
326
324
  function spanMap(array, keyfn, mapfn) {
327
325
  let result;
328
- if (array) {
326
+ if (array !== void 0) {
329
327
  result = [];
330
328
  const len = array.length;
331
329
  let previousKey;
@@ -357,10 +355,10 @@ function spanMap(array, keyfn, mapfn) {
357
355
  return result;
358
356
  }
359
357
  function some(array, predicate) {
360
- if (array) {
361
- if (predicate) {
362
- for (const v of array) {
363
- if (predicate(v)) {
358
+ if (array !== void 0) {
359
+ if (predicate !== void 0) {
360
+ for (let i = 0; i < array.length; i++) {
361
+ if (predicate(array[i])) {
364
362
  return true;
365
363
  }
366
364
  }
@@ -385,8 +383,8 @@ function getRangesWhere(arr, pred, cb) {
385
383
  if (start !== void 0) cb(start, arr.length);
386
384
  }
387
385
  function concatenate(array1, array2) {
388
- if (!some(array2)) return array1;
389
- if (!some(array1)) return array2;
386
+ if (array2 === void 0 || array2.length === 0) return array1;
387
+ if (array1 === void 0 || array1.length === 0) return array2;
390
388
  return [...array1, ...array2];
391
389
  }
392
390
  function selectIndex(_, i) {
@@ -413,8 +411,8 @@ function deduplicateRelational(array, equalityComparer, comparer) {
413
411
  }
414
412
  function deduplicateEquality(array, equalityComparer) {
415
413
  const result = [];
416
- for (const item of array) {
417
- pushIfUnique(result, item, equalityComparer);
414
+ for (let i = 0; i < array.length; i++) {
415
+ pushIfUnique(result, array[i], equalityComparer);
418
416
  }
419
417
  return result;
420
418
  }
@@ -465,10 +463,10 @@ function insertSorted(array, insert, compare, equalityComparer, allowDuplicates)
465
463
  return false;
466
464
  }
467
465
  function sortAndDeduplicate(array, comparer, equalityComparer) {
468
- return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);
466
+ return deduplicateSorted(sort(array, comparer), equalityComparer ?? comparer ?? compareStringsCaseSensitive);
469
467
  }
470
468
  function arrayIsEqualTo(array1, array2, equalityComparer = equateValues) {
471
- if (!array1 || !array2) {
469
+ if (array1 === void 0 || array2 === void 0) {
472
470
  return array1 === array2;
473
471
  }
474
472
  if (array1.length !== array2.length) {
@@ -483,20 +481,18 @@ function arrayIsEqualTo(array1, array2, equalityComparer = equateValues) {
483
481
  }
484
482
  function compact(array) {
485
483
  let result;
486
- if (array) {
484
+ if (array !== void 0) {
487
485
  for (let i = 0; i < array.length; i++) {
488
486
  const v = array[i];
489
- if (result || !v) {
490
- if (!result) {
491
- result = array.slice(0, i);
492
- }
487
+ if (result ?? !v) {
488
+ result ?? (result = array.slice(0, i));
493
489
  if (v) {
494
490
  result.push(v);
495
491
  }
496
492
  }
497
493
  }
498
494
  }
499
- return result || array;
495
+ return result ?? array;
500
496
  }
501
497
  function relativeComplement(arrayA, arrayB, comparer) {
502
498
  if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) return arrayB;
@@ -554,7 +550,7 @@ function pushIfUnique(array, toAdd, equalityComparer) {
554
550
  }
555
551
  }
556
552
  function appendIfUnique(array, toAdd, equalityComparer) {
557
- if (array) {
553
+ if (array !== void 0) {
558
554
  pushIfUnique(array, toAdd, equalityComparer);
559
555
  return array;
560
556
  } else {
@@ -582,7 +578,7 @@ function rangeEquals(array1, array2, pos, end) {
582
578
  return true;
583
579
  }
584
580
  var elementAt = !!Array.prototype.at ? (array, offset) => array == null ? void 0 : array.at(offset) : (array, offset) => {
585
- if (array) {
581
+ if (array !== void 0) {
586
582
  offset = toOffset(array, offset);
587
583
  if (offset < array.length) {
588
584
  return array[offset];
@@ -594,7 +590,7 @@ function firstOrUndefined(array) {
594
590
  return array === void 0 || array.length === 0 ? void 0 : array[0];
595
591
  }
596
592
  function firstOrUndefinedIterator(iter) {
597
- if (iter) {
593
+ if (iter !== void 0) {
598
594
  for (const value of iter) {
599
595
  return value;
600
596
  }
@@ -619,10 +615,10 @@ function last(array) {
619
615
  return array[array.length - 1];
620
616
  }
621
617
  function singleOrUndefined(array) {
622
- return array && array.length === 1 ? array[0] : void 0;
618
+ return array !== void 0 && array.length === 1 ? array[0] : void 0;
623
619
  }
624
620
  function singleOrMany(array) {
625
- return array && array.length === 1 ? array[0] : array;
621
+ return array !== void 0 && array.length === 1 ? array[0] : array;
626
622
  }
627
623
  function replaceElement(array, index, value) {
628
624
  const result = array.slice(0);
@@ -636,7 +632,7 @@ function binarySearchKey(array, key, keySelector, keyComparer, offset) {
636
632
  if (!some(array)) {
637
633
  return -1;
638
634
  }
639
- let low = offset || 0;
635
+ let low = offset ?? 0;
640
636
  let high = array.length - 1;
641
637
  while (low <= high) {
642
638
  const middle = low + (high - low >> 1);
@@ -741,7 +737,8 @@ function equalOwnProperties(left, right, equalityComparer = equateValues) {
741
737
  }
742
738
  function arrayToMap(array, makeKey, makeValue = identity) {
743
739
  const result = /* @__PURE__ */ new Map();
744
- for (const value of array) {
740
+ for (let i = 0; i < array.length; i++) {
741
+ const value = array[i];
745
742
  const key = makeKey(value);
746
743
  if (key !== void 0) result.set(key, makeValue(value));
747
744
  }
@@ -749,7 +746,8 @@ function arrayToMap(array, makeKey, makeValue = identity) {
749
746
  }
750
747
  function arrayToMultiMap(values, makeKey, makeValue = identity) {
751
748
  const result = createMultiMap();
752
- for (const value of values) {
749
+ for (let i = 0; i < values.length; i++) {
750
+ const value = values[i];
753
751
  result.add(makeKey(value), makeValue(value));
754
752
  }
755
753
  return result;
@@ -759,8 +757,9 @@ function group(values, getGroupId, resultSelector = identity) {
759
757
  }
760
758
  function groupBy(values, keySelector) {
761
759
  const result = {};
762
- if (values) {
763
- for (const value of values) {
760
+ if (values !== void 0) {
761
+ for (let i = 0; i < values.length; i++) {
762
+ const value = values[i];
764
763
  const key = `${keySelector(value)}`;
765
764
  const array = result[key] ?? (result[key] = []);
766
765
  array.push(value);
@@ -790,7 +789,7 @@ function copyProperties(first2, second) {
790
789
  }
791
790
  }
792
791
  function maybeBind(obj, fn) {
793
- return fn ? fn.bind(obj) : void 0;
792
+ return fn == null ? void 0 : fn.bind(obj);
794
793
  }
795
794
  function createMultiMap() {
796
795
  const map2 = /* @__PURE__ */ new Map();
@@ -800,7 +799,7 @@ function createMultiMap() {
800
799
  }
801
800
  function multiMapAdd(key, value) {
802
801
  let values = this.get(key);
803
- if (values) {
802
+ if (values !== void 0) {
804
803
  values.push(value);
805
804
  } else {
806
805
  this.set(key, values = [value]);
@@ -809,7 +808,7 @@ function multiMapAdd(key, value) {
809
808
  }
810
809
  function multiMapRemove(key, value) {
811
810
  const values = this.get(key);
812
- if (values) {
811
+ if (values !== void 0) {
813
812
  unorderedRemoveItem(values, value);
814
813
  if (!values.length) {
815
814
  this.delete(key);
@@ -817,7 +816,7 @@ function multiMapRemove(key, value) {
817
816
  }
818
817
  }
819
818
  function createQueue(items) {
820
- const elements = (items == null ? void 0 : items.slice()) || [];
819
+ const elements = (items == null ? void 0 : items.slice()) ?? [];
821
820
  let headIndex = 0;
822
821
  function isEmpty() {
823
822
  return headIndex === elements.length;
@@ -931,6 +930,12 @@ function compareComparableValues(a, b) {
931
930
  function compareValues(a, b) {
932
931
  return compareComparableValues(a, b);
933
932
  }
933
+ function maxBy(arr, init, mapper) {
934
+ for (let i = 0; i < arr.length; i++) {
935
+ init = Math.max(init, mapper(arr[i]));
936
+ }
937
+ return init;
938
+ }
934
939
  function min(items, compare) {
935
940
  return reduceLeft(items, (x, y) => compare(x, y) === -1 /* LessThan */ ? x : y);
936
941
  }
@@ -1076,7 +1081,8 @@ function matchedText(pattern, candidate) {
1076
1081
  function findBestPatternMatch(values, getPattern, candidate) {
1077
1082
  let matchedValue;
1078
1083
  let longestMatchPrefixLength = -1;
1079
- for (const v of values) {
1084
+ for (let i = 0; i < values.length; i++) {
1085
+ const v = values[i];
1080
1086
  const pattern = getPattern(v);
1081
1087
  if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
1082
1088
  longestMatchPrefixLength = pattern.prefix.length;
@@ -1118,7 +1124,7 @@ function singleElementArray(t) {
1118
1124
  return t === void 0 ? void 0 : [t];
1119
1125
  }
1120
1126
  function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
1121
- unchanged = unchanged || noop;
1127
+ unchanged ?? (unchanged = noop);
1122
1128
  let newIndex = 0;
1123
1129
  let oldIndex = 0;
1124
1130
  const newLen = newItems.length;
@@ -1180,7 +1186,7 @@ function cartesianProductWorker(arrays, result, outer, index) {
1180
1186
  }
1181
1187
  }
1182
1188
  function takeWhile(array, predicate) {
1183
- if (array) {
1189
+ if (array !== void 0) {
1184
1190
  const len = array.length;
1185
1191
  let index = 0;
1186
1192
  while (index < len && predicate(array[index])) {
@@ -1190,7 +1196,7 @@ function takeWhile(array, predicate) {
1190
1196
  }
1191
1197
  }
1192
1198
  function skipWhile(array, predicate) {
1193
- if (array) {
1199
+ if (array !== void 0) {
1194
1200
  const len = array.length;
1195
1201
  let index = 0;
1196
1202
  while (index < len && predicate(array[index])) {
@@ -2107,7 +2113,7 @@ m2: ${this.mapper2.__debugToString().split("\n").join("\n ")}`;
2107
2113
  }
2108
2114
  function renderGraph() {
2109
2115
  const columnCount = columnWidths.length;
2110
- const laneCount = nodes.reduce((x, n) => Math.max(x, n.lane), 0) + 1;
2116
+ const laneCount = maxBy(nodes, 0, (n) => n.lane) + 1;
2111
2117
  const lanes = fill(Array(laneCount), "");
2112
2118
  const grid = columnWidths.map(() => Array(laneCount));
2113
2119
  const connectors = columnWidths.map(() => fill(Array(laneCount), 0));
@@ -8115,7 +8121,7 @@ function computePositionOfLineAndCharacter(lineStarts, line, character, debugTex
8115
8121
  if (allowEdits) {
8116
8122
  line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
8117
8123
  } else {
8118
- Debug.fail(`Bad line number. Line: ${line}, lineStarts.length: ${lineStarts.length} , line map is correct? ${debugText !== void 0 ? arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"}`);
8124
+ Debug.fail(`Bad line number. Line: ${line}, lineStarts.length: ${lineStarts.length} , line map is correct? ${debugText !== void 0 ? arrayIsEqualTo(lineStarts, computeLineStarts(debugText)) : "unknown"}`);
8119
8125
  }
8120
8126
  }
8121
8127
  const res = lineStarts[line] + character;
@@ -37513,9 +37519,7 @@ function convertToTSConfig(configParseResult, configFileName, host) {
37513
37519
  return config;
37514
37520
  }
37515
37521
  function optionMapToObject(optionMap) {
37516
- return {
37517
- ...arrayFrom(optionMap.entries()).reduce((prev, cur) => ({ ...prev, [cur[0]]: cur[1] }), {})
37518
- };
37522
+ return Object.fromEntries(optionMap);
37519
37523
  }
37520
37524
  function filterSameAsDefaultInclude(specs) {
37521
37525
  if (!length(specs)) return void 0;
@@ -66420,7 +66424,7 @@ function createTypeChecker(host) {
66420
66424
  return false;
66421
66425
  }
66422
66426
  function inferTypesFromTemplateLiteralType(source, target) {
66423
- return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arraysEqual(source.texts, target.texts) ? map(source.types, (s, i) => {
66427
+ return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arrayIsEqualTo(source.texts, target.texts) ? map(source.types, (s, i) => {
66424
66428
  return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
66425
66429
  }) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
66426
66430
  }
@@ -68584,7 +68588,7 @@ function createTypeChecker(host) {
68584
68588
  return getEvolvingArrayType(getUnionType(map(types, getElementTypeOfEvolvingArrayType)));
68585
68589
  }
68586
68590
  const result = recombineUnknownType(getUnionType(sameMap(types, finalizeEvolvingArrayType), subtypeReduction));
68587
- if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && arraysEqual(result.types, declaredType.types)) {
68591
+ if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && arrayIsEqualTo(result.types, declaredType.types)) {
68588
68592
  return declaredType;
68589
68593
  }
68590
68594
  return result;
@@ -120132,7 +120136,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120132
120136
  if (file.hasNoDefaultLib) {
120133
120137
  return true;
120134
120138
  }
120135
- if (!options.noLib) {
120139
+ if (options.noLib) {
120136
120140
  return false;
120137
120141
  }
120138
120142
  const equalityComparer = host.useCaseSensitiveFileNames() ? equateStringsCaseSensitive : equateStringsCaseInsensitive;
@@ -125450,7 +125454,7 @@ function createTabularErrorsDisplay(filesInError, host) {
125450
125454
  if (distinctFiles.length === 0) return "";
125451
125455
  const numberLength = (num) => Math.log(num) * Math.LOG10E + 1;
125452
125456
  const fileToErrorCount = distinctFiles.map((file) => [file, countWhere(filesInError, (fileInError) => fileInError.fileName === file.fileName)]);
125453
- const maxErrors = fileToErrorCount.reduce((acc, value) => Math.max(acc, value[1] || 0), 0);
125457
+ const maxErrors = maxBy(fileToErrorCount, 0, (value) => value[1]);
125454
125458
  const headerRow = Diagnostics.Errors_Files.message;
125455
125459
  const leftColumnHeadingLength = headerRow.split(" ")[0].length;
125456
125460
  const leftPaddingGoal = Math.max(leftColumnHeadingLength, numberLength(maxErrors));