Skip to content

[BUG] framer-motion is incompatible with TypeScript v5.4 #2592

Closed
@ska-kialo

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:

  1. Install framer-motion v11.0.20 and TypeScript v5.4.3.
  2. Use the library in some way, e.g. const x: CSSStyleDeclarationWithTransform = {} as any;
  3. Run TypeScript.
  4. You see the following error, which seems to appear because lib.dom.d.ts now includes the properties x and y as string on CSSStyleDeclaration:
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:

  1. Clone the framer motion repository.
  2. Upgrade TypeScript to 5.4.3 (e.g. using this patch, this requires ignoring some deprecations which is a separate issue).
  3. Run yarn build.
  4. 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.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions