Skip to content

Commit

Permalink
* core: refactor size helpers types.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Aug 28, 2024
1 parent 1fd3db7 commit bfd1f48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/core/src/helpers/size.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type SizeSetting = number | `${number}%` | `${number}px` | `${number}/${number}` | (string & {}) | ((...args: unknown[]) => SizeSetting);
export type SizeSetting<A extends unknown[] = unknown[]> = number | `${number}%` | `${number}px` | `${number}/${number}` | (string & {}) | ((...args: A) => SizeSetting);

export function parseSize(size: SizeSetting, callbackArgs: unknown[] = []): [value: number, type?: 'px' | '%'] {
export function parseSize<A extends unknown[] = unknown[]>(size: SizeSetting, callbackArgs?: A): [value: number, type?: 'px' | '%'] {
if (typeof size === 'function') {
return parseSize(size(...callbackArgs));
return parseSize(size(...(callbackArgs || [])));
}
if (typeof size === 'number') {
return [size];
Expand All @@ -18,7 +18,7 @@ export function parseSize(size: SizeSetting, callbackArgs: unknown[] = []): [val
return [NaN];
}

export function toCssSize(size: SizeSetting | undefined | null, callbackArgs?: unknown[]): string | null {
export function toCssSize<A extends unknown[] = unknown[]>(size: SizeSetting | undefined | null, callbackArgs?: A): string | null {
if (size === undefined || size === null) {
return null;
}
Expand Down

0 comments on commit bfd1f48

Please sign in to comment.