-
Notifications
You must be signed in to change notification settings - Fork 110
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
Do not emit @type if @define is specified #1003
Conversation
Instead, just trust whatever type is specified in @define, which should be either string, number, or boolean.
Addressed the points. PTAL. |
This should be ready to merge, though it will need some cleanup internally to go along with any CL that brings it in, since all the types on |
/** | ||
* @define | ||
*/ | ||
const DEFINE_WITH_DECLARED_TYPE: string = 'y'; |
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.
thanks, this looks good!
No, if you look at the jsdoc.js test case, you'll see the badConstThing property declared as With only a single required annotation and no optional, I'm less sold on the win with the map, though in my opinion it is more readable: (a) using an enum rather than an inline condition makes it clear why it's doing what it's doing, and (b) it's potentially less repetition of the condition, depending on how it's structured. But I tried removing it and the diff looks a little cleaner, so I'm fine with that. In terms of adding more in the future, we have a few internal annotations around mods that take arguments and might want to go here. Though I can also see an argument for adding those in a separate Set JSDOC_TAGS_WITH_NON_TYPE_ARGS (or just ..._WITH_ARGS). |
Yes, tsickle behaves like TS in here (and like JSCompiler) in that it produces output even for incorrect user code. The question is how much effort we should put into emitting something that'll still likely work. With tsickle in general and There's a question whether we should have ever had this warnings mechanism, I'm not convinced it's useful for anyone. Then again we apparently have some users who use tsickle as a preprocessor to produce JSDoc, they don't care about the effects on JSCompiler at all. Can't really pick your use cases ... I'll take this over and land it. |
Thanks! |
Instead, disallow types in `@define` and fill in the TypeScript type.
Instead, just trust whatever type is specified in @define, which should be either string, number, or boolean.
This is a blocker for rolling out the new module-compatible style of
goog.define
to TypeScript code.