You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's fair enough; we could potentially just rollback the defiantly typed commits that removed the abstract-down and level-down typings; and remove the typings entirely from all level repos. the levelup typings on definitely typed are still there, but incorrect.
I've been playing with the new inferring mechanism in typescript 2.8, but unfortunately it falls short due to not supporting function overloads. Ultimately, the way levelup is structured makes it very difficult to type and infer from any arbitrary abstract-down.
In experiencing trying to implement and distribute the typings - I agree it probably makes sense to get it done on definitely typed.
I agree we use DefinitelyTyped to manage level typings because it will give the community the maximum flexibility to maintain the types for our Level projects.
We have too much pain with writing a .d.ts separately with the JavaScript code. I always believe that if we could write all in TypeScript, the world would be better from now, and the JavaScript developer could still write ES6 JavaScript code without any problem.
Anyway, any solution would be a wonderful solution as long as it could make typing work. Let's move on. :)
It's your call when to remove the typings from Level packages. Seeing as they were experimental, I think we can do so in minor releases across the board (as if they were pre-1.0.0).
I'll strip out the generics this weekend (reduce the coupling between abstract encoder and levelup) and get some prs going, unless someone beats me to it.
We simply need function overload inference in typescript, until then people will just have to make do with a general typing or make their own interface on-top of levelup.
As a warning, that chat is private, not public. I think discussions involving changes to users should be public.
We simply need function overload inference in typescript, until then people will just have to make do with a general typing or make their own interface on-top of levelup.
level, however, can be typed explicitly
I think this sounds like a good plan. I guess level-rocksdb etc. also need explicit typings in DT or they won't work?
I wasn't really comfortable doing patch work on Defiantly Typed; potentially for me to further break things for people. :/ I think its better to clear up the typings separately, then if you still want to move them it can be all done in one go.
I've also made a quick branch in down, encoding, up and abstract to add a notypes branch that strips each of their own typings. then level-typings directly depends on them (github dep)
On a side note, it looks like no one else has decided to fix the DT types either; So they're still out-of-date.
Any plan to address this in the near future? I'm encountering pretty major problems using this library with @types/levelup and @types/leveldown. It might actually be better to remove those libraries from DefinitelyTyped if they no longer work!
For my work I'll be needing to use leveldb / rockdb, so hopefully I can pencil in some time to move this to DT. Unless someone wants to take over that aspect.
As far as I can tell the typing s are done, only need to deal with the DT package and sorting out the inter-dependencies. An alternative would be to make each package entirely self-sufficient, at which point they can just be thrown up to DT.
I understand the reason that many of maintainers don't know typescript but that's the real problem. Developing nowadays almost anything in node without typescript is very error-prone, not reliable, much slower and much harder.
I'm very sad that that you're throwing away so many valuable traits instead learning typescript basics within an hour.
I was happy to rewrite few libs to typescript as it should be fairly easy, but if you don't want it and not willing to change the opinion about typescript then OK.
@wookieb I think you are misinformed. From my understanding both of the declaration files for @DefinitelyTyped/levelup and @DefinitetlyTyped/leveldown are incorrect and extremely deprecated.
The ONLY Level packages that have actually been transferred from Level/Typings as of now are abstract-leveldown and level-codec with the rest to follow in the coming weeks.
Hopefully that clears up the situation, I also noticed the levelup/leveldown typings in DT but as far as I can tell by their contents they are NOT correct nor should you attempt to use them with a recent version of the packages.
THAT BEING SAID, I also can't guarantee that the typings ive moved over are completely correct, so I would really love help or at least another set of eyes on them. If @MeirionHughes is around I am curious about why you chose an interface structure for your declaration file (specifically abstract-leveldown) instead of creating Class declarations? I see that it allows you to create new objects with new and with (...) but is that necessary? I'm not entirely familiar with the library.
@danwbyrne You're right about DefinitelyTypes but that doesn't matter where the typings are. What matters is that you're creating them manually which has all downsides I've mentioned above.
Hopefully that clears up the situation, I also noticed the levelup/leveldown typings in DT but as far as I can tell by their contents they are NOT correct nor should you attempt to use them with a recent version of the packages.
How I was suppose to know that? :)
I also can't guarantee that the typings ive moved over are completely correct, so I would really love help or at least another set of eyes on them
Same as with fixing typings in DefinitelyTyped. That doesnt make sense for you to update typing manually as they might be outdated pretty quickly.
@wookieb For keeping typings in sync, it doesn't matter whether they reside in Level or DefinitelyTyped. Either way someone (preferably a team of people) will have to keep them updated. You can call that "manual work" but there is no alternative. I believe we (the JavaScript maintainers of Level) have been very open to supporting TypeScript users however we can, realizing that this is a big audience. I hope that you can return the favor and realize that there is a big JavaScript audience.
You can call that "manual work" but there is no alternative.
The alternative is: Rewrite to typescript. The alternative is javascript with a lot of typings synchronization problems that every popular js library has.
It's not a joke. Please don't get me wrong. I'm not a Typescript fanboy that is coming here to spread "typescript" disease. I'm talking about real solution for real problems. Developing anything in node.js without typings is a real disease. Developing with wrong typings is even more annoying and that happens really really often.
I hope that you can return the favor and realize that there is a big JavaScript audience.
In the past 12 months, we had faced lots of issues with the TypeScript type definition, but it had not fixed well and the users still cannot work with the right typings after we spent lots of time on it (thanks @MeirionHughes , et al)
Rewriting to TypeScript will fix this problem. However, @vweevers is very happy with the JavaScript and always against to do that.
After some thoughts, I think we have a new direction to make everyone happy.
In short: let's create a new npm module that supports TypeScript natively.
The following will be my purposal:
Create a new repository, like: level/levelmap
levelmap will use levelup as its backend, expost all API as a ES6-Map-like
Develop in TypeScript
publish to npm as levelmap, and suggest TypeScript users to use this module.
The above is my 2-cents, please feel free to contribute any good ideas. If we can get a agreement about it, then I'd like to create the repository, develop it(with portional collabrators like @wookieb ), and publish it to npm as a level alternative for TypeScript users.
The ONLY Level packages that have actually been transferred from Level/Typings as of now are abstract-leveldown and level-codec with the rest to follow in the coming weeks. 👏
I still don't fully support the way these are typed, but I unfortunately don't have the spare time right now to go through them all. You can see I change the pattern of the declarations on encoding-down and rocksdb which is how I think they should all look honestly.
I'll continue to monitor the repos if anyone else decides to contribute to the types, but that does it for me here :)
The error in the callback of the level(up) get operation should be extended. Typescript complains that the 'notFound' or 'type' properties do not exist on plain Error objects. You would need that to check if there is actual failure or if the record is simply not found in the database...
Activity
MeirionHughes commentedon Feb 21, 2018
That's fair enough; we could potentially just rollback the defiantly typed commits that removed the abstract-down and level-down typings; and remove the typings entirely from all level repos. the levelup typings on definitely typed are still there, but incorrect.
I've been playing with the new inferring mechanism in typescript 2.8, but unfortunately it falls short due to not supporting function overloads. Ultimately, the way levelup is structured makes it very difficult to type and infer from any arbitrary abstract-down.
In experiencing trying to implement and distribute the typings - I agree it probably makes sense to get it done on definitely typed.
huan commentedon Feb 22, 2018
I agree we use DefinitelyTyped to manage level typings because it will give the community the maximum flexibility to maintain the types for our Level projects.
We have too much pain with writing a .d.ts separately with the JavaScript code. I always believe that if we could write all in TypeScript, the world would be better from now, and the JavaScript developer could still write ES6 JavaScript code without any problem.
Anyway, any solution would be a wonderful solution as long as it could make typing work. Let's move on. :)
BTW: We can use the discussion board of Github Org Teams for common TypeScript discussion at here: https://github.com/orgs/Level/teams/typescript
vweevers commentedon Feb 22, 2018
Alright, that's settled then!
It's your call when to remove the typings from Level packages. Seeing as they were experimental, I think we can do so in minor releases across the board (as if they were pre-1.0.0).
MeirionHughes commentedon Feb 22, 2018
I'll strip out the generics this weekend (reduce the coupling between abstract encoder and levelup) and get some prs going, unless someone beats me to it.
We simply need function overload inference in typescript, until then people will just have to make do with a general typing or make their own interface on-top of
levelup.level, however, can be typed explicitlyTapppi commentedon Feb 22, 2018
@zixia
As a warning, that chat is private, not public. I think discussions involving changes to users should be public.
I think this sounds like a good plan. I guess
level-rocksdbetc. also need explicit typings in DT or they won't work?huan commentedon Feb 23, 2018
@Tapppi Thanks for the warning, you are right. I thought the discussion is public but it isn't.
sqwk commentedon Mar 16, 2018
Is there a pull request for DefinitelyTyped already? Which typings should get moved/merged?
MeirionHughes commentedon May 11, 2018
I wasn't really comfortable doing patch work on Defiantly Typed; potentially for me to further break things for people. :/ I think its better to clear up the typings separately, then if you still want to move them it can be all done in one go.
I've made a start anyway, see https://github.com/Level/typings
I've also made a quick branch in down, encoding, up and abstract to add a
notypesbranch that strips each of their own typings. thenlevel-typingsdirectly depends on them (github dep)On a side note, it looks like no one else has decided to fix the DT types either; So they're still out-of-date.
asross commentedon Jun 19, 2018
Any plan to address this in the near future? I'm encountering pretty major problems using this library with
@types/levelupand@types/leveldown. It might actually be better to remove those libraries from DefinitelyTyped if they no longer work!asross commentedon Jun 21, 2018
I was actually able to get things working with https://github.com/Level/typings, thanks @MeirionHughes !
MeirionHughes commentedon Jun 22, 2018
For my work I'll be needing to use leveldb / rockdb, so hopefully I can pencil in some time to move this to DT. Unless someone wants to take over that aspect.
As far as I can tell the typing s are done, only need to deal with the DT package and sorting out the inter-dependencies. An alternative would be to make each package entirely self-sufficient, at which point they can just be thrown up to DT.
huan commentedon Jun 22, 2018
Good work @MeirionHughes !
Move TypeScript to DefinitelyTyped +1
And I'm always thinking about to rewrite the JS to TS... because that will make the typing very easy to generate and sync with the latest code.
huan commentedon Aug 3, 2018
Currently, we had moved all the typings to https://github.com/Level/typings, what will we expect the user to use it? I had just upgrade my dep to the latest and found that it seems no good way to integrate with our typings.
If we maintain the typings by ourselves, how about move the Level/typings to DefinitelyTyped, so that we can use @types/encoding-down for convenience?
downgrade encoding-down to restore typing Level/community#16 (comment)
sqwk commentedon Aug 17, 2018
Is there any guide on how to get this working with the current version of levelup/leveldown?
9 remaining items
wookieb commentedon Sep 11, 2018
I was redirected here from the issue: Level/encoding-down#67 (comment)
I'm very sad that you've decided to move typings out of repository. It very error-prone in terms of synchronization of the api. Even now its out of sync since it doesn't say that methods return a promise
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/levelup/index.d.ts
P.s. I'm not going to update it since it's counter productive and effects of my work might be outdated any time.
I understand the reason that many of maintainers don't know typescript but that's the real problem. Developing nowadays almost anything in node without typescript is very error-prone, not reliable, much slower and much harder.
I'm very sad that that you're throwing away so many valuable traits instead learning typescript basics within an hour.
I was happy to rewrite few libs to typescript as it should be fairly easy, but if you don't want it and not willing to change the opinion about typescript then OK.
danwbyrne commentedon Sep 11, 2018
@wookieb I think you are misinformed. From my understanding both of the declaration files for @DefinitelyTyped/levelup and @DefinitetlyTyped/leveldown are incorrect and extremely deprecated.
The ONLY Level packages that have actually been transferred from Level/Typings as of now are abstract-leveldown and level-codec with the rest to follow in the coming weeks.
Hopefully that clears up the situation, I also noticed the levelup/leveldown typings in DT but as far as I can tell by their contents they are NOT correct nor should you attempt to use them with a recent version of the packages.
THAT BEING SAID, I also can't guarantee that the typings ive moved over are completely correct, so I would really love help or at least another set of eyes on them. If @MeirionHughes is around I am curious about why you chose an interface structure for your declaration file (specifically
abstract-leveldown) instead of creating Class declarations? I see that it allows you to create new objects withnewand with(...)but is that necessary? I'm not entirely familiar with the library.wookieb commentedon Sep 11, 2018
@danwbyrne You're right about DefinitelyTypes but that doesn't matter where the typings are. What matters is that you're creating them manually which has all downsides I've mentioned above.
How I was suppose to know that? :)
Same as with fixing typings in DefinitelyTyped. That doesnt make sense for you to update typing manually as they might be outdated pretty quickly.
vweevers commentedon Sep 11, 2018
@wookieb For keeping typings in sync, it doesn't matter whether they reside in Level or DefinitelyTyped. Either way someone (preferably a team of people) will have to keep them updated. You can call that "manual work" but there is no alternative. I believe we (the JavaScript maintainers of Level) have been very open to supporting TypeScript users however we can, realizing that this is a big audience. I hope that you can return the favor and realize that there is a big JavaScript audience.
wookieb commentedon Sep 12, 2018
It's not a joke. Please don't get me wrong. I'm not a Typescript fanboy that is coming here to spread "typescript" disease. I'm talking about real solution for real problems. Developing anything in node.js without typings is a real disease. Developing with wrong typings is even more annoying and that happens really really often.
Not sure what are you trying to say.
vweevers commentedon Sep 12, 2018
I'll rephrase: rewriting to TypeScript is not an option because many people are perfectly happy with JavaScript. That's all.
wookieb commentedon Sep 12, 2018
I know. That's why I'm not insisting anymore.
huan commentedon Sep 13, 2018
Hi all,
In the past 12 months, we had faced lots of issues with the TypeScript type definition, but it had not fixed well and the users still cannot work with the right typings after we spent lots of time on it (thanks @MeirionHughes , et al)
Rewriting to TypeScript will fix this problem. However, @vweevers is very happy with the JavaScript and always against to do that.
After some thoughts, I think we have a new direction to make everyone happy.
In short: let's create a new npm module that supports TypeScript natively.
The following will be my purposal:
level/levelmaplevelmapwill uselevelupas its backend, expost all API as a ES6-Map-likelevelmap, and suggest TypeScript users to use this module.The above is my 2-cents, please feel free to contribute any good ideas. If we can get a agreement about it, then I'd like to create the repository, develop it(with portional collabrators like @wookieb ), and publish it to npm as a
levelalternative for TypeScript users.P.S. Actually, I had already build a module like what I had purposed at here, I used it for more than a year and it can fullfil all my requirements. See: https://github.com/zixia/flash-store
vweevers commentedon Sep 13, 2018
I believe it simply isn't done yet? Someone has to see it through, instead of changing direction (again).
As @danwbyrne said (emphasis and applause mine):
danwbyrne commentedon Sep 17, 2018
Okay! All of the types in https://github.com/level/typings have been at least PR'd to DefinitelyTyped. If you want to track them all in one place here they are:
I still don't fully support the way these are typed, but I unfortunately don't have the spare time right now to go through them all. You can see I change the pattern of the declarations on
encoding-downandrocksdbwhich is how I think they should all look honestly.I'll continue to monitor the repos if anyone else decides to contribute to the types, but that does it for me here :)
vweevers commentedon Sep 21, 2018
Many thanks @danwbyrne!
using official leveldb types (Level/community#16)
MeirionHughes commentedon Jun 20, 2019
Just had another look at typing this beast... typescript still can't deal with inferring derived generic parameters. i.e. :
@danwbyrne belated thanks for getting it up to dt... I've never liked the typings either. :P
reuzel commentedon Dec 16, 2020
The error in the callback of the level(up) get operation should be extended. Typescript complains that the 'notFound' or 'type' properties do not exist on plain Error objects. You would need that to check if there is actual failure or if the record is simply not found in the database...