@typescript-deploys/pr-build 4.6.0-pr-47183-2 → 4.6.0-pr-47126-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20211217";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220107";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -22242,7 +22242,7 @@ var ts;
22242
22242
  result.push(createModifier(144 /* ReadonlyKeyword */));
22243
22243
  if (flags & 256 /* Async */)
22244
22244
  result.push(createModifier(131 /* AsyncKeyword */));
22245
- return result;
22245
+ return result.length ? result : undefined;
22246
22246
  }
22247
22247
  //
22248
22248
  // Names
@@ -26199,32 +26199,36 @@ var ts;
26199
26199
  }
26200
26200
  function updateModifiers(node, modifiers) {
26201
26201
  var _a;
26202
+ var modifierArray;
26202
26203
  if (typeof modifiers === "number") {
26203
- modifiers = createModifiersFromModifierFlags(modifiers);
26204
- }
26205
- return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
26206
- ts.isPropertySignature(node) ? updatePropertySignature(node, modifiers, node.name, node.questionToken, node.type) :
26207
- ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifiers, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
26208
- ts.isMethodSignature(node) ? updateMethodSignature(node, modifiers, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
26209
- ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
26210
- ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifiers, node.parameters, node.body) :
26211
- ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.type, node.body) :
26212
- ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.body) :
26213
- ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifiers, node.parameters, node.type) :
26214
- ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26215
- ts.isArrowFunction(node) ? updateArrowFunction(node, modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
26216
- ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26217
- ts.isVariableStatement(node) ? updateVariableStatement(node, modifiers, node.declarationList) :
26218
- ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26219
- ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26220
- ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26221
- ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.type) :
26222
- ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) :
26223
- ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) :
26224
- ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.name, node.moduleReference) :
26225
- ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier, node.assertClause) :
26226
- ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) :
26227
- ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
26204
+ modifierArray = createModifiersFromModifierFlags(modifiers);
26205
+ }
26206
+ else {
26207
+ modifierArray = modifiers;
26208
+ }
26209
+ return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
26210
+ ts.isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) :
26211
+ ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifierArray, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
26212
+ ts.isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
26213
+ ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
26214
+ ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifierArray, node.parameters, node.body) :
26215
+ ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.type, node.body) :
26216
+ ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.body) :
26217
+ ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifierArray, node.parameters, node.type) :
26218
+ ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26219
+ ts.isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
26220
+ ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26221
+ ts.isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) :
26222
+ ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26223
+ ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26224
+ ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26225
+ ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.type) :
26226
+ ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifierArray, node.name, node.members) :
26227
+ ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifierArray, node.name, node.body) :
26228
+ ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.name, node.moduleReference) :
26229
+ ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) :
26230
+ ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifierArray, node.expression) :
26231
+ ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
26228
26232
  ts.Debug.assertNever(node);
26229
26233
  }
26230
26234
  function asNodeArray(array) {
@@ -57724,7 +57728,7 @@ var ts;
57724
57728
  return symbol_1;
57725
57729
  }
57726
57730
  }
57727
- return globalObjectType === undefined ? undefined : getPropertyOfObjectType(globalObjectType, name);
57731
+ return getPropertyOfObjectType(globalObjectType, name);
57728
57732
  }
57729
57733
  if (type.flags & 3145728 /* UnionOrIntersection */) {
57730
57734
  return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
@@ -67437,7 +67441,8 @@ var ts;
67437
67441
  return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
67438
67442
  access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
67439
67443
  access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
67440
- undefined;
67444
+ access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
67445
+ undefined;
67441
67446
  }
67442
67447
  function containsMatchingReference(source, target) {
67443
67448
  while (ts.isAccessExpression(source)) {
@@ -68777,13 +68782,14 @@ var ts;
68777
68782
  return result;
68778
68783
  }
68779
68784
  function getCandidateDiscriminantPropertyAccess(expr) {
68780
- if (ts.isBindingPattern(reference)) {
68781
- // When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
68782
- // An identifier for a destructuring variable declared in the same binding pattern is a candidate.
68785
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
68786
+ // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
68787
+ // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
68788
+ // parameter declared in the same parameter list is a candidate.
68783
68789
  if (ts.isIdentifier(expr)) {
68784
68790
  var symbol = getResolvedSymbol(expr);
68785
68791
  var declaration = symbol.valueDeclaration;
68786
- if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
68792
+ if (declaration && (ts.isBindingElement(declaration) || ts.isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
68787
68793
  return declaration;
68788
68794
  }
68789
68795
  }
@@ -69585,42 +69591,78 @@ var ts;
69585
69591
  }
69586
69592
  }
69587
69593
  function getNarrowedTypeOfSymbol(symbol, location) {
69588
- // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69589
- // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69590
- // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69591
- // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69592
- // other binding elements from the same destructuring. Consider:
69593
- //
69594
- // type Action =
69595
- // | { kind: 'A', payload: number }
69596
- // | { kind: 'B', payload: string };
69597
- //
69598
- // function f1({ kind, payload }: Action) {
69599
- // if (kind === 'A') {
69600
- // payload.toFixed();
69601
- // }
69602
- // if (kind === 'B') {
69603
- // payload.toUpperCase();
69604
- // }
69605
- // }
69606
- //
69607
- // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69608
- // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69609
- // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69610
- // destructuring from the narrowed parent type.
69611
69594
  var declaration = symbol.valueDeclaration;
69612
- if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69613
- var parent = declaration.parent.parent;
69614
- if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69615
- var links = getNodeLinks(location);
69616
- if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69617
- links.flags |= 268435456 /* InCheckIdentifier */;
69618
- var parentType = getTypeForBindingElementParent(parent);
69619
- links.flags &= ~268435456 /* InCheckIdentifier */;
69620
- if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69621
- var pattern = declaration.parent;
69622
- var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69623
- return getBindingElementTypeFromParentType(declaration, narrowedType);
69595
+ if (declaration) {
69596
+ // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69597
+ // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69598
+ // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69599
+ // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69600
+ // other binding elements from the same destructuring. Consider:
69601
+ //
69602
+ // type Action =
69603
+ // | { kind: 'A', payload: number }
69604
+ // | { kind: 'B', payload: string };
69605
+ //
69606
+ // function f({ kind, payload }: Action) {
69607
+ // if (kind === 'A') {
69608
+ // payload.toFixed();
69609
+ // }
69610
+ // if (kind === 'B') {
69611
+ // payload.toUpperCase();
69612
+ // }
69613
+ // }
69614
+ //
69615
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69616
+ // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69617
+ // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69618
+ // destructuring from the narrowed parent type.
69619
+ if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69620
+ var parent = declaration.parent.parent;
69621
+ if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69622
+ var links = getNodeLinks(location);
69623
+ if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69624
+ links.flags |= 268435456 /* InCheckIdentifier */;
69625
+ var parentType = getTypeForBindingElementParent(parent);
69626
+ links.flags &= ~268435456 /* InCheckIdentifier */;
69627
+ if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69628
+ var pattern = declaration.parent;
69629
+ var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69630
+ return getBindingElementTypeFromParentType(declaration, narrowedType);
69631
+ }
69632
+ }
69633
+ }
69634
+ }
69635
+ // If we have a const-like parameter with no type annotation or initializer, and if the parameter is contextually
69636
+ // typed by a signature with a single rest parameter of a union of tuple types, one or more of the parameters may
69637
+ // represent discriminant tuple elements, and we want the effects of conditional checks on such discriminants to
69638
+ // affect the types of other parameters in the same parameter list. Consider:
69639
+ //
69640
+ // type Action = [kind: 'A', payload: number] | [kind: 'B', payload: string];
69641
+ //
69642
+ // const f: (...args: Action) => void = (kind, payload) => {
69643
+ // if (kind === 'A') {
69644
+ // payload.toFixed();
69645
+ // }
69646
+ // if (kind === 'B') {
69647
+ // payload.toUpperCase();
69648
+ // }
69649
+ // }
69650
+ //
69651
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69652
+ // the arrow function AST node for '(kind, payload) => ...' as a pseudo-reference and narrow this reference as
69653
+ // if it occurred in the specified location. We then recompute the narrowed parameter type by indexing into the
69654
+ // narrowed tuple type.
69655
+ if (ts.isParameter(declaration) && !declaration.type && !declaration.initializer && !declaration.dotDotDotToken) {
69656
+ var func = declaration.parent;
69657
+ if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
69658
+ var contextualSignature = getContextualSignature(func);
69659
+ if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
69660
+ var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
69661
+ if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
69662
+ var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
69663
+ var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
69664
+ return getIndexedAccessType(narrowedType, getNumberLiteralType(index));
69665
+ }
69624
69666
  }
69625
69667
  }
69626
69668
  }
@@ -109018,7 +109060,7 @@ var ts;
109018
109060
  emitPlaceholder(hint, node, snippet);
109019
109061
  break;
109020
109062
  case 0 /* TabStop */:
109021
- emitTabStop(snippet);
109063
+ emitTabStop(hint, node, snippet);
109022
109064
  break;
109023
109065
  }
109024
109066
  }
@@ -109028,7 +109070,10 @@ var ts;
109028
109070
  nonEscapingWrite("}"); // `}`
109029
109071
  // `${2:...}`
109030
109072
  }
109031
- function emitTabStop(snippet) {
109073
+ function emitTabStop(hint, node, snippet) {
109074
+ // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text.
109075
+ ts.Debug.assert(node.kind === 235 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + ".");
109076
+ ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement.");
109032
109077
  nonEscapingWrite("$" + snippet.order);
109033
109078
  }
109034
109079
  //
@@ -113289,8 +113334,8 @@ var ts;
113289
113334
  var gutterSeparator = " ";
113290
113335
  var resetEscapeSequence = "\u001b[0m";
113291
113336
  var ellipsis = "...";
113337
+ var bullet = "● ";
113292
113338
  var halfIndent = " ";
113293
- var indent = " ";
113294
113339
  function getCategoryFormat(category) {
113295
113340
  switch (category) {
113296
113341
  case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
@@ -113304,7 +113349,7 @@ var ts;
113304
113349
  return formatStyle + text + resetEscapeSequence;
113305
113350
  }
113306
113351
  ts.formatColorAndReset = formatColorAndReset;
113307
- function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
113352
+ function formatCodeSpan(file, start, length, indent, underlineColor, host) {
113308
113353
  var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
113309
113354
  var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
113310
113355
  var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
@@ -113328,24 +113373,24 @@ var ts;
113328
113373
  lineContent = ts.trimStringEnd(lineContent); // trim from end
113329
113374
  lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
113330
113375
  // Output the gutter and the actual contents of the line.
113331
- context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
113376
+ context += indent + ts.padLeft("|", gutterWidth) + gutterSeparator;
113332
113377
  context += lineContent + host.getNewLine();
113333
- // Output the gutter and the error span for the line using tildes.
113334
- context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
113335
- context += squiggleColor;
113378
+ // Output the gutter and the error span for the line using underlines.
113379
+ context += indent + ts.padLeft("", gutterWidth) + gutterSeparator;
113380
+ context += underlineColor;
113336
113381
  if (i === firstLine) {
113337
113382
  // If we're on the last line, then limit it to the last character of the last line.
113338
- // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
113383
+ // Otherwise, we'll just underline the rest of the line, giving 'slice' no end position.
113339
113384
  var lastCharForLine = i === lastLine ? lastLineChar : undefined;
113340
113385
  context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
113341
- context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
113386
+ context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "▔");
113342
113387
  }
113343
113388
  else if (i === lastLine) {
113344
- context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
113389
+ context += lineContent.slice(0, lastLineChar).replace(/./g, "▔");
113345
113390
  }
113346
113391
  else {
113347
- // Squiggle the entire line.
113348
- context += lineContent.replace(/./g, "~");
113392
+ // Underline the entire line.
113393
+ context += lineContent.replace(/./g, "▔");
113349
113394
  }
113350
113395
  context += resetEscapeSequence;
113351
113396
  }
@@ -113366,41 +113411,54 @@ var ts;
113366
113411
  }
113367
113412
  ts.formatLocation = formatLocation;
