class Base {
constructor(obj) {
obj.start()
}
}
class Wrapped extends Base {
constructor() {
super({
start: async () => {
const result = await new Promise(resolve => { setTimeout(() => { resolve(0) }, 0) })
this.value = result
}
})
}
}
const wrapped = new Wrapped()
setTimeout(() => {
console.log('value', wrapped.value)
}, 10)
is currently minified to
class Base {
constructor(obj) {
obj.start();
}
}
class Wrapped extends Base {
constructor() {
super({ start: async () => {
this.value = await new Promise((resolve) => {
setTimeout(() => {
resolve(0);
}, 0);
});
} });
}
}
const wrapped = new Wrapped();
setTimeout(() => {
console.log("value", wrapped.value);
}, 10);
(playground).
But we shouldn't do this because evaluating this throws an error until super is called.
Originally reported at vitejs/vite#22186
is currently minified to
(playground).
But we shouldn't do this because evaluating
thisthrows an error untilsuperis called.Originally reported at vitejs/vite#22186