-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
amalitsky/new-building-story
#4Labels
Description
Rollup Version
2.75.0+
Operating System (or Browser)
macOS Monterey
Node Version (if applicable)
16.14.0
Link To Reproduction
https://replit.com/@jindrahm/ParamDefaultBug?v=1
Expected Behaviour
The following code should remain basically untouched after bundling by rollup.
const systemService = {restart};
function restart(options = {}) {
if (options.countdown) {
console.log('shows restart dialog with a countdown');
} else {
console.log('restarts immediately');
}
}
systemService.restart();Actual Behaviour
But it generates this code which throws an error because rollup removed the options param default value so it cannot access the countdown property of undefined.
const systemService = {restart};
function restart(options) {
if (options.countdown) {
console.log('shows restart dialog with a countdown');
} else {
console.log('restarts immediately');
}
}
systemService.restart();Reactions are currently unavailable