tstyche 7.2.5 → 8.0.0-beta.1
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 +49 -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 +24 -0
- package/dist/store/Fetcher.js +68 -0
- package/dist/store/Lock.d.ts +5 -0
- package/dist/store/Lock.js +24 -0
- package/dist/store/LockService.d.ts +8 -0
- package/dist/store/LockService.js +36 -0
- package/dist/store/Manifest.d.ts +30 -0
- package/dist/store/Manifest.js +58 -0
- package/dist/store/ManifestService.d.ts +10 -0
- package/dist/store/ManifestService.js +91 -0
- package/dist/store/PackageService.d.ts +9 -0
- package/dist/store/PackageService.js +89 -0
- package/dist/store/Store.d.ts +12 -0
- package/dist/store/Store.js +103 -0
- package/dist/store/StoreDiagnosticText.d.ts +13 -0
- package/dist/store/StoreDiagnosticText.js +42 -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 +10 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Diagnostic, DiagnosticOrigin, getDiagnosticMessageText } from "#diagnostic";
|
|
2
|
+
import { EventEmitter } from "#events";
|
|
3
|
+
import { SuppressedResult } from "#result";
|
|
4
|
+
import { TextFileService } from "#text";
|
|
5
|
+
import { SuppressedDiagnosticText } from "./SuppressedDiagnosticText.js";
|
|
6
|
+
export class SuppressedService {
|
|
7
|
+
match(testTree) {
|
|
8
|
+
if (!testTree.suppressedErrors) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
for (const suppressedError of testTree.suppressedErrors) {
|
|
12
|
+
const suppressedResult = new SuppressedResult(suppressedError);
|
|
13
|
+
if (suppressedError.diagnostics.length === 0) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (suppressedError.ignore) {
|
|
17
|
+
EventEmitter.dispatch(["suppressed:ignore", { result: suppressedResult }]);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const related = [
|
|
21
|
+
Diagnostic.error(SuppressedDiagnosticText.suppressedError(suppressedError.diagnostics.length)),
|
|
22
|
+
...Diagnostic.fromDiagnostics(suppressedError.diagnostics),
|
|
23
|
+
];
|
|
24
|
+
const origin = new DiagnosticOrigin(suppressedError.directive.start, suppressedError.directive.end, TextFileService.get(testTree.sourceFile));
|
|
25
|
+
if (!suppressedError.argument?.text) {
|
|
26
|
+
const text = SuppressedDiagnosticText.directiveRequires();
|
|
27
|
+
this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (suppressedError.diagnostics.length > 1) {
|
|
31
|
+
const text = SuppressedDiagnosticText.onlySingleError();
|
|
32
|
+
this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const messageText = getDiagnosticMessageText(suppressedError.diagnostics[0]).join("\n");
|
|
36
|
+
if (!this.#matchMessage(messageText, suppressedError.argument.text)) {
|
|
37
|
+
const text = SuppressedDiagnosticText.messageDidNotMatch();
|
|
38
|
+
const origin = new DiagnosticOrigin(suppressedError.argument.start, suppressedError.argument.end, TextFileService.get(testTree.sourceFile));
|
|
39
|
+
this.#onDiagnostics(Diagnostic.error(text, origin).add({ related }), suppressedResult);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
EventEmitter.dispatch(["suppressed:match", { result: suppressedResult }]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
#matchMessage(source, target) {
|
|
46
|
+
if (target.includes("...")) {
|
|
47
|
+
let position = 0;
|
|
48
|
+
for (const segment of target.split("...")) {
|
|
49
|
+
position = source.indexOf(segment, position);
|
|
50
|
+
if (position === -1) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return position > 0;
|
|
55
|
+
}
|
|
56
|
+
return source.includes(target);
|
|
57
|
+
}
|
|
58
|
+
#onDiagnostics(diagnostic, result) {
|
|
59
|
+
EventEmitter.dispatch(["suppressed:error", { diagnostics: [diagnostic], result }]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SuppressedService } from "./SuppressedService.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SuppressedService } from "./SuppressedService.js";
|
package/dist/tag.d.ts
CHANGED
|
@@ -3,6 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns A promise that resolves if the test run is successful and rejects if it fails.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { tstyche as default };
|
|
6
|
+
export default function tstyche(template: TemplateStringsArray, ...substitutions: Array<string>): Promise<void>;
|
package/dist/tag.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Cli } from
|
|
2
|
-
|
|
3
|
-
async function tstyche(template, ...substitutions) {
|
|
1
|
+
import { Cli } from "./api.js";
|
|
2
|
+
export default async function tstyche(template, ...substitutions) {
|
|
4
3
|
const cli = new Cli();
|
|
5
4
|
const commandLine = String.raw(template, ...substitutions).split(/\s+/);
|
|
6
5
|
const exitCode = await cli.run(commandLine);
|
|
@@ -8,5 +7,3 @@ async function tstyche(template, ...substitutions) {
|
|
|
8
7
|
throw new Error("TSTyche test run failed. Check the output above for details.");
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
export { tstyche as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class TextFile {
|
|
2
|
+
path;
|
|
3
|
+
#lineMap;
|
|
4
|
+
text;
|
|
5
|
+
constructor(path, text) {
|
|
6
|
+
this.path = path;
|
|
7
|
+
this.text = text;
|
|
8
|
+
}
|
|
9
|
+
#createLineMap() {
|
|
10
|
+
const result = [0];
|
|
11
|
+
let position = 0;
|
|
12
|
+
while (position < this.text.length) {
|
|
13
|
+
const character = this.text.charAt(position);
|
|
14
|
+
switch (character) {
|
|
15
|
+
case "\n":
|
|
16
|
+
result.push(position + 1);
|
|
17
|
+
break;
|
|
18
|
+
case "\r":
|
|
19
|
+
if (this.text.charAt(position + 1) === "\n") {
|
|
20
|
+
result.push(position + 2);
|
|
21
|
+
position++;
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
position++;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
getLineMap() {
|
|
30
|
+
if (!this.#lineMap) {
|
|
31
|
+
this.#lineMap = this.#createLineMap();
|
|
32
|
+
}
|
|
33
|
+
return this.#lineMap;
|
|
34
|
+
}
|
|
35
|
+
getLocation(position) {
|
|
36
|
+
const lineMap = this.getLineMap();
|
|
37
|
+
const line = lineMap.findLastIndex((line) => line <= position);
|
|
38
|
+
const character = position - lineMap[line];
|
|
39
|
+
return { line, character };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as tsApi from "typescript/sync";
|
|
2
|
+
import type * as ts from "#typescript";
|
|
3
|
+
import { TextFile } from "./TextFile.js";
|
|
4
|
+
export declare class TextFileService {
|
|
5
|
+
#private;
|
|
6
|
+
static close(): void;
|
|
7
|
+
static get(sourceFile: ts.SourceFile | string): TextFile;
|
|
8
|
+
static open(program: tsApi.Program): void;
|
|
9
|
+
static set(filePath: string, file: TextFile): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TextFile } from "./TextFile.js";
|
|
2
|
+
export class TextFileService {
|
|
3
|
+
static #fileCache = new Map();
|
|
4
|
+
static #program;
|
|
5
|
+
static close() {
|
|
6
|
+
TextFileService.#fileCache.clear();
|
|
7
|
+
TextFileService.#program = undefined;
|
|
8
|
+
}
|
|
9
|
+
static get(sourceFile) {
|
|
10
|
+
const filePath = typeof sourceFile === "string" ? sourceFile : sourceFile.fileName;
|
|
11
|
+
let file = TextFileService.#fileCache.get(filePath);
|
|
12
|
+
if (!file) {
|
|
13
|
+
if (typeof sourceFile === "string") {
|
|
14
|
+
const text = TextFileService.#program?.getSourceFile(filePath)?.text ??
|
|
15
|
+
TextFileService.#program?.getConfigSourceFile(filePath)?.text;
|
|
16
|
+
file = new TextFile(filePath, text);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
file = new TextFile(filePath, sourceFile.text);
|
|
20
|
+
}
|
|
21
|
+
TextFileService.#fileCache.set(filePath, file);
|
|
22
|
+
}
|
|
23
|
+
return file;
|
|
24
|
+
}
|
|
25
|
+
static open(program) {
|
|
26
|
+
TextFileService.#program = program;
|
|
27
|
+
}
|
|
28
|
+
static set(filePath, file) {
|
|
29
|
+
TextFileService.#fileCache.set(filePath, file);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var CancellationReason;
|
|
2
|
+
(function (CancellationReason) {
|
|
3
|
+
CancellationReason["ConfigChange"] = "configChange";
|
|
4
|
+
CancellationReason["ConfigError"] = "configError";
|
|
5
|
+
CancellationReason["FailFast"] = "failFast";
|
|
6
|
+
CancellationReason["WatchClose"] = "watchClose";
|
|
7
|
+
})(CancellationReason || (CancellationReason = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CancellationReason } from "./CancellationReason.enum.js";
|
|
2
|
+
export declare class CancellationToken {
|
|
3
|
+
#private;
|
|
4
|
+
cancel(reason: CancellationReason): void;
|
|
5
|
+
isCancellationRequested(): boolean;
|
|
6
|
+
getReason(): CancellationReason | undefined;
|
|
7
|
+
reset(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class CancellationToken {
|
|
2
|
+
#isCancelled = false;
|
|
3
|
+
#reason;
|
|
4
|
+
cancel(reason) {
|
|
5
|
+
if (!this.#isCancelled) {
|
|
6
|
+
this.#isCancelled = true;
|
|
7
|
+
this.#reason = reason;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
isCancellationRequested() {
|
|
11
|
+
return this.#isCancelled;
|
|
12
|
+
}
|
|
13
|
+
getReason() {
|
|
14
|
+
return this.#reason;
|
|
15
|
+
}
|
|
16
|
+
reset() {
|
|
17
|
+
if (this.#isCancelled) {
|
|
18
|
+
this.#isCancelled = false;
|
|
19
|
+
this.#reason = undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CallExpression, Decorator, ExpressionStatement, ExpressionWithTypeArguments, Identifier, ImportDeclaration, NamedImports, NamespaceImport, Node, NumericLiteral, ObjectLiteralExpression, ParameterDeclaration, ParenthesizedExpression, PropertyAccessExpression, PropertyAssignment, RegularExpressionLiteral, SourceFile, SpreadAssignment, StringLiteral, StringLiteralLikeNode, TupleTypeNode, TypeParameterDeclaration, TypeReferenceNode } from "./types.js";
|
|
2
|
+
export declare abstract class BaseAdapter {
|
|
3
|
+
abstract LanguageVariant: any;
|
|
4
|
+
abstract ModifierFlags: any;
|
|
5
|
+
abstract ObjectFlags: any;
|
|
6
|
+
abstract SignatureKind: any;
|
|
7
|
+
abstract SymbolFlags: any;
|
|
8
|
+
abstract SyntaxKind: any;
|
|
9
|
+
abstract TypeFlags: any;
|
|
10
|
+
isCallExpression(node: Node): node is CallExpression;
|
|
11
|
+
isDecorator(node: Node): node is Decorator;
|
|
12
|
+
isExpressionStatement(node: Node): node is ExpressionStatement;
|
|
13
|
+
isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments;
|
|
14
|
+
isIdentifier(node: Node): node is Identifier;
|
|
15
|
+
isImportDeclaration(node: Node): node is ImportDeclaration;
|
|
16
|
+
isNamedImports(node: Node): node is NamedImports;
|
|
17
|
+
isNamespaceImport(node: Node): node is NamespaceImport;
|
|
18
|
+
isNumericLiteral(node: Node): node is NumericLiteral;
|
|
19
|
+
isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression;
|
|
20
|
+
isParameterDeclaration(node: Node): node is ParameterDeclaration;
|
|
21
|
+
isParenthesizedExpression(node: Node): node is ParenthesizedExpression;
|
|
22
|
+
isPropertyAccessExpression(node: Node): node is PropertyAccessExpression;
|
|
23
|
+
isPropertyAssignment(node: Node): node is PropertyAssignment;
|
|
24
|
+
isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral;
|
|
25
|
+
isSourceFile(node: Node): node is SourceFile;
|
|
26
|
+
isSpreadAssignment(node: Node): node is SpreadAssignment;
|
|
27
|
+
isStringLiteral(node: Node): node is StringLiteral;
|
|
28
|
+
isStringLiteralLikeNode(node: Node): node is StringLiteralLikeNode;
|
|
29
|
+
isTupleTypeNode(node: Node): node is TupleTypeNode;
|
|
30
|
+
isTypeReferenceNode(node: Node): node is TypeReferenceNode;
|
|
31
|
+
isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration;
|
|
32
|
+
belongsToArgumentList(node: Node): boolean;
|
|
33
|
+
isCapitaizedIdentifierLike(node: Node): boolean;
|
|
34
|
+
isChildOfExpressionStatement(node: Node): boolean;
|
|
35
|
+
isIdentifierLike(node: Node): boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export class BaseAdapter {
|
|
2
|
+
isCallExpression(node) {
|
|
3
|
+
return node.kind === this.SyntaxKind.CallExpression;
|
|
4
|
+
}
|
|
5
|
+
isDecorator(node) {
|
|
6
|
+
return node.kind === this.SyntaxKind.Decorator;
|
|
7
|
+
}
|
|
8
|
+
isExpressionStatement(node) {
|
|
9
|
+
return node.kind === this.SyntaxKind.ExpressionStatement;
|
|
10
|
+
}
|
|
11
|
+
isExpressionWithTypeArguments(node) {
|
|
12
|
+
return node.kind === this.SyntaxKind.ExpressionWithTypeArguments;
|
|
13
|
+
}
|
|
14
|
+
isIdentifier(node) {
|
|
15
|
+
return node.kind === this.SyntaxKind.Identifier;
|
|
16
|
+
}
|
|
17
|
+
isImportDeclaration(node) {
|
|
18
|
+
return node.kind === this.SyntaxKind.ImportDeclaration;
|
|
19
|
+
}
|
|
20
|
+
isNamedImports(node) {
|
|
21
|
+
return node.kind === this.SyntaxKind.NamedImports;
|
|
22
|
+
}
|
|
23
|
+
isNamespaceImport(node) {
|
|
24
|
+
return node.kind === this.SyntaxKind.NamespaceImport;
|
|
25
|
+
}
|
|
26
|
+
isNumericLiteral(node) {
|
|
27
|
+
return node.kind === this.SyntaxKind.NumericLiteral;
|
|
28
|
+
}
|
|
29
|
+
isObjectLiteralExpression(node) {
|
|
30
|
+
return node.kind === this.SyntaxKind.ObjectLiteralExpression;
|
|
31
|
+
}
|
|
32
|
+
isParameterDeclaration(node) {
|
|
33
|
+
return node.kind === this.SyntaxKind.Parameter;
|
|
34
|
+
}
|
|
35
|
+
isParenthesizedExpression(node) {
|
|
36
|
+
return node.kind === this.SyntaxKind.ParenthesizedExpression;
|
|
37
|
+
}
|
|
38
|
+
isPropertyAccessExpression(node) {
|
|
39
|
+
return node.kind === this.SyntaxKind.PropertyAccessExpression;
|
|
40
|
+
}
|
|
41
|
+
isPropertyAssignment(node) {
|
|
42
|
+
return node.kind === this.SyntaxKind.PropertyAssignment;
|
|
43
|
+
}
|
|
44
|
+
isRegularExpressionLiteral(node) {
|
|
45
|
+
return node.kind === this.SyntaxKind.RegularExpressionLiteral;
|
|
46
|
+
}
|
|
47
|
+
isSourceFile(node) {
|
|
48
|
+
return node.kind === this.SyntaxKind.SourceFile;
|
|
49
|
+
}
|
|
50
|
+
isSpreadAssignment(node) {
|
|
51
|
+
return node.kind === this.SyntaxKind.SpreadAssignment;
|
|
52
|
+
}
|
|
53
|
+
isStringLiteral(node) {
|
|
54
|
+
return node.kind === this.SyntaxKind.StringLiteral;
|
|
55
|
+
}
|
|
56
|
+
isStringLiteralLikeNode(node) {
|
|
57
|
+
return node.kind === this.SyntaxKind.StringLiteral || node.kind === this.SyntaxKind.NoSubstitutionTemplateLiteral;
|
|
58
|
+
}
|
|
59
|
+
isTupleTypeNode(node) {
|
|
60
|
+
return node.kind === this.SyntaxKind.TupleType;
|
|
61
|
+
}
|
|
62
|
+
isTypeReferenceNode(node) {
|
|
63
|
+
return node.kind === this.SyntaxKind.TypeReference;
|
|
64
|
+
}
|
|
65
|
+
isTypeParameterDeclaration(node) {
|
|
66
|
+
return node.kind === this.SyntaxKind.TypeParameter;
|
|
67
|
+
}
|
|
68
|
+
belongsToArgumentList(node) {
|
|
69
|
+
return this.isCallExpression(node.parent) && node.parent.arguments.some((argument) => argument === node);
|
|
70
|
+
}
|
|
71
|
+
isCapitaizedIdentifierLike(node) {
|
|
72
|
+
return this.isIdentifierLike(node) && /^[A-Z_$]/.test(node.getText());
|
|
73
|
+
}
|
|
74
|
+
isChildOfExpressionStatement(node) {
|
|
75
|
+
return this.isExpressionStatement(node.parent);
|
|
76
|
+
}
|
|
77
|
+
isIdentifierLike(node) {
|
|
78
|
+
return (this.isIdentifier(node) ||
|
|
79
|
+
this.isPropertyAccessExpression(node) ||
|
|
80
|
+
this.isTypeReferenceNode(node) ||
|
|
81
|
+
this.isExpressionWithTypeArguments(node));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type ts6 from "@typescript/typescript6";
|
|
2
|
+
import type { ResolvedConfig } from "#config";
|
|
3
|
+
import { CompatProjectService } from "#project";
|
|
4
|
+
import { BaseAdapter } from "./BaseAdapter.js";
|
|
5
|
+
import type { CallbackFunction, ImportDeclaration, Node } from "./types.js";
|
|
6
|
+
export declare class CompatTypeScript extends BaseAdapter {
|
|
7
|
+
#private;
|
|
8
|
+
version: string;
|
|
9
|
+
LanguageVariant: typeof ts6.LanguageVariant;
|
|
10
|
+
ModifierFlags: typeof ts6.ModifierFlags;
|
|
11
|
+
ObjectFlags: typeof ts6.ObjectFlags;
|
|
12
|
+
SignatureKind: typeof ts6.SignatureKind;
|
|
13
|
+
SymbolFlags: typeof ts6.SymbolFlags;
|
|
14
|
+
SyntaxKind: typeof ts6.SyntaxKind;
|
|
15
|
+
TypeFlags: typeof ts6.TypeFlags;
|
|
16
|
+
constructor(compiler: typeof ts6, version: string);
|
|
17
|
+
getLeadingCommentRanges(text: string, pos: number): ts6.CommentRange[] | undefined;
|
|
18
|
+
getProjectService(resolvedConfig: ResolvedConfig): CompatProjectService;
|
|
19
|
+
isCallbackFunction(node: Node): node is CallbackFunction;
|
|
20
|
+
isTypeOnlyImportDeclaration(node: ImportDeclaration): boolean;
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CompatProjectService } from "#project";
|
|
2
|
+
import { BaseAdapter } from "./BaseAdapter.js";
|
|
3
|
+
export class CompatTypeScript extends BaseAdapter {
|
|
4
|
+
#compiler;
|
|
5
|
+
version;
|
|
6
|
+
LanguageVariant;
|
|
7
|
+
ModifierFlags;
|
|
8
|
+
ObjectFlags;
|
|
9
|
+
SignatureKind;
|
|
10
|
+
SymbolFlags;
|
|
11
|
+
SyntaxKind;
|
|
12
|
+
TypeFlags;
|
|
13
|
+
constructor(compiler, version) {
|
|
14
|
+
super();
|
|
15
|
+
this.#compiler = compiler;
|
|
16
|
+
this.version = version;
|
|
17
|
+
this.LanguageVariant = compiler.LanguageVariant;
|
|
18
|
+
this.ModifierFlags = compiler.ModifierFlags;
|
|
19
|
+
this.ObjectFlags = compiler.ObjectFlags;
|
|
20
|
+
this.SignatureKind = compiler.SignatureKind;
|
|
21
|
+
this.SymbolFlags = compiler.SymbolFlags;
|
|
22
|
+
this.SyntaxKind = compiler.SyntaxKind;
|
|
23
|
+
this.TypeFlags = compiler.TypeFlags;
|
|
24
|
+
}
|
|
25
|
+
getLeadingCommentRanges(text, pos) {
|
|
26
|
+
return this.#compiler.getLeadingCommentRanges(text, pos);
|
|
27
|
+
}
|
|
28
|
+
getProjectService(resolvedConfig) {
|
|
29
|
+
return new CompatProjectService(this.#compiler, resolvedConfig);
|
|
30
|
+
}
|
|
31
|
+
isCallbackFunction(node) {
|
|
32
|
+
return this.#compiler.isArrowFunction(node) || this.#compiler.isFunctionExpression(node);
|
|
33
|
+
}
|
|
34
|
+
isTypeOnlyImportDeclaration(node) {
|
|
35
|
+
return node.importClause?.isTypeOnly === true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as tsAst from "typescript/ast";
|
|
2
|
+
import type * as tsApi from "typescript/sync";
|
|
3
|
+
import type { ResolvedConfig } from "#config";
|
|
4
|
+
import { NativeProjectService } from "#project";
|
|
5
|
+
import { BaseAdapter } from "./BaseAdapter.js";
|
|
6
|
+
import type { CallbackFunction, ImportDeclaration, Node } from "./types.js";
|
|
7
|
+
export declare class NativeTypeScript extends BaseAdapter {
|
|
8
|
+
#private;
|
|
9
|
+
version: string;
|
|
10
|
+
ElementFlags: typeof tsApi.ElementFlags;
|
|
11
|
+
LanguageVariant: typeof tsAst.LanguageVariant;
|
|
12
|
+
ModifierFlags: typeof tsApi.ModifierFlags;
|
|
13
|
+
ObjectFlags: typeof tsApi.ObjectFlags;
|
|
14
|
+
SignatureKind: typeof tsApi.SignatureKind;
|
|
15
|
+
SymbolFlags: typeof tsApi.SymbolFlags;
|
|
16
|
+
SyntaxKind: typeof tsAst.SyntaxKind;
|
|
17
|
+
TypeFlags: typeof tsApi.TypeFlags;
|
|
18
|
+
constructor(api: typeof tsApi, ast: typeof tsAst, version: string);
|
|
19
|
+
getApi(): tsApi.API<false>;
|
|
20
|
+
getLeadingCommentRanges(text: string, pos: number): Array<tsAst.CommentRange> | undefined;
|
|
21
|
+
getProjectService(resolvedConfig: ResolvedConfig): NativeProjectService;
|
|
22
|
+
isCallbackFunction(node: Node): node is CallbackFunction;
|
|
23
|
+
isTypeOnlyImportDeclaration(node: ImportDeclaration): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NativeProjectService } from "#project";
|
|
2
|
+
import { BaseAdapter } from "./BaseAdapter.js";
|
|
3
|
+
export class NativeTypeScript extends BaseAdapter {
|
|
4
|
+
#api;
|
|
5
|
+
#ast;
|
|
6
|
+
version;
|
|
7
|
+
ElementFlags;
|
|
8
|
+
LanguageVariant;
|
|
9
|
+
ModifierFlags;
|
|
10
|
+
ObjectFlags;
|
|
11
|
+
SignatureKind;
|
|
12
|
+
SymbolFlags;
|
|
13
|
+
SyntaxKind;
|
|
14
|
+
TypeFlags;
|
|
15
|
+
constructor(api, ast, version) {
|
|
16
|
+
super();
|
|
17
|
+
this.#api = api;
|
|
18
|
+
this.#ast = ast;
|
|
19
|
+
this.version = version;
|
|
20
|
+
this.ElementFlags = api.ElementFlags;
|
|
21
|
+
this.LanguageVariant = ast.LanguageVariant;
|
|
22
|
+
this.ModifierFlags = api.ModifierFlags;
|
|
23
|
+
this.ObjectFlags = api.ObjectFlags;
|
|
24
|
+
this.SignatureKind = api.SignatureKind;
|
|
25
|
+
this.SymbolFlags = api.SymbolFlags;
|
|
26
|
+
this.SyntaxKind = ast.SyntaxKind;
|
|
27
|
+
this.TypeFlags = api.TypeFlags;
|
|
28
|
+
}
|
|
29
|
+
getApi() {
|
|
30
|
+
return new this.#api.API({ runExternalCode: true });
|
|
31
|
+
}
|
|
32
|
+
getLeadingCommentRanges(text, pos) {
|
|
33
|
+
return this.#ast.getLeadingCommentRanges(text, pos);
|
|
34
|
+
}
|
|
35
|
+
getProjectService(resolvedConfig) {
|
|
36
|
+
return new NativeProjectService(this, resolvedConfig);
|
|
37
|
+
}
|
|
38
|
+
isCallbackFunction(node) {
|
|
39
|
+
return this.#ast.isArrowFunction(node) || this.#ast.isFunctionExpression(node);
|
|
40
|
+
}
|
|
41
|
+
isTypeOnlyImportDeclaration(node) {
|
|
42
|
+
return node.importClause?.phaseModifier === this.SyntaxKind.TypeKeyword;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CompatTypeScript } from "./CompatTypeScript.js";
|
|
2
|
+
export { NativeTypeScript } from "./NativeTypeScript.js";
|
|
3
|
+
export type { CallExpression, CommentRange, CompilerOptions, ConditionalType, Declaration, Decorator, Diagnostic, DiagnosticLocation, DiagnosticPosition, Expression, FreshableType, GenericType, Identifier, ImportDeclaration, IndexedAccessType, IndexInfo, IndexType, IntersectionType, LiteralType, ModifierFlags, Node, NodeArray, NumberLiteralType, NumericLiteral, ObjectType, Program, PropertyAccessExpression, PropertyDeclaration, RegularExpressionLiteral, Signature, SignatureKind, SourceFile, StringLiteralLikeNode, StringLiteralType, StringMappingType, StructuredType, SubstitutionType, Symbol, TemplateLiteralType, TupleType, TupleTypeNode, TupleTypeReference, Type, TypeNode, TypeParameter, TypeParameterDeclaration, TypePredicate, TypeReference, TypeScript, UnionType, } from "./types.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type ts6 from "@typescript/typescript6";
|
|
2
|
+
import type * as tsAst from "typescript/ast";
|
|
3
|
+
import type * as tsApi from "typescript/sync";
|
|
4
|
+
import type { CompatTypeScript } from "./CompatTypeScript.js";
|
|
5
|
+
import type { NativeTypeScript } from "./NativeTypeScript.js";
|
|
6
|
+
export type CallExpression = tsAst.CallExpression | ts6.CallExpression;
|
|
7
|
+
export type CallbackFunction = (tsAst.ArrowFunction | tsAst.FunctionExpression) | (ts6.ArrowFunction | ts6.FunctionExpression);
|
|
8
|
+
export type CommentRange = tsAst.CommentRange | ts6.CommentRange;
|
|
9
|
+
export type CompilerOptions = tsApi.CompilerOptions | ts6.CompilerOptions;
|
|
10
|
+
export type ConditionalType = tsApi.ConditionalType | ts6.ConditionalType;
|
|
11
|
+
export type Declaration = tsAst.Declaration | ts6.Declaration;
|
|
12
|
+
export type Decorator = tsAst.Decorator | ts6.Decorator;
|
|
13
|
+
export type Diagnostic = tsApi.Diagnostic | ts6.Diagnostic;
|
|
14
|
+
export type DiagnosticLocation = ts6.DiagnosticWithLocation;
|
|
15
|
+
export type DiagnosticPosition = tsApi.Diagnostic & {
|
|
16
|
+
fileName: string;
|
|
17
|
+
};
|
|
18
|
+
export type Expression = tsAst.Expression | ts6.Expression;
|
|
19
|
+
export type ExpressionStatement = tsAst.ExpressionStatement | ts6.ExpressionStatement;
|
|
20
|
+
export type ExpressionWithTypeArguments = tsAst.ExpressionWithTypeArguments | ts6.ExpressionWithTypeArguments;
|
|
21
|
+
export type FreshableType = tsApi.FreshableType | ts6.FreshableType;
|
|
22
|
+
export type GenericType = tsApi.GenericType | ts6.GenericType;
|
|
23
|
+
export type Identifier = tsAst.Identifier | ts6.Identifier;
|
|
24
|
+
export type ImportDeclaration = tsAst.ImportDeclaration | ts6.ImportDeclaration;
|
|
25
|
+
export type IndexedAccessType = tsApi.IndexedAccessType | ts6.IndexedAccessType;
|
|
26
|
+
export type IndexInfo = tsApi.IndexInfo | ts6.IndexInfo;
|
|
27
|
+
export type IndexType = tsApi.IndexType | ts6.IndexType;
|
|
28
|
+
export type IntersectionType = tsApi.IntersectionType | ts6.IntersectionType;
|
|
29
|
+
export type LiteralType = tsApi.LiteralType | ts6.LiteralType;
|
|
30
|
+
export type ModifierFlags = tsApi.ModifierFlags | ts6.ModifierFlags;
|
|
31
|
+
export type NamespaceImport = tsAst.NamespaceImport | ts6.NamespaceImport;
|
|
32
|
+
export type NamedImports = tsAst.NamedImports | ts6.NamedImports;
|
|
33
|
+
export type Node = tsAst.Node | ts6.Node;
|
|
34
|
+
export type NodeArray<T extends Node> = T extends tsAst.Node ? tsAst.NodeArray<T> : T extends ts6.Node ? ts6.NodeArray<T> : never;
|
|
35
|
+
export type NumericLiteral = tsAst.NumericLiteral | ts6.NumericLiteral;
|
|
36
|
+
export type NumberLiteralType = tsApi.NumberLiteralType | ts6.NumberLiteralType;
|
|
37
|
+
export type ObjectType = tsApi.ObjectType | ts6.ObjectType;
|
|
38
|
+
export type ObjectLiteralExpression = tsAst.ObjectLiteralExpression | ts6.ObjectLiteralExpression;
|
|
39
|
+
export type ParameterDeclaration = tsAst.ParameterDeclaration | ts6.ParameterDeclaration;
|
|
40
|
+
export type ParenthesizedExpression = tsAst.ParenthesizedExpression | ts6.ParenthesizedExpression;
|
|
41
|
+
export type Program = tsApi.Program | ts6.Program;
|
|
42
|
+
export type PropertyAccessExpression = tsAst.PropertyAccessExpression | ts6.PropertyAccessExpression;
|
|
43
|
+
export type PropertyDeclaration = tsAst.PropertyDeclaration | ts6.PropertyDeclaration;
|
|
44
|
+
export type PropertyAssignment = tsAst.PropertyAssignment | ts6.PropertyAssignment;
|
|
45
|
+
export type RegularExpressionLiteral = tsAst.RegularExpressionLiteral | ts6.RegularExpressionLiteral;
|
|
46
|
+
export type Signature = tsApi.Signature | ts6.Signature;
|
|
47
|
+
export type SignatureKind = tsApi.SignatureKind | ts6.SignatureKind;
|
|
48
|
+
export type SourceFile = tsAst.SourceFile | ts6.SourceFile;
|
|
49
|
+
export type SpreadAssignment = tsAst.SpreadAssignment | ts6.SpreadAssignment;
|
|
50
|
+
export type StringLiteral = tsAst.StringLiteral | ts6.StringLiteral;
|
|
51
|
+
export type StringLiteralLikeNode = tsAst.StringLiteralLikeNode | ts6.StringLiteralLike;
|
|
52
|
+
export type StringLiteralType = tsApi.StringLiteralType | ts6.StringLiteralType;
|
|
53
|
+
export type StringMappingType = tsApi.StringMappingType | ts6.StringMappingType;
|
|
54
|
+
export type StructuredType = tsApi.StructuredType | ts6.StructuredType;
|
|
55
|
+
export type SubstitutionType = tsApi.SubstitutionType | ts6.SubstitutionType;
|
|
56
|
+
export type Symbol = tsApi.Symbol | ts6.Symbol;
|
|
57
|
+
export type TemplateLiteralType = tsApi.TemplateLiteralType | ts6.TemplateLiteralType;
|
|
58
|
+
export type TupleType = tsApi.TupleType | ts6.TupleType;
|
|
59
|
+
export type TupleTypeNode = tsAst.TupleTypeNode | ts6.TupleTypeNode;
|
|
60
|
+
export type TupleTypeReference = tsApi.TupleTypeReference | ts6.TupleTypeReference;
|
|
61
|
+
export type Type = tsApi.Type | ts6.Type;
|
|
62
|
+
export type TypeNode = tsAst.TypeNode | ts6.TypeNode;
|
|
63
|
+
export type TypeParameter = tsApi.TypeParameter | ts6.TypeParameter;
|
|
64
|
+
export type TypeParameterDeclaration = tsAst.TypeParameterDeclaration | ts6.TypeParameterDeclaration;
|
|
65
|
+
export type TypePredicate = tsApi.TypePredicate | ts6.TypePredicate;
|
|
66
|
+
export type TypeReference = tsApi.TypeReference | ts6.TypeReference;
|
|
67
|
+
export type TypeReferenceNode = tsAst.TypeReferenceNode | ts6.TypeReferenceNode;
|
|
68
|
+
export type UnionType = tsApi.UnionType | ts6.UnionType;
|
|
69
|
+
export type TypeScript = NativeTypeScript | CompatTypeScript;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class Version {
|
|
2
|
+
static isGreaterThan(source, target) {
|
|
3
|
+
return !(source === target) && Version.#satisfies(source, target);
|
|
4
|
+
}
|
|
5
|
+
static isIncluded(source, range) {
|
|
6
|
+
return range.some((target) => source.startsWith(target));
|
|
7
|
+
}
|
|
8
|
+
static isSatisfiedWith(source, target) {
|
|
9
|
+
return source === target || Version.#satisfies(source, target);
|
|
10
|
+
}
|
|
11
|
+
static #satisfies(source, target) {
|
|
12
|
+
const sourceElements = source.split(/\.|-/);
|
|
13
|
+
const targetElements = target.split(/\.|-/);
|
|
14
|
+
function compare(index = 0) {
|
|
15
|
+
const sourceElement = sourceElements[index];
|
|
16
|
+
const targetElement = targetElements[index];
|
|
17
|
+
if (sourceElement > targetElement) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (sourceElement < targetElement) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (index === sourceElements.length - 1 || index === targetElements.length - 1) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return compare(index + 1);
|
|
27
|
+
}
|
|
28
|
+
return compare();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Version } from "./Version.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Version } from "./Version.js";
|