-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Adding support for @implements. #36292
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
Conversation
Yes I would like to try it out. I will be able to do so next week when I am back in the office. |
To be able to debug, I would need a bot-pack build that I can try out. Let me know when you have one available 😄 |
@TimvdLippe I unfortunately can't summon the TS bot .. let me try something, <clears-throat /> <incantation-voice> |
Sure! |
Hey @orta, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
@dragomirtitian re your questions:
I will look at the code now. I'm a linguist, so I prefer the traditional 3 invocations. Like this: @NoamChomsky @NoamChomsky @NoamChomsky |
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.
Looks good so far. I have a couple of initial suggestions.
As for tests, don't forget fourslash tests -- I think we suggest completions based on implements
so the same thing should work for @implements
.
I can confirm that the updated build is catching issues like missing overrides. That said, we are hitting a couple of other issues with TypeScript (#19983) which makes it hard for us to fully test all of its internals. My understanding thus far is that this change is WAI. One improvement that would be great is that methods with Thank you for doing the work and for the quick implementation! |
@TimvdLippe The scope of this was specifically defined as support for If not I think the only workaround for now would be to |
@dragomirtitian I'd like to keep support for |
@sandersn Given our extensive use of I am okay with punting that to a different PR though. |
Looking at the example in the jsdoc documentation (excerpted below), I note that throwing in the interface body satisfies Typescript because throwing causes the function to return /**
* @interface
*/
function Color() {}
/**
* @returns {Array<number>} An array containing the red, green, and blue values, in that order.
*/
Color.prototype.rgb = function() {
throw new Error('not implemented');
}; Does that work with Closure? |
@sandersn I just checked and the following does indeed compile in both Closure and TS (with this patch): /**
* @interface
*/
export class EventTarget {
/**
* @param {symbol} eventType
* @param {function(!Common.Event)} listener
* @param {!Object=} thisObject
* @return {!Common.EventTarget.EventDescriptor}
*/
addEventListener(eventType, listener, thisObject) {
throw new Error(`Not implemented`);
}
} |
@sandersn I fixed the code review issues. I added a test for multiple interfaces. I ran into the following issues;
Also sorry for the delay, it's been a hectic week at work. |
|
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.
I think this is ready to go, at least as far as I can tell. @dragomirtitian do you want to take it off Draft status?
(Edit: When the minor test suggestions are done.)
tests/cases/conformance/jsdoc/jsdocImplements_interface_multiple.ts
Outdated
Show resolved
Hide resolved
@typescript-bot user test this |
ha ha oh no now user tests are broken because of the new octokit. |
(fix is at #36915; I'll merge it after I see that it can post a user test PR) |
@dragomirtitian can you merge from master and then I'll run the user tests? |
@sandersn Yes, I'll merge from master. First I want to fix the declaration emit for |
@sandersn I merged master, and fixed declaration emit. You should have a look at the emit fixes. |
@typescript-bot user test this |
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.
I haven’t had a chance to look at the test changes yet, but I had some requests for the code that I wanted to make before I quit for the weekend.
I think this will be ready once you get rid of the unneeded checks. |
@sandersn Ok, I think we are good to go! |
@dragomirtitian Thanks for your hard work on this one! |
Fixes #35629
Open issues:
@sandersn For 1 I would suppress these errors for JS. For 2, do you think it is worth showing the fix? Also maybe we could have a typescript-bot pack of this so @TimvdLippe can maybe give it a try.
One issue, unrelated to
@implements
necessarily, is that method in the classes used as interfaces in @TimvdLippe example don't have any return statement, so any return type will cause an error. Support for@abstract
was taken out of the scope of #35629, but maybe adding support for@abstract
could be useful to suppress these errors. Using@ts-ignore
might also be a simpler workaround.