developit / developit/microbundle

[Bug] Wrong function scope with rest parameters after transpiled

Aperta
#1,037 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
8.1k
Fork
358
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### description
async function with rest parameters seems got wrong function scope after transpiled

### version
microbundle@^0.15.1

### reproduce demo

```
// tsconfig.json

{
"compilerOptions": {
"esModuleInterop": true,
"target": "ES6",
"strict": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"baseUrl": ".",
"allowJs": true
},
"include": ["*.ts"]
}

```

```
// test.ts

export const fn = async (...args: unknown[]) => {
await 1;
[].forEach(() => console.log(...args))
}
```

```
// test.js (generated by `microbundle -i test.ts -o test.js`)

exports.fn = function () {
return Promise.resolve(1).then(function () {
var n = arguments; // <- wrong function scope!!!
[].forEach(function () {
var o;
return (o = console).log.apply(o, [].slice.call(n));
});
});
};
//# sourceMappingURL=test.js.map
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start with the test.ts reproduction and run microbundle -i test.ts -o test.js to compare the generated output shown in the issue. Trace the async rest-parameter handling around the generated Promise callback and verify that the completed output uses the outer arguments when logging; done means the reproduced function scope is correct.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, typescript
Ambito
build-system
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.