tstyche 3.5.0 → 4.0.0-beta.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/README.md CHANGED
@@ -59,8 +59,7 @@ Here is the list of all matchers:
59
59
  - `.toBe()`, `.toBeAssignableTo()`, `.toBeAssignableWith()` compare types or types of expression,
60
60
  - `.toAcceptProps()` checks JSX component props type,
61
61
  - `.toHaveProperty()` looks up keys on an object type,
62
- - `.toRaiseError()` captures the type error message or code,
63
- - `.toBeString()`, `.toBeNumber()`, `.toBeVoid()` and 9 more shorthand checks for primitive types.
62
+ - `.toRaiseError()` captures the type error message or code.
64
63
 
65
64
  ## Runner
66
65
 
package/build/index.d.cts CHANGED
@@ -127,80 +127,11 @@ interface Matchers {
127
127
  * Checks if a property key exists on the source type.
128
128
  */
129
129
  toHaveProperty: (key: string | number | symbol) => void;
130
- /**
131
- * Checks if the source type matches the target type.
132
- *
133
- * @deprecated This matcher will be removed in TSTyche 4. To learn more, visit https://tstyche.org/release-notes/tstyche-3.
134
- */
135
- toMatch: {
136
- /**
137
- * Checks if the source type matches the target type.
138
- *
139
- * @deprecated This matcher will be removed in TSTyche 4. To learn more, visit https://tstyche.org/release-notes/tstyche-3.
140
- */
141
- <Target>(): void;
142
- /**
143
- * Checks if the source type matches type of the target expression.
144
- *
145
- * @deprecated This matcher will be removed in TSTyche 4. To learn more, visit https://tstyche.org/release-notes/tstyche-3.
146
- */
147
- (target: unknown): void;
148
- };
149
130
  /**
150
131
  * Checks if the source type raises an error.
151
132
  */
152
133
  toRaiseError: (...target: Array<string | number | RegExp>) => void;
153
134
  }
154
- interface Matchers {
155
- /**
156
- * Checks if the source type is `any`.
157
- */
158
- toBeAny: () => void;
159
- /**
160
- * Checks if the source type is `bigint`.
161
- */
162
- toBeBigInt: () => void;
163
- /**
164
- * Checks if the source type is `boolean`.
165
- */
166
- toBeBoolean: () => void;
167
- /**
168
- * Checks if the source type is `never`.
169
- */
170
- toBeNever: () => void;
171
- /**
172
- * Checks if the source type is `null`.
173
- */
174
- toBeNull: () => void;
175
- /**
176
- * Checks if the source type is `number`.
177
- */
178
- toBeNumber: () => void;
179
- /**
180
- * Checks if the source type is `string`.
181
- */
182
- toBeString: () => void;
183
- /**
184
- * Checks if the source type is `symbol`.
185
- */
186
- toBeSymbol: () => void;
187
- /**
188
- * Checks if the source type is `undefined`.
189
- */
190
- toBeUndefined: () => void;
191
- /**
192
- * Checks if the source type is `unique symbol`.
193
- */
194
- toBeUniqueSymbol: () => void;
195
- /**
196
- * Checks if the source type is `unknown`.
197
- */
198
- toBeUnknown: () => void;
199
- /**
200
- * Checks if the source type is `void`.
201
- */
202
- toBeVoid: () => void;
203
- }
204
135
  interface Modifier {
205
136
  /**
206
137
  * Passes the source type to the matcher.
package/build/index.d.ts CHANGED
@@ -127,80 +127,11 @@ interface Matchers {
127
127
  * Checks if a property key exists on the source type.
128
128
  */
129
129
  toHaveProperty: (key: string | number | symbol) => void;
130
- /**
131
- * Checks if the source type matches the target type.
132
- *
133
- * @deprecated This matcher will be removed in TSTyche 4. To learn more, visit https://tstyche.org/release-notes/tstyche-3.
134
- */
135
- toMatch: {
136
- /**
137
- * Checks if the source type matches the target type.
138
- *
139
- * @deprecated This matcher will be removed in TSTyche 4. To learn more, visit https://tstyche.org/release-notes/tstyche-3.
140
- */
141
- <Target>(): void;
142
- /**
143
- * Checks if the source type matches type of the target expression.
144
- *
145
- * @deprecated This matcher will be removed in TSTyche 4. To learn more, visit https://tstyche.org/release-notes/tstyche-3.
146
- */
147
- (target: unknown): void;
148
- };
149
130
  /**
150
131
  * Checks if the source type raises an error.
151
132
  */
152
133
  toRaiseError: (...target: Array<string | number | RegExp>) => void;
153
134
  }
154
- interface Matchers {
155
- /**
156
- * Checks if the source type is `any`.
157
- */
158
- toBeAny: () => void;
159
- /**
160
- * Checks if the source type is `bigint`.
161
- */
162
- toBeBigInt: () => void;
163
- /**
164
- * Checks if the source type is `boolean`.
165
- */
166
- toBeBoolean: () => void;
167
- /**
168
- * Checks if the source type is `never`.
169
- */
170
- toBeNever: () => void;
171
- /**
172
- * Checks if the source type is `null`.
173
- */
174
- toBeNull: () => void;
175
- /**
176
- * Checks if the source type is `number`.
177
- */
178
- toBeNumber: () => void;
179
- /**
180
- * Checks if the source type is `string`.
181
- */
182
- toBeString: () => void;
183
- /**
184
- * Checks if the source type is `symbol`.
185
- */
186
- toBeSymbol: () => void;
187
- /**
188
- * Checks if the source type is `undefined`.
189
- */
190
- toBeUndefined: () => void;
191
- /**
192
- * Checks if the source type is `unique symbol`.
193
- */
194
- toBeUniqueSymbol: () => void;
195
- /**
196
- * Checks if the source type is `unknown`.
197
- */
198
- toBeUnknown: () => void;
199
- /**
200
- * Checks if the source type is `void`.
201
- */
202
- toBeVoid: () => void;
203
- }
204
135
  interface Modifier {
205
136
  /**
206
137
  * Passes the source type to the matcher.
@@ -38,17 +38,16 @@ declare class SourceFile {
38
38
  }
39
39
 
40
40
  declare class DiagnosticOrigin {
41
- assertion: Assertion | undefined;
41
+ assertion: AssertionNode | undefined;
42
42
  end: number;
43
43
  sourceFile: SourceFile | ts.SourceFile;
44
44
  start: number;
45
- constructor(start: number, end: number, sourceFile: SourceFile | ts.SourceFile, assertion?: Assertion);
46
- static fromAssertion(assertion: Assertion): DiagnosticOrigin;
47
- static fromNode(node: ts.Node, assertion?: Assertion): DiagnosticOrigin;
45
+ constructor(start: number, end: number, sourceFile: SourceFile | ts.SourceFile, assertion?: AssertionNode);
46
+ static fromAssertion(assertion: AssertionNode): DiagnosticOrigin;
47
+ static fromNode(node: ts.Node, assertion?: AssertionNode): DiagnosticOrigin;
48
48
  }
49
49
 
50
50
  declare class Diagnostic {
51
- #private;
52
51
  category: DiagnosticCategory;
53
52
  code: string | undefined;
54
53
  origin: DiagnosticOrigin | undefined;
@@ -62,18 +61,19 @@ declare class Diagnostic {
62
61
  static error(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
63
62
  extendWith(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
64
63
  static fromDiagnostics(diagnostics: Array<ts.Diagnostic>): Array<Diagnostic>;
64
+ static toMessageText(chain: ts.DiagnosticMessageChain): Array<string>;
65
65
  static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
66
66
  }
67
67
 
68
68
  type DiagnosticsHandler<T extends Diagnostic | Array<Diagnostic> = Diagnostic> = (this: void, diagnostics: T) => void;
69
69
 
70
- declare enum TestMemberBrand {
70
+ declare enum TestTreeNodeBrand {
71
71
  Describe = "describe",
72
72
  Test = "test",
73
73
  Expect = "expect"
74
74
  }
75
75
 
76
- declare enum TestMemberFlags {
76
+ declare enum TestTreeNodeFlags {
77
77
  None = 0,
78
78
  Fail = 1,
79
79
  Only = 2,
@@ -81,31 +81,31 @@ declare enum TestMemberFlags {
81
81
  Todo = 8
82
82
  }
83
83
 
84
- declare class TestTree {
85
- diagnostics: Set<ts.Diagnostic>;
86
- members: Array<TestMember | Assertion>;
87
- sourceFile: ts.SourceFile;
88
- constructor(diagnostics: Set<ts.Diagnostic>, sourceFile: ts.SourceFile);
89
- get hasOnly(): boolean;
90
- }
91
-
92
- declare class TestMember {
84
+ declare class TestTreeNode {
93
85
  #private;
94
- brand: TestMemberBrand;
86
+ brand: TestTreeNodeBrand;
87
+ children: Array<TestTreeNode | AssertionNode>;
95
88
  diagnostics: Set<ts.Diagnostic>;
96
- flags: TestMemberFlags;
97
- members: Array<TestMember | Assertion>;
89
+ flags: TestTreeNodeFlags;
98
90
  name: string;
99
91
  node: ts.CallExpression;
100
- parent: TestTree | TestMember;
101
- constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags);
92
+ parent: TestTree | TestTreeNode;
93
+ constructor(compiler: typeof ts, brand: TestTreeNodeBrand, node: ts.CallExpression, parent: TestTree | TestTreeNode, flags: TestTreeNodeFlags);
102
94
  validate(): Array<Diagnostic>;
103
95
  }
104
96
 
97
+ declare class TestTree {
98
+ children: Array<TestTreeNode | AssertionNode>;
99
+ diagnostics: Set<ts.Diagnostic>;
100
+ hasOnly: boolean;
101
+ sourceFile: ts.SourceFile;
102
+ constructor(diagnostics: Set<ts.Diagnostic>, sourceFile: ts.SourceFile);
103
+ }
104
+
105
105
  interface MatcherNode extends ts.CallExpression {
106
106
  expression: ts.PropertyAccessExpression;
107
107
  }
108
- declare class Assertion extends TestMember {
108
+ declare class AssertionNode extends TestTreeNode {
109
109
  isNot: boolean;
110
110
  matcherName: ts.MemberName;
111
111
  matcherNode: MatcherNode;
@@ -113,7 +113,7 @@ declare class Assertion extends TestMember {
113
113
  notNode: ts.PropertyAccessExpression | undefined;
114
114
  source: ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
115
115
  target: ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
116
- constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags, matcherNode: MatcherNode, modifierNode: ts.PropertyAccessExpression, notNode?: ts.PropertyAccessExpression);
116
+ constructor(compiler: typeof ts, brand: TestTreeNodeBrand, node: ts.CallExpression, parent: TestTree | TestTreeNode, flags: TestTreeNodeFlags, matcherNode: MatcherNode, modifierNode: ts.PropertyAccessExpression, notNode?: ts.PropertyAccessExpression);
117
117
  }
118
118
 
119
119
  declare class CollectService {
@@ -207,13 +207,13 @@ interface CommandLineOptions {
207
207
  */
208
208
  failFast?: boolean;
209
209
  /**
210
- * Print the list of command line options with brief descriptions and exit.
210
+ * Fetch specified versions of the 'typescript' package and exit.
211
211
  */
212
- help?: boolean;
212
+ fetch?: boolean;
213
213
  /**
214
- * Install specified versions of the 'typescript' package and exit.
214
+ * Print the list of command line options with brief descriptions and exit.
215
215
  */
216
- install?: boolean;
216
+ help?: boolean;
217
217
  /**
218
218
  * Print the list of supported versions of the 'typescript' package and exit.
219
219
  */
@@ -406,12 +406,12 @@ declare enum ResultStatus {
406
406
  }
407
407
 
408
408
  declare class ExpectResult {
409
- assertion: Assertion;
409
+ assertion: AssertionNode;
410
410
  diagnostics: Array<Diagnostic>;
411
411
  parent: TestResult | undefined;
412
412
  status: ResultStatus;
413
413
  timing: ResultTiming;
414
- constructor(assertion: Assertion, parent?: TestResult);
414
+ constructor(assertion: AssertionNode, parent?: TestResult);
415
415
  }
416
416
 
417
417
  declare class ResultCount {
@@ -428,17 +428,17 @@ declare class TestResult {
428
428
  parent: DescribeResult | undefined;
429
429
  results: Array<ExpectResult>;
430
430
  status: ResultStatus;
431
- test: TestMember;
431
+ test: TestTreeNode;
432
432
  timing: ResultTiming;
433
- constructor(test: TestMember, parent?: DescribeResult);
433
+ constructor(test: TestTreeNode, parent?: DescribeResult);
434
434
  }
435
435
 
436
436
  declare class DescribeResult {
437
- describe: TestMember;
437
+ describe: TestTreeNode;
438
438
  parent: DescribeResult | undefined;
439
439
  results: Array<DescribeResult | TestResult>;
440
440
  timing: ResultTiming;
441
- constructor(describe: TestMember, parent?: DescribeResult);
441
+ constructor(describe: TestTreeNode, parent?: DescribeResult);
442
442
  }
443
443
 
444
444
  declare class Task {
@@ -497,8 +497,6 @@ type Event = ["config:error", {
497
497
  diagnostics: Array<Diagnostic>;
498
498
  }] | ["select:error", {
499
499
  diagnostics: Array<Diagnostic>;
500
- }] | ["deprecation:info", {
501
- diagnostics: Array<Diagnostic>;
502
500
  }] | ["run:start", {
503
501
  result: Result;
504
502
  }] | ["run:end", {
@@ -524,6 +522,12 @@ type Event = ["config:error", {
524
522
  result: TaskResult;
525
523
  }] | ["task:end", {
526
524
  result: TaskResult;
525
+ }] | ["collect:start", {
526
+ testTree: TestTree;
527
+ }] | ["collect:node", {
528
+ testNode: TestTreeNode | AssertionNode;
529
+ }] | ["collect:end", {
530
+ testTree: TestTree;
527
531
  }] | ["describe:start", {
528
532
  result: DescribeResult;
529
533
  }] | ["describe:end", {
@@ -581,7 +585,6 @@ interface TypeChecker extends ts.TypeChecker {
581
585
  relation: {
582
586
  assignable: Relation;
583
587
  identity: Relation;
584
- subtype: Relation;
585
588
  };
586
589
  }
587
590
 
@@ -589,25 +592,12 @@ declare class ExpectService {
589
592
  #private;
590
593
  private toAcceptProps;
591
594
  private toBe;
592
- private toBeAny;
593
595
  private toBeAssignableTo;
594
596
  private toBeAssignableWith;
595
- private toBeBigInt;
596
- private toBeBoolean;
597
- private toBeNever;
598
- private toBeNull;
599
- private toBeNumber;
600
- private toBeString;
601
- private toBeSymbol;
602
- private toBeUndefined;
603
- private toBeUniqueSymbol;
604
- private toBeUnknown;
605
- private toBeVoid;
606
597
  private toHaveProperty;
607
- private toMatch;
608
598
  private toRaiseError;
609
- constructor(compiler: typeof ts, typeChecker: TypeChecker, resolvedConfig?: ResolvedConfig);
610
- match(assertion: Assertion, onDiagnostics: DiagnosticsHandler<Diagnostic | Array<Diagnostic>>): MatchResult | undefined;
599
+ constructor(compiler: typeof ts, typeChecker: TypeChecker, resolvedConfig: ResolvedConfig);
600
+ match(assertion: AssertionNode, onDiagnostics: DiagnosticsHandler<Diagnostic | Array<Diagnostic>>): MatchResult | undefined;
611
601
  }
612
602
 
613
603
  declare class CancellationHandler implements EventHandler {
@@ -627,6 +617,11 @@ declare class ResultHandler implements EventHandler {
627
617
  on([event, payload]: Event): void;
628
618
  }
629
619
 
620
+ declare class TestTreeHandler implements EventHandler {
621
+ testTree: TestTree | undefined;
622
+ on([event, payload]: Event): void;
623
+ }
624
+
630
625
  type InputHandler = (chunk: string) => void;
631
626
  declare class InputService {
632
627
  #private;
@@ -652,9 +647,6 @@ declare namespace ScribblerJsx {
652
647
  props: Record<string, unknown>;
653
648
  type: FunctionComponent | number | string;
654
649
  }
655
- interface ElementChildrenAttribute {
656
- children: ScribblerNode;
657
- }
658
650
  interface IntrinsicElements {
659
651
  ansi: {
660
652
  escapes: Color | Array<Color>;
@@ -806,6 +798,7 @@ declare class SelectDiagnosticText {
806
798
  interface ManifestData {
807
799
  $version?: string;
808
800
  lastUpdated?: number;
801
+ minorVersions: Array<string>;
809
802
  npmRegistry: string;
810
803
  packages: Record<string, {
811
804
  integrity: string;
@@ -818,6 +811,7 @@ declare class Manifest {
818
811
  #private;
819
812
  $version: string;
820
813
  lastUpdated: number;
814
+ minorVersions: Array<string>;
821
815
  npmRegistry: string;
822
816
  packages: Record<string, {
823
817
  integrity: string;
@@ -837,9 +831,7 @@ declare class Manifest {
837
831
  declare class Store {
838
832
  #private;
839
833
  static manifest: Manifest | undefined;
840
- /** @deprecated Use 'Store.manifest' directly. */
841
- static getSupportedTags(): Promise<Array<string> | undefined>;
842
- static install(tag: string): Promise<void>;
834
+ static fetch(tag: string): Promise<void>;
843
835
  static load(tag: string): Promise<typeof ts | undefined>;
844
836
  static open(): Promise<void>;
845
837
  static prune(): Promise<void>;
@@ -851,8 +843,6 @@ declare class Version {
851
843
  #private;
852
844
  static isGreaterThan(source: string, target: string): boolean;
853
845
  static isSatisfiedWith(source: string, target: string): boolean;
854
- /** @deprecated Name of this method is misleading and it is also not needed. */
855
- static isVersionTag(target: string): boolean;
856
846
  }
857
847
 
858
848
  type WatchHandler = (filePath: string) => void;
@@ -877,4 +867,5 @@ declare class WatchService {
877
867
  watch(cancellationToken: CancellationToken): AsyncIterable<Array<Task>>;
878
868
  }
879
869
 
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 };
870
+ export { AssertionNode, BaseReporter, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, Config, ConfigDiagnosticText, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, EventEmitter, ExitCodeHandler, ExpectResult, ExpectService, FileWatcher, InputService, Line, ListReporter, OptionBrand, OptionGroup, Options, OutputService, Path, PluginService, ProjectResult, ProjectService, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, Runner, Scribbler, ScribblerJsx, Select, SelectDiagnosticText, SetupReporter, SourceFile, Store, SummaryReporter, TargetResult, Task, TaskResult, TestResult, TestTree, TestTreeHandler, TestTreeNode, TestTreeNodeBrand, TestTreeNodeFlags, Text, Version, WatchReporter, WatchService, Watcher, addsPackageText, defaultOptions, describeNameText, diagnosticText, environmentOptions, fileViewText, formattedText, helpText, summaryText, taskStatusText, testNameText, usesCompilerText, waitingForFileChangesText, watchUsageText };
871
+ export type { CodeFrameOptions, CommandLineOptions, ConfigFileOptions, DiagnosticsHandler, EnvironmentOptions, Event, EventHandler, FileWatchHandler, InputHandler, ItemDefinition, MatchResult, OptionDefinition, Plugin, Reporter, ReporterEvent, ResolvedConfig, ScribblerOptions, SelectHookContext, TargetResultStatus, TaskResultStatus, TypeChecker, WatchHandler, WatcherOptions };