tstyche 7.2.5 → 8.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 +4 -0
- package/dist/api.d.ts +16 -761
- package/dist/api.js +16 -6204
- package/dist/bin.js +2 -3
- package/dist/checker/BaseCheckerAdapter.d.ts +15 -0
- package/dist/checker/BaseCheckerAdapter.js +32 -0
- package/dist/checker/CompatCheckerAdapter.d.ts +70 -0
- package/dist/checker/CompatCheckerAdapter.js +221 -0
- package/dist/checker/NativeCheckerAdapter.d.ts +70 -0
- package/dist/checker/NativeCheckerAdapter.js +200 -0
- package/dist/checker/index.d.ts +3 -0
- package/dist/checker/index.js +2 -0
- package/dist/checker/types.d.ts +9 -0
- package/dist/checker/types.js +1 -0
- package/dist/cli/Cli.d.ts +5 -0
- package/dist/cli/Cli.js +144 -0
- package/dist/cli/CliDIagnosticText.d.ts +3 -0
- package/dist/cli/CliDIagnosticText.js +9 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/collect/CollectDiagnosticText.d.ts +3 -0
- package/dist/collect/CollectDiagnosticText.js +5 -0
- package/dist/collect/CollectService.d.ts +9 -0
- package/dist/collect/CollectService.js +150 -0
- package/dist/collect/ExpectNode.d.ts +16 -0
- package/dist/collect/ExpectNode.js +30 -0
- package/dist/collect/IdentifierLookup.d.ts +18 -0
- package/dist/collect/IdentifierLookup.js +90 -0
- package/dist/collect/TestTree.d.ts +16 -0
- package/dist/collect/TestTree.js +15 -0
- package/dist/collect/TestTreeNode.d.ts +15 -0
- package/dist/collect/TestTreeNode.js +27 -0
- package/dist/collect/TestTreeNodeBrand.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeBrand.enum.js +7 -0
- package/dist/collect/TestTreeNodeFlags.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeFlags.enum.js +7 -0
- package/dist/collect/index.d.ts +6 -0
- package/dist/collect/index.js +6 -0
- package/dist/config/CommandParser.d.ts +7 -0
- package/dist/config/CommandParser.js +107 -0
- package/dist/config/Config.d.ts +18 -0
- package/dist/config/Config.js +59 -0
- package/dist/config/ConfigDiagnosticText.d.ts +19 -0
- package/dist/config/ConfigDiagnosticText.js +57 -0
- package/dist/config/ConfigParser.d.ts +10 -0
- package/dist/config/ConfigParser.js +165 -0
- package/dist/config/Directive.d.ts +9 -0
- package/dist/config/Directive.js +119 -0
- package/dist/config/DirectiveDiagnosticText.d.ts +5 -0
- package/dist/config/DirectiveDiagnosticText.js +11 -0
- package/dist/config/OptionBrand.enum.d.ts +8 -0
- package/dist/config/OptionBrand.enum.js +9 -0
- package/dist/config/OptionGroup.enum.d.ts +5 -0
- package/dist/config/OptionGroup.enum.js +6 -0
- package/dist/config/Options.d.ts +29 -0
- package/dist/config/Options.js +290 -0
- package/dist/config/Target.d.ts +7 -0
- package/dist/config/Target.js +47 -0
- package/dist/config/defaultOptions.d.ts +2 -0
- package/dist/config/defaultOptions.js +14 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +7 -0
- package/dist/config/types.d.ts +55 -0
- package/dist/config/types.js +1 -0
- package/dist/diagnostic/Diagnostic.d.ts +19 -0
- package/dist/diagnostic/Diagnostic.js +51 -0
- package/dist/diagnostic/DiagnosticCategory.enum.d.ts +4 -0
- package/dist/diagnostic/DiagnosticCategory.enum.js +5 -0
- package/dist/diagnostic/DiagnosticOrigin.d.ts +13 -0
- package/dist/diagnostic/DiagnosticOrigin.js +27 -0
- package/dist/diagnostic/helpers.d.ts +6 -0
- package/dist/diagnostic/helpers.js +74 -0
- package/dist/diagnostic/index.d.ts +5 -0
- package/dist/diagnostic/index.js +4 -0
- package/dist/diagnostic/types.d.ts +2 -0
- package/dist/diagnostic/types.js +1 -0
- package/dist/editor/TextEditor.d.ts +15 -0
- package/dist/editor/TextEditor.js +88 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/editor/types.d.ts +4 -0
- package/dist/editor/types.js +1 -0
- package/dist/environment/Environment.d.ts +5 -0
- package/dist/environment/Environment.js +89 -0
- package/dist/environment/environmentOptions.d.ts +1 -0
- package/dist/environment/environmentOptions.js +2 -0
- package/dist/environment/index.d.ts +2 -0
- package/dist/environment/index.js +1 -0
- package/dist/environment/types.d.ts +10 -0
- package/dist/environment/types.js +1 -0
- package/dist/events/EventEmitter.d.ts +14 -0
- package/dist/events/EventEmitter.js +42 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +1 -0
- package/dist/events/types.d.ts +88 -0
- package/dist/events/types.js +1 -0
- package/dist/expect/AbilityMatcherBase.d.ts +16 -0
- package/dist/expect/AbilityMatcherBase.js +52 -0
- package/dist/expect/Ensure.d.ts +10 -0
- package/dist/expect/Ensure.js +51 -0
- package/dist/expect/ExpectDiagnosticText.d.ts +29 -0
- package/dist/expect/ExpectDiagnosticText.js +87 -0
- package/dist/expect/ExpectService.d.ts +21 -0
- package/dist/expect/ExpectService.js +90 -0
- package/dist/expect/RelationMatcherBase.d.ts +12 -0
- package/dist/expect/RelationMatcherBase.js +16 -0
- package/dist/expect/ToAcceptProps.d.ts +10 -0
- package/dist/expect/ToAcceptProps.js +52 -0
- package/dist/expect/ToBe.d.ts +13 -0
- package/dist/expect/ToBe.js +18 -0
- package/dist/expect/ToBeApplicable.d.ts +10 -0
- package/dist/expect/ToBeApplicable.js +72 -0
- package/dist/expect/ToBeAssignableFrom.d.ts +9 -0
- package/dist/expect/ToBeAssignableFrom.js +12 -0
- package/dist/expect/ToBeAssignableTo.d.ts +9 -0
- package/dist/expect/ToBeAssignableTo.js +12 -0
- package/dist/expect/ToBeCallableWith.d.ts +11 -0
- package/dist/expect/ToBeCallableWith.js +29 -0
- package/dist/expect/ToBeConstructableWith.d.ts +11 -0
- package/dist/expect/ToBeConstructableWith.js +29 -0
- package/dist/expect/ToBeInstantiableWith.d.ts +10 -0
- package/dist/expect/ToBeInstantiableWith.js +31 -0
- package/dist/expect/ToHaveProperty.d.ts +10 -0
- package/dist/expect/ToHaveProperty.js +59 -0
- package/dist/expect/ToRaiseError.d.ts +9 -0
- package/dist/expect/ToRaiseError.js +82 -0
- package/dist/expect/index.d.ts +2 -0
- package/dist/expect/index.js +1 -0
- package/dist/expect/types.d.ts +7 -0
- package/dist/expect/types.js +1 -0
- package/dist/file/FilePosition.d.ts +7 -0
- package/dist/file/FilePosition.js +16 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +1 -0
- package/dist/glob/Braces.d.ts +4 -0
- package/dist/glob/Braces.js +56 -0
- package/dist/glob/Glob.d.ts +4 -0
- package/dist/glob/Glob.js +47 -0
- package/dist/glob/index.d.ts +1 -0
- package/dist/glob/index.js +1 -0
- package/dist/handlers/CancellationHandler.d.ts +7 -0
- package/dist/handlers/CancellationHandler.js +15 -0
- package/dist/handlers/ExitCodeHandler.d.ts +7 -0
- package/dist/handlers/ExitCodeHandler.js +20 -0
- package/dist/handlers/ResultHandler.d.ts +5 -0
- package/dist/handlers/ResultHandler.js +206 -0
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.js +3 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +40 -45
- package/dist/index.d.ts +40 -45
- package/dist/index.js +1 -2
- package/dist/input/InputService.d.ts +6 -0
- package/dist/input/InputService.js +16 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/json/JsonNode.d.ts +11 -0
- package/dist/json/JsonNode.js +28 -0
- package/dist/json/JsonScanner.d.ts +14 -0
- package/dist/json/JsonScanner.js +105 -0
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.js +2 -0
- package/dist/json/types.d.ts +1 -0
- package/dist/json/types.js +1 -0
- package/dist/layers/AbilityLayer.d.ts +10 -0
- package/dist/layers/AbilityLayer.js +186 -0
- package/dist/layers/Layers.d.ts +11 -0
- package/dist/layers/Layers.js +47 -0
- package/dist/layers/SuppressedLayer.d.ts +11 -0
- package/dist/layers/SuppressedLayer.js +93 -0
- package/dist/layers/index.d.ts +2 -0
- package/dist/layers/index.js +1 -0
- package/dist/layers/types.d.ts +8 -0
- package/dist/layers/types.js +1 -0
- package/dist/output/CodeFrameText.d.ts +10 -0
- package/dist/output/CodeFrameText.js +71 -0
- package/dist/output/OutputService.d.ts +13 -0
- package/dist/output/OutputService.js +38 -0
- package/dist/output/StreamController.d.ts +10 -0
- package/dist/output/StreamController.js +16 -0
- package/dist/output/addsText.d.ts +4 -0
- package/dist/output/addsText.js +8 -0
- package/dist/output/describeNameText.d.ts +2 -0
- package/dist/output/describeNameText.js +5 -0
- package/dist/output/diagnosticText.d.ts +4 -0
- package/dist/output/diagnosticText.js +23 -0
- package/dist/output/dotText.d.ts +3 -0
- package/dist/output/dotText.js +11 -0
- package/dist/output/fileStatusText.d.ts +4 -0
- package/dist/output/fileStatusText.js +26 -0
- package/dist/output/formattedText.d.ts +2 -0
- package/dist/output/formattedText.js +19 -0
- package/dist/output/helpText.d.ts +3 -0
- package/dist/output/helpText.js +52 -0
- package/dist/output/helpers.d.ts +5 -0
- package/dist/output/helpers.js +23 -0
- package/dist/output/index.d.ts +16 -0
- package/dist/output/index.js +15 -0
- package/dist/output/prologueText.d.ts +2 -0
- package/dist/output/prologueText.js +5 -0
- package/dist/output/summaryText.d.ts +12 -0
- package/dist/output/summaryText.js +31 -0
- package/dist/output/testNameText.d.ts +3 -0
- package/dist/output/testNameText.js +24 -0
- package/dist/output/types.d.ts +5 -0
- package/dist/output/types.js +1 -0
- package/dist/output/usesText.d.ts +5 -0
- package/dist/output/usesText.js +22 -0
- package/dist/output/waitingForFileChangesText.d.ts +2 -0
- package/dist/output/waitingForFileChangesText.js +5 -0
- package/dist/output/watchUsageText.d.ts +2 -0
- package/dist/output/watchUsageText.js +12 -0
- package/dist/path/Path.d.ts +7 -0
- package/dist/path/Path.js +28 -0
- package/dist/path/index.d.ts +1 -0
- package/dist/path/index.js +1 -0
- package/dist/project/CompatMappedDiagnostic.d.ts +12 -0
- package/dist/project/CompatMappedDiagnostic.js +25 -0
- package/dist/project/CompatProjectService.d.ts +19 -0
- package/dist/project/CompatProjectService.js +188 -0
- package/dist/project/FileMapService.d.ts +6 -0
- package/dist/project/FileMapService.js +14 -0
- package/dist/project/NativeMappedDiagnostic.d.ts +14 -0
- package/dist/project/NativeMappedDiagnostic.js +29 -0
- package/dist/project/NativeProjectService.d.ts +21 -0
- package/dist/project/NativeProjectService.js +216 -0
- package/dist/project/ProjectConfigService.d.ts +8 -0
- package/dist/project/ProjectConfigService.js +73 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/index.js +2 -0
- package/dist/project/types.d.ts +7 -0
- package/dist/project/types.js +1 -0
- package/dist/reject/Reject.d.ts +9 -0
- package/dist/reject/Reject.js +43 -0
- package/dist/reject/RejectDiagnosticText.d.ts +5 -0
- package/dist/reject/RejectDiagnosticText.js +16 -0
- package/dist/reject/helpers.d.ts +1 -0
- package/dist/reject/helpers.js +3 -0
- package/dist/reject/index.d.ts +1 -0
- package/dist/reject/index.js +1 -0
- package/dist/reporters/BaseReporter.d.ts +7 -0
- package/dist/reporters/BaseReporter.js +6 -0
- package/dist/reporters/DotReporter.d.ts +6 -0
- package/dist/reporters/DotReporter.js +51 -0
- package/dist/reporters/FileView.d.ts +13 -0
- package/dist/reporters/FileView.js +33 -0
- package/dist/reporters/ListReporter.d.ts +6 -0
- package/dist/reporters/ListReporter.js +125 -0
- package/dist/reporters/SetupReporter.d.ts +4 -0
- package/dist/reporters/SetupReporter.js +21 -0
- package/dist/reporters/SummaryReporter.d.ts +5 -0
- package/dist/reporters/SummaryReporter.js +19 -0
- package/dist/reporters/WatchReporter.d.ts +5 -0
- package/dist/reporters/WatchReporter.js +21 -0
- package/dist/reporters/index.d.ts +7 -0
- package/dist/reporters/index.js +6 -0
- package/dist/reporters/types.d.ts +5 -0
- package/dist/reporters/types.js +1 -0
- package/dist/result/DescribeResult.d.ts +9 -0
- package/dist/result/DescribeResult.js +11 -0
- package/dist/result/ExpectResult.d.ts +10 -0
- package/dist/result/ExpectResult.js +11 -0
- package/dist/result/FileResult.d.ts +15 -0
- package/dist/result/FileResult.js +13 -0
- package/dist/result/ProjectConfigKind.enum.d.ts +6 -0
- package/dist/result/ProjectConfigKind.enum.js +7 -0
- package/dist/result/ProjectResult.d.ts +8 -0
- package/dist/result/ProjectResult.js +9 -0
- package/dist/result/Result.d.ts +13 -0
- package/dist/result/Result.js +14 -0
- package/dist/result/ResultStatus.enum.d.ts +10 -0
- package/dist/result/ResultStatus.enum.js +11 -0
- package/dist/result/SuppressedResult.d.ts +5 -0
- package/dist/result/SuppressedResult.js +6 -0
- package/dist/result/TargetResult.d.ts +11 -0
- package/dist/result/TargetResult.js +12 -0
- package/dist/result/TestResult.d.ts +13 -0
- package/dist/result/TestResult.js +13 -0
- package/dist/result/helpers.d.ts +7 -0
- package/dist/result/helpers.js +21 -0
- package/dist/result/index.d.ts +11 -0
- package/dist/result/index.js +10 -0
- package/dist/result/types.d.ts +31 -0
- package/dist/result/types.js +1 -0
- package/dist/runner/FileRunner.d.ts +10 -0
- package/dist/runner/FileRunner.js +93 -0
- package/dist/runner/FixmeDiagnosticText.d.ts +4 -0
- package/dist/runner/FixmeDiagnosticText.js +8 -0
- package/dist/runner/FixmeService.d.ts +9 -0
- package/dist/runner/FixmeService.js +51 -0
- package/dist/runner/RunModeFlags.enum.d.ts +7 -0
- package/dist/runner/RunModeFlags.enum.js +8 -0
- package/dist/runner/Runner.d.ts +9 -0
- package/dist/runner/Runner.js +101 -0
- package/dist/runner/TestTreeWalker.d.ts +19 -0
- package/dist/runner/TestTreeWalker.js +169 -0
- package/dist/runner/index.d.ts +1 -0
- package/dist/runner/index.js +1 -0
- package/dist/scribbler/Color.enum.d.ts +10 -0
- package/dist/scribbler/Color.enum.js +11 -0
- package/dist/scribbler/Line.d.ts +9 -0
- package/dist/scribbler/Line.js +5 -0
- package/dist/scribbler/Scribbler.d.ts +10 -0
- package/dist/scribbler/Scribbler.js +53 -0
- package/dist/scribbler/Text.d.ts +9 -0
- package/dist/scribbler/Text.js +8 -0
- package/dist/scribbler/index.d.ts +5 -0
- package/dist/scribbler/index.js +4 -0
- package/dist/scribbler/jsxRuntime.d.ts +4 -0
- package/dist/scribbler/jsxRuntime.js +4 -0
- package/dist/scribbler/types.d.ts +19 -0
- package/dist/scribbler/types.js +1 -0
- package/dist/select/Select.d.ts +7 -0
- package/dist/select/Select.js +91 -0
- package/dist/select/SelectDiagnosticText.d.ts +6 -0
- package/dist/select/SelectDiagnosticText.js +24 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +2 -0
- package/dist/store/Fetcher.d.ts +8 -0
- package/dist/store/Fetcher.js +52 -0
- package/dist/store/Lock.d.ts +5 -0
- package/dist/store/Lock.js +17 -0
- package/dist/store/LockService.d.ts +8 -0
- package/dist/store/LockService.js +36 -0
- package/dist/store/Manifest.d.ts +35 -0
- package/dist/store/Manifest.js +58 -0
- package/dist/store/ManifestService.d.ts +10 -0
- package/dist/store/ManifestService.js +129 -0
- package/dist/store/PackageService.d.ts +8 -0
- package/dist/store/PackageService.js +69 -0
- package/dist/store/Store.d.ts +12 -0
- package/dist/store/Store.js +103 -0
- package/dist/store/StoreDiagnosticText.d.ts +12 -0
- package/dist/store/StoreDiagnosticText.js +36 -0
- package/dist/store/TarReader.d.ts +9 -0
- package/dist/store/TarReader.js +56 -0
- package/dist/store/helpers.d.ts +1 -0
- package/dist/store/helpers.js +3 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/dist/structure/ComparisonResult.enum.d.ts +5 -0
- package/dist/structure/ComparisonResult.enum.js +6 -0
- package/dist/structure/Structure.d.ts +24 -0
- package/dist/structure/Structure.js +481 -0
- package/dist/structure/index.d.ts +1 -0
- package/dist/structure/index.js +1 -0
- package/dist/suppressed/SuppressedDiagnosticText.d.ts +6 -0
- package/dist/suppressed/SuppressedDiagnosticText.js +18 -0
- package/dist/suppressed/SuppressedService.d.ts +5 -0
- package/dist/suppressed/SuppressedService.js +61 -0
- package/dist/suppressed/index.d.ts +1 -0
- package/dist/suppressed/index.js +1 -0
- package/dist/tag.d.ts +1 -3
- package/dist/tag.js +2 -5
- package/dist/text/TextFile.d.ts +11 -0
- package/dist/text/TextFile.js +41 -0
- package/dist/text/TextFileService.d.ts +10 -0
- package/dist/text/TextFileService.js +31 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +2 -0
- package/dist/text/types.d.ts +5 -0
- package/dist/text/types.js +1 -0
- package/dist/token/CancellationReason.enum.d.ts +6 -0
- package/dist/token/CancellationReason.enum.js +7 -0
- package/dist/token/CancellationToken.d.ts +8 -0
- package/dist/token/CancellationToken.js +22 -0
- package/dist/token/index.d.ts +2 -0
- package/dist/token/index.js +2 -0
- package/dist/typescript/BaseAdapter.d.ts +36 -0
- package/dist/typescript/BaseAdapter.js +83 -0
- package/dist/typescript/CompatTypeScript.d.ts +21 -0
- package/dist/typescript/CompatTypeScript.js +37 -0
- package/dist/typescript/NativeTypeScript.d.ts +24 -0
- package/dist/typescript/NativeTypeScript.js +44 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/typescript/index.js +2 -0
- package/dist/typescript/types.d.ts +69 -0
- package/dist/typescript/types.js +1 -0
- package/dist/version/Version.d.ts +6 -0
- package/dist/version/Version.js +30 -0
- package/dist/version/index.d.ts +1 -0
- package/dist/version/index.js +1 -0
- package/dist/watch/Debounce.d.ts +9 -0
- package/dist/watch/Debounce.js +27 -0
- package/dist/watch/FileWatcher.d.ts +5 -0
- package/dist/watch/FileWatcher.js +12 -0
- package/dist/watch/WatchService.d.ts +8 -0
- package/dist/watch/WatchService.js +96 -0
- package/dist/watch/Watcher.d.ts +10 -0
- package/dist/watch/Watcher.js +31 -0
- package/dist/watch/index.d.ts +3 -0
- package/dist/watch/index.js +3 -0
- package/package.json +9 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
import type { Offset } from "./types.js";
|
|
3
|
+
export declare class TextEditor {
|
|
4
|
+
#private;
|
|
5
|
+
static getOffset(position: number, offsets: Array<Offset>): number;
|
|
6
|
+
open(sourceFile: ts.SourceFile): void;
|
|
7
|
+
close(): void;
|
|
8
|
+
erase(start: number, end: number): this;
|
|
9
|
+
eraseTrailingComma(node: ts.NodeArray<ts.Node>): this;
|
|
10
|
+
insert(position: number, text: string): this;
|
|
11
|
+
getFilePath(): string;
|
|
12
|
+
getOffsets(): Array<Offset>;
|
|
13
|
+
getText(): string;
|
|
14
|
+
update(start: number, end: number, text: string): this;
|
|
15
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export class TextEditor {
|
|
2
|
+
#filePath = "";
|
|
3
|
+
#offset = 0;
|
|
4
|
+
#offsets = [];
|
|
5
|
+
#text = "";
|
|
6
|
+
static getOffset(position, offsets) {
|
|
7
|
+
let diff = 0;
|
|
8
|
+
for (const offset of offsets) {
|
|
9
|
+
if (offset.position > position - diff) {
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
diff += offset.diff;
|
|
13
|
+
}
|
|
14
|
+
return diff;
|
|
15
|
+
}
|
|
16
|
+
open(sourceFile) {
|
|
17
|
+
this.#filePath = sourceFile.fileName;
|
|
18
|
+
this.#text = sourceFile.text;
|
|
19
|
+
this.#offset = 0;
|
|
20
|
+
this.#offsets = [];
|
|
21
|
+
}
|
|
22
|
+
close() {
|
|
23
|
+
this.#filePath = "";
|
|
24
|
+
this.#text = "";
|
|
25
|
+
this.#offset = 0;
|
|
26
|
+
this.#offsets = [];
|
|
27
|
+
}
|
|
28
|
+
erase(start, end) {
|
|
29
|
+
this.#text =
|
|
30
|
+
this.#text.slice(0, start + this.#offset) +
|
|
31
|
+
this.#getErased(start + this.#offset, end + this.#offset) +
|
|
32
|
+
this.#text.slice(end + this.#offset);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
eraseTrailingComma(node) {
|
|
36
|
+
if (node.hasTrailingComma) {
|
|
37
|
+
this.erase(node.end - 1, node.end);
|
|
38
|
+
}
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
insert(position, text) {
|
|
42
|
+
this.update(position, position, text);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
#getErased(start, end) {
|
|
46
|
+
if (this.#text.indexOf("\n", start) >= end) {
|
|
47
|
+
return " ".repeat(end - start);
|
|
48
|
+
}
|
|
49
|
+
const text = [];
|
|
50
|
+
for (let index = start; index < end; index++) {
|
|
51
|
+
const character = this.#text.charAt(index);
|
|
52
|
+
switch (character) {
|
|
53
|
+
case "\n":
|
|
54
|
+
case "\r":
|
|
55
|
+
text.push(character);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
text.push(" ");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return text.join("");
|
|
62
|
+
}
|
|
63
|
+
getFilePath() {
|
|
64
|
+
return this.#filePath;
|
|
65
|
+
}
|
|
66
|
+
getOffsets() {
|
|
67
|
+
return this.#offsets;
|
|
68
|
+
}
|
|
69
|
+
getText() {
|
|
70
|
+
return this.#text;
|
|
71
|
+
}
|
|
72
|
+
#setOffset(start, end, text) {
|
|
73
|
+
const diff = text.length - (end - start);
|
|
74
|
+
if (diff > 0) {
|
|
75
|
+
this.#offset += diff;
|
|
76
|
+
this.#offsets.push({ position: end, diff });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
update(start, end, text) {
|
|
80
|
+
this.#text =
|
|
81
|
+
this.#text.slice(0, start + this.#offset) +
|
|
82
|
+
text +
|
|
83
|
+
this.#getErased(start + this.#offset, end + this.#offset).slice(text.length) +
|
|
84
|
+
this.#text.slice(end + this.#offset);
|
|
85
|
+
this.#setOffset(start, end, text);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextEditor } from "./TextEditor.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { Path } from "#path";
|
|
4
|
+
export class Environment {
|
|
5
|
+
static resolve() {
|
|
6
|
+
return {
|
|
7
|
+
fetchRetries: Environment.#resolveFetchRetries(),
|
|
8
|
+
fetchTimeout: Environment.#resolveFetchTimeout(),
|
|
9
|
+
isCi: Environment.#resolveIsCi(),
|
|
10
|
+
noColor: Environment.#resolveNoColor(),
|
|
11
|
+
noInteractive: Environment.#resolveNoInteractive(),
|
|
12
|
+
npmRegistry: Environment.#resolveNpmRegistry(),
|
|
13
|
+
storePath: Environment.#resolveStorePath(),
|
|
14
|
+
typescriptSpecifier: Environment.#resolveTypeScriptSpecifier(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
static #resolveFetchRetries() {
|
|
18
|
+
if (process.env["TSTYCHE_FETCH_RETRIES"] != null) {
|
|
19
|
+
return Number(process.env["TSTYCHE_FETCH_RETRIES"]);
|
|
20
|
+
}
|
|
21
|
+
return 2;
|
|
22
|
+
}
|
|
23
|
+
static #resolveFetchTimeout() {
|
|
24
|
+
if (process.env["TSTYCHE_FETCH_TIMEOUT"] != null) {
|
|
25
|
+
return Number.parseFloat(process.env["TSTYCHE_FETCH_TIMEOUT"]);
|
|
26
|
+
}
|
|
27
|
+
return 30;
|
|
28
|
+
}
|
|
29
|
+
static #resolveIsCi() {
|
|
30
|
+
if (process.env["CI"] != null) {
|
|
31
|
+
return process.env["CI"] !== "";
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
static #resolveNoColor() {
|
|
36
|
+
if (process.env["TSTYCHE_NO_COLOR"] != null) {
|
|
37
|
+
return process.env["TSTYCHE_NO_COLOR"] !== "";
|
|
38
|
+
}
|
|
39
|
+
if (process.env["NO_COLOR"] != null) {
|
|
40
|
+
return process.env["NO_COLOR"] !== "";
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
static #resolveNoInteractive() {
|
|
45
|
+
if (process.env["TSTYCHE_NO_INTERACTIVE"] != null) {
|
|
46
|
+
return process.env["TSTYCHE_NO_INTERACTIVE"] !== "";
|
|
47
|
+
}
|
|
48
|
+
return !process.stdout.isTTY;
|
|
49
|
+
}
|
|
50
|
+
static #resolveNpmRegistry() {
|
|
51
|
+
if (process.env["TSTYCHE_NPM_REGISTRY"] != null) {
|
|
52
|
+
return process.env["TSTYCHE_NPM_REGISTRY"];
|
|
53
|
+
}
|
|
54
|
+
return "https://registry.npmjs.org";
|
|
55
|
+
}
|
|
56
|
+
static #resolveStorePath() {
|
|
57
|
+
if (process.env["TSTYCHE_STORE_PATH"] != null) {
|
|
58
|
+
return Path.resolve(process.env["TSTYCHE_STORE_PATH"]);
|
|
59
|
+
}
|
|
60
|
+
if (process.platform === "darwin") {
|
|
61
|
+
return Path.resolve(os.homedir(), "Library", "TSTyche");
|
|
62
|
+
}
|
|
63
|
+
if (process.env["LocalAppData"] != null) {
|
|
64
|
+
return Path.resolve(process.env["LocalAppData"], "TSTyche");
|
|
65
|
+
}
|
|
66
|
+
if (process.env["XDG_DATA_HOME"] != null) {
|
|
67
|
+
return Path.resolve(process.env["XDG_DATA_HOME"], "TSTyche");
|
|
68
|
+
}
|
|
69
|
+
return Path.resolve(os.homedir(), ".local", "share", "TSTyche");
|
|
70
|
+
}
|
|
71
|
+
static #resolveTypeScriptSpecifier() {
|
|
72
|
+
function resolve(specifier) {
|
|
73
|
+
return import.meta.resolve(`${specifier}/package.json`).replace(/package\.json$/, "");
|
|
74
|
+
}
|
|
75
|
+
if (process.env["TSTYCHE_TYPESCRIPT_SPECIFIER"] != null) {
|
|
76
|
+
const specifier = process.env["TSTYCHE_TYPESCRIPT_SPECIFIER"];
|
|
77
|
+
if (specifier !== "") {
|
|
78
|
+
return resolve(specifier);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return resolve("typescript");
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const environmentOptions: import("./types.js").EnvironmentOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { environmentOptions } from "./environmentOptions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Reporter } from "#reporters";
|
|
2
|
+
import type { Event, EventHandler } from "./types.js";
|
|
3
|
+
export declare class EventEmitter {
|
|
4
|
+
#private;
|
|
5
|
+
static instanceCount: number;
|
|
6
|
+
constructor();
|
|
7
|
+
addHandler(handler: EventHandler): void;
|
|
8
|
+
addReporter(reporter: Reporter): void;
|
|
9
|
+
static dispatch(event: Event): void;
|
|
10
|
+
removeHandler(handler: EventHandler): void;
|
|
11
|
+
removeReporter(reporter: Reporter): void;
|
|
12
|
+
removeHandlers(): void;
|
|
13
|
+
removeReporters(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class EventEmitter {
|
|
2
|
+
static instanceCount = 0;
|
|
3
|
+
static #handlers = new Map();
|
|
4
|
+
static #reporters = new Map();
|
|
5
|
+
#scope;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.#scope = EventEmitter.instanceCount++;
|
|
8
|
+
EventEmitter.#handlers.set(this.#scope, new Set());
|
|
9
|
+
EventEmitter.#reporters.set(this.#scope, new Set());
|
|
10
|
+
}
|
|
11
|
+
addHandler(handler) {
|
|
12
|
+
EventEmitter.#handlers.get(this.#scope)?.add(handler);
|
|
13
|
+
}
|
|
14
|
+
addReporter(reporter) {
|
|
15
|
+
EventEmitter.#reporters.get(this.#scope)?.add(reporter);
|
|
16
|
+
}
|
|
17
|
+
static dispatch(event) {
|
|
18
|
+
function forEachHandler(handlers, event) {
|
|
19
|
+
for (const handler of handlers) {
|
|
20
|
+
handler.on(event);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const handlers of EventEmitter.#handlers.values()) {
|
|
24
|
+
forEachHandler(handlers, event);
|
|
25
|
+
}
|
|
26
|
+
for (const handlers of EventEmitter.#reporters.values()) {
|
|
27
|
+
forEachHandler(handlers, event);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
removeHandler(handler) {
|
|
31
|
+
EventEmitter.#handlers.get(this.#scope)?.delete(handler);
|
|
32
|
+
}
|
|
33
|
+
removeReporter(reporter) {
|
|
34
|
+
EventEmitter.#reporters.get(this.#scope)?.delete(reporter);
|
|
35
|
+
}
|
|
36
|
+
removeHandlers() {
|
|
37
|
+
EventEmitter.#handlers.get(this.#scope)?.clear();
|
|
38
|
+
}
|
|
39
|
+
removeReporters() {
|
|
40
|
+
EventEmitter.#reporters.get(this.#scope)?.clear();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EventEmitter } from "./EventEmitter.js";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ExpectNode, TestTree, TestTreeNode } from "#collect";
|
|
2
|
+
import type { Diagnostic } from "#diagnostic";
|
|
3
|
+
import type { DescribeResult, ExpectResult, FileResult, ProjectConfig, Result, SuppressedResult, TargetResult, TestResult } from "#result";
|
|
4
|
+
export type Event = ["config:error", {
|
|
5
|
+
diagnostics: Array<Diagnostic>;
|
|
6
|
+
}] | ["select:error", {
|
|
7
|
+
diagnostics: Array<Diagnostic>;
|
|
8
|
+
}] | ["run:start", {
|
|
9
|
+
result: Result;
|
|
10
|
+
}] | ["run:end", {
|
|
11
|
+
result: Result;
|
|
12
|
+
}] | ["store:adds", {
|
|
13
|
+
packagePath: string;
|
|
14
|
+
packageVersion: string;
|
|
15
|
+
}] | ["store:error", {
|
|
16
|
+
diagnostics: Array<Diagnostic>;
|
|
17
|
+
}] | ["target:start", {
|
|
18
|
+
result: TargetResult;
|
|
19
|
+
}] | ["target:end", {
|
|
20
|
+
result: TargetResult;
|
|
21
|
+
}] | ["project:uses", {
|
|
22
|
+
compilerVersion: string;
|
|
23
|
+
projectConfig: ProjectConfig;
|
|
24
|
+
}] | ["project:error", {
|
|
25
|
+
diagnostics: Array<Diagnostic>;
|
|
26
|
+
}] | ["file:start", {
|
|
27
|
+
result: FileResult;
|
|
28
|
+
}] | ["file:error", {
|
|
29
|
+
diagnostics: Array<Diagnostic>;
|
|
30
|
+
result: FileResult;
|
|
31
|
+
}] | ["file:end", {
|
|
32
|
+
result: FileResult;
|
|
33
|
+
}] | ["directive:error", {
|
|
34
|
+
diagnostics: Array<Diagnostic>;
|
|
35
|
+
}] | ["collect:start", {
|
|
36
|
+
tree: TestTree;
|
|
37
|
+
}] | ["collect:error", {
|
|
38
|
+
diagnostics: Array<Diagnostic>;
|
|
39
|
+
}] | ["collect:node", {
|
|
40
|
+
node: TestTreeNode | ExpectNode;
|
|
41
|
+
}] | ["collect:end", {
|
|
42
|
+
tree: TestTree;
|
|
43
|
+
}] | ["describe:start", {
|
|
44
|
+
result: DescribeResult;
|
|
45
|
+
}] | ["describe:end", {
|
|
46
|
+
result: DescribeResult;
|
|
47
|
+
}] | ["test:start", {
|
|
48
|
+
result: TestResult;
|
|
49
|
+
}] | ["test:error", {
|
|
50
|
+
diagnostics: Array<Diagnostic>;
|
|
51
|
+
result: TestResult;
|
|
52
|
+
}] | ["test:fail", {
|
|
53
|
+
result: TestResult;
|
|
54
|
+
}] | ["test:pass", {
|
|
55
|
+
result: TestResult;
|
|
56
|
+
}] | ["test:skip", {
|
|
57
|
+
result: TestResult;
|
|
58
|
+
}] | ["test:fixme", {
|
|
59
|
+
result: TestResult;
|
|
60
|
+
}] | ["test:todo", {
|
|
61
|
+
result: TestResult;
|
|
62
|
+
}] | ["expect:start", {
|
|
63
|
+
result: ExpectResult;
|
|
64
|
+
}] | ["expect:error", {
|
|
65
|
+
diagnostics: Array<Diagnostic>;
|
|
66
|
+
result: ExpectResult;
|
|
67
|
+
}] | ["expect:fail", {
|
|
68
|
+
diagnostics: Array<Diagnostic>;
|
|
69
|
+
result: ExpectResult;
|
|
70
|
+
}] | ["expect:pass", {
|
|
71
|
+
result: ExpectResult;
|
|
72
|
+
}] | ["expect:skip", {
|
|
73
|
+
result: ExpectResult;
|
|
74
|
+
}] | ["expect:fixme", {
|
|
75
|
+
result: ExpectResult;
|
|
76
|
+
}] | ["suppressed:error", {
|
|
77
|
+
diagnostics: Array<Diagnostic>;
|
|
78
|
+
result: SuppressedResult;
|
|
79
|
+
}] | ["suppressed:match", {
|
|
80
|
+
result: SuppressedResult;
|
|
81
|
+
}] | ["suppressed:ignore", {
|
|
82
|
+
result: SuppressedResult;
|
|
83
|
+
}] | ["watch:error", {
|
|
84
|
+
diagnostics: Array<Diagnostic>;
|
|
85
|
+
}];
|
|
86
|
+
export interface EventHandler {
|
|
87
|
+
on: (event: Event) => void;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Checker } from "#checker";
|
|
2
|
+
import type { ExpectNode } from "#collect";
|
|
3
|
+
import { Diagnostic, type DiagnosticsHandler } from "#diagnostic";
|
|
4
|
+
import type * as ts from "#typescript";
|
|
5
|
+
import type { ArgumentNode, MatchResult } from "./types.js";
|
|
6
|
+
export declare abstract class AbilityMatcherBase {
|
|
7
|
+
protected checker: Checker;
|
|
8
|
+
protected ts: ts.TypeScript;
|
|
9
|
+
constructor(ts: ts.TypeScript, checker: Checker);
|
|
10
|
+
abstract explainText(isExpression: boolean, targetText?: string): string;
|
|
11
|
+
abstract explainNotText(isExpression: boolean, targetText?: string): string;
|
|
12
|
+
protected getArgumentCountText(nodes: ts.NodeArray<ArgumentNode>): string;
|
|
13
|
+
protected getTypeArgumentCountText(targetNode: ts.TupleTypeNode): string;
|
|
14
|
+
explain(expectNode: ExpectNode, sourceNode: ArgumentNode, targetNode: ts.NodeArray<ArgumentNode> | ArgumentNode, getArgumentCountText?: () => string): Array<Diagnostic>;
|
|
15
|
+
abstract match(expectNode: ExpectNode, sourceNode: ArgumentNode, targetNodes: ts.NodeArray<ArgumentNode> | ArgumentNode | undefined, onDiagnostics: DiagnosticsHandler<Array<Diagnostic>>): MatchResult | undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Diagnostic, DiagnosticOrigin, diagnosticBelongsToNode, getDiagnosticMessageText, isDiagnosticLocation, isDiagnosticPosition, } from "#diagnostic";
|
|
2
|
+
export class AbilityMatcherBase {
|
|
3
|
+
checker;
|
|
4
|
+
ts;
|
|
5
|
+
constructor(ts, checker) {
|
|
6
|
+
this.ts = ts;
|
|
7
|
+
this.checker = checker;
|
|
8
|
+
}
|
|
9
|
+
getArgumentCountText(nodes) {
|
|
10
|
+
if (nodes.length === 0) {
|
|
11
|
+
return "without arguments";
|
|
12
|
+
}
|
|
13
|
+
if (nodes.length === 1 && nodes[0]?.kind === this.ts.SyntaxKind.SpreadElement) {
|
|
14
|
+
return "with the given arguments";
|
|
15
|
+
}
|
|
16
|
+
return `with the given argument${nodes.length === 1 ? "" : "s"}`;
|
|
17
|
+
}
|
|
18
|
+
getTypeArgumentCountText(targetNode) {
|
|
19
|
+
if (targetNode.elements.length === 0) {
|
|
20
|
+
return "without type arguments";
|
|
21
|
+
}
|
|
22
|
+
return `with the given type argument${targetNode.elements.length === 1 ? "" : "s"}`;
|
|
23
|
+
}
|
|
24
|
+
explain(expectNode, sourceNode, targetNode, getArgumentCountText) {
|
|
25
|
+
const isExpression = this.ts.belongsToArgumentList(sourceNode);
|
|
26
|
+
const argumentCountText = getArgumentCountText?.();
|
|
27
|
+
const diagnostics = [];
|
|
28
|
+
if (expectNode.abilityDiagnostics.size > 0) {
|
|
29
|
+
for (const diagnostic of expectNode.abilityDiagnostics) {
|
|
30
|
+
const text = [this.explainNotText(isExpression, argumentCountText), ...getDiagnosticMessageText(diagnostic)];
|
|
31
|
+
let origin;
|
|
32
|
+
if ((isDiagnosticPosition(diagnostic) || isDiagnosticLocation(diagnostic)) &&
|
|
33
|
+
diagnosticBelongsToNode(diagnostic, targetNode)) {
|
|
34
|
+
origin = DiagnosticOrigin.fromAbilityDiagnostic(diagnostic, expectNode);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
origin = DiagnosticOrigin.fromAssertion(expectNode);
|
|
38
|
+
}
|
|
39
|
+
let related;
|
|
40
|
+
if (diagnostic.relatedInformation != null) {
|
|
41
|
+
related = Diagnostic.fromDiagnostics(diagnostic.relatedInformation);
|
|
42
|
+
}
|
|
43
|
+
diagnostics.push(Diagnostic.error(text, origin).add({ related }));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const origin = DiagnosticOrigin.fromAssertion(expectNode);
|
|
48
|
+
diagnostics.push(Diagnostic.error(this.explainText(isExpression, argumentCountText), origin));
|
|
49
|
+
}
|
|
50
|
+
return diagnostics;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Diagnostic, type DiagnosticsHandler } from "#diagnostic";
|
|
2
|
+
import type * as ts from "#typescript";
|
|
3
|
+
export declare class Ensure {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(ts: ts.TypeScript, program: ts.Program);
|
|
6
|
+
argument<T extends ts.Node>(node: T | undefined, enclosingNode: ts.Node, onDiagnostics: DiagnosticsHandler<Array<Diagnostic>>): node is NonNullable<T>;
|
|
7
|
+
argumentOrTypeArgument<T extends ts.Node>(node: T | undefined, enclosingNode: ts.Node, onDiagnostics: DiagnosticsHandler<Array<Diagnostic>>): node is NonNullable<T>;
|
|
8
|
+
jsxSetup(node: ts.Node, onDiagnostics: DiagnosticsHandler<Array<Diagnostic>>): boolean;
|
|
9
|
+
typeArgument<T extends ts.Node>(node: T | undefined, enclosingNode: ts.Node, onDiagnostics: DiagnosticsHandler<Array<Diagnostic>>): node is NonNullable<T>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Diagnostic, DiagnosticOrigin } from "#diagnostic";
|
|
2
|
+
export class Ensure {
|
|
3
|
+
#compilerOptions;
|
|
4
|
+
#ts;
|
|
5
|
+
constructor(ts, program) {
|
|
6
|
+
this.#ts = ts;
|
|
7
|
+
this.#compilerOptions = program.getCompilerOptions();
|
|
8
|
+
}
|
|
9
|
+
argument(node, enclosingNode, onDiagnostics) {
|
|
10
|
+
if (!node || !this.#ts.belongsToArgumentList(node)) {
|
|
11
|
+
this.#emitDiagnostic("An argument must be provided.", enclosingNode, onDiagnostics);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
argumentOrTypeArgument(node, enclosingNode, onDiagnostics) {
|
|
17
|
+
if (!node) {
|
|
18
|
+
this.#emitDiagnostic("An argument or type argument must be provided.", enclosingNode, onDiagnostics);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
jsxSetup(node, onDiagnostics) {
|
|
24
|
+
const diagnosticText = [];
|
|
25
|
+
if (!this.#compilerOptions.jsx) {
|
|
26
|
+
diagnosticText.push("The matcher requires the 'jsx' compiler option to be configured.");
|
|
27
|
+
}
|
|
28
|
+
if (node.getSourceFile().languageVariant !== this.#ts.LanguageVariant.JSX) {
|
|
29
|
+
diagnosticText.push("The matcher requires a '.tsx' file extension.");
|
|
30
|
+
}
|
|
31
|
+
if (diagnosticText.length > 0) {
|
|
32
|
+
this.#emitDiagnostic(diagnosticText, node, onDiagnostics);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
typeArgument(node, enclosingNode, onDiagnostics) {
|
|
38
|
+
if (!node || this.#ts.belongsToArgumentList(node)) {
|
|
39
|
+
this.#emitDiagnostic("A type argument must be provided.", enclosingNode, onDiagnostics);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
#emitDiagnostic(text, enclosingNode, onDiagnostics) {
|
|
45
|
+
if (!Array.isArray(text)) {
|
|
46
|
+
text = [text];
|
|
47
|
+
}
|
|
48
|
+
const origin = DiagnosticOrigin.fromNode(enclosingNode);
|
|
49
|
+
onDiagnostics(text.map((text) => Diagnostic.error(text, origin)));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare class ExpectDiagnosticText {
|
|
2
|
+
static argumentMustBe(expectedText: string): string;
|
|
3
|
+
static typeArgumentMustBe(expectedText: string): string;
|
|
4
|
+
static isCallable(isExpression: boolean, targetText: string): string;
|
|
5
|
+
static isNotCallable(isExpression: boolean, targetText: string): string;
|
|
6
|
+
static isConstructable(isExpression: boolean, targetText: string): string;
|
|
7
|
+
static isNotConstructable(isExpression: boolean, targetText: string): string;
|
|
8
|
+
static isInstantiable(isExpression: boolean, targetText: string): string;
|
|
9
|
+
static isNotInstantiable(isExpression: boolean, targetText: string): string;
|
|
10
|
+
static acceptsProps(isExpression: boolean): string;
|
|
11
|
+
static doesNotAcceptProps(isExpression: boolean): string;
|
|
12
|
+
static canBeApplied(targetText: string): string;
|
|
13
|
+
static cannotBeApplied(targetText: string): string;
|
|
14
|
+
static hasProperty(typeText: string, propertyNameText: string): string;
|
|
15
|
+
static doesNotHaveProperty(typeText: string, propertyNameText: string): string;
|
|
16
|
+
static didYouMeanToUse(suggestionText: string): string;
|
|
17
|
+
static matcherIsNotSupported(matcherNameText: string): string;
|
|
18
|
+
static raisedTypeError(count?: number): string;
|
|
19
|
+
static raisedError(isExpression: boolean, count: number, targetCount: number): string;
|
|
20
|
+
static didNotRaiseError(isExpression: boolean): string;
|
|
21
|
+
static raisedMatchingError(isExpression: boolean): string;
|
|
22
|
+
static didNotRaiseMatchingError(isExpression: boolean): string;
|
|
23
|
+
static isAssignableTo(sourceTypeText: string, targetTypeText: string): string;
|
|
24
|
+
static isNotAssignableTo(sourceTypeText: string, targetTypeText: string): string;
|
|
25
|
+
static isAssignableFrom(sourceTypeText: string, targetTypeText: string): string;
|
|
26
|
+
static isNotAssignableFrom(sourceTypeText: string, targetTypeText: string): string;
|
|
27
|
+
static isTheSame(sourceTypeText: string, targetTypeText: string): string;
|
|
28
|
+
static isNotTheSame(sourceTypeText: string, targetTypeText: string): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class ExpectDiagnosticText {
|
|
2
|
+
static argumentMustBe(expectedText) {
|
|
3
|
+
return `The argument must be ${expectedText}.`;
|
|
4
|
+
}
|
|
5
|
+
static typeArgumentMustBe(expectedText) {
|
|
6
|
+
return `The type argument must be ${expectedText}.`;
|
|
7
|
+
}
|
|
8
|
+
static isCallable(isExpression, targetText) {
|
|
9
|
+
return `${isExpression ? "Expression" : "Type"} is callable ${targetText}.`;
|
|
10
|
+
}
|
|
11
|
+
static isNotCallable(isExpression, targetText) {
|
|
12
|
+
return `${isExpression ? "Expression" : "Type"} is not callable ${targetText}.`;
|
|
13
|
+
}
|
|
14
|
+
static isConstructable(isExpression, targetText) {
|
|
15
|
+
return `${isExpression ? "Expression" : "Type"} is constructable ${targetText}.`;
|
|
16
|
+
}
|
|
17
|
+
static isNotConstructable(isExpression, targetText) {
|
|
18
|
+
return `${isExpression ? "Expression" : "Type"} is not constructable ${targetText}.`;
|
|
19
|
+
}
|
|
20
|
+
static isInstantiable(isExpression, targetText) {
|
|
21
|
+
return `${isExpression ? "Expression" : "Type"} is instantiable ${targetText}.`;
|
|
22
|
+
}
|
|
23
|
+
static isNotInstantiable(isExpression, targetText) {
|
|
24
|
+
return `${isExpression ? "Expression" : "Type"} is not instantiable ${targetText}.`;
|
|
25
|
+
}
|
|
26
|
+
static acceptsProps(isExpression) {
|
|
27
|
+
return `${isExpression ? "Component" : "Type"} accepts props of the given type.`;
|
|
28
|
+
}
|
|
29
|
+
static doesNotAcceptProps(isExpression) {
|
|
30
|
+
return `${isExpression ? "Component" : "Type"} does not accept props of the given type.`;
|
|
31
|
+
}
|
|
32
|
+
static canBeApplied(targetText) {
|
|
33
|
+
return `The decorator function can be applied${targetText}.`;
|
|
34
|
+
}
|
|
35
|
+
static cannotBeApplied(targetText) {
|
|
36
|
+
return `The decorator function cannot be applied${targetText}.`;
|
|
37
|
+
}
|
|
38
|
+
static hasProperty(typeText, propertyNameText) {
|
|
39
|
+
return `Type '${typeText}' has property '${propertyNameText}'.`;
|
|
40
|
+
}
|
|
41
|
+
static doesNotHaveProperty(typeText, propertyNameText) {
|
|
42
|
+
return `Type '${typeText}' does not have property '${propertyNameText}'.`;
|
|
43
|
+
}
|
|
44
|
+
static didYouMeanToUse(suggestionText) {
|
|
45
|
+
return `Did you mean to use ${suggestionText}?`;
|
|
46
|
+
}
|
|
47
|
+
static matcherIsNotSupported(matcherNameText) {
|
|
48
|
+
return `The '.${matcherNameText}()' matcher is not supported.`;
|
|
49
|
+
}
|
|
50
|
+
static raisedTypeError(count = 1) {
|
|
51
|
+
return `The raised type error${count === 1 ? "" : "s"}:`;
|
|
52
|
+
}
|
|
53
|
+
static raisedError(isExpression, count, targetCount) {
|
|
54
|
+
let countText = "a";
|
|
55
|
+
if (count > 1 || targetCount > 1) {
|
|
56
|
+
countText = count > targetCount ? `${count}` : `only ${count}`;
|
|
57
|
+
}
|
|
58
|
+
return `${isExpression ? "Expression" : "Type"} raised ${countText} type error${count === 1 ? "" : "s"}.`;
|
|
59
|
+
}
|
|
60
|
+
static didNotRaiseError(isExpression) {
|
|
61
|
+
return `${isExpression ? "Expression" : "Type"} did not raise a type error.`;
|
|
62
|
+
}
|
|
63
|
+
static raisedMatchingError(isExpression) {
|
|
64
|
+
return `${isExpression ? "Expression" : "Type"} raised a matching type error.`;
|
|
65
|
+
}
|
|
66
|
+
static didNotRaiseMatchingError(isExpression) {
|
|
67
|
+
return `${isExpression ? "Expression" : "Type"} did not raise a matching type error.`;
|
|
68
|
+
}
|
|
69
|
+
static isAssignableTo(sourceTypeText, targetTypeText) {
|
|
70
|
+
return `Type '${sourceTypeText}' is assignable to type '${targetTypeText}'.`;
|
|
71
|
+
}
|
|
72
|
+
static isNotAssignableTo(sourceTypeText, targetTypeText) {
|
|
73
|
+
return `Type '${sourceTypeText}' is not assignable to type '${targetTypeText}'.`;
|
|
74
|
+
}
|
|
75
|
+
static isAssignableFrom(sourceTypeText, targetTypeText) {
|
|
76
|
+
return `Type '${sourceTypeText}' is assignable from type '${targetTypeText}'.`;
|
|
77
|
+
}
|
|
78
|
+
static isNotAssignableFrom(sourceTypeText, targetTypeText) {
|
|
79
|
+
return `Type '${sourceTypeText}' is not assignable from type '${targetTypeText}'.`;
|
|
80
|
+
}
|
|
81
|
+
static isTheSame(sourceTypeText, targetTypeText) {
|
|
82
|
+
return `Type '${sourceTypeText}' is the same as type '${targetTypeText}'.`;
|
|
83
|
+
}
|
|
84
|
+
static isNotTheSame(sourceTypeText, targetTypeText) {
|
|
85
|
+
return `Type '${sourceTypeText}' is not the same as type '${targetTypeText}'.`;
|
|
86
|
+
}
|
|
87
|
+
}
|