From b5eeb68b9b663075ace5fc5d0e3de30ae427540d Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Mon, 11 May 2026 20:47:51 +0200 Subject: [PATCH] =?UTF-8?q?Type=20framer-motion=20variants=20as=20Variants?= =?UTF-8?q?=20=E2=80=94=20kill=2033=20tsgo=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ToolbarView and FriendsBarView declared their motion variant objects without a type annotation, so tsgo widened transition.type to 'string' where framer-motion's Variants narrows it to a literal union (spring / tween / inertia / etc). Every site flagged the mismatch. Annotating the constants as Variants makes the literal inference work ('spring' stays 'spring'); also drops the redundant 'as const' on staggerDirection now that the parent type pins it. Net tsgo error count: 133 -> 100. --- .../friends/views/friends-bar/FriendsBarView.tsx | 8 ++++---- src/components/toolbar/ToolbarView.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/friends/views/friends-bar/FriendsBarView.tsx b/src/components/friends/views/friends-bar/FriendsBarView.tsx index 7f56628..de51519 100644 --- a/src/components/friends/views/friends-bar/FriendsBarView.tsx +++ b/src/components/friends/views/friends-bar/FriendsBarView.tsx @@ -2,18 +2,18 @@ import { FC, useRef, useState } from 'react'; import { FaChevronLeft, FaChevronRight } from 'react-icons/fa'; import { LocalizeText, MessengerFriend } from '../../../../api'; import { FriendBarItemView } from './FriendBarItemView'; -import { motion, AnimatePresence } from 'framer-motion'; +import { motion, AnimatePresence, Variants } from 'framer-motion'; const MAX_DISPLAY_COUNT = 3; // Mirrored from Toolbar to keep physics identical -const containerVariants = { +const containerVariants: Variants = { hidden: {}, visible: { transition: { staggerChildren: 0.05 } }, - exit: { transition: { staggerChildren: 0.03, staggerDirection: -1 as const } }, + exit: { transition: { staggerChildren: 0.03, staggerDirection: -1 } }, }; -const itemVariants = { +const itemVariants: Variants = { hidden: { opacity: 0, y: 10, scale: 0.8 }, visible: { opacity: 1, y: 0, scale: 1, transition: { type: 'spring', stiffness: 400, damping: 22 } }, exit: { opacity: 0, y: 6, scale: 0.85, transition: { duration: 0.1 } }, diff --git a/src/components/toolbar/ToolbarView.tsx b/src/components/toolbar/ToolbarView.tsx index 6caac21..a3c7d4c 100644 --- a/src/components/toolbar/ToolbarView.tsx +++ b/src/components/toolbar/ToolbarView.tsx @@ -1,5 +1,5 @@ import { CreateLinkEvent, Dispose, DropBounce, EaseOut, GetSessionDataManager, JumpBy, Motions, NitroToolbarAnimateIconEvent, PerkAllowancesMessageEvent, PerkEnum, Queue, Wait, YouTubeRoomSettingsEvent } from '@nitrots/nitro-renderer'; -import { AnimatePresence, motion } from 'framer-motion'; +import { AnimatePresence, motion, Variants } from 'framer-motion'; import { FC, useEffect, useState } from 'react'; import { GetConfigurationValue, MessengerIconState, OpenMessengerChat, setYoutubeRoomEnabled, VisitDesktop } from '../../api'; import { Flex, LayoutAvatarImageView, LayoutItemCountView } from '../../common'; @@ -8,13 +8,13 @@ import { ToolbarItemView } from './ToolbarItemView'; import { ToolbarMeView } from './ToolbarMeView'; import { YouTubePlayerView } from './YouTubePlayerView'; -const containerVariants = { +const containerVariants: Variants = { hidden: {}, visible: { transition: { staggerChildren: 0.05 } }, - exit: { transition: { staggerChildren: 0.03, staggerDirection: -1 as const } } + exit: { transition: { staggerChildren: 0.03, staggerDirection: -1 } } }; -const itemVariants = { +const itemVariants: Variants = { hidden: { opacity: 0, y: 10, scale: 0.8 }, visible: { opacity: 1, y: 0, scale: 1, transition: { type: 'spring', stiffness: 400, damping: 22 } }, exit: { opacity: 0, y: 6, scale: 0.85, transition: { duration: 0.1 } }