tsc-ts 0.0.6 → 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 (71) hide show
  1. package/dist/api/compiler/ast.d.ts +57 -18
  2. package/dist/api/compiler/ast.js +134 -39
  3. package/dist/api/compiler/binder-utilities.js +2 -2
  4. package/dist/api/compiler/binder.js +6 -6
  5. package/dist/api/compiler/checker-calls.js +4 -4
  6. package/dist/api/compiler/checker-contextual.js +1 -1
  7. package/dist/api/compiler/checker-emit-helpers.d.ts +2 -1
  8. package/dist/api/compiler/checker-emit-helpers.js +5 -4
  9. package/dist/api/compiler/checker-grammar.js +5 -5
  10. package/dist/api/compiler/checker-inference.d.ts +20 -10
  11. package/dist/api/compiler/checker-inference.js +48 -25
  12. package/dist/api/compiler/checker-members.d.ts +27 -0
  13. package/dist/api/compiler/checker-members.js +165 -0
  14. package/dist/api/compiler/checker-modules.d.ts +14 -0
  15. package/dist/api/compiler/checker-modules.js +73 -1
  16. package/dist/api/compiler/checker.d.ts +16 -0
  17. package/dist/api/compiler/checker.js +17 -0
  18. package/dist/api/compiler/diagnostics.js +9 -5
  19. package/dist/api/compiler/parallel-parse.js +3 -1
  20. package/dist/api/compiler/parser.js +33 -23
  21. package/dist/api/compiler/printer/factory-base.js +8 -8
  22. package/dist/api/compiler/printer/factory.js +4 -4
  23. package/dist/api/compiler/printer/printer.js +6 -6
  24. package/dist/api/compiler/program-checker.d.ts +5 -0
  25. package/dist/api/compiler/program-checker.js +11 -1
  26. package/dist/api/compiler/relations.js +8 -3
  27. package/dist/api/compiler/reparser.js +13 -5
  28. package/dist/api/compiler/transformers/class-fields.js +3 -3
  29. package/dist/api/compiler/transformers/commonjs-module.js +3 -3
  30. package/dist/api/compiler/transformers/declarations-pseudo.js +2 -2
  31. package/dist/api/compiler/transformers/module.js +2 -2
  32. package/dist/api/compiler/transformers/optional-chain.js +3 -3
  33. package/dist/api/compiler/transformers/subtree-facts.js +2 -2
  34. package/dist/api/compiler/transformers/tagged-template.js +2 -2
  35. package/dist/api/compiler/transformers/type-eraser.js +2 -2
  36. package/dist/api/compiler/transformers/visitor-base.js +3 -3
  37. package/dist/api/compiler/tsconfig.js +2 -2
  38. package/package.json +8 -8
  39. package/src/compiler/ast.ts +184 -59
  40. package/src/compiler/binder-utilities.ts +2 -1
  41. package/src/compiler/binder.ts +11 -5
  42. package/src/compiler/checker-calls.ts +5 -3
  43. package/src/compiler/checker-contextual.ts +1 -1
  44. package/src/compiler/checker-emit-helpers.ts +5 -4
  45. package/src/compiler/checker-grammar.ts +5 -3
  46. package/src/compiler/checker-inference.ts +49 -25
  47. package/src/compiler/checker-members.ts +164 -0
  48. package/src/compiler/checker-modules.ts +92 -1
  49. package/src/compiler/checker.ts +19 -0
  50. package/src/compiler/decoder.ts +5 -4
  51. package/src/compiler/diagnostics.ts +10 -5
  52. package/src/compiler/encoder.ts +10 -5
  53. package/src/compiler/parallel-parse.ts +3 -1
  54. package/src/compiler/parser.ts +53 -23
  55. package/src/compiler/printer/factory-base.ts +14 -7
  56. package/src/compiler/printer/factory.ts +5 -3
  57. package/src/compiler/printer/printer.ts +8 -6
  58. package/src/compiler/program-checker.ts +10 -1
  59. package/src/compiler/relations.ts +10 -2
  60. package/src/compiler/reparser.ts +14 -4
  61. package/src/compiler/transformers/class-fields.ts +12 -2
  62. package/src/compiler/transformers/commonjs-module.ts +3 -2
  63. package/src/compiler/transformers/declarations-pseudo.ts +2 -1
  64. package/src/compiler/transformers/declarations.ts +1 -1
  65. package/src/compiler/transformers/module.ts +2 -1
  66. package/src/compiler/transformers/optional-chain.ts +5 -2
  67. package/src/compiler/transformers/subtree-facts.ts +2 -1
  68. package/src/compiler/transformers/tagged-template.ts +2 -2
  69. package/src/compiler/transformers/type-eraser.ts +2 -1
  70. package/src/compiler/transformers/visitor-base.ts +10 -5
  71. package/src/compiler/tsconfig.ts +2 -1
