-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove build warnings from the profile plugin #420
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
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 a bunch for making sure that we have no new warnings. (I assume that this brings us back down to 9?) Once we've excised these and the ones in the graph plugin, we should make warnings fail the build.
Interestingly, the warnings (outputted by Closure) indicate that we should not use optional function parameters in our code. TypeScript allows for parameters with default values, but Closure will issue a warning.
This is known: see #149. If you have a function foo(x: number, y = 'I am optional') in TypeScript, and from non-TypeSciprt you call foo(1), then the Closure compiler will emit an error…but if you add /** @param {string=} y */ to the TypeScript file then this error is silenced. That is, you can still use default arguments, but you must explicitly tell the closure compiler about them.
Could you try adding these annotations instead? They're a better solution: if the default value of the argument changes, under this approach existing code will use the new value. (I.e., only under this approach can you actually use default arguments.)
| _updateValue: function(value) { | ||
| this.style.background = "linear-gradient(to right, " + flameColor(value) + | ||
| " " + percent(value) + ", #ccc " + percent(value) + ")"; | ||
| this.style.background = "linear-gradient(to right, " + |
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.
Consider rewriting as:
const color = flameColor(value);
const length = percent(value);
const background =
`linear-gradient(to right, ${color} ${length}, #ccc ${length})`;
this.style.background = background;?
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.
Ah yes. Lets clean it up. Done.
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.
The Closure annotations for optional parameters work! That rids us of all warnings during compilation.
| _updateValue: function(value) { | ||
| this.style.background = "linear-gradient(to right, " + flameColor(value) + | ||
| " " + percent(value) + ", #ccc " + percent(value) + ")"; | ||
| this.style.background = "linear-gradient(to right, " + |
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.
Ah yes. Lets clean it up. Done.
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.
Much better; thanks! Thanks for fixing.
Previously, the profile plugin had been causing warnings to appear during building. This change removes those warnings by adding Closure annotations. @ioeric @sam-mccall
Previously, the profile plugin had been causing warnings to appear during building. This change removes those warnings by adding Closure annotations. @ioeric @sam-mccall
Previously, the profile plugin had been outputting build warnings. This change removes them. Interestingly, the warnings (outputted by Closure) indicate that we should not use optional function parameters in our code. TypeScript allows for parameters with default values, but Closure will issue a warning.