#How can we type web components in Astro?

5 messages · Page 1 of 1 (latest)

green brook
#

I'm trying to use a custom web component in a .tsx file (React) in Astro. My code looks like this:

export const SomeComponent = ({ 
  code,
  state,
}: Props) => {


  return ( 
    <custom-web-component
      code={code}
      state={state}
    ></custom-web-component>
  )
}

and I'm getting an error like this:

Property 'custom-web-component' does not exist on type 'JSX.IntrinsicElements'

How can I solve this issue? Thanks!

visual iris
green brook
#

Thanks! That solution works when I put that definition in the same file as the component but it doesn't work if I move it to some arbitrary d.ts file. Do you happen to know the solution for housing this globally in a project?

green brook
#

Well now the original solution suddenly stopped working and I'm back to the original error. I don't believe I changed anything... 😮‍💨

visual iris