microsoft / microsoft/TypeScript
VS Code variable inspection / watch does not work for default imports in NodeJS environment
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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);
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit filea.ts, fileb.ts und tsconfig.json, inspiziere anschließend das erzeugte CommonJS-JavaScript und seine Source Map, während du das Watch-Verhalten in VS Code reproduzierst. Ermittle, ob Namen von Default-Imports auf den Zugriff filea_1.default in der erzeugten Datei abgebildet werden können, ohne die bestehende Laufzeitausgabe zu beeinträchtigen. Erledigt ist die Aufgabe, wenn die importierte Variable a in der NodeJS-Umgebung inspiziert und überwacht werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- node.js, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100