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

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.
@@ -19,10 +19,57 @@ and limitations under the License.
19
19
 
20
20
 
21
21
  interface ErrorOptions {
22
- cause?: Error;
22
+ cause?: Error;
23
+ }
24
+
25
+ interface Error {
26
+ cause?: Error;
23
27
  }
24
28
 
25
29
  interface ErrorConstructor {
26
- new(message?: string, options?: ErrorOptions): Error;
27
- (message?: string, options?: ErrorOptions): Error;
30
+ new (message?: string, options?: ErrorOptions): Error;
31
+ (message?: string, options?: ErrorOptions): Error;
32
+ }
33
+
34
+ interface EvalErrorConstructor {
35
+ new (message?: string, options?: ErrorOptions): EvalError;
36
+ (message?: string, options?: ErrorOptions): EvalError;
37
+ }
38
+
39
+ interface RangeErrorConstructor {
40
+ new (message?: string, options?: ErrorOptions): RangeError;
41
+ (message?: string, options?: ErrorOptions): RangeError;
42
+ }
43
+
44
+ interface ReferenceErrorConstructor {
45
+ new (message?: string, options?: ErrorOptions): ReferenceError;
46
+ (message?: string, options?: ErrorOptions): ReferenceError;
47
+ }
48
+
49
+ interface SyntaxErrorConstructor {
50
+ new (message?: string, options?: ErrorOptions): SyntaxError;
51
+ (message?: string, options?: ErrorOptions): SyntaxError;
52
+ }
53
+
54
+ interface TypeErrorConstructor {
55
+ new (message?: string, options?: ErrorOptions): TypeError;
56
+ (message?: string, options?: ErrorOptions): TypeError;
57
+ }
58
+
59
+ interface URIErrorConstructor {
60
+ new (message?: string, options?: ErrorOptions): URIError;
61
+ (message?: string, options?: ErrorOptions): URIError;
62
+ }
63
+
64
+ interface AggregateErrorConstructor {
65
+ new (
66
+ errors: Iterable<any>,
67
+ message?: string,
68
+ options?: ErrorOptions
69
+ ): AggregateError;
70
+ (
71
+ errors: Iterable<any>,
72
+ message?: string,
73
+ options?: ErrorOptions
74
+ ): AggregateError;
28
75
  }
package/lib/tsc.js CHANGED
@@ -1855,6 +1855,14 @@ var ts;
1855
1855
  }
1856
1856
  return s.slice(0, end + 1);
1857
1857
  }
1858
+ function startWhitespaceCount(s) {
1859
+ for (var i = 0; i < s.length; i++) {
1860
+ if (!ts.isWhiteSpaceLike(s.charCodeAt(i)))
1861
+ return i;
1862
+ }
1863
+ return s.length;
1864
+ }
1865
+ ts.startWhitespaceCount = startWhitespaceCount;
1858
1866
  })(ts || (ts = {}));
1859
1867
  var ts;
1860
1868
  (function (ts) {
@@ -5806,12 +5814,12 @@ var ts;
5806
5814
  Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."),
5807
5815
  Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
5808
5816
  Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"),
5809
- _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
5817
+ _0_is_declared_here_Colon: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_Colon_2728", "'{0}' is declared here:"),
5810
5818
  Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."),
5811
5819
  An_arrow_function_cannot_have_a_this_parameter: diag(2730, ts.DiagnosticCategory.Error, "An_arrow_function_cannot_have_a_this_parameter_2730", "An arrow function cannot have a 'this' parameter."),
5812
5820
  Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."),
5813
5821
  Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension."),
5814
- Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
5822
+ Property_0_was_also_declared_here_Colon: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_Colon_2733", "Property '{0}' was also declared here:"),
5815
5823
  Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
5816
5824
  Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"),
5817
5825
  Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."),
@@ -6242,7 +6250,7 @@ var ts;
6242
6250
  Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"),
6243
6251
  Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
6244
6252
  Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
6245
- _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
6253
+ _0_was_also_declared_here_Colon: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_Colon_6203", "'{0}' was also declared here:"),
6246
6254
  and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
6247
6255
  All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."),
6248
6256
  package_json_has_a_typesVersions_field_with_version_specific_path_mappings: diag(6206, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206", "'package.json' has a 'typesVersions' field with version-specific path mappings."),
@@ -11002,7 +11010,8 @@ var ts;
11002
11010
  Float64Array: ["at"],
11003
11011
  BigInt64Array: ["at"],
11004
11012
  BigUint64Array: ["at"],
11005
- ObjectConstructor: ["hasOwn"]
11013
+ ObjectConstructor: ["hasOwn"],
11014
+ Error: ["cause"]
11006
11015
  }
11007
11016
  };
11008
11017
  }
@@ -39144,7 +39153,7 @@ var ts;
39144
39153
  if (adjustedNode === errorNode)
39145
39154
  return "continue";
39146
39155
  err.relatedInformation = err.relatedInformation || [];
39147
- var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
39156
+ var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here_Colon, symbolName);
39148
39157
  var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
39149
39158
  if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
39150
39159
  return "continue";
@@ -39738,7 +39747,7 @@ var ts;
39738
39747
  var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
39739
39748
  addErrorOrSuggestion(!isUncheckedJS, diagnostic);
39740
39749
  if (suggestion.valueDeclaration) {
39741
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
39750
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestionName));
39742
39751
  }
39743
39752
  }
39744
39753
  }
@@ -40035,7 +40044,7 @@ var ts;
40035
40044
  }
40036
40045
  }
40037
40046
  if (diagnosticMessage) {
40038
- ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
40047
+ ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here_Colon, declarationName));
40039
40048
  }
40040
40049
  }
40041
40050
  }
@@ -40307,7 +40316,7 @@ var ts;
40307
40316
  var suggestionName = symbolToString(suggestion);
40308
40317
  var diagnostic = error(name, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
40309
40318
  if (suggestion.valueDeclaration) {
40310
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
40319
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestionName));
40311
40320
  }
40312
40321
  }
40313
40322
  else {
@@ -40339,7 +40348,7 @@ var ts;
40339
40348
  error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
40340
40349
  if (localSymbol.declarations) {
40341
40350
  ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
40342
- return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
40351
+ return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here_Colon : ts.Diagnostics.and_here, declarationName);
40343
40352
  }), false));
40344
40353
  }
40345
40354
  }
@@ -45110,8 +45119,8 @@ var ts;
45110
45119
  if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
45111
45120
  var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
45112
45121
  var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
45113
- ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
45114
- ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
45122
+ ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here_Colon, unescapedName));
45123
+ ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here_Colon, unescapedName));
45115
45124
  }
45116
45125
  var union = createSymbol(s.flags | exportedMember.flags, name);
45117
45126
  union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
@@ -46361,7 +46370,7 @@ var ts;
46361
46370
  if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
46362
46371
  var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
46363
46372
  var name_4 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
46364
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_4); });
46373
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here_Colon, name_4); });
46365
46374
  error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_4);
46366
46375
  lateSymbol = createSymbol(0, memberName, 4096);
46367
46376
  }
@@ -53773,7 +53782,7 @@ var ts;
53773
53782
  var propName = symbolToString(unmatchedProperty);
53774
53783
  reportError.apply(void 0, __spreadArray([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target), false));
53775
53784
  if (ts.length(unmatchedProperty.declarations)) {
53776
- associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
53785
+ associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here_Colon, propName));
53777
53786
  }
53778
53787
  if (shouldSkipElaboration && errorInfo) {
53779
53788
  overrideNextErrorInfo++;
@@ -60850,7 +60859,7 @@ var ts;
60850
60859
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
60851
60860
  }
60852
60861
  if (diagnosticMessage) {
60853
- ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
60862
+ ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, declarationName));
60854
60863
  }
60855
60864
  }
60856
60865
  function isInPropertyInitializerOrClassStaticBlock(node) {
@@ -60940,7 +60949,7 @@ var ts;
60940
60949
  var suggestedName = ts.symbolName(suggestion);
60941
60950
  var message = isUncheckedJS ? ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2 : ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2;
60942
60951
  errorInfo = ts.chainDiagnosticMessages(errorInfo, message, missingProperty, container, suggestedName);
60943
- relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
60952
+ relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestedName);
60944
60953
  }
