Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdding support for @implements. #36292
Conversation
This comment has been minimized.
This comment has been minimized.
TimvdLippe
commented
Jan 18, 2020
|
Yes I would like to try it out. I will be able to do so next week when I am back in the office. |
This comment has been minimized.
This comment has been minimized.
TimvdLippe
commented
Jan 20, 2020
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@TimvdLippe I unfortunately can't summon the TS bot .. let me try something, <clears-throat /> <incantation-voice> |
This comment has been minimized.
This comment has been minimized.
|
Sure! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@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 |
|
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 |
This comment has been minimized.
This comment has been minimized.
TimvdLippe
commented
Jan 23, 2020
|
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! |
This comment has been minimized.
This comment has been minimized.
|
@TimvdLippe The scope of this was specifically defined as support for If not I think the only workaround for now would be to |
This comment has been minimized.
This comment has been minimized.
|
@dragomirtitian I'd like to keep support for |
This comment has been minimized.
This comment has been minimized.
TimvdLippe
commented
Jan 23, 2020
|
@sandersn Given our extensive use of I am okay with punting that to a different PR though. |
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
TimvdLippe
commented
Jan 27, 2020
|
@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`);
}
} |
This comment has been minimized.
This comment has been minimized.
|
@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. |
dragomirtitian commentedJan 18, 2020
•
edited
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
@implementsnecessarily, 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@abstractwas taken out of the scope of #35629, but maybe adding support for@abstractcould be useful to suppress these errors. Using@ts-ignoremight also be a simpler workaround.