From 409eef10d7cf6ec79b457cfe7b03ce3eadeef894 Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Tue, 18 May 2021 08:39:11 -0700 Subject: [PATCH] compose: Add types to `usePrevious` --- packages/compose/README.md | 2 +- packages/compose/src/hooks/use-previous/index.js | 4 ++-- packages/compose/tsconfig.json | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/compose/README.md b/packages/compose/README.md index 016560af43f142..be4650584d31f4 100644 --- a/packages/compose/README.md +++ b/packages/compose/README.md @@ -332,7 +332,7 @@ _Parameters_ _Returns_ -- `T|undefined`: The value from the previous render. +- `T | undefined`: The value from the previous render. # **useReducedMotion** diff --git a/packages/compose/src/hooks/use-previous/index.js b/packages/compose/src/hooks/use-previous/index.js index 035a272b06953c..c50e392a43226a 100644 --- a/packages/compose/src/hooks/use-previous/index.js +++ b/packages/compose/src/hooks/use-previous/index.js @@ -11,14 +11,14 @@ import { useEffect, useRef } from '@wordpress/element'; * * @param {T} value The value to track. * - * @return {T|undefined} The value from the previous render. + * @return {T | undefined} The value from the previous render. */ export default function usePrevious( value ) { // Disable reason: without an explicit type detail, the type of ref will be // inferred based on the initial useRef argument, which is undefined. // https://github.com/WordPress/gutenberg/pull/22597#issuecomment-633588366 /* eslint-disable jsdoc/no-undefined-types */ - const ref = useRef( /** @type {T|undefined} */ ( undefined ) ); + const ref = useRef( /** @type {T | undefined} */ ( undefined ) ); /* eslint-enable jsdoc/no-undefined-types */ // Store current value in ref. diff --git a/packages/compose/tsconfig.json b/packages/compose/tsconfig.json index 460abe2c783394..3b8bd5e142d149 100644 --- a/packages/compose/tsconfig.json +++ b/packages/compose/tsconfig.json @@ -17,6 +17,7 @@ "src/hooks/use-async-list/**/*", "src/hooks/use-constrained-tabbing/**/*", "src/hooks/use-instance-id/**/*", + "src/hooks/use-previous/**/*", "src/utils/**/*" ] }