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

VS Code variable inspection / watch does not work for default imports in NodeJS environment #36304

Open
fis-cz opened this issue Jan 19, 2020 · 1 comment
Labels
Bug A bug in TypeScript
Milestone

Comments

@fis-cz
Copy link

fis-cz commented Jan 19, 2020

TypeScript Version: 3.7.5
VSCode Version: 1.41.1 2019-12-18

Search Terms:
VSCode TypeScript Default Import Renamed Can't Debug Watch Inspect

Code

filea.ts

const a: string = "hello";
export default a;

fileb.ts

import a from "./filea"
console.log(a);

tsconfig.json

{
   "compilerOptions": {
      "lib": [ "es6" ],
      "moduleResolution": "node",
      "module": "commonjs",
      "target": "es6",
      "sourceMap": true
   }
}

Expected behavior:

Works correctly in runtime
Variable a (imported one) can be inspected

Actual behavior:

Works correctly in runtime
Variable a (imported one) can't be inspected neither watched as VS Code says: not available

The problem is the variable a does not exist at runtime as the import is transpiled as:

const filea_1 = require("./filea");
console.log(filea_1.default);

Watching of filea_1.default works correctly, of course.

I am not sure if there is additional mapping somewhere, but everything else works well (breakpoints, other variable inspections...)

maybe the default imports can be transpiled as

const a = require("./filea").default;
console.log(a);
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 6, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 6, 2020
@credred
Copy link

credred commented Feb 27, 2020

Same.
image

I can't get any intelligence when hover on createServer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants