Closed GoogleCodeExporter closed 9 years ago
I would think some of these would actually be constant, no? For example, the
'version' of a MIDIPort won't change over time, will it? (I could be totally
wrong, I haven't actually played with web midi at all.)
Original comment by tbreisac...@google.com
on 7 Mar 2014 at 5:23
Just a clarification.
If a variable or property in externs is marked as @const, the compiler cannot
use that knowledge in optimizations, eg, to inline the value, because it
doesn't know what that value is (it's set in some file invisible to the
compiler). So, it can't break your code.
The only effect of an @const annotation in externs is that the compiler checks
that you don't assign to that variable or property in your code. So, it's safe
to have the annotation and you will have more type checking.
Original comment by dim...@google.com
on 7 Mar 2014 at 6:04
Turns out I was wrong here. The compiler can alias @consts in externs, which
can break your code. So, yes, you shouldn't be using @const for readonly
variables that can change in external code.
Original comment by dim...@google.com
on 7 Mar 2014 at 6:22
Issue tracking has been migrated to github. Please make any further comments on
this issue through https://github.com/google/closure-compiler/issues
Original comment by blic...@google.com
on 1 May 2014 at 6:31
Original comment by blic...@google.com
on 1 May 2014 at 6:34
Original issue reported on code.google.com by
RetroModular
on 7 Mar 2014 at 9:57Attachments: