clutz
clutz copied to clipboard
Reserved keyword cannot be used as function name
if a reserved keyword is used as a function name, the generated typescrit code is invalid:
/**
* @param {string} sym
* @return {symbol|undefined}
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for
*/
Symbol.for;
is converted to:
declare namespace ಠ_ಠ.clutz.Symbol {
function for (a : string ) : any ;
}
members named with a reserverd keyword should be enclosed in a class scope. This code is valid:
declare namespace ಠ_ಠ.clutz {
class Symbol {
static for (a : string ) : any ;
}
}
Symbol is not marked as constructor so better output would be
declare namespace ಠ_ಠ.clutz {
var Symbol : {
for (a : string ) : any ,
(a: string): any
}
}
In fact we already implemented something like this - see https://github.com/angular/clutz/blob/master/src/test/java/com/google/javascript/clutz/reserved_var_names.js. But for some reason it doesn't work on your example (maybe the function throws it off, or the externs part?).