-
Notifications
You must be signed in to change notification settings - Fork 75
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
docs: include FailTag jsdoc on Assert type #1393
base: master
Are you sure you want to change the base?
Conversation
@turadg from past experiences with TypeScript I know there are serious drawback to the expansive use of Questions
My understanding of how the IDE works through the code relative to this PR:
Insights
To see how broken TypeScript (version 4.9.4 per my VSCode) is for our purposes all I need to do is make the following subtle correction: /**
* @typedef {Object} AssertPrototype
* @property {FailTag} Fail
* @property {MakeAssert} makeAssert
*
* assert that expr is truthy, with an optional details to describe
* the assertion. It is a tagged template literal like
* ```js
* assert(expr, details`....`);`
* ```
*
* The literal portions of the template are assumed non-sensitive, as
* are the `typeof` types of the substitution values. These are
* assembled into the thrown error message. The actual contents of the
* substitution values are assumed sensitive, to be revealed to
* the console only. We assume only the virtual platform's owner can read
* what is written to the console, where the owner is in a privileged
* position over computation running on that platform.
*
* The optional `optDetails` can be a string for backwards compatibility
* with the nodejs assertion library.
*
* @typedef { BaseAssert & AssertPrototype & {
* typeof: AssertTypeof,
* error: AssertMakeError,
* fail: AssertFail,
* equal: AssertEqual,
* string: AssertString,
* note: AssertNote,
* details: DetailsTag,
* Fail: FailTag,
* quote: AssertQuote,
* makeAssert: MakeAssert,
* } } Assert
*/ Now you will see the documentation body when you hover only for If you switch around the order of the two With more So this does not give us a solution and I am merely demonstrating how TypeScript really lacks the necessary functionality for this pattern. Conventions I also have some concerns regarding casing and naming conventions which are outside the scope of this PR. My observations regarding conventions:
I wonder if there is place where such conventions are addressed somewhere in the repo. |
Yes, the intent is to solve #1392. Any instance of
No. Of course that's out of scope of the problem at hand.
I assume you mean by "here" you mean the repo because this PR has none. I expect the types will work better by making less use of @typedef, but that's not a requirement.
@SMotaal you're more than welcome to submit another PR to solve #1392. This is a draft mostly to demonstrate an approach. I haven't had time to complete it and will probably hold off until I see what you propose. If you want to tackle bigger changes, you're also welcome to propose some, though I can't promise they'll be supported. |
I plan to open PR next week, not sure how that fits with project timelines.
Yes, I think I will open up a separate issue regarding conventions depending on what I dig up when looking closer at the history.
Here at this point when I checkout the PR locally as I was commenting 😊
Yes that is one aspect, but also coerced @turadg, I guess it would be helpful if you know if that is the case? Thanks! |
I think originally there was a desire to keep the type annotations in separate files, but that's no longer a requirement. In my opinion, there's no need for |
draft of how to solve #1392
Copying the jsdoc as done in this PR makes it appear in the IDE as desired:
