midwinter
Version:
A next-gen middleware engine built for the WinterCG environments.
22 lines (20 loc) • 718 B
TypeScript
type Awaitable<T> = Promise<T> | T;
/** Simplify ({...} & {...}) types into a unified object */
type Simplify<T> = {
[KeyType in keyof T]: T[KeyType];
} & {};
/**
* Merge two objects, at a depth of 1, where keys of B take precedence over A
*/
type MergeObjectsShallow<A, B> = Simplify<{
[K in keyof A]: K extends keyof B ? B[K] : A[K];
} & B>;
type UnknownValues<T> = {
[Key in keyof T]: unknown;
};
type AnyCtx = Record<PropertyKey, unknown>;
type AnyMeta = Record<PropertyKey, unknown>;
type Strip<T, U> = {
[Key in keyof T as [T[Key]] extends [U] ? never : Key]: T[Key];
} & {};
export type { AnyCtx as A, MergeObjectsShallow as M, Strip as S, UnknownValues as U, AnyMeta as a, Awaitable as b };