I'm having problems with the piece of code below:
CoreModule.filter('translateEnum', ['$parse', '$translate', function(
$parse: angular.IParseService,
$translate: angular.translate.ITranslateService
) {
var translateFilter = function (translationId, namespace, interpolateParams, interpolation): string {
if (!translationId) {
return '';
} else {
if (!angular.isObject(interpolateParams)) {
interpolateParams = $parse(interpolateParams)(this)
}
return $translate.instant( namespace + '.' + translationId, interpolateParams, interpolation)
}
}
translateFilter.$stateful = true;
return translateFilter;
}]);
I'm getting compilation error constantly:
>> app/modules/core/filters/filters.ts(47,19): error TS2339: Property '$stateful
' does not exist on type '(translationId: any, namespace: any, interpolateParams
: any, interpolation: any) => string'.
The problem is that I need to assing $stateful: boolean
property to a function object and I've got no idea how to do this in typescript.
Here are some tries I've done, but all of them failed:
interface StatefulFunction {
(translationId, namespace, interpolateParams, interpolation): string;
$stateful: boolean;
}
or
interface StatefulFunction {
(...args: any[]): any;
$stateful: boolean;
}
or even
interface StatefulFunction extends Function {
$stateful: boolean;
}