node_modules/preact/src/jsx.d.ts:2145:22 - error TS2304: Cannot find name 'SVGSetElement'
Asked Answered
N

2

8

I am experiencing this build error since last two days (Angular App).

Error: node_modules/preact/src/jsx.d.ts:2138:24 - error TS2304: Cannot find name 'SVGMPathElement'. 2138 mpath: SVGAttributes<SVGMPathElement>;

node_modules/preact/src/jsx.d.ts:2145:22 - error TS2304: Cannot find name 'SVGSetElement'. 2145 set: SVGAttributes<SVGSetElement>;

enter image description here

I tried so many methods to resolve and followed many answers related to error 2304 module not found. But, None of them did work. node and angular versions are 16.16.0 and 11.2.14 respectively. Anyone experienced this error or anyone has solution please reply. Any response will be appreciated. Thank you!

Tried adding preact to the package.json and some other approaches given in stackoverflow

Neldanelia answered 28/2, 2023 at 11:13 Comment(0)
N
7

You're using an outdated version of TypeScript. Preact, as of v10.13.0, ships with definitions that consume built-ins from TS v4.4 (which shipped 2 years ago). If you're using a version of TypeScript older than this, they will not be available.

There's a number of options here though:

  1. Upgrade TypeScript to v4.4+
  2. Pin Preact to v10.12.1 (before this change was made)
  3. Add "skipLibCheck": true to your tsconfig.json
  4. Manually add the types
Nonchalance answered 28/2, 2023 at 23:14 Comment(2)
Adding "skipLibCheck": true to tsconfig.json did work for me. Thank you!Neldanelia
thanks bro save my life "skipLibCheck": true work ❤️❤️Doggish
T
1

I have been experiencing the same for last two days. In my local machine, where the npm packages were already installed, both serve and build worked fine. When it came to the pipeline, the build fails.

On checking the package-lock json, noticed that preact was getting installed as a dependency package. It looked like some type checking was failing for that library which was causing the issue. I'm still unclear on how this started happening all of a sudden. But updating the compiler options helped to resolve the issue for me.

Setting skipLibCheck to true in the compiler options of tsconfig helped me fix the issue. Hope the same works for you as well.

Thereat answered 28/2, 2023 at 21:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.