tstyche 2.0.0-rc.2 → 2.1.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.
@@ -1,52 +1,17 @@
1
1
  import type ts from 'typescript';
2
2
 
3
- declare class DiagnosticOrigin {
4
- breadcrumbs: Array<string> | undefined;
5
- end: number;
6
- sourceFile: ts.SourceFile;
7
- start: number;
8
- constructor(start: number, end: number, sourceFile: ts.SourceFile, breadcrumbs?: Array<string>);
9
- static fromJsonNode(node: ts.Node, sourceFile: ts.SourceFile, skipTrivia: (position: number, sourceFile: ts.SourceFile) => number): DiagnosticOrigin;
10
- static fromNode(node: ts.Node, breadcrumbs?: Array<string>): DiagnosticOrigin;
11
- }
12
-
13
- declare enum DiagnosticCategory {
14
- Error = "error",
15
- Warning = "warning"
16
- }
17
-
18
- declare class Diagnostic {
19
- category: DiagnosticCategory;
20
- code: string | undefined;
21
- related: Array<Diagnostic> | undefined;
22
- origin: DiagnosticOrigin | undefined;
23
- text: string | Array<string>;
24
- constructor(text: string | Array<string>, category: DiagnosticCategory, origin?: DiagnosticOrigin);
25
- add(options: {
26
- code?: string;
27
- origin?: DiagnosticOrigin;
28
- related?: Array<Diagnostic>;
29
- }): this;
30
- static error(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
31
- static fromDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>, compiler: typeof ts): Array<Diagnostic>;
32
- static fromError(text: string | Array<string>, error: unknown): Diagnostic;
33
- static isTsDiagnosticWithLocation(diagnostic: ts.Diagnostic): diagnostic is ts.DiagnosticWithLocation;
34
- static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
35
- }
36
-
37
3
  declare enum CancellationReason {
38
4
  ConfigChange = "configChange",
39
5
  ConfigError = "configError",
40
- FailFast = "failFast"
6
+ FailFast = "failFast",
7
+ WatchClose = "watchClose"
41
8
  }
42
9
 
43
- type CancellationRequestedHandler = (reason: CancellationReason) => void;
44
10
  declare class CancellationToken {
45
11
  #private;
46
12
  get isCancellationRequested(): boolean;
47
13
  get reason(): CancellationReason | undefined;
48
14
  cancel(reason: CancellationReason): void;
49
- onCancellationRequested(handler: CancellationRequestedHandler): void;
50
15
  reset(): void;
51
16
  }
52
17
 
@@ -57,7 +22,6 @@ declare class StoreService {
57
22
  install(tag: string, cancellationToken?: CancellationToken): Promise<string | undefined>;
58
23
  load(tag: string, cancellationToken?: CancellationToken): Promise<typeof ts | undefined>;
59
24
  open(): Promise<void>;
60
- resolveTag(tag: string): Promise<string | undefined>;
61
25
  update(): Promise<void>;
62
26
  validateTag(tag: string): Promise<boolean | undefined>;
63
27
  }
@@ -98,6 +62,95 @@ declare class OptionDefinitionsMap {
98
62
  static for(optionGroup: OptionGroup): Map<string, OptionDefinition>;
99
63
  }
100
64
 
65
+ declare class TestTree {
66
+ diagnostics: Set<ts.Diagnostic>;
67
+ members: Array<TestMember | Assertion>;
68
+ sourceFile: ts.SourceFile;
69
+ constructor(diagnostics: Set<ts.Diagnostic>, sourceFile: ts.SourceFile);
70
+ get hasOnly(): boolean;
71
+ }
72
+
73
+ declare enum TestMemberBrand {
74
+ Describe = "describe",
75
+ Test = "test",
76
+ Expect = "expect"
77
+ }
78
+ declare enum TestMemberFlags {
79
+ None = 0,
80
+ Fail = 1,
81
+ Only = 2,
82
+ Skip = 4,
83
+ Todo = 8
84
+ }
85
+
86
+ declare class TestMember {
87
+ #private;
88
+ brand: TestMemberBrand;
89
+ diagnostics: Set<ts.Diagnostic>;
90
+ flags: TestMemberFlags;
91
+ members: Array<TestMember | Assertion>;
92
+ name: string;
93
+ node: ts.CallExpression;
94
+ parent: TestTree | TestMember;
95
+ constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags);
96
+ validate(): Array<Diagnostic>;
97
+ }
98
+
99
+ interface MatcherNode extends ts.CallExpression {
100
+ expression: ts.PropertyAccessExpression;
101
+ }
102
+ declare class Assertion extends TestMember {
103
+ isNot: boolean;
104
+ matcherNode: MatcherNode;
105
+ modifierNode: ts.PropertyAccessExpression;
106
+ notNode: ts.PropertyAccessExpression | undefined;
107
+ constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags, matcherNode: MatcherNode, modifierNode: ts.PropertyAccessExpression, notNode?: ts.PropertyAccessExpression);
108
+ get matcherName(): ts.MemberName;
109
+ get source(): ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
110
+ get target(): ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
111
+ }
112
+
113
+ declare class CollectService {
114
+ #private;
115
+ constructor(compiler: typeof ts);
116
+ createTestTree(sourceFile: ts.SourceFile, semanticDiagnostics?: Array<ts.Diagnostic>): TestTree;
117
+ }
118
+
119
+ declare class DiagnosticOrigin {
120
+ assertion: Assertion | undefined;
121
+ end: number;
122
+ sourceFile: ts.SourceFile;
123
+ start: number;
124
+ constructor(start: number, end: number, sourceFile: ts.SourceFile, assertion?: Assertion);
125
+ static fromAssertion(assertion: Assertion): DiagnosticOrigin;
126
+ static fromJsonNode(node: ts.Node, sourceFile: ts.SourceFile, skipTrivia: (position: number, sourceFile: ts.SourceFile) => number): DiagnosticOrigin;
127
+ static fromNode(node: ts.Node, assertion?: Assertion): DiagnosticOrigin;
128
+ }
129
+
130
+ declare enum DiagnosticCategory {
131
+ Error = "error",
132
+ Warning = "warning"
133
+ }
134
+
135
+ declare class Diagnostic {
136
+ #private;
137
+ category: DiagnosticCategory;
138
+ code: string | undefined;
139
+ origin: DiagnosticOrigin | undefined;
140
+ related: Array<Diagnostic> | undefined;
141
+ text: string | Array<string>;
142
+ constructor(text: string | Array<string>, category: DiagnosticCategory, origin?: DiagnosticOrigin);
143
+ add(options: {
144
+ code?: string | undefined;
145
+ related?: Array<Diagnostic> | undefined;
146
+ }): this;
147
+ static error(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
148
+ extendWith(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
149
+ static fromDiagnostics(diagnostics: Array<ts.Diagnostic>, compiler: typeof ts): Array<Diagnostic>;
150
+ static fromError(text: string | Array<string>, error: unknown): Diagnostic;
151
+ static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
152
+ }
153
+
101
154
  /**
102
155
  * Options passed through the command line.
103
156
  */
@@ -156,6 +209,19 @@ interface CommandLineOptions {
156
209
  watch?: boolean;
157
210
  }
158
211
 
212
+ declare class ConfigDiagnosticText {
213
+ #private;
214
+ static doubleQuotesExpected(): string;
215
+ static expectsListItemType(optionName: string, optionBrand: OptionBrand): string;
216
+ static expectsValue(optionName: string, optionGroup: OptionGroup): string;
217
+ static fileDoesNotExist(filePath: string): string;
218
+ static testFileMatchCannotStartWith(segment: string): Array<string>;
219
+ static requiresValueType(optionName: string, optionBrand: OptionBrand, optionGroup: OptionGroup): string;
220
+ static unknownOption(optionName: string): string;
221
+ static versionIsNotSupported(value: string): string;
222
+ static watchCannotBeEnabled(): string;
223
+ }
224
+
159
225
  /**
160
226
  * Options loaded from the configuration file.
161
227
  */
@@ -197,22 +263,6 @@ declare class ConfigService {
197
263
  resolveConfig(): ResolvedConfig;
198
264
  }
199
265
 
200
- declare class OptionDiagnosticText {
201
- #private;
202
- static doubleQuotesExpected(): string;
203
- static expectsListItemType(optionName: string, optionBrand: OptionBrand): string;
204
- static expectsValue(optionName: string, optionGroup: OptionGroup): string;
205
- static fileDoesNotExist(filePath: string): string;
206
- static noTestFilesWereLeft(resolvedConfig: ResolvedConfig): Array<string>;
207
- static noTestFilesWereSelected(resolvedConfig: ResolvedConfig): Array<string>;
208
- static testFileMatchCannotStartWith(segment: string): Array<string>;
209
- static requiresValueType(optionName: string, optionBrand: OptionBrand, optionGroup: OptionGroup): string;
210
- static unknownOption(optionName: string): string;
211
- static versionIsNotSupported(value: string): string;
212
- static watchCannotBeEnabledInCiEnvironment(): string;
213
- static watchIsNotAvailable(): string;
214
- }
215
-
216
266
  declare enum Color {
217
267
  Reset = "0",
218
268
  Red = "31",
@@ -283,61 +333,6 @@ declare class TestFile {
283
333
  constructor(identifier: string | URL, position?: number);
284
334
  }
285
335
 
286
- declare class TestTree {
287
- diagnostics: Set<ts.Diagnostic>;
288
- members: Array<TestMember | Assertion>;
289
- sourceFile: ts.SourceFile;
290
- constructor(diagnostics: Set<ts.Diagnostic>, sourceFile: ts.SourceFile);
291
- get hasOnly(): boolean;
292
- }
293
-
294
- declare enum TestMemberBrand {
295
- Describe = "describe",
296
- Test = "test",
297
- Expect = "expect"
298
- }
299
- declare enum TestMemberFlags {
300
- None = 0,
301
- Fail = 1,
302
- Only = 2,
303
- Skip = 4,
304
- Todo = 8
305
- }
306
-
307
- declare class TestMember {
308
- brand: TestMemberBrand;
309
- diagnostics: Set<ts.Diagnostic>;
310
- flags: TestMemberFlags;
311
- members: Array<TestMember | Assertion>;
312
- name: string;
313
- node: ts.CallExpression;
314
- parent: TestTree | TestMember;
315
- constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags);
316
- get ancestorNames(): Array<string>;
317
- validate(): Array<Diagnostic>;
318
- }
319
-
320
- interface MatcherNode extends ts.CallExpression {
321
- expression: ts.PropertyAccessExpression;
322
- }
323
- declare class Assertion extends TestMember {
324
- isNot: boolean;
325
- matcherNode: MatcherNode;
326
- modifierNode: ts.PropertyAccessExpression;
327
- notNode: ts.PropertyAccessExpression | undefined;
328
- constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags, matcherNode: MatcherNode, modifierNode: ts.PropertyAccessExpression, notNode?: ts.PropertyAccessExpression);
329
- get ancestorNames(): Array<string>;
330
- get matcherName(): ts.MemberName;
331
- get source(): ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
332
- get target(): ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
333
- }
334
-
335
- declare class CollectService {
336
- #private;
337
- constructor(compiler: typeof ts);
338
- createTestTree(sourceFile: ts.SourceFile, semanticDiagnostics?: Array<ts.Diagnostic>): TestTree;
339
- }
340
-
341
336
  declare class ResultTiming {
342
337
  end: number;
343
338
  start: number;
@@ -430,85 +425,6 @@ declare class Result {
430
425
  constructor(resolvedConfig: ResolvedConfig, testFiles: Array<TestFile>);
431
426
  }
432
427
 
433
- type Event = ["config:error", {
434
- diagnostics: Array<Diagnostic>;
435
- }] | ["deprecation:info", {
436
- diagnostics: Array<Diagnostic>;
437
- }] | ["select:error", {
438
- diagnostics: Array<Diagnostic>;
439
- }] | ["run:start", {
440
- result: Result;
441
- }] | ["run:end", {
442
- result: Result;
443
- }] | ["store:info", {
444
- compilerVersion: string;
445
- installationPath: string;
446
- }] | ["store:error", {
447
- diagnostics: Array<Diagnostic>;
448
- }] | ["target:start", {
449
- result: TargetResult;
450
- }] | ["target:end", {
451
- result: TargetResult;
452
- }] | ["project:info", {
453
- compilerVersion: string;
454
- projectConfigFilePath: string | undefined;
455
- }] | ["project:error", {
456
- diagnostics: Array<Diagnostic>;
457
- }] | ["file:start", {
458
- result: FileResult;
459
- }] | ["file:error", {
460
- diagnostics: Array<Diagnostic>;
461
- result: FileResult;
462
- }] | ["file:end", {
463
- result: FileResult;
464
- }] | ["describe:start", {
465
- result: DescribeResult;
466
- }] | ["describe:end", {
467
- result: DescribeResult;
468
- }] | ["test:start", {
469
- result: TestResult;
470
- }] | ["test:error", {
471
- diagnostics: Array<Diagnostic>;
472
- result: TestResult;
473
- }] | ["test:fail", {
474
- result: TestResult;
475
- }] | ["test:pass", {
476
- result: TestResult;
477
- }] | ["test:skip", {
478
- result: TestResult;
479
- }] | ["test:todo", {
480
- result: TestResult;
481
- }] | ["expect:start", {
482
- result: ExpectResult;
483
- }] | ["expect:error", {
484
- diagnostics: Array<Diagnostic>;
485
- result: ExpectResult;
486
- }] | ["expect:fail", {
487
- diagnostics: Array<Diagnostic>;
488
- result: ExpectResult;
489
- }] | ["expect:pass", {
490
- result: ExpectResult;
491
- }] | ["expect:skip", {
492
- result: ExpectResult;
493
- }] | ["watch:error", {
494
- diagnostics: Array<Diagnostic>;
495
- }];
496
- interface EventHandler {
497
- handleEvent: (event: Event) => void;
498
- }
499
- declare class EventEmitter {
500
- #private;
501
- addHandler(handler: EventHandler): void;
502
- static dispatch(event: Event): void;
503
- removeHandler(handler: EventHandler): void;
504
- removeHandlers(): void;
505
- }
506
-
507
- declare class ResultHandler {
508
- #private;
509
- handleEvent([eventName, payload]: Event): void;
510
- }
511
-
512
428
  declare function fileStatusText(status: FileResultStatus, testFile: TestFile): ScribblerJsx.Element;
513
429
 
514
430
  declare function fileViewText(lines: Array<ScribblerJsx.Element>, addEmptyFinalLine: boolean): ScribblerJsx.Element;
@@ -518,7 +434,7 @@ declare function formattedText(input: string | Array<string> | Record<string, un
518
434
  declare function helpText(optionDefinitions: Map<string, OptionDefinition>, tstycheVersion: string): ScribblerJsx.Element;
519
435
 
520
436
  interface WriteStream {
521
- write: (log: string) => void;
437
+ write: (chunk: string) => void;
522
438
  }
523
439
  interface OutputServiceOptions {
524
440
  noColor?: boolean;
@@ -530,9 +446,9 @@ declare class OutputService {
530
446
  constructor(options?: OutputServiceOptions);
531
447
  clearTerminal(): void;
532
448
  eraseLastLine(): void;
533
- writeError(body: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
534
- writeMessage(body: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
535
- writeWarning(body: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
449
+ writeError(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
450
+ writeMessage(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
451
+ writeWarning(element: ScribblerJsx.Element | Array<ScribblerJsx.Element>): void;
536
452
  }
537
453
 
538
454
  declare function summaryText({ duration, expectCount, fileCount, onlyMatch, pathMatch, skipMatch, targetCount, testCount, }: {
@@ -556,6 +472,12 @@ declare function waitingForFileChangesText(): ScribblerJsx.Element;
556
472
 
557
473
  declare function watchUsageText(): ScribblerJsx.Element;
558
474
 
475
+ declare class SelectDiagnosticText {
476
+ #private;
477
+ static noTestFilesWereLeft(resolvedConfig: ResolvedConfig): Array<string>;
478
+ static noTestFilesWereSelected(resolvedConfig: ResolvedConfig): Array<string>;
479
+ }
480
+
559
481
  declare class SelectService {
560
482
  #private;
561
483
  constructor(resolvedConfig: ResolvedConfig);
@@ -604,6 +526,83 @@ declare class Environment {
604
526
  static get typescriptPath(): string | undefined;
605
527
  }
606
528
 
529
+ type Event = ["config:error", {
530
+ diagnostics: Array<Diagnostic>;
531
+ }] | ["deprecation:info", {
532
+ diagnostics: Array<Diagnostic>;
533
+ }] | ["select:error", {
534
+ diagnostics: Array<Diagnostic>;
535
+ }] | ["run:start", {
536
+ result: Result;
537
+ }] | ["run:end", {
538
+ result: Result;
539
+ }] | ["store:info", {
540
+ compilerVersion: string;
541
+ installationPath: string;
542
+ }] | ["store:error", {
543
+ diagnostics: Array<Diagnostic>;
544
+ }] | ["target:start", {
545
+ result: TargetResult;
546
+ }] | ["target:end", {
547
+ result: TargetResult;
548
+ }] | ["project:info", {
549
+ compilerVersion: string;
550
+ projectConfigFilePath: string | undefined;
551
+ }] | ["project:error", {
552
+ diagnostics: Array<Diagnostic>;
553
+ }] | ["file:start", {
554
+ result: FileResult;
555
+ }] | ["file:error", {
556
+ diagnostics: Array<Diagnostic>;
557
+ result: FileResult;
558
+ }] | ["file:end", {
559
+ result: FileResult;
560
+ }] | ["describe:start", {
561
+ result: DescribeResult;
562
+ }] | ["describe:end", {
563
+ result: DescribeResult;
564
+ }] | ["test:start", {
565
+ result: TestResult;
566
+ }] | ["test:error", {
567
+ diagnostics: Array<Diagnostic>;
568
+ result: TestResult;
569
+ }] | ["test:fail", {
570
+ result: TestResult;
571
+ }] | ["test:pass", {
572
+ result: TestResult;
573
+ }] | ["test:skip", {
574
+ result: TestResult;
575
+ }] | ["test:todo", {
576
+ result: TestResult;
577
+ }] | ["expect:start", {
578
+ result: ExpectResult;
579
+ }] | ["expect:error", {
580
+ diagnostics: Array<Diagnostic>;
581
+ result: ExpectResult;
582
+ }] | ["expect:fail", {
583
+ diagnostics: Array<Diagnostic>;
584
+ result: ExpectResult;
585
+ }] | ["expect:pass", {
586
+ result: ExpectResult;
587
+ }] | ["expect:skip", {
588
+ result: ExpectResult;
589
+ }] | ["watch:error", {
590
+ diagnostics: Array<Diagnostic>;
591
+ }];
592
+
593
+ interface EventHandler {
594
+ handleEvent: (event: Event) => void;
595
+ }
596
+ declare class EventEmitter {
597
+ #private;
598
+ addHandler(handler: EventHandler): void;
599
+ static dispatch(event: Event): void;
600
+ removeHandler(handler: EventHandler): void;
601
+ removeHandlers(): void;
602
+ }
603
+
604
+ type ArgumentNode = ts.Expression | ts.TypeNode;
605
+ type DiagnosticsHandler = (diagnostics: Diagnostic | Array<Diagnostic>) => void;
607
606
  interface MatchResult {
608
607
  explain: () => Array<Diagnostic>;
609
608
  isMatch: boolean;
@@ -618,66 +617,116 @@ interface TypeChecker extends ts.TypeChecker {
618
617
  };
619
618
  }
620
619
 
620
+ declare class MatchWorker {
621
+ #private;
622
+ assertion: Assertion;
623
+ constructor(compiler: typeof ts, typeChecker: TypeChecker, assertion: Assertion);
624
+ checkIsAssignableTo(sourceNode: ArgumentNode, targetNode: ArgumentNode): boolean;
625
+ checkIsAssignableWith(sourceNode: ArgumentNode, targetNode: ArgumentNode): boolean;
626
+ checkIsIdenticalTo(sourceNode: ArgumentNode, targetNode: ArgumentNode): boolean;
627
+ checkIsSubtype(sourceNode: ArgumentNode, targetNode: ArgumentNode): boolean;
628
+ extendsObjectType(type: ts.Type): boolean;
629
+ getParameterType(signature: ts.Signature, index: number): ts.Type | undefined;
630
+ getSignatures(node: ArgumentNode): Array<ts.Signature>;
631
+ getTypeText(node: ArgumentNode): string;
632
+ getType(node: ArgumentNode): ts.Type;
633
+ isAnyOrNeverType(type: ts.Type): type is ts.StringLiteralType | ts.NumberLiteralType;
634
+ isStringOrNumberLiteralType(type: ts.Type): type is ts.StringLiteralType | ts.NumberLiteralType;
635
+ isObjectType(type: ts.Type): type is ts.ObjectType;
636
+ isUnionType(type: ts.Type): type is ts.UnionType;
637
+ isUniqueSymbolType(type: ts.Type): type is ts.UniqueESSymbolType;
638
+ resolveDiagnosticOrigin(symbol: ts.Symbol, enclosingNode: ts.Node): DiagnosticOrigin;
639
+ }
640
+
621
641
  declare class PrimitiveTypeMatcher {
622
642
  #private;
623
- typeChecker: TypeChecker;
624
- constructor(typeChecker: TypeChecker, targetTypeFlag: ts.TypeFlags);
625
- match(sourceType: ts.Type): MatchResult;
643
+ constructor(targetTypeFlag: ts.TypeFlags);
644
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode): MatchResult;
645
+ }
646
+
647
+ declare class ToAcceptProps {
648
+ #private;
649
+ constructor(compiler: typeof ts, typeChecker: TypeChecker);
650
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode, onDiagnostics: DiagnosticsHandler): MatchResult | undefined;
651
+ }
652
+
653
+ declare class ExpectDiagnosticText {
654
+ static argumentOrTypeArgumentMustBeProvided(argumentNameText: string, typeArgumentNameText: string): string;
655
+ static argumentMustBe(argumentNameText: string, expectedText: string): string;
656
+ static argumentMustBeProvided(argumentNameText: string): string;
657
+ static componentAcceptsProps(isTypeNode: boolean): string;
658
+ static componentDoesNotAcceptProps(isTypeNode: boolean): string;
659
+ static matcherIsDeprecated(matcherNameText: string): Array<string>;
660
+ static matcherIsNotSupported(matcherNameText: string): string;
661
+ static overloadGaveTheFollowingError(indexText: string, countText: string, signatureText: string): string;
662
+ static raisedTypeError(count?: number): string;
663
+ static typeArgumentMustBe(argumentNameText: string, expectedText: string): string;
664
+ static typeDidNotRaiseError(isTypeNode: boolean): string;
665
+ static typeDidNotRaiseMatchingError(isTypeNode: boolean): string;
666
+ static typeDoesNotHaveProperty(typeText: string, propertyNameText: string): string;
667
+ static typeDoesMatch(sourceTypeText: string, targetTypeText: string): string;
668
+ static typeDoesNotMatch(sourceTypeText: string, targetTypeText: string): string;
669
+ static typeHasProperty(typeText: string, propertyNameText: string): string;
670
+ static typeIs(typeText: string): string;
671
+ static typeIsAssignableTo(sourceTypeText: string, targetTypeText: string): string;
672
+ static typeIsAssignableWith(sourceTypeText: string, targetTypeText: string): string;
673
+ static typeIsIdenticalTo(sourceTypeText: string, targetTypeText: string): string;
674
+ static typeIsNotAssignableTo(sourceTypeText: string, targetTypeText: string): string;
675
+ static typeIsNotAssignableWith(sourceTypeText: string, targetTypeText: string): string;
676
+ static typeIsNotCompatibleWith(sourceTypeText: string, targetTypeText: string): string;
677
+ static typeIsNotIdenticalTo(sourceTypeText: string, targetTypeText: string): string;
678
+ static typeRaisedError(isTypeNode: boolean, count: number, targetCount: number): string;
679
+ static typeRaisedMatchingError(isTypeNode: boolean): string;
680
+ static typeRequiresProperty(typeText: string, propertyNameText: string): string;
681
+ static typesOfPropertyAreNotCompatible(propertyNameText: string): string;
626
682
  }
627
683
 
628
684
  declare abstract class RelationMatcherBase {
629
- abstract relation: Relation;
630
- abstract relationExplanationText: string;
631
- relationExplanationVerb: string;
632
- typeChecker: TypeChecker;
633
- constructor(typeChecker: TypeChecker);
634
- protected explain(sourceType: ts.Type, targetType: ts.Type, isNot: boolean): Array<Diagnostic>;
635
- match(sourceType: ts.Type, targetType: ts.Type, isNot: boolean): MatchResult;
685
+ abstract explainText(sourceTypeText: string, targetTypeText: string): string;
686
+ abstract explainNotText(sourceTypeText: string, targetTypeText: string): string;
687
+ protected explain(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode): Diagnostic[];
688
+ abstract match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode): MatchResult;
636
689
  }
637
690
 
638
691
  declare class ToBe extends RelationMatcherBase {
639
- relation: Relation;
640
- relationExplanationText: string;
692
+ explainText: typeof ExpectDiagnosticText.typeIsIdenticalTo;
693
+ explainNotText: typeof ExpectDiagnosticText.typeIsNotIdenticalTo;
694
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode): MatchResult;
641
695
  }
642
696
 
643
697
  declare class ToBeAssignableTo extends RelationMatcherBase {
644
- relation: Relation;
645
- relationExplanationText: string;
698
+ explainText: typeof ExpectDiagnosticText.typeIsAssignableTo;
699
+ explainNotText: typeof ExpectDiagnosticText.typeIsNotAssignableTo;
700
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode): MatchResult;
646
701
  }
647
702
 
648
703
  declare class ToBeAssignableWith extends RelationMatcherBase {
649
- relation: Relation;
650
- relationExplanationText: string;
651
- match(sourceType: ts.Type, targetType: ts.Type, isNot: boolean): MatchResult;
704
+ explainText: typeof ExpectDiagnosticText.typeIsAssignableWith;
705
+ explainNotText: typeof ExpectDiagnosticText.typeIsNotAssignableWith;
706
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode): MatchResult;
652
707
  }
653
708
 
654
709
  declare class ToHaveProperty {
655
710
  #private;
656
- compiler: typeof ts;
657
- typeChecker: TypeChecker;
658
- constructor(compiler: typeof ts, typeChecker: TypeChecker);
659
- match(sourceType: ts.Type, targetType: ts.StringLiteralType | ts.NumberLiteralType | ts.UniqueESSymbolType, isNot: boolean): MatchResult;
711
+ constructor(compiler: typeof ts);
712
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode, onDiagnostics: DiagnosticsHandler): MatchResult | undefined;
660
713
  }
661
714
 
662
715
  declare class ToMatch extends RelationMatcherBase {
663
- relation: Relation;
664
- relationExplanationText: string;
665
- relationExplanationVerb: string;
716
+ explainText: typeof ExpectDiagnosticText.typeDoesMatch;
717
+ explainNotText: typeof ExpectDiagnosticText.typeDoesNotMatch;
718
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNode: ArgumentNode): MatchResult;
666
719
  }
667
720
 
668
721
  declare class ToRaiseError {
669
722
  #private;
670
- compiler: typeof ts;
671
- typeChecker: TypeChecker;
672
- constructor(compiler: typeof ts, typeChecker: TypeChecker);
673
- match(source: {
674
- diagnostics: Array<ts.Diagnostic>;
675
- node: ts.Expression | ts.TypeNode;
676
- }, targetTypes: Array<ts.StringLiteralType | ts.NumberLiteralType>, isNot: boolean): MatchResult;
723
+ constructor(compiler: typeof ts);
724
+ match(matchWorker: MatchWorker, sourceNode: ArgumentNode, targetNodes: Array<ArgumentNode>, onDiagnostics: DiagnosticsHandler): MatchResult | undefined;
677
725
  }
678
726
 
679
- declare class Expect {
727
+ declare class ExpectService {
680
728
  #private;
729
+ toAcceptProps: ToAcceptProps;
681
730
  toBe: ToBe;
682
731
  toBeAny: PrimitiveTypeMatcher;
683
732
  toBeAssignable: ToBeAssignableWith;
@@ -700,7 +749,7 @@ declare class Expect {
700
749
  toRaiseError: ToRaiseError;
701
750
  constructor(compiler: typeof ts, typeChecker: TypeChecker);
702
751
  static assertTypeChecker(typeChecker: ts.TypeChecker): typeChecker is TypeChecker;
703
- match(assertion: Assertion, expectResult: ExpectResult): MatchResult | undefined;
752
+ match(assertion: Assertion, onDiagnostics: DiagnosticsHandler): MatchResult | undefined;
704
753
  }
705
754
 
706
755
  declare class CancellationHandler implements EventHandler {
@@ -715,34 +764,40 @@ declare class ExitCodeHandler implements EventHandler {
715
764
  resetCode(): void;
716
765
  }
717
766
 
718
- declare class RuntimeReporter implements EventHandler {
767
+ declare class ResultHandler implements EventHandler {
719
768
  #private;
720
- constructor(resolvedConfig: ResolvedConfig, outputService: OutputService);
721
769
  handleEvent([eventName, payload]: Event): void;
722
770
  }
723
771
 
724
- declare class SetupReporter implements EventHandler {
725
- #private;
772
+ declare abstract class Reporter implements EventHandler {
773
+ protected outputService: OutputService;
726
774
  constructor(outputService: OutputService);
727
- handleEvent([eventName, payload]: Event): void;
775
+ abstract handleEvent([eventName, payload]: Event): void;
728
776
  }
729
777
 
730
- declare class SummaryReporter implements EventHandler {
778
+ declare class RunReporter extends Reporter implements EventHandler {
731
779
  #private;
732
- constructor(outputService: OutputService);
780
+ constructor(resolvedConfig: ResolvedConfig, outputService: OutputService);
733
781
  handleEvent([eventName, payload]: Event): void;
734
782
  }
735
783
 
736
- declare class WatchReporter implements EventHandler {
737
- #private;
738
- constructor(outputService: OutputService);
784
+ declare class SetupReporter extends Reporter implements EventHandler {
739
785
  handleEvent([eventName, payload]: Event): void;
740
786
  }
741
787
 
742
- type InputHandler = (chunk: Buffer) => void;
788
+ declare class SummaryReporter extends Reporter implements EventHandler {
789
+ handleEvent([eventName, payload]: Event): void;
790
+ }
791
+
792
+ declare class WatchReporter extends Reporter implements EventHandler {
793
+ handleEvent([eventName, payload]: Event): void;
794
+ }
795
+
796
+ type InputHandler = (chunk: string) => void;
743
797
  interface ReadStream {
744
798
  addListener: (event: "data", handler: InputHandler) => this;
745
799
  removeListener: (event: "data", handler: InputHandler) => this;
800
+ setEncoding: (encoding: "utf8") => this;
746
801
  setRawMode?: (mode: boolean) => this;
747
802
  unref: () => this;
748
803
  }
@@ -786,7 +841,7 @@ declare class Version {
786
841
  static isVersionTag(target: string): boolean;
787
842
  }
788
843
 
789
- type WatchHandler = (filePath: string) => void | Promise<void>;
844
+ type WatchHandler = (filePath: string) => void;
790
845
  interface WatcherOptions {
791
846
  recursive?: boolean;
792
847
  }
@@ -794,20 +849,18 @@ declare class Watcher {
794
849
  #private;
795
850
  constructor(targetPath: string, onChanged: WatchHandler, onRemoved?: WatchHandler, options?: WatcherOptions);
796
851
  close(): void;
797
- watch(): Promise<void>;
852
+ watch(): void;
798
853
  }
799
854
 
800
- type FileWatchHandler = () => void | Promise<void>;
855
+ type FileWatchHandler = () => void;
801
856
  declare class FileWatcher extends Watcher {
802
857
  constructor(targetPath: string, onChanged: FileWatchHandler);
803
858
  }
804
859
 
805
- type RunCallback = (testFiles: Array<TestFile>) => Promise<void>;
806
860
  declare class WatchService {
807
861
  #private;
808
- constructor(resolvedConfig: ResolvedConfig, runCallback: RunCallback, selectService: SelectService, testFiles: Array<TestFile>);
809
- close(): void;
810
- watch(cancellationToken?: CancellationToken): Promise<Array<void>>;
862
+ constructor(resolvedConfig: ResolvedConfig, selectService: SelectService, testFiles: Array<TestFile>);
863
+ watch(cancellationToken: CancellationToken): AsyncIterable<Array<TestFile>>;
811
864
  }
812
865
 
813
- export { Assertion, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, type ConfigFileOptions, ConfigService, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Environment, type Event, EventEmitter, type EventHandler, ExitCodeHandler, Expect, ExpectResult, FileResult, type FileResultStatus, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type InputServiceOptions, type ItemDefinition, Line, type MatchResult, OptionBrand, type OptionDefinition, OptionDefinitionsMap, OptionDiagnosticText, OptionGroup, OutputService, type OutputServiceOptions, Path, ProjectResult, ProjectService, type ReadStream, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, type RunCallback, RuntimeReporter, Scribbler, ScribblerJsx, type ScribblerOptions, SelectService, SetupReporter, StoreService, SummaryReporter, TSTyche, TargetResult, type TargetResultStatus, TaskRunner, TestFile, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, type WriteStream, addsPackageStepText, defaultOptions, describeNameText, diagnosticText, fileStatusText, fileViewText, formattedText, helpText, summaryText, testNameText, usesCompilerStepText, waitingForFileChangesText, watchUsageText };
866
+ export { Assertion, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, ConfigDiagnosticText, type ConfigFileOptions, ConfigService, DescribeResult, Diagnostic, DiagnosticCategory, DiagnosticOrigin, Environment, type Event, EventEmitter, type EventHandler, ExitCodeHandler, ExpectResult, ExpectService, FileResult, type FileResultStatus, type FileWatchHandler, FileWatcher, type InputHandler, InputService, type InputServiceOptions, type ItemDefinition, Line, type MatchResult, OptionBrand, type OptionDefinition, OptionDefinitionsMap, OptionGroup, OutputService, type OutputServiceOptions, Path, ProjectResult, ProjectService, type ReadStream, type ResolvedConfig, Result, ResultCount, ResultHandler, ResultStatus, ResultTiming, RunReporter, Scribbler, ScribblerJsx, type ScribblerOptions, SelectDiagnosticText, SelectService, SetupReporter, StoreService, SummaryReporter, TSTyche, TargetResult, type TargetResultStatus, TaskRunner, TestFile, TestMember, TestMemberBrand, TestMemberFlags, TestResult, TestTree, Text, type TypeChecker, Version, type WatchHandler, WatchReporter, WatchService, Watcher, type WatcherOptions, type WriteStream, addsPackageStepText, defaultOptions, describeNameText, diagnosticText, fileStatusText, fileViewText, formattedText, helpText, summaryText, testNameText, usesCompilerStepText, waitingForFileChangesText, watchUsageText };