tstyche 6.0.0-beta.1 → 6.0.0-beta.3
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/{build → dist}/tstyche.d.ts +3 -25
- package/{build → dist}/tstyche.js +38 -150
- package/package.json +8 -12
- package/build/index.cjs +0 -20
- package/build/index.d.cts +0 -255
- /package/{build → dist}/bin.js +0 -0
- /package/{build → dist}/index.d.ts +0 -0
- /package/{build → dist}/index.js +0 -0
|
@@ -142,7 +142,6 @@ interface CommandLineOptions {
|
|
|
142
142
|
list?: boolean;
|
|
143
143
|
listFiles?: boolean;
|
|
144
144
|
only?: string;
|
|
145
|
-
plugins?: Array<string>;
|
|
146
145
|
prune?: boolean;
|
|
147
146
|
reporters?: Array<string>;
|
|
148
147
|
showConfig?: boolean;
|
|
@@ -158,8 +157,6 @@ interface ConfigFileOptions {
|
|
|
158
157
|
checkSuppressedErrors?: boolean;
|
|
159
158
|
failFast?: boolean;
|
|
160
159
|
fixtureFileMatch?: Array<string>;
|
|
161
|
-
legacyToBe?: boolean;
|
|
162
|
-
plugins?: Array<string>;
|
|
163
160
|
rejectAnyType?: boolean;
|
|
164
161
|
rejectNeverType?: boolean;
|
|
165
162
|
reporters?: Array<string>;
|
|
@@ -646,23 +643,6 @@ declare class Path {
|
|
|
646
643
|
static resolve(...filePaths: Array<string>): string;
|
|
647
644
|
}
|
|
648
645
|
|
|
649
|
-
interface SelectHookContext {
|
|
650
|
-
resolvedConfig: ResolvedConfig;
|
|
651
|
-
}
|
|
652
|
-
interface Plugin {
|
|
653
|
-
name: string;
|
|
654
|
-
config?: (resolvedConfig: ResolvedConfig) => ResolvedConfig | Promise<ResolvedConfig>;
|
|
655
|
-
select?: (this: SelectHookContext, testFiles: Array<string>) => Array<string | URL> | Promise<Array<string | URL>>;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
type Hooks = Required<Omit<Plugin, "name">>;
|
|
659
|
-
declare class PluginService {
|
|
660
|
-
#private;
|
|
661
|
-
static addHandler(plugin: Plugin): void;
|
|
662
|
-
static call<T extends keyof Hooks>(hook: T, argument: Parameters<Hooks[T]>[0], context: ThisParameterType<Hooks[T]>): Promise<Awaited<ReturnType<Hooks[T]>>>;
|
|
663
|
-
static removeHandlers(): void;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
646
|
declare class Runner {
|
|
667
647
|
#private;
|
|
668
648
|
static version: string;
|
|
@@ -720,9 +700,7 @@ declare class Store {
|
|
|
720
700
|
#private;
|
|
721
701
|
static manifest: Manifest | undefined;
|
|
722
702
|
static fetch(tag: string): Promise<void>;
|
|
723
|
-
static load(tag: string
|
|
724
|
-
notPatched?: boolean;
|
|
725
|
-
}): Promise<typeof ts | undefined>;
|
|
703
|
+
static load(tag: string): Promise<typeof ts | undefined>;
|
|
726
704
|
static open(): Promise<void>;
|
|
727
705
|
static prune(): Promise<void>;
|
|
728
706
|
static update(): Promise<void>;
|
|
@@ -736,5 +714,5 @@ declare class Version {
|
|
|
736
714
|
static isSatisfiedWith(source: string, target: string): boolean;
|
|
737
715
|
}
|
|
738
716
|
|
|
739
|
-
export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path,
|
|
740
|
-
export type { AssertionCounts, AssertionResultStatus, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, OptionDefinition,
|
|
717
|
+
export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectResult, Result, ResultStatus, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, Store, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileStatusText, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
|
718
|
+
export type { AssertionCounts, AssertionResultStatus, CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, EnvironmentOptions, Event, EventHandler, FileCounts, FileResultStatus, InlineConfig, ItemDefinition, OptionDefinition, Reporter, ReporterEvent, ResolvedConfig, ResultCounts, ResultTiming, ScribblerOptions, SuppressedCounts, SuppressedResultStatus, TargetCounts, TargetResultStatus, TestCounts, TestResultStatus, TextRange };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { writeFileSync, rmSync, existsSync, watch } from 'node:fs';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import process from 'node:process';
|
|
7
|
-
import { createRequire } from 'node:module';
|
|
8
|
-
import vm from 'node:vm';
|
|
9
7
|
|
|
10
8
|
class EventEmitter {
|
|
11
9
|
static instanceCount = 0;
|
|
@@ -397,9 +395,9 @@ class ConfigDiagnosticText {
|
|
|
397
395
|
}
|
|
398
396
|
static rangeUsage() {
|
|
399
397
|
return [
|
|
400
|
-
"A range must be specified using an operator and a minor version: '>=5.
|
|
401
|
-
"To set an upper bound, use the intersection of two ranges: '>=5.
|
|
402
|
-
"Use the '||' operator to join ranges into a union: '>=5.
|
|
398
|
+
"A range must be specified using an operator and a minor version: '>=5.8'.",
|
|
399
|
+
"To set an upper bound, use the intersection of two ranges: '>=5.4 <5.6'.",
|
|
400
|
+
"Use the '||' operator to join ranges into a union: '>=5.4 <5.6 || 5.6.2 || >=5.8'.",
|
|
403
401
|
];
|
|
404
402
|
}
|
|
405
403
|
static seen(element) {
|
|
@@ -731,7 +729,7 @@ class ManifestService {
|
|
|
731
729
|
const versions = [];
|
|
732
730
|
const packageMetadata = (await response.json());
|
|
733
731
|
for (const [tag, meta] of Object.entries(packageMetadata.versions)) {
|
|
734
|
-
if (!tag.includes("-") && Version.isSatisfiedWith(tag, "5.
|
|
732
|
+
if (!tag.includes("-") && Version.isSatisfiedWith(tag, "5.4.2")) {
|
|
735
733
|
versions.push(tag);
|
|
736
734
|
packages[tag] = { integrity: meta.dist.integrity, tarball: meta.dist.tarball };
|
|
737
735
|
}
|
|
@@ -896,7 +894,6 @@ class PackageService {
|
|
|
896
894
|
}
|
|
897
895
|
|
|
898
896
|
class Store {
|
|
899
|
-
static #compilerInstanceCache = new Map();
|
|
900
897
|
static #fetcher;
|
|
901
898
|
static #lockService;
|
|
902
899
|
static manifest;
|
|
@@ -924,14 +921,10 @@ class Store {
|
|
|
924
921
|
}
|
|
925
922
|
await Store.#packageService.ensure(version, Store.manifest);
|
|
926
923
|
}
|
|
927
|
-
static async load(tag
|
|
928
|
-
let
|
|
929
|
-
if (compilerInstance != null) {
|
|
930
|
-
return compilerInstance;
|
|
931
|
-
}
|
|
932
|
-
let modulePath;
|
|
924
|
+
static async load(tag) {
|
|
925
|
+
let resolvedModule;
|
|
933
926
|
if (tag === "*" && environmentOptions.typescriptModule != null) {
|
|
934
|
-
|
|
927
|
+
resolvedModule = environmentOptions.typescriptModule;
|
|
935
928
|
}
|
|
936
929
|
else {
|
|
937
930
|
await Store.open();
|
|
@@ -940,40 +933,15 @@ class Store {
|
|
|
940
933
|
Store.#onDiagnostics(Diagnostic.error(StoreDiagnosticText.cannotAddTypeScriptPackage(tag)));
|
|
941
934
|
return;
|
|
942
935
|
}
|
|
943
|
-
compilerInstance = Store.#compilerInstanceCache.get(version);
|
|
944
|
-
if (compilerInstance != null) {
|
|
945
|
-
return compilerInstance;
|
|
946
|
-
}
|
|
947
936
|
const packagePath = await Store.#packageService.ensure(version, Store.manifest);
|
|
948
937
|
if (packagePath != null) {
|
|
949
|
-
|
|
938
|
+
resolvedModule = pathToFileURL(`${packagePath}/lib/typescript.js`).toString();
|
|
950
939
|
}
|
|
951
940
|
}
|
|
952
|
-
if (
|
|
953
|
-
|
|
954
|
-
const { version: packageVersion } = JSON.parse(packageConfigText);
|
|
955
|
-
if (!Version.isSatisfiedWith(packageVersion, "5.3")) {
|
|
956
|
-
modulePath = Path.resolve(modulePath, "../tsserverlibrary.js");
|
|
957
|
-
}
|
|
958
|
-
if (options?.notPatched) {
|
|
959
|
-
const moduleSpecifier = pathToFileURL(modulePath).toString();
|
|
960
|
-
compilerInstance = (await import(moduleSpecifier)).default;
|
|
961
|
-
}
|
|
962
|
-
else {
|
|
963
|
-
compilerInstance = await Store.#loadPatchedModule(modulePath);
|
|
964
|
-
}
|
|
965
|
-
Store.#compilerInstanceCache.set(tag, compilerInstance);
|
|
966
|
-
Store.#compilerInstanceCache.set(compilerInstance.version, compilerInstance);
|
|
941
|
+
if (resolvedModule != null) {
|
|
942
|
+
return (await import(resolvedModule)).default;
|
|
967
943
|
}
|
|
968
|
-
return
|
|
969
|
-
}
|
|
970
|
-
static async #loadPatchedModule(modulePath) {
|
|
971
|
-
const sourceText = await fs.readFile(modulePath, { encoding: "utf8" });
|
|
972
|
-
const compiledWrapper = vm.compileFunction(sourceText.replace("return checker;", "return { ...checker, isTypeIdenticalTo };"), ["exports", "require", "module", "__filename", "__dirname"], { filename: modulePath });
|
|
973
|
-
const exports$1 = {};
|
|
974
|
-
const module = { exports: exports$1 };
|
|
975
|
-
compiledWrapper(exports$1, createRequire(modulePath), module, modulePath, Path.dirname(modulePath));
|
|
976
|
-
return module.exports;
|
|
944
|
+
return;
|
|
977
945
|
}
|
|
978
946
|
static #onDiagnostics(diagnostic) {
|
|
979
947
|
EventEmitter.dispatch(["store:error", { diagnostics: [diagnostic] }]);
|
|
@@ -1107,12 +1075,6 @@ class Options {
|
|
|
1107
1075
|
group: 2,
|
|
1108
1076
|
name: "help",
|
|
1109
1077
|
},
|
|
1110
|
-
{
|
|
1111
|
-
brand: "boolean",
|
|
1112
|
-
description: "Use the patch-based implementation of the '.toBe()' matcher.",
|
|
1113
|
-
group: 4,
|
|
1114
|
-
name: "legacyToBe",
|
|
1115
|
-
},
|
|
1116
1078
|
{
|
|
1117
1079
|
brand: "true",
|
|
1118
1080
|
description: "Print the list of supported versions of the 'typescript' package and exit.",
|
|
@@ -1131,16 +1093,6 @@ class Options {
|
|
|
1131
1093
|
group: 2,
|
|
1132
1094
|
name: "only",
|
|
1133
1095
|
},
|
|
1134
|
-
{
|
|
1135
|
-
brand: "list",
|
|
1136
|
-
description: "The list of plugins to use.",
|
|
1137
|
-
group: 2 | 4,
|
|
1138
|
-
items: {
|
|
1139
|
-
brand: "string",
|
|
1140
|
-
name: "plugins",
|
|
1141
|
-
},
|
|
1142
|
-
name: "plugins",
|
|
1143
|
-
},
|
|
1144
1096
|
{
|
|
1145
1097
|
brand: "true",
|
|
1146
1098
|
description: "Remove all installed versions of the 'typescript' package and exit.",
|
|
@@ -1257,7 +1209,6 @@ class Options {
|
|
|
1257
1209
|
}
|
|
1258
1210
|
optionValue = Path.resolve(rootPath, optionValue);
|
|
1259
1211
|
break;
|
|
1260
|
-
case "plugins":
|
|
1261
1212
|
case "reporters":
|
|
1262
1213
|
if (canonicalOptionName === "reporters" && Options.#isBuiltinReporter(optionValue)) {
|
|
1263
1214
|
break;
|
|
@@ -1290,7 +1241,6 @@ class Options {
|
|
|
1290
1241
|
}
|
|
1291
1242
|
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.fileDoesNotExist(optionValue), origin));
|
|
1292
1243
|
break;
|
|
1293
|
-
case "plugins":
|
|
1294
1244
|
case "reporters":
|
|
1295
1245
|
if (canonicalOptionName === "reporters" && Options.#isBuiltinReporter(optionValue)) {
|
|
1296
1246
|
break;
|
|
@@ -1603,8 +1553,6 @@ const defaultOptions = {
|
|
|
1603
1553
|
checkSuppressedErrors: true,
|
|
1604
1554
|
failFast: false,
|
|
1605
1555
|
fixtureFileMatch: ["**/__fixtures__/*.{ts,tsx}", "**/fixtures/*.{ts,tsx}"],
|
|
1606
|
-
legacyToBe: false,
|
|
1607
|
-
plugins: [],
|
|
1608
1556
|
rejectAnyType: true,
|
|
1609
1557
|
rejectNeverType: true,
|
|
1610
1558
|
reporters: ["list", "summary"],
|
|
@@ -2432,7 +2380,7 @@ function CommandLineUsageText() {
|
|
|
2432
2380
|
const usage = [
|
|
2433
2381
|
["tstyche", "Run all tests."],
|
|
2434
2382
|
["tstyche query-params", "Only run the matching test file."],
|
|
2435
|
-
["tstyche --target '5.
|
|
2383
|
+
["tstyche --target '5.4 || 5.6.2 || >=5.8'", "Test against specific versions of TypeScript."],
|
|
2436
2384
|
];
|
|
2437
2385
|
const usageText = usage.map(([commandText, descriptionText]) => (jsx(Line, { children: [jsx(CommandText, { text: commandText }), jsx(OptionDescriptionText, { text: descriptionText })] })));
|
|
2438
2386
|
return jsx(Text, { children: usageText });
|
|
@@ -2577,25 +2525,6 @@ function watchUsageText() {
|
|
|
2577
2525
|
return jsx(Text, { children: usageText });
|
|
2578
2526
|
}
|
|
2579
2527
|
|
|
2580
|
-
class PluginService {
|
|
2581
|
-
static #handlers = new Map();
|
|
2582
|
-
static addHandler(plugin) {
|
|
2583
|
-
PluginService.#handlers.set(plugin.name, plugin);
|
|
2584
|
-
}
|
|
2585
|
-
static async call(hook, argument, context) {
|
|
2586
|
-
let result = argument;
|
|
2587
|
-
for (const [, plugin] of PluginService.#handlers) {
|
|
2588
|
-
if (hook in plugin) {
|
|
2589
|
-
result = await plugin[hook].call(context, result);
|
|
2590
|
-
}
|
|
2591
|
-
}
|
|
2592
|
-
return result;
|
|
2593
|
-
}
|
|
2594
|
-
static removeHandlers() {
|
|
2595
|
-
PluginService.#handlers.clear();
|
|
2596
|
-
}
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
2528
|
class BaseReporter {
|
|
2600
2529
|
resolvedConfig;
|
|
2601
2530
|
constructor(resolvedConfig) {
|
|
@@ -4363,29 +4292,6 @@ class ExpectDiagnosticText {
|
|
|
4363
4292
|
}
|
|
4364
4293
|
}
|
|
4365
4294
|
|
|
4366
|
-
class RelationMatcherBase {
|
|
4367
|
-
explain(matchWorker, sourceNode, targetNode) {
|
|
4368
|
-
const sourceTypeText = matchWorker.getTypeText(sourceNode);
|
|
4369
|
-
const targetTypeText = matchWorker.getTypeText(targetNode);
|
|
4370
|
-
const text = matchWorker.assertionNode.isNot
|
|
4371
|
-
? this.explainText(sourceTypeText, targetTypeText)
|
|
4372
|
-
: this.explainNotText(sourceTypeText, targetTypeText);
|
|
4373
|
-
const origin = DiagnosticOrigin.fromNode(targetNode, matchWorker.assertionNode);
|
|
4374
|
-
return [Diagnostic.error(text, origin)];
|
|
4375
|
-
}
|
|
4376
|
-
}
|
|
4377
|
-
|
|
4378
|
-
class LegacyToBe extends RelationMatcherBase {
|
|
4379
|
-
explainText = ExpectDiagnosticText.isTheSame;
|
|
4380
|
-
explainNotText = ExpectDiagnosticText.isNotTheSame;
|
|
4381
|
-
match(matchWorker, sourceNode, targetNode) {
|
|
4382
|
-
return {
|
|
4383
|
-
explain: () => this.explain(matchWorker, sourceNode, targetNode),
|
|
4384
|
-
isMatch: matchWorker.checkIsIdenticalTo(sourceNode, targetNode),
|
|
4385
|
-
};
|
|
4386
|
-
}
|
|
4387
|
-
}
|
|
4388
|
-
|
|
4389
4295
|
class MatchWorker {
|
|
4390
4296
|
assertionNode;
|
|
4391
4297
|
#compiler;
|
|
@@ -4397,25 +4303,15 @@ class MatchWorker {
|
|
|
4397
4303
|
this.assertionNode = assertionNode;
|
|
4398
4304
|
}
|
|
4399
4305
|
checkIsAssignableTo(sourceNode, targetNode) {
|
|
4400
|
-
return this.#checkIsRelatedTo(sourceNode, targetNode
|
|
4306
|
+
return this.#checkIsRelatedTo(sourceNode, targetNode);
|
|
4401
4307
|
}
|
|
4402
4308
|
checkIsAssignableWith(sourceNode, targetNode) {
|
|
4403
|
-
return this.#checkIsRelatedTo(targetNode, sourceNode
|
|
4309
|
+
return this.#checkIsRelatedTo(targetNode, sourceNode);
|
|
4404
4310
|
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
}
|
|
4410
|
-
#checkIsRelatedTo(sourceNode, targetNode, relation) {
|
|
4411
|
-
const sourceType = relation === "identical" ? this.#simplifyType(this.getType(sourceNode)) : this.getType(sourceNode);
|
|
4412
|
-
const targetType = relation === "identical" ? this.#simplifyType(this.getType(targetNode)) : this.getType(targetNode);
|
|
4413
|
-
switch (relation) {
|
|
4414
|
-
case "assignable":
|
|
4415
|
-
return this.typeChecker.isTypeAssignableTo(sourceType, targetType);
|
|
4416
|
-
case "identical":
|
|
4417
|
-
return this.typeChecker.isTypeIdenticalTo(sourceType, targetType);
|
|
4418
|
-
}
|
|
4311
|
+
#checkIsRelatedTo(sourceNode, targetNode) {
|
|
4312
|
+
const sourceType = this.getType(sourceNode);
|
|
4313
|
+
const targetType = this.getType(targetNode);
|
|
4314
|
+
return this.typeChecker.isTypeAssignableTo(sourceType, targetType);
|
|
4419
4315
|
}
|
|
4420
4316
|
extendsObjectType(type) {
|
|
4421
4317
|
const nonPrimitiveType = "getNonPrimitiveType" in this.typeChecker
|
|
@@ -4458,15 +4354,6 @@ class MatchWorker {
|
|
|
4458
4354
|
}
|
|
4459
4355
|
return DiagnosticOrigin.fromNode(enclosingNode, this.assertionNode);
|
|
4460
4356
|
}
|
|
4461
|
-
#simplifyType(type) {
|
|
4462
|
-
if (type.isUnionOrIntersection()) {
|
|
4463
|
-
const candidateType = this.#simplifyType(type.types[0]);
|
|
4464
|
-
if (type.types.every((type) => this.typeChecker.isTypeIdenticalTo(this.#simplifyType(type), candidateType))) {
|
|
4465
|
-
return candidateType;
|
|
4466
|
-
}
|
|
4467
|
-
}
|
|
4468
|
-
return type;
|
|
4469
|
-
}
|
|
4470
4357
|
}
|
|
4471
4358
|
|
|
4472
4359
|
function isStringOrNumberLiteralType(compiler, type) {
|
|
@@ -5131,6 +5018,18 @@ class Structure {
|
|
|
5131
5018
|
}
|
|
5132
5019
|
}
|
|
5133
5020
|
|
|
5021
|
+
class RelationMatcherBase {
|
|
5022
|
+
explain(matchWorker, sourceNode, targetNode) {
|
|
5023
|
+
const sourceTypeText = matchWorker.getTypeText(sourceNode);
|
|
5024
|
+
const targetTypeText = matchWorker.getTypeText(targetNode);
|
|
5025
|
+
const text = matchWorker.assertionNode.isNot
|
|
5026
|
+
? this.explainText(sourceTypeText, targetTypeText)
|
|
5027
|
+
: this.explainNotText(sourceTypeText, targetTypeText);
|
|
5028
|
+
const origin = DiagnosticOrigin.fromNode(targetNode, matchWorker.assertionNode);
|
|
5029
|
+
return [Diagnostic.error(text, origin)];
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
|
|
5134
5033
|
class ToBe extends RelationMatcherBase {
|
|
5135
5034
|
#structure;
|
|
5136
5035
|
constructor(compiler, program) {
|
|
@@ -5482,12 +5381,12 @@ class ExpectService {
|
|
|
5482
5381
|
toBeConstructableWith;
|
|
5483
5382
|
toHaveProperty;
|
|
5484
5383
|
toRaiseError;
|
|
5485
|
-
constructor(compiler, program, reject
|
|
5384
|
+
constructor(compiler, program, reject) {
|
|
5486
5385
|
this.#compiler = compiler;
|
|
5487
5386
|
this.#program = program;
|
|
5488
5387
|
this.#reject = reject;
|
|
5489
5388
|
this.toAcceptProps = new ToAcceptProps(compiler, program);
|
|
5490
|
-
this.toBe =
|
|
5389
|
+
this.toBe = new ToBe(compiler, program);
|
|
5491
5390
|
this.toBeApplicable = new ToBeApplicable(compiler);
|
|
5492
5391
|
this.toBeAssignableFrom = new ToBeAssignableFrom();
|
|
5493
5392
|
this.toBeAssignableTo = new ToBeAssignableTo();
|
|
@@ -5732,7 +5631,7 @@ class TestTreeWalker {
|
|
|
5732
5631
|
this.#hasOnly = options.hasOnly || resolvedConfig.only != null || options.position != null;
|
|
5733
5632
|
this.#position = options.position;
|
|
5734
5633
|
const reject = new Reject(compiler, program, resolvedConfig);
|
|
5735
|
-
this.#expectService = new ExpectService(compiler, program, reject
|
|
5634
|
+
this.#expectService = new ExpectService(compiler, program, reject);
|
|
5736
5635
|
this.#whenService = new WhenService(reject, onFileDiagnostics);
|
|
5737
5636
|
}
|
|
5738
5637
|
async #resolveRunMode(flags, node) {
|
|
@@ -5950,10 +5849,6 @@ class FileRunner {
|
|
|
5950
5849
|
return { runModeFlags, testTree, program };
|
|
5951
5850
|
}
|
|
5952
5851
|
async #run(file, fileResult, cancellationToken) {
|
|
5953
|
-
if (!existsSync(file.path)) {
|
|
5954
|
-
this.#onDiagnostics([Diagnostic.error(`Test file '${file.path}' does not exist.`)], fileResult);
|
|
5955
|
-
return;
|
|
5956
|
-
}
|
|
5957
5852
|
const facts = await this.#resolveFileFacts(file, fileResult, 0);
|
|
5958
5853
|
if (!facts) {
|
|
5959
5854
|
return;
|
|
@@ -5977,7 +5872,7 @@ class FileRunner {
|
|
|
5977
5872
|
class Runner {
|
|
5978
5873
|
#eventEmitter = new EventEmitter();
|
|
5979
5874
|
#resolvedConfig;
|
|
5980
|
-
static version = "6.0.0-beta.
|
|
5875
|
+
static version = "6.0.0-beta.3";
|
|
5981
5876
|
constructor(resolvedConfig) {
|
|
5982
5877
|
this.#resolvedConfig = resolvedConfig;
|
|
5983
5878
|
}
|
|
@@ -6034,7 +5929,7 @@ class Runner {
|
|
|
6034
5929
|
for (const target of this.#resolvedConfig.target) {
|
|
6035
5930
|
const targetResult = new TargetResult(target, files);
|
|
6036
5931
|
EventEmitter.dispatch(["target:start", { result: targetResult }]);
|
|
6037
|
-
const compiler = await Store.load(target
|
|
5932
|
+
const compiler = await Store.load(target);
|
|
6038
5933
|
if (compiler) {
|
|
6039
5934
|
const fileRunner = new FileRunner(compiler, this.#resolvedConfig);
|
|
6040
5935
|
for (const file of files) {
|
|
@@ -6102,7 +5997,7 @@ class Cli {
|
|
|
6102
5997
|
this.#eventEmitter.addReporter(setupReporter);
|
|
6103
5998
|
}
|
|
6104
5999
|
const { configFileOptions, configFilePath } = await Config.parseConfigFile(commandLineOptions.config);
|
|
6105
|
-
|
|
6000
|
+
const resolvedConfig = Config.resolve({
|
|
6106
6001
|
configFileOptions,
|
|
6107
6002
|
configFilePath,
|
|
6108
6003
|
commandLineOptions,
|
|
@@ -6114,11 +6009,6 @@ class Cli {
|
|
|
6114
6009
|
}
|
|
6115
6010
|
continue;
|
|
6116
6011
|
}
|
|
6117
|
-
for (const pluginSpecifier of resolvedConfig.plugins) {
|
|
6118
|
-
const plugin = (await import(pluginSpecifier)).default;
|
|
6119
|
-
PluginService.addHandler(plugin);
|
|
6120
|
-
}
|
|
6121
|
-
resolvedConfig = await PluginService.call("config", resolvedConfig, {});
|
|
6122
6012
|
if (commandLine.includes("--showConfig")) {
|
|
6123
6013
|
OutputService.writeMessage(formattedText({ ...resolvedConfig, ...environmentOptions }));
|
|
6124
6014
|
continue;
|
|
@@ -6139,7 +6029,6 @@ class Cli {
|
|
|
6139
6029
|
continue;
|
|
6140
6030
|
}
|
|
6141
6031
|
}
|
|
6142
|
-
testFiles = await PluginService.call("select", testFiles, { resolvedConfig });
|
|
6143
6032
|
if (commandLine.includes("--listFiles")) {
|
|
6144
6033
|
OutputService.writeMessage(formattedText(testFiles.map((testFile) => testFile.toString())));
|
|
6145
6034
|
continue;
|
|
@@ -6148,7 +6037,6 @@ class Cli {
|
|
|
6148
6037
|
this.#eventEmitter.removeReporter(setupReporter);
|
|
6149
6038
|
const runner = new Runner(resolvedConfig);
|
|
6150
6039
|
await runner.run(testFiles, cancellationToken);
|
|
6151
|
-
PluginService.removeHandlers();
|
|
6152
6040
|
} while (cancellationToken.getReason() === "configChange");
|
|
6153
6041
|
this.#eventEmitter.removeHandlers();
|
|
6154
6042
|
}
|
|
@@ -6180,4 +6068,4 @@ class Cli {
|
|
|
6180
6068
|
}
|
|
6181
6069
|
}
|
|
6182
6070
|
|
|
6183
|
-
export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path,
|
|
6071
|
+
export { BaseReporter, CancellationReason, CancellationToken, Cli, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExpectResult, FileLocation, FileResult, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, ProjectResult, Result, ResultStatus, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, Store, SummaryReporter, SuppressedResult, TargetResult, TestResult, Text, Version, WatchReporter, addsPackageText, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileStatusText, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, prologueText, summaryText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tstyche",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.3",
|
|
4
4
|
"description": "Everything You Need for Type Testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -21,18 +21,14 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
|
-
".":
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"./package.json": "./package.json",
|
|
29
|
-
"./tstyche": "./build/tstyche.js"
|
|
24
|
+
".": "./dist/index.js",
|
|
25
|
+
"./tstyche": "./dist/tstyche.js",
|
|
26
|
+
"./package.json": "./package.json"
|
|
30
27
|
},
|
|
31
|
-
"main": "./
|
|
32
|
-
"
|
|
33
|
-
"bin": "./build/bin.js",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"bin": "./dist/bin.js",
|
|
34
30
|
"peerDependencies": {
|
|
35
|
-
"typescript": ">=5.
|
|
31
|
+
"typescript": ">=5.4"
|
|
36
32
|
},
|
|
37
33
|
"peerDependenciesMeta": {
|
|
38
34
|
"typescript": {
|
|
@@ -40,6 +36,6 @@
|
|
|
40
36
|
}
|
|
41
37
|
},
|
|
42
38
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
39
|
+
"node": ">=22.12"
|
|
44
40
|
}
|
|
45
41
|
}
|
package/build/index.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function noop() {
|
|
4
|
-
}
|
|
5
|
-
const noopChain = new Proxy(noop, {
|
|
6
|
-
apply() {
|
|
7
|
-
return noopChain;
|
|
8
|
-
},
|
|
9
|
-
get() {
|
|
10
|
-
return noopChain;
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
exports.describe = noopChain;
|
|
15
|
-
exports.expect = noopChain;
|
|
16
|
-
exports.it = noopChain;
|
|
17
|
-
exports.omit = noop;
|
|
18
|
-
exports.pick = noop;
|
|
19
|
-
exports.test = noopChain;
|
|
20
|
-
exports.when = noopChain;
|
package/build/index.d.cts
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
interface Describe {
|
|
2
|
-
/**
|
|
3
|
-
* Defines a group of tests.
|
|
4
|
-
*
|
|
5
|
-
* @param name - The name of the group.
|
|
6
|
-
* @param callback - The function to create a scope for a group of tests.
|
|
7
|
-
*/
|
|
8
|
-
(name: string, callback: () => void | Promise<void>): void;
|
|
9
|
-
/**
|
|
10
|
-
* Marks a group of tests as focused.
|
|
11
|
-
*
|
|
12
|
-
* @param name - The name of the group.
|
|
13
|
-
* @param callback - The function to create a scope for a group of tests.
|
|
14
|
-
*/
|
|
15
|
-
only: (name: string, callback: () => void | Promise<void>) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Marks a group of tests as skipped.
|
|
18
|
-
*
|
|
19
|
-
* @param name - The name of the group.
|
|
20
|
-
* @param callback - The function to create a scope for a group of tests.
|
|
21
|
-
*/
|
|
22
|
-
skip: (name: string, callback: () => void | Promise<void>) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Marks a group of tests as yet to be implemented.
|
|
25
|
-
*
|
|
26
|
-
* @param name - The name of the group.
|
|
27
|
-
* @param callback - The function to create a scope for a group of tests.
|
|
28
|
-
*/
|
|
29
|
-
todo: (name: string, callback?: () => void | Promise<void>) => void;
|
|
30
|
-
}
|
|
31
|
-
interface Test {
|
|
32
|
-
/**
|
|
33
|
-
* Defines a single test.
|
|
34
|
-
*
|
|
35
|
-
* @param name - The name of the test.
|
|
36
|
-
* @param callback - The function with a code snippet and assertions.
|
|
37
|
-
*/
|
|
38
|
-
(name: string, callback: () => void | Promise<void>): void;
|
|
39
|
-
/**
|
|
40
|
-
* Marks a test as focused.
|
|
41
|
-
*
|
|
42
|
-
* @param name - The name of the test.
|
|
43
|
-
* @param callback - The function with a code snippet and assertions.
|
|
44
|
-
*/
|
|
45
|
-
only: (name: string, callback: () => void | Promise<void>) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Marks a test as skipped.
|
|
48
|
-
*
|
|
49
|
-
* @param name - The name of the test.
|
|
50
|
-
* @param callback - The function with a code snippet and assertions.
|
|
51
|
-
*/
|
|
52
|
-
skip: (name: string, callback: () => void | Promise<void>) => void;
|
|
53
|
-
/**
|
|
54
|
-
* Marks a test as yet to be implemented.
|
|
55
|
-
*
|
|
56
|
-
* @param name - The name of the test.
|
|
57
|
-
* @param callback - The function with a code snippet and assertions.
|
|
58
|
-
*/
|
|
59
|
-
todo: (name: string, callback?: () => void | Promise<void>) => void;
|
|
60
|
-
}
|
|
61
|
-
interface Matchers {
|
|
62
|
-
/**
|
|
63
|
-
* Checks if the JSX component accepts props of the given type.
|
|
64
|
-
*
|
|
65
|
-
* @remarks
|
|
66
|
-
*
|
|
67
|
-
* This is a work in progress feature. Generic components are not yet supported.
|
|
68
|
-
*/
|
|
69
|
-
toAcceptProps: {
|
|
70
|
-
/**
|
|
71
|
-
* Checks if the JSX component accepts props of the given type.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
*
|
|
75
|
-
* This is a work in progress feature. Generic components are not yet supported.
|
|
76
|
-
*/
|
|
77
|
-
<Target>(): void;
|
|
78
|
-
/**
|
|
79
|
-
* Checks if the JSX component accepts the given props.
|
|
80
|
-
*
|
|
81
|
-
* @remarks
|
|
82
|
-
*
|
|
83
|
-
* This is a work in progress feature. Generic components are not yet supported.
|
|
84
|
-
*/
|
|
85
|
-
(target: unknown): void;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Checks if the source type is the same as the target type.
|
|
89
|
-
*/
|
|
90
|
-
toBe: {
|
|
91
|
-
/**
|
|
92
|
-
* Checks if the source type is the same as the target type.
|
|
93
|
-
*/
|
|
94
|
-
<Target>(): void;
|
|
95
|
-
/**
|
|
96
|
-
* Checks if the source type is the same as type of the target expression.
|
|
97
|
-
*/
|
|
98
|
-
(target: unknown): void;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the decorator function can be applied.
|
|
102
|
-
*/
|
|
103
|
-
toBeApplicable: (target: unknown, context: DecoratorContext) => void;
|
|
104
|
-
/**
|
|
105
|
-
* Checks if the source type is assignable from the target type.
|
|
106
|
-
*/
|
|
107
|
-
toBeAssignableFrom: {
|
|
108
|
-
/**
|
|
109
|
-
* Checks if the source type is assignable from the target type.
|
|
110
|
-
*/
|
|
111
|
-
<Target>(): void;
|
|
112
|
-
/**
|
|
113
|
-
* Checks if the source type is assignable from type of the target expression.
|
|
114
|
-
*/
|
|
115
|
-
(target: unknown): void;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Checks if the source type is assignable to the target type.
|
|
119
|
-
*/
|
|
120
|
-
toBeAssignableTo: {
|
|
121
|
-
/**
|
|
122
|
-
* Checks if the source type is assignable to the target type.
|
|
123
|
-
*/
|
|
124
|
-
<Target>(): void;
|
|
125
|
-
/**
|
|
126
|
-
* Checks if the source type is assignable to type of the target expression.
|
|
127
|
-
*/
|
|
128
|
-
(target: unknown): void;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Checks if the source type is callable with the given arguments.
|
|
132
|
-
*/
|
|
133
|
-
toBeCallableWith: (...args: Array<unknown>) => void;
|
|
134
|
-
/**
|
|
135
|
-
* Checks if the source type is constructable with the given arguments.
|
|
136
|
-
*/
|
|
137
|
-
toBeConstructableWith: (...args: Array<unknown>) => void;
|
|
138
|
-
/**
|
|
139
|
-
* Checks if a property key exists on the source type.
|
|
140
|
-
*/
|
|
141
|
-
toHaveProperty: (key: string | number | symbol) => void;
|
|
142
|
-
/**
|
|
143
|
-
* Checks if the source type raises an error.
|
|
144
|
-
*/
|
|
145
|
-
toRaiseError: (...target: Array<string | number | RegExp>) => void;
|
|
146
|
-
}
|
|
147
|
-
interface Modifier {
|
|
148
|
-
/**
|
|
149
|
-
* Indicates a type-level assertion.
|
|
150
|
-
*/
|
|
151
|
-
type: Matchers & {
|
|
152
|
-
/**
|
|
153
|
-
* Negates the assertion.
|
|
154
|
-
*/
|
|
155
|
-
not: Matchers;
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
interface Expect {
|
|
159
|
-
/**
|
|
160
|
-
* Builds an assertion.
|
|
161
|
-
*
|
|
162
|
-
* @template Source - The type which is checked.
|
|
163
|
-
*/
|
|
164
|
-
<Source>(): Modifier;
|
|
165
|
-
/**
|
|
166
|
-
* Builds an assertion.
|
|
167
|
-
*
|
|
168
|
-
* @param source - The expression whose type is checked.
|
|
169
|
-
*/
|
|
170
|
-
(source: unknown): Modifier;
|
|
171
|
-
/**
|
|
172
|
-
* Marks an assertion as focused.
|
|
173
|
-
*/
|
|
174
|
-
only: {
|
|
175
|
-
/**
|
|
176
|
-
* Marks an assertion as focused.
|
|
177
|
-
*
|
|
178
|
-
* @template Source - The type which is checked.
|
|
179
|
-
*/
|
|
180
|
-
<Source>(): Modifier;
|
|
181
|
-
/**
|
|
182
|
-
* Marks an assertion as focused.
|
|
183
|
-
*
|
|
184
|
-
* @param source - The expression whose type is checked.
|
|
185
|
-
*/
|
|
186
|
-
(source: unknown): Modifier;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Marks an assertion as skipped.
|
|
190
|
-
*/
|
|
191
|
-
skip: {
|
|
192
|
-
/**
|
|
193
|
-
* Marks an assertion as skipped.
|
|
194
|
-
*
|
|
195
|
-
* @template Source - The type which is checked.
|
|
196
|
-
*/
|
|
197
|
-
<Source>(): Modifier;
|
|
198
|
-
/**
|
|
199
|
-
* Marks an assertion as skipped.
|
|
200
|
-
*
|
|
201
|
-
* @param source - The expression whose type is checked.
|
|
202
|
-
*/
|
|
203
|
-
(source: unknown): Modifier;
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Builds an assertion.
|
|
208
|
-
*/
|
|
209
|
-
declare const expect: Expect;
|
|
210
|
-
/**
|
|
211
|
-
* Reshapes type of the given object by removing the specified keys.
|
|
212
|
-
*/
|
|
213
|
-
declare function omit<T, K extends PropertyKey>(object: T, ...keys: [K, ...Array<K>]): Omit<T, K>;
|
|
214
|
-
/**
|
|
215
|
-
* Reshapes type of the given object by keeping only the specified keys.
|
|
216
|
-
*/
|
|
217
|
-
declare function pick<T, K extends keyof T>(object: T, ...keys: [K, ...Array<K>]): Pick<T, K>;
|
|
218
|
-
/**
|
|
219
|
-
* Defines a test group.
|
|
220
|
-
*/
|
|
221
|
-
declare const describe: Describe;
|
|
222
|
-
/**
|
|
223
|
-
* Defines a single test.
|
|
224
|
-
*/
|
|
225
|
-
declare const it: Test;
|
|
226
|
-
/**
|
|
227
|
-
* Defines a single test.
|
|
228
|
-
*/
|
|
229
|
-
declare const test: Test;
|
|
230
|
-
interface Actions {
|
|
231
|
-
/**
|
|
232
|
-
* Calls the given function with the provided arguments.
|
|
233
|
-
*/
|
|
234
|
-
isCalledWith: (...args: Array<unknown>) => void;
|
|
235
|
-
}
|
|
236
|
-
interface When {
|
|
237
|
-
/**
|
|
238
|
-
* Creates a test plan.
|
|
239
|
-
*
|
|
240
|
-
* @template Target - The type upon which an action is performed.
|
|
241
|
-
*/
|
|
242
|
-
<Target>(): Actions;
|
|
243
|
-
/**
|
|
244
|
-
* Creates a test plan.
|
|
245
|
-
*
|
|
246
|
-
* @param target - The expression upon which an action is performed.
|
|
247
|
-
*/
|
|
248
|
-
(target: unknown): Actions;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Creates a test plan.
|
|
252
|
-
*/
|
|
253
|
-
declare const when: When;
|
|
254
|
-
|
|
255
|
-
export { describe, expect, it, omit, pick, test, when };
|
/package/{build → dist}/bin.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/{build → dist}/index.js
RENAMED
|
File without changes
|