@@ -5,7 +5,7 @@
5
5
  // const file = parseSourceFile('/src/main.ts', text);
6
6
  // for (const statement of file.statements.nodes) console.log(statement.kind);
7
7
  // ```
8
- import { ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BigIntLiteral, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, CheckJsDirective, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleIndicatorOptions, ExternalModuleReference, FileReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDocAllType, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, KeywordExpression, KeywordTypeNode, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, MissingDeclaration, MissingNodeList, ModifierList, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NoSubstitutionTemplateLiteral, NodeList, NodeVisitor, NonNullExpression, NumericLiteral, ObjectLiteralExpression, OmittedExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PostfixUnaryExpression, Pragma, PragmaArgument, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, ReferenceIdentifier, RegularExpressionLiteral, RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringLiteral, SwitchStatement, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisTypeNode, ThrowStatement, Token, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, getBody, getIsTypeOnly, getModifiers, getName, getPostfixToken, getQuestionToken, getStatements, getText, getType, getTypeArguments, getTypeParameters, } from './ast.js';
8
+ import { appendToList, ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BigIntLiteral, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, CheckJsDirective, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, emptyCommentDirectives, emptyDiagnostics, emptyFileReferences, emptyNodes, emptyPragmas, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleIndicatorOptions, ExternalModuleReference, FileReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDocAllType, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, KeywordExpression, KeywordTypeNode, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, MissingDeclaration, MissingNodeList, ModifierList, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NoSubstitutionTemplateLiteral, NodeList, NodeVisitor, NonNullExpression, NumericLiteral, ObjectLiteralExpression, OmittedExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PostfixUnaryExpression, Pragma, PragmaArgument, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, ReferenceIdentifier, RegularExpressionLiteral, RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringLiteral, SwitchStatement, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisTypeNode, ThrowStatement, Token, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, getBody, getIsTypeOnly, getModifiers, getName, getPostfixToken, getQuestionToken, getStatements, getText, getType, getTypeArguments, getTypeParameters, newCallExpression, newPropertyAssignment, } from './ast.js';
9
9
  import { canHaveDecorators, canHaveIllegalDecorators, compareNodePositions, getBinaryOperatorPrecedence, getExternalModuleName, getImportTypeNodeLiteral, getTextOfNodeFromSourceText, isAmbientModule, isAnyImportOrReExport, isAssignmentOperator, isClassMemberModifier, isFunctionLike, isImportCall, isImportMeta, isInJSFile, isKeyword, isKeywordOrPunctuation, isLeftHandSideExpression, isModifierKind, isRequireCall, isReservedWord, isStringLiteralLike, modifierToFlag, modifiersToFlags, nodeIsMissing, nodeIsPresent, tagNamesAreEquivalent, tokenIsIdentifierOrKeyword, tokenIsIdentifierOrKeywordOrGreaterThan, } from './ast-utilities.js';
10
10
  import { isLineBreak } from './character-codes.js';
11
11
  import { Diagnostic, messageCode } from './diagnostics.js';
@@ -52,6 +52,10 @@ function appendRange(to, from, start, end) {
52
52
  for (let i = start; i < end; i += 1)
53
53
  to.push(from[i]);
54
54
  }
55
+ // The nodes of every empty parsed list. A list's nodes are pushed into a new `[]`, which natively
56
+ // reserves room for its first elements (112 bytes); a parsed list never changes, so an empty one
57
+ // keeps this shared array instead and its builder is freed.
58
+ const emptyListNodes = [];
55
59
  /** Parses `text` as the file `fileName`. The script kind defaults to the one implied by the extension. */
