From a01cd7c0c257f4031f5075630240fffdac29c058 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 22:47:04 +0800 Subject: [PATCH 1/5] chore(deps-dev): bump @types/node from 22.18.8 to 24.6.1 (#688) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.18.8 to 24.6.1. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-version: 24.6.1 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb810e97..dba8807b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@rc-component/np": "^1.0.3", "@testing-library/react": "^16.0.0", "@types/jest": "^29.4.0", - "@types/node": "^22.5.5", + "@types/node": "^24.6.1", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@types/react-is": "^19.0.0", From 1d5ae86656ff2e1e817a2b41965a836a8fc75eb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 22:53:56 +0800 Subject: [PATCH 2/5] chore(deps-dev): bump @types/jest from 29.5.14 to 30.0.0 (#651) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.5.14 to 30.0.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-version: 30.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: lijianan <574980606@qq.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dba8807b..f0c633ee 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@rc-component/father-plugin": "^2.0.1", "@rc-component/np": "^1.0.3", "@testing-library/react": "^16.0.0", - "@types/jest": "^29.4.0", + "@types/jest": "^30.0.0", "@types/node": "^24.6.1", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", From 33ca7f79e92865a6089afcb27cab65f1d31cb2dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 02:54:25 +0800 Subject: [PATCH 3/5] chore(deps-dev): bump glob from 9.3.5 to 11.0.3 (#649) Bumps [glob](https://github.com/isaacs/node-glob) from 9.3.5 to 11.0.3. - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](https://github.com/isaacs/node-glob/compare/v9.3.5...v11.0.3) --- updated-dependencies: - dependency-name: glob dependency-version: 11.0.3 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0c633ee..72fcdb1e 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "eslint-plugin-jest": "^28.2.0", "eslint-plugin-unicorn": "^56.0.1", "father": "^4.1.3", - "glob": "^9.2.1", + "glob": "^11.0.3", "husky": "^9.1.6", "lint-staged": "^15.1.0", "prettier": "^3.3.2", From 8a927851874191f680344de757faff18593a2b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Wed, 5 Nov 2025 15:56:01 +0800 Subject: [PATCH 4/5] chore: useEvent type support undefined (#706) * chore: useEvent type support undefined * chore: update --- src/hooks/useEvent.ts | 14 ++++++++++---- tests/hooks.test.tsx | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/hooks/useEvent.ts b/src/hooks/useEvent.ts index f9bb7dce..4c6f92a0 100644 --- a/src/hooks/useEvent.ts +++ b/src/hooks/useEvent.ts @@ -2,12 +2,18 @@ /* eslint-disable react-hooks/exhaustive-deps */ import * as React from 'react'; -function useEvent(callback: T): T { - const fnRef = React.useRef(); +function useEvent any) | undefined>( + callback: T, +): undefined extends T + ? ( + ...args: Parameters> + ) => ReturnType> | undefined + : T { + const fnRef = React.useRef(callback); fnRef.current = callback; - const memoFn = React.useCallback( - ((...args: any) => fnRef.current?.(...args)) as any, + const memoFn = React.useCallback( + (...args: any[]) => fnRef.current?.(...args), [], ); diff --git a/tests/hooks.test.tsx b/tests/hooks.test.tsx index b8154c66..fc096500 100644 --- a/tests/hooks.test.tsx +++ b/tests/hooks.test.tsx @@ -9,6 +9,7 @@ import useMobile from '../src/hooks/useMobile'; import useState from '../src/hooks/useState'; import useSyncState from '../src/hooks/useSyncState'; import useControlledState from '../src/hooks/useControlledState'; +import useEvent from '../src/hooks/useEvent'; global.disableUseId = false; @@ -706,4 +707,23 @@ describe('hooks', () => { expect(container.textContent).toEqual('2'); }); }); + + describe('useEvent', () => { + it('extract type', () => { + const Demo = (props: { + canUndefined?: (a: number) => boolean; + notUndefined: (a: number) => boolean; + }) => { + const ua = useEvent(props.canUndefined); + const ub = useEvent(props.notUndefined); + + ua(1); + ub(2); + + return null; + }; + + expect(Demo).toBeTruthy(); + }); + }); }); From 04ff654037be3b37eb5594270e6a8cb14478e1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Wed, 5 Nov 2025 16:13:51 +0800 Subject: [PATCH 5/5] chore: bump version to 1.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72fcdb1e..75ad891d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rc-component/util", - "version": "1.3.0", + "version": "1.3.1", "description": "Common Utils For React Component", "keywords": [ "react",