Files
vscode/extensions/html-language-features
6dc67ef483 fix: wrap module script content in block scope to prevent false redeclaration errors (#308027)
* fix: wrap module script content in block scope to isolate variables (#229357)

When multiple <script> tags exist in an HTML file, the HTML language
server concatenates their content into a single virtual JavaScript
document for validation. This causes false "Cannot redeclare
block-scoped variable" errors when <script type="module"> tags declare
variables with the same name as regular <script> tags, since module
scripts should have their own scope per the HTML spec.

Fix by wrapping <script type="module"> content in block scope delimiters
({ ... }) in the virtual document, preventing variable name collisions
between module scripts and regular scripts.

* fix: validate HTML module scripts separately

* test: cover HTML module script isolation

---------

Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
Co-authored-by: Dmitriy Vasyura <dmitriv@microsoft.com>
2026-08-01 00:30:58 +00:00
..

Language Features for HTML

Notice: This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled.

Features

See HTML in Visual Studio Code to learn about the features of this extension.

Please read the CONTRIBUTING.md file to learn how to contribute to this extension.