Skip to content

[html] Vscode detect wrong scope for script with type=module #229357

@urffin

Description

@urffin

Type: Bug

  1. create simple html file

    <!DOCTYPE html>
    <html>
    <head>
        <script>let a = 10;</script>
        <script type="module">let a = 10;</script>
    </head>
    </html>
    
  2. get wrong "problems" message: Cannot redeclare block-scoped variable 'a'.

image
image

Expected behavior

No problems, because script with type="module" have own scope, so in this case no redelared variable.

VS Code version: Code 1.93.1 (38c31bc, 2024-09-11T17:20:05.685Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs AMD FX(tm)-8350 Eight-Core Processor (8 x 3991)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.97GB (3.94GB free)
Process Argv --disable-extensions --crash-reporter-id d754423a-bca8-4bd8-88a2-702aab8631b1
Screen Reader no
VM 0%
Extensions disabled
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
bdiig495:31013172
a69g1124:31058053
dvdeprecation:31068756
dwnewjupyter:31046869
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
flighttreat:31134774
wkspc-onlycs-t:31132770
wkspc-ranged-t:31125599
pme_test_t:31118333
fje88620:31121564

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bughtmlHTML support issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions