You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class DBWrapper {
_db = null;
async open() {
if (this._db) return;
this._db = await new Promise((resolve, reject) => {
resolve('db')
});
return this;
}
async transaction(callback) {
await this.open();
return await new Promise((resolve, reject) => {
const txn = this._db;
callback(txn);
});
}
}
const db = new DBWrapper();
db.transaction((tx) => console.log(tx));
If both are pasted in src/index.js of clean preact-cli project, example 1 returns "1981[object Array Iterator]" while example 2 works. If browserlists: [">0.75%", "not ie 11", "not op_mini all"] is added to package.js, example 1 works but example 2 throws Cannot read property '_db' of undefined.
My current fix is to keep browserslist at >0.75% and add @babel/plugin-transform-arrow-functions via preact.config.js but that's unfortunate as both snippets work natively in the browser.
Please mention other relevant information.
Tested using clean [email protected] (default and typescript template) and Chrome 88 on Windows 10
BTW. example 2 is a reduced part of failing code from workbox when using custom sw and ExpirationPlugin. Jeff Posnick kindly pointed out error in transpilation to me.
The text was updated successfully, but these errors were encountered:
Do you want to request a feature or report a bug?
Bug
What is the current behaviour?
See following snippets
example 1
example 2
If both are pasted in
src/index.js
of cleanpreact-cli
project, example 1 returns"1981[object Array Iterator]"
while example 2 works. Ifbrowserlists: [">0.75%", "not ie 11", "not op_mini all"]
is added topackage.js
, example 1 works but example 2 throwsCannot read property '_db' of undefined
.My current fix is to keep
browserslist
at >0.75% and add@babel/plugin-transform-arrow-functions
viapreact.config.js
but that's unfortunate as both snippets work natively in the browser.Please mention other relevant information.
Tested using clean
[email protected]
(default and typescript template) and Chrome 88 on Windows 10BTW. example 2 is a reduced part of failing code from workbox when using custom sw and
ExpirationPlugin
. Jeff Posnick kindly pointed out error in transpilation to me.The text was updated successfully, but these errors were encountered: