#1125·snabbdom

JSX.IntrinsicElements type error in editor

Author: PiIsFourCreated Nov 6, 2024Updated Jan 22, 2025

Hi, I wanted to try out snabbdom, but I'm stuck with this TS error and I'm out of ideas what I did wrong. Maybe anyone here has an idea what I could try.

Just set up an empty project with vite, added the index.html, and index.tsx. Installed snabbdom and added the jsx as documented to the tsconfig. The code is working in the browser.

But I get this error in vscode on the span: "JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. ts(7026)"

typescript
import { init, jsx, Fragment } from 'snabbdom'

const patch = init([])

const root = document.querySelector('#root')

if (!root)
    throw new Error('root div mising')

// const node = h('span', {}, ['hello world'])
const node = <span>hello world 2</span>

type test = jsx.IntrinsicElements

patch(root, node)

Not sure what to do about this, the type does seem to exist. I'm aware that the jsx is lower case. But importing it jsx as JSX, does not seem to help.

Thanks for investing the time to read this and sorry for any mistakes. Any help will be appreciated.