@justeattakeaway/pie-webc-core
Advanced tools
Comparing version 0.23.0 to 0.24.0
# Changelog | ||
## 0.24.0 | ||
### Minor Changes | ||
- [Changed] - Update default props generic helper type to include all props by default ([#1582](https://github.com/justeattakeaway/pie/pull/1582)) by [@xander-marjoram](https://github.com/xander-marjoram) | ||
[Changed] - Naming of generic type | ||
[Added] - JSDoc comment | ||
## 0.23.0 | ||
@@ -4,0 +13,0 @@ |
{ | ||
"name": "@justeattakeaway/pie-webc-core", | ||
"version": "0.23.0", | ||
"version": "0.24.0", | ||
"description": "PIE design system base classes, mixins and utilities for web components", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,1 +0,31 @@ | ||
export type ComponentDefaultPropsGeneric<T, K extends keyof T> = Readonly<Required<Pick<T, K>>>; | ||
/** | ||
* This type should be used when defining the default props for a component. | ||
* It is a generic type that takes two type parameters: | ||
* - `T` is the type of the props object that the default props are being defined for. | ||
* - `K` is the type of the keys in `T` that should be required in the default props. | ||
* By default, `K` is set to be all the keys in `T`. This means that all the keys in `T` will be required in the default props. | ||
* You can override this by specifying a subset of the keys in `T` that should be required in the default props. | ||
* | ||
* @example ```tsx | ||
* interface MyComponentProps { | ||
* a: string; | ||
* b?: number; | ||
* c: boolean; | ||
* } | ||
* const allProps: ComponentDefaultProps<MyComponentProps> = { | ||
* a: 'default value', | ||
* b: 42, | ||
* c: true, | ||
* }; | ||
* | ||
* const pickProps: ComponentDefaultProps<MyComponentProps, 'a'> = { | ||
* a: 'default value', | ||
* }; | ||
* | ||
* const omitProps: ComponentDefaultProps<MyComponentProps, keyof Omit<MyComponentProps, 'a'>> = { | ||
* b: 42, | ||
* c: true, | ||
* }; | ||
* ``` | ||
*/ | ||
export type ComponentDefaultProps<T, K extends keyof T = keyof T> = Readonly<Required<Pick<T, K>>>; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47534
914