@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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20211217";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220107";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -22436,7 +22436,7 @@ var ts;
22436
22436
  result.push(createModifier(144 /* ReadonlyKeyword */));
22437
22437
  if (flags & 256 /* Async */)
22438
22438
  result.push(createModifier(131 /* AsyncKeyword */));
22439
- return result;
22439
+ return result.length ? result : undefined;
22440
22440
  }
22441
22441
  //
22442
22442
  // Names
@@ -26393,32 +26393,36 @@ var ts;
26393
26393
  }
26394
26394
  function updateModifiers(node, modifiers) {
26395
26395
  var _a;
26396
+ var modifierArray;
26396
26397
  if (typeof modifiers === "number") {
26397
- modifiers = createModifiersFromModifierFlags(modifiers);
26398
- }
26399
- return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
26400
- ts.isPropertySignature(node) ? updatePropertySignature(node, modifiers, node.name, node.questionToken, node.type) :
26401
- ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifiers, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
26402
- ts.isMethodSignature(node) ? updateMethodSignature(node, modifiers, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
26403
- ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
26404
- ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifiers, node.parameters, node.body) :
26405
- ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.type, node.body) :
26406
- ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.body) :
26407
- ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifiers, node.parameters, node.type) :
26408
- ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26409
- ts.isArrowFunction(node) ? updateArrowFunction(node, modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
26410
- ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26411
- ts.isVariableStatement(node) ? updateVariableStatement(node, modifiers, node.declarationList) :
26412
- ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26413
- ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26414
- ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26415
- ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.type) :
26416
- ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) :
26417
- ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) :
26418
- ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.name, node.moduleReference) :
26419
- ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier, node.assertClause) :
26420
- ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) :
26421
- ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
26398
+ modifierArray = createModifiersFromModifierFlags(modifiers);
26399
+ }
26400
+ else {
26401
+ modifierArray = modifiers;
26402
+ }
26403
+ return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
26404
+ ts.isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) :
26405
+ ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifierArray, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
26406
+ ts.isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
26407
+ ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
26408
+ ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifierArray, node.parameters, node.body) :
26409
+ ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.type, node.body) :
26410
+ ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.body) :
26411
+ ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifierArray, node.parameters, node.type) :
26412
+ ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26413
+ ts.isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
26414
+ ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26415
+ ts.isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) :
26416
+ ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26417
+ ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26418
+ ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26419
+ ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.type) :
26420
+ ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifierArray, node.name, node.members) :
26421
+ ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifierArray, node.name, node.body) :
26422
+ ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.name, node.moduleReference) :
26423
+ ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) :
26424
+ ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifierArray, node.expression) :
26425
+ ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
26422
26426
  ts.Debug.assertNever(node);
26423
26427
  }
26424
26428
  function asNodeArray(array) {
@@ -57918,7 +57922,7 @@ var ts;
57918
57922
  return symbol_1;
57919
57923
  }
57920
57924
  }
57921
- return globalObjectType === undefined ? undefined : getPropertyOfObjectType(globalObjectType, name);
57925
+ return getPropertyOfObjectType(globalObjectType, name);
57922
57926
  }
57923
57927
  if (type.flags & 3145728 /* UnionOrIntersection */) {
57924
57928
  return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
@@ -67631,7 +67635,8 @@ var ts;
67631
67635
  return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
67632
67636
  access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
67633
67637
  access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
67634
- undefined;
67638
+ access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
67639
+ undefined;
67635
67640
  }
67636
67641
  function containsMatchingReference(source, target) {
67637
67642
  while (ts.isAccessExpression(source)) {
@@ -68971,13 +68976,14 @@ var ts;
68971
68976
  return result;
68972
68977
  }
68973
68978
  function getCandidateDiscriminantPropertyAccess(expr) {
68974
- if (ts.isBindingPattern(reference)) {
68975
- // When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
68976
- // An identifier for a destructuring variable declared in the same binding pattern is a candidate.
68979
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
68980
+ // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
68981
+ // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
68982
+ // parameter declared in the same parameter list is a candidate.
68977
68983
  if (ts.isIdentifier(expr)) {
68978
68984
  var symbol = getResolvedSymbol(expr);
68979
68985
  var declaration = symbol.valueDeclaration;
68980
- if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
68986
+ if (declaration && (ts.isBindingElement(declaration) || ts.isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
68981
68987
  return declaration;
68982
68988
  }
68983
68989
  }
@@ -69779,42 +69785,78 @@ var ts;
69779
69785
  }
69780
69786
  }
69781
69787
  function getNarrowedTypeOfSymbol(symbol, location) {
69782
- // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69783
- // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69784
- // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69785
- // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69786
- // other binding elements from the same destructuring. Consider:
69787
- //
69788
- // type Action =
69789
- // | { kind: 'A', payload: number }
69790
- // | { kind: 'B', payload: string };
69791
- //
69792
- // function f1({ kind, payload }: Action) {
69793
- // if (kind === 'A') {
69794
- // payload.toFixed();
69795
- // }
69796
- // if (kind === 'B') {
69797
- // payload.toUpperCase();
69798
- // }
69799
- // }
69800
- //
69801
- // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69802
- // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69803
- // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69804
- // destructuring from the narrowed parent type.
69805
69788
  var declaration = symbol.valueDeclaration;
69806
- if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69807
- var parent = declaration.parent.parent;
69808
- if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69809
- var links = getNodeLinks(location);
69810
- if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69811
- links.flags |= 268435456 /* InCheckIdentifier */;
69812
- var parentType = getTypeForBindingElementParent(parent);
69813
- links.flags &= ~268435456 /* InCheckIdentifier */;
69814
- if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69815
- var pattern = declaration.parent;
69816
- var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69817
- return getBindingElementTypeFromParentType(declaration, narrowedType);
69789
+ if (declaration) {
69790
+ // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69791
+ // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69792
+ // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69793
+ // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69794
+ // other binding elements from the same destructuring. Consider:
69795
+ //
69796
+ // type Action =
69797
+ // | { kind: 'A', payload: number }
69798
+ // | { kind: 'B', payload: string };
69799
+ //
69800
+ // function f({ kind, payload }: Action) {
69801
+ // if (kind === 'A') {
69802
+ // payload.toFixed();
69803
+ // }
69804
+ // if (kind === 'B') {
69805
+ // payload.toUpperCase();
69806
+ // }
69807
+ // }
69808
+ //
69809
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69810
+ // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69811
+ // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69812
+ // destructuring from the narrowed parent type.
69813
+ if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69814
+ var parent = declaration.parent.parent;
69815
+ if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69816
+ var links = getNodeLinks(location);
69817
+ if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69818
+ links.flags |= 268435456 /* InCheckIdentifier */;
69819
+ var parentType = getTypeForBindingElementParent(parent);
69820
+ links.flags &= ~268435456 /* InCheckIdentifier */;
69821
+ if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69822
+ var pattern = declaration.parent;
69823
+ var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69824
+ return getBindingElementTypeFromParentType(declaration, narrowedType);
69825
+ }
69826
+ }
69827
+ }
69828
+ }
69829
+ // If we have a const-like parameter with no type annotation or initializer, and if the parameter is contextually
69830
+ // typed by a signature with a single rest parameter of a union of tuple types, one or more of the parameters may
69831
+ // represent discriminant tuple elements, and we want the effects of conditional checks on such discriminants to
69832
+ // affect the types of other parameters in the same parameter list. Consider:
69833
+ //
69834
+ // type Action = [kind: 'A', payload: number] | [kind: 'B', payload: string];
69835
+ //
69836
+ // const f: (...args: Action) => void = (kind, payload) => {
69837
+ // if (kind === 'A') {
69838
+ // payload.toFixed();
69839
+ // }
69840
+ // if (kind === 'B') {
69841
+ // payload.toUpperCase();
69842
+ // }
69843
+ // }
69844
+ //
69845
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69846
+ // the arrow function AST node for '(kind, payload) => ...' as a pseudo-reference and narrow this reference as
69847
+ // if it occurred in the specified location. We then recompute the narrowed parameter type by indexing into the
69848
+ // narrowed tuple type.
69849
+ if (ts.isParameter(declaration) && !declaration.type && !declaration.initializer && !declaration.dotDotDotToken) {
69850
+ var func = declaration.parent;
69851
+ if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
69852
+ var contextualSignature = getContextualSignature(func);
69853
+ if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
69854
+ var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
69855
+ if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
69856
+ var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
69857
+ var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
69858
+ return getIndexedAccessType(narrowedType, getNumberLiteralType(index));
69859
+ }
69818
69860
  }
