Skip to content

Commit 92eac9a

Browse files
committed
fix: update safe type Feature[] to Array<typeof Feature>
1 parent 5c84a10 commit 92eac9a

File tree

7 files changed

+11
-12
lines changed

7 files changed

+11
-12
lines changed

packages/motion/src/components/lazy-motion/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createContext } from '@/utils'
33
import type { Ref } from 'vue'
44

55
export type LazyMotionContext = {
6-
features: Ref<Feature[]>
6+
features: Ref<Array<typeof Feature>>
77
strict: boolean
88
}
99
export const [useLazyMotionContext, lazyMotionContextProvider] = createContext<LazyMotionContext>('LazyMotionContext')

packages/motion/src/components/motion/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type MotionCompProps = {
1212
}
1313
export interface MotionCreateOptions {
1414
forwardMotionProps?: boolean
15-
features?: Feature[]
15+
features?: Array<typeof Feature>
1616
}
1717
export function checkMotionIsHidden(instance: ComponentPublicInstance) {
1818
const isHidden = getMotionElement(instance.$el)?.style.display === 'none'
@@ -104,7 +104,7 @@ export function createMotionComponent(
104104
props: {
105105
...MotionComponentProps,
106106
features: {
107-
type: Object as PropType<Feature[] | Promise<Feature[]>>,
107+
type: Object as PropType<Array<typeof Feature> | Promise<Array<typeof Feature>>>,
108108
default: () => (options.features || []),
109109
},
110110
as: { type: [String, Object], default: component || 'div' },
@@ -163,7 +163,7 @@ type MotionNameSpace = {
163163
} & MotionCompProps
164164

165165
export function createMotionComponentWithFeatures(
166-
features: Feature[] = [],
166+
features: Array<typeof Feature> = [],
167167
) {
168168
return new Proxy({} as unknown as MotionNameSpace, {
169169
get(target, prop) {

packages/motion/src/features/dom-animation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { FocusGesture } from '@/features/gestures/focus'
99
// import { PanGesture } from '@/features/gestures/pan'
1010
import type { Feature } from '@/features/feature'
1111

12-
export const domAnimation = [
12+
export const domAnimation: Array<typeof Feature> = [
1313
AnimationFeature,
1414
PressGesture,
1515
HoverGesture,
1616
InViewGesture,
1717
FocusGesture,
18-
] as unknown as Feature[]
18+
]

packages/motion/src/features/dom-max.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LayoutFeature } from '@/features/layout/layout'
99
import { PanGesture } from '@/features/gestures/pan'
1010
import type { Feature } from '@/features/feature'
1111

12-
export const domMax = [
12+
export const domMax: Array<typeof Feature> = [
1313
AnimationFeature,
1414
PressGesture,
1515
HoverGesture,
@@ -19,4 +19,4 @@ export const domMax = [
1919
PanGesture,
2020
DragGesture,
2121
LayoutFeature,
22-
] as unknown as Feature[]
22+
]

packages/motion/src/features/feature-manager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ export class FeatureManager {
77
constructor(state: MotionState) {
88
const { features = [], lazyMotionContext } = state.options
99
const allFeatures = features.concat(lazyMotionContext.features.value)
10-
this.features = allFeatures.map((Feature: any) => new Feature(state))
10+
this.features = allFeatures.map(Feature => new Feature(state))
1111
// watch for lazy motion features
12-
// @eslint-disable-next-line
1312
const featureInstances = this.features
1413
/**
1514
* Watch for lazy motion features

packages/motion/src/features/feature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MotionState } from '@/state/motion-state'
22

3-
export abstract class Feature {
3+
export class Feature {
44
state: MotionState
55

66
constructor(state: MotionState) {

packages/motion/src/state/motion-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class MotionState {
3030
public parent?: MotionState
3131
public options: Options & {
3232
animatePresenceContext?: PresenceContext
33-
features?: Feature[]
33+
features?: Array<typeof Feature>
3434
lazyMotionContext?: LazyMotionContext
3535
}
3636

0 commit comments

Comments
 (0)