56
60
  export function parseSourceFile(fileName, text, options) {
57
61
  const path = options === undefined ? fileName : options.path;
@@ -368,10 +372,10 @@ export class Parser extends ScannerErrorReporter {
368
372
  }
369
373
  // Nodes
370
374
  newNodeList(pos, end, nodes) {
371
- return new NodeList(pos, end, nodes);
375
+ return new NodeList(pos, end, nodes.length === 0 ? emptyListNodes : nodes);
372
376
  }
373
377
  newModifierList(pos, end, nodes) {
374
- return new ModifierList(pos, end, nodes, modifiersToFlags(nodes));
378
+ return new ModifierList(pos, end, nodes.length === 0 ? emptyListNodes : nodes, modifiersToFlags(nodes));
375
379
  }
376
380
  finishNode(node, pos) {
377
381
  return this.finishNodeWithEnd(node, pos, this.nodePos());
@@ -434,7 +438,8 @@ export class Parser extends ScannerErrorReporter {
434
438
  return new SourceFile(this.fileName, this.path, this.sourceText, this.externalModuleIndicatorOptions, statements, eof);
435
439
  }
436
440
  finishSourceFile(result, isDeclarationFile) {
437
- result.commentDirectives = this.scanner.getCommentDirectives();
441
+ const commentDirectives = this.scanner.getCommentDirectives();
442
+ result.commentDirectives = commentDirectives.length === 0 ? emptyCommentDirectives : commentDirectives;
438
443
  result.pragmas = getCommentPragmas(this.sourceText);
439
444
  this.processPragmasIntoFields(result);
440
445
  result.diagnostics = attachFileToDiagnostics(this.diagnostics, result);
@@ -452,9 +457,13 @@ export class Parser extends ScannerErrorReporter {
452
457
  // The table stays with the parser: when top-level await reparsing produces a second source
453
458
  // file, it finishes with the same table, which still holds the JSDoc of retained statements.
454
459
  result.jsDocs = this.jsDocTable;
455
- const clones = this.reparsedClones.slice();
456
- clones.sort(compareNodePositions);
457
- result.reparsedClones = clones;
460
+ if (this.reparsedClones.length === 0)
461
+ result.reparsedClones = emptyNodes;
462
+ else {
463
+ const clones = this.reparsedClones.slice();
464
+ clones.sort(compareNodePositions);
465
+ result.reparsedClones = clones;
466
+ }
458
467
  setExternalModuleIndicator(result);
459
468
  }
460
469
  parseToplevelStatement(index) {
@@ -4449,7 +4458,7 @@ export class Parser extends ScannerErrorReporter {
4449
4458
  const inner = expression;
4450
4459
  const argumentList = this.parseArgumentList();
4451
4460
  const isOptionalChain = questionDotToken !== undefined || this.tryReparseOptionalChain(expression);
4452
- expression = this.checkJSSyntax(this.finishNode(new CallExpression(expression, questionDotToken, typeArguments, argumentList, isOptionalChain ? 32 /* NodeFlags.OptionalChain */ : 0 /* NodeFlags.None */), pos));
4461
+ expression = this.checkJSSyntax(this.finishNode(newCallExpression(expression, questionDotToken, typeArguments, argumentList, isOptionalChain ? 32 /* NodeFlags.OptionalChain */ : 0 /* NodeFlags.None */, (this.contextFlags & 65536 /* NodeFlags.JavaScriptFile */) !== 0), pos));
4453
4462
  this.unparseExpressionWithTypeArguments(inner, typeArguments, expression);
4454
4463
  continue;
4455
4464
  }
@@ -4636,7 +4645,7 @@ export class Parser extends ScannerErrorReporter {
4636
4645
  else {
4637
4646
  this.parseExpected(58 /* SyntaxKind.ColonToken */);
4638
4647
  const initializer = this.parseAssignmentExpressionOrHigherAllowIn();
4639
- node = new PropertyAssignment(modifiers, name, postfixToken, undefined, initializer);
4648
+ node = newPropertyAssignment(modifiers, name, postfixToken, undefined, initializer, (this.contextFlags & 65536 /* NodeFlags.JavaScriptFile */) !== 0);
4640
4649
  }
4641
4650
  return this.finishWithJSDoc(node, pos, jsdoc);
4642
4651
  }
@@ -5540,9 +5549,9 @@ export class Parser extends ScannerErrorReporter {
5540
5549
  // Pragmas
5541
5550
  processPragmasIntoFields(file) {
5542
5551
  file.checkJsDirective = undefined;
5543
- file.referencedFiles = [];
5544
- file.typeReferenceDirectives = [];
5545
- file.libReferenceDirectives = [];
5552
+ file.referencedFiles = emptyFileReferences;
5553
+ file.typeReferenceDirectives = emptyFileReferences;
5554
+ file.libReferenceDirectives = emptyFileReferences;
5546
5555
  for (const pragma of file.pragmas) {
5547
5556
  switch (pragma.name) {
5548
5557
  case 'reference': {
@@ -5561,13 +5570,13 @@ export class Parser extends ScannerErrorReporter {
5561
5570
  const parsed = resolutionMode !== undefined
5562
5571
  ? this.parseResolutionMode(resolutionMode.value, resolutionMode.pos, resolutionMode.end)
5563
5572
  : ModuleKind.None;
5564
- file.typeReferenceDirectives.push(new FileReference(types.pos, types.end, types.value, parsed, isPreserved));
5573
+ file.typeReferenceDirectives = appendToList(file.typeReferenceDirectives, new FileReference(types.pos, types.end, types.value, parsed, isPreserved));
5565
5574
  }
5566
5575
  else if (lib !== undefined) {
5567
- file.libReferenceDirectives.push(new FileReference(lib.pos, lib.end, lib.value, ModuleKind.None, isPreserved));
5576
+ file.libReferenceDirectives = appendToList(file.libReferenceDirectives, new FileReference(lib.pos, lib.end, lib.value, ModuleKind.None, isPreserved));
5568
5577
  }
5569
5578
  else if (path !== undefined) {
5570
- file.referencedFiles.push(new FileReference(path.pos, path.end, path.value, ModuleKind.None, isPreserved));
5579
+ file.referencedFiles = appendToList(file.referencedFiles, new FileReference(path.pos, path.end, path.value, ModuleKind.None, isPreserved));
5571
5580
  }
5572
5581
  else {
5573
5582
  this.parseErrorAt(pragma.range.pos, pragma.range.end, 57 /* Diagnostics.Invalid_reference_directive_syntax */);
@@ -5776,7 +5785,7 @@ function typeHasBlockingError(node) {
5776
5785
  }
5777
5786
  function attachFileToDiagnostics(diagnostics, file) {
5778
5787
  if (diagnostics.length === 0)
5779
- return diagnostics;
5788
+ return emptyDiagnostics;
5780
5789
  const diagnosticFile = file.diagnosticFile();
5781
5790
  for (const d of diagnostics) {
5782
5791
  d.file = diagnosticFile;
@@ -6034,12 +6043,13 @@ function nextTokenIsNotColon(p) {
6034
6043
  }
6035
6044
  // Pragmas
6036
6045
  function getCommentPragmas(sourceText) {
6037
- const pragmas = [];
6038
6046
  const ranges = getLeadingCommentRanges(sourceText, 0);
6039
- if (ranges !== undefined)
6040
- for (const range of ranges)
6041
- extractPragmas(range, sourceText.substring(range.pos, range.end), pragmas);
6042
- return pragmas;
6047
+ if (ranges === undefined)
6048
+ return emptyPragmas;
6049
+ const pragmas = [];
6050
+ for (const range of ranges)
6051
+ extractPragmas(range, sourceText.substring(range.pos, range.end), pragmas);
6052
+ return pragmas.length === 0 ? emptyPragmas : pragmas;
6043
6053
  }
6044
6054
  function extractPragmas(range, text, pragmas) {
6045
6055
  if (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) {
@@ -6200,10 +6210,10 @@ function collectModuleReferences(file, node, inAmbientModule) {
6200
6210
  (inAmbientModule || hasModifierFlag(node, 128 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) {
6201
6211
  const nameText = getText(node.name);
6202
6212
  if (file.externalModuleIndicator !== undefined || (inAmbientModule && !isExternalModuleNameRelative(nameText))) {
6203
- file.moduleAugmentations.push(node.name);
6213
+ file.moduleAugmentations = appendToList(file.moduleAugmentations, node.name);
6204
6214
  }
6205
6215
  else if (!inAmbientModule) {
6206
- file.ambientModuleNames.push(nameText);
6216
+ file.ambientModuleNames = appendToList(file.ambientModuleNames, nameText);
6207
6217
  const body = node.body;
6208
6218
  if (body !== undefined) {
6209
6219
  const statements = getStatements(body);
@@ -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);
@@ -10,7 +10,7 @@ import { createDiagnosticForNode } from './checker.js';
10
10
  import { cachedTypeKey, emptyTypes, newTypeMapper, SimpleTypeMapper, } from './checker-types.js';
11
11
  import { createInferenceContext, inferTypes } from './checker-inference.js';
12
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';
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, } 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';
14
14
  import { getParentOfSymbol, getMergedSymbol, getMembersOfSymbol, getSpellingSuggestionForName, } from './checker-symbols.js';
15
15
  import { CodePoints, distanceToCandidate, utf8Length } from './spelling.js';
16
16
  import { getConstraintFromTypeParameter, getDeclaredTypeOfSymbol, getDefaultOrUnknownFromTypeParameter, fillMissingTypeArguments, getMinTypeArgumentCount, hasBaseType, hasNonCircularBaseConstraint, computeEnumMemberValues, getBaseTypes, getExtendsHeritageClauseElement, } from './checker-declared-types.js';
@@ -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;
@@ -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
  // Lowers class fields, private names, static blocks and `accessor` fields: initializers move to
2
2
  // the constructor (useDefineForClassFields: false, or targets before ES2022), private members
3
3
  // become WeakMaps, WeakSets and hoisted functions, and static `this` and `super` refer to the class.
4
- import { ArrayLiteralExpression, BinaryExpression, Block, CallExpression, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConstructorDeclaration, ElementAccessExpression, ExportAssignment, ExpressionWithTypeArguments, GetAccessorDeclaration, HeritageClause, Identifier, NodeList, ObjectLiteralExpression, ParameterDeclaration, ParenthesizedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, SetAccessorDeclaration, ShorthandPropertyAssignment, SpreadAssignment, SpreadElement, StringLiteral, TryStatement, NewExpression, ArrowFunction, CatchClause, FunctionExpression, MethodDeclaration, NodeVisitor, VoidExpression, getBody, getParameters, getInitializer, getMembers, getModifiers, getName, } from '../ast.js';
4
+ import { ArrayLiteralExpression, BinaryExpression, Block, CallExpression, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConstructorDeclaration, ElementAccessExpression, ExportAssignment, ExpressionWithTypeArguments, GetAccessorDeclaration, HeritageClause, Identifier, NodeList, ObjectLiteralExpression, ParameterDeclaration, ParenthesizedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, SetAccessorDeclaration, ShorthandPropertyAssignment, SpreadAssignment, SpreadElement, StringLiteral, TryStatement, NewExpression, ArrowFunction, CatchClause, FunctionExpression, MethodDeclaration, NodeVisitor, VoidExpression, getBody, getParameters, getInitializer, getMembers, getModifiers, getName, callQuestionDotToken, callTypeArguments, newCallExpression, } from '../ast.js';
5
5
  import { isLeftHandSideExpression } from '../ast-utilities.js';
6
6
  import { getNameOfDeclaration, hasStaticModifier, isAssignmentExpression, isAutoAccessorPropertyDeclaration, isClassLike, isDestructuringAssignment, isMethodOrAccessor, isPrivateIdentifierClassElementDeclaration, isStatic, skipParentheses, } from '../binder-utilities.js';
7
7
  import { isIdentifierText } from '../scanner.js';
@@ -963,7 +963,7 @@ export class ClassFieldsTransformer extends Transformer {
963
963
  if (node instanceof ParenthesizedExpression)
964
964
  return factory.cloneNode(node, new ParenthesizedExpression(node.expression));
965
965
  if (node instanceof CallExpression)
966
- return factory.cloneNode(node, new CallExpression(node.expression, node.questionDotToken, node.typeArguments, node.arguments, node.flags));
966
+ return factory.cloneNode(node, newCallExpression(node.expression, callQuestionDotToken(node), callTypeArguments(node), node.arguments, node.flags, false));
967
967
  return factory.cloneNode(node, node.deepClone());
968
968
  }
969
969
  visitCallExpression(node) {
@@ -980,7 +980,7 @@ export class ClassFieldsTransformer extends Transformer {
980
980
  for (let i = 0; i < visitedArgs.length; i++)
981
981
  args.push(visitedArgs[i]);
982
982
  const optional = (node.flags & 32 /* NodeFlags.OptionalChain */) !== 0;
983
- const call = factory.created(new PropertyAccessExpression(target, optional ? node.questionDotToken : undefined, factory.createIdentifier('call'), optional ? 32 /* NodeFlags.OptionalChain */ : 0 /* NodeFlags.None */));
983
+ const call = factory.created(new PropertyAccessExpression(target, optional ? callQuestionDotToken(node) : undefined, factory.createIdentifier('call'), optional ? 32 /* NodeFlags.OptionalChain */ : 0 /* NodeFlags.None */));
984
984
  return factory.updateCallExpression(node, call, undefined, undefined, factory.createNodeList(args), node.flags);
985
985
  }
986
986
  const data = this.staticSuperData(callee);
@@ -1,5 +1,5 @@
1
1
  // CommonJS module output: imports become `require` calls, exports assignments to `exports`.
2
- import { ArrowFunction, BinaryExpression, BindingPattern, Block, CallExpression, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, DoStatement, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, Identifier, IfStatement, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, LabeledStatement, NamedExports, NamespaceExport, NodeList, NodeVisitor, ObjectLiteralExpression, ArrayLiteralExpression, ParenthesizedExpression, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAssignment, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringLiteral, SwitchStatement, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateSpan, TemplateTail, TryStatement, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, EmptyStatement, getElements, getName, } from '../ast.js';
2
+ import { ArrowFunction, BinaryExpression, BindingPattern, Block, CallExpression, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, DoStatement, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, Identifier, IfStatement, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, LabeledStatement, NamedExports, NamespaceExport, NodeList, NodeVisitor, ObjectLiteralExpression, ArrayLiteralExpression, ParenthesizedExpression, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAssignment, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringLiteral, SwitchStatement, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateSpan, TemplateTail, TryStatement, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, EmptyStatement, getElements, getName, callQuestionDotToken, } from '../ast.js';
3
3
  import { getExternalModuleName, isImportCall, isInJSFile, isRequireCall } from '../ast-utilities.js';
4
4
  import { isAssignmentExpression, isDestructuringAssignment } from '../binder-utilities.js';
5
5
  import { JsxEmit, ModuleKind, ScriptTarget, getEmitModuleKind, getEmitScriptTarget, } from '../options.js';
@@ -869,7 +869,7 @@ export class CommonJSModuleTransformer extends Transformer {
869
869
  const callee = node.expression;
870
870
  if (callee instanceof Identifier) {
871
871
  const expression = this.visitExpressionIdentifier(callee);
872
- const updated = this.factory.updateCallExpression(node, expression, node.questionDotToken, undefined, this.visitNodes(node.arguments), node.flags);
872
+ const updated = this.factory.updateCallExpression(node, expression, callQuestionDotToken(node), undefined, this.visitNodes(node.arguments), node.flags);
873
873
  if (!(expression instanceof Identifier) && (this.context.getEmitFlags(callee) & 1024 /* EmitFlags.HelperName */) === 0)
874
874
  this.context.addEmitFlags(updated, 1048576 /* EmitFlags.IndirectCall */);
875
875
  return updated;
@@ -938,7 +938,7 @@ export class CommonJSModuleTransformer extends Transformer {
938
938
  if (rewritten !== first || visitedRest !== rest)
939
939
  args = new NodeList(args.pos, args.end, [rewritten].concat(visitedRest));
940
940
  }
941
- return factory.updateCallExpression(node, expression, node.questionDotToken, undefined, args, node.flags);
941
+ return factory.updateCallExpression(node, expression, callQuestionDotToken(node), undefined, args, node.flags);
942
942
  }
943
943
  visitTaggedTemplateExpression(node) {
944
944
  const tag = node.tag;
@@ -2,7 +2,7 @@
2
2
  // pseudochecker and the isolatedDeclarations rules. Annotations, literals, `as const` values
3
3
  // and function expressions with annotated returns have pseudo-types; everything else is
4
4
  // "inferred" and needs the checker.
5
- import { ArrayLiteralExpression, ArrowFunction, FunctionExpression, MethodDeclaration, GetAccessorDeclaration, NodeVisitor, ObjectLiteralExpression, ParameterDeclaration, PrefixUnaryExpression, PropertyAssignment, PropertyDeclaration, ReturnStatement, SetAccessorDeclaration, TypeReferenceNode, VariableDeclaration, UnionTypeNode, IntersectionTypeNode, getAsteriskToken, getBody, getExpression, getName, getParameters, getPostfixToken, getSymbol, getType, getTypeParameters, } from '../ast.js';
5
+ import { ArrayLiteralExpression, ArrowFunction, FunctionExpression, MethodDeclaration, GetAccessorDeclaration, NodeVisitor, ObjectLiteralExpression, ParameterDeclaration, PrefixUnaryExpression, PropertyAssignment, PropertyDeclaration, ReturnStatement, SetAccessorDeclaration, TypeReferenceNode, VariableDeclaration, UnionTypeNode, IntersectionTypeNode, getAsteriskToken, getBody, getExpression, getName, getParameters, getPostfixToken, getSymbol, getType, getTypeParameters, propertyAssignmentPostfixToken, } from '../ast.js';
6
6
  import { isFunctionLike, nodeIsMissing } from '../ast-utilities.js';
7
7
  import { getCombinedNodeFlags, hasSyntacticModifier, isIdentifierNamed } from '../binder-utilities.js';
8
8
  import { getAllAccessorDeclarations } from './declarations-diagnostics.js';
@@ -416,7 +416,7 @@ export class PseudoChecker {
416
416
  }
417
417
  case 303 /* SyntaxKind.PropertyAssignment */: {
418
418
  const assignment = property;
419
- const postfix = assignment.postfixToken;
419
+ const postfix = propertyAssignmentPostfixToken(assignment);
420
420
  members.push(new PseudoMember(1 /* PseudoMemberKind.Property */, assignment.name, postfix !== undefined && postfix.kind === 57 /* SyntaxKind.QuestionToken */, false, undefined, [], [], this.typeFromExpression(assignment.initializer)));
421
421
  break;
422
422
  }
@@ -1,6 +1,6 @@
1
1
  // `"use strict"` prologues and module output: ECMAScript modules, CommonJS, or each file in the
2
2
  // format its extension and package.json imply.
3
- import { CallExpression, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExternalModuleReference, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, MetaProperty, NamedExports, NamedImports, NamespaceExport, NamespaceImport, NodeList, SourceFile, StringLiteral, NoSubstitutionTemplateLiteral, Identifier, } from '../ast.js';
3
+ import { CallExpression, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExternalModuleReference, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, MetaProperty, NamedExports, NamedImports, NamespaceExport, NamespaceImport, NodeList, SourceFile, StringLiteral, NoSubstitutionTemplateLiteral, Identifier, callQuestionDotToken, } from '../ast.js';
4
4
  import { isAnyImportOrReExport, isImportCall, isInJSFile, isRequireCall } from '../ast-utilities.js';
5
5
  import { JsxEmit, ModuleKind, getEmitModuleKind, getIsolatedModules } from '../options.js';
6
6
  import { isPrologueDirective } from '../printer/utilities.js';
@@ -257,7 +257,7 @@ export class ESModuleTransformer extends Transformer {
257
257
  ? rewriteModuleSpecifier(this.context, first, this.options)
258
258
  : factory.createRewriteRelativeImportExtensionsHelper(first, this.options.jsx === JsxEmit.Preserve);
259
259
  const rest = this.visitArray(args.slice(1));
260
- return factory.updateCallExpression(node, this.visitNode(node.expression), node.questionDotToken, undefined, new NodeList(node.arguments.pos, node.arguments.end, [argument].concat(rest)), node.flags);
260
+ return factory.updateCallExpression(node, this.visitNode(node.expression), callQuestionDotToken(node), undefined, new NodeList(node.arguments.pos, node.arguments.end, [argument].concat(rest)), node.flags);
261
261
  }
262
262
  importAttributes(node) {
263
263
  const visited = this.visitNode(node);
@@ -1,5 +1,5 @@
1
1
  // Lowers optional chains such as `a?.b.c()` to conditionals on `null` and `undefined` (ES2020).
2
- import { CallExpression, DeleteExpression, ElementAccessExpression, ParenthesizedExpression, PropertyAccessExpression, SyntheticReferenceExpression, TaggedTemplateExpression, } from '../ast.js';
2
+ import { CallExpression, DeleteExpression, ElementAccessExpression, ParenthesizedExpression, PropertyAccessExpression, SyntheticReferenceExpression, TaggedTemplateExpression, callQuestionDotToken, newCallExpression, } from '../ast.js';
3
3
  import { skipParentheses } from '../binder-utilities.js';
4
4
  import { skipPartiallyEmittedExpressions } from '../printer/utilities.js';
5
5
  import { isSimpleCopiableExpression } from './destructuring.js';
@@ -147,7 +147,7 @@ export class OptionalChainTransformer extends Transformer {
147
147
  rightExpression = factory.createFunctionCallCall(rightExpression, callThisArg, this.visitNodes(segment.arguments).nodes);
148
148
  }
149
149
  else
150
- rightExpression = factory.created(new CallExpression(rightExpression, undefined, undefined, this.visitNodes(segment.arguments), 0 /* NodeFlags.None */));
150
+ rightExpression = factory.created(newCallExpression(rightExpression, undefined, undefined, this.visitNodes(segment.arguments), 0 /* NodeFlags.None */, false));
151
151
  }
152
152
  context.setOriginal(rightExpression, segment);
153
153
  }
@@ -169,7 +169,7 @@ function questionDotTokenOf(node) {
169
169
  if (node instanceof ElementAccessExpression)
170
170
  return node.questionDotToken;
171
171
  if (node instanceof CallExpression)
172
- return node.questionDotToken;
172
+ return callQuestionDotToken(node);
173
173
  return undefined;
174
174
  }
175
175
  /** The expression a link of a chain accesses or calls. */
@@ -1,6 +1,6 @@
1
1
  // Whether a subtree contains TypeScript-only syntax, computed as tsgo's subtree facts are.
2
2
  // Transforms skip subtrees without it; that also decides how malformed code is emitted.
3
- import { ClassDeclaration, ClassExpression, ConstructorDeclaration, ExportAssignment, ExportDeclaration, ExportSpecifier, FunctionDeclaration, GetAccessorDeclaration, Identifier, ImportClause, ImportEqualsDeclaration, ImportSpecifier, MethodDeclaration, NodeVisitor, ParameterDeclaration, PropertyDeclaration, SetAccessorDeclaration, VariableDeclaration, VariableStatement, ArrowFunction, FunctionExpression, CallExpression, NewExpression, TaggedTemplateExpression, ExpressionWithTypeArguments, JsxOpeningElement, JsxSelfClosingElement, HeritageClause, getModifiers, } from '../ast.js';
3
+ import { ClassDeclaration, ClassExpression, ConstructorDeclaration, ExportAssignment, ExportDeclaration, ExportSpecifier, FunctionDeclaration, GetAccessorDeclaration, Identifier, ImportClause, ImportEqualsDeclaration, ImportSpecifier, MethodDeclaration, NodeVisitor, ParameterDeclaration, PropertyDeclaration, SetAccessorDeclaration, VariableDeclaration, VariableStatement, ArrowFunction, FunctionExpression, CallExpression, NewExpression, TaggedTemplateExpression, ExpressionWithTypeArguments, JsxOpeningElement, JsxSelfClosingElement, HeritageClause, getModifiers, callTypeArguments, } from '../ast.js';
4
4
  import { ClusteredIntLinkTable } from '../link-tables.js';
5
5
  import { isTypeNodeKind } from '../printer/utilities.js';
6
6
  /** Memoized `containsTypeScript` answers for one emit. */
@@ -185,7 +185,7 @@ function ownFacts(node) {
185
185
  ? 1 /* Facts.TypeScript */
186
186
  : 0 /* Facts.None */;
187
187
  case 214 /* SyntaxKind.CallExpression */:
188
- return node instanceof CallExpression && node.typeArguments !== undefined ? 1 /* Facts.TypeScript */ : 0 /* Facts.None */;
188
+ return node instanceof CallExpression && callTypeArguments(node) !== undefined ? 1 /* Facts.TypeScript */ : 0 /* Facts.None */;
189
189
  case 215 /* SyntaxKind.NewExpression */:
190
190
  return node instanceof NewExpression && node.typeArguments !== undefined ? 1 /* Facts.TypeScript */ : 0 /* Facts.None */;
191
191
  case 216 /* SyntaxKind.TaggedTemplateExpression */:
@@ -1,6 +1,6 @@
1
1
  // Lowers tagged templates with invalid escapes, allowed in tagged templates since ES2018, to
2
2
  // calls with a `__makeTemplateObject` template object.
3
- import { ArrayLiteralExpression, CallExpression, NoSubstitutionTemplateLiteral, SourceFile, TaggedTemplateExpression, TemplateExpression, TemplateMiddle, TemplateTail, } from '../ast.js';
3
+ import { ArrayLiteralExpression, NoSubstitutionTemplateLiteral, SourceFile, TaggedTemplateExpression, TemplateExpression, TemplateMiddle, TemplateTail, newCallExpression, } from '../ast.js';
4
4
  import { getSourceTextOfNode } from '../printer/utilities.js';
5
5
  import { Transformer } from './transformer.js';
6
6
  import { isExternalModule } from './utilities.js';
@@ -83,7 +83,7 @@ export class TaggedTemplateTransformer extends Transformer {
83
83
  templateObject = factory.createLogicalOr(name, factory.createAssignment(name, helperCall));
84
84
  }
85
85
  args.unshift(templateObject);
86
- const call = factory.created(new CallExpression(tag, undefined, undefined, factory.createNodeList(args), 0));
86
+ const call = factory.created(newCallExpression(tag, undefined, undefined, factory.createNodeList(args), 0, false));
87
87
  call.pos = node.pos;
88
88
  call.end = node.end;
89
89
  return call;