60945
60954
  else {
60946
60955
  var diagnostic = containerSeemsToBeEmptyDomElement(containingType)
@@ -61598,7 +61607,7 @@ var ts;
61598
61607
  var diag = ts.createDiagnosticForNode(node.tagName, ts.Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, ts.entityNameToString(node.tagName), absoluteMinArgCount, ts.entityNameToString(factory), maxParamCount);
61599
61608
  var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
61600
61609
  if (tagNameDeclaration) {
61601
- ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
61610
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here_Colon, ts.entityNameToString(node.tagName)));
61602
61611
  }
61603
61612
  if (errorOutputContainer && errorOutputContainer.skipLogging) {
61604
61613
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -67406,7 +67415,7 @@ var ts;
67406
67415
  var declName = ts.declarationNameToString(nextDeclarationName);
67407
67416
  var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
67408
67417
  if (firstDeclaration) {
67409
- ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
67418
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here_Colon, declName));
67410
67419
  }
67411
67420
  }
67412
67421
  function areDeclarationFlagsIdentical(left, right) {
@@ -93449,10 +93458,17 @@ var ts;
93449
93458
  var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
93450
93459
  var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
93451
93460
  var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
93461
+ var gutterWidth = 1;
93452
93462
  var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
93453
- var gutterWidth = (lastLine + 1 + "").length;
93454
- if (hasMoreThanFiveLines) {
93455
- gutterWidth = Math.max(ellipsis.length, gutterWidth);
93463
+ var whitespaceToTrim = Number.MAX_VALUE;
93464
+ for (var i = firstLine; i <= lastLine; i++) {
93465
+ if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
93466
+ i = lastLine - 1;
93467
+ }
93468
+ var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
93469
+ var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
93470
+ var lineContent = file.text.slice(lineStart, lineEnd);
93471
+ whitespaceToTrim = Math.min(whitespaceToTrim, ts.startWhitespaceCount(lineContent));
93456
93472
  }
93457
93473
  var context = "";
93458
93474
  for (var i = firstLine; i <= lastLine; i++) {
@@ -93465,15 +93481,19 @@ var ts;
93465
93481
  var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
93466
93482
  var lineContent = file.text.slice(lineStart, lineEnd);
93467
93483
  lineContent = ts.trimStringEnd(lineContent);
93484
+ lineContent = lineContent.slice(whitespaceToTrim);
93468
93485
  lineContent = lineContent.replace(/\t/g, " ");
93469
- context += indent + ts.padLeft("|", gutterWidth) + gutterSeparator;
93486
+ var gutterLine = "|";
93487
+ console.log({ gutterWidth: gutterWidth, indent: indent, lastLine: lastLine });
93488
+ context += indent + ts.padLeft(gutterLine, gutterWidth) + gutterSeparator;
93470
93489
  context += lineContent + host.getNewLine();
93471
93490
  context += indent + ts.padLeft("", gutterWidth) + gutterSeparator;
93472
93491
  context += underlineColor;
93473
93492
  if (i === firstLine) {
93474
93493
  var lastCharForLine = i === lastLine ? lastLineChar : undefined;
93475
- context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
93476
- context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "▔");
93494
+ context += lineContent.slice(0, firstLineChar - whitespaceToTrim).replace(/\S/g, " ");
93495
+ var amendedLastChar = lastCharForLine ? lastCharForLine - whitespaceToTrim : undefined;
93496
+ context += lineContent.slice(firstLineChar - whitespaceToTrim, amendedLastChar).replace(/./g, "▔");
93477
93497
  }
93478
93498
  else if (i === lastLine) {
93479
93499
  context += lineContent.slice(0, lastLineChar).replace(/./g, "▔");
@@ -93525,15 +93545,14 @@ var ts;
93525
93545
  output += diagnosticText;
93526
93546
  output += host.getNewLine();
93527
93547
  if (diagnostic.relatedInformation) {
93548
+ output += host.getNewLine();
93528
93549
  for (var _c = 0, _d = diagnostic.relatedInformation; _c < _d.length; _c++) {
93529
93550
  var _e = _d[_c], file = _e.file, start = _e.start, length_9 = _e.length, messageText = _e.messageText;
93530
- output += host.getNewLine();
93531
- output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine(), 0, true);
93532
- output += host.getNewLine();
93551
+ output += ts.trimStringStart(flattenDiagnosticMessageText(messageText, host.getNewLine(), 0, true));
93533
93552
  if (file) {
93534
- output += indent + formatLocation(file, start, host);
93553
+ output += " " + formatLocation(file, start, host);
93535
93554
  output += host.getNewLine();
93536
- output += formatCodeSpan(file, start, length_9, indent, ForegroundColorEscapeSequences.Cyan, host);
93555
+ output += formatCodeSpan(file, start, length_9, indent + " ", ForegroundColorEscapeSequences.Cyan, host);
93537
93556
  }
93538
93557
  }
93539
93558
  }
package/lib/tsserver.js CHANGED
@@ -2250,6 +2250,14 @@ var ts;
2250
2250
  }
