I am working on a simple hook to export animation helper and element ref i.e.
import { gsap } from 'gsap';
import { useRef } from 'react';
export function useTween<R extends gsap.TweenTarget>(vars: gsap.TweenVars['pixi']) {
const tweenRef = useRef<R>(null);
const tween = gsap.to(tweenRef.current, { pixi: vars });
return [tween, tweenRef];
}
What matters here is that returned array has types, however when I use it in another component i.e.
const [textTween, textRef] = useTween<Text>({ scale: 2 });
now textTween
and textRef
both have type of any
, I was under impression that these types would be preserved, but am I missing something here?