Skip to content

Type Alias: AppendDefault<T, D>

ts
type AppendDefault<T, D> = {
  [P in keyof T]-?: unknown extends D[P]
    ? T[P]
    : T[P] extends Record<string, unknown>
      ? Omit<T[P], "type" | "default"> & {
          default: MergeDefault<T[P], D[P]>;
          type: PropType<MergeTypeDefault<T[P], D[P]>>;
        }
      : {
          default: MergeDefault<T[P], D[P]>;
          type: PropType<MergeTypeDefault<T[P], D[P]>>;
        };
};

Applies default values to component prop definitions. For each prop, if a default is provided, it updates the prop's default and type accordingly.

Type Parameters

Type ParameterDescription
T extends ComponentObjectPropsOptionsThe component props options
D extends PartialKeys<T>Partial defaults object with values for some props