[BUG] framer-motion is incompatible with TypeScript v5.4 #2592
Closed
Description
1. Read the FAQs 👇
Done, couldn't find anything related.
2. Describe the bug
Upgrading TypeScript to v5.4(.3) in our project produces a type error in framer-motion.
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
I couldn't figure out how to run type checking in CodeSandbox.
See steps below.
4. Steps to reproduce
Steps to reproduce on a repository that uses framer-motion:
- Install framer-motion v11.0.20 and TypeScript v5.4.3.
- Use the library in some way, e.g.
const x: CSSStyleDeclarationWithTransform = {} as any;
- Run TypeScript.
- You see the following error, which seems to appear because
lib.dom.d.ts
now includes the propertiesx
andy
asstring
onCSSStyleDeclaration
:
node_modules/framer-motion/dist/index.d.ts:1212:11 - error TS2430: Interface 'CSSStyleDeclarationWithTransform' incorrectly extends interface 'Omit<CSSStyleDeclaration, "direction" | "transition">'.
Types of property 'x' are incompatible.
Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
Steps to reproduce on this repository:
- Clone the framer motion repository.
- Upgrade TypeScript to 5.4.3 (e.g. using this patch, this requires ignoring some deprecations which is a separate issue).
- Run
yarn build
. - You see the same error as mentioned above.
5. Expected behavior
No type errors are reported.
6. Video or screenshots
--
7. Environment details
Running on macOS on an M1 Mac. Can easily be reproduced on other systems.