* 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>
* html-language-features: include JSDoc summary and tags in <script> hover
In doHover for JavaScript embedded in HTML <script> blocks, surface
info.documentation (JSDoc summary) and info.tags (@param, @returns,
etc.) alongside the existing info.displayParts signature. The hover
now returns a MarkupContent markdown payload with the signature,
description, and tag sections so HTML files get parity with
.js/.ts hovers.
Fixes#268776
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* update
---------
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
For #269213
This adds a new eslint rule for `as any` and `<any>({... })`. We'd like to remove almost all of these, however right now the first goal is to prevent them in new code. That's why with this first PR I simply add `eslint-disable` comments for all breaks
Trying to get this change in soon after branching off for release to hopefully minimize disruption during debt week work
* fix problems with html style comments in embedded code
* add spacings to the replaced characters
add same amount of characters, in the replacements so that all offsets stays the same
* revert javascriptMode.ts
* add replace characters in embeddedSupport.ts instead
* added few more tests with javascript
more testcases with js code before and after the comments
* polish
Co-authored-by: UwUeeb <106700035+UwUeeb@users.noreply.github.com>
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
* Bump default JS target for scripts in html
For JS/TS files, we target ES2020 by default. However in html files we're still stuck targetting es6
This change aligns the two
* use es2020.full (includes dom), fix web, avoid searching in node_modules
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
* Adopt official semantic tokens api for JS/TS in html
Fixes#114477
This switches the semantic tokens implementation for js/ts inside html to use the finalized `getEncodedSemanticClassifications` api instead of our custom impl
* Update tests