- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
Description
Originally posted by @jaydenseric in #47792 (comment)
I've been using TypeScript v4.6-dev.x and the node12 mode extensively for some time now. One of the things that makes it really confusing to work with the new node12 mode is that often VS Code lies and is able to display types for imports ok within the editor (yes, with the local TypeScript installation selected in VS Code), when really tsc via the CLI can't resolve the types. You will see "has no exported member" type errors for the same imports, when the imported package doesn't support TypeScript v4.6 node12 mode properly with correct package exports, .d.mts files, etc.
It makes it harder to evaluate as you are working what packages are ESM ready and to experiment with possible fixes for a PR by hacking them in node_modules, since you have to ignore what the editor is saying and keep running the tsc CLI for feedback.
An example of a package this happens with is [email protected]...
With this .vscode/settings.json:
{
  "typescript.disableAutomaticTypeAcquisition": true,
  "typescript.enablePromptUseWorkspaceTsdk": true,
  "typescript.tsdk": "node_modules/typescript/lib"
}And this jsconfig.json:
{
  "compilerOptions": {
    "module": "node12",
    "noEmit": true,
    "strict": true
  },
  "typeAcquisition": {
    "enable": false
  }
}And this package devDependency:
{
  "typescript": "^4.6.0-dev.20220207"
}And this package scripts:
{
  "types": "tsc -p jsconfig.json",
}If you run:
npm run types
In a.mjs:
// @ts-check
/** @typedef {import("playwright").chromium} A */
/** @typedef {import("playwright").Page} B */In b.mts:
import { chromium } from "playwright";
import type { Page } from "playwright";In the VS Code editor the imported Page type resolves for intellisense:
But via tsc:
The playwright package doesn't appear to be in the list of "popular" packages for this issue, but given it's pretty popular and also a Microsoft project that aims to support TypeScript it would really make sense for it to be fully compatible with TypeScript v4.6.
Originally posted by @jaydenseric in #47792 (comment)


