Skip to content

v5 Migrator: js_parse_error #14802

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

Closed
Bilge opened this issue Dec 21, 2024 · 2 comments
Closed

v5 Migrator: js_parse_error #14802

Bilge opened this issue Dec 21, 2024 · 2 comments

Comments

@Bilge
Copy link

Bilge commented Dec 21, 2024

Describe the bug

It seems the migrator cannot handle the TS casts? e.g. <HTMLElement>.

Reproduction

npx sv migrate svelte-5

Logs

Error while migrating Svelte code [InternalCompileError: Unexpected token
https://svelte.dev/e/js_parse_error] {
  code: 'js_parse_error',
  filename: 'static/component/ButtonGroup.svelte',
  position: [ 573, 573 ],
  start: { line: 18, column: 54, character: 573 },
  end: { line: 18, column: 54, character: 573 },
  frame: '17:             if (button.previousElementSibling\n' +
    '18:                 && (<HTMLElement>button).offsetLeft < (<HTMLElement>button.previousElementSibling).offsetLeft\n' +
    '                                                          ^\n' +
    '19:             ) {\n' +
    "20:                 button.previousElementSibling.classList.add('end');"
}

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 9.76 GB / 11.69 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 22.12.0 - /run/user/1000/fnm_multishells/407453_1734819266147/bin/node
    Yarn: 1.22.10 - /mnt/c/Users/Bilge/AppData/Roaming/npm/yarn
    npm: 10.9.0 - /run/user/1000/fnm_multishells/407453_1734819266147/bin/npm
  npmPackages:
    svelte: ^5.0.0 => 4.2.19
    webpack: ^5.11.0 => 5.97.1

Severity

blocking an upgrade

@Ocean-OS
Copy link
Contributor

Please provide a reproduction using the REPL.

@dummdidumm
Copy link
Member

Closing as duplicate of #13179 - this is a bug of the TS plugin we use which can't deal with type casts in the form of <Foo>x, it only works with x as Foo.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2025
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

No branches or pull requests

3 participants