test.tsx
<img onerror="this.style.display='none'" height="178" cmd="start" />
yields
error TS2339: Property 'onerror' does not exist on type 'HTMLAttributes'.
So I add to test.tsx above the JSX part:
namespace JSX {
interface HTMLAttributes {
onerror?: any; // 1. attempt: add the missing onerror attribute
}
interface IntrinsicElements {
img: any // 2. attempt: generally override the type of img, allowing anything
}
}
But with no effect. Hmm?
How can I locally add attributes to the JSX code that i want to use?
I know that I can brutally hack the imported types file, but i would like to know if there is a local way.
edit: In addition to the onerror attribute (that is 'erroneously' missing in preact.d.ts) I would generally like to know how I can add ad-hoc attributes to intrinsic or even my own elements. Curiously and phantastically, typescript never complains about "data-*" attributes which I likely will switch over too (want to be a nice html5 dev anyway). But the question about expansion of interface HTMLAttributes is still open to me.