developit / developit/microbundle
[Bug] Wrong function scope with rest parameters after transpiled
- Vorherrschende Sprache
- JavaScript
- Sterne
- 8.1k
- Forks
- 358
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
### 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
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- build-system
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100