diff --git a/src/types.ts b/src/types.ts index e9cccc83..3208bd7c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,3 +54,17 @@ export interface EggAppConfig extends Record { supportParams?: boolean; }; } + +/** + * Powerful Partial, Support adding ? modifier to a mapped property in deep level + * @example + * import { PowerPartial, EggAppConfig } from 'egg'; + * + * // { view: { defaultEngines: string } } => { view?: { defaultEngines?: string } } + * type EggConfig = PowerPartial + */ +export type PowerPartial = { + [U in keyof T]?: T[U] extends object + ? PowerPartial + : T[U] +};