From a63e95f0237bdeca6682404a09bcbf98979b93d7 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Thu, 31 Mar 2022 10:10:39 +0200 Subject: [PATCH 1/3] Components utils: use Object.assign instead of { ...spread } syntax to avoid errors in the code generated by TypeScript --- packages/components/src/utils/colors-values.js | 7 ++++--- packages/components/src/utils/config-values.js | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/components/src/utils/colors-values.js b/packages/components/src/utils/colors-values.js index dcdc87821fd3af..5ad74c7000b935 100644 --- a/packages/components/src/utils/colors-values.js +++ b/packages/components/src/utils/colors-values.js @@ -166,8 +166,9 @@ export const UI = { textLight: BASE.black, }; -export const COLORS = { - ...BASE, +// Using Object.assign instead of { ...spread } syntax helps TypeScript +// to extract the correct type defs here. +export const COLORS = Object.assign( {}, BASE, { darkGray: merge( {}, DARK_GRAY, G2.darkGray ), darkOpacity: DARK_OPACITY, darkOpacityLight: DARK_OPACITY_LIGHT, @@ -179,6 +180,6 @@ export const COLORS = { alert: ALERT, admin: ADMIN, ui: UI, -}; +} ); export default COLORS; diff --git a/packages/components/src/utils/config-values.js b/packages/components/src/utils/config-values.js index b1e624b4e8931e..21edd8d64ebfea 100644 --- a/packages/components/src/utils/config-values.js +++ b/packages/components/src/utils/config-values.js @@ -26,15 +26,16 @@ const CONTROL_PROPS = { controlHeightLarge: `calc( ${ CONTROL_HEIGHT } * 1.2 )`, controlHeightXLarge: `calc( ${ CONTROL_HEIGHT } * 1.4 )`, }; + const TOGGLE_GROUP_CONTROL_PROPS = { toggleGroupControlBackgroundColor: CONTROL_PROPS.controlBackgroundColor, toggleGroupControlBorderColor: COLORS.ui.border, toggleGroupControlButtonColorActive: CONTROL_PROPS.controlBackgroundColor, }; -export default { - ...CONTROL_PROPS, - ...TOGGLE_GROUP_CONTROL_PROPS, +// Using Object.assign to avoid creating circular references when emitting +// TypeScript type declarations +export default Object.assign( {}, CONTROL_PROPS, TOGGLE_GROUP_CONTROL_PROPS, { colorDivider: 'rgba(0, 0, 0, 0.1)', colorScrollbarThumb: 'rgba(0, 0, 0, 0.2)', colorScrollbarThumbHover: 'rgba(0, 0, 0, 0.5)', @@ -79,4 +80,4 @@ export default { transitionDurationFastest: '100ms', transitionTimingFunction: 'cubic-bezier(0.08, 0.52, 0.52, 1)', transitionTimingFunctionControl: 'cubic-bezier(0.12, 0.8, 0.32, 1)', -}; +} ); From 45dc9ff06ea7da222147fadbcc69b67f6a67cf71 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Thu, 31 Mar 2022 10:46:15 +0200 Subject: [PATCH 2/3] CHANGELOG --- packages/components/CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index b6d13f24455cf8..3ef364d5318132 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- Update `BorderControl` and `BorderBoxControl` to allow the passing of custom class names to popovers ([#39753](https://github.com/WordPress/gutenberg/pull/39753)). +- Update `BorderControl` and `BorderBoxControl` to allow the passing of custom class names to popovers ([#39753](https://github.com/WordPress/gutenberg/pull/39753)). ### Internal @@ -12,8 +12,12 @@ ### New Features -- Add `BorderControl` component ([#37769](https://github.com/WordPress/gutenberg/pull/37769)). -- Add `BorderBoxControl` component ([#38876](https://github.com/WordPress/gutenberg/pull/38876)). +- Add `BorderControl` component ([#37769](https://github.com/WordPress/gutenberg/pull/37769)). +- Add `BorderBoxControl` component ([#38876](https://github.com/WordPress/gutenberg/pull/38876)). + +### Bug Fix + +- Use `Object.assign` instead of `{ ...spread }` syntax to avoid errors in the code generated by TypeScript ([#39932](https://github.com/WordPress/gutenberg/pull/39932)). ## 19.7.0 (2022-03-23) From d20d4314c76e6cf84a980afe2ee5ce0cc0577ff2 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Thu, 31 Mar 2022 12:41:06 +0200 Subject: [PATCH 3/3] Update packages/components/src/utils/config-values.js Co-authored-by: Nik Tsekouras --- packages/components/src/utils/config-values.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/src/utils/config-values.js b/packages/components/src/utils/config-values.js index 21edd8d64ebfea..a049b5ce0847ff 100644 --- a/packages/components/src/utils/config-values.js +++ b/packages/components/src/utils/config-values.js @@ -34,7 +34,7 @@ const TOGGLE_GROUP_CONTROL_PROPS = { }; // Using Object.assign to avoid creating circular references when emitting -// TypeScript type declarations +// TypeScript type declarations. export default Object.assign( {}, CONTROL_PROPS, TOGGLE_GROUP_CONTROL_PROPS, { colorDivider: 'rgba(0, 0, 0, 0.1)', colorScrollbarThumb: 'rgba(0, 0, 0, 0.2)',