microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.93k stars 28.77k forks source link

vscode looks at wrong version of typescript lib #195253

Closed brianreinhold closed 11 months ago

brianreinhold commented 11 months ago

Type: Bug

The function supportedValuesOf Intl.supportedValuesOf('timeZone'); is clearly shown in VS code's intellisense and I find the function declared in the list of libraries in the .vscode directory.

However, when I try and compile it in an Angular studio project using typescript 4.9.5 vscode gives me the error

Property 'supportedValuesOf' does not exist on type 'typeof Intl'.

Have spent all morning trying to work aound this error.

VS Code version: Code 1.83.0 (e7e037083ff4455cf320e344325dacb480062c3c, 2023-10-03T16:12:16.321Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i3-6320 CPU @ 3.90GHz (4 x 3912)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.89GB (6.72GB free)| |Process Argv|--crash-reporter-id e49935b1-e723-47d0-963f-fcfd0b0f441a| |Screen Reader|no| |VM|0%|
Extensions (47) Extension|Author (truncated)|Version ---|---|--- angular-material|1to|0.13.0 project-manager|ale|12.7.0 vscode-angular2-files|ale|1.6.4 ng-template|Ang|16.1.8 path-intellisense|chr|2.8.5 vscode-css-modules|cli|0.5.1 elasticdeveloper|cra|1.2.15 angular-schematics|cyr|5.4.2 vscode-eslint|dba|2.4.2 EditorConfig|Edi|0.16.4 vscode-npm-script|eg2|0.3.29 prettier-vscode|esb|10.1.0 auto-close-tag|for|0.5.14 auto-rename-tag|for|0.1.10 vscode-test-explorer|hbe|2.21.1 angular2-switcher|inf|0.4.0 angular-file-changer|joh|0.0.4 angular-essentials|joh|16.0.4 Angular2|joh|16.0.1 vscode-peacock|joh|4.2.2 angular-extension-pack|loi|1.1.0 karma-test-explorer|luc|0.8.2 json-to-ts|Mar|1.7.5 ts-error-translator|mat|0.10.1 debug-tracker-vscode|mcu|0.0.15 memory-view|mcu|0.0.24 rtos-views|mcu|0.0.7 jupyter-keymap|ms-|1.1.2 remote-ssh|ms-|0.106.5 remote-ssh-edit|ms-|0.86.0 live-server|ms-|0.4.11 test-adapter-converter|ms-|0.1.8 vscode-typescript-next|ms-|5.3.20231009 arrr|obe|0.1.3 material-icon-theme|PKi|4.31.0 vscode-css-navigation|puc|1.14.0 quicktype|qui|12.0.46 karma-problem-matcher|rct|1.0.1 vscode-yaml|red|1.14.0 LiveServer|rit|5.7.9 angular-cli|seg|0.0.19 simontest|Sim|1.9.10 autoimport|ste|1.5.4 move-ts|str|1.12.0 tabnine-vscode|Tab|3.17.0 vscode-angular-support|vis|0.1.4 jinja|who|0.0.8 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30410667 py29gd2263cf:30856253 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 2e4cg342:30602488 89544117:30613380 2i9eh265:30646982 showlangstatbar:30737416 0bi6i642:30841073 03d35959:30757346 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxptcf:30805731 pythonnoceb:30805159 copilotsettingc:30839828 dsvsc013:30795093 dsvsc014:30804076 diffeditorv1:30821571 dsvsc015:30845448 pythonfb280951:30830810 ```
mjbvz commented 11 months ago

Have you tried telling VS Code to use your workspace TS version: https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript

brianreinhold commented 11 months ago

The funny thing about that is that the VS code version is later than the workspace version and the VS code version is selected. However, both versions are well past the version where Intl.supportedValuesOf('timezone') is supported. What I dont understand is why when I click on 'Intl' to find its source, VS brings me to an older version in the .vscode directory where it is not supported. A few files down in that same directory is the version where it is supported.

But seeing that VS code supports 5.3.0 and my project is at 4.9.5, its time to update my project! I already updated tslib but that did not help.

mjbvz commented 11 months ago

when I try and compile it in an Angular studio project

VS code doesn't provide a compiler so this sounds like an issue with your configuration for angular or with the angular tools. Try following up with them. They should also be able to help you configure VS Code to use the same TS configuration as the compiler

brianreinhold commented 11 months ago

I can do the latter without a problem. Why VS Code is grabbing the wrong tslib (ES2020) even though configured for ES2022 remains a mystery.