microsoft / microsoft/TypeScript

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

オープン
#36,304 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: JS Emit
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

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);

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

filea.ts、fileb.ts、tsconfig.json から始め、VS Code で watch の動作を再現しながら、出力された CommonJS JavaScript とその source map を調査します。既存の実行時出力を壊さずに、default-import の名前を生成されたファイルの filea_1.default アクセスにマッピングできるかどうかを確認します。NodeJS 環境でインポートされた変数 a を検査およびウォッチできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。