Skip to content

v5 Migrator: js_parse_error #14802

@Bilge

Description

@Bilge

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions