Skip to content

Instantly share code, notes, and snippets.

@julenwang
Last active December 17, 2021 06:08
Show Gist options
  • Save julenwang/87bc5a11347412746a92d7bfa0dec196 to your computer and use it in GitHub Desktop.
Save julenwang/87bc5a11347412746a92d7bfa0dec196 to your computer and use it in GitHub Desktop.
import { Merge } from 'type-fest';
export type AsyncFunction = (...args: any[]) => Promise<any>;
/**
* 扩展对象联合类型的每一项
*/
export type ExpandObjectUnion<Union, Item extends Record<string, unknown>> = Union extends unknown
? Merge<Union, Item>
: never;
export type NonNullableAll<T> = {
[P in keyof T]: NonNullable<T[P]>;
};
export type ArrayItem<T> = T extends (infer P)[] ? P : never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment