facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.09k stars 1.86k forks source link

How are we supposed to used IDBKeyRange with Flow ? #8366

Open julienw opened 4 years ago

julienw commented 4 years ago

Missing/Incorrect APIs

IDBKeyRange in IndexedDB

The problems are:

Relevant documentation

https://developer.mozilla.org/en-US/docs/Web/API/IDBKeyRange

julienw commented 4 years ago

This is the current definition of IDBKeyRange: https://github.com/facebook/flow/blob/4acb3575d94d9aa95cdaf9aff3da8b5282d5bb18/lib/indexeddb.js#L103-L112

This is mostly incorrect because we need these methods to be static. However I believe it's not possible with interfaces.

What's difficult here is that IDBKeyRange is 2 things: a type, and an object with static methods that return this type. Should that be a class instead of an interface ?

charlag commented 3 years ago

Just run into it, better to not have IDBKeyRange definition than to have this. this could be a class (that's how it is for other "type + static" built-ins) or it could be two different types: IDBKeyRange for static methods and another type for instances but this might be confusing.