mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix type errors around backend routes
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f9843cc1cc
commit
6642aef44a
@ -10,9 +10,13 @@ import type { LensApiResultContentType } from "./router-content-types";
|
|||||||
import type { URLSearchParams } from "url";
|
import type { URLSearchParams } from "url";
|
||||||
import type { SafeParseReturnType } from "zod";
|
import type { SafeParseReturnType } from "zod";
|
||||||
|
|
||||||
|
declare const emptyObjectSymbol: unique symbol;
|
||||||
|
|
||||||
|
export interface EmptyObject {[emptyObjectSymbol]?: never}
|
||||||
|
|
||||||
export type InferParam<
|
export type InferParam<
|
||||||
T extends string,
|
T extends string,
|
||||||
PathParams extends Record<string, string>,
|
PathParams,
|
||||||
> =
|
> =
|
||||||
T extends `{${infer P}?}`
|
T extends `{${infer P}?}`
|
||||||
? PathParams & Partial<Record<P, string>>
|
? PathParams & Partial<Record<P, string>>
|
||||||
@ -27,12 +31,14 @@ export type InferParamFromPath<P extends string> =
|
|||||||
: never
|
: never
|
||||||
: P extends `${infer A}/${infer B}`
|
: P extends `${infer A}/${infer B}`
|
||||||
? InferParam<A, InferParamFromPath<B>>
|
? InferParam<A, InferParamFromPath<B>>
|
||||||
: InferParam<P, Record<string, never>>;
|
: InferParam<P, EmptyObject>;
|
||||||
|
|
||||||
export interface LensApiRequest<Path extends string> {
|
export interface LensApiRequest<Path extends string> {
|
||||||
path: Path;
|
path: Path;
|
||||||
payload: unknown;
|
payload: unknown;
|
||||||
params: InferParamFromPath<Path>;
|
params: string extends Path
|
||||||
|
? Partial<Record<string, string>>
|
||||||
|
: InferParamFromPath<Path>;
|
||||||
cluster: Cluster | undefined;
|
cluster: Cluster | undefined;
|
||||||
query: URLSearchParams;
|
query: URLSearchParams;
|
||||||
raw: {
|
raw: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user