69819
69861
  }
69820
69862
  }
@@ -109212,7 +109254,7 @@ var ts;
109212
109254
  emitPlaceholder(hint, node, snippet);
109213
109255
  break;
109214
109256
  case 0 /* TabStop */:
109215
- emitTabStop(snippet);
109257
+ emitTabStop(hint, node, snippet);
109216
109258
  break;
109217
109259
  }
109218
109260
  }
@@ -109222,7 +109264,10 @@ var ts;
109222
109264
  nonEscapingWrite("}"); // `}`
109223
109265
  // `${2:...}`
109224
109266
  }
109225
- function emitTabStop(snippet) {
109267
+ function emitTabStop(hint, node, snippet) {
109268
+ // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text.
109269
+ ts.Debug.assert(node.kind === 235 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + ".");
109270
+ ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement.");
109226
109271
  nonEscapingWrite("$" + snippet.order);
109227
109272
  }
109228
109273
  //
@@ -113483,8 +113528,8 @@ var ts;
113483
113528
  var gutterSeparator = " ";
113484
113529
  var resetEscapeSequence = "\u001b[0m";
113485
113530
  var ellipsis = "...";
113531
+ var bullet = "● ";
113486
113532
  var halfIndent = " ";
113487
- var indent = " ";
113488
113533
  function getCategoryFormat(category) {
113489
113534
  switch (category) {
113490
113535
  case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
@@ -113498,7 +113543,7 @@ var ts;
113498
113543
  return formatStyle + text + resetEscapeSequence;
113499
113544
  }
113500
113545
  ts.formatColorAndReset = formatColorAndReset;
113501
- function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
113546
+ function formatCodeSpan(file, start, length, indent, underlineColor, host) {
113502
113547
  var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
113503
113548
  var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
113504
113549
  var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
@@ -113522,24 +113567,24 @@ var ts;
113522
113567
  lineContent = ts.trimStringEnd(lineContent); // trim from end
113523
113568
  lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
113524
113569
  // Output the gutter and the actual contents of the line.
113525
- context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
113570
+ context += indent + ts.padLeft("|", gutterWidth) + gutterSeparator;
113526
113571
  context += lineContent + host.getNewLine();
113527
- // Output the gutter and the error span for the line using tildes.
113528
- context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
113529
- context += squiggleColor;
113572
+ // Output the gutter and the error span for the line using underlines.
113573
+ context += indent + ts.padLeft("", gutterWidth) + gutterSeparator;
113574
+ context += underlineColor;
113530
113575
  if (i === firstLine) {
113531
113576
  // If we're on the last line, then limit it to the last character of the last line.
113532
- // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
113577
+ // Otherwise, we'll just underline the rest of the line, giving 'slice' no end position.
113533
113578
  var lastCharForLine = i === lastLine ? lastLineChar : undefined;
113534
113579
  context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
113535
- context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
113580
+ context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "▔");
113536
113581
  }
113537
113582
  else if (i === lastLine) {
113538
- context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
113583
+ context += lineContent.slice(0, lastLineChar).replace(/./g, "▔");
113539
113584
  }
113540
113585
  else {
113541
- // Squiggle the entire line.
113542
- context += lineContent.replace(/./g, "~");
113586
+ // Underline the entire line.
113587
+ context += lineContent.replace(/./g, "▔");
113543
113588
  }
113544
113589
  context += resetEscapeSequence;
113545
113590
  }
@@ -113560,41 +113605,54 @@ var ts;
113560
113605
  }
113561
113606
  ts.formatLocation = formatLocation;
113562
113607
  function formatDiagnosticsWithColorAndContext(diagnostics, host) {
113608
+ var _a, _b;
113609
+ var terminalWidth = (_b = (_a = ts.sys.getWidthOfTerminal) === null || _a === void 0 ? void 0 : _a.call(ts.sys)) !== null && _b !== void 0 ? _b : 0;
113610
+ var indent = terminalWidth < 60 ? "" : halfIndent;
113563
113611
  var output = "";
113564
113612
  for (var _i = 0, diagnostics_4 = diagnostics; _i < diagnostics_4.length; _i++) {
113565
113613
  var diagnostic = diagnostics_4[_i];
113614
+ var diagnosticCode = "TS" + diagnostic.code;
113566
113615
  if (diagnostic.file) {
113567
113616
  var file = diagnostic.file, start = diagnostic.start;
113568
- output += formatLocation(file, start, host); // TODO: GH#18217
113569
- output += " - ";
113570
- }
113571
- output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
113572
- output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
113573
- output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
113574
- if (diagnostic.file) {
113617
+ var location = formatLocation(file, start, host); // TODO: GH#18217
113618
+ // Get the location string display length without color & escape sequences.
113619
+ var locationLength = location.replace(/\u001b[[0-9]+m/g, "").length;
113620
+ var codeLength = diagnosticCode.length;
113621
+ output += bullet + location;
113622
+ // Separate the error code from the location by a space on thinner terminals
113623
+ // and those of unknown length, or right-align it on wider terminals.
113624
+ var defaultPad = codeLength + 1;
113625
+ var padWidth = terminalWidth < 60 ? defaultPad : terminalWidth - (bullet.length + locationLength + codeLength);
113626
+ if (padWidth < diagnosticCode.length)
113627
+ padWidth = defaultPad;
113628
+ output += ts.padLeft(diagnosticCode, padWidth);
113629
+ output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, indent, getCategoryFormat(diagnostic.category), host); // TODO: GH#18217
113575
113630
  output += host.getNewLine();
113576
- output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host); // TODO: GH#18217
113577
113631
  }
113632
+ var diagnosticText = flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine(), 0, /*pretty*/ true);
113633
+ diagnosticText = ts.map(diagnosticText.split(host.getNewLine()), function (text) { return indent + text; }).join(host.getNewLine());
113634
+ output += diagnosticText;
113635
+ output += host.getNewLine();
113578
113636
  if (diagnostic.relatedInformation) {
113579
- output += host.getNewLine();
113580
- for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
113581
- var _c = _b[_a], file = _c.file, start = _c.start, length_9 = _c.length, messageText = _c.messageText;
113637
+ for (var _c = 0, _d = diagnostic.relatedInformation; _c < _d.length; _c++) {
113638
+ var _e = _d[_c], file = _e.file, start = _e.start, length_9 = _e.length, messageText = _e.messageText;
113639
+ output += host.getNewLine();
113640
+ output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine(), 0, /*pretty*/ true);
113641
+ output += host.getNewLine();
113582
113642
  if (file) {
113643
+ output += indent + formatLocation(file, start, host); // TODO: GH#18217
113583
113644
  output += host.getNewLine();
113584
- output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217
113585
113645
  output += formatCodeSpan(file, start, length_9, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
113586
113646
  }
113587
- output += host.getNewLine();
113588
- output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
113589
113647
  }
113590
113648
  }
