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
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import process from
|
|
3
|
-
import { Cli } from
|
|
4
|
-
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { Cli } from "./api.js";
|
|
5
4
|
const cli = new Cli();
|
|
6
5
|
const commandLine = process.argv.slice(2);
|
|
7
6
|
process.exitCode = await cli.run(commandLine);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
export declare abstract class BaseCheckerAdapter {
|
|
3
|
+
abstract checker: any;
|
|
4
|
+
abstract ts: any;
|
|
5
|
+
isOptionalProperty(symbol: ts.Symbol): boolean;
|
|
6
|
+
getProperties(type: ts.Type): ReadonlyArray<ts.Symbol>;
|
|
7
|
+
getSymbolAtLocation(node: ts.Node): ts.Symbol | undefined;
|
|
8
|
+
getType(node: ts.Node): ts.Type;
|
|
9
|
+
getTypeArguments(type: ts.TypeReference): ReadonlyArray<ts.Type>;
|
|
10
|
+
hasCallSignatures(type: ts.Type): boolean;
|
|
11
|
+
hasConstructSignatures(type: ts.Type): boolean;
|
|
12
|
+
isTupleType(type: ts.Type): type is ts.TupleTypeReference;
|
|
13
|
+
isTypeAssignableTo(source: ts.Type, target: ts.Type): boolean;
|
|
14
|
+
typeToString(type: ts.Type): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class BaseCheckerAdapter {
|
|
2
|
+
isOptionalProperty(symbol) {
|
|
3
|
+
return !!(symbol.flags & this.ts.SymbolFlags.Optional);
|
|
4
|
+
}
|
|
5
|
+
getProperties(type) {
|
|
6
|
+
return this.checker.getPropertiesOfType(type);
|
|
7
|
+
}
|
|
8
|
+
getSymbolAtLocation(node) {
|
|
9
|
+
return this.checker.getSymbolAtLocation(node);
|
|
10
|
+
}
|
|
11
|
+
getType(node) {
|
|
12
|
+
return this.checker.getTypeAtLocation(node);
|
|
13
|
+
}
|
|
14
|
+
getTypeArguments(type) {
|
|
15
|
+
return this.checker.getTypeArguments(type);
|
|
16
|
+
}
|
|
17
|
+
hasCallSignatures(type) {
|
|
18
|
+
return this.checker.getSignaturesOfType(type, this.ts.SignatureKind.Call).length > 0;
|
|
19
|
+
}
|
|
20
|
+
hasConstructSignatures(type) {
|
|
21
|
+
return this.checker.getSignaturesOfType(type, this.ts.SignatureKind.Construct).length > 0;
|
|
22
|
+
}
|
|
23
|
+
isTupleType(type) {
|
|
24
|
+
return this.checker.isTupleType(type);
|
|
25
|
+
}
|
|
26
|
+
isTypeAssignableTo(source, target) {
|
|
27
|
+
return this.checker.isTypeAssignableTo(source, target);
|
|
28
|
+
}
|
|
29
|
+
typeToString(type) {
|
|
30
|
+
return this.checker.typeToString(type);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type ts6 from "@typescript/typescript6";
|
|
2
|
+
import type * as ts from "#typescript";
|
|
3
|
+
import { BaseCheckerAdapter } from "./BaseCheckerAdapter.js";
|
|
4
|
+
import type { ParameterFacts } from "./types.js";
|
|
5
|
+
export declare class CompatCheckerAdapter extends BaseCheckerAdapter {
|
|
6
|
+
#private;
|
|
7
|
+
checker: ts6.TypeChecker;
|
|
8
|
+
ts: typeof ts6;
|
|
9
|
+
constructor(ts: typeof ts6, checker: ts6.TypeChecker);
|
|
10
|
+
containsInstantiable(target: ts.Type): boolean;
|
|
11
|
+
getDeclarations(symbol: ts.Symbol): Array<ts.Declaration> | undefined;
|
|
12
|
+
getDeclarationModifierFlags(symbol: ts.Symbol): ts.ModifierFlags;
|
|
13
|
+
getIndexSignatures(type: ts.Type): ReadonlyArray<ts.IndexInfo>;
|
|
14
|
+
getNonPrimitiveType(): ts.Type;
|
|
15
|
+
getParameterCount(signature: ts.Signature): number;
|
|
16
|
+
getParameterFacts(signature: ts.Signature, parameterIndex: number): ParameterFacts;
|
|
17
|
+
getPropertyType: (symbol: ts.Symbol, compilerOptions: ts.CompilerOptions) => ts.Type;
|
|
18
|
+
getReducedType(type: ts.Type): ts.Type;
|
|
19
|
+
getSignatures(type: ts.Type, kind: ts.SignatureKind): ReadonlyArray<ts.Signature>;
|
|
20
|
+
getSymbol(type: ts.Type): ts.Symbol | undefined;
|
|
21
|
+
getAliasSymbol(type: ts.Type): ts.Symbol | undefined;
|
|
22
|
+
getTargetSymbol(symbol: ts.Symbol): ts.Symbol | undefined;
|
|
23
|
+
getTypeParameterModifiers(typeParameter: ts.TypeParameter): ts.ModifierFlags;
|
|
24
|
+
isReadonlyProperty(symbol: ts.Symbol): boolean;
|
|
25
|
+
signature: {
|
|
26
|
+
getReturnType: (signature: ts.Signature) => ts.Type;
|
|
27
|
+
getThisParameterType: (signature: ts.Signature) => ts.Type | undefined;
|
|
28
|
+
getTypePredicate: (signature: ts.Signature) => ts.TypePredicate | undefined;
|
|
29
|
+
};
|
|
30
|
+
conditionalType: {
|
|
31
|
+
getCheckType(type: ts.ConditionalType): ts.Type;
|
|
32
|
+
getExtendsType(type: ts.ConditionalType): ts.Type;
|
|
33
|
+
getTrueType: (type: ts.ConditionalType) => ts.Type;
|
|
34
|
+
getFalseType: (type: ts.ConditionalType) => ts.Type;
|
|
35
|
+
};
|
|
36
|
+
genericType: {
|
|
37
|
+
getTypeParameters(type: ts.GenericType): ReadonlyArray<ts.TypeParameter>;
|
|
38
|
+
};
|
|
39
|
+
freshableType: {
|
|
40
|
+
getFreshType(type: ts.FreshableType): ts.Type;
|
|
41
|
+
getRegularType(type: ts.FreshableType): ts.Type;
|
|
42
|
+
};
|
|
43
|
+
indexedAccessType: {
|
|
44
|
+
getObjectType(type: ts.IndexedAccessType): ts.Type;
|
|
45
|
+
getIndexType(type: ts.IndexedAccessType): ts.Type;
|
|
46
|
+
};
|
|
47
|
+
indexType: {
|
|
48
|
+
getTarget(type: ts.IndexType): ts.Type;
|
|
49
|
+
};
|
|
50
|
+
stringMappingType: {
|
|
51
|
+
getTarget(type: ts.StringMappingType): ts.Type;
|
|
52
|
+
};
|
|
53
|
+
substitutionType: {
|
|
54
|
+
getBaseType(type: ts.SubstitutionType): ts.Type;
|
|
55
|
+
getConstraint(type: ts.SubstitutionType): ts.Type;
|
|
56
|
+
};
|
|
57
|
+
templateLiteralType: {
|
|
58
|
+
getTypes(type: ts.TemplateLiteralType): ReadonlyArray<ts.Type>;
|
|
59
|
+
};
|
|
60
|
+
typeParameter: {
|
|
61
|
+
getConstraint(type: ts.TypeParameter): ts.Type | undefined;
|
|
62
|
+
getDefault(type: ts.TypeParameter): ts.Type | undefined;
|
|
63
|
+
};
|
|
64
|
+
typeReference: {
|
|
65
|
+
getTarget(type: ts.TypeReference): ts.GenericType;
|
|
66
|
+
};
|
|
67
|
+
unionOrIntersection: {
|
|
68
|
+
getTypes(type: ts.UnionType | ts.IntersectionType): ReadonlyArray<ts.Type>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { BaseCheckerAdapter } from "./BaseCheckerAdapter.js";
|
|
2
|
+
export class CompatCheckerAdapter extends BaseCheckerAdapter {
|
|
3
|
+
checker;
|
|
4
|
+
ts;
|
|
5
|
+
constructor(ts, checker) {
|
|
6
|
+
super();
|
|
7
|
+
this.ts = ts;
|
|
8
|
+
this.checker = checker;
|
|
9
|
+
}
|
|
10
|
+
containsInstantiable(target) {
|
|
11
|
+
if ("types" in target) {
|
|
12
|
+
return target.types.some((type) => type.flags & this.ts.TypeFlags.Instantiable);
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
getDeclarations(symbol) {
|
|
17
|
+
return symbol.getDeclarations();
|
|
18
|
+
}
|
|
19
|
+
getDeclarationModifierFlags(symbol) {
|
|
20
|
+
return this.ts.getDeclarationModifierFlagsFromSymbol(symbol);
|
|
21
|
+
}
|
|
22
|
+
getIndexSignatures(type) {
|
|
23
|
+
if (type.flags & this.ts.TypeFlags.Intersection) {
|
|
24
|
+
return type.types.flatMap((type) => this.getIndexSignatures(type));
|
|
25
|
+
}
|
|
26
|
+
return this.checker.getIndexInfosOfType(type);
|
|
27
|
+
}
|
|
28
|
+
getNonPrimitiveType() {
|
|
29
|
+
return "getNonPrimitiveType" in this.checker
|
|
30
|
+
? this.checker.getNonPrimitiveType()
|
|
31
|
+
: { flags: this.ts.TypeFlags.NonPrimitive };
|
|
32
|
+
}
|
|
33
|
+
getParameterCount(signature) {
|
|
34
|
+
signature = signature;
|
|
35
|
+
if (signature.declaration != null && this.ts.hasRestParameter(signature.declaration)) {
|
|
36
|
+
const restType = this.checker.getTypeOfSymbol(signature.parameters.at(-1));
|
|
37
|
+
if (this.isTupleType(restType)) {
|
|
38
|
+
return signature.parameters.length + this.getTypeArguments(restType).length - 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return signature.parameters.length;
|
|
42
|
+
}
|
|
43
|
+
getParameterFacts(signature, parameterIndex) {
|
|
44
|
+
signature = signature;
|
|
45
|
+
if (parameterIndex >= signature.parameters.length - 1 && this.ts.hasRestParameter(signature.getDeclaration())) {
|
|
46
|
+
const restType = this.checker.getTypeOfSymbol(signature.parameters.at(-1));
|
|
47
|
+
if (this.isTupleType(restType)) {
|
|
48
|
+
const fixedLength = signature.parameters.length - 1;
|
|
49
|
+
return this.#getParameterFactsFromTuple(restType, parameterIndex - fixedLength);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const parameter = signature.parameters[parameterIndex];
|
|
53
|
+
return {
|
|
54
|
+
isOptional: this.#isOptionalParameter(parameter),
|
|
55
|
+
isRest: this.#isRestParameter(parameter),
|
|
56
|
+
getType: () => this.checker.getParameterType(signature, parameterIndex),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
#getParameterFactsFromTuple(type, position) {
|
|
60
|
+
return {
|
|
61
|
+
isOptional: !!(type.target.elementFlags[position] & this.ts.ElementFlags.Optional),
|
|
62
|
+
isRest: !!(type.target.elementFlags[position] & this.ts.ElementFlags.Rest),
|
|
63
|
+
getType: () => this.checker.getTypeArguments(type)[position],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
#isOptionalParameter(symbol) {
|
|
67
|
+
return (symbol.valueDeclaration != null &&
|
|
68
|
+
this.ts.isParameter(symbol.valueDeclaration) &&
|
|
69
|
+
(symbol.valueDeclaration.questionToken != null || symbol.valueDeclaration.initializer != null));
|
|
70
|
+
}
|
|
71
|
+
#isRestParameter(symbol) {
|
|
72
|
+
return (symbol.valueDeclaration != null &&
|
|
73
|
+
this.ts.isParameter(symbol.valueDeclaration) &&
|
|
74
|
+
symbol.valueDeclaration.dotDotDotToken != null);
|
|
75
|
+
}
|
|
76
|
+
getPropertyType = (symbol, compilerOptions) => {
|
|
77
|
+
const type = this.checker.getTypeOfSymbol(symbol);
|
|
78
|
+
if (compilerOptions.exactOptionalPropertyTypes && this.isOptionalProperty(symbol)) {
|
|
79
|
+
if (type.flags & this.ts.TypeFlags.Union) {
|
|
80
|
+
const filteredType = type.types.filter((type) => !("debugIntrinsicName" in type && type.debugIntrinsicName === "missing"));
|
|
81
|
+
if (filteredType.length === type.types.length) {
|
|
82
|
+
return type;
|
|
83
|
+
}
|
|
84
|
+
if (filteredType.length === 1) {
|
|
85
|
+
return filteredType.at(0);
|
|
86
|
+
}
|
|
87
|
+
return { ...type, types: filteredType };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return type;
|
|
91
|
+
};
|
|
92
|
+
getReducedType(type) {
|
|
93
|
+
this.checker.typeToString(type);
|
|
94
|
+
if ("resolvedReducedType" in type) {
|
|
95
|
+
return type.resolvedReducedType;
|
|
96
|
+
}
|
|
97
|
+
return type;
|
|
98
|
+
}
|
|
99
|
+
getSignatures(type, kind) {
|
|
100
|
+
if (type.flags & this.ts.TypeFlags.Intersection) {
|
|
101
|
+
return type.types.flatMap((type) => this.getSignatures(type, kind));
|
|
102
|
+
}
|
|
103
|
+
return this.checker.getSignaturesOfType(type, kind);
|
|
104
|
+
}
|
|
105
|
+
getSymbol(type) {
|
|
106
|
+
return type.symbol;
|
|
107
|
+
}
|
|
108
|
+
getAliasSymbol(type) {
|
|
109
|
+
return type.aliasSymbol;
|
|
110
|
+
}
|
|
111
|
+
getTargetSymbol(symbol) {
|
|
112
|
+
return this.#isCheckFlagSet(symbol, this.ts.CheckFlags.Instantiated)
|
|
113
|
+
? symbol.links.target
|
|
114
|
+
: symbol;
|
|
115
|
+
}
|
|
116
|
+
getTypeParameterModifiers(typeParameter) {
|
|
117
|
+
typeParameter = typeParameter;
|
|
118
|
+
if (!typeParameter.symbol.declarations) {
|
|
119
|
+
return this.ts.ModifierFlags.None;
|
|
120
|
+
}
|
|
121
|
+
return (typeParameter.symbol.declarations.reduce((modifiers, declaration) => modifiers | this.ts.getEffectiveModifierFlags(declaration), this.ts.ModifierFlags.None) &
|
|
122
|
+
(this.ts.ModifierFlags.In | this.ts.ModifierFlags.Out | this.ts.ModifierFlags.Const));
|
|
123
|
+
}
|
|
124
|
+
#isCheckFlagSet(symbol, flag) {
|
|
125
|
+
return !!(symbol.flags & this.ts.SymbolFlags.Transient && symbol.links.checkFlags & flag);
|
|
126
|
+
}
|
|
127
|
+
isReadonlyProperty(symbol) {
|
|
128
|
+
return !!(this.#isCheckFlagSet(symbol, this.ts.CheckFlags.Readonly) ||
|
|
129
|
+
(symbol.flags & this.ts.SymbolFlags.Property &&
|
|
130
|
+
this.ts.getDeclarationModifierFlagsFromSymbol(symbol) & this.ts.ModifierFlags.Readonly) ||
|
|
131
|
+
(symbol.flags & this.ts.SymbolFlags.Accessor && !(symbol.flags & this.ts.SymbolFlags.SetAccessor)));
|
|
132
|
+
}
|
|
133
|
+
signature = {
|
|
134
|
+
getReturnType: (signature) => {
|
|
135
|
+
return this.checker.getReturnTypeOfSignature(signature);
|
|
136
|
+
},
|
|
137
|
+
getThisParameterType: (signature) => {
|
|
138
|
+
const thisParameter = signature.thisParameter;
|
|
139
|
+
return thisParameter && this.checker.getTypeOfSymbol(thisParameter);
|
|
140
|
+
},
|
|
141
|
+
getTypePredicate: (signature) => {
|
|
142
|
+
return this.checker.getTypePredicateOfSignature(signature);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
conditionalType = {
|
|
146
|
+
getCheckType(type) {
|
|
147
|
+
return type.checkType;
|
|
148
|
+
},
|
|
149
|
+
getExtendsType(type) {
|
|
150
|
+
return type.extendsType;
|
|
151
|
+
},
|
|
152
|
+
getTrueType: (type) => {
|
|
153
|
+
return this.checker.getTypeAtLocation(type.root.node.trueType);
|
|
154
|
+
},
|
|
155
|
+
getFalseType: (type) => {
|
|
156
|
+
return this.checker.getTypeAtLocation(type.root.node.falseType);
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
genericType = {
|
|
160
|
+
getTypeParameters(type) {
|
|
161
|
+
return type.typeParameters ?? [];
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
freshableType = {
|
|
165
|
+
getFreshType(type) {
|
|
166
|
+
return type.freshType;
|
|
167
|
+
},
|
|
168
|
+
getRegularType(type) {
|
|
169
|
+
return type.regularType;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
indexedAccessType = {
|
|
173
|
+
getObjectType(type) {
|
|
174
|
+
return type.objectType;
|
|
175
|
+
},
|
|
176
|
+
getIndexType(type) {
|
|
177
|
+
return type.indexType;
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
indexType = {
|
|
181
|
+
getTarget(type) {
|
|
182
|
+
return type.type;
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
stringMappingType = {
|
|
186
|
+
getTarget(type) {
|
|
187
|
+
return type.type;
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
substitutionType = {
|
|
191
|
+
getBaseType(type) {
|
|
192
|
+
return type.baseType;
|
|
193
|
+
},
|
|
194
|
+
getConstraint(type) {
|
|
195
|
+
return type.constraint;
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
templateLiteralType = {
|
|
199
|
+
getTypes(type) {
|
|
200
|
+
return type.types;
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
typeParameter = {
|
|
204
|
+
getConstraint(type) {
|
|
205
|
+
return type.getConstraint();
|
|
206
|
+
},
|
|
207
|
+
getDefault(type) {
|
|
208
|
+
return type.getDefault();
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
typeReference = {
|
|
212
|
+
getTarget(type) {
|
|
213
|
+
return type.target;
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
unionOrIntersection = {
|
|
217
|
+
getTypes(type) {
|
|
218
|
+
return type.types;
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type * as tsApi from "typescript/sync";
|
|
2
|
+
import type * as ts from "#typescript";
|
|
3
|
+
import { BaseCheckerAdapter } from "./BaseCheckerAdapter.js";
|
|
4
|
+
import type { ParameterFacts } from "./types.js";
|
|
5
|
+
export declare class NativeCheckerAdapter extends BaseCheckerAdapter {
|
|
6
|
+
#private;
|
|
7
|
+
checker: tsApi.Checker;
|
|
8
|
+
ts: ts.NativeTypeScript;
|
|
9
|
+
constructor(ts: ts.NativeTypeScript, checker: tsApi.Checker);
|
|
10
|
+
containsInstantiable(target: ts.Type): boolean;
|
|
11
|
+
getDeclarations(symbol: ts.Symbol): Array<ts.Declaration> | undefined;
|
|
12
|
+
getDeclarationModifierFlags(symbol: ts.Symbol): ts.ModifierFlags;
|
|
13
|
+
getNonPrimitiveType(): ts.Type;
|
|
14
|
+
getParameterCount(signature: ts.Signature): number;
|
|
15
|
+
getParameterFacts(signature: ts.Signature, parameterIndex: number): ParameterFacts;
|
|
16
|
+
getIndexSignatures(type: ts.Type): ReadonlyArray<ts.IndexInfo>;
|
|
17
|
+
getPropertyType(symbol: ts.Symbol): ts.Type;
|
|
18
|
+
getReducedType(type: ts.Type): ts.Type;
|
|
19
|
+
getSignatures(type: ts.Type, kind: ts.SignatureKind): ReadonlyArray<ts.Signature>;
|
|
20
|
+
getSymbol(type: ts.Type): ts.Symbol | undefined;
|
|
21
|
+
getAliasSymbol(type: ts.Type): ts.Symbol | undefined;
|
|
22
|
+
getTargetSymbol(symbol: ts.Symbol): ts.Symbol;
|
|
23
|
+
getTypeParameterModifiers(typeParameter: ts.TypeParameter): ts.ModifierFlags;
|
|
24
|
+
isReadonlyProperty(symbol: ts.Symbol): boolean;
|
|
25
|
+
signature: {
|
|
26
|
+
getReturnType: (signature: ts.Signature) => ts.Type;
|
|
27
|
+
getThisParameterType: (signature: ts.Signature) => ts.Type | undefined;
|
|
28
|
+
getTypePredicate: (signature: ts.Signature) => ts.TypePredicate | undefined;
|
|
29
|
+
};
|
|
30
|
+
conditionalType: {
|
|
31
|
+
getCheckType(type: ts.ConditionalType): ts.Type;
|
|
32
|
+
getExtendsType(type: ts.ConditionalType): ts.Type;
|
|
33
|
+
getTrueType(type: ts.ConditionalType): ts.Type;
|
|
34
|
+
getFalseType(type: ts.ConditionalType): ts.Type;
|
|
35
|
+
};
|
|
36
|
+
genericType: {
|
|
37
|
+
getTypeParameters(type: ts.GenericType): ReadonlyArray<ts.TypeParameter>;
|
|
38
|
+
};
|
|
39
|
+
freshableType: {
|
|
40
|
+
getFreshType(type: ts.FreshableType): ts.Type | undefined;
|
|
41
|
+
getRegularType(type: ts.FreshableType): ts.Type | undefined;
|
|
42
|
+
};
|
|
43
|
+
indexedAccessType: {
|
|
44
|
+
getObjectType(type: ts.IndexedAccessType): ts.Type;
|
|
45
|
+
getIndexType(type: ts.IndexedAccessType): ts.Type;
|
|
46
|
+
};
|
|
47
|
+
indexType: {
|
|
48
|
+
getTarget(type: ts.IndexType): ts.Type;
|
|
49
|
+
};
|
|
50
|
+
stringMappingType: {
|
|
51
|
+
getTarget(type: ts.StringMappingType): ts.Type;
|
|
52
|
+
};
|
|
53
|
+
substitutionType: {
|
|
54
|
+
getBaseType(type: ts.SubstitutionType): ts.Type;
|
|
55
|
+
getConstraint(type: ts.SubstitutionType): ts.Type;
|
|
56
|
+
};
|
|
57
|
+
templateLiteralType: {
|
|
58
|
+
getTypes(type: ts.TemplateLiteralType): ReadonlyArray<ts.Type>;
|
|
59
|
+
};
|
|
60
|
+
typeParameter: {
|
|
61
|
+
getConstraint(type: ts.TypeParameter): ts.Type | undefined;
|
|
62
|
+
getDefault(type: ts.TypeParameter): ts.Type | undefined;
|
|
63
|
+
};
|
|
64
|
+
typeReference: {
|
|
65
|
+
getTarget(type: ts.TypeReference): ts.GenericType;
|
|
66
|
+
};
|
|
67
|
+
unionOrIntersection: {
|
|
68
|
+
getTypes(type: ts.UnionType | ts.IntersectionType): ReadonlyArray<ts.Type>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { BaseCheckerAdapter } from "./BaseCheckerAdapter.js";
|
|
2
|
+
export class NativeCheckerAdapter extends BaseCheckerAdapter {
|
|
3
|
+
checker;
|
|
4
|
+
ts;
|
|
5
|
+
constructor(ts, checker) {
|
|
6
|
+
super();
|
|
7
|
+
this.ts = ts;
|
|
8
|
+
this.checker = checker;
|
|
9
|
+
}
|
|
10
|
+
containsInstantiable(target) {
|
|
11
|
+
if (target.flags & (this.ts.TypeFlags.Union | this.ts.TypeFlags.Intersection | this.ts.TypeFlags.TemplateLiteral)) {
|
|
12
|
+
return target
|
|
13
|
+
.getTypes()
|
|
14
|
+
.some((type) => type.flags & this.ts.TypeFlags.Instantiable);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
getDeclarations(symbol) {
|
|
19
|
+
return symbol.declarations
|
|
20
|
+
.map((declaration) => declaration.resolve())
|
|
21
|
+
.filter((declaration) => declaration != null);
|
|
22
|
+
}
|
|
23
|
+
getDeclarationModifierFlags(symbol) {
|
|
24
|
+
let modifiers = this.ts.ModifierFlags.None;
|
|
25
|
+
for (const declaration of symbol.declarations) {
|
|
26
|
+
const node = declaration.resolve();
|
|
27
|
+
if ("modifierFlags" in node) {
|
|
28
|
+
modifiers |= node.modifierFlags;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return modifiers;
|
|
32
|
+
}
|
|
33
|
+
getNonPrimitiveType() {
|
|
34
|
+
return this.checker.getNonPrimitiveType();
|
|
35
|
+
}
|
|
36
|
+
getParameterCount(signature) {
|
|
37
|
+
signature = signature;
|
|
38
|
+
if (signature.declaration != null && signature.hasRestParameter) {
|
|
39
|
+
const restType = this.checker.getTypeOfSymbol(signature.getParameters().at(-1));
|
|
40
|
+
if (this.isTupleType(restType)) {
|
|
41
|
+
return signature.parameters.length + this.getTypeArguments(restType).length - 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return signature.parameters.length;
|
|
45
|
+
}
|
|
46
|
+
getParameterFacts(signature, parameterIndex) {
|
|
47
|
+
signature = signature;
|
|
48
|
+
if (parameterIndex >= signature.parameters.length - 1 && signature.hasRestParameter) {
|
|
49
|
+
const restType = this.checker.getTypeOfSymbol(signature.getParameters().at(-1));
|
|
50
|
+
if (this.isTupleType(restType)) {
|
|
51
|
+
const fixedLength = signature.parameters.length - 1;
|
|
52
|
+
return this.#getParameterFactsFromTuple(restType, parameterIndex - fixedLength);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const parameter = signature.getParameters()[parameterIndex];
|
|
56
|
+
return {
|
|
57
|
+
isOptional: this.#isOptionalParameter(parameter),
|
|
58
|
+
isRest: this.#isRestParameter(parameter),
|
|
59
|
+
getType: () => this.checker.getParameterType(signature, parameterIndex),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
#getParameterFactsFromTuple(type, position) {
|
|
63
|
+
const target = type.getTarget();
|
|
64
|
+
return {
|
|
65
|
+
isOptional: !!(target.elementFlags[position] & this.ts.ElementFlags.Optional),
|
|
66
|
+
isRest: !!(target.elementFlags[position] & this.ts.ElementFlags.Rest),
|
|
67
|
+
getType: () => this.checker.getTypeArguments(type)[position],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
#isOptionalParameter(symbol) {
|
|
71
|
+
const node = symbol.valueDeclaration?.resolve();
|
|
72
|
+
return (node != null && this.ts.isParameterDeclaration(node) && (node.questionToken != null || node.initializer != null));
|
|
73
|
+
}
|
|
74
|
+
#isRestParameter(symbol) {
|
|
75
|
+
const node = symbol.valueDeclaration?.resolve();
|
|
76
|
+
return node != null && this.ts.isParameterDeclaration(node) && node.dotDotDotToken != null;
|
|
77
|
+
}
|
|
78
|
+
getIndexSignatures(type) {
|
|
79
|
+
if (type.flags & this.ts.TypeFlags.Intersection) {
|
|
80
|
+
return type.getTypes().flatMap((type) => this.getIndexSignatures(type));
|
|
81
|
+
}
|
|
82
|
+
return this.checker.getIndexInfosOfType(type);
|
|
83
|
+
}
|
|
84
|
+
getPropertyType(symbol) {
|
|
85
|
+
return this.checker.getNonMissingTypeOfSymbol(symbol);
|
|
86
|
+
}
|
|
87
|
+
getReducedType(type) {
|
|
88
|
+
return this.checker.getReducedType(type);
|
|
89
|
+
}
|
|
90
|
+
getSignatures(type, kind) {
|
|
91
|
+
if (type.flags & this.ts.TypeFlags.Intersection) {
|
|
92
|
+
return type.getTypes().flatMap((type) => this.getSignatures(type, kind));
|
|
93
|
+
}
|
|
94
|
+
return this.checker.getSignaturesOfType(type, kind);
|
|
95
|
+
}
|
|
96
|
+
getSymbol(type) {
|
|
97
|
+
return type.getSymbol();
|
|
98
|
+
}
|
|
99
|
+
getAliasSymbol(type) {
|
|
100
|
+
return type.getAliasSymbol();
|
|
101
|
+
}
|
|
102
|
+
getTargetSymbol(symbol) {
|
|
103
|
+
return this.checker.getTargetSymbol(symbol);
|
|
104
|
+
}
|
|
105
|
+
getTypeParameterModifiers(typeParameter) {
|
|
106
|
+
return (this.getDeclarationModifierFlags(typeParameter.getSymbol()) &
|
|
107
|
+
(this.ts.ModifierFlags.In | this.ts.ModifierFlags.Out | this.ts.ModifierFlags.Const));
|
|
108
|
+
}
|
|
109
|
+
isReadonlyProperty(symbol) {
|
|
110
|
+
return this.checker.isReadonlySymbol(symbol);
|
|
111
|
+
}
|
|
112
|
+
signature = {
|
|
113
|
+
getReturnType: (signature) => {
|
|
114
|
+
return this.checker.getReturnTypeOfSignature(signature);
|
|
115
|
+
},
|
|
116
|
+
getThisParameterType: (signature) => {
|
|
117
|
+
const thisParameter = signature.getThisParameter();
|
|
118
|
+
return thisParameter && this.checker.getTypeOfSymbol(thisParameter);
|
|
119
|
+
},
|
|
120
|
+
getTypePredicate: (signature) => {
|
|
121
|
+
return this.checker.getTypePredicateOfSignature(signature);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
conditionalType = {
|
|
125
|
+
getCheckType(type) {
|
|
126
|
+
return type.getCheckType();
|
|
127
|
+
},
|
|
128
|
+
getExtendsType(type) {
|
|
129
|
+
return type.getExtendsType();
|
|
130
|
+
},
|
|
131
|
+
getTrueType(type) {
|
|
132
|
+
return type.getTrueType();
|
|
133
|
+
},
|
|
134
|
+
getFalseType(type) {
|
|
135
|
+
return type.getFalseType();
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
genericType = {
|
|
139
|
+
getTypeParameters(type) {
|
|
140
|
+
return type.getTypeParameters();
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
freshableType = {
|
|
144
|
+
getFreshType(type) {
|
|
145
|
+
return type.getFreshType();
|
|
146
|
+
},
|
|
147
|
+
getRegularType(type) {
|
|
148
|
+
return type.getRegularType();
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
indexedAccessType = {
|
|
152
|
+
getObjectType(type) {
|
|
153
|
+
return type.getObjectType();
|
|
154
|
+
},
|
|
155
|
+
getIndexType(type) {
|
|
156
|
+
return type.getIndexType();
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
indexType = {
|
|
160
|
+
getTarget(type) {
|
|
161
|
+
return type.getTarget();
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
stringMappingType = {
|
|
165
|
+
getTarget(type) {
|
|
166
|
+
return type.getTarget();
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
substitutionType = {
|
|
170
|
+
getBaseType(type) {
|
|
171
|
+
return type.getBaseType();
|
|
172
|
+
},
|
|
173
|
+
getConstraint(type) {
|
|
174
|
+
return type.getConstraint();
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
templateLiteralType = {
|
|
178
|
+
getTypes(type) {
|
|
179
|
+
return type.getTypes();
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
typeParameter = {
|
|
183
|
+
getConstraint(type) {
|
|
184
|
+
return type.getConstraint();
|
|
185
|
+
},
|
|
186
|
+
getDefault(type) {
|
|
187
|
+
return type.getDefault();
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
typeReference = {
|
|
191
|
+
getTarget(type) {
|
|
192
|
+
return type.getTarget();
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
unionOrIntersection = {
|
|
196
|
+
getTypes(type) {
|
|
197
|
+
return type.getTypes();
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
import type { CompatCheckerAdapter } from "./CompatCheckerAdapter.js";
|
|
3
|
+
import type { NativeCheckerAdapter } from "./NativeCheckerAdapter.js";
|
|
4
|
+
export type Checker = NativeCheckerAdapter | CompatCheckerAdapter;
|
|
5
|
+
export interface ParameterFacts {
|
|
6
|
+
isRest: boolean;
|
|
7
|
+
isOptional: boolean;
|
|
8
|
+
getType: () => ts.Type;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|