-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSDoc Typedef should pull name from attached property if missing #19983
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
Comments
I just discovered this issue while trying to migrate DevTools to TypeScript. The following piece of code triggers the /**
* @typedef {!{data: *}}
*/
export let EventTargetEvent; Per https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc I have tried the following, but Closure does not accept this syntax: /**
* @typedef {!{data: *}} EventTargetEvent
*/ Could typedefs use the name of the variable declaration it is attached to if you don't specify your own name? |
@TimvdLippe what are the intended semantics? Here is what works in Typescript today: /**
* @typedef {!{data: number}}
*/
export let EventTargetEvent;
/** @type {EventTargetEvent} */
var x
x.data Here, |
I think you are correct. I don't see any type issues per-se when we use I just tested the following code and it resulted in the error below (which is probably WAI, it is just a bit hard to spot which errors are correct and which aren't, as TS reports quite a lot of errors atm on existing code): /**
* @typedef {!{eventTarget: !Common.EventTarget, eventType: (string|symbol), thisObject: (!Object|undefined), listener: function(!Common.Event)}}
*/
export let EventDescriptor;
/** @type {!EventDescriptor} */
var x = {
eventTarget: 5,
};
Should I open a separate issue for P.S. Thanks for responding so quickly! |
Yes, please. When designing checkJS, we thought people would not be using noImplicitAny because it would just be a quick re response time: You are the beneficiary of my new year's resolution to look at my GH notifications instead of shuddering and shying away! |
This particular issue is fixed now, I believe by @weswigham a few months ago. |
To answer the |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 2.7.0-dev.201xxxxx
Code
Expected behavior:
ColorPicker.Spectrum.Palette
is effectively a type alias for the type in the typedef.Actual behavior:
(A parse error on the trailing
*
of thetypedef
).This is used everywhere in the chrome devtools codebase.
The text was updated successfully, but these errors were encountered: