pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.62k stars 1.6k forks source link

property does not exist on JSX.IntrinsicElements - ts(2339) #3385

Open dragidavid opened 3 weeks ago

dragidavid commented 3 weeks ago

Hey all 👋

recently update to next 15/react 19 and since then I'm getting these errors for basic threejs elements like ambientLight, spotLight and geometries

Property 'ambientLight' does not exist on type 'JSX.IntrinsicElements'.ts(2339)

Screenshot 2024-10-27 at 23 14 08

Anyone's got a fix or workaround for this?

mmmoli commented 3 weeks ago

+1 got this too.

kumikumi commented 3 weeks ago

I just started using react-three-fiber yesterday and thought I was losing my mind, glad I'm not the only one having this issue.

Here's what worked for me.

You'll need to put this in a file somewhere (e.g. a types.d.ts file). Make sure to configure typeRoots in tsconfig.json to include the directory where you put the file

import { ThreeElements } from '@react-three/fiber'

declare global {
  namespace React {
    namespace JSX {
        interface IntrinsicElements extends ThreeElements {
        }
    }
  }
}

This fixed it for me. FWIW I'm using this library with preact with preact/compat and preact-reconciler