Level / level

Universal abstract-level database for Node.js and browsers.
MIT License
1.55k stars 106 forks source link

support typescript #170

Closed zy445566 closed 4 years ago

vweevers commented 4 years ago

We have this default export in a bunch of other modules, but surely typescript users have used level at this point so I'm wondering when/why this is needed? And why can't TS fix this on their end?

cc @MeirionHughes

MeirionHughes commented 4 years ago

I'm inclined to suggest we remove the default export from everything, as at the moment its quite inconsistent (there are more modules that don't use 'default' that do - especially in the wider eco-system):

import levelup from 'levelup';
import * as subleveldown from 'subleveldown;

you don't need 'default' to use it, and the level modules are not esm - they're cjs. Could potentially do this ('hide' the default export) without a major semver, here, but it probably would require a major semver on definitely typed (which might be problematic as they're trying to keep the versions synced these days).

you can actually use the --allowSyntheticDefaultImports option on typescript anyway and it will allow you to do a default import on modules that don't have one.