2251
2251
  return s.slice(0, end + 1);
2252
2252
  }
2253
+ function startWhitespaceCount(s) {
2254
+ for (var i = 0; i < s.length; i++) {
2255
+ if (!ts.isWhiteSpaceLike(s.charCodeAt(i)))
2256
+ return i;
2257
+ }
2258
+ return s.length;
2259
+ }
2260
+ ts.startWhitespaceCount = startWhitespaceCount;
2253
2261
  })(ts || (ts = {}));
2254
2262
  /* @internal */
2255
2263
  var ts;
@@ -8592,12 +8600,12 @@ var ts;
8592
8600
  Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."),
8593
8601
  Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
8594
8602
  Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"),
8595
- _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
8603
+ _0_is_declared_here_Colon: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_Colon_2728", "'{0}' is declared here:"),
8596
8604
  Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."),
8597
8605
  An_arrow_function_cannot_have_a_this_parameter: diag(2730, ts.DiagnosticCategory.Error, "An_arrow_function_cannot_have_a_this_parameter_2730", "An arrow function cannot have a 'this' parameter."),
8598
8606
  Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."),
8599
8607
  Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension."),
8600
- Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
8608
+ Property_0_was_also_declared_here_Colon: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_Colon_2733", "Property '{0}' was also declared here:"),
8601
8609
  Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
8602
8610
  Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"),
8603
8611
  Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."),
@@ -9028,7 +9036,7 @@ var ts;
9028
9036
  Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"),
9029
9037
  Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
9030
9038
  Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
9031
- _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
9039
+ _0_was_also_declared_here_Colon: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_Colon_6203", "'{0}' was also declared here:"),
9032
9040
  and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
9033
9041
  All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."),
9034
9042
  package_json_has_a_typesVersions_field_with_version_specific_path_mappings: diag(6206, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206", "'package.json' has a 'typesVersions' field with version-specific path mappings."),
@@ -14456,7 +14464,8 @@ var ts;
14456
14464
  Float64Array: ["at"],
14457
14465
  BigInt64Array: ["at"],
14458
14466
  BigUint64Array: ["at"],
14459
- ObjectConstructor: ["hasOwn"]
14467
+ ObjectConstructor: ["hasOwn"],
14468
+ Error: ["cause"]
14460
14469
  }
14461
14470
  };
14462
14471
  }
@@ -47726,7 +47735,7 @@ var ts;
47726
47735
  if (adjustedNode === errorNode)
47727
47736
  return "continue";
47728
47737
  err.relatedInformation = err.relatedInformation || [];
47729
- var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
47738
+ var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here_Colon, symbolName);
47730
47739
  var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
47731
47740
  if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; }))
47732
47741
  return "continue";
@@ -48470,7 +48479,7 @@ var ts;
48470
48479
  var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
48471
48480
  addErrorOrSuggestion(!isUncheckedJS, diagnostic);
48472
48481
  if (suggestion.valueDeclaration) {
48473
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
48482
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestionName));
48474
48483
  }
