Just for amusement, I'm trying to use TypeScript's strong typing in code containing a closure. Here's what the original JavaScript code looks like:
var func = (function() {
var private_count = 0;
var increment = function() {
private_count += 1;
return private_count;
}
return increment;
}());
Here's my best attempt to implement this with TypeScript:
var func: ()=>()=>number = (function(): ()=>number {
var _count: number = 0;
var increment: ()=>number = function(): number {
_count += 1;
return _count;
}
return increment;
}());
func is a function that returns a function that returns a number. I've set its type to '()=>()=>number', but the compiler doesn't like that. I know this isn't the most practical use of TypeScript, but does anyone have any thoughts for fixing the compile error?