This commit is contained in:
2023-05-31 09:44:14 +08:00
parent 3fab4a8fc5
commit 5d75c211a7
4 changed files with 62 additions and 17 deletions

View File

@@ -134,3 +134,12 @@ export function filterFilename(p: string, maxLength = 256) {
}
return p;
}
export type DiscriminatedUnion<
K extends PropertyKey,
T extends Record<PropertyKey, unknown>,
> = {
[P in keyof T]: ({ [Q in K]: P } & T[P]) extends infer U
? { [Q in keyof U]: U[Q] }
: never;
}[keyof T];