48475
48484
  }
48476
48485
  }
@@ -48798,7 +48807,7 @@ var ts;
48798
48807
  }
48799
48808
  }
48800
48809
  if (diagnosticMessage) {
48801
- ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
48810
+ ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here_Colon, declarationName));
48802
48811
  }
48803
48812
  }
48804
48813
  }
@@ -49123,7 +49132,7 @@ var ts;
49123
49132
  var suggestionName = symbolToString(suggestion);
49124
49133
  var diagnostic = error(name, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
49125
49134
  if (suggestion.valueDeclaration) {
49126
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
49135
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestionName));
49127
49136
  }
49128
49137
  }
49129
49138
  else {
@@ -49155,7 +49164,7 @@ var ts;
49155
49164
  error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
49156
49165
  if (localSymbol.declarations) {
49157
49166
  ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
49158
- return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
49167
+ return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here_Colon : ts.Diagnostics.and_here, declarationName);
49159
49168
  }), false));
49160
49169
  }
49161
49170
  }
@@ -54658,8 +54667,8 @@ var ts;
54658
54667
  if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
54659
54668
  var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
54660
54669
  var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
54661
- ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
54662
- ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
54670
+ ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here_Colon, unescapedName));
54671
+ ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here_Colon, unescapedName));
54663
54672
  }
54664
54673
  var union = createSymbol(s.flags | exportedMember.flags, name);
54665
54674
  union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
@@ -56121,7 +56130,7 @@ var ts;
56121
56130
  // report an error at each declaration.
56122
56131
  var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
56123
56132
  var name_4 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
56124
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_4); });
56133
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here_Colon, name_4); });
56125
56134
  error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_4);
56126
56135
  lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
56127
56136
  }
@@ -64574,7 +64583,7 @@ var ts;
64574
64583
  var propName = symbolToString(unmatchedProperty);
64575
64584
  reportError.apply(void 0, __spreadArray([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target), false));
64576
64585
  if (ts.length(unmatchedProperty.declarations)) {
64577
- associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
64586
+ associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here_Colon, propName));
64578
64587
  }
64579
64588
  if (shouldSkipElaboration && errorInfo) {
64580
64589
  overrideNextErrorInfo++;
@@ -72845,7 +72854,7 @@ var ts;
72845
72854
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
72846
72855
  }
72847
72856
  if (diagnosticMessage) {
72848
- ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
72857
+ ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, declarationName));
72849
72858
  }
72850
72859
  }
72851
72860
  function isInPropertyInitializerOrClassStaticBlock(node) {
@@ -72939,7 +72948,7 @@ var ts;
72939
72948
  var suggestedName = ts.symbolName(suggestion);
72940
72949
  var message = isUncheckedJS ? ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2 : ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2;
72941
72950
  errorInfo = ts.chainDiagnosticMessages(errorInfo, message, missingProperty, container, suggestedName);
72942
- relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
72951
+ relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestedName);
72943
72952
  }
72944
72953
  else {
72945
72954
  var diagnostic = containerSeemsToBeEmptyDomElement(containingType)
@@ -73723,7 +73732,7 @@ var ts;
73723
73732
  var diag = ts.createDiagnosticForNode(node.tagName, ts.Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, ts.entityNameToString(node.tagName), absoluteMinArgCount, ts.entityNameToString(factory), maxParamCount);
73724
73733
  var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73725
73734
  if (tagNameDeclaration) {
73726
- ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
73735
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here_Colon, ts.entityNameToString(node.tagName)));
73727
73736
  }
73728
73737
  if (errorOutputContainer && errorOutputContainer.skipLogging) {
73729
73738
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -80466,7 +80475,7 @@ var ts;
80466
80475
  var declName = ts.declarationNameToString(nextDeclarationName);
80467
80476
  var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
80468
80477
  if (firstDeclaration) {
80469
- ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
80478
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here_Colon, declName));
80470
80479
  }
80471
80480
  }
80472
80481
  function areDeclarationFlagsIdentical(left, right) {
@@ -113353,10 +113362,18 @@ var ts;
113353
113362
  var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
113354
113363
  var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
113355
113364
  var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
113365
+ var gutterWidth = 1;
113356
113366
  var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
113357
- var gutterWidth = (lastLine + 1 + "").length;
113358
- if (hasMoreThanFiveLines) {
113359
- gutterWidth = Math.max(ellipsis.length, gutterWidth);
113367
+ // Dedent all of the code lines consistently
113368
+ var whitespaceToTrim = Number.MAX_VALUE;
113369
+ for (var i = firstLine; i <= lastLine; i++) {
113370
+ if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
113371
+ i = lastLine - 1;
113372
+ }
113373
+ var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
113374
+ var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
113375
+ var lineContent = file.text.slice(lineStart, lineEnd);
113376
+ whitespaceToTrim = Math.min(whitespaceToTrim, ts.startWhitespaceCount(lineContent));
113360
113377
  }
113361
113378
  var context = "";
113362
113379
  for (var i = firstLine; i <= lastLine; i++) {
@@ -113371,9 +113388,14 @@ var ts;
113371
113388
  var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
113372
113389
  var lineContent = file.text.slice(lineStart, lineEnd);
113373
113390
  lineContent = ts.trimStringEnd(lineContent); // trim from end
113391
+ lineContent = lineContent.slice(whitespaceToTrim); // remove preceding whitespaces
113374
113392
  lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
113393
+ // TODO: the extra characters for the grey bar has confusing issues
113394
+ // const gutterLine = ForegroundColorEscapeSequences.Grey + "|" + resetEscapeSequence;
113375
113395
  // Output the gutter and the actual contents of the line.
113376
- context += indent + ts.padLeft("|", gutterWidth) + gutterSeparator;
113396
+ var gutterLine = "|";
113397
+ console.log({ gutterWidth: gutterWidth, indent: indent, lastLine: lastLine });
113398
+ context += indent + ts.padLeft(gutterLine, gutterWidth) + gutterSeparator;
113377
113399
  context += lineContent + host.getNewLine();
113378
113400
  // Output the gutter and the error span for the line using underlines.
113379
113401
  context += indent + ts.padLeft("", gutterWidth) + gutterSeparator;
@@ -113382,8 +113404,9 @@ var ts;
113382
113404
  // If we're on the last line, then limit it to the last character of the last line.
113383
113405
  // Otherwise, we'll just underline the rest of the line, giving 'slice' no end position.
113384
113406
  var lastCharForLine = i === lastLine ? lastLineChar : undefined;
113385
- context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
113386
- context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "▔");
113407
+ context += lineContent.slice(0, firstLineChar - whitespaceToTrim).replace(/\S/g, " ");
113408
+ var amendedLastChar = lastCharForLine ? lastCharForLine - whitespaceToTrim : undefined;
113409
+ context += lineContent.slice(firstLineChar - whitespaceToTrim, amendedLastChar).replace(/./g, "▔");
113387
113410
  }
113388
113411
  else if (i === lastLine) {
113389
113412
  context += lineContent.slice(0, lastLineChar).replace(/./g, "▔");
@@ -113440,15 +113463,15 @@ var ts;
113440
113463
  output += diagnosticText;
113441
113464
  output += host.getNewLine();
113442
113465
  if (diagnostic.relatedInformation) {
113466
+ output += host.getNewLine();
113443
113467
  for (var _c = 0, _d = diagnostic.relatedInformation; _c < _d.length; _c++) {
113444
113468
  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();
113469
+ output += ts.trimStringStart(flattenDiagnosticMessageText(messageText, host.getNewLine(), 0, /*pretty*/ true));
113470
+ // output += host.getNewLine();
113448
113471
  if (file) {
113449
- output += indent + formatLocation(file, start, host); // TODO: GH#18217
113472
+ output += " " + formatLocation(file, start, host); // TODO: GH#18217
113450
113473
  output += host.getNewLine();
113451
- output += formatCodeSpan(file, start, length_9, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
113474
+ output += formatCodeSpan(file, start, length_9, indent + " ", ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
113452
113475
  }
113453
113476
  }
113454
113477
  }