113591
- output += host.getNewLine();
113592
113649
  }
113593
113650
  return output;
113594
113651
  }
113595
113652
  ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
113596
- function flattenDiagnosticMessageText(diag, newLine, indent) {
113653
+ function flattenDiagnosticMessageText(diag, newLine, indent, pretty) {
113597
113654
  if (indent === void 0) { indent = 0; }
113655
+ if (pretty === void 0) { pretty = false; }
113598
113656
  if (ts.isString(diag)) {
113599
113657
  return diag;
113600
113658
  }
@@ -113604,9 +113662,16 @@ var ts;
113604
113662
  var result = "";
113605
113663
  if (indent) {
113606
113664
  result += newLine;
113607
- for (var i = 0; i < indent; i++) {
113608
- result += " ";
113665
+ // If using pretty formatting, the second line shouldn't be indented past the first,
113666
+ // instead separating the two with an extra empty line.
113667
+ var indentsToReplaceWithNewLines = pretty ? 1 : 0;
113668
+ if (indent > indentsToReplaceWithNewLines) {
113669
+ for (var i = indentsToReplaceWithNewLines; i < indent; i++) {
113670
+ result += " ";
113671
+ }
113609
113672
  }
113673
+ else
113674
+ result += newLine;
113610
113675
  }
113611
113676
  result += diag.messageText;
113612
113677
  indent++;
@@ -126748,6 +126813,16 @@ var ts;
126748
126813
  : ts.getLocaleSpecificMessage(diag);
126749
126814
  }
126750
126815
  ts.diagnosticToString = diagnosticToString;
126816
+ /**
126817
+ * Get format code settings for a code writing context (e.g. when formatting text changes or completions code).
126818
+ */
126819
+ function getFormatCodeSettingsForWriting(_a, sourceFile) {
126820
+ var options = _a.options;
126821
+ var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
126822
+ var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
126823
+ return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
126824
+ }
126825
+ ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
126751
126826
  // #endregion
126752
126827
  })(ts || (ts = {}));
126753
126828
  /*@internal*/
@@ -128371,7 +128446,8 @@ var ts;
128371
128446
  return convertPathCompletions(completion.paths);
128372
128447
  case 1 /* Properties */: {
128373
128448
  var entries = ts.createSortedArray();
128374
- 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
128449
+ Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options,
128450
+ /*formatContext*/ undefined); // Target will not be used, so arbitrary
128375
128451
  return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
128376
128452
  }
128377
128453
  case 2 /* Types */: {
@@ -129192,7 +129268,7 @@ var ts;
129192
129268
  return result;
129193
129269
  }
129194
129270
  }
129195
- function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken) {
129271
+ function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
129196
129272
  var _a;
129197
129273
  var previousToken = getRelevantTokens(position, sourceFile).previousToken;
129198
129274
  if (triggerCharacter && !ts.isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
@@ -129232,7 +129308,7 @@ var ts;
129232
129308
  }
129233
129309
  switch (completionData.kind) {
129234
129310
  case 0 /* Data */:
129235
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
129311
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
129236
129312
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129237
129313
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129238
129314
  }
@@ -129352,7 +129428,7 @@ var ts;
129352
129428
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129353
129429
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129354
129430
  }
129355
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
129431
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129356
129432
  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;
129357
129433
  // Verify if the file is JSX language variant
129358
129434
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129364,7 +129440,7 @@ var ts;
129364
129440
  var entries = ts.createSortedArray();
129365
129441
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129366
129442
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129367
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129443
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129368
129444
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
129369
129445
  }
129370
129446
  else {
@@ -129372,7 +129448,7 @@ var ts;
129372
129448
  return undefined;
129373
129449
  }
129374
129450
  getCompletionEntriesFromSymbols(symbols, entries,
129375
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129451
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129376
129452
  }
