Skip to content

🐛 BUG: error if template literal containing html string is used in component script #984

@WickyNilliams

Description

@WickyNilliams

What version of @astrojs/compiler are you using?

2.7.0

What package manager are you using?

npm

What operating system are you using?

mac

Describe the Bug

I have a component which contains some code approximately similar to this in the component script:

const source = `
  ${Math.random() ? `<style>test {}</style>` : ""}
`;

This causes some errors in the vscode extension.

It causes the following error at the end of the component script

Expression expected.ts(1109)

And this error in the component template:

JSX expressions must have one parent element.ts(2657)

Additionally, I get an error page in my site:

Expected ">" but found "class"

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wfswdw

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