113368
113413
  function formatDiagnosticsWithColorAndContext(diagnostics, host) {
113414
+ var _a, _b;
113415
+ var terminalWidth = (_b = (_a = ts.sys.getWidthOfTerminal) === null || _a === void 0 ? void 0 : _a.call(ts.sys)) !== null && _b !== void 0 ? _b : 0;
113416
+ var indent = terminalWidth < 60 ? "" : halfIndent;
113369
113417
  var output = "";
113370
113418
  for (var _i = 0, diagnostics_4 = diagnostics; _i < diagnostics_4.length; _i++) {
113371
113419
  var diagnostic = diagnostics_4[_i];
113420
+ var diagnosticCode = "TS" + diagnostic.code;
113372
113421
  if (diagnostic.file) {
113373
113422
  var file = diagnostic.file, start = diagnostic.start;
113374
- output += formatLocation(file, start, host); // TODO: GH#18217
113375
- output += " - ";
113376
- }
113377
- output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
113378
- output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
113379
- output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
113380
- if (diagnostic.file) {
113423
+ var location = formatLocation(file, start, host); // TODO: GH#18217
113424
+ // Get the location string display length without color & escape sequences.
113425
+ var locationLength = location.replace(/\u001b[[0-9]+m/g, "").length;
113426
+ var codeLength = diagnosticCode.length;
113427
+ output += bullet + location;
113428
+ // Separate the error code from the location by a space on thinner terminals
113429
+ // and those of unknown length, or right-align it on wider terminals.
113430
+ var defaultPad = codeLength + 1;
113431
+ var padWidth = terminalWidth < 60 ? defaultPad : terminalWidth - (bullet.length + locationLength + codeLength);
113432
+ if (padWidth < diagnosticCode.length)
113433
+ padWidth = defaultPad;
113434
+ output += ts.padLeft(diagnosticCode, padWidth);
113435
+ output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, indent, getCategoryFormat(diagnostic.category), host); // TODO: GH#18217
113381
113436
  output += host.getNewLine();
113382
- output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host); // TODO: GH#18217
113383
113437
  }
113438
+ var diagnosticText = flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine(), 0, /*pretty*/ true);
113439
+ diagnosticText = ts.map(diagnosticText.split(host.getNewLine()), function (text) { return indent + text; }).join(host.getNewLine());
113440
+ output += diagnosticText;
113441
+ output += host.getNewLine();
113384
113442
  if (diagnostic.relatedInformation) {
113385
- output += host.getNewLine();
113386
- for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
113387
- var _c = _b[_a], file = _c.file, start = _c.start, length_9 = _c.length, messageText = _c.messageText;
113443
+ for (var _c = 0, _d = diagnostic.relatedInformation; _c < _d.length; _c++) {
113444
+ var _e = _d[_c], file = _e.file, start = _e.start, length_9 = _e.length, messageText = _e.messageText;
113445
+ output += host.getNewLine();
113446
+ output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine(), 0, /*pretty*/ true);
113447
+ output += host.getNewLine();
113388
113448
  if (file) {
113449
+ output += indent + formatLocation(file, start, host); // TODO: GH#18217
113389
113450
  output += host.getNewLine();
113390
- output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217
113391
113451
  output += formatCodeSpan(file, start, length_9, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
113392
113452
  }
113393
- output += host.getNewLine();
113394
- output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
113395
113453
  }
113396
113454
  }
113397
- output += host.getNewLine();
113398
113455
  }
113399
113456
  return output;
113400
113457
  }
113401
113458
  ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
113402
- function flattenDiagnosticMessageText(diag, newLine, indent) {
113459
+ function flattenDiagnosticMessageText(diag, newLine, indent, pretty) {
113403
113460
  if (indent === void 0) { indent = 0; }
113461
+ if (pretty === void 0) { pretty = false; }
113404
113462
  if (ts.isString(diag)) {
113405
113463
  return diag;
113406
113464
  }
@@ -113410,9 +113468,16 @@ var ts;
113410
113468
  var result = "";
113411
113469
  if (indent) {
113412
113470
  result += newLine;
113413
- for (var i = 0; i < indent; i++) {
113414
- result += " ";
113471
+ // If using pretty formatting, the second line shouldn't be indented past the first,
113472
+ // instead separating the two with an extra empty line.
113473
+ var indentsToReplaceWithNewLines = pretty ? 1 : 0;
113474
+ if (indent > indentsToReplaceWithNewLines) {
113475
+ for (var i = indentsToReplaceWithNewLines; i < indent; i++) {
113476
+ result += " ";
113477
+ }
113415
113478
  }
113479
+ else
113480
+ result += newLine;
113416
113481
  }
113417
113482
  result += diag.messageText;
113418
113483
  indent++;
@@ -126166,6 +126231,16 @@ var ts;
126166
126231
  : ts.getLocaleSpecificMessage(diag);
126167
126232
  }
126168
126233
  ts.diagnosticToString = diagnosticToString;
126234
+ /**
126235
+ * Get format code settings for a code writing context (e.g. when formatting text changes or completions code).
126236
+ */
126237
+ function getFormatCodeSettingsForWriting(_a, sourceFile) {
126238
+ var options = _a.options;
126239
+ var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
126240
+ var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
126241
+ return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
126242
+ }
126243
+ ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
126169
126244
  // #endregion
126170
126245
  })(ts || (ts = {}));
126171
126246
  /*@internal*/
@@ -127789,7 +127864,8 @@ var ts;
127789
127864
  return convertPathCompletions(completion.paths);
127790
127865
  case 1 /* Properties */: {
127791
127866
  var entries = ts.createSortedArray();
127792
- Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
127867
+ Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options,
127868
+ /*formatContext*/ undefined); // Target will not be used, so arbitrary
127793
127869
  return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
127794
127870
  }
127795
127871
  case 2 /* Types */: {
@@ -128610,7 +128686,7 @@ var ts;
128610
128686
  return result;
128611
128687
  }
128612
128688
  }
128613
- function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken) {
128689
+ function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
128614
128690
  var _a;
128615
128691
  var previousToken = getRelevantTokens(position, sourceFile).previousToken;
128616
128692
  if (triggerCharacter && !ts.isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
@@ -128650,7 +128726,7 @@ var ts;
128650
128726
  }
128651
128727
  switch (completionData.kind) {
128652
128728
  case 0 /* Data */:
128653
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
128729
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
128654
128730
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
128655
128731
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
128656
128732
  }
@@ -128770,7 +128846,7 @@ var ts;
128770
128846
  // StringLiteralLike locations are handled separately in stringCompletions.ts
128771
128847
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
128772
128848
  }
128773
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
128849
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
128774
128850
  var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
128775
128851
  // Verify if the file is JSX language variant
128776
128852
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -128782,7 +128858,7 @@ var ts;
128782
128858
  var entries = ts.createSortedArray();
128783
128859
  if (isUncheckedFile(sourceFile, compilerOptions)) {
128784
128860
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
128785
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128861
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128786
128862
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
128787
128863
  }
128788
128864
  else {
@@ -128790,7 +128866,7 @@ var ts;
128790
128866
  return undefined;
128791
128867
  }
128792
128868
  getCompletionEntriesFromSymbols(symbols, entries,
128793
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128869
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128794
128870
  }
128795
128871
  if (keywordFilters !== 0 /* None */) {
128796
128872
  var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
@@ -128896,7 +128972,7 @@ var ts;
128896
128972
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
128897
128973
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
128898
128974
  }
128899
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
128975
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
128900
128976
  var _a, _b;
128901
128977
  var insertText;
128902
128978
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -128961,7 +129037,7 @@ var ts;
128961
129037
  completionKind === 3 /* MemberLike */ &&
128962
129038
  isClassLikeMemberCompletion(symbol, location)) {
128963
129039
  var importAdder = void 0;
128964
- (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129040
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
128965
129041
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
128966
129042
  hasAction = true;
128967
129043
  source = CompletionSource.ClassMemberSnippet;
@@ -129060,7 +129136,7 @@ var ts;
129060
129136
  ts.isSyntaxList(location) &&
129061
129137
  ts.isClassLike(location.parent)));
129062
129138
  }
129063
- function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
129139
+ function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext) {
129064
129140
  var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
129065
129141
  if (!classLikeDeclaration) {
129066
129142
  return { insertText: name };
@@ -129077,15 +129153,16 @@ var ts;
129077
129153
  newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
129078
129154
  });
129079
129155
  var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
129156
+ // Create empty body for possible method implementation.
129080
129157
  var body;
129081
129158
  if (preferences.includeCompletionsWithSnippetText) {
129082
129159
  isSnippet = true;
129083
129160
  // We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
129084
129161
  // if it has one, so that the cursor ends up in the body once the completion is inserted.
129085
129162
  // Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
129086
- var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
129087
- ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
129088
- body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
129163
+ var emptyStmt = ts.factory.createEmptyStatement();
129164
+ body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
129165
+ ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
129089
129166
  }
129090
129167
  else {
129091
129168
  body = ts.factory.createBlock([], /* multiline */ true);
@@ -129131,7 +129208,27 @@ var ts;
129131
129208
  completionNodes.push(node);
129132
129209
  }, body, 2 /* Property */, isAbstract);
