dumbmatter / fakeIndexedDB

A pure JS in-memory implementation of the IndexedDB API
Apache License 2.0
564 stars 69 forks source link

add type declarations #29

Closed mcshaz closed 5 years ago

mcshaz commented 5 years ago

since the project is in Typescript, it should be easy to export a .d.ts file as well - this will make it much easier for others using your library with typescript.

mcshaz commented 5 years ago

it is failing on Travis and my machine (above), but it would not build for me before I made the changes.

dumbmatter commented 5 years ago

I imagine this would only cover the main entry point, which is not optimal because a lot of other people import things like FDBKeyRange.

Also, an alternative idea would be to simply declare these variables to have the same type as the native IndexedDB ones. I haven't tried that, but the API is identical, so it should work I guess... might be easier than fighting TypeScript to get it to output things correctly.

EDIT: I just saw your comment on #23 saying exactly this lol.

mcshaz commented 5 years ago

actually ignore - looking at the code it is just polyfilling the window (/global/self) object and doesnt actually export anything

yankeeinlondon commented 4 years ago

What happened to this thread? I am eager to use this in conjunction with my Dexie testing but simply adding:

import 'fake-indexeddb/auto';

is not getting Dexie to pick up the API:

indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.

Usually when this happens I then try to dig into things with the help of TypeScript. Sadly it would appear that we didn't quite get to the finish line in exporting the symbols.

dumbmatter commented 4 years ago

TypeScript types don't have any affect at runtime, so it's probably unrelated to your error.

yankeeinlondon commented 4 years ago

That is true of course but I find typed interface a very efficient way of exploring a new API or library :)