svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Typescript Error when defining custom elements as a consumer in Svelte v4

Open afreidz opened this issue 1 year ago • 0 comments

Describe the bug

When enabling custom elements compiler option, defining a custom element tag name using Component.element (as per the v4 docs) produces a type error. The __SvelteComponent_ type cannot resolve element.

Reproduction

Stackblitz: https://stackblitz.com/edit/vitejs-vite-3sffk2?file=src%2Fmain.ts

Logs

❯ npm run check

> [email protected] check
> svelte-check --tsconfig ./tsconfig.json


====================================
Loading svelte-check in workspace: /home/projects/vitejs-vite-3sffk2
Getting Svelte diagnostics...

/home/projects/vitejs-vite-3sffk2/src/main.ts:4:45
Error: Property 'element' does not exist on type 'typeof Counter__SvelteComponent_'. 

customElements.define("my-counter", Counter.element);



====================================
svelte-check found 1 error and 0 warnings in 1 file

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (2) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.20.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.3 - /usr/local/bin/pnpm
  npmPackages:
    svelte: ^4.0.3 => 4.0.4

Severity

annoyance

afreidz avatar Jul 07 '23 21:07 afreidz