Skip to content

Commit

Permalink
Use Object.assign instead of object spread syntax to fix TypeScript e…
Browse files Browse the repository at this point in the history
…rrors

Use Object.assign instead of spread

More object.assign instead of spread
  • Loading branch information
ciampo committed Mar 23, 2022
1 parent 811ac88 commit 9ffcfb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions packages/components/src/utils/colors-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -179,6 +180,6 @@ export const COLORS = {
alert: ALERT,
admin: ADMIN,
ui: UI,
};
} );

export default COLORS;
9 changes: 5 additions & 4 deletions packages/components/src/utils/config-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down Expand Up @@ -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)',
};
} );

0 comments on commit 9ffcfb1

Please sign in to comment.