Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
afreidz opened this issue Jul 7, 2023 · 0 comments · Fixed by #11079
Closed

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

afreidz opened this issue Jul 7, 2023 · 0 comments · Fixed by #11079
Labels
good first issue A small, encapsulated issue, ideal for a new contributor to Svelte to tackle. types / typescript
Milestone

Comments

@afreidz
Copy link

afreidz commented Jul 7, 2023

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

@Rich-Harris Rich-Harris added this to the 5.0 milestone Apr 3, 2024
@Rich-Harris Rich-Harris added the good first issue A small, encapsulated issue, ideal for a new contributor to Svelte to tackle. label Apr 3, 2024
dummdidumm added a commit that referenced this issue Apr 6, 2024
for the SvelteComponent type
closes #8936
dummdidumm added a commit that referenced this issue Apr 8, 2024
for the SvelteComponent type
closes #8936
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue A small, encapsulated issue, ideal for a new contributor to Svelte to tackle. types / typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants