tell TS we're certain to have a txn

This commit is contained in:
Bruno Windels 2021-08-31 08:43:39 +02:00
parent 3d66d71c97
commit 995ed23b3e

View file

@ -74,7 +74,7 @@ export function openDatabase(name: string, createObjectStore: CreateObjectStore,
req.onupgradeneeded = async (ev : IDBVersionChangeEvent) => { req.onupgradeneeded = async (ev : IDBVersionChangeEvent) => {
const req = ev.target as IDBRequest<IDBDatabase>; const req = ev.target as IDBRequest<IDBDatabase>;
const db = req.result; const db = req.result;
const txn = req.transaction; const txn = req.transaction!;
const oldVersion = ev.oldVersion; const oldVersion = ev.oldVersion;
try { try {
await createObjectStore(db, txn, oldVersion, version); await createObjectStore(db, txn, oldVersion, version);