tstyche 2.0.0-beta.1 → 2.0.0-rc.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,23 +1,27 @@
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
+
3
13
  declare enum DiagnosticCategory {
4
14
  Error = "error",
5
15
  Warning = "warning"
6
16
  }
7
17
 
8
- interface DiagnosticOrigin {
9
- breadcrumbs?: Array<string>;
10
- end: number;
11
- file: ts.SourceFile;
12
- start: number;
13
- }
14
18
  declare class Diagnostic {
15
- text: string | Array<string>;
16
19
  category: DiagnosticCategory;
17
- origin?: DiagnosticOrigin | undefined;
18
- code?: string;
19
- related?: Array<Diagnostic>;
20
- constructor(text: string | Array<string>, category: DiagnosticCategory, origin?: DiagnosticOrigin | undefined);
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);
21
25
  add(options: {
22
26
  code?: string;
23
27
  origin?: DiagnosticOrigin;
@@ -187,7 +191,6 @@ interface ResolvedConfig extends Omit<CommandLineOptions, keyof ConfigFileOption
187
191
  declare const defaultOptions: Required<ConfigFileOptions>;
188
192
  declare class ConfigService {
189
193
  #private;
190
- compiler: typeof ts;
191
194
  constructor(compiler: typeof ts, storeService: StoreService);
192
195
  parseCommandLine(commandLineArgs: Array<string>): Promise<void>;
193
196
  readConfigFile(): Promise<void>;
@@ -202,6 +205,7 @@ declare class OptionDiagnosticText {
202
205
  static fileDoesNotExist(filePath: string): string;
203
206
  static noTestFilesWereLeft(resolvedConfig: ResolvedConfig): Array<string>;
204
207
  static noTestFilesWereSelected(resolvedConfig: ResolvedConfig): Array<string>;
208
+ static testFileMatchCannotStartWith(segment: string): Array<string>;
205
209
  static requiresValueType(optionName: string, optionBrand: OptionBrand, optionGroup: OptionGroup): string;
206
210
  static unknownOption(optionName: string): string;
207
211
  static versionIsNotSupported(value: string): string;
@@ -256,7 +260,7 @@ interface LineProps {
256
260
  indent?: number;
257
261
  }
258
262
  declare class Line implements ScribblerJsx.ElementClass {
259
- readonly props: LineProps;
263
+ props: LineProps;
260
264
  constructor(props: LineProps);
261
265
  render(): ScribblerJsx.Element;
262
266
  }
@@ -277,7 +281,7 @@ interface TextProps {
277
281
  indent?: number | undefined;
278
282
  }
279
283
  declare class Text implements ScribblerJsx.ElementClass {
280
- readonly props: TextProps;
284
+ props: TextProps;
281
285
  constructor(props: TextProps);
282
286
  render(): ScribblerJsx.Element;
283
287
  }
@@ -291,19 +295,15 @@ declare function diagnosticText(diagnostic: Diagnostic): ScribblerJsx.Element;
291
295
  declare class TestFile {
292
296
  #private;
293
297
  path: string;
294
- position?: number;
295
- constructor(identifier: string | URL);
296
- add(options: {
297
- position?: number;
298
- }): this;
298
+ position: number | undefined;
299
+ constructor(identifier: string | URL, position?: number);
299
300
  }
300
301
 
301
302
  declare class TestTree {
302
- compiler: typeof ts;
303
303
  diagnostics: Set<ts.Diagnostic>;
304
- sourceFile: ts.SourceFile;
305
304
  members: Array<TestMember | Assertion>;
306
- constructor(compiler: typeof ts, diagnostics: Set<ts.Diagnostic>, sourceFile: ts.SourceFile);
305
+ sourceFile: ts.SourceFile;
306
+ constructor(diagnostics: Set<ts.Diagnostic>, sourceFile: ts.SourceFile);
307
307
  get hasOnly(): boolean;
308
308
  }
309
309
 
@@ -322,14 +322,13 @@ declare enum TestMemberFlags {
322
322
 
323
323
  declare class TestMember {
324
324
  brand: TestMemberBrand;
325
- node: ts.CallExpression;
326
- parent: TestTree | TestMember;
327
- flags: TestMemberFlags;
328
- compiler: typeof ts;
329
325
  diagnostics: Set<ts.Diagnostic>;
326
+ flags: TestMemberFlags;
330
327
  members: Array<TestMember | Assertion>;
331
328
  name: string;
332
- constructor(brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags);
329
+ node: ts.CallExpression;
330
+ parent: TestTree | TestMember;
331
+ constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags);
333
332
  get ancestorNames(): Array<string>;
334
333
  validate(): Array<Diagnostic>;
335
334
  }
@@ -338,11 +337,11 @@ interface MatcherNode extends ts.CallExpression {
338
337
  expression: ts.PropertyAccessExpression;
339
338
  }
340
339
  declare class Assertion extends TestMember {
340
+ isNot: boolean;
341
341
  matcherNode: MatcherNode;
342
342
  modifierNode: ts.PropertyAccessExpression;
343
343
  notNode: ts.PropertyAccessExpression | undefined;
344
- isNot: boolean;
345
- constructor(brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags, matcherNode: MatcherNode, modifierNode: ts.PropertyAccessExpression, notNode: ts.PropertyAccessExpression | undefined);
344
+ constructor(compiler: typeof ts, brand: TestMemberBrand, node: ts.CallExpression, parent: TestTree | TestMember, flags: TestMemberFlags, matcherNode: MatcherNode, modifierNode: ts.PropertyAccessExpression, notNode?: ts.PropertyAccessExpression);
346
345
  get ancestorNames(): Array<string>;
347
346
  get matcherName(): ts.MemberName;
348
347
  get source(): ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
@@ -351,10 +350,6 @@ declare class Assertion extends TestMember {
351
350
 
352
351
  declare class CollectService {
353
352
  #private;
354
- compiler: typeof ts;
355
- readonly matcherIdentifiers: string[];
356
- readonly modifierIdentifiers: string[];
357
- readonly notIdentifier = "not";
358
353
  constructor(compiler: typeof ts);
359
354
  createTestTree(sourceFile: ts.SourceFile, semanticDiagnostics?: Array<ts.Diagnostic>): TestTree;
360
355
  }
@@ -375,11 +370,11 @@ declare enum ResultStatus {
375
370
 
376
371
  declare class ExpectResult {
377
372
  assertion: Assertion;
378
- parent: TestResult | undefined;
379
373
  diagnostics: Array<Diagnostic>;
374
+ parent: TestResult | undefined;
380
375
  status: ResultStatus;
381
376
  timing: ResultTiming;
382
- constructor(assertion: Assertion, parent: TestResult | undefined);
377
+ constructor(assertion: Assertion, parent?: TestResult);
383
378
  }
384
379
 
385
380
  declare class ResultCount {
@@ -391,14 +386,14 @@ declare class ResultCount {
391
386
  }
392
387
 
393
388
  declare class TestResult {
394
- test: TestMember;
395
- parent: DescribeResult | undefined;
396
389
  diagnostics: Array<Diagnostic>;
397
390
  expectCount: ResultCount;
391
+ parent: DescribeResult | undefined;
398
392
  results: Array<ExpectResult>;
399
393
  status: ResultStatus;
394
+ test: TestMember;
400
395
  timing: ResultTiming;
401
- constructor(test: TestMember, parent: DescribeResult | undefined);
396
+ constructor(test: TestMember, parent?: DescribeResult);
402
397
  }
403
398
 
404
399
  declare class DescribeResult {
@@ -406,47 +401,47 @@ declare class DescribeResult {
406
401
  parent: DescribeResult | undefined;
407
402
  results: Array<DescribeResult | TestResult>;
408
403
  timing: ResultTiming;
409
- constructor(describe: TestMember, parent: DescribeResult | undefined);
404
+ constructor(describe: TestMember, parent?: DescribeResult);
410
405
  }
411
406
 
412
407
  type FileResultStatus = ResultStatus.Runs | ResultStatus.Passed | ResultStatus.Failed;
413
408
  declare class FileResult {
414
- testFile: TestFile;
415
409
  diagnostics: Array<Diagnostic>;
416
410
  expectCount: ResultCount;
417
411
  results: Array<DescribeResult | TestResult | ExpectResult>;
418
412
  status: FileResultStatus;
419
413
  testCount: ResultCount;
414
+ testFile: TestFile;
420
415
  timing: ResultTiming;
421
416
  constructor(testFile: TestFile);
422
417
  }
423
418
 
424
419
  declare class ProjectResult {
425
420
  compilerVersion: string;
426
- projectConfigFilePath: string | undefined;
427
421
  diagnostics: Array<Diagnostic>;
422
+ projectConfigFilePath: string | undefined;
428
423
  results: Array<FileResult>;
429
424
  constructor(compilerVersion: string, projectConfigFilePath: string | undefined);
430
425
  }
431
426
 
432
427
  type TargetResultStatus = ResultStatus.Runs | ResultStatus.Passed | ResultStatus.Failed;
433
428
  declare class TargetResult {
434
- versionTag: string;
435
- testFiles: Array<TestFile>;
436
429
  results: Map<string | undefined, ProjectResult>;
437
430
  status: TargetResultStatus;
431
+ testFiles: Array<TestFile>;
438
432
  timing: ResultTiming;
433
+ versionTag: string;
439
434
  constructor(versionTag: string, testFiles: Array<TestFile>);
440
435
  }
441
436
 
442
437
  declare class Result {
443
- resolvedConfig: ResolvedConfig;
444
- testFiles: Array<TestFile>;
445
438
  expectCount: ResultCount;
446
439
  fileCount: ResultCount;
440
+ resolvedConfig: ResolvedConfig;
447
441
  results: Array<TargetResult>;
448
442
  targetCount: ResultCount;
449
443
  testCount: ResultCount;
444
+ testFiles: Array<TestFile>;
450
445
  timing: ResultTiming;
451
446
  constructor(resolvedConfig: ResolvedConfig, testFiles: Array<TestFile>);
452
447
  }
@@ -579,7 +574,6 @@ declare function watchUsageText(): ScribblerJsx.Element;
579
574
 
580
575
  declare class SelectService {
581
576
  #private;
582
- readonly resolvedConfig: ResolvedConfig;
583
577
  constructor(resolvedConfig: ResolvedConfig);
584
578
  isTestFile(filePath: string): boolean;
585
579
  selectFiles(): Promise<Array<string>>;
@@ -587,8 +581,7 @@ declare class SelectService {
587
581
 
588
582
  declare class TSTyche {
589
583
  #private;
590
- readonly resolvedConfig: ResolvedConfig;
591
- static readonly version = "2.0.0-beta.1";
584
+ static version: string;
592
585
  constructor(resolvedConfig: ResolvedConfig, outputService: OutputService, selectService: SelectService, storeService: StoreService);
593
586
  close(): void;
594
587
  run(testFiles: Array<string | URL>, cancellationToken?: CancellationToken): Promise<void>;
@@ -649,10 +642,10 @@ declare class PrimitiveTypeMatcher {
649
642
  }
650
643
 
651
644
  declare abstract class RelationMatcherBase {
652
- typeChecker: TypeChecker;
653
645
  abstract relation: Relation;
654
646
  abstract relationExplanationText: string;
655
647
  relationExplanationVerb: string;
648
+ typeChecker: TypeChecker;
656
649
  constructor(typeChecker: TypeChecker);
657
650
  protected explain(sourceType: ts.Type, targetType: ts.Type, isNot: boolean): Array<Diagnostic>;
658
651
  match(sourceType: ts.Type, targetType: ts.Type, isNot: boolean): MatchResult;
@@ -701,8 +694,6 @@ declare class ToRaiseError {
701
694
 
702
695
  declare class Expect {
703
696
  #private;
704
- compiler: typeof ts;
705
- typeChecker: TypeChecker;
706
697
  toBe: ToBe;
707
698
  toBeAny: PrimitiveTypeMatcher;
708
699
  toBeAssignable: ToBeAssignableWith;
@@ -742,7 +733,6 @@ declare class ExitCodeHandler implements EventHandler {
742
733
 
743
734
  declare class RuntimeReporter implements EventHandler {
744
735
  #private;
745
- readonly resolvedConfig: ResolvedConfig;
746
736
  constructor(resolvedConfig: ResolvedConfig, outputService: OutputService);
747
737
  handleEvent([eventName, payload]: Event): void;
748
738
  }
@@ -782,16 +772,15 @@ declare class InputService {
782
772
  }
783
773
 
784
774
  declare class Path {
775
+ static normalizeSlashes: (filePath: string) => string;
785
776
  static dirname(filePath: string): string;
786
777
  static join(...filePaths: Array<string>): string;
787
- static normalizeSlashes(filePath: string): string;
788
778
  static relative(from: string, to: string): string;
789
779
  static resolve(...filePaths: Array<string>): string;
790
780
  }
791
781
 
792
782
  declare class ProjectService {
793
783
  #private;
794
- compiler: typeof ts;
795
784
  constructor(compiler: typeof ts);
796
785
  closeFile(filePath: string): void;
797
786
  getDefaultProject(filePath: string): ts.server.Project | undefined;
@@ -801,7 +790,6 @@ declare class ProjectService {
801
790
 
802
791
  declare class TaskRunner {
803
792
  #private;
804
- readonly resolvedConfig: ResolvedConfig;
805
793
  constructor(resolvedConfig: ResolvedConfig, selectService: SelectService, storeService: StoreService);
806
794
  close(): void;
807
795
  run(testFiles: Array<TestFile>, cancellationToken?: CancellationToken): Promise<void>;
@@ -815,10 +803,12 @@ declare class Version {
815
803
  }
816
804
 
817
805
  type WatchHandler = (filePath: string) => void | Promise<void>;
806
+ interface WatcherOptions {
807
+ recursive?: boolean;
808
+ }
818
809
  declare class Watcher {
819
810
  #private;
820
- readonly targetPath: string;
821
- constructor(targetPath: string, onChanged: WatchHandler, onRemoved?: WatchHandler, recursive?: boolean);
811
+ constructor(targetPath: string, onChanged: WatchHandler, onRemoved?: WatchHandler, options?: WatcherOptions);
822
812
  close(): void;
823
813
  watch(): Promise<void>;
824
814
  }
@@ -831,10 +821,9 @@ declare class FileWatcher extends Watcher {
831
821
  type RunCallback = (testFiles: Array<TestFile>) => Promise<void>;
832
822
  declare class WatchService {
833
823
  #private;
834
- readonly resolvedConfig: ResolvedConfig;
835
824
  constructor(resolvedConfig: ResolvedConfig, runCallback: RunCallback, selectService: SelectService, testFiles: Array<TestFile>);
836
825
  close(): void;
837
826
  watch(cancellationToken?: CancellationToken): Promise<Array<void>>;
838
827
  }
839
828
 
840
- export { Assertion, CancellationHandler, CancellationReason, CancellationToken, Cli, CollectService, Color, type CommandLineOptions, type ConfigFileOptions, ConfigService, DescribeResult, Diagnostic, DiagnosticCategory, type 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 WriteStream, addsPackageStepText, defaultOptions, describeNameText, diagnosticText, fileStatusText, fileViewText, formattedText, helpText, summaryText, testNameText, usesCompilerStepText, waitingForFileChangesText, watchUsageText };
829
+ 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 };