0

How do I add web components to typescript JSX type for preact on Deno?

enter image description here

/// <reference lib="dom" />

/** @jsx h */
import { PreactDOMAttributes, h } from 'https://esm.sh/preact@10.16.0'

type CustomEvents<K extends string> = { [key in K] : (event: CustomEvent) => void };
type CustomElement<T, K extends string> = Partial<T & PreactDOMAttributes & { children: any } & CustomEvents<`on${K}`>>;

class InputObject extends HTMLElement {}

declare global {
  namespace JSX {
    interface IntrinsicElements {
      ['template']: HTMLTemplateElement;
      ['input-object']: CustomElement<InputObject, ''>
    }
  }
}

const meow = () => {
  return (
    <input-object>
      <template data-item>
        <input name="meow"/>
      </template>
    </input-object>
  )
}
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
  • Does this answer your question? [Using web-components within Preact and typescript](https://stackoverflow.com/questions/61015445/using-web-components-within-preact-and-typescript) – jsejcksn Aug 14 '23 at 14:06

0 Answers0