Skip to content

Commit

Permalink
fix: export PowerPartial
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Feb 4, 2025
1 parent 799d37f commit fd97c8d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ export interface EggAppConfig extends Record<string, any> {
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<EggAppConfig>
*/
export type PowerPartial<T> = {
[U in keyof T]?: T[U] extends object
? PowerPartial<T[U]>
: T[U]
};

0 comments on commit fd97c8d

Please sign in to comment.