tstyche 7.0.0-beta.3 → 7.0.0-beta.4
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/dist/api.d.ts +2 -6
- package/dist/api.js +46 -43
- package/dist/bin.js +2 -1
- package/dist/tag.js +4 -25
- package/package.json +1 -1
- package/schemas/config.json +88 -0
package/dist/api.d.ts
CHANGED
|
@@ -15,13 +15,9 @@ declare class CancellationToken {
|
|
|
15
15
|
reset(): void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
interface CliOptions {
|
|
19
|
-
noErrorExitCode?: boolean;
|
|
20
|
-
}
|
|
21
18
|
declare class Cli {
|
|
22
19
|
#private;
|
|
23
|
-
|
|
24
|
-
run(commandLine: ReadonlyArray<string>, cancellationToken?: CancellationToken): Promise<void>;
|
|
20
|
+
run(commandLine: ReadonlyArray<string>, cancellationToken?: CancellationToken): Promise<number>;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
declare enum DiagnosticCategory {
|
|
@@ -755,4 +751,4 @@ declare class Version {
|
|
|
755
751
|
}
|
|
756
752
|
|
|
757
753
|
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 };
|
|
758
|
-
export type { AssertionCounts, AssertionResultStatus,
|
|
754
|
+
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, WriteStream };
|
package/dist/api.js
CHANGED
|
@@ -56,25 +56,24 @@ class JsonNode {
|
|
|
56
56
|
this.text = text;
|
|
57
57
|
}
|
|
58
58
|
getValue(options) {
|
|
59
|
-
if (this.text
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return Number.parseFloat(this.text);
|
|
59
|
+
if (this.text != null) {
|
|
60
|
+
if (/^['"]/.test(this.text)) {
|
|
61
|
+
return this.text.slice(1, -1).replaceAll("\\", "");
|
|
62
|
+
}
|
|
63
|
+
if (options?.expectsIdentifier) {
|
|
64
|
+
return this.text;
|
|
65
|
+
}
|
|
66
|
+
if (this.text === "true") {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (this.text === "false") {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
if (/^\d/.test(this.text)) {
|
|
73
|
+
return Number.parseFloat(this.text);
|
|
74
|
+
}
|
|
76
75
|
}
|
|
77
|
-
return
|
|
76
|
+
return;
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
|
|
@@ -730,7 +729,9 @@ class ManifestService {
|
|
|
730
729
|
const versions = [];
|
|
731
730
|
const packageMetadata = (await response.json());
|
|
732
731
|
for (const [tag, meta] of Object.entries(packageMetadata.versions)) {
|
|
733
|
-
if (!tag.includes("-") &&
|
|
732
|
+
if (!tag.includes("-") &&
|
|
733
|
+
Version.isSatisfiedWith(tag, "5.4") &&
|
|
734
|
+
!Version.isSatisfiedWith(tag, "7.0")) {
|
|
734
735
|
versions.push(tag);
|
|
735
736
|
packages[tag] = { integrity: meta.dist.integrity, tarball: meta.dist.tarball };
|
|
736
737
|
}
|
|
@@ -752,6 +753,7 @@ class ManifestService {
|
|
|
752
753
|
}
|
|
753
754
|
}
|
|
754
755
|
}
|
|
756
|
+
resolutions["latest"] = versions.findLast((version) => version.startsWith("6"));
|
|
755
757
|
return new Manifest({ minorVersions, npmRegistry: this.#npmRegistry, packages, resolutions, versions });
|
|
756
758
|
}
|
|
757
759
|
async open(options) {
|
|
@@ -1795,22 +1797,23 @@ class CancellationHandler {
|
|
|
1795
1797
|
}
|
|
1796
1798
|
|
|
1797
1799
|
class ExitCodeHandler {
|
|
1800
|
+
#exitCode = 0;
|
|
1801
|
+
getExitCode() {
|
|
1802
|
+
return this.#exitCode;
|
|
1803
|
+
}
|
|
1798
1804
|
on([event, payload]) {
|
|
1799
1805
|
if (event === "run:start") {
|
|
1800
|
-
this
|
|
1806
|
+
this.#exitCode = 0;
|
|
1801
1807
|
return;
|
|
1802
1808
|
}
|
|
1803
1809
|
if ("diagnostics" in payload) {
|
|
1804
1810
|
if (payload.diagnostics.some((diagnostic) => diagnostic.category === "error")) {
|
|
1805
|
-
this.#
|
|
1811
|
+
this.#exitCode = 1;
|
|
1806
1812
|
}
|
|
1807
1813
|
}
|
|
1808
1814
|
}
|
|
1809
|
-
|
|
1810
|
-
this.#
|
|
1811
|
-
}
|
|
1812
|
-
#setCode(exitCode) {
|
|
1813
|
-
process.exitCode = exitCode;
|
|
1815
|
+
reset() {
|
|
1816
|
+
this.#exitCode = 0;
|
|
1814
1817
|
}
|
|
1815
1818
|
}
|
|
1816
1819
|
|
|
@@ -4517,12 +4520,12 @@ class MatchWorker {
|
|
|
4517
4520
|
this.typeChecker = program.getTypeChecker();
|
|
4518
4521
|
this.assertionNode = assertionNode;
|
|
4519
4522
|
}
|
|
4523
|
+
checkIsAssignableFrom(sourceNode, targetNode) {
|
|
4524
|
+
return this.#checkIsRelatedTo(targetNode, sourceNode);
|
|
4525
|
+
}
|
|
4520
4526
|
checkIsAssignableTo(sourceNode, targetNode) {
|
|
4521
4527
|
return this.#checkIsRelatedTo(sourceNode, targetNode);
|
|
4522
4528
|
}
|
|
4523
|
-
checkIsAssignableWith(sourceNode, targetNode) {
|
|
4524
|
-
return this.#checkIsRelatedTo(targetNode, sourceNode);
|
|
4525
|
-
}
|
|
4526
4529
|
#checkIsRelatedTo(sourceNode, targetNode) {
|
|
4527
4530
|
const sourceType = this.getType(sourceNode);
|
|
4528
4531
|
const targetType = this.getType(targetNode);
|
|
@@ -5378,7 +5381,7 @@ class ToBeAssignableFrom extends RelationMatcherBase {
|
|
|
5378
5381
|
match(matchWorker, sourceNode, targetNode) {
|
|
5379
5382
|
return {
|
|
5380
5383
|
explain: () => this.explain(matchWorker, sourceNode, targetNode),
|
|
5381
|
-
isMatch: matchWorker.
|
|
5384
|
+
isMatch: matchWorker.checkIsAssignableFrom(sourceNode, targetNode),
|
|
5382
5385
|
};
|
|
5383
5386
|
}
|
|
5384
5387
|
}
|
|
@@ -6176,7 +6179,7 @@ class FileRunner {
|
|
|
6176
6179
|
class Runner {
|
|
6177
6180
|
#eventEmitter = new EventEmitter();
|
|
6178
6181
|
#resolvedConfig;
|
|
6179
|
-
static version = "7.0.0-beta.
|
|
6182
|
+
static version = "7.0.0-beta.4";
|
|
6180
6183
|
constructor(resolvedConfig) {
|
|
6181
6184
|
this.#resolvedConfig = resolvedConfig;
|
|
6182
6185
|
}
|
|
@@ -6275,15 +6278,20 @@ class CliDiagnosticText {
|
|
|
6275
6278
|
class Cli {
|
|
6276
6279
|
#deferredDiagnostics;
|
|
6277
6280
|
#eventEmitter = new EventEmitter();
|
|
6278
|
-
#noErrorExitCode;
|
|
6279
|
-
constructor(options) {
|
|
6280
|
-
this.#noErrorExitCode = options?.noErrorExitCode ?? false;
|
|
6281
|
-
}
|
|
6282
6281
|
async run(commandLine, cancellationToken = new CancellationToken()) {
|
|
6282
|
+
const exitCodeHandler = new ExitCodeHandler();
|
|
6283
|
+
this.#eventEmitter.addHandler(exitCodeHandler);
|
|
6284
|
+
await this.#run(commandLine, exitCodeHandler, cancellationToken);
|
|
6285
|
+
if (this.#deferredDiagnostics != null) {
|
|
6286
|
+
OutputService.writeBlankLine();
|
|
6287
|
+
OutputService.writeWarning(diagnosticText(this.#deferredDiagnostics));
|
|
6288
|
+
}
|
|
6289
|
+
this.#eventEmitter.removeHandlers();
|
|
6290
|
+
return exitCodeHandler.getExitCode();
|
|
6291
|
+
}
|
|
6292
|
+
async #run(commandLine, exitCodeHandler, cancellationToken) {
|
|
6283
6293
|
const cancellationHandler = new CancellationHandler(cancellationToken, "configError");
|
|
6284
6294
|
this.#eventEmitter.addHandler(cancellationHandler);
|
|
6285
|
-
const exitCodeHandler = new ExitCodeHandler();
|
|
6286
|
-
!this.#noErrorExitCode && this.#eventEmitter.addHandler(exitCodeHandler);
|
|
6287
6295
|
const setupReporter = new SetupReporter();
|
|
6288
6296
|
this.#eventEmitter.addReporter(setupReporter);
|
|
6289
6297
|
if (commandLine.includes("--help")) {
|
|
@@ -6325,7 +6333,7 @@ class Cli {
|
|
|
6325
6333
|
do {
|
|
6326
6334
|
if (cancellationToken.getReason() === "configChange") {
|
|
6327
6335
|
cancellationToken.reset();
|
|
6328
|
-
exitCodeHandler.
|
|
6336
|
+
exitCodeHandler.reset();
|
|
6329
6337
|
OutputService.clearTerminal();
|
|
6330
6338
|
this.#eventEmitter.addHandler(cancellationHandler);
|
|
6331
6339
|
this.#eventEmitter.addReporter(setupReporter);
|
|
@@ -6367,11 +6375,6 @@ class Cli {
|
|
|
6367
6375
|
const runner = new Runner(resolvedConfig);
|
|
6368
6376
|
await runner.run(testFiles, cancellationToken);
|
|
6369
6377
|
} while (cancellationToken.getReason() === "configChange");
|
|
6370
|
-
if (this.#deferredDiagnostics != null) {
|
|
6371
|
-
OutputService.writeBlankLine();
|
|
6372
|
-
OutputService.writeWarning(diagnosticText(this.#deferredDiagnostics));
|
|
6373
|
-
}
|
|
6374
|
-
this.#eventEmitter.removeHandlers();
|
|
6375
6378
|
}
|
|
6376
6379
|
#waitForChangedFiles(resolvedConfig, cancellationToken) {
|
|
6377
6380
|
return new Promise((resolve) => {
|
package/dist/bin.js
CHANGED
package/dist/tag.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
import { Cli
|
|
1
|
+
import { Cli } from './api.js';
|
|
2
2
|
|
|
3
|
-
class StatusHandler {
|
|
4
|
-
#hasError = false;
|
|
5
|
-
hasError() {
|
|
6
|
-
return this.#hasError;
|
|
7
|
-
}
|
|
8
|
-
on([event, payload]) {
|
|
9
|
-
if (event === "run:start") {
|
|
10
|
-
this.#hasError = false;
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if ("diagnostics" in payload) {
|
|
14
|
-
if (payload.diagnostics.some((diagnostic) => diagnostic.category === "error")) {
|
|
15
|
-
this.#hasError = true;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
3
|
async function tstyche(template, ...substitutions) {
|
|
21
|
-
const cli = new Cli(
|
|
4
|
+
const cli = new Cli();
|
|
22
5
|
const commandLine = String.raw(template, ...substitutions).split(/\s+/);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
eventEmitter.addHandler(statusHandler);
|
|
26
|
-
await cli.run(commandLine, new CancellationToken());
|
|
27
|
-
eventEmitter.removeHandler(statusHandler);
|
|
28
|
-
if (statusHandler.hasError()) {
|
|
6
|
+
const exitCode = await cli.run(commandLine);
|
|
7
|
+
if (exitCode > 0) {
|
|
29
8
|
throw new Error("TSTyche test run failed. Check the output above for details.");
|
|
30
9
|
}
|
|
31
10
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"checkDeclarationFiles": {
|
|
6
|
+
"description": "Check declaration files for type errors.",
|
|
7
|
+
"default": true,
|
|
8
|
+
"type": "boolean"
|
|
9
|
+
},
|
|
10
|
+
"checkSuppressedErrors": {
|
|
11
|
+
"description": "Check errors silenced by '@ts-expect-error' directives.",
|
|
12
|
+
"default": true,
|
|
13
|
+
"type": "boolean"
|
|
14
|
+
},
|
|
15
|
+
"failFast": {
|
|
16
|
+
"description": "Stop running tests after the first failed assertion.",
|
|
17
|
+
"default": false,
|
|
18
|
+
"type": "boolean"
|
|
19
|
+
},
|
|
20
|
+
"fixtureFileMatch": {
|
|
21
|
+
"description": "The list of glob patterns matching the fixture files.",
|
|
22
|
+
"default": [
|
|
23
|
+
"**/__fixtures__/*.{ts,tsx}",
|
|
24
|
+
"**/fixtures/*.{ts,tsx}"
|
|
25
|
+
],
|
|
26
|
+
"type": "array",
|
|
27
|
+
"uniqueItems": true,
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"quiet": {
|
|
33
|
+
"description": "Silence all test runner output except errors and warnings.",
|
|
34
|
+
"default": false,
|
|
35
|
+
"type": "boolean"
|
|
36
|
+
},
|
|
37
|
+
"rejectAnyType": {
|
|
38
|
+
"description": "Reject the 'any' type passed as an argument to the 'expect()' function or a matcher.",
|
|
39
|
+
"default": true,
|
|
40
|
+
"type": "boolean"
|
|
41
|
+
},
|
|
42
|
+
"rejectNeverType": {
|
|
43
|
+
"description": "Reject the 'never' type passed as an argument to the 'expect()' function or a matcher.",
|
|
44
|
+
"default": true,
|
|
45
|
+
"type": "boolean"
|
|
46
|
+
},
|
|
47
|
+
"reporters": {
|
|
48
|
+
"description": "The list of reporters to use.",
|
|
49
|
+
"default": [
|
|
50
|
+
"list",
|
|
51
|
+
"summary"
|
|
52
|
+
],
|
|
53
|
+
"type": "array",
|
|
54
|
+
"uniqueItems": true,
|
|
55
|
+
"items": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"target": {
|
|
60
|
+
"description": "The range of TypeScript versions to test against.",
|
|
61
|
+
"default": "*",
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"testFileMatch": {
|
|
65
|
+
"description": "The list of glob patterns matching the test files.",
|
|
66
|
+
"default": [
|
|
67
|
+
"**/*.tst.*",
|
|
68
|
+
"**/__typetests__/*.test.*",
|
|
69
|
+
"**/typetests/*.test.*"
|
|
70
|
+
],
|
|
71
|
+
"type": "array",
|
|
72
|
+
"uniqueItems": true,
|
|
73
|
+
"items": {
|
|
74
|
+
"type": "string"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"tsconfig": {
|
|
78
|
+
"description": "The TSConfig to load.",
|
|
79
|
+
"default": "findup",
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"verbose": {
|
|
83
|
+
"description": "Enable detailed logging.",
|
|
84
|
+
"default": false,
|
|
85
|
+
"type": "boolean"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|