Skip to content

svelte cli: error when converting typescript with angle-brackets casting #14571

@werner-drklein

Description

@werner-drklein

Describe the bug

sv migrate svelte-5

fails with an error like

Error while migrating Svelte code [InternalCompileError: Unexpected token `}`. Did you mean `}` or `{"}"}`?] {

when typescript code contains casting using angle-brackets. (<>)

Reproduction

in typescript code use angle-brackets casting:

const variable = <string>somevar;

If you instead cast using the as keyword, it works as expected:

const variable = somevar as string;

Logs

No response

System Info

sv 0.6.6


  System:
    OS: macOS 14.7.1
    CPU: (14) arm64 Apple M3 Max
    Memory: 104.59 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - /opt/homebrew/bin/npm
    pnpm: 9.12.2 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.108
    Edge: 131.0.2903.70
    Safari: 18.1.1

Severity

annoyance

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