You have to explicitely add a type declaration to your variable.
export var getCode : (param: string) => string = function (param: string): string {
//...
}
You said this looks pretty unreadable. Well, yes, anonymous types makes TS code look worse, especially when they are huge. In that case, you can declare a callable interface, like this:
export interface CodeGetter {
(param: string): string;
}
export var getCode: CodeGetter = function(param: string): string { ... }
You can check whether tslint allows you (I can't check it right now) to drop type declaration in definition of the function when using the interface
export interface CodeGetter {
(param: string): string;
}
export var getCode: CodeGetter = function(param) { ... }
getCode
? I meanexport var getCode : (param: string) => string = function (param: string): string { ... }
– Dismast