File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 77
88import { RedactableError } from "./errors" ;
99
10+ // Matches any type that is not an array. This is useful to help avoid
11+ // nested arrays, or for cases like createSingleSelectionCommand to avoid T
12+ // accidentally getting instantiated as DatabaseItem[] instead of DatabaseItem.
13+ export type NotArray =
14+ | string
15+ | bigint
16+ | number
17+ | boolean
18+ | ( object & {
19+ length ?: never ;
20+ } ) ;
21+
1022/**
1123 * This error is used to indicate a runtime failure of an exhaustivity check enforced at compile time.
1224 */
Original file line number Diff line number Diff line change @@ -3,14 +3,10 @@ import type {
33 TreeViewContextMultiSelectionCommandFunction ,
44 TreeViewContextSingleSelectionCommandFunction ,
55} from "../commands" ;
6+ import type { NotArray } from "../helpers-pure" ;
67import type { NotificationLogger } from "../logging" ;
78import { showAndLogErrorMessage } from "../logging" ;
89
9- // A hack to match types that are not an array, which is useful to help avoid
10- // misusing createSingleSelectionCommand, e.g. where T accidentally gets instantiated
11- // as DatabaseItem[] instead of DatabaseItem.
12- type NotArray = object & { length ?: never } ;
13-
1410// A way to get the type system to help assert that one type is a supertype of another.
1511type CreateSupertypeOf < Super , Sub extends Super > = Sub ;
1612
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
88import type { LocalQueries } from "../local-queries" ;
99import { getQuickEvalContext , validateQueryPath } from "../run-queries-shared" ;
1010import type { LaunchConfig } from "./debug-protocol" ;
11+ import type { NotArray } from "../common/helpers-pure" ;
1112import { getErrorMessage } from "../common/helpers-pure" ;
1213import { showAndLogErrorMessage } from "../common/logging" ;
1314import { extLogger } from "../common/logging/vscode" ;
@@ -39,7 +40,7 @@ export type QLDebugConfiguration = DebugConfiguration & QLDebugArgs;
3940export type QLResolvedDebugConfiguration = DebugConfiguration & LaunchConfig ;
4041
4142/** If the specified value is a single element, then turn it into an array containing that element. */
42- function makeArray < T extends Exclude < unknown , unknown [ ] > > ( value : T | T [ ] ) : T [ ] {
43+ function makeArray < T extends NotArray > ( value : T | T [ ] ) : T [ ] {
4344 if ( Array . isArray ( value ) ) {
4445 return value ;
4546 } else {
You can’t perform that action at this time.
0 commit comments