microsoft / microsoft/TypeScript
Broken IndexedDB event typings in 3.1.5
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.1.5
Search Terms:
indexedDB
Code
let dbreq = indexedDB.open('test', 1);
dbreq.onsuccess = function (evt) {
let database = evt.target.result;
}
Expected behavior:
evt.target.result should be an IDBDatabase
Actual behavior:
TS2339: Property 'result' does not exist on type 'EventTarget'.
Related Issues:
This is caused by the updates resulting from https://github.com/Microsoft/TypeScript/issues/25547
It works if you add a cast:
let dbreq = indexedDB.open('test', 1);
dbreq.onsuccess = function (evt) {
let database = (evt.target as IDBOpenDBRequest).result;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript 3.1.5 DOM typings involved in the IndexedDB event callbacks, using the Playground link to reproduce the error. Read related issue #25547 to understand the preceding changes, then verify that the sample recognizes evt.target.result as an IDBDatabase without a cast.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100