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
@@ -1,4 +1,5 @@
1
1
  import { FunctionDeclaration, Identifier, type Node, NodeList, SourceFile } from '../ast.js';
2
+ import { ClusteredLinkTable } from '../link-tables.js';
2
3
  import { SyntaxKind } from '../syntax-kind.js';
3
4
  import { EmitFlags } from './emit-flags.js';
4
5
  import { AutoGenerateInfo } from './auto-generate.js';
@@ -54,8 +55,10 @@ export { AutoGenerateInfo, newAutoGenerateId } from './auto-generate.js';
54
55
  export declare class EmitContext extends NodeFactory {
55
56
  readonly autoGenerate: Map<Node, AutoGenerateInfo>;
56
57
  readonly textSource: Map<Node, Node>;
57
- readonly original: Map<Node, Node>;
58
- readonly emitNodes: Map<Node, EmitNode>;
58
+ /** The node each node was made from, by node id. */
59
+ readonly original: ClusteredLinkTable<Node>;
60
+ /** The emit data of nodes, by node id. */
61
+ readonly emitNodes: ClusteredLinkTable<EmitNode>;
59
62
  private lastLookup;
60
63
  private lastEmitNode;
61
64
  readonly assignedNames: Map<Node, Node>;
@@ -1,6 +1,7 @@
1
1
  // Side tables that transforms fill in and the printer reads: original nodes, emit flags,
2
2
  // comment and source map ranges, synthesized comments, generated names and emit helpers.
3
3
  import { ExpressionStatement, FunctionDeclaration, Identifier, NodeList, PrivateIdentifier, StringLiteral, VariableDeclaration, VariableStatement, } from '../ast.js';
4
+ import { ClusteredLinkTable } from '../link-tables.js';
4
5
  import { NodeFactory } from './factory.js';
5
6
  import { isParseTreeNode, isPrologueDirective } from './utilities.js';
6
7
  export { EmitHelper, compareEmitHelpers, noPriority } from './helpers.js';
@@ -90,7 +91,9 @@ export { AutoGenerateInfo, newAutoGenerateId } from './auto-generate.js';
90
91
  export class EmitContext extends NodeFactory {
91
92
  autoGenerate;
92
93
  textSource;
94
+ /** The node each node was made from, by node id. */
93
95
  original;
96
+ /** The emit data of nodes, by node id. */
94
97
  emitNodes;
95
98
  lastLookup;
96
99
  lastEmitNode;
@@ -104,8 +107,8 @@ export class EmitContext extends NodeFactory {
104
107
  super();
105
108
  this.autoGenerate = new Map();
106
109
  this.textSource = new Map();
107
- this.original = new Map();
108
- this.emitNodes = new Map();
110
+ this.original = new ClusteredLinkTable();
111
+ this.emitNodes = new ClusteredLinkTable();
109
112
  this.lastLookup = undefined;
110
113
  this.lastEmitNode = undefined;
111
114
  this.assignedNames = new Map();
@@ -138,7 +141,7 @@ export class EmitContext extends NodeFactory {
138
141
  let emitNode = this.lookup(node);
139
142
  if (emitNode === undefined) {
140
143
  emitNode = new EmitNode();
141
- this.emitNodes.set(node, emitNode);
144
+ this.emitNodes.set(node.id, emitNode);
142
145
  this.lastLookup = node;
143
146
  this.lastEmitNode = emitNode;
144
147
  }
@@ -148,7 +151,7 @@ export class EmitContext extends NodeFactory {
148
151
  lookup(node) {
149
152
  if (node === this.lastLookup)
150
153
  return this.lastEmitNode;
151
- const emitNode = this.emitNodes.get(node);
154
+ const emitNode = this.emitNodes.get(node.id);
152
155
  this.lastLookup = node;
153
156
  this.lastEmitNode = emitNode;
154
157
  return emitNode;
@@ -158,30 +161,33 @@ export class EmitContext extends NodeFactory {
158
161
  this.setOriginalEx(node, original, false);
159
162
  }
160
163
  setOriginalEx(node, original, allowOverwrite) {
161
- const existing = this.original.get(node);
164
+ const existing = this.original.get(node.id);
162
165
  if (existing === undefined) {
163
- this.original.set(node, original);
166
+ this.original.set(node.id, original);
164
167
  const emitNode = this.lookup(original);
165
168
  if (emitNode !== undefined)
166
169
  this.emitNode(node).copyFrom(emitNode);
167
170
  }
168
171
  else if (allowOverwrite)
169
- this.original.set(node, original);
172
+ this.original.set(node.id, original);
170
173
  else if (existing !== original)
171
174
  throw new Error('Original node already set.');
172
175
  }
173
176
  unsetOriginal(node) {
174
- return this.original.delete(node);
177
+ if (this.original.get(node.id) === undefined)
178
+ return false;
179
+ this.original.set(node.id, undefined);
180
+ return true;
175
181
  }
176
182
  getOriginal(node) {
177
- return this.original.get(node);
183
+ return this.original.get(node.id);
178
184
  }
179
185
  /** The node at the end of the chain of original nodes. */
180
186
  mostOriginal(node) {
181
- let original = this.original.get(node);
187
+ let original = this.original.get(node.id);
182
188
  while (original !== undefined) {
183
189
  node = original;
184
- original = this.original.get(node);
190
+ original = this.original.get(node.id);
185
191
  }
186
192
  return node;
187
193
  }
@@ -204,7 +210,7 @@ export class EmitContext extends NodeFactory {
204
210
  return name;
205
211
  let node = info.node;
206
212
  const id = info.id;
207
- let original = this.original.get(node);
213
+ let original = this.original.get(node.id);
208
214
  while (original !== undefined) {
209
215
  node = original;
210
216
  if (node instanceof Identifier || node instanceof PrivateIdentifier) {
@@ -217,7 +223,7 @@ export class EmitContext extends NodeFactory {
217
223
  continue;
218
224
  }
219
225
  }
220
- original = this.original.get(node);
226
+ original = this.original.get(node.id);
221
227
  }
222
228
  return node;
223
229
  }
@@ -1,5 +1,5 @@
1
1
  // Generated by scripts/generate-visitor.mjs; do not edit.
2
- import { ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocDeprecatedTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocNameReference, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocOverloadTag, JSDocOverrideTag, JSDocParameterOrPropertyTag, JSDocPrivateTag, JSDocProtectedTag, JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, JSDocThrowsTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypeTag, JSDocTypedefTag, JSDocUnknownTag, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxSelfClosingElement, JsxSpreadAttribute, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NonNullExpression, ObjectLiteralExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, RestTypeNode, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, SpreadAssignment, SpreadElement, SwitchStatement, SyntaxList, SyntheticReferenceExpression, TaggedTemplateExpression, TemplateExpression, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateSpan, ThrowStatement, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, } from '../ast.js';
2
+ import { ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocDeprecatedTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocNameReference, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocOverloadTag, JSDocOverrideTag, JSDocParameterOrPropertyTag, JSDocPrivateTag, JSDocProtectedTag, JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, JSDocThrowsTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypeTag, JSDocTypedefTag, JSDocUnknownTag, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxSelfClosingElement, JsxSpreadAttribute, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NonNullExpression, ObjectLiteralExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAccessExpression, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, RestTypeNode, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, SpreadAssignment, SpreadElement, SwitchStatement, SyntaxList, SyntheticReferenceExpression, TaggedTemplateExpression, TemplateExpression, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateSpan, ThrowStatement, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, propertyAssignmentPostfixToken, propertyAssignmentType, callQuestionDotToken, propertyAssignmentModifiers, callTypeArguments, newCallExpression, newPropertyAssignment, } from '../ast.js';
3
3
  /** `update*` functions: return the node if no child changed, else a copy with the node's flags, range and original. */
4
4
  export class NodeFactoryBase {
5
5
  updateArrayLiteralExpression(node, elements, multiLine) {
@@ -97,11 +97,11 @@ export class NodeFactoryBase {
97
97
  }
98
98
  updateCallExpression(node, expression, questionDotToken, typeArguments, args, flags) {
99
99
  if (expression !== node.expression ||
100
- questionDotToken !== node.questionDotToken ||
101
- typeArguments !== node.typeArguments ||
100
+ questionDotToken !== callQuestionDotToken(node) ||
101
+ typeArguments !== callTypeArguments(node) ||
102
102
  args !== node.arguments ||
103
103
  flags !== node.flags) {
104
- const updated = new CallExpression(expression, questionDotToken, typeArguments, args, flags);
104
+ const updated = newCallExpression(expression, questionDotToken, typeArguments, args, flags, false);
105
105
  this.finishUpdate(updated, node);
106
106
  return updated;
107
107
  }
@@ -1154,12 +1154,12 @@ export class NodeFactoryBase {
1154
1154
  return node;
1155
1155
  }
1156
1156
  updatePropertyAssignment(node, modifiers, name, postfixToken, typeNode, initializer) {
1157
- if (modifiers !== node.modifiers ||
1157
+ if (modifiers !== propertyAssignmentModifiers(node) ||
1158
1158
  name !== node.name ||
1159
- postfixToken !== node.postfixToken ||
1160
- typeNode !== node.type ||
1159
+ postfixToken !== propertyAssignmentPostfixToken(node) ||
1160
+ typeNode !== propertyAssignmentType(node) ||
1161
1161
  initializer !== node.initializer) {
1162
- const updated = new PropertyAssignment(modifiers, name, postfixToken, typeNode, initializer);
1162
+ const updated = newPropertyAssignment(modifiers, name, postfixToken, typeNode, initializer, false);
1163
1163
  this.finishUpdate(updated, node);
1164
1164
  return updated;
1165
1165
  }
@@ -1,6 +1,6 @@
1
1
  // Creates synthesized nodes for transforms and the printer. Created nodes are flagged
2
2
  // `Synthesized` and have no range; updated nodes keep the original's flags, range and emit data.
3
- import { ArrowFunction, AsExpression, DeleteExpression, ExpressionWithTypeArguments, NonNullExpression, PartiallyEmittedExpression, SatisfiesExpression, SyntheticReferenceExpression, TypeAssertion, BinaryExpression, ElementAccessExpression, FunctionExpression, ObjectLiteralExpression, ParameterDeclaration, PrefixUnaryExpression, PropertyAssignment, QualifiedName, Block, CallExpression, ConditionalExpression, ExpressionStatement, Identifier, IfStatement, KeywordExpression, ModifierList, NodeList, NumericLiteral, ParenthesizedExpression, PrivateIdentifier, PropertyAccessExpression, ReturnStatement, SetAccessorDeclaration, SourceFile, StringLiteral, SyntaxList, Token, TypeOfExpression, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, } from '../ast.js';
3
+ import { ArrowFunction, AsExpression, DeleteExpression, ExpressionWithTypeArguments, NonNullExpression, PartiallyEmittedExpression, SatisfiesExpression, SyntheticReferenceExpression, TypeAssertion, BinaryExpression, ElementAccessExpression, FunctionExpression, ObjectLiteralExpression, ParameterDeclaration, PrefixUnaryExpression, QualifiedName, Block, CallExpression, ConditionalExpression, ExpressionStatement, Identifier, IfStatement, KeywordExpression, ModifierList, NodeList, NumericLiteral, ParenthesizedExpression, PrivateIdentifier, PropertyAccessExpression, ReturnStatement, SetAccessorDeclaration, SourceFile, StringLiteral, SyntaxList, Token, TypeOfExpression, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, newCallExpression, newPropertyAssignment, } from '../ast.js';
4
4
  import { modifierToFlag } from '../ast-utilities.js';
5
5
  import { getNameOfDeclaration, getNonAssignedNameOfDeclaration, hasSyntacticModifier } from '../binder-utilities.js';
6
6
  import { AutoGenerateInfo, newAutoGenerateId } from './auto-generate.js';
@@ -83,7 +83,7 @@ export class NodeFactory extends NodeFactoryBase {
83
83
  return this.created(new PropertyAccessExpression(expression, undefined, name, 0 /* NodeFlags.None */));
84
84
  }
85
85
  createCallExpression(expression, args) {
86
- return this.created(new CallExpression(expression, undefined, undefined, this.createNodeList(args), 0 /* NodeFlags.None */));
86
+ return this.created(newCallExpression(expression, undefined, undefined, this.createNodeList(args), 0 /* NodeFlags.None */, false));
87
87
  }
88
88
  createBinaryExpression(left, operator, right) {
89
89
  return this.created(new BinaryExpression(undefined, left, undefined, this.createToken(operator), right));
@@ -146,7 +146,7 @@ export class NodeFactory extends NodeFactoryBase {
146
146
  return this.created(new ObjectLiteralExpression(this.createNodeList(properties), multiLine));
147
147
  }
148
148
  createPropertyAssignment(name, initializer) {
149
- return this.created(new PropertyAssignment(undefined, name, undefined, undefined, initializer));
149
+ return this.created(newPropertyAssignment(undefined, name, undefined, undefined, initializer, false));
150
150
  }
151
151
  createParameter(name) {
152
152
  return this.created(new ParameterDeclaration(undefined, undefined, name, undefined, undefined, undefined));
@@ -362,7 +362,7 @@ export class NodeFactory extends NodeFactoryBase {
362
362
  createMethodCall(object, method, args) {
363
363
  const callee = this.createPropertyAccessExpression(object, this.createIdentifier(method));
364
364
  const flags = object instanceof CallExpression ? object.flags & 32 /* NodeFlags.OptionalChain */ : 0 /* NodeFlags.None */;
365
- return this.created(new CallExpression(callee, undefined, undefined, this.createNodeList(args), flags));
365
+ return this.created(newCallExpression(callee, undefined, undefined, this.createNodeList(args), flags, false));
366
366
  }
367
367
  /** `Global.method(...args)`, such as `Math.pow(a, b)`. */
368
368
  createGlobalMethodCall(global, method, args) {
@@ -1,6 +1,6 @@
1
1
  // Prints syntax trees as source text the way tsgo's printer does: formatting, comments,
2
2
  // source maps, generated names and emit helpers.
3
- import { ArrayLiteralExpression, ArrowFunction, AsExpression, AwaitExpression, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NonNullExpression, NumericLiteral, ObjectLiteralExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, RestTypeNode, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringLiteral, SwitchStatement, TaggedTemplateExpression, TemplateExpression, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateSpan, ThrowStatement, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, ArrayTypeNode, getName, getParameters, getTypeParameters, getTypeArguments, getArguments, getElements, getProperties, getStatements, getModifiers, } from '../ast.js';
3
+ import { ArrayLiteralExpression, ArrowFunction, AsExpression, AwaitExpression, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NonNullExpression, NumericLiteral, ObjectLiteralExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, RestTypeNode, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringLiteral, SwitchStatement, TaggedTemplateExpression, TemplateExpression, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateSpan, ThrowStatement, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, ArrayTypeNode, getName, getParameters, getTypeParameters, getTypeArguments, getArguments, getElements, getProperties, getStatements, getModifiers, callQuestionDotToken, callTypeArguments, } from '../ast.js';
4
4
  import { computeLineOfPosition, computeLineStarts, getLeadingCommentRanges, getShebang, getTrailingCommentRanges, skipTrivia, tokenToString, } from '../scanner.js';
5
5
  import { ScriptTarget } from '../options.js';
6
6
  import { fileExtensionIs } from '../path.js';
@@ -1728,8 +1728,8 @@ export class Printer extends NameGeneratorHost {
1728
1728
  emitCallExpression(node) {
1729
1729
  const state = this.enterNode(node);
1730
1730
  this.emitCallee(node.expression, node);
1731
- this.emitOptionalToken(node.questionDotToken);
1732
- this.emitTypeArguments(node, node.typeArguments);
1731
+ this.emitOptionalToken(callQuestionDotToken(node));
1732
+ this.emitTypeArguments(node, callTypeArguments(node));
1733
1733
  this.emitList(13 /* ListItem.Argument */, node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */);
1734
1734
  this.exitNode(node, state);
1735
1735
  return true;
@@ -2094,7 +2094,7 @@ export class Printer extends NameGeneratorHost {
2094
2094
  if (node instanceof ElementAccessExpression)
2095
2095
  return factory.updateElementAccessExpression(node, this.parenthesizeExpressionForNoAsi(node.expression), node.questionDotToken, node.argumentExpression, node.flags);
2096
2096
  if (node instanceof CallExpression)
2097
- return factory.updateCallExpression(node, this.parenthesizeExpressionForNoAsi(node.expression), node.questionDotToken, node.typeArguments, node.arguments, node.flags);
2097
+ return factory.updateCallExpression(node, this.parenthesizeExpressionForNoAsi(node.expression), callQuestionDotToken(node), callTypeArguments(node), node.arguments, node.flags);
2098
2098
  if (node instanceof TaggedTemplateExpression)
2099
2099
  return factory.updateTaggedTemplateExpression(node, this.parenthesizeExpressionForNoAsi(node.tag), node.questionDotToken, node.typeArguments, node.template, node.flags);
2100
2100
  if (node instanceof PostfixUnaryExpression)
@@ -2339,8 +2339,8 @@ export class Printer extends NameGeneratorHost {
2339
2339
  this.write1('(');
2340
2340
  this.emitExpression(call.expression, 0 /* OperatorPrecedence.Lowest */);
2341
2341
  this.write1(')');
2342
- this.emitOptionalToken(call.questionDotToken);
2343
- this.emitTypeArguments(call, call.typeArguments);
2342
+ this.emitOptionalToken(callQuestionDotToken(call));
2343
+ this.emitTypeArguments(call, callTypeArguments(call));
2344
2344
  this.emitList(13 /* ListItem.Argument */, call, call.arguments, 2576 /* ListFormat.CallExpressionArguments */);
2345
2345
  this.exitNode(call, callState);
2346
2346
  }
@@ -24,6 +24,11 @@ import { type SourceFileMetadata } from './program-utilities.js';
24
24
  export declare class ProgramCheckerHost extends CheckerHost {
25
25
  readonly program: Program;
26
26
  private specifierHost;
27
+ /**
28
+ * `getSourceFileForResolvedModule` by resolved file name (null when there is none): every import of
29
+ * a module asks again, and the program finds a file by its path, which it computes from the name.
30
+ */
31
+ private readonly resolvedSourceFiles;
27
32
  constructor(program: Program);
28
33
  getCompilerOptions(): CompilerOptions;
29
34
  getSourceFiles(): readonly SourceFile[];
@@ -9,6 +9,11 @@ import { computeLineOfPosition } from './scanner.js';
9
9
  export class ProgramCheckerHost extends CheckerHost {
10
10
  program;
11
11
  specifierHost = undefined;
12
+ /**
13
+ * `getSourceFileForResolvedModule` by resolved file name (null when there is none): every import of
14
+ * a module asks again, and the program finds a file by its path, which it computes from the name.
15
+ */
16
+ resolvedSourceFiles = new Map();
12
17
  constructor(program) {
13
18
  super();
14
19
  this.program = program;
@@ -26,7 +31,12 @@ export class ProgramCheckerHost extends CheckerHost {
26
31
  return this.program.getResolvedModule(file, moduleName, mode);
27
32
  }
28
33
  getSourceFileForResolvedModule(fileName) {
29
- return this.program.getSourceFileForResolvedModule(fileName);
34
+ const known = this.resolvedSourceFiles.get(fileName);
35
+ if (known !== undefined)
36
+ return known ?? undefined;
37
+ const file = this.program.getSourceFileForResolvedModule(fileName);
38
+ this.resolvedSourceFiles.set(fileName, file ?? null);
39
+ return file;
30
40
  }
31
41
  getModeForUsageLocation(file, location) {
32
42
  return this.program.getModeForUsageLocation(file, location);
@@ -357,6 +367,9 @@ class Directives {
357
367
  byLine = new Map();
358
368
  constructor(file) {
359
369
  this.file = file;
370
+ // Most files have no directives, and need no line starts.
371
+ if (file.commentDirectives.length === 0)
372
+ return;
360
373
  const lineStarts = file.diagnosticFile().getLineStarts();
361
374
  for (const directive of file.commentDirectives) {
362
375
  const line = computeLineOfPosition(lineStarts, directive.pos);
@@ -62,13 +62,21 @@ export class Program {
62
62
  this.programDiagnosticsList.push(diagnostic);
63
63
  for (const path of previous.emitBlockingPaths)
64
64
  this.emitBlockingPaths.add(path);
65
- this.symlinks = previous.symlinks;
65
+ // The files and include reasons it takes from a program shared with checker threads are immutable, and
66
+ // so is that program's symlink cache: this one computes its own then (`getSymlinkCache`).
67
+ this.shared = previous.shared;
68
+ if (!previous.shared)
69
+ this.symlinks = previous.symlinks;
70
+ // The same files are emitted, so the common source directory is the same. Its diagnostics are those
71
+ // `previous` was created with (`IncludeProcessor.copy`).
72
+ this.commonSourceDirectoryValue = previous.commonSourceDirectoryValue;
66
73
  }
67
74
  else {
68
75
  this.processed = (loader ?? new FileLoader(host, commandLine)).load();
69
76
  this.includeProcessor = this.processed.includeProcessor;
70
77
  this.verifyCompilerOptions();
71
78
  }
79
+ this.includeProcessor.noteProgramCreated();
72
80
  }
73
81
  /**
74
82
  * The program with the file at `path` read again from `host` and everything else taken from this program,
@@ -1,12 +1,12 @@
1
1
  import { ModifierFlags, type Node } from './ast.js';
2
2
  import { Diagnostic, type DiagnosticMessage } from './diagnostics.js';
3
- import { type Symbol } from './symbol.js';
4
3
  import { type Checker } from './checker.js';
5
4
  import { type IndexInfo, type MappedType, type Signature, SignatureKind, Ternary, type Type, type UnionType, VarianceFlags } from './checker-types.js';
6
5
  import { typeListKey } from './checker-type-factory.js';
7
6
  import { findApplicableIndexInfo } from './checker-members.js';
8
7
  import { getMergedSymbol } from './checker-symbols.js';
9
8
  import { getPropertyNameFromType } from './checker-utilities.js';
9
+ import { type Symbol } from './symbol.js';
10
10
  export declare const enum RelationComparisonResult {
11
11
  None = 0,
12
12
  Succeeded = 1,
@@ -5,13 +5,12 @@ import { getExpression, getName, getNodeId, getText, } from './ast.js';
5
5
  import { getSymbolNameForPrivateIdentifier } from './binder.js';
6
6
  import { getCombinedModifierFlags } from './binder-utilities.js';
7
7
  import { Diagnostic, messageElidedInCompatibilityPyramid } from './diagnostics.js';
8
- import { getSymbolId } from './symbol.js';
9
8
  import { isContextSensitive } from './checker-functions.js';
10
9
  import { createDiagnosticForNode } from './checker.js';
11
10
  import { cachedTypeKey, emptyTypes, newTypeMapper, SimpleTypeMapper, } from './checker-types.js';
12
11
  import { createInferenceContext, inferTypes } from './checker-inference.js';
13
12
  import { unionContainsSortedTypes, unionContainsType, createArrayTypeEx, compareTypes, containsMissingType, createTypeReference, everyType, filterType, getBaseTypeOfLiteralType, getBaseTypeOfEnumLikeType, getElementTypes, getIntersectionType, getIntersectionTypeEx, getTargetType, getTypeArguments, getTypeReferenceArity, getUnionType, getUnionTypeEx, isArrayOrTupleType, isArrayType, isEmptyAnonymousObjectType, isEmptyObjectType, isErrorType, isFreshLiteralType, isGenericTupleType, isLiteralType, isMutableArrayOrTuple, isReadonlyArrayType, isTupleType, isUnitType, someType, tupleTargetOf, typesOf, countTypes, getStartElementCount, getEndElementCount, createNormalizedTypeReference, typeListKey, getRegularTypeOfLiteralType, } from './checker-type-factory.js';
14
- import { findApplicableIndexInfo, getApparentType, getApplicableIndexInfo, getApplicableIndexInfoForName, getBaseConstraintOfType, getBaseConstraintOrType, getConstraintOfType, getDeclarationModifierFlagsFromSymbol, getIndexInfoOfType, getIndexInfosOfType, getIndexTypeOfType, getPropertiesOfObjectType, getPropertiesOfType, getPropertiesOfUnionOrIntersectionType, getPropertyOfObjectType, getPropertyOfType, getPropertyOfUnionOrIntersectionType, getReducedType, getSignaturesOfStructuredType, getSignaturesOfType, getTargetSymbol, getTypeOfPropertyOfType, getTypeWithThisArgument, getUnionOrIntersectionProperty, isApplicableIndexType, isArrayLikeType, isObjectLiteralType, isDiscriminantWithNeverType, isConflictingPrivateProperty, resolveStructuredTypeMembers, getResolvedMember, hasResolvedProperties, resolvedPropertiesAreOptional, } from './checker-members.js';
13
+ import { findApplicableIndexInfo, getApparentType, getApplicableIndexInfo, getApplicableIndexInfoForName, getBaseConstraintOfType, getBaseConstraintOrType, getConstraintOfType, getDeclarationModifierFlagsFromSymbol, getIndexInfoOfType, getIndexInfosOfType, getIndexTypeOfType, getPropertiesOfObjectType, getPropertiesOfType, getPropertiesOfUnionOrIntersectionType, getPropertyOfObjectType, getPropertyOfType, getPropertyOfUnionOrIntersectionType, getReducedType, getSignaturesOfStructuredType, getSignaturesOfType, getTargetSymbol, getTypeOfPropertyOfType, getTypeWithThisArgument, getUnionOrIntersectionProperty, isApplicableIndexType, isArrayLikeType, isObjectLiteralType, isDiscriminantWithNeverType, isConflictingPrivateProperty, resolveStructuredTypeMembers, getResolvedMember, hasResolvedProperties, resolvedPropertiesAreOptional, positionsOfNamesFoundInSource, firstUnmatchedProperty, } from './checker-members.js';
15
14
  import { getParentOfSymbol, getMergedSymbol, getMembersOfSymbol, getSpellingSuggestionForName, } from './checker-symbols.js';
16
15
  import { CodePoints, distanceToCandidate, utf8Length } from './spelling.js';
17
16
  import { getConstraintFromTypeParameter, getDeclaredTypeOfSymbol, getDefaultOrUnknownFromTypeParameter, fillMissingTypeArguments, getMinTypeArgumentCount, hasBaseType, hasNonCircularBaseConstraint, computeEnumMemberValues, getBaseTypes, getExtendsHeritageClauseElement, } from './checker-declared-types.js';
@@ -23,6 +22,7 @@ import { getConstraintOfDistributiveConditionalType, getDefaultConstraintOfCondi
23
22
  import { getCanonicalSignature, getErasedSignature, getMinArgumentCount, getNonArrayRestType, getNonCircularReturnTypeOfSignature, getParameterCount, getParameterNameAtPosition, getRestOrAnyTypeAtPosition, getReturnTypeOfSignature, getSingleCallSignature, getThisTypeOfSignature, getTypeAtPosition, getTypePredicateOfSignature, hasEffectiveRestParameter, instantiateSignatureInContextOf, isTopSignature, tryGetTypeAtPosition, } from './checker-signatures.js';
24
23
  import { getNonNullableType, getTypeFacts } from './checker-flow.js';
25
24
  import { getPropertyNameFromType, isLateBoundName, isNumericLiteralName, maybeTypeOfKind, } from './checker-utilities.js';
25
+ import { declarationCount, getDeclarations, getSymbolId } from './symbol.js';
26
26
  /**
27
27
  * Cached results of one relation by numeric relation key (see getRelationKey): an open-addressing
28
28
  * table of keys and one-byte results. Keys are never 0 (packed keys are positive, interned ones
@@ -430,8 +430,8 @@ function isEnumTypeRelatedTo(c, source, target, reporter) {
430
430
  c.enumRelation.set(key, 2 /* RelationComparisonResult.Failed */);
431
431
  return false;
432
432
  }
433
- const sourceDecl = sourceProperty.declarations.find((d) => d.kind === 306 /* SyntaxKind.EnumMember */);
434
- const targetDecl = targetProperty.declarations.find((d) => d.kind === 306 /* SyntaxKind.EnumMember */);
433
+ const sourceDecl = getDeclarations(sourceProperty).find((d) => d.kind === 306 /* SyntaxKind.EnumMember */);
434
+ const targetDecl = getDeclarations(targetProperty).find((d) => d.kind === 306 /* SyntaxKind.EnumMember */);
435
435
  if (sourceDecl === undefined || targetDecl === undefined)
436
436
  continue;
437
437
  computeEnumMemberValues(c, sourceDecl.parent);
@@ -933,8 +933,8 @@ export class Relater extends TypeComparer {
933
933
  ]);
934
934
  return true;
935
935
  }
936
- const objectLiteralDeclaration = source.symbol !== undefined && source.symbol.declarations.length !== 0
937
- ? source.symbol.declarations[0]
936
+ const objectLiteralDeclaration = source.symbol !== undefined && declarationCount(source.symbol) !== 0
937
+ ? source.symbol.declaration
938
938
  : undefined;
939
939
  const valueDeclaration = prop.valueDeclaration;
940
940
  let suggestion = undefined;
@@ -2058,7 +2058,12 @@ export class Relater extends TypeComparer {
2058
2058
  !isObjectLiteralType(source) &&
2059
2059
  !isEmptyArrayLiteralType(c, source) &&
2060
2060
  !isTupleType(source);
2061
- const unmatchedProperty = getUnmatchedProperty(c, source, target, requireOptionalProperties, false);
2061
+ const targetProperties = getPropertiesOfType(c, target);
2062
+ // Where it is known which target names the source has, nothing else is looked up by name.
2063
+ const found = positionsOfNamesFoundInSource(c, source, target, targetProperties);
2064
+ const unmatchedProperty = found !== undefined
2065
+ ? firstUnmatchedProperty(c, targetProperties, found, requireOptionalProperties)
2066
+ : getUnmatchedProperty(c, source, target, requireOptionalProperties, false);
2062
2067
  if (unmatchedProperty !== undefined) {
2063
2068
  if (reportErrors && shouldReportUnmatchedPropertyError(c, source, target))
2064
2069
  this.reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
@@ -2079,7 +2084,7 @@ export class Relater extends TypeComparer {
2079
2084
  }
2080
2085
  }
2081
2086
  const numericNamesOnly = isTupleType(source) && isTupleType(target);
2082
- for (const targetProp of getPropertiesOfType(c, target)) {
2087
+ for (const targetProp of found !== undefined ? found.map((i) => targetProperties[i]) : targetProperties) {
2083
2088
  if (excludedProperties !== undefined && excludedProperties.has(targetProp.name))
2084
2089
  continue;
2085
2090
  const name = targetProp.name;
@@ -2202,8 +2207,8 @@ export class Relater extends TypeComparer {
2202
2207
  names[0],
2203
2208
  names[1],
2204
2209
  ]);
2205
- if (unmatchedProperty.declarations.length !== 0)
2206
- this.relatedInfo.push(createDiagnosticForNode(unmatchedProperty.declarations[0], 860 /* Diagnostics.X_0_is_declared_here */, [propName]));
2210
+ if (declarationCount(unmatchedProperty) !== 0)
2211
+ this.relatedInfo.push(createDiagnosticForNode(unmatchedProperty.declaration, 860 /* Diagnostics.X_0_is_declared_here */, [propName]));
2207
2212
  }
2208
2213
  else if (this.tryElaborateArrayLikeErrors(source, target, false)) {
2209
2214
  const names = getTypeNamesForErrorDisplay(c, source, target);
@@ -2547,12 +2552,12 @@ export class Relater extends TypeComparer {
2547
2552
  this.reportRelationError(headMessage, source, target);
2548
2553
  if ((source.flags & 524288 /* TypeFlags.TypeParameter */) !== 0 &&
2549
2554
  source.symbol !== undefined &&
2550
- source.symbol.declarations.length !== 0 &&
2555
+ declarationCount(source.symbol) !== 0 &&
2551
2556
  getConstraintOfType(c, source) === undefined) {
2552
2557
  const syntheticParam = cloneTypeParameter(c, source);
2553
2558
  syntheticParam.constraint = instantiateType(c, target, new SimpleTypeMapper(source, syntheticParam));
2554
2559
  if (hasNonCircularBaseConstraint(c, syntheticParam)) {
2555
- this.relatedInfo.push(createDiagnosticForNode(source.symbol.declarations[0], 473 /* Diagnostics.This_type_parameter_might_need_an_extends_0_constraint */, [typeToString(c, target)]));
2560
+ this.relatedInfo.push(createDiagnosticForNode(source.symbol.declaration, 473 /* Diagnostics.This_type_parameter_might_need_an_extends_0_constraint */, [typeToString(c, target)]));
2556
2561
  }
2557
2562
  }
2558
2563
  }
@@ -3476,7 +3481,7 @@ import { getTypeAliasInstantiation } from './checker-type-nodes.js';
3476
3481
  export function getTypeParameterModifiers(tp) {
3477
3482
  let flags = 0;
3478
3483
  if (tp.symbol !== undefined)
3479
- for (const d of tp.symbol.declarations)
3484
+ for (const d of getDeclarations(tp.symbol))
3480
3485
  flags |= getCombinedModifierFlags(d);
3481
3486
  return flags & (8192 /* ModifierFlags.In */ | 16384 /* ModifierFlags.Out */ | 4096 /* ModifierFlags.Const */);
3482
3487
  }
@@ -6,7 +6,7 @@
6
6
  //
7
7
  // Fields of `instanceof`-narrowed nodes are read through `as` casts: scriptc reads them
8
8
  // statically, but reads fields of a narrowed value dynamically.
9
- import { ArrayTypeNode, ArrowFunction, AsExpression, BinaryExpression, CallSignatureDeclaration, ClassDeclaration, ClassExpression, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ElementAccessExpression, ExportAssignment, ExpressionStatement, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, ImportDeclaration, IndexSignatureDeclaration, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocImplementsTag, JSDocImportTag, JSDocOverloadTag, JSDocParameterOrPropertyTag, JSDocSatisfiesTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypedefTag, JSDocVariadicType, JSDocOptionalType, KeywordTypeNode, MethodDeclaration, MethodSignatureDeclaration, ModifierList, ModuleBlock, ModuleDeclaration, NodeList, NodeVisitor, NumericLiteral, ParameterDeclaration, ParenthesizedExpression, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, StringLiteral, Token, TypeAliasDeclaration, TypeLiteralNode, TypeParameterDeclaration, VariableDeclaration, VariableStatement, getComment, getModifiers, getName, getParameters, getText, getType, getTypeExpression, getTypeParameters, } from './ast.js';
9
+ import { ArrayTypeNode, ArrowFunction, AsExpression, BinaryExpression, CallSignatureDeclaration, ClassDeclaration, ClassExpression, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ElementAccessExpression, ExportAssignment, ExpressionStatement, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, ImportDeclaration, IndexSignatureDeclaration, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocImplementsTag, JSDocImportTag, JSDocOverloadTag, JSDocParameterOrPropertyTag, JSDocSatisfiesTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypedefTag, JSDocVariadicType, JSDocOptionalType, KeywordTypeNode, MethodDeclaration, MethodSignatureDeclaration, ModifierList, ModuleBlock, ModuleDeclaration, NodeList, NodeVisitor, NumericLiteral, ParameterDeclaration, ParenthesizedExpression, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, StringLiteral, Token, TypeAliasDeclaration, TypeLiteralNode, TypeParameterDeclaration, VariableDeclaration, VariableStatement, getComment, getModifiers, getName, getParameters, getText, getType, getTypeExpression, getTypeParameters, FullPropertyAssignment, } from './ast.js';
10
10
  import { isAssignmentOperator, isFunctionLike, isInJSFile, isLeftHandSideExpression, isStringLiteralLike, } from './ast-utilities.js';
11
11
  import { isIdentifierPart, isIdentifierStart } from './character-codes.js';
12
12
  /** Sets the parent of every node in a subtree. */
@@ -652,10 +652,14 @@ export class Reparser {
652
652
  return false;
653
653
  const className = tag.className;
654
654
  const heritageClauses = getHeritageClauses(parent);
655
+ // Parsed lists may share their nodes array (empty ones do), so a longer list is a new list.
655
656
  if (heritageClauses !== undefined) {
656
657
  for (const clause of heritageClauses.nodes)
657
658
  if (clause instanceof HeritageClause && clause.token === 118 /* SyntaxKind.ImplementsKeyword */) {
658
- clause.types.nodes.push(this.addDeepCloneReparse(className));
659
+ const types = clause.types;
660
+ const nodes = types.nodes.slice();
661
+ nodes.push(this.addDeepCloneReparse(className));
662
+ clause.types = this.p.newNodeList(types.pos, types.end, nodes);
659
663
  this.finishMutatedNode(clause);
660
664
  return true;
661
665
  }
@@ -665,8 +669,11 @@ export class Reparser {
665
669
  this.finishReparsedNode(heritageClause, className);
666
670
  if (heritageClauses === undefined)
667
671
  setHeritageClauses(parent, this.p.newNodeList(className.pos, className.end, [heritageClause]));
668
- else
669
- heritageClauses.nodes.push(heritageClause);
672
+ else {
673
+ const nodes = heritageClauses.nodes.slice();
674
+ nodes.push(heritageClause);
675
+ setHeritageClauses(parent, this.p.newNodeList(heritageClauses.pos, heritageClauses.end, nodes));
676
+ }
670
677
  this.finishMutatedNode(parent);
671
678
  return true;
672
679
  }
@@ -1178,7 +1185,8 @@ function setType(node, value) {
1178
1185
  node.type = value;
1179
1186
  return true;
1180
1187
  }
1181
- if (node instanceof PropertyAssignment) {
1188
+ // Property assignments in JavaScript files, which are the ones reparsed, are full ones.
1189
+ if (node instanceof FullPropertyAssignment) {
1182
1190
  node.type = value;
1183
1191
  return true;
1184
1192
  }
@@ -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, SymbolFlags, type SymbolTable } from './symbol.js';
4
3
  import { SymbolAccessibilityResult } from './transformers/declarations-resolver.js';
4
+ import { type Symbol, SymbolFlags, type SymbolTable } from './symbol.js';
5
5
  export declare function isTypeSymbolAccessible(c: Checker, symbol: Symbol, enclosingDeclaration: Node | undefined): boolean;
6
6
  export declare function isValueSymbolAccessible(c: Checker, symbol: Symbol, enclosingDeclaration: Node | undefined): boolean;
7
7
  export declare function isSymbolAccessibleByFlags(c: Checker, symbol: Symbol, enclosingDeclaration: Node | undefined, flags: SymbolFlags): boolean;