-
Notifications
You must be signed in to change notification settings - Fork 8
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
typescript #9
Comments
I think 2 over 4, specially since there is no answer |
Surprised this doesn't have types yet. Has the author indicated they don't want other's to supply types? If not, I'd be happy to add types to Definitely Typed on this library's behalf. |
yeah, I completely dropped the ball on this. I do think that example that I included earlier is a valid set of types to use (and have been using them internally in my project for a year or so), I just got sidetracked before I could get the tests put together for the types that would be desired/required for DefinitelyTyped. If you, @AHBruns, fancy putting that together, I'll happily review it for you. If not, I can try and get to it later, maybe this weekend. |
There are a few things I'd change, for example, the static intersection should require at least 2 set arguments, and the instance intersection should require at least 1 set argument. Same with difference. Not sure about union since we could say the union of no sets is the empty set and the union of 1 set as itself. Also the map should probably map to a generic type, not unknown. Mostly minor though. If you have the types written, I'll defer to you. Ping me when you need a review. If not, I can probably get around to writing them sometime this weekend. |
I see what you mean, but since the underlying code doesn't make that requirement, I didn't change it. I literally just put types on the existing interface. |
Actually looking at the implementation, there's a quite a few optimizations that could be made. I may just write something myself. I'd still be happy to help with reviewing typings, of course, but for my use-case I'll probably just write something new. Will release it, with types, if it ends up being as useful as Zet. |
Also, the implementation for difference does require at least 1 set. It will encounter a runtime error if you give it 0 sets. |
It handles 1 by just returning the empty set though. |
First let me say that this is a fantastic library, and I really appreciate you making it available.
I've been poking at this with typescript and I was wondering what you level of typescript interest is? To use this library seamlessly with typescript, we need type declarations. There are several ways to handle this.
Firstly you need types, that would be an index.d.ts file like this:
There are a number of ways to handle this.
FYI the only significant change in the code other than adding types was replacing the spread operator with
Array.from
since typescript doesn't support spreading Sets.Thoughts?
The text was updated successfully, but these errors were encountered: