-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add types to style mixins #26369
Add types to style mixins #26369
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,10 @@ function useJumpStep( { | |
const [ isShiftKey, setIsShiftKey ] = useState( false ); | ||
|
||
useEffect( () => { | ||
const handleShiftKeyToggle = ( event ) => { | ||
const handleShiftKeyToggle = ( | ||
/** @type {KeyboardEvent} */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This get's passed to |
||
event | ||
) => { | ||
setIsShiftKey( event.shiftKey ); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,24 +19,23 @@ export function getNumber( value ) { | |
/** | ||
* Safely adds 2 values. | ||
* | ||
* @param {number|string} args Values to add together. | ||
* @param {(number|string)[]} args Values to add together. | ||
* | ||
* @return {number} The sum of values. | ||
*/ | ||
export function add( ...args ) { | ||
return args.reduce( ( sum, arg ) => sum + getNumber( arg ), 0 ); | ||
return args.map( getNumber ).reduce( ( sum, arg ) => sum + arg, 0 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and the change below should be equivalent in runtime but appeases the typechecking (I couldn't figure out how to communicate to TS through JSDoc that |
||
} | ||
|
||
/** | ||
* Safely subtracts 2 values. | ||
* | ||
* @param {number|string} args Values to subtract together. | ||
* @param {(number|string)[]} args Values to subtract together. | ||
* | ||
* @return {number} The difference of the 2 values. | ||
*/ | ||
export function subtract( ...args ) { | ||
return args.reduce( ( diff, arg, index ) => { | ||
const value = getNumber( arg ); | ||
return args.map( getNumber ).reduce( ( diff, value, index ) => { | ||
return index === 0 ? value : diff - value; | ||
} ); | ||
} | ||
|
@@ -56,10 +55,10 @@ function getPrecision( value ) { | |
/** | ||
* Clamps a value based on a min/max range with rounding | ||
* | ||
* @param {number} value The value. | ||
* @param {number} min The minimum range. | ||
* @param {number} max The maximum range. | ||
* @param {number} step A multiplier for the value. | ||
* @param {number} [value=0] The value. | ||
* @param {number} [min=Infinity] The minimum range. | ||
* @param {number} [max=Infinity] The maximum range. | ||
* @param {number} [step=1] A multiplier for the value. | ||
* | ||
* @return {number} The rounded and clamped value. | ||
*/ | ||
|
@@ -84,11 +83,7 @@ export function roundClamp( | |
* Clamps a value based on a min/max range with rounding. | ||
* Returns a string. | ||
* | ||
* @param {any} args Arguments for roundClamp(). | ||
* @property {number} value The value. | ||
* @property {number} min The minimum range. | ||
* @property {number} max The maximum range. | ||
* @property {number} step A multiplier for the value. | ||
* @param {Parameters<roundClamp>} args Arguments for roundClamp(). | ||
* | ||
* @return {string} The rounded and clamped value. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template
T
isn't in scope here 😕