129133
129210
  if (completionNodes.length) {
129134
- insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129211
+ // If we have access to formatting settings, we print the nodes using the emitter,
129212
+ // and then format the printed text.
129213
+ if (formatContext) {
129214
+ var syntheticFile_1 = {
129215
+ text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
129216
+ getLineAndCharacterOfPosition: function (pos) {
129217
+ return ts.getLineAndCharacterOfPosition(this, pos);
129218
+ },
129219
+ };
129220
+ var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
129221
+ var changes = ts.flatMap(completionNodes, function (node) {
129222
+ var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
129223
+ return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
129224
+ /* indentation */ 0,
129225
+ /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
129226
+ });
129227
+ insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
129228
+ }
129229
+ else { // Otherwise, just use emitter to print the new nodes.
129230
+ insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129231
+ }
129135
129232
  }
129136
129233
  return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
129137
129234
  }
@@ -129175,8 +129272,8 @@ var ts;
129175
129272
  return undefined;
129176
129273
  }
129177
129274
  function createSnippetPrinter(printerOptions) {
129178
- var printer = ts.createPrinter(printerOptions);
129179
- var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
129275
+ var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
129276
+ var printer = ts.createPrinter(printerOptions, baseWriter);
129180
129277
  var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
129181
129278
  return {
129182
129279
  printSnippetList: printSnippetList,
@@ -129281,7 +129378,7 @@ var ts;
129281
129378
  return CompletionSource.ThisProperty;
129282
129379
  }
129283
129380
  }
129284
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129381
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129285
129382
  var _a;
129286
129383
  var start = ts.timestamp();
129287
129384
  var variableDeclaration = getVariableDeclaration(location);
@@ -129302,7 +129399,7 @@ var ts;
129302
129399
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
129303
129400
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
129304
129401
  var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
129305
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
129402
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
129306
129403
  if (!entry) {
129307
129404
  continue;
129308
129405
  }
@@ -129498,7 +129595,7 @@ var ts;
129498
129595
  }
129499
129596
  }
129500
129597
  if (source === CompletionSource.ClassMemberSnippet) {
129501
- var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
129598
+ var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken, formatContext).importAdder;
129502
129599
  if (importAdder) {
129503
129600
  var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
129504
129601
  return {
@@ -145382,19 +145479,13 @@ var ts;
145382
145479
  + ((!options.suffix || ts.endsWith(noIndent, options.suffix))
145383
145480
  ? "" : options.suffix);
145384
145481
  }
145385
- function getFormatCodeSettingsForWriting(_a, sourceFile) {
145386
- var options = _a.options;
145387
- var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
145388
- var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile);
145389
- return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
145390
- }
145391
145482
  /** Note: this may mutate `nodeIn`. */
145392
145483
  function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) {
145393
145484
  var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta;
145394
145485
  var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text;
145395
145486
  if (validate)
145396
145487
  validate(node, text);
145397
- var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
145488
+ var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
145398
145489
  var initialIndentation = indentation !== undefined
145399
145490
  ? indentation
145400
145491
  : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos);
@@ -145442,6 +145533,7 @@ var ts;
145442
145533
  ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
145443
145534
  return newNode;
145444
145535
  }
145536
+ textChanges_3.assignPositionsToNode = assignPositionsToNode;
145445
145537
  function assignPositionsToNodeArray(nodes, visitor, test, start, count) {
145446
145538
  var visited = ts.visitNodes(nodes, visitor, test, start, count);
145447
145539
  if (!visited) {
@@ -145612,6 +145704,7 @@ var ts;
145612
145704
  clear: clear
145613
145705
  };
145614
145706
  }
145707
+ textChanges_3.createWriter = createWriter;
145615
145708
  function getInsertionPositionAtSourceFileTop(sourceFile) {
145616
145709
  var lastPrologue;
145617
145710
  for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
@@ -160509,12 +160602,12 @@ var ts;
160509
160602
  synchronizeHostData();
160510
160603
  return __spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true);
160511
160604
  }
160512
- function getCompletionsAtPosition(fileName, position, options) {
160605
+ function getCompletionsAtPosition(fileName, position, options, formattingSettings) {
160513
160606
  if (options === void 0) { options = ts.emptyOptions; }
160514
160607
  // Convert from deprecated options names to new names
160515
160608
  var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions });
160516
160609
  synchronizeHostData();
160517
- return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken);
160610
+ return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken, formattingSettings && ts.formatting.getFormatContext(formattingSettings, host));
160518
160611
  }
160519
160612
  function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) {
160520
160613
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -162677,9 +162770,9 @@ var ts;
162677
162770
  * to provide at the given source position and providing a member completion
162678
162771
  * list if requested.
162679
162772
  */
162680
- LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences) {
162773
+ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) {
162681
162774
  var _this = this;
162682
- return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); });
162775
+ return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); });
162683
162776
  };
162684
162777
  /** Get a string based representation of a completion list entry details */
162685
162778
  LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) {
@@ -171233,6 +171326,9 @@ var ts;
171233
171326
  }
171234
171327
  return;
171235
171328
  }
171329
+ this.writeMessage(msg);
171330
+ };
171331
+ Session.prototype.writeMessage = function (msg) {
171236
171332
  var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine);
171237
171333
  ts.perfLogger.logEvent("Response message size: " + msgText.length);
171238
171334
  this.host.write(msgText);
@@ -171984,7 +172080,7 @@ var ts;
171984
172080
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
171985
172081
  var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
171986
172082
  var position = this.getPosition(args, scriptInfo);
171987
- var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }));
172083
+ var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }), project.projectService.getFormatCodeOptions(file));
171988
172084
  if (completions === undefined)
171989
172085
  return undefined;
171990
172086
  if (kind === "completions-full" /* CompletionsFull */)
@@ -175272,12 +175368,40 @@ var ts;
175272
175368
  };
175273
175369
  return IOSession;
175274
175370
  }(server.Session));
175371
+ var IpcIOSession = /** @class */ (function (_super) {
175372
+ __extends(IpcIOSession, _super);
175373
+ function IpcIOSession() {
175374
+ return _super !== null && _super.apply(this, arguments) || this;
175375
+ }
175376
+ IpcIOSession.prototype.writeMessage = function (msg) {
175377
+ var verboseLogging = logger.hasLevel(server.LogLevel.verbose);
175378
+ if (verboseLogging) {
175379
+ var json = JSON.stringify(msg);
175380
+ logger.info(msg.type + ":" + server.indent(json));
175381
+ }
175382
+ process.send(msg);
175383
+ };
175384
+ IpcIOSession.prototype.parseMessage = function (message) {
175385
+ return message;
175386
+ };
175387
+ IpcIOSession.prototype.toStringMessage = function (message) {
175388
+ return JSON.stringify(message, undefined, 2);
175389
+ };
175390
+ IpcIOSession.prototype.listen = function () {
175391
+ var _this = this;
175392
+ process.on("message", function (e) {
175393
+ _this.onMessage(e);
175394
+ });
175395
+ };
175396
+ return IpcIOSession;
175397
+ }(IOSession));
175275
175398
  var eventPort = parseEventPort(server.findArgument("--eventPort"));
175276
175399
  var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); // TODO: GH#18217
175277
175400
  var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation) || ts.combinePaths(ts.getDirectoryPath(ts.sys.getExecutingFilePath()), "typesMap.json");
175278
175401
  var npmLocation = server.findArgument(server.Arguments.NpmLocation);
175279
175402
  var validateDefaultNpmLocation = server.hasArgument(server.Arguments.ValidateDefaultNpmLocation);
175280
175403
  var disableAutomaticTypingAcquisition = server.hasArgument("--disableAutomaticTypingAcquisition");
175404
+ var useNodeIpc = server.hasArgument("--useNodeIpc");
175281
175405
  var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry);
175282
175406
  var commandLineTraceDir = server.findArgument("--traceDirectory");
175283
175407
  var traceDir = commandLineTraceDir
@@ -175286,7 +175410,7 @@ var ts;
175286
175410
  if (traceDir) {
175287
175411
  ts.startTracing("server", traceDir);
175288
175412
  }
175289
- var ioSession = new IOSession();
175413
+ var ioSession = useNodeIpc ? new IpcIOSession() : new IOSession();
175290
175414
  process.on("uncaughtException", function (err) {
175291
175415
  ioSession.logError(err, "unknown");
175292
175416
  });