tstyche 3.4.0 → 3.5.0

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.
@@ -695,7 +695,13 @@ declare function addsPackageText(packageVersion: string, packagePath: string): S
695
695
 
696
696
  declare function describeNameText(name: string, indent?: number): ScribblerJsx.Element;
697
697
 
698
- declare function diagnosticText(diagnostic: Diagnostic): ScribblerJsx.Element;
698
+ interface CodeFrameOptions {
699
+ linesAbove?: number;
700
+ linesBelow?: number;
701
+ showBreadcrumbs?: boolean;
702
+ }
703
+
704
+ declare function diagnosticText(diagnostic: Diagnostic, codeFrameOptions?: CodeFrameOptions): ScribblerJsx.Element;
699
705
 
700
706
  declare function taskStatusText(status: TaskResultStatus, task: Task): ScribblerJsx.Element;
701
707
 
@@ -871,4 +877,4 @@ declare class WatchService {
871
877
  watch(cancellationToken: CancellationToken): AsyncIterable<Array<Task>>;
872
878
  }
873
879
 
874
- export { Assertion, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, Config, ConfigDiagnosticText, type ConfigFileOptions, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, type DiagnosticsHandler, type EnvironmentOptions, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type ItemDefinition, Line, ListReporter, type MatchResult, OptionBrand, type OptionDefinition, OptionGroup, Options, OutputService, Path, type Plugin, PluginService, ProjectResult, ProjectService, type Reporter, type ReporterEvent, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, type ScribblerOptions, Select, SelectDiagnosticText, type SelectHookContext, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, type TargetResultStatus, Task, TaskResult, type TaskResultStatus, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, addsPackageText, defaultOptions, describeNameText, diagnosticText, environmentOptions, fileViewText, formattedText, helpText, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
880
+ export { Assertion, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, type CodeFrameOptions, CollectService, Color, type CommandLineOptions, Config, ConfigDiagnosticText, type ConfigFileOptions, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, type DiagnosticsHandler, type EnvironmentOptions, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type ItemDefinition, Line, ListReporter, type MatchResult, OptionBrand, type OptionDefinition, OptionGroup, Options, OutputService, Path, type Plugin, PluginService, ProjectResult, ProjectService, type Reporter, type ReporterEvent, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, type ScribblerOptions, Select, SelectDiagnosticText, type SelectHookContext, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, type TargetResultStatus, Task, TaskResult, type TaskResultStatus, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, addsPackageText, defaultOptions, describeNameText, diagnosticText, environmentOptions, fileViewText, formattedText, helpText, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
package/build/tstyche.js CHANGED
@@ -1157,11 +1157,11 @@ class CommandLineParser {
1157
1157
  this.#onDiagnostics = onDiagnostics;
1158
1158
  this.#options = Options.for(OptionGroup.CommandLine);
1159
1159
  }
1160
- async #onExpectsValue(optionName, optionBrand) {
1160
+ #onExpectsValue(optionName, optionBrand) {
1161
1161
  const text = [
1162
1162
  ConfigDiagnosticText.expectsValue(optionName),
1163
- await ConfigDiagnosticText.usage(optionName, optionBrand),
1164
- ].flat();
1163
+ ...ConfigDiagnosticText.usage(optionName, optionBrand),
1164
+ ];
1165
1165
  this.#onDiagnostics(Diagnostic.error(text));
1166
1166
  }
1167
1167
  async parse(commandLineArgs) {
@@ -1215,7 +1215,7 @@ class CommandLineParser {
1215
1215
  index++;
1216
1216
  break;
1217
1217
  }
1218
- await this.#onExpectsValue(optionName, optionDefinition.brand);
1218
+ this.#onExpectsValue(optionName, optionDefinition.brand);
1219
1219
  break;
1220
1220
  case OptionBrand.String:
1221
1221
  if (optionValue !== "") {
@@ -1225,7 +1225,7 @@ class CommandLineParser {
1225
1225
  index++;
1226
1226
  break;
1227
1227
  }
1228
- await this.#onExpectsValue(optionName, optionDefinition.brand);
1228
+ this.#onExpectsValue(optionName, optionDefinition.brand);
1229
1229
  break;
1230
1230
  }
1231
1231
  return index;
@@ -2013,12 +2013,15 @@ function CodeLineText({ gutterWidth, lineNumber, lineNumberColor = Color.Gray, l
2013
2013
  function SquiggleLineText({ gutterWidth, indentWidth = 0, squiggleColor, squiggleWidth }) {
2014
2014
  return (jsx(Line, { children: [" ".repeat(gutterWidth), jsx(Text, { color: Color.Gray, children: " | " }), " ".repeat(indentWidth), jsx(Text, { color: squiggleColor, children: "~".repeat(squiggleWidth === 0 ? 1 : squiggleWidth) })] }));
2015
2015
  }
2016
- function CodeSpanText({ diagnosticCategory, diagnosticOrigin }) {
2016
+ function CodeFrameText({ diagnosticCategory, diagnosticOrigin, options }) {
2017
+ const linesAbove = options?.linesAbove ?? 2;
2018
+ const linesBelow = options?.linesBelow ?? 3;
2019
+ const showBreadcrumbs = options?.showBreadcrumbs ?? true;
2017
2020
  const lineMap = diagnosticOrigin.sourceFile.getLineStarts();
2018
2021
  const { character: firstMarkedLineCharacter, line: firstMarkedLine } = diagnosticOrigin.sourceFile.getLineAndCharacterOfPosition(diagnosticOrigin.start);
2019
2022
  const { character: lastMarkedLineCharacter, line: lastMarkedLine } = diagnosticOrigin.sourceFile.getLineAndCharacterOfPosition(diagnosticOrigin.end);
2020
- const firstLine = Math.max(firstMarkedLine - 2, 0);
2021
- const lastLine = Math.min(firstLine + 5, lineMap.length - 1);
2023
+ const firstLine = Math.max(firstMarkedLine - linesAbove, 0);
2024
+ const lastLine = Math.min(lastMarkedLine + linesBelow, lineMap.length - 1);
2022
2025
  const gutterWidth = (lastLine + 1).toString().length + 2;
2023
2026
  let highlightColor;
2024
2027
  switch (diagnosticCategory) {
@@ -2029,43 +2032,47 @@ function CodeSpanText({ diagnosticCategory, diagnosticOrigin }) {
2029
2032
  highlightColor = Color.Yellow;
2030
2033
  break;
2031
2034
  }
2032
- const codeSpan = [];
2035
+ const codeFrame = [];
2033
2036
  for (let index = firstLine; index <= lastLine; index++) {
2034
2037
  const lineStart = lineMap[index];
2035
2038
  const lineEnd = index === lineMap.length - 1 ? diagnosticOrigin.sourceFile.text.length : lineMap[index + 1];
2036
2039
  const lineText = diagnosticOrigin.sourceFile.text.slice(lineStart, lineEnd).trimEnd().replace(/\t/g, " ");
2037
2040
  if (index >= firstMarkedLine && index <= lastMarkedLine) {
2038
- codeSpan.push(jsx(CodeLineText, { gutterWidth: gutterWidth, lineNumber: index + 1, lineNumberColor: highlightColor, lineText: lineText }));
2041
+ codeFrame.push(jsx(CodeLineText, { gutterWidth: gutterWidth, lineNumber: index + 1, lineNumberColor: highlightColor, lineText: lineText }));
2039
2042
  if (index === firstMarkedLine) {
2040
2043
  const squiggleLength = index === lastMarkedLine
2041
2044
  ? lastMarkedLineCharacter - firstMarkedLineCharacter
2042
2045
  : lineText.length - firstMarkedLineCharacter;
2043
- codeSpan.push(jsx(SquiggleLineText, { gutterWidth: gutterWidth, indentWidth: firstMarkedLineCharacter, squiggleColor: highlightColor, squiggleWidth: squiggleLength }));
2046
+ codeFrame.push(jsx(SquiggleLineText, { gutterWidth: gutterWidth, indentWidth: firstMarkedLineCharacter, squiggleColor: highlightColor, squiggleWidth: squiggleLength }));
2044
2047
  }
2045
2048
  else if (index === lastMarkedLine) {
2046
- codeSpan.push(jsx(SquiggleLineText, { gutterWidth: gutterWidth, squiggleColor: highlightColor, squiggleWidth: lastMarkedLineCharacter }));
2049
+ codeFrame.push(jsx(SquiggleLineText, { gutterWidth: gutterWidth, squiggleColor: highlightColor, squiggleWidth: lastMarkedLineCharacter }));
2047
2050
  }
2048
2051
  else {
2049
- codeSpan.push(jsx(SquiggleLineText, { gutterWidth: gutterWidth, squiggleColor: highlightColor, squiggleWidth: lineText.length }));
2052
+ codeFrame.push(jsx(SquiggleLineText, { gutterWidth: gutterWidth, squiggleColor: highlightColor, squiggleWidth: lineText.length }));
2050
2053
  }
2051
2054
  }
2052
2055
  else {
2053
- codeSpan.push(jsx(CodeLineText, { gutterWidth: gutterWidth, lineNumber: index + 1, lineText: lineText }));
2056
+ codeFrame.push(jsx(CodeLineText, { gutterWidth: gutterWidth, lineNumber: index + 1, lineText: lineText }));
2054
2057
  }
2055
2058
  }
2056
- const location = (jsx(Line, { children: [" ".repeat(gutterWidth + 2), jsx(Text, { color: Color.Gray, children: " at " }), jsx(Text, { color: Color.Cyan, children: Path.relative("", diagnosticOrigin.sourceFile.fileName) }), jsx(Text, { color: Color.Gray, children: `:${firstMarkedLine + 1}:${firstMarkedLineCharacter + 1}` }), diagnosticOrigin.assertion && jsx(BreadcrumbsText, { ancestor: diagnosticOrigin.assertion.parent })] }));
2057
- return (jsx(Text, { children: [codeSpan, jsx(Line, {}), location] }));
2059
+ let breadcrumbs;
2060
+ if (showBreadcrumbs && diagnosticOrigin.assertion != null) {
2061
+ breadcrumbs = jsx(BreadcrumbsText, { ancestor: diagnosticOrigin.assertion.parent });
2062
+ }
2063
+ const location = (jsx(Line, { children: [" ".repeat(gutterWidth + 2), jsx(Text, { color: Color.Gray, children: " at " }), jsx(Text, { color: Color.Cyan, children: Path.relative("", diagnosticOrigin.sourceFile.fileName) }), jsx(Text, { color: Color.Gray, children: `:${firstMarkedLine + 1}:${firstMarkedLineCharacter + 1}` }), breadcrumbs] }));
2064
+ return (jsx(Text, { children: [codeFrame, jsx(Line, {}), location] }));
2058
2065
  }
2059
2066
 
2060
- function DiagnosticText({ diagnostic }) {
2067
+ function DiagnosticText({ codeFrameOptions, diagnostic }) {
2061
2068
  const code = diagnostic.code ? jsx(Text, { color: Color.Gray, children: [" ", diagnostic.code] }) : undefined;
2062
2069
  const text = Array.isArray(diagnostic.text) ? diagnostic.text : [diagnostic.text];
2063
2070
  const message = text.map((text, index) => (jsx(Text, { children: [index === 1 ? jsx(Line, {}) : undefined, jsx(Line, { children: [text, index === 0 ? code : undefined] })] })));
2064
2071
  const related = diagnostic.related?.map((relatedDiagnostic) => jsx(DiagnosticText, { diagnostic: relatedDiagnostic }));
2065
- const codeSpan = diagnostic.origin ? (jsx(Text, { children: [jsx(Line, {}), jsx(CodeSpanText, { diagnosticCategory: diagnostic.category, diagnosticOrigin: diagnostic.origin })] })) : undefined;
2066
- return (jsx(Text, { children: [message, codeSpan, jsx(Line, {}), jsx(Text, { indent: 2, children: related })] }));
2072
+ const codeFrame = diagnostic.origin ? (jsx(Text, { children: [jsx(Line, {}), jsx(CodeFrameText, { diagnosticCategory: diagnostic.category, diagnosticOrigin: diagnostic.origin, options: codeFrameOptions })] })) : undefined;
2073
+ return (jsx(Text, { children: [message, codeFrame, jsx(Line, {}), jsx(Text, { indent: 2, children: related })] }));
2067
2074
  }
2068
- function diagnosticText(diagnostic) {
2075
+ function diagnosticText(diagnostic, codeFrameOptions = {}) {
2069
2076
  let prefix;
2070
2077
  switch (diagnostic.category) {
2071
2078
  case DiagnosticCategory.Error:
@@ -2075,7 +2082,7 @@ function diagnosticText(diagnostic) {
2075
2082
  prefix = jsx(Text, { color: Color.Yellow, children: "Warning: " });
2076
2083
  break;
2077
2084
  }
2078
- return (jsx(Text, { children: [prefix, jsx(DiagnosticText, { diagnostic: diagnostic })] }));
2085
+ return (jsx(Text, { children: [prefix, jsx(DiagnosticText, { codeFrameOptions: codeFrameOptions, diagnostic: diagnostic })] }));
2079
2086
  }
2080
2087
 
2081
2088
  function FileNameText({ filePath }) {
@@ -4336,7 +4343,7 @@ class TaskRunner {
4336
4343
  class Runner {
4337
4344
  #eventEmitter = new EventEmitter();
4338
4345
  #resolvedConfig;
4339
- static version = "3.4.0";
4346
+ static version = "3.5.0";
4340
4347
  constructor(resolvedConfig) {
4341
4348
  this.#resolvedConfig = resolvedConfig;
4342
4349
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "The Essential Type Testing Tool.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -63,12 +63,12 @@
63
63
  "devDependencies": {
64
64
  "@biomejs/biome": "1.9.4",
65
65
  "@rollup/plugin-typescript": "12.1.2",
66
- "@types/node": "22.10.5",
67
- "@types/react": "19.0.4",
66
+ "@types/node": "22.10.6",
67
+ "@types/react": "19.0.6",
68
68
  "ajv": "8.17.1",
69
- "cspell": "8.17.1",
69
+ "cspell": "8.17.2",
70
70
  "magic-string": "0.30.17",
71
- "monocart-coverage-reports": "2.11.5",
71
+ "monocart-coverage-reports": "2.11.6",
72
72
  "pretty-ansi": "3.0.0",
73
73
  "rollup": "4.30.1",
74
74
  "rollup-plugin-dts": "6.1.1",