Skip to content

Commit

Permalink
♻️ Don't place @deprecated function overload first
Browse files Browse the repository at this point in the history
  • Loading branch information
juliencrn committed Feb 6, 2024
1 parent 87ba579 commit dddbf01
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
40 changes: 20 additions & 20 deletions packages/usehooks-ts/src/useCountdown/useCountdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,6 @@ interface CountdownControllers {
resetCountdown: () => void
}

/**
* A hook to manage countdown - Legacy interface
* @overload
* @param {LegacyCountdownOptions} countdownOptions the countdown's options.
* @param {number} countdownOptions.seconds the countdown's number, generally time seconds.
* @param {number} countdownOptions.interval the countdown's interval, milliseconds.
* @param {?boolean} [countdownOptions.isIncrement] `false` by default, determine the countdown is increment, otherwise is decrement.
* @returns {[number, LegacyCountdownControllers]} An array containing the countdown's count and its controllers.
* @deprecated new useCountdown interface is already available (see [Documentation](https://usehooks-ts.com/react-hook/use-countdown)), the old version will retire on usehooks-ts@3.
* @see [Documentation](https://usehooks-ts.com/react-hook/use-countdown)
* @example
* const [counter, { start, stop, reset }] = useCountdown({
* seconds: 10,
* interval: 1000,
* isIncrement: false,
* });
*/
export function useCountdown(
countdownOptions: LegacyCountdownOptions,
): [number, LegacyCountdownControllers]
/**
* A hook to manage countdown - New interface with default value.
* @overload
Expand All @@ -71,6 +51,26 @@ export function useCountdown(
export function useCountdown(
countdownOptions: CountdownOptions,
): [number, CountdownControllers]
/**
* A hook to manage countdown - Legacy interface
* @overload
* @param {LegacyCountdownOptions} countdownOptions the countdown's options.
* @param {number} countdownOptions.seconds the countdown's number, generally time seconds.
* @param {number} countdownOptions.interval the countdown's interval, milliseconds.
* @param {?boolean} [countdownOptions.isIncrement] `false` by default, determine the countdown is increment, otherwise is decrement.
* @returns {[number, LegacyCountdownControllers]} An array containing the countdown's count and its controllers.
* @deprecated new useCountdown interface is already available (see [Documentation](https://usehooks-ts.com/react-hook/use-countdown)), the old version will retire on usehooks-ts@3.
* @see [Documentation](https://usehooks-ts.com/react-hook/use-countdown)
* @example
* const [counter, { start, stop, reset }] = useCountdown({
* seconds: 10,
* interval: 1000,
* isIncrement: false,
* });
*/
export function useCountdown(
countdownOptions: LegacyCountdownOptions,
): [number, LegacyCountdownControllers]
/**
* A hook to manage countdown
* @param {CountdownOptions | LegacyCountdownOptions} countdownOptions the countdown's options.
Expand Down
2 changes: 1 addition & 1 deletion packages/usehooks-ts/src/useDarkMode/useDarkMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface DarkModeOutput {
set: (value: boolean) => void
}

export function useDarkMode(options?: DarkModeOptions): DarkModeOutput
/**
* Custom hook that returns the current state of the dark mode.
* @deprecated this useDarkMode's signature is deprecated, it now accepts an options object instead of multiple parameters.
Expand All @@ -35,7 +36,6 @@ export function useDarkMode(
defaultValue: boolean,
localStorageKey?: string,
): DarkModeOutput
export function useDarkMode(options?: DarkModeOptions): DarkModeOutput
/**
* Custom hook that returns the current state of the dark mode.
* @param {?boolean | ?DarkModeOptions} [options] - the initial value of the dark mode, default `false`.
Expand Down
8 changes: 4 additions & 4 deletions packages/usehooks-ts/src/useMediaQuery/useMediaQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ type UseMediaQueryOptions = {

const IS_SERVER = typeof window === 'undefined'

export function useMediaQuery(
query: string,
options?: UseMediaQueryOptions,
): boolean
/**
* Custom hook for tracking the state of a media query.
* @deprecated - this useMediaQuery's signature is deprecated, it now accepts an query parameter and an options object.
Expand All @@ -22,10 +26,6 @@ const IS_SERVER = typeof window === 'undefined'
* // Use `isSmallScreen` to conditionally apply styles or logic based on the screen size.
*/
export function useMediaQuery(query: string, defaultValue: boolean): boolean // defaultValue should be false by default
export function useMediaQuery(
query: string,
options?: UseMediaQueryOptions,
): boolean
/**
* Custom hook for tracking the state of a media query.
* @param {string} query - The media query to track.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type TernaryDarkModeResult = {
toggleTernaryDarkMode: () => void
}

export function useTernaryDarkMode(
options?: TernaryDarkModeOptions,
): TernaryDarkModeResult
/**
* Custom hook for managing ternary (system, dark, light) dark mode with local storage support.
* @deprecated this useTernaryDarkMode's signature is deprecated, it now accepts an options object instead of multiple parameters.
Expand All @@ -34,11 +37,6 @@ type TernaryDarkModeResult = {
export function useTernaryDarkMode(
localStorageKey: string,
): TernaryDarkModeResult

export function useTernaryDarkMode(
options?: TernaryDarkModeOptions,
): TernaryDarkModeResult

/**
* Custom hook for managing ternary (system, dark, light) dark mode with local storage support.
* @param {?TernaryDarkModeOptions | string} [options] - Options or the local storage key for the hook.
Expand Down

0 comments on commit dddbf01

Please sign in to comment.