tstyche 4.1.0 → 4.3.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.
- package/build/tstyche.d.ts +9 -2
- package/build/tstyche.js +99 -18
- package/package.json +1 -1
package/build/tstyche.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ interface ConfigFileOptions {
|
|
|
43
43
|
checkSourceFiles?: boolean;
|
|
44
44
|
checkSuppressedErrors?: boolean;
|
|
45
45
|
failFast?: boolean;
|
|
46
|
+
fixtureFileMatch?: Array<string>;
|
|
46
47
|
plugins?: Array<string>;
|
|
47
48
|
rejectAnyType?: boolean;
|
|
48
49
|
rejectNeverType?: boolean;
|
|
@@ -95,13 +96,13 @@ declare class ConfigDiagnosticText {
|
|
|
95
96
|
static expectsListItemType(optionName: string, optionBrand: OptionBrand): string;
|
|
96
97
|
static expectsValue(optionName: string): string;
|
|
97
98
|
static fileDoesNotExist(filePath: string): string;
|
|
99
|
+
static fileMatchPatternCannotStartWith(optionName: string, segment: string): Array<string>;
|
|
98
100
|
static inspectSupportedVersions(): string;
|
|
99
101
|
static moduleWasNotFound(specifier: string): string;
|
|
100
102
|
static rangeIsNotValid(value: string): string;
|
|
101
103
|
static rangeUsage(): Array<string>;
|
|
102
104
|
static requiresValueType(optionName: string, optionBrand: OptionBrand): string;
|
|
103
105
|
static seen(element: string): string;
|
|
104
|
-
static testFileMatchCannotStartWith(segment: string): Array<string>;
|
|
105
106
|
static unexpected(element: string): string;
|
|
106
107
|
static unknownOption(optionName: string): string;
|
|
107
108
|
static usage(optionName: string, optionBrand: OptionBrand): Array<string>;
|
|
@@ -558,6 +559,11 @@ declare class ExpectService {
|
|
|
558
559
|
match(assertion: AssertionNode, onDiagnostics: DiagnosticsHandler<Diagnostic | Array<Diagnostic>>): MatchResult | undefined;
|
|
559
560
|
}
|
|
560
561
|
|
|
562
|
+
declare class Glob {
|
|
563
|
+
#private;
|
|
564
|
+
static toRegex(patterns: Array<string>, target: "directories" | "files"): RegExp;
|
|
565
|
+
}
|
|
566
|
+
|
|
561
567
|
declare class CancellationHandler implements EventHandler {
|
|
562
568
|
#private;
|
|
563
569
|
constructor(cancellationToken: CancellationToken, cancellationReason: CancellationReason);
|
|
@@ -717,6 +723,7 @@ declare class Runner {
|
|
|
717
723
|
|
|
718
724
|
declare class Select {
|
|
719
725
|
#private;
|
|
726
|
+
static isFixtureFile(filePath: string, resolvedConfig: ResolvedConfig): boolean;
|
|
720
727
|
static isTestFile(filePath: string, resolvedConfig: ResolvedConfig): boolean;
|
|
721
728
|
static selectFiles(resolvedConfig: ResolvedConfig): Promise<Array<string>>;
|
|
722
729
|
}
|
|
@@ -810,5 +817,5 @@ declare class WhenService {
|
|
|
810
817
|
action(when: WhenNode): void;
|
|
811
818
|
}
|
|
812
819
|
|
|
813
|
-
export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Reject, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, SuppressedService, TargetResult, Task, TaskResult, TestResult, TestTree, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, WhenNode, WhenService, addsPackageText, argumentIsProvided, argumentOrTypeArgumentIsProvided, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, nodeBelongsToArgumentList, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
|
820
|
+
export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, Glob, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Reject, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, SuppressedService, TargetResult, Task, TaskResult, TestResult, TestTree, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, WhenNode, WhenService, addsPackageText, argumentIsProvided, argumentOrTypeArgumentIsProvided, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, nodeBelongsToArgumentList, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
|
814
821
|
export type { CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, DirectiveRange, DirectiveRanges, EnvironmentOptions, Event, EventHandler, FileWatchHandler, InlineConfig, InputHandler, ItemDefinition, MatchResult, OptionDefinition, Plugin, Reporter, ReporterEvent, ResolvedConfig, ScribblerOptions, SelectHookContext, SuppressedError, SuppressedErrors, TargetResultStatus, TaskResultStatus, TextRange, TypeChecker, WatchHandler, WatcherOptions };
|
package/build/tstyche.js
CHANGED
|
@@ -225,6 +225,12 @@ class ConfigDiagnosticText {
|
|
|
225
225
|
static fileDoesNotExist(filePath) {
|
|
226
226
|
return `The specified path '${filePath}' does not exist.`;
|
|
227
227
|
}
|
|
228
|
+
static fileMatchPatternCannotStartWith(optionName, segment) {
|
|
229
|
+
return [
|
|
230
|
+
`A '${optionName}' pattern cannot start with '${segment}'.`,
|
|
231
|
+
"The files are only collected within the 'rootPath' directory.",
|
|
232
|
+
];
|
|
233
|
+
}
|
|
228
234
|
static inspectSupportedVersions() {
|
|
229
235
|
return "Use the '--list' command line option to inspect the list of supported versions.";
|
|
230
236
|
}
|
|
@@ -247,12 +253,6 @@ class ConfigDiagnosticText {
|
|
|
247
253
|
static seen(element) {
|
|
248
254
|
return `The ${element} was seen here.`;
|
|
249
255
|
}
|
|
250
|
-
static testFileMatchCannotStartWith(segment) {
|
|
251
|
-
return [
|
|
252
|
-
`A test file match pattern cannot start with '${segment}'.`,
|
|
253
|
-
"The test files are only collected within the 'rootPath' directory.",
|
|
254
|
-
];
|
|
255
|
-
}
|
|
256
256
|
static unexpected(element) {
|
|
257
257
|
return `Unexpected ${element}.`;
|
|
258
258
|
}
|
|
@@ -934,6 +934,16 @@ class Options {
|
|
|
934
934
|
group: OptionGroup.CommandLine,
|
|
935
935
|
name: "fetch",
|
|
936
936
|
},
|
|
937
|
+
{
|
|
938
|
+
brand: OptionBrand.List,
|
|
939
|
+
description: "The list of glob patterns matching the fixture files.",
|
|
940
|
+
group: OptionGroup.ConfigFile,
|
|
941
|
+
items: {
|
|
942
|
+
brand: OptionBrand.String,
|
|
943
|
+
name: "fixtureFileMatch",
|
|
944
|
+
},
|
|
945
|
+
name: "fixtureFileMatch",
|
|
946
|
+
},
|
|
937
947
|
{
|
|
938
948
|
brand: OptionBrand.BareTrue,
|
|
939
949
|
description: "Print the list of command line options with brief descriptions and exit.",
|
|
@@ -1147,10 +1157,11 @@ class Options {
|
|
|
1147
1157
|
}
|
|
1148
1158
|
break;
|
|
1149
1159
|
}
|
|
1160
|
+
case "fixtureFileMatch":
|
|
1150
1161
|
case "testFileMatch":
|
|
1151
1162
|
for (const segment of ["/", "../"]) {
|
|
1152
1163
|
if (optionValue.startsWith(segment)) {
|
|
1153
|
-
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.
|
|
1164
|
+
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.fileMatchPatternCannotStartWith(canonicalOptionName, segment), origin));
|
|
1154
1165
|
}
|
|
1155
1166
|
}
|
|
1156
1167
|
break;
|
|
@@ -1402,6 +1413,7 @@ const defaultOptions = {
|
|
|
1402
1413
|
checkSourceFiles: true,
|
|
1403
1414
|
checkSuppressedErrors: false,
|
|
1404
1415
|
failFast: false,
|
|
1416
|
+
fixtureFileMatch: ["**/__fixtures__/*.{ts,tsx}", "**/fixtures/*.{ts,tsx}"],
|
|
1405
1417
|
plugins: [],
|
|
1406
1418
|
rejectAnyType: true,
|
|
1407
1419
|
rejectNeverType: true,
|
|
@@ -2742,7 +2754,64 @@ class InputService {
|
|
|
2742
2754
|
}
|
|
2743
2755
|
}
|
|
2744
2756
|
|
|
2745
|
-
class
|
|
2757
|
+
class Braces {
|
|
2758
|
+
static expand(text) {
|
|
2759
|
+
const start = text.indexOf("{");
|
|
2760
|
+
if (start === -1) {
|
|
2761
|
+
return [text];
|
|
2762
|
+
}
|
|
2763
|
+
let position = start;
|
|
2764
|
+
let depth = 0;
|
|
2765
|
+
for (position; position < text.length; position++) {
|
|
2766
|
+
if (text[position] === "{") {
|
|
2767
|
+
depth++;
|
|
2768
|
+
}
|
|
2769
|
+
else if (text[position] === "}") {
|
|
2770
|
+
depth--;
|
|
2771
|
+
}
|
|
2772
|
+
if (depth === 0) {
|
|
2773
|
+
break;
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
if (depth !== 0) {
|
|
2777
|
+
return [text];
|
|
2778
|
+
}
|
|
2779
|
+
const before = text.slice(0, start);
|
|
2780
|
+
const options = Braces.#splitOptions(text.slice(start + 1, position));
|
|
2781
|
+
const after = text.slice(position + 1);
|
|
2782
|
+
const result = [];
|
|
2783
|
+
for (const option of options) {
|
|
2784
|
+
for (const expanded of Braces.expand(option + after)) {
|
|
2785
|
+
result.push(before + expanded);
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
return result;
|
|
2789
|
+
}
|
|
2790
|
+
static #splitOptions(optionText) {
|
|
2791
|
+
const options = [];
|
|
2792
|
+
let current = "";
|
|
2793
|
+
let depth = 0;
|
|
2794
|
+
for (const character of optionText) {
|
|
2795
|
+
if (character === "," && depth === 0) {
|
|
2796
|
+
options.push(current);
|
|
2797
|
+
current = "";
|
|
2798
|
+
}
|
|
2799
|
+
else {
|
|
2800
|
+
if (character === "{") {
|
|
2801
|
+
depth++;
|
|
2802
|
+
}
|
|
2803
|
+
if (character === "}") {
|
|
2804
|
+
depth--;
|
|
2805
|
+
}
|
|
2806
|
+
current += character;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
options.push(current);
|
|
2810
|
+
return options;
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
class Glob {
|
|
2746
2815
|
static #reservedCharacterRegex = /[^\w\s/]/g;
|
|
2747
2816
|
static #parse(pattern, usageTarget) {
|
|
2748
2817
|
const segments = pattern.split("/");
|
|
@@ -2761,7 +2830,7 @@ class GlobPattern {
|
|
|
2761
2830
|
optionalSegmentCount++;
|
|
2762
2831
|
}
|
|
2763
2832
|
resultPattern += "\\/";
|
|
2764
|
-
const segmentPattern = segment.replace(
|
|
2833
|
+
const segmentPattern = segment.replace(Glob.#reservedCharacterRegex, Glob.#replaceReservedCharacter);
|
|
2765
2834
|
if (segmentPattern !== segment) {
|
|
2766
2835
|
resultPattern += "(?!(node_modules)(\\/|$))";
|
|
2767
2836
|
}
|
|
@@ -2781,7 +2850,10 @@ class GlobPattern {
|
|
|
2781
2850
|
}
|
|
2782
2851
|
}
|
|
2783
2852
|
static toRegex(patterns, target) {
|
|
2784
|
-
const patternText = patterns
|
|
2853
|
+
const patternText = patterns
|
|
2854
|
+
.flatMap((pattern) => Braces.expand(pattern))
|
|
2855
|
+
.map((pattern) => `(${Glob.#parse(pattern, target)})`)
|
|
2856
|
+
.join("|");
|
|
2785
2857
|
return new RegExp(`^(${patternText})$`);
|
|
2786
2858
|
}
|
|
2787
2859
|
}
|
|
@@ -2839,8 +2911,8 @@ class Select {
|
|
|
2839
2911
|
let matchPatterns = Select.#patternsCache.get(globPatterns);
|
|
2840
2912
|
if (!matchPatterns) {
|
|
2841
2913
|
matchPatterns = {
|
|
2842
|
-
includedDirectory:
|
|
2843
|
-
includedFile:
|
|
2914
|
+
includedDirectory: Glob.toRegex(globPatterns, "directories"),
|
|
2915
|
+
includedFile: Glob.toRegex(globPatterns, "files"),
|
|
2844
2916
|
};
|
|
2845
2917
|
Select.#patternsCache.set(globPatterns, matchPatterns);
|
|
2846
2918
|
}
|
|
@@ -2856,6 +2928,10 @@ class Select {
|
|
|
2856
2928
|
}
|
|
2857
2929
|
return matchPatterns.includedFile.test(filePath);
|
|
2858
2930
|
}
|
|
2931
|
+
static isFixtureFile(filePath, resolvedConfig) {
|
|
2932
|
+
const matchPatterns = Select.#getMatchPatterns(resolvedConfig.fixtureFileMatch);
|
|
2933
|
+
return Select.#isFileIncluded(Path.relative(resolvedConfig.rootPath, filePath), matchPatterns, resolvedConfig);
|
|
2934
|
+
}
|
|
2859
2935
|
static isTestFile(filePath, resolvedConfig) {
|
|
2860
2936
|
const matchPatterns = Select.#getMatchPatterns(resolvedConfig.testFileMatch);
|
|
2861
2937
|
return Select.#isFileIncluded(Path.relative(resolvedConfig.rootPath, filePath), matchPatterns, resolvedConfig);
|
|
@@ -3690,7 +3766,7 @@ class ProjectService {
|
|
|
3690
3766
|
{ diagnostics: Diagnostic.fromDiagnostics(configFileErrors) },
|
|
3691
3767
|
]);
|
|
3692
3768
|
}
|
|
3693
|
-
if (
|
|
3769
|
+
if (!this.#seenTestFiles.has(filePath)) {
|
|
3694
3770
|
this.#seenTestFiles.add(filePath);
|
|
3695
3771
|
const languageService = this.getLanguageService(filePath);
|
|
3696
3772
|
const program = languageService?.getProgram();
|
|
@@ -3702,10 +3778,13 @@ class ProjectService {
|
|
|
3702
3778
|
if (program.isSourceFileFromExternalLibrary(sourceFile) || program.isSourceFileDefaultLibrary(sourceFile)) {
|
|
3703
3779
|
return false;
|
|
3704
3780
|
}
|
|
3781
|
+
if (Select.isFixtureFile(sourceFile.fileName, { ...this.#resolvedConfig, pathMatch: [] })) {
|
|
3782
|
+
return true;
|
|
3783
|
+
}
|
|
3705
3784
|
if (Select.isTestFile(sourceFile.fileName, { ...this.#resolvedConfig, pathMatch: [] })) {
|
|
3706
3785
|
return false;
|
|
3707
3786
|
}
|
|
3708
|
-
return
|
|
3787
|
+
return this.#resolvedConfig.checkSourceFiles;
|
|
3709
3788
|
});
|
|
3710
3789
|
const diagnostics = [];
|
|
3711
3790
|
for (const sourceFile of sourceFilesToCheck) {
|
|
@@ -3723,7 +3802,7 @@ class SuppressedDiagnosticText {
|
|
|
3723
3802
|
return [
|
|
3724
3803
|
"Directive requires an argument.",
|
|
3725
3804
|
"Add a fragment of the expected error message after the directive.",
|
|
3726
|
-
"To ignore the directive, append
|
|
3805
|
+
"To ignore the directive, append the '!' character after it.",
|
|
3727
3806
|
];
|
|
3728
3807
|
}
|
|
3729
3808
|
static messageDidNotMatch() {
|
|
@@ -3956,7 +4035,9 @@ class MatchWorker {
|
|
|
3956
4035
|
}
|
|
3957
4036
|
}
|
|
3958
4037
|
extendsObjectType(type) {
|
|
3959
|
-
const nonPrimitiveType =
|
|
4038
|
+
const nonPrimitiveType = "getNonPrimitiveType" in this.typeChecker
|
|
4039
|
+
? this.typeChecker.getNonPrimitiveType()
|
|
4040
|
+
: { flags: this.#compiler.TypeFlags.NonPrimitive };
|
|
3960
4041
|
return this.typeChecker.isTypeAssignableTo(type, nonPrimitiveType);
|
|
3961
4042
|
}
|
|
3962
4043
|
getParameterType(signature, index) {
|
|
@@ -5022,7 +5103,7 @@ class TaskRunner {
|
|
|
5022
5103
|
class Runner {
|
|
5023
5104
|
#eventEmitter = new EventEmitter();
|
|
5024
5105
|
#resolvedConfig;
|
|
5025
|
-
static version = "4.
|
|
5106
|
+
static version = "4.3.0";
|
|
5026
5107
|
constructor(resolvedConfig) {
|
|
5027
5108
|
this.#resolvedConfig = resolvedConfig;
|
|
5028
5109
|
}
|
|
@@ -5222,4 +5303,4 @@ class Cli {
|
|
|
5222
5303
|
}
|
|
5223
5304
|
}
|
|
5224
5305
|
|
|
5225
|
-
export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Reject, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, SuppressedService, TargetResult, Task, TaskResult, TestResult, TestTree, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, WhenNode, WhenService, addsPackageText, argumentIsProvided, argumentOrTypeArgumentIsProvided, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, nodeBelongsToArgumentList, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|
|
5306
|
+
export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Directive, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, Glob, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Reject, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, SuppressedService, TargetResult, Task, TaskResult, TestResult, TestTree, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, WhenNode, WhenService, addsPackageText, argumentIsProvided, argumentOrTypeArgumentIsProvided, defaultOptions, describeNameText, diagnosticBelongsToNode, diagnosticText, environmentOptions, fileViewText, formattedText, getDiagnosticMessageText, getTextSpanEnd, helpText, isDiagnosticWithLocation, nodeBelongsToArgumentList, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
|