tstyche 7.0.0-beta.0 → 7.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{tstyche.d.ts → api.d.ts} +6 -5
- package/dist/{tstyche.js → api.js} +14 -14
- package/dist/bin.js +1 -1
- package/dist/tag.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ tstyche query-params --only multiple --target '>=5.6'
|
|
|
73
73
|
|
|
74
74
|
It is that simple! Actually, TSTyche does even more:
|
|
75
75
|
|
|
76
|
-
- checks messages of errors suppressed by
|
|
76
|
+
- checks messages of errors suppressed by `@ts-expect-error` directives,
|
|
77
77
|
- generates type tests from a data table,
|
|
78
78
|
- runs tests in watch mode.
|
|
79
79
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
import type { WriteStream } from 'node:tty';
|
|
3
2
|
|
|
4
3
|
declare enum CancellationReason {
|
|
5
4
|
ConfigChange = "configChange",
|
|
@@ -257,8 +256,7 @@ declare const defaultOptions: Required<ConfigFileOptions>;
|
|
|
257
256
|
declare enum OptionGroup {
|
|
258
257
|
CommandLine = 2,
|
|
259
258
|
ConfigFile = 4,
|
|
260
|
-
InlineConditions = 8
|
|
261
|
-
ResolvedConfig = 6
|
|
259
|
+
InlineConditions = 8
|
|
262
260
|
}
|
|
263
261
|
|
|
264
262
|
interface BaseOptionDefinition {
|
|
@@ -283,7 +281,7 @@ declare class Options {
|
|
|
283
281
|
#private;
|
|
284
282
|
static for(optionGroup: OptionGroup): Map<string, OptionDefinition>;
|
|
285
283
|
static isJsonString(text: string): boolean;
|
|
286
|
-
static resolve(optionName: string, optionValue: string,
|
|
284
|
+
static resolve(optionName: string, optionValue: string, basePath?: string): string;
|
|
287
285
|
static validate(optionName: string, optionValue: string, onDiagnostics: DiagnosticsHandler, origin?: DiagnosticOrigin): Promise<void>;
|
|
288
286
|
}
|
|
289
287
|
|
|
@@ -632,6 +630,9 @@ declare function formattedText(input: string | Array<string> | Record<string, un
|
|
|
632
630
|
|
|
633
631
|
declare function helpText(options: Map<string, OptionDefinition>, version: string): ScribblerJsx.Element;
|
|
634
632
|
|
|
633
|
+
interface WriteStream {
|
|
634
|
+
write(text: string): void;
|
|
635
|
+
}
|
|
635
636
|
declare class StreamController {
|
|
636
637
|
#private;
|
|
637
638
|
constructor(stream: WriteStream);
|
|
@@ -754,4 +755,4 @@ declare class Version {
|
|
|
754
755
|
}
|
|
755
756
|
|
|
756
757
|
export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, DotReporter, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectConfigKind, ProjectResult, Result, ResultStatus, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, Store, StreamController, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, dotText, environmentOptions, fileStatusText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesText, waitingForFileChangesText, watchUsageText };
|
|
757
|
-
export type { AssertionCounts, AssertionResultStatus, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, OptionDefinition, ProjectConfig, Reporter, ReporterEvent, ResolvedConfig, ResultCounts, ResultTiming, ScribblerOptions, SuppressedCounts, SuppressedResultStatus, TargetCounts, TargetResultStatus, TestCounts, TestResultStatus, TextRange };
|
|
758
|
+
export type { AssertionCounts, AssertionResultStatus, CliOptions, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, OptionDefinition, ProjectConfig, Reporter, ReporterEvent, ResolvedConfig, ResultCounts, ResultTiming, ScribblerOptions, SuppressedCounts, SuppressedResultStatus, TargetCounts, TargetResultStatus, TestCounts, TestResultStatus, TextRange, WriteStream };
|
|
@@ -1038,7 +1038,7 @@ class Options {
|
|
|
1038
1038
|
},
|
|
1039
1039
|
{
|
|
1040
1040
|
brand: "boolean",
|
|
1041
|
-
description: "Check errors silenced by '
|
|
1041
|
+
description: "Check errors silenced by '@ts-expect-error' directives.",
|
|
1042
1042
|
group: 4,
|
|
1043
1043
|
name: "checkSuppressedErrors",
|
|
1044
1044
|
},
|
|
@@ -1214,7 +1214,7 @@ class Options {
|
|
|
1214
1214
|
static isJsonString(text) {
|
|
1215
1215
|
return text.startsWith("{");
|
|
1216
1216
|
}
|
|
1217
|
-
static resolve(optionName, optionValue,
|
|
1217
|
+
static resolve(optionName, optionValue, basePath = ".") {
|
|
1218
1218
|
const canonicalOptionName = Options.#getCanonicalOptionName(optionName);
|
|
1219
1219
|
switch (canonicalOptionName) {
|
|
1220
1220
|
case "config":
|
|
@@ -1227,7 +1227,7 @@ class Options {
|
|
|
1227
1227
|
if (optionValue.startsWith("file:")) {
|
|
1228
1228
|
optionValue = fileURLToPath(optionValue);
|
|
1229
1229
|
}
|
|
1230
|
-
optionValue = Path.resolve(
|
|
1230
|
+
optionValue = Path.resolve(basePath, optionValue);
|
|
1231
1231
|
break;
|
|
1232
1232
|
case "reporters":
|
|
1233
1233
|
if (Options.#isBuiltinReporter(optionValue)) {
|
|
@@ -1235,7 +1235,7 @@ class Options {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
try {
|
|
1237
1237
|
if (optionValue.startsWith(".")) {
|
|
1238
|
-
optionValue = pathToFileURL(Path.relative(".", Path.resolve(
|
|
1238
|
+
optionValue = pathToFileURL(Path.relative(".", Path.resolve(basePath, optionValue))).toString();
|
|
1239
1239
|
}
|
|
1240
1240
|
else {
|
|
1241
1241
|
optionValue = import.meta.resolve(optionValue);
|
|
@@ -1447,8 +1447,8 @@ class ConfigParser {
|
|
|
1447
1447
|
this.#onRequiresValue(optionDefinition.name, optionDefinition.brand, jsonNode, isListItem);
|
|
1448
1448
|
break;
|
|
1449
1449
|
}
|
|
1450
|
-
const
|
|
1451
|
-
optionValue = Options.resolve(optionDefinition.name, optionValue,
|
|
1450
|
+
const basePath = Path.dirname(this.#sourceFile.fileName);
|
|
1451
|
+
optionValue = Options.resolve(optionDefinition.name, optionValue, basePath);
|
|
1452
1452
|
await Options.validate(optionDefinition.name, optionValue, this.#onDiagnostics, jsonNode.origin);
|
|
1453
1453
|
break;
|
|
1454
1454
|
}
|
|
@@ -1776,7 +1776,6 @@ var OptionGroup;
|
|
|
1776
1776
|
OptionGroup[OptionGroup["CommandLine"] = 2] = "CommandLine";
|
|
1777
1777
|
OptionGroup[OptionGroup["ConfigFile"] = 4] = "ConfigFile";
|
|
1778
1778
|
OptionGroup[OptionGroup["InlineConditions"] = 8] = "InlineConditions";
|
|
1779
|
-
OptionGroup[OptionGroup["ResolvedConfig"] = 6] = "ResolvedConfig";
|
|
1780
1779
|
})(OptionGroup || (OptionGroup = {}));
|
|
1781
1780
|
|
|
1782
1781
|
class CancellationHandler {
|
|
@@ -3567,7 +3566,7 @@ class SourceTextEditor {
|
|
|
3567
3566
|
class SuppressedLayer {
|
|
3568
3567
|
#compiler;
|
|
3569
3568
|
#editor;
|
|
3570
|
-
#expectErrorRegex = /^(\
|
|
3569
|
+
#expectErrorRegex = /^([ \t/*{]*)(@ts-expect-error)(!?)(:? *)(.*?)(?:\*\/.*)?$/gim;
|
|
3571
3570
|
#resolvedConfig;
|
|
3572
3571
|
#suppressedErrorsMap;
|
|
3573
3572
|
constructor(compiler, editor, resolvedConfig) {
|
|
@@ -4071,7 +4070,7 @@ class ProjectService {
|
|
|
4071
4070
|
#lastSeenProject = "";
|
|
4072
4071
|
#projectConfig;
|
|
4073
4072
|
#resolvedConfig;
|
|
4074
|
-
#
|
|
4073
|
+
#seenProjects = new Set();
|
|
4075
4074
|
#seenTestFiles = new Set();
|
|
4076
4075
|
#service;
|
|
4077
4076
|
constructor(compiler, resolvedConfig) {
|
|
@@ -4129,6 +4128,7 @@ class ProjectService {
|
|
|
4129
4128
|
jsx: this.#compiler.JsxEmit.Preserve,
|
|
4130
4129
|
module: this.#compiler.ModuleKind.NodeNext,
|
|
4131
4130
|
moduleResolution: this.#compiler.ModuleResolutionKind.NodeNext,
|
|
4131
|
+
noEmit: true,
|
|
4132
4132
|
noUncheckedIndexedAccess: true,
|
|
4133
4133
|
resolveJsonModule: true,
|
|
4134
4134
|
strict: true,
|
|
@@ -4211,10 +4211,10 @@ class ProjectService {
|
|
|
4211
4211
|
this.#seenTestFiles.add(filePath);
|
|
4212
4212
|
const languageService = this.getLanguageService(filePath);
|
|
4213
4213
|
const program = languageService?.getProgram();
|
|
4214
|
-
if (!program || this.#
|
|
4214
|
+
if (!program || this.#seenProjects.has(configFileName)) {
|
|
4215
4215
|
return;
|
|
4216
4216
|
}
|
|
4217
|
-
this.#
|
|
4217
|
+
this.#seenProjects.add(configFileName);
|
|
4218
4218
|
const sourceFilesToCheck = program.getSourceFiles().filter((sourceFile) => {
|
|
4219
4219
|
if (program.isSourceFileFromExternalLibrary(sourceFile) || program.isSourceFileDefaultLibrary(sourceFile)) {
|
|
4220
4220
|
return false;
|
|
@@ -4230,9 +4230,9 @@ class ProjectService {
|
|
|
4230
4230
|
}
|
|
4231
4231
|
return false;
|
|
4232
4232
|
});
|
|
4233
|
-
const diagnostics = [];
|
|
4233
|
+
const diagnostics = [...program.getOptionsDiagnostics()];
|
|
4234
4234
|
for (const sourceFile of sourceFilesToCheck) {
|
|
4235
|
-
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile), ...program.getSemanticDiagnostics(sourceFile));
|
|
4235
|
+
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile), ...program.getSemanticDiagnostics(sourceFile), ...program.getDeclarationDiagnostics(sourceFile));
|
|
4236
4236
|
}
|
|
4237
4237
|
if (diagnostics.length > 0) {
|
|
4238
4238
|
EventEmitter.dispatch(["project:error", { diagnostics: Diagnostic.fromDiagnostics(diagnostics) }]);
|
|
@@ -6065,7 +6065,7 @@ class FileRunner {
|
|
|
6065
6065
|
class Runner {
|
|
6066
6066
|
#eventEmitter = new EventEmitter();
|
|
6067
6067
|
#resolvedConfig;
|
|
6068
|
-
static version = "7.0.0-beta.
|
|
6068
|
+
static version = "7.0.0-beta.2";
|
|
6069
6069
|
constructor(resolvedConfig) {
|
|
6070
6070
|
this.#resolvedConfig = resolvedConfig;
|
|
6071
6071
|
}
|
package/dist/bin.js
CHANGED
package/dist/tag.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tstyche",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.2",
|
|
4
4
|
"description": "Everything You Need for Type Testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"import": "./dist/index.js",
|
|
26
26
|
"require": "./dist/index.cjs"
|
|
27
27
|
},
|
|
28
|
+
"./api": "./dist/api.js",
|
|
28
29
|
"./tag": "./dist/tag.js",
|
|
29
|
-
"./tstyche": "./dist/tstyche.js",
|
|
30
30
|
"./package.json": "./package.json"
|
|
31
31
|
},
|
|
32
32
|
"main": "./dist/index.js",
|