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

svelte-check errors when handling custom event with periods in its name #1759

Closed
theodorejb opened this issue Dec 5, 2022 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@theodorejb
Copy link

Describe the bug

svelte-check outputs parse errors and type errors when a component handles custom events with a period in their name:

c:\code\main\src\routes\home\+page.svelte:189:8
Error: Identifier expected. (ts)

c:\code\main\src\routes\home\+page.svelte:189:86
Error: Unexpected token. Did you mean `{'>'}` or `>`? (ts)

c:\code\main\src\routes\home\+page.svelte:189:89
Error: Expected corresponding closing tag for JSX fragment. (ts)

c:\code\main\src\routes\home\+page.svelte:189:6
Error: Type '{ onhidden: true; }' is not assignable to type 'HTMLProps<HTMLDivElement>'.
  Property 'onhidden' does not exist on type 'HTMLProps<HTMLDivElement>'. Did you mean 'hidden'? (ts)

Reproduction

I added the following to my app.d.ts file per the comments in #1563:

declare namespace svelte.JSX {
    interface HTMLAttributes<T> {
        "onhidden.bs.modal"?: (e: CustomEvent) => void;
    }
}

In my component I have this Bootstrap modal element:

<div on:hidden.bs.modal={handleHide} class="modal" id="videoModal" aria-hidden="true"></div>

VSCode doesn't show any errors for this code, and when I build my app the event is handled as expected. However, when I run svelte-check, it produces 4 parse/type errors from the above line in the component.

Expected behaviour

svelte-check should be able to parse custom event names containing periods, and not output errors.

System Info

  • OS: Windows 11
  • IDE: VSCode

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

No response

@theodorejb theodorejb added the bug Something isn't working label Dec 5, 2022
@jasonlyu123
Copy link
Member

Did you use the --use-new-transformation option as mentioned in #1563 (comment)?

@theodorejb
Copy link
Author

@jasonlyu123 No, I somehow missed that the --use-new-transformation flag had to be added to the svelte-check script. That does indeed make the error go away! Is there a reason it isn't enabled by default?

@jasonlyu123
Copy link
Member

jasonlyu123 commented Dec 5, 2022

It'll be soon. You can see the new transformation roadmap here #1552. We want to test out the new typing format before adding it to the svelte core. And there'll be a new major version for svelte-check which enable new transformation by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants