-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC: Simpler database auto-closure using using
keyword
#6791
Conversation
using
keywordusing
keyword
3ce48bd
to
22a3e8d
Compare
ESLint won't support this until it's in Stage 4, which may happen much later unless we swap the parser.
Closing for now |
src/telemetry/logging.ts
Outdated
} | ||
|
||
/** | ||
* Add a log entry to the database. | ||
* @param entry the log entry to add | ||
*/ | ||
export async function appendEntry(entry: LogEntry): Promise<void> { | ||
const db = await getDB(); | ||
const {db} = await using getDB(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "using" goes where the const is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It turns out that immediate destructuring isn't possible either so it would look like this:
using resource = await getDB();
resource.db.getAll();
I pushed a new partial commit here just for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened in issue in the Typescript IDB repository: jakearchibald/idb#300
What does this PR do?
Reviewer Tips
A few dependency updates are needed before this can be merged:
using
keyword is not supported eslint/eslint#17701Checklist