Skip to content

Svelte 5 TS: class property in template literal causes Unterminated template / Unexpected token! #13188

Closed
@cshaa

Description

@cshaa

Describe the bug

Optional chaining to a property named class inside a template literal in a TypeScript script breaks the Svelte 5 parser.

Reproduction

<script lang="ts">
  const str = `${obj?.class}`;
</script>

Throws Unterminated template.

<script lang="ts">
  const str = `${obj?.class} ${42}`;
</script>

Throws Unexpected token.

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions