Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode does not show some typescript isolatedModules errors #57833

Closed
bradzacher opened this issue Mar 18, 2024 · 3 comments · Fixed by #57914
Closed

VSCode does not show some typescript isolatedModules errors #57833

bradzacher opened this issue Mar 18, 2024 · 3 comments · Fixed by #57914
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@bradzacher
Copy link
Contributor

bradzacher commented Mar 18, 2024

Type: Bug

Repro

  1. Checkout https://github.com/bradzacher/bug-repros/tree/vscode-typescript-isolatedModules:
    • git clone https://github.com/bradzacher/bug-repros.git
    • git fetch
    • git switch vscode-typescript-isolatedModules
  2. Open the folder in vscode
  3. Open terminal and install in folder npm i
  4. Open package1/index.ts
    • Observe there are no TS errors reported.
  5. Open terminal and build npm run build
    • Observe there is a TS build error reported:
> tsc -p ./package1/tsconfig.json

package1/index.ts:3:21 - error TS2748: Cannot access ambient const enums when 'isolatedModules' is enabled.

3 export const test = Foo.Bar;
                      ~~~

Found 1 error in package1/index.ts:3

Expected:

VSCode shows the error when viewing package1/index.ts in the IDE

Actual:

VSCode shows no errors.


VS Code version: Code 1.87.2 (Universal) (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:21:31.043Z)
OS version: Darwin arm64 23.4.0
Modes:

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
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
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 2, 2, 3
Memory (System) 64.00GB (20.85GB free)
Process Argv --crash-reporter-id 4f7fbb36-3a81-40a0-a922-a2a72f77abfa
Screen Reader no
VM 0%
Extensions (49)
Extension Author (truncated) Version
vscode-ndjson adr 0.100.0
vscode-zipfs arc 3.0.0
ast-grep-vscode ast 0.1.3
vscode-bazel Baz 0.9.0
soysyntaxchecker Blo 3.30.0
vscode-coloured-status-bar-problems bra 0.2.0
vscode-copy-filename bra 0.1.1
npm-intellisense chr 1.4.5
path-intellisense chr 2.8.5
vscode-css-modules cli 0.5.1
coder-remote cod 0.1.35
vscode-clock Com 0.0.1
vscode-markdownlint Dav 0.54.0
vscode-eslint dba 2.4.4
make-hidden dev 4.0.4
dprint dpr 0.16.0
gitlens eam 14.9.0
EditorConfig Edi 0.16.4
prettier-vscode esb 10.1.0
vscode-github-actions git 0.26.2
vscode-pull-request-github Git 0.82.0
vscode-graphql Gra 0.9.3
vscode-graphql-syntax Gra 1.3.5
nix-ide jno 0.3.1
statusbarerror Joe 0.4.0
vscode-json5 mrm 1.0.0
remote-ssh ms- 0.109.0
remote-ssh-edit ms- 0.86.0
hexeditor ms- 1.9.14
remote-explorer ms- 0.4.3
vscode-js-profile-flame ms- 1.0.8
vsliveshare ms- 1.0.5918
vscode-paste-image mus 1.0.4
inline-sql-syntax quf 2.16.0
rust-analyzer rus 0.3.1877
bazel-stack-vscode Sta 1.9.8
rewrap stk 1.16.3
code-spell-checker str 3.0.1
vscode-stylelint sty 1.3.0
even-better-toml tam 0.19.2
shellcheck tim 0.37.0
jest-snapshot-language-support tle 1.1.1
pdf tom 1.2.2
vscode-mdx uni 1.8.2
vscode-lldb vad 1.10.0
es-quotes vil 0.2.6
vscode-icons vsc 12.7.0
vscode-wakatime Wak 24.4.0
vscode-proto3 zxh 0.5.5
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:30979542
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
ccp2r6:30958158
dsvsc020:30976470

@bradzacher
Copy link
Contributor Author

Note: I'm not sure if this is a vscode or a typescript bug.
The issue specifically manifests within VSCode - hence I'm starting here.

I would assume that there is a breakage here due to the TS project service not properly respecting isolatedModules + project references?

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 18, 2024
@mjbvz mjbvz removed their assignment Mar 18, 2024
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 18, 2024
@andrewbranch andrewbranch added this to the TypeScript 5.5.0 milestone Mar 18, 2024
@bradzacher
Copy link
Contributor Author

It's worth noting that fixing this would likely cause some strife for people due to #37774

In the current state the IDE shows no errors and it's possible to work around/hide the "incorrect" CLI errors with a custom tsc wrapper.

If this bug is fixed then the IDE would show errors and there would be no way to silence them.

So they might best be solved together so that the IDE only shows these errors for "truly invalid" usecases (eg accessing a const enum from a node_module where the existence of preserveConstEnum can't be determined) and no errors are shown for "valid" usecases (eg accessing a const enum from a project reference)

@andrewbranch
Copy link
Member

I think that this bug is basically expected behavior that falls out of the poor design or bug that is #37774. I want to try to address #37774 directly to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
5 participants