Merge pull request #3330 from github/robertbrignull/debug_configuration_makearray
Remove use of any and make typing clearer in debugger code
This commit is contained in:
@@ -7,6 +7,18 @@
|
||||
|
||||
import { RedactableError } from "./errors";
|
||||
|
||||
// Matches any type that is not an array. This is useful to help avoid
|
||||
// nested arrays, or for cases like createSingleSelectionCommand to avoid T
|
||||
// accidentally getting instantiated as DatabaseItem[] instead of DatabaseItem.
|
||||
export type NotArray =
|
||||
| string
|
||||
| bigint
|
||||
| number
|
||||
| boolean
|
||||
| (object & {
|
||||
length?: never;
|
||||
});
|
||||
|
||||
/**
|
||||
* This error is used to indicate a runtime failure of an exhaustivity check enforced at compile time.
|
||||
*/
|
||||
|
||||
@@ -3,14 +3,10 @@ import type {
|
||||
TreeViewContextMultiSelectionCommandFunction,
|
||||
TreeViewContextSingleSelectionCommandFunction,
|
||||
} from "../commands";
|
||||
import type { NotArray } from "../helpers-pure";
|
||||
import type { NotificationLogger } from "../logging";
|
||||
import { showAndLogErrorMessage } from "../logging";
|
||||
|
||||
// A hack to match types that are not an array, which is useful to help avoid
|
||||
// misusing createSingleSelectionCommand, e.g. where T accidentally gets instantiated
|
||||
// as DatabaseItem[] instead of DatabaseItem.
|
||||
type NotArray = object & { length?: never };
|
||||
|
||||
// A way to get the type system to help assert that one type is a supertype of another.
|
||||
type CreateSupertypeOf<Super, Sub extends Super> = Sub;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||
import type { LocalQueries } from "../local-queries";
|
||||
import { getQuickEvalContext, validateQueryPath } from "../run-queries-shared";
|
||||
import type { LaunchConfig } from "./debug-protocol";
|
||||
import type { NotArray } from "../common/helpers-pure";
|
||||
import { getErrorMessage } from "../common/helpers-pure";
|
||||
import { showAndLogErrorMessage } from "../common/logging";
|
||||
import { extLogger } from "../common/logging/vscode";
|
||||
@@ -22,7 +23,7 @@ export interface QLDebugArgs {
|
||||
extensionPacks?: string[] | string;
|
||||
quickEval?: boolean;
|
||||
noDebug?: boolean;
|
||||
additionalRunQueryArgs?: Record<string, any>;
|
||||
additionalRunQueryArgs?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ export type QLDebugConfiguration = DebugConfiguration & QLDebugArgs;
|
||||
export type QLResolvedDebugConfiguration = DebugConfiguration & LaunchConfig;
|
||||
|
||||
/** If the specified value is a single element, then turn it into an array containing that element. */
|
||||
function makeArray<T extends Exclude<any, any[]>>(value: T | T[]): T[] {
|
||||
function makeArray<T extends NotArray>(value: T | T[]): T[] {
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
} else {
|
||||
|
||||
@@ -71,7 +71,7 @@ export interface LaunchConfig {
|
||||
/** Run the query without debugging it. */
|
||||
noDebug: boolean;
|
||||
/** Undocumented: Additional arguments to be passed to the `runQuery` API on the query server. */
|
||||
additionalRunQueryArgs: Record<string, any>;
|
||||
additionalRunQueryArgs: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface LaunchRequest extends Request, DebugProtocol.LaunchRequest {
|
||||
|
||||
Reference in New Issue
Block a user