google/traceur-compiler — pull request #721 by tpodom (2014-01-25 23:19:20+00:00)
Title: Runtime type assertions

Added a new feature to insert runtime type assertions for type annotations. The type assertions are added as assert.type(value, Type);. In order to simplify the insertion of the assertion into variable declarations and return statements it is expected that assert.type return the value passed to it.

Once we support more types of type annotations we will need to come up with a way of representing the annotations in a way that will allow us to call the assert.type function with the additional information represented by the type annotation.

The type assertions are controlled by two new flags:
* --type-assertions (boolean): Turns on assertion generation
* --type-assertions-module (string): Specifies an import path to a type assertion library. If this module path is specified then an import statement is added for the assertion library. Otherwise it is assumed that an assertion library which implements the type check is exposed globally.

Example:
```javascript
function isStringEmpty(value:String):Boolean {
return value ? value.length > 0 : false;
}
```
Would generate:
```javascript
function isStringEmpty(value) {
assert.type(value, String);
return assert.type(value ? value.length > 0: false, Boolean);
}
```