microsoft / microsoft/TypeScript
VS Code variable inspection / watch does not work for default imports in NodeJS environment
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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);
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con filea.ts, fileb.ts e tsconfig.json, quindi esamina il JavaScript CommonJS emesso e la relativa source map mentre riproduci il comportamento di watch in VS Code. Determina se i nomi degli import predefiniti possono essere mappati sull’accesso filea_1.default nel file generato senza compromettere l’output di runtime esistente. Il lavoro è completo quando la variabile importata a può essere ispezionata e monitorata nell’ambiente NodeJS.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- node.js, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100