microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.1k stars 12.37k forks source link

Globally installed npm @types packages are no longer respected in standalone JS/TS files #59465

Closed jhmaster2000 closed 1 month ago

jhmaster2000 commented 1 month ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Create a new file.ts file anywhere in explorer and double-click it/open it in VSCode as a standalone file (not opening a folder)
  2. Write import fs from "node:fs";
  3. VSCode will frustratingly refuse to resolve the Node built-in, this used to be fixable (I do not recall the exact VSC version) by running npm i -g @types/node
  4. Attempt to run npm i -g @types/node and reload VSCode
  5. Issue still occurs.

How is one supposed to tell VSCode to load Node types in standalone JS/TS files now? I refuse to have to create an entire TSConfig/node_modules/package.json every time I want to write simple one-off scripts to be ran directly like node file.js (or bun file.ts for TS scripts)

VSCodeTriageBot commented 1 month ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.91.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

jhmaster2000 commented 1 month ago

^ Updated for 1.91.1 f1e16e1e6214d7c44d078b1f0607b2388f29d729 x64 Issue persists.

RyanCavanaugh commented 1 month ago

I refuse to have to create an entire TSConfig/node_modules/package.json ... VSCode will frustratingly refuse to resolve the Node built-in, this used to be fixable

For TypeScript, this has never been a supported configuration as far as I can tell. TypeScript files don't get automatic type acquisition and never have.

For JS files, this works without any config needed. You shouldn't need to do anything.

Sharing your TS Server log might be helpful.