-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Feature]: Improve Project's JSDoc Types #2241
Comments
My motivation for this is that I'm currently in the process of rewriting my Medium article on testing Along the way, I found an area where the types could potentially be improved, but I was hesitant to interact with |
Thank you, but I'm not interested. I don't want to deal with breaking changes in the types, issues opened for TypeScript related problems, adapt the JSDoc comments to please the TypeScript compiler, or replace the TypeScript "maintainers" once they are gone. Let all TypeScript stuff live outside the repository, please. |
If I may:
I'm assuming that you're referring to when TypeScript updates. Is that correct? If so, then as Rich Harris said in the video, the TypeScript team is very cognizant of backwards compatibility. From what I can see, the
This is something that I'd be willing to do (so you wouldn't have to), and it should be rather easy. For one thing, you technically wouldn't have to do this to get the compiler to work. (The minor tweaks would just be for making the types more specific and/or idiomatic.) For another thing, this is technically more advantageous for contributors because popular IDEs seem to understand TypeScript's types in JSDocs better.
You wouldn't have to. I think there are three thoughts worth considering: 1) The people currently maintaining 2) You wouldn't have to replace the type maintainers if you didn't want to. You've refused to take on type-related issues so far, and you can continue to do so in the future. The reality is, if 3) You are already maintaining your JSDocs. There would not be a significant difference between maintaining those and maintaining the "different version". In fact, there's a high probability that the TS issues you encounter would decrease overall because your JSDocs would always be up to date.
I will happily close this issue if you are genuinely unwilling to accept a If you could just add a single |
Yes, I don't want it to be in the repository. The community is very active and useful one day and another day it no longer exists and you have to deal with problems you did not want to deal with in the first place. Thank you anyway.
I understand how small it would be but I'm still not ok with it. Once added, it would be hard to remove in the future. |
(Thank you so much for your time. Please allow me one or two more comments before closing.)
I would be willing to commit to maintaining the JSDoc types for at least 1 year. If at any point within that year (including during the initial PR) you conclude that the new JSDocs would make your workflow worse, and you conclude that they would only be a burden with no benefit whatsoever, then I will gladly take the responsibility for reverting those changes as well. (This is how much faith I have that the changes are easy to maintain.) Of course, if the PR that I create never gets merged, then nothing will have to be reverted anyway. If I open a PR, then you would have the ability to test what your developer experience would be like in your own IDE with my fork of the repository. And you would get a clearer picture of the pros/cons. (If you aren't a fan of TS, then I think it's easier to assume from afar that things would be worse than they really are.) Of course, if -- as I start writing out the code for the PR -- I somehow discover that the changes would yield more problems than I anticipated, then I could simply inform you of my discovery and not open the PR. In that case, things would remain exactly as they are today. A test PR is the safest route in my opinion: You would get to test everything, and nothing would have to be reverted if the PR isn't merged.
All that you would have to do to remove the feature is delete the I know you're saying that you understand the change would be small. But the fact that you're discussing future problems with maintenance leads me to think that you may still see the effort as larger than it really is. (I'm not just talking about the effort for adding the feature, I'm talking about the effort for maintaining/supporting/removing it afterwards.) |
I would not notice because I do not take advantage of TS features in my workflow.
The removal of the Once the If you want to improve JSDoc, go for it. If the goal is to add a |
I think generally, this is up to library authors.
I can't speak to this from experience, but this scenario sounds plausible. I could understand why that experience would not be desirable, though I personally think the better UX is worth it. (Yes, I know. It's much easier to say that when I'm not a maintainer.)
Your concern about adding If your repository is written in JSDocs, then in theory I should be able to follow a process like this:
No one would have to know that the types "officially" came from here. That would be an "implementation detail" of how the maintainers of
Basically, you would get better types, and the |
Can't you keep the |
Yes, I think that should be doable. |
In that case I'll rename this issue and start working on the JSDoc improvements as I have time. |
Ok. |
I'll probably have some questions as I work through this. I want to make sure that I understand what's going on in the code so that the type improvements that I try to make are valid. I'll probably have questions here and there. If this isn't the appropriate place to ask those, please let me know and direct me to the proper communication channel. Regarding
I also understand that these questions are type related and are not necessarily your highest priority. So don't feel pressured to answer immediately. (Though I would appreciate not being left hanging for like 3 months. 😅) Edit: searching for the uses of |
Yes, it is correct. The reason is that Node.js 10 is still supported.
It was made to be generic. A |
✅
Is the desire to keep it generic in this way? From the JSDoc, it doesn't seem like |
Yes, I find it more correct. That stuff is not bound to |
Okay. Thank you. 🙏🏾 |
The documentation says that an Do you remember if Edit: There also seems to be a similar discrepancy between the documentation's |
It is nullable because an |
Is createWebSocketStream expected to operate only on MDN doesn't seem to suggest that a browser's |
Yes. |
Similar question when it comes to the discrepancy between Separate but related note, how important is the |
The type of the
The type of the
They are not documented for various reasons. They are exposed for historic reasons and because they might be useful. For example, see #617 (comment). |
Forgive my ignorance, but on Line 119, the Thanks again for all of your insights. |
Clever. Thanks. |
Based on the discussion in #2242, I think I'm going to close this issue. When I originally proposed my idea, I was thinking that there would at least be some TypeScript syntax in the JSDocs being used (preferably non-egregious TS syntax 😅). This syntax provides a better IDE experience without placing any constraints on maintainers, so I assumed that this would be desirable. However, after opening the PR, I now see that no TypeScript syntax or Google Closure Compiler type expression syntax is desired in this project. Since some degree of syntax from either of those tools would be necessary to implement the plan that I described earlier, this GitHub issue is sadly no longer actionable. This is unfortunate since I consumed some of your time with my questions and with the PR that I opened. But nonetheless, I very much appreciate your willingness to answer those questions and review the PR. I'm sorry for the waste, and I'm very thankful for your patience. Best! |
No problem. Thank you. |
EDIT: This will now only be an improvement to the project's JSDoc types. (See discussion below.)
Is there an existing issue for this?
Description
From a developer standpoint, it's a little inconvenient that developers have to install
ws
and@types/ws
separately. From a maintainability standpoint, it's more work to manage both the library's code and the library's types separately. Doing so also opens up the door for types to accidentally get out of sync.I've noticed that this library is so important that even members of the TypeScript team have contributed to the package's type definitions at certain points in time. (Though I don't know how motivated they are to do this in the present.) Having the types and the library code in a central place would provide a great DX.
For clarity, I saw #1623 and #1762. This is not a request to rewrite the project to TypeScript. Instead, it's a request to reuse the JSDoc approach that the library is already leveraging -- just like Rich Harris suggests (and has suggested in many other videos). Some of the existing JSDocs might need a little improvement, but I'm not assuming this would require any kind of overhaul.
I'm happy to contribute to this if the team is open to the idea.
The Approach
If this is something that's of interest, then the approach should be pretty simple. It's pretty much just creating a
tsconfig
that can check JSDocs. For example:Then add a new step to the package release process. (There is no build step.) Basically, this step would tell TypeScript to generate the
.d.ts
files from the JS files (tsc
), and it would include those generated files in the released package. That's pretty much it. Since you won't be managing the.d.ts
files yourself, they should probably be added to the.gitignore
.This would not have to be done in one fell swoop. We could try this incrementally by "converting" one file at a time and seeing how it feels. From a brief scan, it seems like most of the "conversions" would be simple (e.g.,
Number
-->number
and*
-->any
/unknown
).ws version
8.x
The text was updated successfully, but these errors were encountered: