-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrade github actions to v3, node to 16.x, jest to 29.5 and r…
…ollup to 3.20.2 + fix typing
- Loading branch information
Pierre Burel
committed
Mar 27, 2023
1 parent
59b8935
commit 9fbba5a
Showing
6 changed files
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
export type Input = number | string | Input[] | { [key: string]: Input }; | ||
|
||
// Return same types as input but recursively cast number as string | ||
export type Output<T> = T extends number ? string : { [K in keyof T]: Output<T[K]> } | ||
// Return same types as input but recursively cast number as string if unit !== false | ||
export type Output<T, O> = T extends number ? O extends { unit: false } ? T : string : { [K in keyof T]: Output<T[K], O> } | ||
|
||
export type To = 'rem' | 'em' | 'px'; | ||
|
||
export type Options = { | ||
baseline?: number; | ||
precision?: number; | ||
unit?: boolean; | ||
} | ||
|
||
export function convert<Value extends Input>(value: Value, to?: To, options?: Options): Output<Value>; | ||
export function convert<I extends Input, _, O extends Options>(value: I, to?: To, options?: O): Output<I, O>; | ||
|
||
export function rem<Value extends Input>(value: Value, options?: Options): Output<Value>; | ||
export function rem<I extends Input, O extends Options>(value: I, options?: O): Output<I, O>; | ||
|
||
export function em<Value extends Input>(value: Value, baseline: Options['baseline'], options?: Omit<Options, 'baseline'>): Output<Value>; | ||
export function em<I extends Input, _, O extends Options>(value: I, baseline: Options['baseline'], options?: Omit<Options, 'baseline'>): Output<I, O>; | ||
|
||
export function px<Value extends Input>(value: Value, options?: Options): Output<Value>; | ||
export function px<I extends Input, O extends Options>(value: I, options?: Options): Output<I, O>; | ||
|
||
export default rem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters