From af10376aafa9a723572ee9bef8df0ac4749d1711 Mon Sep 17 00:00:00 2001 From: heygsc <1596920983@qq.com> Date: Tue, 9 Jul 2024 16:56:17 +0800 Subject: [PATCH 1/2] add type-feature --- src/utils/type-feature.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/utils/type-feature.ts diff --git a/src/utils/type-feature.ts b/src/utils/type-feature.ts new file mode 100644 index 00000000..bc523874 --- /dev/null +++ b/src/utils/type-feature.ts @@ -0,0 +1,7 @@ +export function objectEntries(obj: T) { + return Object.entries(obj) as Array<[keyof T, T[keyof T]]> +} + +export function objectKeys(obj: T) { + return Object.keys(obj) as Array +} From 201692100cce465746b5ee2fbfc87e6e82654533 Mon Sep 17 00:00:00 2001 From: heygsc <1596920983@qq.com> Date: Tue, 9 Jul 2024 16:57:19 +0800 Subject: [PATCH 2/2] fix: types --- src/useMotionProperties.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/useMotionProperties.ts b/src/useMotionProperties.ts index 6dbbd2bf..7658d84a 100644 --- a/src/useMotionProperties.ts +++ b/src/useMotionProperties.ts @@ -5,6 +5,7 @@ import { useElementStyle } from './useElementStyle' import { useElementTransform } from './useElementTransform' import { usePermissiveTarget } from './usePermissiveTarget' import { isTransformProp } from './utils/transform' +import { objectEntries } from './utils/type-feature' /** * A Composable giving access to both `transform` and `style`objects for a single element. @@ -29,12 +30,10 @@ export function useMotionProperties(target: MaybeRef, defaultV watch( motionProperties, (newVal) => { - Object.entries(newVal).forEach(([key, value]) => { + objectEntries(newVal).forEach(([key, value]) => { const target = isTransformProp(key) ? transform : style - // @ts-expect-error - Fix errors later for typescript 5 if (target[key] && target[key] === value) return - // @ts-expect-error - Fix errors later for typescript 5 target[key] = value }) },