tstyche 7.2.4 → 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 -6170
- 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,290 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { Diagnostic } from "#diagnostic";
|
|
4
|
+
import { environmentOptions } from "#environment";
|
|
5
|
+
import { Path } from "#path";
|
|
6
|
+
import { Store } from "#store";
|
|
7
|
+
import { ConfigDiagnosticText } from "./ConfigDiagnosticText.js";
|
|
8
|
+
import { Target } from "./Target.js";
|
|
9
|
+
export class Options {
|
|
10
|
+
static #definitions = [
|
|
11
|
+
{
|
|
12
|
+
brand: "string",
|
|
13
|
+
description: "The Url to the config file validation schema.",
|
|
14
|
+
group: 4,
|
|
15
|
+
name: "$schema",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
brand: "boolean",
|
|
19
|
+
description: "Check declaration files for type errors.",
|
|
20
|
+
group: 4,
|
|
21
|
+
name: "checkDeclarationFiles",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
brand: "boolean",
|
|
25
|
+
description: "Check errors suppressed by '@ts-expect-error' directives.",
|
|
26
|
+
group: 4,
|
|
27
|
+
name: "checkSuppressedErrors",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
brand: "string",
|
|
31
|
+
description: "The path to a TSTyche configuration file.",
|
|
32
|
+
group: 2,
|
|
33
|
+
name: "config",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
brand: "boolean",
|
|
37
|
+
description: "Stop running tests after the first failed assertion.",
|
|
38
|
+
group: 4 | 2,
|
|
39
|
+
name: "failFast",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
brand: "true",
|
|
43
|
+
description: "Fetch the specified versions of the 'typescript' package and exit.",
|
|
44
|
+
group: 2,
|
|
45
|
+
name: "fetch",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
brand: "list",
|
|
49
|
+
description: "The list of glob patterns matching the fixture files.",
|
|
50
|
+
group: 4,
|
|
51
|
+
items: {
|
|
52
|
+
brand: "string",
|
|
53
|
+
name: "fixtureFileMatch",
|
|
54
|
+
},
|
|
55
|
+
name: "fixtureFileMatch",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
brand: "true",
|
|
59
|
+
description: "Print the list of command line options with brief descriptions and exit.",
|
|
60
|
+
group: 2,
|
|
61
|
+
name: "help",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
brand: "true",
|
|
65
|
+
description: "Print the list of supported versions of the 'typescript' package and exit.",
|
|
66
|
+
group: 2,
|
|
67
|
+
name: "list",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
brand: "true",
|
|
71
|
+
description: "Print the list of selected test files and exit.",
|
|
72
|
+
group: 2,
|
|
73
|
+
name: "listFiles",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
brand: "string",
|
|
77
|
+
description: "Only run tests with a matching name.",
|
|
78
|
+
group: 2,
|
|
79
|
+
name: "only",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
brand: "true",
|
|
83
|
+
description: "Remove all fetched versions of the 'typescript' package and exit.",
|
|
84
|
+
group: 2,
|
|
85
|
+
name: "prune",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
brand: "boolean",
|
|
89
|
+
description: "Silence all test runner output except errors and warnings.",
|
|
90
|
+
group: 2 | 4,
|
|
91
|
+
name: "quiet",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
brand: "boolean",
|
|
95
|
+
description: "Reject the 'any' type passed as an argument to the 'expect()' function or a matcher.",
|
|
96
|
+
group: 4,
|
|
97
|
+
name: "rejectAnyType",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
brand: "boolean",
|
|
101
|
+
description: "Reject the 'never' type passed as an argument to the 'expect()' function or a matcher.",
|
|
102
|
+
group: 4,
|
|
103
|
+
name: "rejectNeverType",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
brand: "list",
|
|
107
|
+
description: "The list of reporters to use.",
|
|
108
|
+
group: 2 | 4,
|
|
109
|
+
items: {
|
|
110
|
+
brand: "string",
|
|
111
|
+
name: "reporters",
|
|
112
|
+
},
|
|
113
|
+
name: "reporters",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
brand: "string",
|
|
117
|
+
description: "The path to the root directory of a test project.",
|
|
118
|
+
group: 2,
|
|
119
|
+
name: "root",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
brand: "true",
|
|
123
|
+
description: "Print the resolved configuration and exit.",
|
|
124
|
+
group: 2,
|
|
125
|
+
name: "showConfig",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
brand: "string",
|
|
129
|
+
description: "Skip tests with a matching name.",
|
|
130
|
+
group: 2,
|
|
131
|
+
name: "skip",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
brand: "range",
|
|
135
|
+
description: "The TypeScript version or range of versions to test against.",
|
|
136
|
+
group: 2 | 4 | 8,
|
|
137
|
+
name: "target",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
brand: "list",
|
|
141
|
+
description: "The list of glob patterns matching the test files.",
|
|
142
|
+
group: 4,
|
|
143
|
+
items: {
|
|
144
|
+
brand: "string",
|
|
145
|
+
name: "testFileMatch",
|
|
146
|
+
},
|
|
147
|
+
name: "testFileMatch",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
brand: "string",
|
|
151
|
+
description: "The TSConfig to load.",
|
|
152
|
+
group: 2 | 4,
|
|
153
|
+
name: "tsconfig",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
brand: "true",
|
|
157
|
+
description: "Fetch the 'typescript' package metadata from the registry and exit.",
|
|
158
|
+
group: 2,
|
|
159
|
+
name: "update",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
brand: "boolean",
|
|
163
|
+
description: "Enable detailed logging.",
|
|
164
|
+
group: 2 | 4,
|
|
165
|
+
name: "verbose",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
brand: "true",
|
|
169
|
+
description: "Print the version number and exit.",
|
|
170
|
+
group: 2,
|
|
171
|
+
name: "version",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
brand: "true",
|
|
175
|
+
description: "Watch for changes and rerun related test files.",
|
|
176
|
+
group: 2,
|
|
177
|
+
name: "watch",
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
static for(optionGroup) {
|
|
181
|
+
const definitionMap = new Map();
|
|
182
|
+
for (const definition of Options.#definitions) {
|
|
183
|
+
if (definition.group & optionGroup) {
|
|
184
|
+
definitionMap.set(definition.name, definition);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return definitionMap;
|
|
188
|
+
}
|
|
189
|
+
static #getCanonicalOptionName(optionName) {
|
|
190
|
+
return optionName.startsWith("--") ? optionName.slice(2) : optionName;
|
|
191
|
+
}
|
|
192
|
+
static #isBuiltinReporter(optionValue) {
|
|
193
|
+
return ["dot", "list", "summary"].includes(optionValue);
|
|
194
|
+
}
|
|
195
|
+
static #isLookupStrategy(optionValue) {
|
|
196
|
+
return ["findup", "baseline"].includes(optionValue);
|
|
197
|
+
}
|
|
198
|
+
static isJsonString(text) {
|
|
199
|
+
return text.startsWith("{");
|
|
200
|
+
}
|
|
201
|
+
static resolve(optionName, optionValue, basePath = ".") {
|
|
202
|
+
const canonicalOptionName = Options.#getCanonicalOptionName(optionName);
|
|
203
|
+
switch (canonicalOptionName) {
|
|
204
|
+
case "config":
|
|
205
|
+
case "root":
|
|
206
|
+
case "tsconfig":
|
|
207
|
+
if (canonicalOptionName === "tsconfig" &&
|
|
208
|
+
(Options.#isLookupStrategy(optionValue) || Options.isJsonString(optionValue))) {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
if (optionValue.startsWith("file:")) {
|
|
212
|
+
optionValue = fileURLToPath(optionValue);
|
|
213
|
+
}
|
|
214
|
+
optionValue = Path.resolve(basePath, optionValue);
|
|
215
|
+
break;
|
|
216
|
+
case "reporters":
|
|
217
|
+
if (Options.#isBuiltinReporter(optionValue)) {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
if (optionValue.startsWith(".")) {
|
|
222
|
+
optionValue = pathToFileURL(Path.relative(".", Path.resolve(basePath, optionValue))).toString();
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
optionValue = import.meta.resolve(optionValue);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
return optionValue;
|
|
233
|
+
}
|
|
234
|
+
static async validate(optionName, optionValue, onDiagnostics, origin) {
|
|
235
|
+
const canonicalOptionName = Options.#getCanonicalOptionName(optionName);
|
|
236
|
+
switch (canonicalOptionName) {
|
|
237
|
+
case "config":
|
|
238
|
+
case "root":
|
|
239
|
+
case "tsconfig":
|
|
240
|
+
if (canonicalOptionName === "tsconfig" &&
|
|
241
|
+
(Options.#isLookupStrategy(optionValue) || Options.isJsonString(optionValue))) {
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
if (existsSync(optionValue)) {
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.fileDoesNotExist(optionValue), origin));
|
|
248
|
+
break;
|
|
249
|
+
case "reporters":
|
|
250
|
+
if (Options.#isBuiltinReporter(optionValue)) {
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
if (optionValue.startsWith("file:") && existsSync(new URL(optionValue))) {
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.moduleWasNotFound(optionValue), origin));
|
|
257
|
+
break;
|
|
258
|
+
case "target": {
|
|
259
|
+
if (/[<>=]/.test(optionValue)) {
|
|
260
|
+
if (!Target.isRange(optionValue)) {
|
|
261
|
+
const text = [ConfigDiagnosticText.rangeIsNotValid(optionValue), ...ConfigDiagnosticText.rangeUsage()];
|
|
262
|
+
onDiagnostics(Diagnostic.error(text, origin));
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
if ((await Store.validateTag(optionValue)) === false) {
|
|
267
|
+
const text = [
|
|
268
|
+
ConfigDiagnosticText.versionIsNotSupported(optionValue),
|
|
269
|
+
ConfigDiagnosticText.inspectSupportedVersions(),
|
|
270
|
+
];
|
|
271
|
+
onDiagnostics(Diagnostic.error(text, origin));
|
|
272
|
+
}
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
case "fixtureFileMatch":
|
|
276
|
+
case "testFileMatch":
|
|
277
|
+
for (const segment of ["/", "../"]) {
|
|
278
|
+
if (optionValue.startsWith(segment)) {
|
|
279
|
+
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.fileMatchPatternCannotStartWith(canonicalOptionName, segment), origin));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case "watch":
|
|
284
|
+
if (environmentOptions.isCi) {
|
|
285
|
+
onDiagnostics(Diagnostic.error(ConfigDiagnosticText.watchCannotBeEnabled(), origin));
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DiagnosticOrigin, type DiagnosticsHandler } from "#diagnostic";
|
|
2
|
+
export declare class Target {
|
|
3
|
+
#private;
|
|
4
|
+
static expand(range: string, onDiagnostics: DiagnosticsHandler, origin?: DiagnosticOrigin): Promise<Array<string>>;
|
|
5
|
+
static isRange(query: string): boolean;
|
|
6
|
+
static split(range: string): string[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Diagnostic } from "#diagnostic";
|
|
2
|
+
import { Store } from "#store";
|
|
3
|
+
import { Version } from "#version";
|
|
4
|
+
import { ConfigDiagnosticText } from "./ConfigDiagnosticText.js";
|
|
5
|
+
export class Target {
|
|
6
|
+
static #rangeRegex = /^[<>]=?\d\.\d( [<>]=?\d\.\d)?$/;
|
|
7
|
+
static async expand(range, onDiagnostics, origin) {
|
|
8
|
+
if (Target.isRange(range)) {
|
|
9
|
+
await Store.open();
|
|
10
|
+
if (Store.manifest != null) {
|
|
11
|
+
let versions = [...Store.manifest.minorVersions];
|
|
12
|
+
for (const comparator of range.split(" ")) {
|
|
13
|
+
versions = Target.#filter(comparator.trim(), versions);
|
|
14
|
+
if (versions.length === 0) {
|
|
15
|
+
const text = [
|
|
16
|
+
ConfigDiagnosticText.rangeDoesNotMatchSupported(range),
|
|
17
|
+
ConfigDiagnosticText.inspectSupportedVersions(),
|
|
18
|
+
];
|
|
19
|
+
onDiagnostics(Diagnostic.error(text, origin));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return versions;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return [range];
|
|
26
|
+
}
|
|
27
|
+
static #filter(comparator, versions) {
|
|
28
|
+
const targetVersion = comparator.replace(/^[<>]=?/, "");
|
|
29
|
+
switch (comparator.charAt(0)) {
|
|
30
|
+
case ">":
|
|
31
|
+
return versions.filter((sourceVersion) => comparator.charAt(1) === "="
|
|
32
|
+
? Version.isSatisfiedWith(sourceVersion, targetVersion)
|
|
33
|
+
: Version.isGreaterThan(sourceVersion, targetVersion));
|
|
34
|
+
case "<":
|
|
35
|
+
return versions.filter((sourceVersion) => comparator.charAt(1) === "="
|
|
36
|
+
? Version.isSatisfiedWith(targetVersion, sourceVersion)
|
|
37
|
+
: Version.isGreaterThan(targetVersion, sourceVersion));
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
static isRange(query) {
|
|
42
|
+
return Target.#rangeRegex.test(query);
|
|
43
|
+
}
|
|
44
|
+
static split(range) {
|
|
45
|
+
return range.split(/ *\|\| */);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const defaultOptions = {
|
|
2
|
+
checkDeclarationFiles: true,
|
|
3
|
+
checkSuppressedErrors: true,
|
|
4
|
+
failFast: false,
|
|
5
|
+
fixtureFileMatch: ["**/__fixtures__/*.{ts,tsx}", "**/fixtures/*.{ts,tsx}"],
|
|
6
|
+
quiet: false,
|
|
7
|
+
rejectAnyType: true,
|
|
8
|
+
rejectNeverType: true,
|
|
9
|
+
reporters: ["list", "summary"],
|
|
10
|
+
target: ["*"],
|
|
11
|
+
testFileMatch: ["**/*.tst.*", "**/__typetests__/*.test.*", "**/typetests/*.test.*"],
|
|
12
|
+
tsconfig: "findup",
|
|
13
|
+
verbose: false,
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Config } from "./Config.js";
|
|
2
|
+
export { ConfigDiagnosticText } from "./ConfigDiagnosticText.js";
|
|
3
|
+
export { Directive } from "./Directive.js";
|
|
4
|
+
export { defaultOptions } from "./defaultOptions.js";
|
|
5
|
+
export { OptionBrand } from "./OptionBrand.enum.js";
|
|
6
|
+
export { OptionGroup } from "./OptionGroup.enum.js";
|
|
7
|
+
export { type ItemDefinition, type OptionDefinition, Options } from "./Options.js";
|
|
8
|
+
export type { CommandLineOptions, ConfigFileOptions, DirectiveRange, InlineConfig, ResolvedConfig, } from "./types.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Config } from "./Config.js";
|
|
2
|
+
export { ConfigDiagnosticText } from "./ConfigDiagnosticText.js";
|
|
3
|
+
export { Directive } from "./Directive.js";
|
|
4
|
+
export { defaultOptions } from "./defaultOptions.js";
|
|
5
|
+
export { OptionBrand } from "./OptionBrand.enum.js";
|
|
6
|
+
export { OptionGroup } from "./OptionGroup.enum.js";
|
|
7
|
+
export { Options } from "./Options.js";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { TextFile, TextRange } from "#text";
|
|
2
|
+
export interface CommandLineOptions {
|
|
3
|
+
config?: string;
|
|
4
|
+
failFast?: boolean;
|
|
5
|
+
fetch?: boolean;
|
|
6
|
+
help?: boolean;
|
|
7
|
+
list?: boolean;
|
|
8
|
+
listFiles?: boolean;
|
|
9
|
+
only?: string;
|
|
10
|
+
prune?: boolean;
|
|
11
|
+
quiet?: boolean;
|
|
12
|
+
reporters?: Array<string>;
|
|
13
|
+
root?: string;
|
|
14
|
+
showConfig?: boolean;
|
|
15
|
+
skip?: string;
|
|
16
|
+
target?: Array<string>;
|
|
17
|
+
tsconfig?: string;
|
|
18
|
+
update?: boolean;
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
version?: boolean;
|
|
21
|
+
watch?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ConfigFileOptions {
|
|
24
|
+
checkDeclarationFiles?: boolean;
|
|
25
|
+
checkSuppressedErrors?: boolean;
|
|
26
|
+
failFast?: boolean;
|
|
27
|
+
fixtureFileMatch?: Array<string>;
|
|
28
|
+
quiet?: boolean;
|
|
29
|
+
rejectAnyType?: boolean;
|
|
30
|
+
rejectNeverType?: boolean;
|
|
31
|
+
reporters?: Array<string>;
|
|
32
|
+
target?: Array<string>;
|
|
33
|
+
testFileMatch?: Array<string>;
|
|
34
|
+
tsconfig?: string;
|
|
35
|
+
verbose?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type { OptionValue } from "#json";
|
|
38
|
+
export interface InlineConfig {
|
|
39
|
+
fixme?: boolean;
|
|
40
|
+
if?: {
|
|
41
|
+
target?: Array<string>;
|
|
42
|
+
};
|
|
43
|
+
template?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ResolvedConfig extends Omit<CommandLineOptions, "config" | "root" | keyof ConfigFileOptions>, Required<ConfigFileOptions> {
|
|
46
|
+
configFilePath: string;
|
|
47
|
+
pathMatch: Array<string>;
|
|
48
|
+
rootPath: string;
|
|
49
|
+
}
|
|
50
|
+
export interface DirectiveRange {
|
|
51
|
+
file: TextFile;
|
|
52
|
+
namespace: TextRange;
|
|
53
|
+
directive?: TextRange;
|
|
54
|
+
argument?: TextRange;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
import { DiagnosticCategory } from "./DiagnosticCategory.enum.js";
|
|
3
|
+
import { DiagnosticOrigin } from "./DiagnosticOrigin.js";
|
|
4
|
+
export declare class Diagnostic {
|
|
5
|
+
category: DiagnosticCategory;
|
|
6
|
+
code: string | undefined;
|
|
7
|
+
origin: DiagnosticOrigin | undefined;
|
|
8
|
+
related: Array<Diagnostic> | undefined;
|
|
9
|
+
text: string | Array<string>;
|
|
10
|
+
constructor(text: string | Array<string>, category: DiagnosticCategory, origin?: DiagnosticOrigin);
|
|
11
|
+
add(options: {
|
|
12
|
+
code?: string | undefined;
|
|
13
|
+
related?: Array<Diagnostic> | undefined;
|
|
14
|
+
}): this;
|
|
15
|
+
static error(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
|
|
16
|
+
extendWith(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
|
|
17
|
+
static fromDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): Array<Diagnostic>;
|
|
18
|
+
static warning(text: string | Array<string>, origin?: DiagnosticOrigin): Diagnostic;
|
|
19
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TextFileService } from "#text";
|
|
2
|
+
import { DiagnosticOrigin } from "./DiagnosticOrigin.js";
|
|
3
|
+
import { getDiagnosticMessageText, isDiagnosticLocation, isDiagnosticPosition } from "./helpers.js";
|
|
4
|
+
export class Diagnostic {
|
|
5
|
+
category;
|
|
6
|
+
code;
|
|
7
|
+
origin;
|
|
8
|
+
related;
|
|
9
|
+
text;
|
|
10
|
+
constructor(text, category, origin) {
|
|
11
|
+
this.text = text;
|
|
12
|
+
this.category = category;
|
|
13
|
+
this.origin = origin;
|
|
14
|
+
}
|
|
15
|
+
add(options) {
|
|
16
|
+
if (options.code != null) {
|
|
17
|
+
this.code = options.code;
|
|
18
|
+
}
|
|
19
|
+
if (options.related != null) {
|
|
20
|
+
this.related = options.related;
|
|
21
|
+
}
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
static error(text, origin) {
|
|
25
|
+
return new Diagnostic(text, "error", origin);
|
|
26
|
+
}
|
|
27
|
+
extendWith(text, origin) {
|
|
28
|
+
return new Diagnostic([this.text, text].flat(), this.category, origin ?? this.origin);
|
|
29
|
+
}
|
|
30
|
+
static fromDiagnostics(diagnostics) {
|
|
31
|
+
return diagnostics.map((diagnostic) => {
|
|
32
|
+
const code = `ts(${diagnostic.code})`;
|
|
33
|
+
let origin;
|
|
34
|
+
if (isDiagnosticPosition(diagnostic)) {
|
|
35
|
+
origin = new DiagnosticOrigin(diagnostic.pos, diagnostic.end, TextFileService.get(diagnostic.fileName));
|
|
36
|
+
}
|
|
37
|
+
if (isDiagnosticLocation(diagnostic)) {
|
|
38
|
+
origin = new DiagnosticOrigin(diagnostic.start, diagnostic.start + diagnostic.length, TextFileService.get(diagnostic.file));
|
|
39
|
+
}
|
|
40
|
+
let related;
|
|
41
|
+
if (diagnostic.relatedInformation != null) {
|
|
42
|
+
related = Diagnostic.fromDiagnostics(diagnostic.relatedInformation);
|
|
43
|
+
}
|
|
44
|
+
const text = getDiagnosticMessageText(diagnostic);
|
|
45
|
+
return new Diagnostic(text, "error", origin).add({ code, related });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
static warning(text, origin) {
|
|
49
|
+
return new Diagnostic(text, "warning", origin);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExpectNode } from "#collect";
|
|
2
|
+
import { type TextFile } from "#text";
|
|
3
|
+
import type * as ts from "#typescript";
|
|
4
|
+
export declare class DiagnosticOrigin {
|
|
5
|
+
expectNode: ExpectNode | undefined;
|
|
6
|
+
end: number;
|
|
7
|
+
file: TextFile;
|
|
8
|
+
start: number;
|
|
9
|
+
constructor(start: number, end: number, file: TextFile, expectNode?: ExpectNode);
|
|
10
|
+
static fromAbilityDiagnostic(diagnostic: ts.DiagnosticPosition | ts.DiagnosticLocation, expectNode: ExpectNode): DiagnosticOrigin;
|
|
11
|
+
static fromAssertion(expectNode: ExpectNode): DiagnosticOrigin;
|
|
12
|
+
static fromNode(node: ts.Node, expectNode?: ExpectNode): DiagnosticOrigin;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TextFileService } from "#text";
|
|
2
|
+
import { isDiagnosticPosition } from "./helpers.js";
|
|
3
|
+
export class DiagnosticOrigin {
|
|
4
|
+
expectNode;
|
|
5
|
+
end;
|
|
6
|
+
file;
|
|
7
|
+
start;
|
|
8
|
+
constructor(start, end, file, expectNode) {
|
|
9
|
+
this.start = start;
|
|
10
|
+
this.end = end;
|
|
11
|
+
this.file = file;
|
|
12
|
+
this.expectNode = expectNode;
|
|
13
|
+
}
|
|
14
|
+
static fromAbilityDiagnostic(diagnostic, expectNode) {
|
|
15
|
+
if (isDiagnosticPosition(diagnostic)) {
|
|
16
|
+
return new DiagnosticOrigin(diagnostic.pos, diagnostic.end, TextFileService.get(diagnostic.fileName), expectNode);
|
|
17
|
+
}
|
|
18
|
+
return new DiagnosticOrigin(diagnostic.start, diagnostic.start + diagnostic.length, TextFileService.get(diagnostic.file), expectNode);
|
|
19
|
+
}
|
|
20
|
+
static fromAssertion(expectNode) {
|
|
21
|
+
const node = expectNode.matcherNameNode.name;
|
|
22
|
+
return new DiagnosticOrigin(node.getStart(), node.getEnd(), TextFileService.get(node.getSourceFile()), expectNode);
|
|
23
|
+
}
|
|
24
|
+
static fromNode(node, expectNode) {
|
|
25
|
+
return new DiagnosticOrigin(node.getStart(), node.getEnd(), TextFileService.get(node.getSourceFile()), expectNode);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
export declare function compareDiagnostics(a: ts.Diagnostic, b: ts.Diagnostic): boolean;
|
|
3
|
+
export declare function diagnosticBelongsToNode(diagnostic: ts.Diagnostic, node: ts.NodeArray<ts.Node> | ts.Node): boolean;
|
|
4
|
+
export declare function getDiagnosticMessageText(diagnostic: ts.Diagnostic): Array<string>;
|
|
5
|
+
export declare function isDiagnosticLocation(diagnostic: ts.Diagnostic): diagnostic is ts.DiagnosticLocation;
|
|
6
|
+
export declare function isDiagnosticPosition(diagnostic: ts.Diagnostic): diagnostic is ts.DiagnosticPosition;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export function compareDiagnostics(a, b) {
|
|
2
|
+
if (isDiagnosticPosition(a) && isDiagnosticPosition(b)) {
|
|
3
|
+
if (a.fileName !== b.fileName) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
return deepCompareKeys(a, b, ["pos", "end", "code", "text"]);
|
|
7
|
+
}
|
|
8
|
+
if (isDiagnosticLocation(a) && isDiagnosticLocation(b)) {
|
|
9
|
+
if (a.file?.fileName !== b.file?.fileName) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return deepCompareKeys(a, b, ["start", "length", "code", "messageText"]);
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
function deepCompareKeys(a, b, keys) {
|
|
17
|
+
if (a == null || b == null) {
|
|
18
|
+
return a === b;
|
|
19
|
+
}
|
|
20
|
+
if (typeof a !== typeof b) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (typeof a !== "object") {
|
|
24
|
+
return a === b;
|
|
25
|
+
}
|
|
26
|
+
for (const key of Object.keys(a).filter((key) => keys.includes(key))) {
|
|
27
|
+
if (!(key in b) || !deepCompareKeys(a[key], b[key], keys)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
export function diagnosticBelongsToNode(diagnostic, node) {
|
|
34
|
+
if (isDiagnosticPosition(diagnostic)) {
|
|
35
|
+
return diagnostic.pos >= node.pos && diagnostic.pos <= node.end;
|
|
36
|
+
}
|
|
37
|
+
if (isDiagnosticLocation(diagnostic)) {
|
|
38
|
+
return diagnostic.start >= node.pos && diagnostic.start <= node.end;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function flattenDiagnosticText(diagnostic) {
|
|
43
|
+
let text;
|
|
44
|
+
let messageChain;
|
|
45
|
+
if ("text" in diagnostic) {
|
|
46
|
+
text = diagnostic.text;
|
|
47
|
+
messageChain = diagnostic.messageChain;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
text = diagnostic.messageText;
|
|
51
|
+
messageChain = diagnostic.next;
|
|
52
|
+
}
|
|
53
|
+
const result = [text];
|
|
54
|
+
if (messageChain != null) {
|
|
55
|
+
for (const message of messageChain) {
|
|
56
|
+
result.push(...flattenDiagnosticText(message));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
export function getDiagnosticMessageText(diagnostic) {
|
|
62
|
+
if ("text" in diagnostic) {
|
|
63
|
+
return flattenDiagnosticText(diagnostic);
|
|
64
|
+
}
|
|
65
|
+
return typeof diagnostic.messageText === "string"
|
|
66
|
+
? [diagnostic.messageText]
|
|
67
|
+
: flattenDiagnosticText(diagnostic.messageText);
|
|
68
|
+
}
|
|
69
|
+
export function isDiagnosticLocation(diagnostic) {
|
|
70
|
+
return "file" in diagnostic && diagnostic.file != null && diagnostic.start != null && diagnostic.length != null;
|
|
71
|
+
}
|
|
72
|
+
export function isDiagnosticPosition(diagnostic) {
|
|
73
|
+
return "fileName" in diagnostic && diagnostic.fileName != null && diagnostic.pos >= 0 && diagnostic.end >= 0;
|
|
74
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Diagnostic } from "./Diagnostic.js";
|
|
2
|
+
export { DiagnosticCategory } from "./DiagnosticCategory.enum.js";
|
|
3
|
+
export { DiagnosticOrigin } from "./DiagnosticOrigin.js";
|
|
4
|
+
export { compareDiagnostics, diagnosticBelongsToNode, getDiagnosticMessageText, isDiagnosticLocation, isDiagnosticPosition, } from "./helpers.js";
|
|
5
|
+
export type { DiagnosticsHandler } from "./types.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Diagnostic } from "./Diagnostic.js";
|
|
2
|
+
export { DiagnosticCategory } from "./DiagnosticCategory.enum.js";
|
|
3
|
+
export { DiagnosticOrigin } from "./DiagnosticOrigin.js";
|
|
4
|
+
export { compareDiagnostics, diagnosticBelongsToNode, getDiagnosticMessageText, isDiagnosticLocation, isDiagnosticPosition, } from "./helpers.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|