I'm working with indexeddb and typescript. My issue is that TS doesn't seem to be able handle the event.target.result
property. Case in point:
request.onsuccess = (event) => {
namespace.db = event.target.result; //the property 'results' does not
//exist on the value of type 'EventTarget'
var a = event.target;
var b = <IDBOpenDBRequest>a;
var c = b.result; // <-- magically there's a results property here
version = parseInt(namespace.db.version);
console.log("version: " + version);
deferred.resolve();
}
So my question is: Is there an easier way to cast the target
property to <IDBOpenDBRequest>
other then the a
, b
method above?