-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added integrated Typescript typings #108
Added integrated Typescript typings #108
Conversation
…ort on BufferListStream
…t and moved BufferList and BufferListStream to be BufferListStreamConstructor (static) properties
wdyt @rvagg? Should we ship types? |
Yeah, I don't mind shipping types, but checking correctness of manually generated types and keeping them in sync is the challenge. I've mostly been going with the approach of annotations and using tsc to compile type definitions from my JS and ship that. But doing that means making sure the annotations are complete and correct through the whole codebase, which can be a bit tedious. We could ship this and cross fingers, and hope that people show up in the future to adjust and correct the over time, but it'll always be a catch-up effort as TypeScript evolves and our dependencies evolve too. |
@alexandercerutti could you add some https://www.npmjs.com/package/tsd tests? |
This is what happens today, just they are not under your domain but under DefinitelyTyped's, isn't it?
@mcollina I can try adding them, sure, but are we sure this is needed? I mean, as per tsd statement (
) a typings test allow to check the types... but as the per main concern (if I got it correctly) if the JS API changes and the test do not get updated, tests will still pass, don't you agree? This is also basically what happens on DT. Maybe the best way for testing the whole thing, would be using something like EDIT: I also tried in other projects tests written in JS but type-checked with |
…pt Uint8Array and an array of itself
@mcollina @rvagg I've chosen a different approach, which I think is more reliable in terms of testing types: type-checking existing tests. Luckily for us, Typescript supports a subset of JSDoc, so I sightly changed By doing so, I also discovered some cases that were not supported by the declarations I created. For example, methods like I also added types support for BufferList and BufferListStream to Just a few notes and questions:
Lines 794 to 797 in ccff4dc
I've added two logs to see more. Sadly tape seems to suppress But this test is always to be I might be missing something here. But I'm not sure if this is correct...
To test, take Let me know what you think about this, any concerns, or if I should revert this at all and proceed with |
some brief drive-by thoughts while I have some time to glance at this:
Otherwise I think this seems reasonable? I still wouldn't mind doing a compilation of the types from annotated source, I do this on most of my new projects these days and have been slowly retrofitting older ones I use a lot. https://github.com/rvagg/iamap is an example of this - I'm not saying this is necessary here, it could be a stretch goal, but we may find the output differs when we do it like that. |
@rvagg thanks for the reply
This is a very bad behavior from ts folks - assuming that Typescript can completely replace JS - I agree with you.
That would be possible in this library, maybe, by using classes (but that would mean to sacrifice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Hey @rvagg, just to remember you about this :) |
@rvagg I can release if you are ok with the approach. |
Hey @rvagg, do you have any updates about this? |
Any update on this? What's missing to be merged? |
sorry, seems fine to me I think, just some minor things in package.json and we can get this out |
@rvagg done! |
if you can come up with an .editorconfig that isn't too disruptive then I think that'd be fine |
I'll try to keep styles as similar as possible with the original code style 👍 |
Should I start a branch too for the Int64 support of #109, or should I wait to get this merged first? |
## [5.1.0](v5.0.0...v5.1.0) (2022-10-18) ### Features * added integrated TypeScript typings ([#108](#108)) ([433ff89](433ff89)) ### Bug Fixes * windows support in tests ([387dfaf](387dfaf)) ### Trivial Changes * GH Actions, Dependabot, auto-release, remove Travis ([997f058](997f058)) * **no-release:** bump standard from 16.0.4 to 17.0.0 ([#112](#112)) ([078bfe3](078bfe3))
🎉 This PR is included in version 5.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [5.1.0](rvagg/bl@v5.0.0...v5.1.0) (2022-10-18) ### Features * added integrated TypeScript typings ([rvagg#108](rvagg#108)) ([433ff89](rvagg@433ff89)) ### Bug Fixes * windows support in tests ([387dfaf](rvagg@387dfaf)) ### Trivial Changes * GH Actions, Dependabot, auto-release, remove Travis ([997f058](rvagg@997f058)) * **no-release:** bump standard from 16.0.4 to 17.0.0 ([rvagg#112](rvagg#112)) ([078bfe3](rvagg@078bfe3))
Great! I'll now proceed with requesting DefinitelyTyped types deprecation! |
Hello there, I'm working on a migration to Typescript of a library that uses a very old version of
bl
(v1.2.3
- which, for unknown reasons, is unlisted on NPM to me, but still accessible via URL).I'm not a very huge fan of DefinitelyTyped but I DefinitelyLove Typescript. Also, I was looking at
@types/bl
, and they seemed a bit wrong to me, based on the implementation.So I decided to rewrite them with a better structure to represent how the code was written (in fact
interfaces
allow to specify of both a constructor and a function to be executed) and inside the package.Now all the methods include a documentation comment based on the one in the Readme.
I also tried to run the tests available inside
@types/bl
, and they seem to be okay, and run linting.I hope this is appreciated. Let me know if there's anything that you feel is wrong, and I'll feeex it! 🛠️
(EDIT: Moved to draft, I found a few issues when trying to integrate the types inside the project I'm migrating to TS - still attempting to fix. Meanwhile, feel free to comment).P.s. I'll handle deprecation of
@types/bl
on DefinitelyTyped if this PR will get accepted.