You must explicitly add a type declaration to your variable.
export var getCode : (param: string) => string = function (param: string): string {
}
You said it looks pretty impenetrable. Well, yes, anonymous types make TS code worse, especially when they are huge. In this case, you can declare the called interface, for example:
export interface CodeGetter {
(param: string): string;
}
export var getCode: CodeGetter = function(param: string): string { ... }
You can check if tslint allows (I can't check it right now) to discard the type declaration in the function definition when using the interface
export interface CodeGetter {
(param: string): string;
}
export var getCode: CodeGetter = function(param) { ... }
source
share