tsc-ts 0.0.5 → 0.0.7

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.
Files changed (203) hide show
  1. package/README.md +1 -1
  2. package/dist/api/compiler/ast.d.ts +67 -27
  3. package/dist/api/compiler/ast.js +156 -55
  4. package/dist/api/compiler/binder-utilities.js +4 -3
  5. package/dist/api/compiler/binder.js +14 -13
  6. package/dist/api/compiler/checker-calls.js +7 -6
  7. package/dist/api/compiler/checker-contextual.js +1 -1
  8. package/dist/api/compiler/checker-declaration-order.js +2 -1
  9. package/dist/api/compiler/checker-declarations.js +14 -14
  10. package/dist/api/compiler/checker-declared-types.d.ts +1 -1
  11. package/dist/api/compiler/checker-declared-types.js +12 -11
  12. package/dist/api/compiler/checker-decorators.js +3 -3
  13. package/dist/api/compiler/checker-deprecation.js +17 -18
  14. package/dist/api/compiler/checker-destructuring.d.ts +1 -1
  15. package/dist/api/compiler/checker-destructuring.js +3 -3
  16. package/dist/api/compiler/checker-elaboration.js +8 -7
  17. package/dist/api/compiler/checker-emit-helpers.d.ts +2 -1
  18. package/dist/api/compiler/checker-emit-helpers.js +5 -4
  19. package/dist/api/compiler/checker-emit-resolver.d.ts +1 -1
  20. package/dist/api/compiler/checker-emit-resolver.js +5 -4
  21. package/dist/api/compiler/checker-grammar.js +23 -9
  22. package/dist/api/compiler/checker-heritage.d.ts +1 -1
  23. package/dist/api/compiler/checker-heritage.js +14 -13
  24. package/dist/api/compiler/checker-inference.d.ts +21 -11
  25. package/dist/api/compiler/checker-inference.js +57 -34
  26. package/dist/api/compiler/checker-javascript.d.ts +1 -1
  27. package/dist/api/compiler/checker-javascript.js +5 -4
  28. package/dist/api/compiler/checker-jsx.d.ts +1 -1
  29. package/dist/api/compiler/checker-jsx.js +4 -4
  30. package/dist/api/compiler/checker-literals.js +2 -2
  31. package/dist/api/compiler/checker-members.d.ts +32 -3
  32. package/dist/api/compiler/checker-members.js +240 -53
  33. package/dist/api/compiler/checker-modules.d.ts +15 -1
  34. package/dist/api/compiler/checker-modules.js +86 -14
  35. package/dist/api/compiler/checker-object-literals.d.ts +1 -1
  36. package/dist/api/compiler/checker-object-literals.js +11 -7
  37. package/dist/api/compiler/checker-overloads.d.ts +1 -1
  38. package/dist/api/compiler/checker-overloads.js +4 -3
  39. package/dist/api/compiler/checker-property-access.d.ts +1 -1
  40. package/dist/api/compiler/checker-property-access.js +2 -2
  41. package/dist/api/compiler/checker-services.js +2 -2
  42. package/dist/api/compiler/checker-signatures.d.ts +1 -1
  43. package/dist/api/compiler/checker-signatures.js +9 -8
  44. package/dist/api/compiler/checker-symbol-types.d.ts +2 -18
  45. package/dist/api/compiler/checker-symbol-types.js +22 -952
  46. package/dist/api/compiler/checker-symbols.d.ts +2 -2
  47. package/dist/api/compiler/checker-symbols.js +29 -27
  48. package/dist/api/compiler/checker-type-factory.d.ts +2 -2
  49. package/dist/api/compiler/checker-type-factory.js +57 -16
  50. package/dist/api/compiler/checker-type-nodes.d.ts +1 -1
  51. package/dist/api/compiler/checker-type-nodes.js +2 -2
  52. package/dist/api/compiler/checker-type-operators.d.ts +1 -1
  53. package/dist/api/compiler/checker-type-operators.js +5 -5
  54. package/dist/api/compiler/checker-types.d.ts +73 -7
  55. package/dist/api/compiler/checker-types.js +220 -43
  56. package/dist/api/compiler/checker-unused.d.ts +1 -1
  57. package/dist/api/compiler/checker-unused.js +3 -3
  58. package/dist/api/compiler/checker.d.ts +45 -8
  59. package/dist/api/compiler/checker.js +46 -9
  60. package/dist/api/compiler/diagnostics.d.ts +2 -8
  61. package/dist/api/compiler/diagnostics.js +13 -45
  62. package/dist/api/compiler/file-include.d.ts +35 -8
  63. package/dist/api/compiler/file-include.js +81 -18
  64. package/dist/api/compiler/file-loader.d.ts +33 -4
  65. package/dist/api/compiler/file-loader.js +90 -24
  66. package/dist/api/compiler/instantiation.d.ts +1 -1
  67. package/dist/api/compiler/instantiation.js +86 -50
  68. package/dist/api/compiler/link-tables.d.ts +69 -0
  69. package/dist/api/compiler/link-tables.js +236 -0
  70. package/dist/api/compiler/name-resolver.js +3 -3
  71. package/dist/api/compiler/node-builder-names.d.ts +1 -1
  72. package/dist/api/compiler/node-builder-names.js +12 -12
  73. package/dist/api/compiler/node-builder-pseudo.d.ts +1 -1
  74. package/dist/api/compiler/node-builder-pseudo.js +2 -1
  75. package/dist/api/compiler/node-builder.d.ts +1 -1
  76. package/dist/api/compiler/node-builder.js +16 -16
  77. package/dist/api/compiler/parallel-parse.d.ts +2 -0
  78. package/dist/api/compiler/parallel-parse.js +7 -1
  79. package/dist/api/compiler/parser.d.ts +33 -16
  80. package/dist/api/compiler/parser.js +127 -98
  81. package/dist/api/compiler/printer/emit-context.d.ts +5 -2
  82. package/dist/api/compiler/printer/emit-context.js +19 -13
  83. package/dist/api/compiler/printer/factory-base.js +8 -8
  84. package/dist/api/compiler/printer/factory.js +4 -4
  85. package/dist/api/compiler/printer/printer.js +6 -6
  86. package/dist/api/compiler/program-checker.d.ts +5 -0
  87. package/dist/api/compiler/program-checker.js +14 -1
  88. package/dist/api/compiler/program.js +9 -1
  89. package/dist/api/compiler/relations.d.ts +1 -1
  90. package/dist/api/compiler/relations.js +18 -13
  91. package/dist/api/compiler/reparser.js +13 -5
  92. package/dist/api/compiler/symbol-accessibility.d.ts +1 -1
  93. package/dist/api/compiler/symbol-accessibility.js +123 -26
  94. package/dist/api/compiler/symbol.d.ts +45 -3
  95. package/dist/api/compiler/symbol.js +121 -10
  96. package/dist/api/compiler/transformers/alias-references.d.ts +1 -1
  97. package/dist/api/compiler/transformers/alias-references.js +2 -1
  98. package/dist/api/compiler/transformers/class-fields.js +3 -3
  99. package/dist/api/compiler/transformers/commonjs-module.js +3 -3
  100. package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
  101. package/dist/api/compiler/transformers/declarations-pseudo.js +6 -4
  102. package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -1
  103. package/dist/api/compiler/transformers/declarations-syntactic.js +9 -9
  104. package/dist/api/compiler/transformers/declarations-tracker.d.ts +1 -1
  105. package/dist/api/compiler/transformers/declarations-tracker.js +3 -2
  106. package/dist/api/compiler/transformers/declarations.js +6 -5
  107. package/dist/api/compiler/transformers/module.js +2 -2
  108. package/dist/api/compiler/transformers/optional-chain.js +3 -3
  109. package/dist/api/compiler/transformers/reference-resolver.d.ts +2 -1
  110. package/dist/api/compiler/transformers/reference-resolver.js +26 -24
  111. package/dist/api/compiler/transformers/subtree-facts.d.ts +1 -0
  112. package/dist/api/compiler/transformers/subtree-facts.js +9 -7
  113. package/dist/api/compiler/transformers/syntax-facts.d.ts +1 -0
  114. package/dist/api/compiler/transformers/syntax-facts.js +9 -5
  115. package/dist/api/compiler/transformers/tagged-template.js +2 -2
  116. package/dist/api/compiler/transformers/type-eraser.js +2 -2
  117. package/dist/api/compiler/transformers/type-serialization.js +12 -12
  118. package/dist/api/compiler/transformers/visitor-base.js +3 -3
  119. package/dist/api/compiler/tsconfig.js +2 -2
  120. package/package.json +9 -9
  121. package/src/compiler/ast.ts +211 -78
  122. package/src/compiler/binder-utilities.ts +4 -3
  123. package/src/compiler/binder.ts +26 -16
  124. package/src/compiler/checker-calls.ts +8 -6
  125. package/src/compiler/checker-contextual.ts +1 -1
  126. package/src/compiler/checker-declaration-order.ts +2 -2
  127. package/src/compiler/checker-declarations.ts +21 -14
  128. package/src/compiler/checker-declared-types.ts +12 -12
  129. package/src/compiler/checker-decorators.ts +3 -3
  130. package/src/compiler/checker-deprecation.ts +17 -21
  131. package/src/compiler/checker-destructuring.ts +3 -3
  132. package/src/compiler/checker-elaboration.ts +8 -8
  133. package/src/compiler/checker-emit-helpers.ts +5 -4
  134. package/src/compiler/checker-emit-resolver.ts +5 -5
  135. package/src/compiler/checker-grammar.ts +22 -8
  136. package/src/compiler/checker-heritage.ts +21 -14
  137. package/src/compiler/checker-inference.ts +66 -34
  138. package/src/compiler/checker-javascript.ts +5 -5
  139. package/src/compiler/checker-jsx.ts +12 -8
  140. package/src/compiler/checker-literals.ts +2 -2
  141. package/src/compiler/checker-members.ts +255 -47
  142. package/src/compiler/checker-modules.ts +115 -14
  143. package/src/compiler/checker-object-literals.ts +22 -6
  144. package/src/compiler/checker-overloads.ts +6 -6
  145. package/src/compiler/checker-property-access.ts +2 -2
  146. package/src/compiler/checker-services.ts +2 -2
  147. package/src/compiler/checker-signatures.ts +9 -9
  148. package/src/compiler/checker-symbol-types.ts +20 -940
  149. package/src/compiler/checker-symbols.ts +42 -35
  150. package/src/compiler/checker-type-factory.ts +53 -16
  151. package/src/compiler/checker-type-nodes.ts +2 -2
  152. package/src/compiler/checker-type-operators.ts +13 -5
  153. package/src/compiler/checker-types.ts +223 -43
  154. package/src/compiler/checker-unused.ts +3 -3
  155. package/src/compiler/checker.ts +50 -9
  156. package/src/compiler/decoder.ts +5 -4
  157. package/src/compiler/diagnostics.ts +14 -48
  158. package/src/compiler/encoder.ts +10 -5
  159. package/src/compiler/file-include.ts +85 -17
  160. package/src/compiler/file-loader.ts +104 -35
  161. package/src/compiler/incremental.ts +39 -5
  162. package/src/compiler/instantiation.ts +99 -55
  163. package/src/compiler/link-tables.ts +245 -0
  164. package/src/compiler/name-resolver.ts +3 -3
  165. package/src/compiler/node-builder-names.ts +21 -19
  166. package/src/compiler/node-builder-pseudo.ts +2 -2
  167. package/src/compiler/node-builder.ts +24 -16
  168. package/src/compiler/parallel-check.ts +11 -8
  169. package/src/compiler/parallel-parse.ts +8 -1
  170. package/src/compiler/parse-thread.ts +0 -4
  171. package/src/compiler/parser.ts +173 -93
  172. package/src/compiler/printer/emit-context.ts +20 -15
  173. package/src/compiler/printer/factory-base.ts +14 -7
  174. package/src/compiler/printer/factory.ts +5 -3
  175. package/src/compiler/printer/printer.ts +8 -6
  176. package/src/compiler/program-checker.ts +12 -1
  177. package/src/compiler/program.ts +8 -1
  178. package/src/compiler/relations.ts +20 -12
  179. package/src/compiler/reparser.ts +14 -4
  180. package/src/compiler/symbol-accessibility.ts +120 -25
  181. package/src/compiler/symbol.ts +127 -9
  182. package/src/compiler/transformers/alias-references.ts +2 -2
  183. package/src/compiler/transformers/class-fields.ts +12 -2
  184. package/src/compiler/transformers/commonjs-module.ts +3 -2
  185. package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
  186. package/src/compiler/transformers/declarations-pseudo.ts +9 -5
  187. package/src/compiler/transformers/declarations-syntactic.ts +17 -9
  188. package/src/compiler/transformers/declarations-tracker.ts +3 -3
  189. package/src/compiler/transformers/declarations.ts +7 -7
  190. package/src/compiler/transformers/module.ts +2 -1
  191. package/src/compiler/transformers/optional-chain.ts +5 -2
  192. package/src/compiler/transformers/reference-resolver.ts +37 -25
  193. package/src/compiler/transformers/subtree-facts.ts +15 -6
  194. package/src/compiler/transformers/syntax-facts.ts +10 -5
  195. package/src/compiler/transformers/tagged-template.ts +2 -2
  196. package/src/compiler/transformers/type-eraser.ts +2 -1
  197. package/src/compiler/transformers/type-serialization.ts +12 -12
  198. package/src/compiler/transformers/visitor-base.ts +10 -5
  199. package/src/compiler/tsc-build.ts +17 -13
  200. package/src/compiler/tsc-cli.ts +9 -6
  201. package/src/compiler/tsc-compile.ts +16 -7
  202. package/src/compiler/tsc-watch.ts +94 -26
  203. package/src/compiler/tsconfig.ts +2 -1
@@ -20,21 +20,6 @@ export class TypeAlias {
20
20
  this.typeArguments = typeArguments;
21
21
  }
22
22
  }
23
- /** One entry of a `TypeListCache`: the parts of its key, its value, and the next entry with the same hash. */
24
- class TypeListEntry {
25
- types;
26
- alias;
27
- tag;
28
- value;
29
- next;
30
- constructor(types, alias, tag, value) {
31
- this.types = types;
32
- this.alias = alias;
33
- this.tag = tag;
34
- this.value = value;
35
- this.next = undefined;
36
- }
37
- }
38
23
  function sameTypeListParts(a, b) {
39
24
  if (a.length !== b.length)
40
25
  return false;
@@ -53,32 +38,149 @@ function sameAliasParts(a, b) {
53
38
  * aliasKey(alias)` plus a suffix spelled, without building them. A lookup takes a number hashing the
54
39
  * parts (`typeListHash`); entries keep their parts, so a match is exact and keys sharing a hash chain.
55
40
  * Like tsgo's hashed type list keys. A list must not change after it keys an entry.
41
+ *
42
+ * Entries are numbered in the order they are added: `heads` maps a hash to its first entry, and the
43
+ * lists and values of the entries are kept in arrays by number. Aliases, tags and the chains of
44
+ * entries that share a hash get arrays once an entry needs them.
56
45
  */
57
46
  export class TypeListCache {
58
- entries = new Map();
47
+ heads;
48
+ lists;
49
+ values;
50
+ aliases;
51
+ tags;
52
+ /** The next entry with the same hash, or -1. */
53
+ nexts;
54
+ constructor() {
55
+ this.heads = new Map();
56
+ this.lists = [];
57
+ this.values = [];
58
+ this.aliases = undefined;
59
+ this.tags = undefined;
60
+ this.nexts = undefined;
61
+ }
59
62
  get(hash, types, alias, tag) {
60
- for (let e = this.entries.get(hash); e !== undefined; e = e.next)
61
- if (e.tag === tag && sameTypeListParts(e.types, types) && sameAliasParts(e.alias, alias))
62
- return e.value;
63
- return undefined;
63
+ const entry = this.find(hash, types, alias, tag);
64
+ return entry >= 0 ? this.values[entry] : undefined;
64
65
  }
65
66
  set(hash, types, alias, tag, value) {
66
- const head = this.entries.get(hash);
67
+ const head = this.heads.get(hash);
68
+ if (head !== undefined) {
69
+ const entry = this.findFrom(head, types, alias, tag);
70
+ if (entry >= 0) {
71
+ this.values[entry] = value;
72
+ return;
73
+ }
74
+ }
75
+ const entry = this.lists.length;
76
+ this.lists.push(types);
77
+ this.values.push(value);
78
+ const aliases = this.aliases;
79
+ if (aliases !== undefined)
80
+ aliases.push(alias);
81
+ else if (alias !== undefined) {
82
+ const created = [];
83
+ for (let i = 0; i < entry; i++)
84
+ created.push(undefined);
85
+ created.push(alias);
86
+ this.aliases = created;
87
+ }
88
+ const tags = this.tags;
89
+ if (tags !== undefined)
90
+ tags.push(tag);
91
+ else if (tag !== 0) {
92
+ const created = [];
93
+ for (let i = 0; i < entry; i++)
94
+ created.push(0);
95
+ created.push(tag);
96
+ this.tags = created;
97
+ }
98
+ let nexts = this.nexts;
99
+ if (nexts !== undefined)
100
+ nexts.push(-1);
67
101
  if (head === undefined) {
68
- this.entries.set(hash, new TypeListEntry(types, alias, tag, value));
102
+ this.heads.set(hash, entry);
69
103
  return;
70
104
  }
71
- for (let e = head; e !== undefined; e = e.next)
72
- if (e.tag === tag && sameTypeListParts(e.types, types) && sameAliasParts(e.alias, alias)) {
73
- e.value = value;
74
- return;
75
- }
76
- const entry = new TypeListEntry(types, alias, tag, value);
77
- entry.next = head.next;
78
- head.next = entry;
105
+ // A second entry with this hash: chain it after the first.
106
+ if (nexts === undefined) {
107
+ nexts = [];
108
+ for (let i = 0; i <= entry; i++)
109
+ nexts.push(-1);
110
+ this.nexts = nexts;
111
+ }
112
+ nexts[entry] = nexts[head];
113
+ nexts[head] = entry;
79
114
  }
80
115
  clear() {
81
- this.entries.clear();
116
+ this.heads = new Map();
117
+ this.lists = [];
118
+ this.values = [];
119
+ this.aliases = undefined;
120
+ this.tags = undefined;
121
+ this.nexts = undefined;
122
+ }
123
+ /** The number of the entry with these parts, or -1. */
124
+ find(hash, types, alias, tag) {
125
+ const head = this.heads.get(hash);
126
+ return head !== undefined ? this.findFrom(head, types, alias, tag) : -1;
127
+ }
128
+ findFrom(head, types, alias, tag) {
129
+ const tags = this.tags;
130
+ const aliases = this.aliases;
131
+ const nexts = this.nexts;
132
+ for (let entry = head; entry >= 0; entry = nexts !== undefined ? nexts[entry] : -1)
133
+ if ((tags !== undefined ? tags[entry] : 0) === tag &&
134
+ sameTypeListParts(this.lists[entry], types) &&
135
+ sameAliasParts(aliases !== undefined ? aliases[entry] : undefined, alias))
136
+ return entry;
137
+ return -1;
138
+ }
139
+ }
140
+ /**
141
+ * One list for each sequence of types that a checker keeps (`Checker.typeLists`): references and
142
+ * instantiation caches hold the same type arguments in many places, mostly lists of one or two types,
143
+ * and share one list for them. A list must not change once it is in the table.
144
+ */
145
+ export class TypeListTable {
146
+ heads = new Map();
147
+ lists = [];
148
+ /** The next list with the same hash, or -1, once two lists share one. */
149
+ nexts = undefined;
150
+ /**
151
+ * The list in the table with the types of `types`, in order, or `types` itself, which joins the
152
+ * table. `hash` is `typeListHash(types, undefined, 0)`.
153
+ */
154
+ intern(hash, types) {
155
+ if (types.length === 0)
156
+ return types;
157
+ const head = this.heads.get(hash);
158
+ const nexts = this.nexts;
159
+ if (head !== undefined)
160
+ for (let entry = head; entry >= 0; entry = nexts !== undefined ? nexts[entry] : -1) {
161
+ const list = this.lists[entry];
162
+ if (sameTypeListParts(list, types))
163
+ return list;
164
+ }
165
+ const entry = this.lists.length;
166
+ this.lists.push(types);
167
+ if (nexts !== undefined)
168
+ nexts.push(-1);
169
+ if (head === undefined) {
170
+ this.heads.set(hash, entry);
171
+ return types;
172
+ }
173
+ // A second list with this hash: chain it after the first.
174
+ let chain = nexts;
175
+ if (chain === undefined) {
176
+ chain = [];
177
+ for (let i = 0; i <= entry; i++)
178
+ chain.push(-1);
179
+ this.nexts = chain;
180
+ }
181
+ chain[entry] = chain[head];
182
+ chain[head] = entry;
183
+ return types;
82
184
  }
83
185
  }
84
186
  /**
@@ -133,7 +235,7 @@ export class TypeExtra {
133
235
  origin;
134
236
  keyPropertyName;
135
237
  constituentMap;
136
- constituentSet;
238
+ constituentIds;
137
239
  membershipTests;
138
240
  // IntersectionType
139
241
  uniqueLiteralFilledInstantiation;
@@ -146,7 +248,7 @@ export class TypeExtra {
146
248
  this.origin = undefined;
147
249
  this.keyPropertyName = '';
148
250
  this.constituentMap = undefined;
149
- this.constituentSet = undefined;
251
+ this.constituentIds = undefined;
150
252
  this.membershipTests = 0;
151
253
  this.uniqueLiteralFilledInstantiation = undefined;
152
254
  }
@@ -635,19 +737,43 @@ export class EvolvingArrayType extends ObjectType {
635
737
  this.finalArrayType = undefined;
636
738
  }
637
739
  }
638
- export class UnionOrIntersectionType extends StructuredType {
740
+ /**
741
+ * A union or intersection. Few have their members resolved or their properties cached, so those
742
+ * live in `membersOf` (`UnionOrIntersectionMembers`), which is created when they are first written.
743
+ */
744
+ export class UnionOrIntersectionType extends Type {
639
745
  types;
640
- propertyCache;
641
- propertyCacheWithoutFunctionPropertyAugment;
642
- resolvedProperties;
746
+ membersOf;
643
747
  constructor(flags, objectFlags, id, types) {
644
748
  super(flags, objectFlags, id, undefined);
645
749
  this.types = types;
750
+ this.membersOf = undefined;
751
+ }
752
+ }
753
+ /**
754
+ * The resolved members of a union or intersection (`membersHolder`) and the caches of its
755
+ * properties, created on first use.
756
+ */
757
+ export class UnionOrIntersectionMembers extends StructuredType {
758
+ propertyCache;
759
+ propertyCacheWithoutFunctionPropertyAugment;
760
+ resolvedProperties;
761
+ constructor(flags, id) {
762
+ super(flags, 0 /* ObjectFlags.None */, id, undefined);
646
763
  this.propertyCache = undefined;
647
764
  this.propertyCacheWithoutFunctionPropertyAugment = undefined;
648
765
  this.resolvedProperties = undefined;
649
766
  }
650
767
  }
768
+ /** The members holder of a union or intersection, created if it has none yet. */
769
+ export function unionOrIntersectionMembers(t) {
770
+ let members = t.membersOf;
771
+ if (members === undefined) {
772
+ members = new UnionOrIntersectionMembers(t.flags, t.id);
773
+ t.membersOf = members;
774
+ }
775
+ return members;
776
+ }
651
777
  /** A union; all of its own fields are rarely set and live in `extra`. */
652
778
  export class UnionType extends UnionOrIntersectionType {
653
779
  constructor(objectFlags, id, types) {
@@ -695,14 +821,18 @@ export class UnionType extends UnionOrIntersectionType {
695
821
  if (map !== undefined || this.extra !== undefined)
696
822
  typeExtra(this).constituentMap = map;
697
823
  }
698
- /** The constituents of a large union, for membership tests; created on the second test. */
699
- get constituentSet() {
824
+ /**
825
+ * A hash table of the ids of a large union's constituents, for membership tests; created on the
826
+ * second test (`constituentTable`). About eight bytes a constituent, where a set of them took
827
+ * about five times that.
828
+ */
829
+ get constituentIds() {
700
830
  const extra = this.extra;
701
- return extra !== undefined ? extra.constituentSet : undefined;
831
+ return extra !== undefined ? extra.constituentIds : undefined;
702
832
  }
703
- set constituentSet(set) {
704
- if (set !== undefined || this.extra !== undefined)
705
- typeExtra(this).constituentSet = set;
833
+ set constituentIds(ids) {
834
+ if (ids !== undefined || this.extra !== undefined)
835
+ typeExtra(this).constituentIds = ids;
706
836
  }
707
837
  get membershipTests() {
708
838
  const extra = this.extra;
@@ -1111,6 +1241,40 @@ export class ArrayTypeMapper extends TypeMapper {
1111
1241
  mapsThisOnly() {
1112
1242
  return this.sources.length === 1 && isThisTypeParameter(this.sources[0]);
1113
1243
  }
1244
+ /** The number of targets, one per source. */
1245
+ targetCount() {
1246
+ return this.targets.length;
1247
+ }
1248
+ /** The target of the source at `index`. */
1249
+ targetAt(index) {
1250
+ return this.targets[index];
1251
+ }
1252
+ }
1253
+ /**
1254
+ * The mapper of a type reference's members: its type arguments, then the reference itself for the
1255
+ * last source, the class or interface's `this` type. `targets` holds the type arguments only, so the
1256
+ * reference's own list serves without a copy that adds the reference.
1257
+ */
1258
+ export class ThisArgumentTypeMapper extends ArrayTypeMapper {
1259
+ thisTarget;
1260
+ constructor(sources, typeArguments, thisTarget) {
1261
+ super(sources, typeArguments);
1262
+ this.thisTarget = thisTarget;
1263
+ }
1264
+ map(type) {
1265
+ const sources = this.sources;
1266
+ const last = sources.length - 1;
1267
+ for (let i = 0; i < last; i++)
1268
+ if (type === sources[i])
1269
+ return this.targets[i];
1270
+ return type === sources[last] ? this.thisTarget : type;
1271
+ }
1272
+ targetCount() {
1273
+ return this.targets.length + 1;
1274
+ }
1275
+ targetAt(index) {
1276
+ return index < this.targets.length ? this.targets[index] : this.thisTarget;
1277
+ }
1114
1278
  }
1115
1279
  /**
1116
1280
  * The number of sources from which a mapper looks types up in an index. A tuple reference with thousands of
@@ -1178,6 +1342,19 @@ export function newTypeMapper(sources, targets) {
1178
1342
  ? new IndexedArrayTypeMapper(sources, targets)
1179
1343
  : new ArrayTypeMapper(sources, targets);
1180
1344
  }
1345
+ /** `newTypeMapper(sources, [...typeArguments, thisTarget])`, without building that list where it can. */
1346
+ export function newThisArgumentTypeMapper(sources, typeArguments, thisTarget) {
1347
+ if (sources.length === 1)
1348
+ return new SimpleTypeMapper(sources[0], thisTarget);
1349
+ if (sources.length >= indexedTypeMapperThreshold) {
1350
+ const targets = [];
1351
+ for (const t of typeArguments)
1352
+ targets.push(t);
1353
+ targets.push(thisTarget);
1354
+ return new IndexedArrayTypeMapper(sources, targets);
1355
+ }
1356
+ return new ThisArgumentTypeMapper(sources, typeArguments, thisTarget);
1357
+ }
1181
1358
  export function mergeTypeMappers(m1, m2) {
1182
1359
  return m1 !== undefined ? new MergedTypeMapper(m1, m2) : m2;
1183
1360
  }
@@ -1,7 +1,7 @@
1
1
  import { type Node, type SourceFile } from './ast.js';
2
2
  import { type Checker } from './checker.js';
3
- import { type Symbol } from './symbol.js';
4
3
  import type { Type } from './checker-types.js';
4
+ import { type Symbol } from './symbol.js';
5
5
  /** Whether `node` is only written, as the target of `=` or of a for-in/of initializer. */
6
6
  export declare function isWriteOnlyAccess(node: Node): boolean;
7
7
  /** Whether `node` is written, possibly also read. */
@@ -7,7 +7,6 @@ import { isAmbientModule, isAssignmentOperator, isGlobalScopeAugmentation, isTyp
7
7
  import { getCombinedNodeFlags, getModifierFlags, getRootDeclaration, getSourceFileOfNode, hasSyntacticModifier, isExternalOrCommonJSModule, isParameterPropertyDeclaration, } from './binder-utilities.js';
8
8
  import { createDiagnosticForNode } from './checker.js';
9
9
  import { Diagnostic } from './diagnostics.js';
10
- import { getSymbolId } from './symbol.js';
11
10
  import { getMergedSymbol, getSymbolOfDeclaration } from './checker-symbols.js';
12
11
  import { getResolvedSymbol } from './checker-expressions.js';
13
12
  import { skipTrivia } from './scanner.js';
@@ -17,6 +16,7 @@ import { symbolToString } from './type-printer.js';
17
16
  import { getLiteralTypeFromPropertyName } from './checker-type-operators.js';
18
17
  import { getPropertyOfType } from './checker-members.js';
19
18
  import { getPropertyNameFromType, isTypeUsableAsPropertyName } from './checker-utilities.js';
19
+ import { getDeclarations, getSymbolId } from './symbol.js';
20
20
  // ---- References
21
21
  /** Whether `node` is only written, as the target of `=` or of a for-in/of initializer. */
22
22
  export function isWriteOnlyAccess(node) {
@@ -342,7 +342,7 @@ function checkUnusedLocalsAndParameters(c, node) {
342
342
  local.exportSymbol !== undefined ||
343
343
  (local.flags & 134217728 /* SymbolFlags.ModuleExports */) !== 0)
344
344
  continue;
345
- for (const declaration of local.declarations) {
345
+ for (const declaration of getDeclarations(local)) {
346
346
  switch (declaration.kind) {
347
347
  case 261 /* SyntaxKind.VariableDeclaration */:
348
348
  case 170 /* SyntaxKind.Parameter */:
@@ -513,7 +513,7 @@ function isUnreferencedTypeParameter(c, typeParameter) {
513
513
  return ((referenceKinds & 262144 /* SymbolFlags.TypeParameter */) === 0 && !isIdentifierThatStartsWithUnderscore(getName(typeParameter)));
514
514
  }
515
515
  function allDeclarationsInSameSourceFile(symbol) {
516
- const declarations = symbol.declarations;
516
+ const declarations = getDeclarations(symbol);
517
517
  if (declarations.length <= 1)
518
518
  return true;
519
519
  const file = getSourceFileOfNode(declarations[0]);
@@ -1,11 +1,12 @@
1
1
  import type { DeferredCollisionCheck } from './checker-generated-code.js';
2
2
  import type { EmitHelperFileLinks } from './checker-emit-helpers.js';
3
3
  import type { Node, PatternAmbientModule, SourceFile } from './ast.js';
4
- import { IntLinkTable, LinkTable, SparseLinkTable } from './link-tables.js';
4
+ import { CompactSymbolLinkTable, IntLinkTable, LinkTable, SparseLinkTable } from './link-tables.js';
5
5
  import { Diagnostic, type DiagnosticMessage, Diagnostics } from './diagnostics.js';
6
6
  import { type CompilerOptions, ModuleKind, ScriptTarget } from './options.js';
7
7
  import { CheckFlags, Symbol, SymbolFlags, type SymbolTable } from './symbol.js';
8
- import { IndexInfo, IntrinsicType, LiteralType, MemberNames, NodeLinks, ObjectFlags, ObjectType, Signature, SignatureFlags, SymbolLinks, type Type, TypeFlags, TypeMapper, TypeParameter, TypePredicate, VarianceFlags, TypeListCache, type ConditionalType, type InterfaceType, type TypeChecking } from './checker-types.js';
8
+ import { IndexInfo, IntrinsicType, LiteralType, MemberNames, NodeLinks, ObjectFlags, ObjectType, Signature, SignatureFlags, SymbolLinks, type Type, TypeFlags, TypeMapper, TypeParameter, TypePredicate, VarianceFlags, TypeListCache, TypeListTable, type ConditionalType, type InterfaceType, type TypeChecking } from './checker-types.js';
9
+ import type { ModuleResolution } from './checker-modules.js';
9
10
  import { CheckerNameResolver, type LibGlobals, type MergedGlobals, TableChanges, SuggestionNameResolver } from './checker-symbols.js';
10
11
  import { Relation, RelationKey, type InternedRelationKey, type Relater, TypeComparer } from './relations.js';
11
12
  import { TypeNodeVisitor } from './checker-source-file.js';
@@ -15,11 +16,11 @@ import type { FlowNode, FlowReduceLabel } from './flow.js';
15
16
  import { JsxState } from './checker-jsx.js';
16
17
  import type { DeferredIterationError, IterationTypes } from './checker-iteration.js';
17
18
  import type { SpreadIndices } from './checker-contextual.js';
18
- import type { SlotSiblingProperties } from './checker-symbol-types.js';
19
19
  import { SourceFileMetadata } from './program-utilities.js';
20
20
  import type { GrammarChecker } from './checker-grammar.js';
21
21
  import type { ResolvedModule } from './module-resolution-types.js';
22
22
  import type { ModuleSpecifierHost } from './module-specifiers.js';
23
+ import type { PropertyListIndex } from './checker-members.js';
23
24
  /** What the checker needs from a program. */
24
25
  export declare abstract class CheckerHost {
25
26
  abstract getCompilerOptions(): CompilerOptions;
@@ -77,6 +78,21 @@ declare class DiagnosticCollection {
77
78
  }
78
79
  /** Maximum depth of nested `typeToString` calls before diagnostics are discarded. */
79
80
  export declare const maxSerializationLevel = 2;
81
+ /**
82
+ * File positions per symbol id in `ExternalModuleContainerIndex.keys`. Symbol ids are int32, so the
83
+ * keys stay exact.
84
+ */
85
+ export declare const fileIndexScale: number;
86
+ /** The modules that export each symbol, built once from every module's exports. */
87
+ export declare class ExternalModuleContainerIndex {
88
+ complete: boolean;
89
+ /**
90
+ * One key per symbol and module that exports it, ascending: the id of the symbol the export
91
+ * resolves to times `fileIndexScale`, plus the module's file position in `Checker.files`. The
92
+ * keys of one symbol are contiguous and in program order.
93
+ */
94
+ keys: number[];
95
+ }
80
96
  /** The checker's caches for symbol accessibility. */
81
97
  export declare class SymbolAccessibilityCaches {
82
98
  /** Accessible chains by symbol id, then by `chainCacheKey`. */
@@ -87,6 +103,8 @@ export declare class SymbolAccessibilityCaches {
87
103
  readonly containersByFile: Map<number, Map<number, Symbol[]>>;
88
104
  /** All modules that export a symbol, by symbol id. */
89
105
  readonly containers: Map<number, Symbol[]>;
106
+ /** The modules each symbol is exported from, built on the first search of all modules. */
107
+ externalModuleContainers: ExternalModuleContainerIndex | undefined;
90
108
  /** The name tables of named class expressions, by node id. */
91
109
  readonly classExpressionNames: Map<number, SymbolTable>;
92
110
  /** Computed declaration visibility by node id (see isDeclarationVisible), 0 if not computed. */
@@ -135,6 +153,15 @@ export declare class Checker implements TypeChecking {
135
153
  currentNode: Node | undefined;
136
154
  readonly diagnostics: DiagnosticCollection;
137
155
  readonly suggestionDiagnostics: DiagnosticCollection;
156
+ /** Diagnostics and suggestions reported so far, whether kept or not (`resolveExternalModule`'s cache). */
157
+ reports: number;
158
+ /** `resolveExternalModule` results that reported nothing, by module specifier (checker-modules.ts). */
159
+ readonly moduleResolutions: Map<Node, ModuleResolution>;
160
+ /**
161
+ * Whether ambient modules and module augmentations are merged. Merging can give a module a new
162
+ * merged symbol, so `resolveExternalModule` keeps results only from then on.
163
+ */
164
+ modulesMerged: boolean;
138
165
  /** Module specifiers of `import("…")` types, by module symbol id, importing file path and resolution mode. */
139
166
  readonly moduleSpecifiers: Map<string, string>;
140
167
  /** Specifier generation for hosts without a program. */
@@ -145,6 +172,11 @@ export declare class Checker implements TypeChecking {
145
172
  readonly sideHolders: LinkTable<Type>;
146
173
  /** The same for signatures with side state (`signatureSideOf`), by signature id. */
147
174
  readonly signatureSideHolders: LinkTable<Signature>;
175
+ /**
176
+ * The indexes of long property lists that `propertiesRelatedTo` walks; before a list is indexed, its uses
177
+ * so far; null where a list repeats a name.
178
+ */
179
+ readonly propertyListIndexes: Map<Symbol[], number | PropertyListIndex | null>;
148
180
  /** The type of a value symbol. */
149
181
  readonly symbolTypes: LinkTable<Type>;
150
182
  /** For instantiated and synthetic symbols, the symbol they come from. */
@@ -165,7 +197,7 @@ export declare class Checker implements TypeChecking {
165
197
  /** Bits of SymbolFlags for the meanings in which a symbol was referenced. */
166
198
  readonly symbolReferenceKinds: IntLinkTable;
167
199
  /** The resolved symbol of an identifier, entity name or call. */
168
- readonly resolvedSymbols: SparseLinkTable<Symbol>;
200
+ readonly resolvedSymbols: CompactSymbolLinkTable;
169
201
  /** The resolved type of a type node or expression. */
170
202
  readonly resolvedTypes: SparseLinkTable<Type>;
171
203
  /** The resolved signature of a call-like node or a signature declaration. */
@@ -201,10 +233,6 @@ export declare class Checker implements TypeChecking {
201
233
  readonly unresolvedSymbols: Map<string, Symbol>;
202
234
  /** Widening's optional `undefined` properties by the id of the property each is created from. */
203
235
  readonly undefinedProperties: Map<number, Symbol>;
204
- /** By file and name, the property that widening's optional `undefined` properties are created from. */
205
- readonly firstSiblingProperties: Map<SourceFile, Map<string, Node>>;
206
- /** By tsgo checker, the first sibling properties of its files (firstSiblingProperty). */
207
- readonly slotSiblingProperties: Map<number, SlotSiblingProperties>;
208
236
  readonly stringLiteralTypes: Map<string, LiteralType>;
209
237
  readonly numberLiteralTypes: Map<number, LiteralType>;
210
238
  readonly bigintLiteralTypes: Map<string, LiteralType>;
@@ -222,6 +250,8 @@ export declare class Checker implements TypeChecking {
222
250
  readonly templateLiteralTypes: Map<string, Type>;
223
251
  /** Instantiations of template literal types: the instantiated types, tagged with the template's id. */
224
252
  readonly templateLiteralInstantiations: TypeListCache<Type>;
253
+ /** The type argument lists that references and instantiations keep, one of each (`TypeListTable`). */
254
+ readonly typeLists: TypeListTable;
225
255
  readonly stringMappingTypes: Map<string, Type>;
226
256
  readonly substitutionTypes: Map<string, Type>;
227
257
  readonly subtypeReductionCache: TypeListCache<Type[]>;
@@ -347,6 +377,13 @@ export declare class Checker implements TypeChecking {
347
377
  */
348
378
  readonly freeMapperCaches: Map<number, Type>[];
349
379
  freeMapperCacheCount: number;
380
+ /** Empty lists for type arguments that are compared with cached instantiations before any is kept. */
381
+ readonly freeTypeLists: Type[][];
382
+ /**
383
+ * 1 by type id for the anonymous and mapped types whose declaration has no outer type parameters
384
+ * to instantiate (`getObjectTypeInstantiation`).
385
+ */
386
+ readonly withoutOuterTypeParameters: IntLinkTable;
350
387
  conditionalConstraintDepth: number;
351
388
  readonly suggestionResolver: SuggestionNameResolver;
352
389
  readonly awaitedTypeStack: number[];
@@ -1,10 +1,10 @@
1
1
  import { sideOf } from './side-state.js';
2
- import { IntLinkTable, LinkTable, SparseLinkTable } from './link-tables.js';
2
+ import { CompactSymbolLinkTable, IntLinkTable, LinkTable, SparseLinkTable } from './link-tables.js';
3
3
  import { getErrorRangeForNode, getSourceFileOfNode } from './binder-utilities.js';
4
4
  import { Diagnostic, compareDiagnostics } from './diagnostics.js';
5
5
  import { ModuleKind, ScriptTarget, getEmitScriptTarget, getIsolatedModules, getStrictOptionValue, shouldPreserveConstEnums, } from './options.js';
6
6
  import { Symbol, getSymbolId } from './symbol.js';
7
- import { IndexInfo, IntrinsicType, LiteralType, NodeLinks, Signature, SymbolLinks, TypeParameter, TypePredicate, emptyTypes, TypeListCache, } from './checker-types.js';
7
+ import { IndexInfo, IntrinsicType, LiteralType, NodeLinks, Signature, SymbolLinks, TypeParameter, TypePredicate, emptyTypes, TypeListCache, TypeListTable, } from './checker-types.js';
8
8
  import { getBaseTypes } from './checker-declared-types.js';
9
9
  import { getFalseTypeFromConditionalType, getTrueTypeFromConditionalType } from './checker-type-operators.js';
10
10
  import { createArrayType, createTypeFromGenericGlobalType, getBigIntLiteralType, getNumberLiteralType, getStringLiteralType, getTemplateLiteralType, getUnionType, newAnonymousType, newObjectType, } from './checker-type-factory.js';
@@ -154,6 +154,21 @@ function stableSort(list) {
154
154
  }
155
155
  /** Maximum depth of nested `typeToString` calls before diagnostics are discarded. */
156
156
  export const maxSerializationLevel = 2;
157
+ /**
158
+ * File positions per symbol id in `ExternalModuleContainerIndex.keys`. Symbol ids are int32, so the
159
+ * keys stay exact.
160
+ */
161
+ export const fileIndexScale = 2 ** 21;
162
+ /** The modules that export each symbol, built once from every module's exports. */
163
+ export class ExternalModuleContainerIndex {
164
+ complete = false;
165
+ /**
166
+ * One key per symbol and module that exports it, ascending: the id of the symbol the export
167
+ * resolves to times `fileIndexScale`, plus the module's file position in `Checker.files`. The
168
+ * keys of one symbol are contiguous and in program order.
169
+ */
170
+ keys = [];
171
+ }
157
172
  /** The checker's caches for symbol accessibility. */
158
173
  export class SymbolAccessibilityCaches {
159
174
  /** Accessible chains by symbol id, then by `chainCacheKey`. */
@@ -164,6 +179,8 @@ export class SymbolAccessibilityCaches {
164
179
  containersByFile = new Map();
165
180
  /** All modules that export a symbol, by symbol id. */
166
181
  containers = new Map();
182
+ /** The modules each symbol is exported from, built on the first search of all modules. */
183
+ externalModuleContainers = undefined;
167
184
  /** The name tables of named class expressions, by node id. */
168
185
  classExpressionNames = new Map();
169
186
  /** Computed declaration visibility by node id (see isDeclarationVisible), 0 if not computed. */
@@ -213,6 +230,15 @@ export class Checker {
213
230
  currentNode = undefined;
214
231
  diagnostics = new DiagnosticCollection();
215
232
  suggestionDiagnostics = new DiagnosticCollection();
233
+ /** Diagnostics and suggestions reported so far, whether kept or not (`resolveExternalModule`'s cache). */
234
+ reports = 0;
235
+ /** `resolveExternalModule` results that reported nothing, by module specifier (checker-modules.ts). */
236
+ moduleResolutions = new Map();
237
+ /**
238
+ * Whether ambient modules and module augmentations are merged. Merging can give a module a new
239
+ * merged symbol, so `resolveExternalModule` keeps results only from then on.
240
+ */
241
+ modulesMerged = false;
216
242
  /** Module specifiers of `import("…")` types, by module symbol id, importing file path and resolution mode. */
217
243
  moduleSpecifiers = new Map();
218
244
  /** Specifier generation for hosts without a program. */
@@ -226,6 +252,11 @@ export class Checker {
226
252
  sideHolders = new LinkTable();
227
253
  /** The same for signatures with side state (`signatureSideOf`), by signature id. */
228
254
  signatureSideHolders = new LinkTable();
255
+ /**
256
+ * The indexes of long property lists that `propertiesRelatedTo` walks; before a list is indexed, its uses
257
+ * so far; null where a list repeats a name.
258
+ */
259
+ propertyListIndexes = new Map();
229
260
  /** The type of a value symbol. */
230
261
  symbolTypes = new LinkTable();
231
262
  /** For instantiated and synthetic symbols, the symbol they come from. */
@@ -246,7 +277,7 @@ export class Checker {
246
277
  /** Bits of SymbolFlags for the meanings in which a symbol was referenced. */
247
278
  symbolReferenceKinds = new IntLinkTable();
248
279
  /** The resolved symbol of an identifier, entity name or call. */
249
- resolvedSymbols = new SparseLinkTable();
280
+ resolvedSymbols = new CompactSymbolLinkTable();
250
281
  /** The resolved type of a type node or expression. */
251
282
  resolvedTypes = new SparseLinkTable();
252
283
  /** The resolved signature of a call-like node or a signature declaration. */
@@ -283,10 +314,6 @@ export class Checker {
283
314
  unresolvedSymbols = new Map();
284
315
  /** Widening's optional `undefined` properties by the id of the property each is created from. */
285
316
  undefinedProperties = new Map();
286
- /** By file and name, the property that widening's optional `undefined` properties are created from. */
287
- firstSiblingProperties = new Map();
288
- /** By tsgo checker, the first sibling properties of its files (firstSiblingProperty). */
289
- slotSiblingProperties = new Map();
290
317
  // Interning tables.
291
318
  stringLiteralTypes = new Map();
292
319
  numberLiteralTypes = new Map();
@@ -305,6 +332,8 @@ export class Checker {
305
332
  templateLiteralTypes = new Map();
306
333
  /** Instantiations of template literal types: the instantiated types, tagged with the template's id. */
307
334
  templateLiteralInstantiations = new TypeListCache();
335
+ /** The type argument lists that references and instantiations keep, one of each (`TypeListTable`). */
336
+ typeLists = new TypeListTable();
308
337
  stringMappingTypes = new Map();
309
338
  substitutionTypes = new Map();
310
339
  subtypeReductionCache = new TypeListCache();
@@ -436,6 +465,13 @@ export class Checker {
436
465
  */
437
466
  freeMapperCaches = [];
438
467
  freeMapperCacheCount = 0;
468
+ /** Empty lists for type arguments that are compared with cached instantiations before any is kept. */
469
+ freeTypeLists = [];
470
+ /**
471
+ * 1 by type id for the anonymous and mapped types whose declaration has no outer type parameters
472
+ * to instantiate (`getObjectTypeInstantiation`).
473
+ */
474
+ withoutOuterTypeParameters = new IntLinkTable();
439
475
  conditionalConstraintDepth = 0;
440
476
  suggestionResolver;
441
477
  awaitedTypeStack = [];
@@ -718,6 +754,7 @@ export class Checker {
718
754
  this.diagnostics.startLog();
719
755
  this.suggestionDiagnostics.startLog();
720
756
  mergeAmbientModulesAndAugmentations(this);
757
+ this.modulesMerged = true;
721
758
  this.mergeDiagnostics.push(this.diagnostics.takeLog(), this.suggestionDiagnostics.takeLog());
722
759
  }
723
760
  // ---- Public API
@@ -808,11 +845,13 @@ export class Checker {
808
845
  return diagnostic;
809
846
  }
810
847
  addDiagnostic(diagnostic) {
848
+ this.reports++;
811
849
  // Discard diagnostics created while at the maximum number of nested typeToString calls.
812
850
  if (this.serializationLevel < maxSerializationLevel)
813
851
  this.diagnostics.add(diagnostic);
814
852
  }
815
853
  addSuggestion(diagnostic) {
854
+ this.reports++;
816
855
  this.suggestionDiagnostics.add(diagnostic);
817
856
  }
818
857
  /** Reports an error, or a suggestion when `isError` is false. */
@@ -858,8 +897,6 @@ export function disposeChecker(c) {
858
897
  c.symbolAccessibilityCaches = undefined;
859
898
  c.unresolvedSymbols.clear();
860
899
  c.undefinedProperties.clear();
861
- c.firstSiblingProperties.clear();
862
- c.slotSiblingProperties.clear();
863
900
  c.stringLiteralTypes.clear();
864
901
  c.numberLiteralTypes.clear();
865
902
  c.bigintLiteralTypes.clear();