129377
129453
  if (keywordFilters !== 0 /* None */) {
129378
129454
  var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
@@ -129478,7 +129554,7 @@ var ts;
129478
129554
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
129479
129555
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
129480
129556
  }
129481
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
129557
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
129482
129558
  var _a, _b;
129483
129559
  var insertText;
129484
129560
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -129543,7 +129619,7 @@ var ts;
129543
129619
  completionKind === 3 /* MemberLike */ &&
129544
129620
  isClassLikeMemberCompletion(symbol, location)) {
129545
129621
  var importAdder = void 0;
129546
- (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129622
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129547
129623
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
129548
129624
  hasAction = true;
129549
129625
  source = CompletionSource.ClassMemberSnippet;
@@ -129642,7 +129718,7 @@ var ts;
129642
129718
  ts.isSyntaxList(location) &&
129643
129719
  ts.isClassLike(location.parent)));
129644
129720
  }
129645
- function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
129721
+ function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext) {
129646
129722
  var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
129647
129723
  if (!classLikeDeclaration) {
129648
129724
  return { insertText: name };
@@ -129659,15 +129735,16 @@ var ts;
129659
129735
  newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
129660
129736
  });
129661
129737
  var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
129738
+ // Create empty body for possible method implementation.
129662
129739
  var body;
129663
129740
  if (preferences.includeCompletionsWithSnippetText) {
129664
129741
  isSnippet = true;
129665
129742
  // We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
129666
129743
  // if it has one, so that the cursor ends up in the body once the completion is inserted.
129667
129744
  // Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
129668
- var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
129669
- ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
129670
- body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
129745
+ var emptyStmt = ts.factory.createEmptyStatement();
129746
+ body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
129747
+ ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
129671
129748
  }
129672
129749
  else {
129673
129750
  body = ts.factory.createBlock([], /* multiline */ true);
@@ -129713,7 +129790,27 @@ var ts;
129713
129790
  completionNodes.push(node);
129714
129791
  }, body, 2 /* Property */, isAbstract);
129715
129792
  if (completionNodes.length) {
129716
- insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129793
+ // If we have access to formatting settings, we print the nodes using the emitter,
129794
+ // and then format the printed text.
129795
+ if (formatContext) {
129796
+ var syntheticFile_1 = {
129797
+ text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
129798
+ getLineAndCharacterOfPosition: function (pos) {
129799
+ return ts.getLineAndCharacterOfPosition(this, pos);
129800
+ },
129801
+ };
129802
+ var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
129803
+ var changes = ts.flatMap(completionNodes, function (node) {
129804
+ var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
129805
+ return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
129806
+ /* indentation */ 0,
129807
+ /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
129808
+ });
129809
+ insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
129810
+ }
129811
+ else { // Otherwise, just use emitter to print the new nodes.
129812
+ insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129813
+ }
129717
129814
  }
129718
129815
  return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
129719
129816
  }
@@ -129757,8 +129854,8 @@ var ts;
129757
129854
  return undefined;
129758
129855
  }
129759
129856
  function createSnippetPrinter(printerOptions) {
129760
- var printer = ts.createPrinter(printerOptions);
129761
- var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
129857
+ var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
129858
+ var printer = ts.createPrinter(printerOptions, baseWriter);
129762
129859
  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)); } });
129763
129860
  return {
129764
129861
  printSnippetList: printSnippetList,
@@ -129863,7 +129960,7 @@ var ts;
129863
129960
  return CompletionSource.ThisProperty;
129864
129961
  }
129865
129962
  }
129866
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129963
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129867
129964
  var _a;
129868
129965
  var start = ts.timestamp();
129869
129966
  var variableDeclaration = getVariableDeclaration(location);
@@ -129884,7 +129981,7 @@ var ts;
129884
129981
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
129885
129982
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
129886
129983
  var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
129887
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
129984
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
129888
129985
  if (!entry) {
129889
129986
  continue;
129890
129987
  }
@@ -130080,7 +130177,7 @@ var ts;
130080
130177
  }
130081
130178
  }
130082
130179
  if (source === CompletionSource.ClassMemberSnippet) {
130083
- var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
130180
+ var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken, formatContext).importAdder;
130084
130181
  if (importAdder) {
130085
130182
  var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
130086
130183
  return {
@@ -145964,19 +146061,13 @@ var ts;
145964
146061
  + ((!options.suffix || ts.endsWith(noIndent, options.suffix))
145965
146062
  ? "" : options.suffix);
145966
146063
  }
145967
- function getFormatCodeSettingsForWriting(_a, sourceFile) {
145968
- var options = _a.options;
145969
- var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
145970
- var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile);
145971
- return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
145972
- }
145973
146064
  /** Note: this may mutate `nodeIn`. */
145974
146065
  function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) {
145975
146066
  var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta;
145976
146067
  var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text;
145977
146068
  if (validate)
145978
146069
  validate(node, text);
145979
- var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
146070
+ var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
145980
146071
  var initialIndentation = indentation !== undefined
145981
146072
  ? indentation
145982
146073
  : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos);
@@ -146024,6 +146115,7 @@ var ts;
146024
146115
  ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
146025
146116
  return newNode;
146026
146117
  }
146118
+ textChanges_3.assignPositionsToNode = assignPositionsToNode;
146027
146119
  function assignPositionsToNodeArray(nodes, visitor, test, start, count) {
146028
146120
  var visited = ts.visitNodes(nodes, visitor, test, start, count);
146029
146121
  if (!visited) {
@@ -146194,6 +146286,7 @@ var ts;
146194
146286
  clear: clear
146195
146287
  };
146196
146288
  }
146289
+ textChanges_3.createWriter = createWriter;
146197
146290
  function getInsertionPositionAtSourceFileTop(sourceFile) {
146198
146291
  var lastPrologue;
146199
146292
  for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
@@ -161091,12 +161184,12 @@ var ts;
161091
161184
  synchronizeHostData();
161092
161185
  return __spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true);
161093
161186
  }
161094
- function getCompletionsAtPosition(fileName, position, options) {
161187
+ function getCompletionsAtPosition(fileName, position, options, formattingSettings) {
161095
161188
  if (options === void 0) { options = ts.emptyOptions; }
161096
161189
  // Convert from deprecated options names to new names
161097
161190
  var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions });
161098
161191
  synchronizeHostData();
161099
- return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken);
161192
+ return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken, formattingSettings && ts.formatting.getFormatContext(formattingSettings, host));
161100
161193
  }
161101
161194
  function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) {
161102
161195
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -163259,9 +163352,9 @@ var ts;
163259
163352
  * to provide at the given source position and providing a member completion
163260
163353
  * list if requested.
163261
163354
  */
163262
- LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences) {
163355
+ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) {
163263
163356
  var _this = this;
163264
- return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); });
163357
+ return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); });
163265
163358
  };
163266
163359
  /** Get a string based representation of a completion list entry details */
163267
163360
  LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) {
@@ -171427,6 +171520,9 @@ var ts;
171427
171520
  }
171428
171521
  return;
171429
171522
  }
171523
+ this.writeMessage(msg);
171524
+ };
171525
+ Session.prototype.writeMessage = function (msg) {
171430
171526
  var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine);
171431
171527
  ts.perfLogger.logEvent("Response message size: " + msgText.length);
171432
171528
  this.host.write(msgText);
@@ -172178,7 +172274,7 @@ var ts;
172178
172274
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
172179
172275
  var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
172180
172276
  var position = this.getPosition(args, scriptInfo);
172181
- 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 }));
172277
+ 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));
172182
172278
  if (completions === undefined)
172183
172279
  return undefined;
172184
172280
  if (kind === "completions-full" /* CompletionsFull */)