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 5: $$Events is an illegal variable name #11412

Closed
rChaoz opened this issue May 1, 2024 · 0 comments · Fixed by #11513
Closed

Svelte 5: $$Events is an illegal variable name #11412

rChaoz opened this issue May 1, 2024 · 0 comments · Fixed by #11513
Assignees
Milestone

Comments

@rChaoz
Copy link
Contributor

rChaoz commented May 1, 2024

Describe the bug

I was testing updating my projecte to Svelte 5, and it seems like it believes that $$Events is a variable, but it's actually a type.

Probably related to #11416

Reproduction

interface $$Events {
    commit: CustomEvent<string>
    keydown: KeyboardEvent
}

type ExtractEventMap<T> = {
    [key in keyof T]: T[key] extends CustomEvent<infer U> ? U : never
}

// error here:
const dispatch = createEventDispatcher<ExtractEventMap<$$Events>>()

So declaring the interface itself is no issue, just my edge-case here.

Logs

21:12:07 [vite] Internal server error: [...] `$$Events` is an illegal variable name. To reference a global variable called `$$Events`, use `globalThis.$$Events`
  Plugin: vite-plugin-svelte

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700KF
    Memory: 13.10 GB / 31.86 GB
  Binaries:
    Node: 20.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.1.1 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0)
    Internet Explorer: 11.0.19041.1566

Severity

annoyance

@rChaoz rChaoz changed the title $$Events is an illegal variable name - for TypeScript interface Updating to Svelte 5: $$Events is an illegal variable name May 1, 2024
@rChaoz rChaoz changed the title Updating to Svelte 5: $$Events is an illegal variable name Svelte 5: $$Events is an illegal variable name May 1, 2024
@trueadm trueadm self-assigned this May 2, 2024
@trueadm trueadm added this to the 5.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants