Created
December 19, 2013 04:13
-
-
Save vmadman/8034329 to your computer and use it in GitHub Desktop.
This is *my* current temporary fix to get SugarJS's static method additions working in typescript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../path/to/sugar.d.ts" /> | |
/** | |
* Usage Examples: | |
* sgObject.isArray([1]); // -> true | |
*/ | |
declare var sgObject:ObjectStatic; | |
declare var sgNumber:NumberStatic; | |
declare var sgDate:DateStatic; | |
declare var sgRegExp:RegExpStatic; | |
eval( | |
"sgObject = Object;" + | |
"sgNumber = Number;" + | |
"sgDate = Date;" + | |
"sgRegExp = RegExp;" | |
); |
Just realized that regarding the second point, you could actually just copy the definitions over from Date to DateStatic (maybe that's what you did).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to avoid the eval you could also initialize your objects like this:
The only problems I see with this solution are:
Still, it's better than nothing.