Type Alias: ExtractPublicDefaultPropTypes<O>
ts
type ExtractPublicDefaultPropTypes<O> = {
[K in keyof ExtractDefaultPropTypes<O> &
keyof ExtractPublicPropTypes<O>]: NonNullable<
ExtractDefaultPropTypes<O>[K]
>;
};Extract default values for properties that are both public and have defaults. This ensures we only get defaults for props that are actually exposed to consumers.
This type intersects the keys from both ExtractDefaultPropTypes and ExtractPublicPropTypes to create a type that only includes properties that are:
- Public (exposed to component consumers)
- Have default values defined
- Are not nullable/undefined
Type Parameters
| Type Parameter | Description |
|---|---|
O | The props object type to extract from |
Example
typescript
type MyProps = {
publicWithDefault: { type: StringConstructor; default: "hello" };
publicRequired: { type: NumberConstructor; required: true };
privateWithDefault: {
type: BooleanConstructor;
default: false;
__internal: true;
};
};
type Defaults = ExtractPublicDefaultPropTypes<MyProps>;
// Result: { publicWithDefault: string }