@typescript-deploys/pr-build 5.7.0-pr-59417-32 → 5.7.0-pr-59759-2

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
@@ -1203,6 +1203,73 @@ function skipWhile(array, predicate) {
1203
1203
  function isNodeLikeSystem() {
1204
1204
  return typeof process !== "undefined" && !!process.nextTick && !process.browser && typeof require !== "undefined";
1205
1205
  }
1206
+ function createPrefixSuffixTrie() {
1207
+ function createTrie() {
1208
+ return {
1209
+ children: void 0,
1210
+ value: void 0
1211
+ };
1212
+ }
1213
+ const root = createTrie();
1214
+ function* iterateAllMatches(input) {
1215
+ var _a;
1216
+ let node = root;
1217
+ if (node.value) {
1218
+ yield* iterateSuffix(node.value, 0);
1219
+ }
1220
+ for (let i = 0; i < input.length; i++) {
1221
+ const child = (_a = node.children) == null ? void 0 : _a[input[i]];
1222
+ if (!child) break;
1223
+ if (child.value) {
1224
+ yield* iterateSuffix(child.value, i + 1);
1225
+ }
1226
+ node = child;
1227
+ }
1228
+ return;
1229
+ function* iterateSuffix(node2, start) {
1230
+ var _a2;
1231
+ if (node2.value) {
1232
+ yield node2.value;
1233
+ }
1234
+ for (let i = input.length - 1; i >= start; i--) {
1235
+ const child = (_a2 = node2.children) == null ? void 0 : _a2[input[i]];
1236
+ if (!child) break;
1237
+ if (child.value) {
1238
+ yield child.value;
1239
+ }
1240
+ node2 = child;
1241
+ }
1242
+ }
1243
+ }
1244
+ function set(prefix, suffix, fn) {
1245
+ let prefixNode = root;
1246
+ for (let i = 0; i < prefix.length; i++) {
1247
+ const char = prefix[i];
1248
+ const children = prefixNode.children ?? (prefixNode.children = {});
1249
+ const child = children[char] ?? (children[char] = createTrie());
1250
+ prefixNode = child;
1251
+ }
1252
+ let suffixNode = prefixNode.value ?? (prefixNode.value = createTrie());
1253
+ for (let i = suffix.length - 1; i >= 0; i--) {
1254
+ const char = suffix[i];
1255
+ const children = suffixNode.children ?? (suffixNode.children = {});
1256
+ const child = children[char] ?? (children[char] = createTrie());
1257
+ suffixNode = child;
1258
+ }
1259
+ suffixNode.value = fn(suffixNode.value);
1260
+ }
1261
+ function hasAnyMatch(input) {
1262
+ for (const _ of iterateAllMatches(input)) {
1263
+ return true;
1264
+ }
1265
+ return false;
1266
+ }
1267
+ return {
1268
+ iterateAllMatches,
1269
+ set,
1270
+ hasAnyMatch
1271
+ };
1272
+ }
1206
1273
 
1207
1274
  // src/compiler/debug.ts
1208
1275
  var Debug;
@@ -59921,13 +59988,38 @@ function createTypeChecker(host) {
59921
59988
  }
59922
59989
  }
59923
59990
  function removeStringLiteralsMatchedByTemplateLiterals(types) {
59924
- const templates = filter(types, isPatternLiteralType);
59925
- if (templates.length) {
59991
+ let patterns = filter(types, isPatternLiteralType);
59992
+ const templateLiterals = filter(patterns, (t) => !!(t.flags & 134217728 /* TemplateLiteral */));
59993
+ const estimatedCount = templateLiterals.length * countWhere(types, (t) => !!(t.flags & 128 /* StringLiteral */));
59994
+ if (estimatedCount > 0) {
59995
+ const trie = createPrefixSuffixTrie();
59996
+ forEach(templateLiterals, (t) => {
59997
+ const prefix = t.texts[0];
59998
+ const suffix = t.texts[t.texts.length - 1];
59999
+ trie.set(prefix, suffix, (templates) => append(templates, t));
60000
+ });
60001
+ let i = types.length;
60002
+ outer: while (i > 0) {
60003
+ i--;
60004
+ const t = types[i];
60005
+ if (!(t.flags & 128 /* StringLiteral */)) continue;
60006
+ const text = t.value;
60007
+ for (const templates of trie.iterateAllMatches(text)) {
60008
+ if (some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
60009
+ orderedRemoveItemAt(types, i);
60010
+ continue outer;
60011
+ }
60012
+ }
60013
+ }
60014
+ patterns = filter(patterns, (t) => !!(t.flags & 268435456 /* StringMapping */));
60015
+ }
60016
+ if (patterns.length) {
59926
60017
  let i = types.length;
59927
60018
  while (i > 0) {
59928
60019
  i--;
59929
60020
  const t = types[i];
59930
- if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
60021
+ if (!(t.flags & 128 /* StringLiteral */)) continue;
60022
+ if (some(patterns, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
59931
60023
  orderedRemoveItemAt(types, i);
59932
60024
  }
59933
60025
  }
package/lib/typescript.js CHANGED
@@ -429,6 +429,7 @@ __export(typescript_exports, {
429
429
  createPackageJsonInfo: () => createPackageJsonInfo,
430
430
  createParenthesizerRules: () => createParenthesizerRules,
431
431
  createPatternMatcher: () => createPatternMatcher,
432
+ createPrefixSuffixTrie: () => createPrefixSuffixTrie,
432
433
  createPrinter: () => createPrinter,
433
434
  createPrinterWithDefaults: () => createPrinterWithDefaults,
434
435
  createPrinterWithRemoveComments: () => createPrinterWithRemoveComments,
@@ -3745,6 +3746,73 @@ function skipWhile(array, predicate) {
3745
3746
  function isNodeLikeSystem() {
3746
3747
  return typeof process !== "undefined" && !!process.nextTick && !process.browser && typeof require !== "undefined";
3747
3748
  }
3749
+ function createPrefixSuffixTrie() {
3750
+ function createTrie() {
3751
+ return {
3752
+ children: void 0,
3753
+ value: void 0
3754
+ };
3755
+ }
3756
+ const root = createTrie();
3757
+ function* iterateAllMatches(input) {
3758
+ var _a;
3759
+ let node = root;
3760
+ if (node.value) {
3761
+ yield* iterateSuffix(node.value, 0);
3762
+ }
3763
+ for (let i = 0; i < input.length; i++) {
3764
+ const child = (_a = node.children) == null ? void 0 : _a[input[i]];
3765
+ if (!child) break;
3766
+ if (child.value) {
3767
+ yield* iterateSuffix(child.value, i + 1);
3768
+ }
3769
+ node = child;
3770
+ }
3771
+ return;
3772
+ function* iterateSuffix(node2, start) {
3773
+ var _a2;
3774
+ if (node2.value) {
3775
+ yield node2.value;
3776
+ }
3777
+ for (let i = input.length - 1; i >= start; i--) {
3778
+ const child = (_a2 = node2.children) == null ? void 0 : _a2[input[i]];
3779
+ if (!child) break;
3780
+ if (child.value) {
3781
+ yield child.value;
3782
+ }
3783
+ node2 = child;
3784
+ }
3785
+ }
3786
+ }
3787
+ function set(prefix, suffix, fn) {
3788
+ let prefixNode = root;
3789
+ for (let i = 0; i < prefix.length; i++) {
3790
+ const char = prefix[i];
3791
+ const children = prefixNode.children ?? (prefixNode.children = {});
3792
+ const child = children[char] ?? (children[char] = createTrie());
3793
+ prefixNode = child;
3794
+ }
3795
+ let suffixNode = prefixNode.value ?? (prefixNode.value = createTrie());
3796
+ for (let i = suffix.length - 1; i >= 0; i--) {
3797
+ const char = suffix[i];
3798
+ const children = suffixNode.children ?? (suffixNode.children = {});
3799
+ const child = children[char] ?? (children[char] = createTrie());
3800
+ suffixNode = child;
3801
+ }
3802
+ suffixNode.value = fn(suffixNode.value);
3803
+ }
3804
+ function hasAnyMatch(input) {
3805
+ for (const _ of iterateAllMatches(input)) {
3806
+ return true;
3807
+ }
3808
+ return false;
3809
+ }
3810
+ return {
3811
+ iterateAllMatches,
3812
+ set,
3813
+ hasAnyMatch
3814
+ };
3815
+ }
3748
3816
 
3749
3817
  // src/compiler/debug.ts
3750
3818
  var LogLevel = /* @__PURE__ */ ((LogLevel3) => {
@@ -64543,13 +64611,38 @@ function createTypeChecker(host) {
64543
64611
  }
64544
64612
  }
64545
64613
  function removeStringLiteralsMatchedByTemplateLiterals(types) {
64546
- const templates = filter(types, isPatternLiteralType);
64547
- if (templates.length) {
64614
+ let patterns = filter(types, isPatternLiteralType);
64615
+ const templateLiterals = filter(patterns, (t) => !!(t.flags & 134217728 /* TemplateLiteral */));
64616
+ const estimatedCount = templateLiterals.length * countWhere(types, (t) => !!(t.flags & 128 /* StringLiteral */));
64617
+ if (estimatedCount > 0) {
64618
+ const trie = createPrefixSuffixTrie();
64619
+ forEach(templateLiterals, (t) => {
64620
+ const prefix = t.texts[0];
64621
+ const suffix = t.texts[t.texts.length - 1];
64622
+ trie.set(prefix, suffix, (templates) => append(templates, t));
64623
+ });
64624
+ let i = types.length;
64625
+ outer: while (i > 0) {
64626
+ i--;
64627
+ const t = types[i];
64628
+ if (!(t.flags & 128 /* StringLiteral */)) continue;
64629
+ const text = t.value;
64630
+ for (const templates of trie.iterateAllMatches(text)) {
64631
+ if (some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
64632
+ orderedRemoveItemAt(types, i);
64633
+ continue outer;
64634
+ }
64635
+ }
64636
+ }
64637
+ patterns = filter(patterns, (t) => !!(t.flags & 268435456 /* StringMapping */));
64638
+ }
64639
+ if (patterns.length) {
64548
64640
  let i = types.length;
64549
64641
  while (i > 0) {
64550
64642
  i--;
64551
64643
  const t = types[i];
64552
- if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
64644
+ if (!(t.flags & 128 /* StringLiteral */)) continue;
64645
+ if (some(patterns, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
64553
64646
  orderedRemoveItemAt(types, i);
64554
64647
  }
64555
64648
  }
@@ -180150,6 +180243,7 @@ __export(ts_exports2, {
180150
180243
  createPackageJsonInfo: () => createPackageJsonInfo,
180151
180244
  createParenthesizerRules: () => createParenthesizerRules,
180152
180245
  createPatternMatcher: () => createPatternMatcher,
180246
+ createPrefixSuffixTrie: () => createPrefixSuffixTrie,
180153
180247
  createPrinter: () => createPrinter,
180154
180248
  createPrinterWithDefaults: () => createPrinterWithDefaults,
180155
180249
  createPrinterWithRemoveComments: () => createPrinterWithRemoveComments,
@@ -194508,6 +194602,7 @@ if (typeof console !== "undefined") {
194508
194602
  createPackageJsonInfo,
194509
194603
  createParenthesizerRules,
194510
194604
  createPatternMatcher,
194605
+ createPrefixSuffixTrie,
194511
194606
  createPrinter,
194512
194607
  createPrinterWithDefaults,
194513
194608
  createPrinterWithRemoveComments,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.7.0-pr-59417-32",
5
+ "version": "5.7.0-pr-59759-2",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [