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,56 @@
|
|
|
1
|
+
export class TarReader {
|
|
2
|
+
#leftover = new Uint8Array(0);
|
|
3
|
+
#reader;
|
|
4
|
+
#textDecoder = new TextDecoder();
|
|
5
|
+
constructor(stream) {
|
|
6
|
+
this.#reader = stream.getReader();
|
|
7
|
+
}
|
|
8
|
+
async *extract() {
|
|
9
|
+
while (true) {
|
|
10
|
+
const header = await this.#read(512);
|
|
11
|
+
if (this.#isEndOfArchive(header)) {
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
const name = this.#textDecoder.decode(header.subarray(0, 100)).replace(/\0.*$/, "");
|
|
15
|
+
const mode = Number.parseInt(this.#textDecoder.decode(header.subarray(100, 108)).replace(/\0.*$/, "").trim(), 8);
|
|
16
|
+
const sizeOctal = this.#textDecoder.decode(header.subarray(124, 136)).replace(/\0.*$/, "").trim();
|
|
17
|
+
const size = Number.parseInt(sizeOctal, 8);
|
|
18
|
+
const content = await this.#read(size);
|
|
19
|
+
yield { name, mode, content };
|
|
20
|
+
if (size % 512 !== 0) {
|
|
21
|
+
const toSkip = 512 - (size % 512);
|
|
22
|
+
await this.#read(toSkip);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
#isEndOfArchive(entry) {
|
|
27
|
+
return entry.every((byte) => byte === 0);
|
|
28
|
+
}
|
|
29
|
+
async #read(n) {
|
|
30
|
+
const result = new Uint8Array(n);
|
|
31
|
+
let filled = 0;
|
|
32
|
+
if (this.#leftover.length > 0) {
|
|
33
|
+
const toCopy = Math.min(this.#leftover.length, n);
|
|
34
|
+
result.set(this.#leftover.subarray(0, toCopy), filled);
|
|
35
|
+
filled += toCopy;
|
|
36
|
+
this.#leftover = this.#leftover.subarray(toCopy);
|
|
37
|
+
if (filled === n) {
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
while (filled < n) {
|
|
42
|
+
const { value, done } = await this.#reader.read();
|
|
43
|
+
if (done) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
const toCopy = Math.min(value.length, n - filled);
|
|
47
|
+
result.set(value.subarray(0, toCopy), filled);
|
|
48
|
+
filled += toCopy;
|
|
49
|
+
if (toCopy < value.length) {
|
|
50
|
+
this.#leftover = value.subarray(toCopy);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result.subarray(0, filled);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(delay: number): Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Store } from "./Store.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Store } from "./Store.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var ComparisonResult;
|
|
2
|
+
(function (ComparisonResult) {
|
|
3
|
+
ComparisonResult[ComparisonResult["Pending"] = 0] = "Pending";
|
|
4
|
+
ComparisonResult[ComparisonResult["Identical"] = 1] = "Identical";
|
|
5
|
+
ComparisonResult[ComparisonResult["Different"] = 2] = "Different";
|
|
6
|
+
})(ComparisonResult || (ComparisonResult = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Checker } from "#checker";
|
|
2
|
+
import type * as ts from "#typescript";
|
|
3
|
+
export declare class Structure {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(ts: ts.TypeScript, program: ts.Program, checker: Checker);
|
|
6
|
+
compare(a: ts.Type, b: ts.Type): boolean;
|
|
7
|
+
compareStructured(a: ts.StructuredType, b: ts.StructuredType): boolean;
|
|
8
|
+
compareInstantiable(a: ts.Type, b: ts.Type): boolean;
|
|
9
|
+
compareIntersections(a: ts.IntersectionType, b: ts.IntersectionType): boolean;
|
|
10
|
+
compareUnions(a: ts.UnionType, b: ts.UnionType): boolean;
|
|
11
|
+
compareObjects(a: ts.ObjectType, b: ts.ObjectType): boolean;
|
|
12
|
+
compareTypeReferences(a: ts.TypeReference, b: ts.TypeReference): boolean;
|
|
13
|
+
compareTuples(a: ts.TupleTypeReference, b: ts.TupleTypeReference): boolean;
|
|
14
|
+
compareStructures(a: ts.Type, b: ts.Type): boolean;
|
|
15
|
+
compareProperties(a: ts.Type, b: ts.Type): boolean;
|
|
16
|
+
compareSignatures(a: ts.Type, b: ts.Type, kind: ts.SignatureKind): boolean;
|
|
17
|
+
compareIndexSignatures(a: ts.Type, b: ts.Type): boolean;
|
|
18
|
+
compareTypeParameters(a: ts.TypeParameter, b: ts.TypeParameter): boolean;
|
|
19
|
+
compareIndexedAccessTypes(a: ts.IndexedAccessType, b: ts.IndexedAccessType): boolean;
|
|
20
|
+
compareConditionalTypes(a: ts.ConditionalType, b: ts.ConditionalType): boolean;
|
|
21
|
+
compareSubstitutionTypes(a: ts.SubstitutionType, b: ts.SubstitutionType): boolean;
|
|
22
|
+
compareTemplateLiteralTypes(a: ts.TemplateLiteralType, b: ts.TemplateLiteralType): boolean;
|
|
23
|
+
compareStringMappingTypes(a: ts.StringMappingType, b: ts.StringMappingType): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
export class Structure {
|
|
2
|
+
#checker;
|
|
3
|
+
#compilerOptions;
|
|
4
|
+
#ts;
|
|
5
|
+
#deduplicateCache = new WeakMap();
|
|
6
|
+
#memoizeCache = new Map();
|
|
7
|
+
#recursionStack = [];
|
|
8
|
+
#unusedTypeParametersLookup = new WeakMap();
|
|
9
|
+
constructor(ts, program, checker) {
|
|
10
|
+
this.#ts = ts;
|
|
11
|
+
this.#checker = checker;
|
|
12
|
+
this.#compilerOptions = program.getCompilerOptions();
|
|
13
|
+
}
|
|
14
|
+
#compareMaybeNullish(a, b) {
|
|
15
|
+
if (a != null && b != null) {
|
|
16
|
+
return this.compare(a, b);
|
|
17
|
+
}
|
|
18
|
+
return !a && !b;
|
|
19
|
+
}
|
|
20
|
+
compare(a, b) {
|
|
21
|
+
a = this.#normalize(a);
|
|
22
|
+
b = this.#normalize(b);
|
|
23
|
+
if (a === b) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (a.flags & this.#ts.TypeFlags.Any) {
|
|
27
|
+
return !!(b.flags & this.#ts.TypeFlags.Any);
|
|
28
|
+
}
|
|
29
|
+
if (a.flags & this.#ts.TypeFlags.Never) {
|
|
30
|
+
return !!(b.flags & this.#ts.TypeFlags.Never);
|
|
31
|
+
}
|
|
32
|
+
if (a.flags & this.#ts.TypeFlags.Undefined) {
|
|
33
|
+
return !!(b.flags & this.#ts.TypeFlags.Undefined);
|
|
34
|
+
}
|
|
35
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.StructuredType) {
|
|
36
|
+
if (a.flags & this.#ts.TypeFlags.StructuredType && b.flags & this.#ts.TypeFlags.StructuredType) {
|
|
37
|
+
return this.#memoize(a, b, () => this.compareStructured(a, b));
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Instantiable) {
|
|
42
|
+
if (a.flags & this.#ts.TypeFlags.Instantiable && b.flags & this.#ts.TypeFlags.Instantiable) {
|
|
43
|
+
return this.#memoize(a, b, () => this.compareInstantiable(a, b));
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
compareStructured(a, b) {
|
|
50
|
+
if (this.#checker.isTupleType(a) || this.#checker.isTupleType(b)) {
|
|
51
|
+
if (this.#checker.isTupleType(a) && this.#checker.isTupleType(b)) {
|
|
52
|
+
return this.compareTuples(a, b);
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Union) {
|
|
57
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.Union) {
|
|
58
|
+
return this.compareUnions(a, b);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Intersection) {
|
|
63
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.Intersection) {
|
|
64
|
+
if (this.compareIntersections(a, b)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (this.#checker.containsInstantiable(a) || this.#checker.containsInstantiable(b)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Object) {
|
|
73
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.Object) {
|
|
74
|
+
return this.compareObjects(a, b);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return this.compareStructures(a, b);
|
|
78
|
+
}
|
|
79
|
+
compareInstantiable(a, b) {
|
|
80
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.TypeParameter) {
|
|
81
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.TypeParameter) {
|
|
82
|
+
return this.compareTypeParameters(a, b);
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.IndexedAccess) {
|
|
87
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.IndexedAccess) {
|
|
88
|
+
return this.compareIndexedAccessTypes(a, b);
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Conditional) {
|
|
93
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.Conditional) {
|
|
94
|
+
return this.compareConditionalTypes(a, b);
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Substitution) {
|
|
99
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.Substitution) {
|
|
100
|
+
return this.compareSubstitutionTypes(a, b);
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.Index) {
|
|
105
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.Index) {
|
|
106
|
+
return this.compare(this.#checker.indexType.getTarget(a), this.#checker.indexType.getTarget(b));
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.TemplateLiteral) {
|
|
111
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.TemplateLiteral) {
|
|
112
|
+
return this.compareTemplateLiteralTypes(a, b);
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if ((a.flags | b.flags) & this.#ts.TypeFlags.StringMapping) {
|
|
117
|
+
if (a.flags & b.flags & this.#ts.TypeFlags.StringMapping) {
|
|
118
|
+
return this.compareStringMappingTypes(a, b);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
compareIntersections(a, b) {
|
|
124
|
+
const aTypes = this.#deduplicate(a);
|
|
125
|
+
const bTypes = this.#deduplicate(b);
|
|
126
|
+
if (aTypes.length !== bTypes.length) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return aTypes.every((aType, i) => this.compare(aType, bTypes[i]));
|
|
130
|
+
}
|
|
131
|
+
compareUnions(a, b) {
|
|
132
|
+
const aTypes = this.#deduplicate(a);
|
|
133
|
+
const bTypes = this.#deduplicate(b);
|
|
134
|
+
if (aTypes.length !== bTypes.length) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return aTypes.every((aType) => bTypes.some((bType) => this.compare(aType, bType)));
|
|
138
|
+
}
|
|
139
|
+
compareObjects(a, b) {
|
|
140
|
+
if (a.objectFlags & b.objectFlags & this.#ts.ObjectFlags.Reference) {
|
|
141
|
+
if (!((a.objectFlags | b.objectFlags) & this.#ts.ObjectFlags.ClassOrInterface)) {
|
|
142
|
+
return this.compareTypeReferences(a, b);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return this.compareStructures(a, b);
|
|
146
|
+
}
|
|
147
|
+
compareTypeReferences(a, b) {
|
|
148
|
+
if (this.compare(this.#checker.typeReference.getTarget(a), this.#checker.typeReference.getTarget(b))) {
|
|
149
|
+
const aTypeArguments = this.#checker.getTypeArguments(a);
|
|
150
|
+
const bTypeArguments = this.#checker.getTypeArguments(b);
|
|
151
|
+
const unusedTypeParameters = this.#getUnusedTypeParameterIndexes(this.#checker.typeReference.getTarget(a));
|
|
152
|
+
for (let i = 0; i < aTypeArguments.length; i++) {
|
|
153
|
+
if (unusedTypeParameters.has(i)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (!this.compare(aTypeArguments[i], bTypeArguments[i])) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
return this.compareStructures(a, b);
|
|
163
|
+
}
|
|
164
|
+
#getUnusedTypeParameterIndexes(type) {
|
|
165
|
+
const result = new Set();
|
|
166
|
+
const symbol = this.#checker.getSymbol(type);
|
|
167
|
+
const typeParameters = this.#checker.genericType.getTypeParameters(type);
|
|
168
|
+
if (symbol != null) {
|
|
169
|
+
const declarations = this.#checker.getDeclarations(symbol);
|
|
170
|
+
if (declarations != null) {
|
|
171
|
+
const cached = this.#unusedTypeParametersLookup.get(symbol);
|
|
172
|
+
if (cached != null) {
|
|
173
|
+
return cached;
|
|
174
|
+
}
|
|
175
|
+
for (let i = 0; i < typeParameters.length; i++) {
|
|
176
|
+
const symbol = this.#checker.getSymbol(typeParameters[i]);
|
|
177
|
+
const identifier = symbol.declarations[0].name;
|
|
178
|
+
const isUsed = declarations.some((declaration) => this.#isSymbolUsedIn(declaration, symbol, identifier));
|
|
179
|
+
if (!isUsed) {
|
|
180
|
+
result.add(i);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
this.#unusedTypeParametersLookup.set(symbol, result);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
#isSymbolUsedIn(node, symbol, identifier, enclosingNode = node) {
|
|
189
|
+
if (node === identifier || (this.#ts.isTypeParameterDeclaration(node) && node.parent === enclosingNode)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
if (this.#ts.isIdentifier(node) && this.#checker.getSymbolAtLocation(node) === symbol) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
return node.forEachChild((child) => this.#isSymbolUsedIn(child, symbol, identifier, enclosingNode)) ?? false;
|
|
196
|
+
}
|
|
197
|
+
compareTuples(a, b) {
|
|
198
|
+
const aTarget = this.#checker.typeReference.getTarget(a);
|
|
199
|
+
const bTarget = this.#checker.typeReference.getTarget(b);
|
|
200
|
+
if (aTarget.readonly !== bTarget.readonly) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const aTypeArguments = this.#checker.getTypeArguments(a);
|
|
204
|
+
const bTypeArguments = this.#checker.getTypeArguments(b);
|
|
205
|
+
if (aTypeArguments.length !== bTypeArguments.length) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
for (let i = 0; i < aTypeArguments.length; i++) {
|
|
209
|
+
if (aTarget.elementFlags[i] !== bTarget.elementFlags[i]) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
if (!this.compare(aTypeArguments[i], bTypeArguments[i])) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
compareStructures(a, b) {
|
|
219
|
+
if (!this.compareProperties(a, b)) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (!this.compareSignatures(a, b, this.#ts.SignatureKind.Call)) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (!this.compareSignatures(a, b, this.#ts.SignatureKind.Construct)) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (!this.compareIndexSignatures(a, b)) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
compareProperties(a, b) {
|
|
234
|
+
const aProperties = this.#checker.getProperties(a);
|
|
235
|
+
const bProperties = this.#checker.getProperties(b);
|
|
236
|
+
if (aProperties.length !== bProperties.length) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
for (const aProperty of aProperties) {
|
|
240
|
+
const bProperty = bProperties.find((bProperty) => bProperty.escapedName === aProperty.escapedName);
|
|
241
|
+
if (!bProperty) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
if (aProperty === bProperty) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const aAccessibility = this.#checker.getDeclarationModifierFlags(aProperty) & this.#ts.ModifierFlags.NonPublicAccessibilityModifier;
|
|
248
|
+
const bAccessibility = this.#checker.getDeclarationModifierFlags(bProperty) & this.#ts.ModifierFlags.NonPublicAccessibilityModifier;
|
|
249
|
+
if (aAccessibility !== bAccessibility) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (aAccessibility) {
|
|
253
|
+
if (this.#checker.getTargetSymbol(aProperty) !== this.#checker.getTargetSymbol(bProperty)) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (this.#checker.isOptionalProperty(aProperty) !== this.#checker.isOptionalProperty(bProperty)) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
if (this.#checker.isReadonlyProperty(aProperty) !== this.#checker.isReadonlyProperty(bProperty)) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
const aType = this.#checker.getPropertyType(aProperty, this.#compilerOptions);
|
|
264
|
+
const bType = this.#checker.getPropertyType(bProperty, this.#compilerOptions);
|
|
265
|
+
if (!this.compare(aType, bType)) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
compareSignatures(a, b, kind) {
|
|
272
|
+
const aSignatures = this.#checker.getSignatures(a, kind);
|
|
273
|
+
const bSignatures = this.#checker.getSignatures(b, kind);
|
|
274
|
+
if (aSignatures.length !== bSignatures.length) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
for (let i = 0; i < aSignatures.length; i++) {
|
|
278
|
+
const aThisType = this.#checker.signature.getThisParameterType(aSignatures[i]);
|
|
279
|
+
const bThisType = this.#checker.signature.getThisParameterType(bSignatures[i]);
|
|
280
|
+
if (!this.#compareMaybeNullish(aThisType, bThisType)) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
const aParametersCount = this.#checker.getParameterCount(aSignatures[i]);
|
|
284
|
+
const bParametersCount = this.#checker.getParameterCount(bSignatures[i]);
|
|
285
|
+
if (aParametersCount !== bParametersCount) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
for (let j = 0; j < aParametersCount; j++) {
|
|
289
|
+
const aParameter = this.#checker.getParameterFacts(aSignatures[i], j);
|
|
290
|
+
const bParameter = this.#checker.getParameterFacts(bSignatures[i], j);
|
|
291
|
+
if (aParameter.isOptional !== bParameter.isOptional) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (aParameter.isRest !== bParameter.isRest) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
if (!this.compare(aParameter.getType(), bParameter.getType())) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const aReturnType = this.#checker.signature.getReturnType(aSignatures[i]);
|
|
302
|
+
const bReturnType = this.#checker.signature.getReturnType(bSignatures[i]);
|
|
303
|
+
if (!this.compare(aReturnType, bReturnType)) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
const aTypePredicate = this.#checker.signature.getTypePredicate(aSignatures[i]);
|
|
307
|
+
const bTypePredicate = this.#checker.signature.getTypePredicate(bSignatures[i]);
|
|
308
|
+
if (aTypePredicate?.parameterIndex !== bTypePredicate?.parameterIndex) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
if (aTypePredicate?.kind !== bTypePredicate?.kind ||
|
|
312
|
+
!this.#compareMaybeNullish(aTypePredicate?.type, bTypePredicate?.type)) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
compareIndexSignatures(a, b) {
|
|
319
|
+
const aSignatures = this.#checker.getIndexSignatures(a);
|
|
320
|
+
const bSignatures = this.#checker.getIndexSignatures(b);
|
|
321
|
+
if (aSignatures.length !== bSignatures.length) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
return aSignatures.every((aSignature) => {
|
|
325
|
+
return bSignatures.some((bSignature) => {
|
|
326
|
+
if (aSignature.isReadonly !== bSignature.isReadonly) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (!this.compare(aSignature.keyType, bSignature.keyType)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
if (!this.compare("valueType" in aSignature ? aSignature.valueType : aSignature.type, "valueType" in bSignature ? bSignature.valueType : bSignature.type)) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
return true;
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
compareTypeParameters(a, b) {
|
|
340
|
+
if (this.#checker.getTypeParameterModifiers(a) !== this.#checker.getTypeParameterModifiers(b)) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (!this.#compareMaybeNullish(this.#checker.typeParameter.getConstraint(a), this.#checker.typeParameter.getConstraint(b))) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (!this.#compareMaybeNullish(this.#checker.typeParameter.getDefault(a), this.#checker.typeParameter.getDefault(b))) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
compareIndexedAccessTypes(a, b) {
|
|
352
|
+
if (!this.compare(this.#checker.indexedAccessType.getObjectType(a), this.#checker.indexedAccessType.getObjectType(b))) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
if (!this.compare(this.#checker.indexedAccessType.getIndexType(a), this.#checker.indexedAccessType.getIndexType(b))) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
compareConditionalTypes(a, b) {
|
|
361
|
+
if (!this.compare(this.#checker.conditionalType.getCheckType(a), this.#checker.conditionalType.getCheckType(b))) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
if (!this.compare(this.#checker.conditionalType.getExtendsType(a), this.#checker.conditionalType.getExtendsType(b))) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
if (!this.compare(this.#checker.conditionalType.getTrueType(a), this.#checker.conditionalType.getTrueType(b))) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
if (!this.compare(this.#checker.conditionalType.getFalseType(a), this.#checker.conditionalType.getFalseType(b))) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
compareSubstitutionTypes(a, b) {
|
|
376
|
+
if (!this.compare(this.#checker.substitutionType.getBaseType(a), this.#checker.substitutionType.getBaseType(b))) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
if (!this.compare(this.#checker.substitutionType.getConstraint(a), this.#checker.substitutionType.getConstraint(b))) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
compareTemplateLiteralTypes(a, b) {
|
|
385
|
+
if (a.texts.length !== b.texts.length) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
const aTypes = this.#checker.templateLiteralType.getTypes(a);
|
|
389
|
+
const bTypes = this.#checker.templateLiteralType.getTypes(b);
|
|
390
|
+
for (let i = 0; i < a.texts.length; i++) {
|
|
391
|
+
if (a.texts[i] !== b.texts[i]) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
if (!this.#compareMaybeNullish(aTypes[i], bTypes[i])) {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
compareStringMappingTypes(a, b) {
|
|
401
|
+
if (this.#checker.getSymbol(a) !== this.#checker.getSymbol(b)) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (!this.compare(this.#checker.stringMappingType.getTarget(a), this.#checker.stringMappingType.getTarget(b))) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
#deduplicate(target) {
|
|
410
|
+
let result = this.#deduplicateCache.get(target);
|
|
411
|
+
if (result) {
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
const types = this.#checker.unionOrIntersection.getTypes(target);
|
|
415
|
+
result = types.slice(0, 1);
|
|
416
|
+
for (let i = 1; i < types.length; i++) {
|
|
417
|
+
if (!result.some((existing) => this.compare(existing, types[i]))) {
|
|
418
|
+
result.push(types[i]);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
this.#deduplicateCache.set(target, result);
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
#getRecursionIdentity(type) {
|
|
425
|
+
return this.#checker.getAliasSymbol(type) ?? this.#checker.getSymbol(type);
|
|
426
|
+
}
|
|
427
|
+
#isInfiniteRecursion(a, b) {
|
|
428
|
+
const aIdentity = this.#getRecursionIdentity(a);
|
|
429
|
+
const bIdentity = this.#getRecursionIdentity(b);
|
|
430
|
+
if (!aIdentity || !bIdentity) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
let matches = 0;
|
|
434
|
+
for (const frame of this.#recursionStack) {
|
|
435
|
+
if (frame.aIdentity === aIdentity && frame.bIdentity === bIdentity && a.id > frame.aId && b.id > frame.bId) {
|
|
436
|
+
matches++;
|
|
437
|
+
if (matches >= 2) {
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
#memoize(a, b, compare) {
|
|
445
|
+
const key = [a.id, b.id].sort((a, b) => a - b).join(":");
|
|
446
|
+
const result = this.#memoizeCache.get(key);
|
|
447
|
+
if (result !== undefined) {
|
|
448
|
+
return result !== 2;
|
|
449
|
+
}
|
|
450
|
+
if (this.#isInfiniteRecursion(a, b)) {
|
|
451
|
+
this.#memoizeCache.set(key, 1);
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
this.#memoizeCache.set(key, 0);
|
|
455
|
+
const aIdentity = this.#getRecursionIdentity(a);
|
|
456
|
+
const bIdentity = this.#getRecursionIdentity(b);
|
|
457
|
+
if (aIdentity != null && bIdentity != null) {
|
|
458
|
+
this.#recursionStack.push({ aId: a.id, bId: b.id, aIdentity, bIdentity });
|
|
459
|
+
}
|
|
460
|
+
const isSame = compare();
|
|
461
|
+
if (aIdentity != null && bIdentity != null) {
|
|
462
|
+
this.#recursionStack.pop();
|
|
463
|
+
}
|
|
464
|
+
this.#memoizeCache.set(key, isSame ? 1 : 2);
|
|
465
|
+
return isSame;
|
|
466
|
+
}
|
|
467
|
+
#normalize(type) {
|
|
468
|
+
type = this.#checker.getReducedType(type);
|
|
469
|
+
if (type.flags & this.#ts.TypeFlags.Freshable &&
|
|
470
|
+
this.#checker.freshableType.getFreshType(type) === type) {
|
|
471
|
+
return this.#checker.freshableType.getRegularType(type);
|
|
472
|
+
}
|
|
473
|
+
if (type.flags & this.#ts.TypeFlags.UnionOrIntersection) {
|
|
474
|
+
const parts = this.#deduplicate(type);
|
|
475
|
+
if (parts.length === 1) {
|
|
476
|
+
return parts.at(0);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return type;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Structure } from "./Structure.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Structure } from "./Structure.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class SuppressedDiagnosticText {
|
|
2
|
+
static directiveRequires() {
|
|
3
|
+
return [
|
|
4
|
+
"Directive requires an argument.",
|
|
5
|
+
"Add a fragment of the expected error message after the directive.",
|
|
6
|
+
"To ignore the directive, append the '!' character after it.",
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
static messageDidNotMatch() {
|
|
10
|
+
return "The diagnostic message did not match.";
|
|
11
|
+
}
|
|
12
|
+
static onlySingleError() {
|
|
13
|
+
return "Only a single error can be suppressed.";
|
|
14
|
+
}
|
|
15
|
+
static suppressedError(count = 1) {
|
|
16
|
+
return `The suppressed error${count === 1 ? "" : "s"}:`;
|
|
17
|
+
}
|
|
18
|
+
}
|