-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: syntaxIssue in our syntax highlighting (scope)Issue in our syntax highlighting (scope)pkg: language-toolsRelated to language-tooling (scope)Related to language-tooling (scope)
Description
Astro Info
Astro v5.17.1
Vite v6.4.1
Node v22.14.0
System macOS (arm64)
Package Manager pnpm
Output static
Adapter none
Integrations astro-sitemap (v1.0.0)
astro-robots-txt (v1.0.0)
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Inside .astro files, placing a <script> tag inside a conditional expression ({cond ? (…) : null} or {cond && (…)}) causes the editor to stop providing JS hints/IntelliSense and sometimes breaks formatting behavior. The Astro compiler still builds and runs fine in dev and production. Inside the conditional, the <script> contents lose JS language features (no hints / incorrect tokenization), formatting fails too.
- Open VS Code with the Astro & Prettier extension installed
- Create an .astro file with the following content
- Observe script block syntax highlighting and IntelliSense
---
const view = 'Gallery';
---
{view === 'Gallery' ? (
<script>
for (let index = 0; index < 10; index++) {
console.log(index);
}
</script>
) : null}
What's the expected result?
The <script> contents should behave like normal script content in .astro files:
- syntax highlighting
- IntelliSense / errors
- formatting support
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: syntaxIssue in our syntax highlighting (scope)Issue in our syntax highlighting (scope)pkg: language-toolsRelated to language-tooling (scope)Related to language-tooling (scope)