Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Document the JSCompiler's "type-tightening" behavior in asserts.js.
Browse files Browse the repository at this point in the history
RELNOTES: n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=236244963
  • Loading branch information
nanaze authored and shicks committed Mar 1, 2019
1 parent 1eb5e5d commit 1488aa2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions closure/goog/asserts/asserts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
* The compiler will leave in foo() (because its return value is used),
* but it will remove bar() because it assumes it does not have side-effects.
*
* Additionally, note the compiler will consider the type to be "tightened" for
* all statements <em>after</em> the assertion. For example:
* <code>
* const /** ?Object &#ast;/ value = foo();
* goog.asserts.assert(value);
* // "value" is of type {!Object} at this point.
* </code>
*
* @author agrieve@google.com (Andrew Grieve)
*/

Expand Down

0 comments on commit 1488aa2

Please sign in to comment.