So, in TypeScript's strict mode strict: "true"Function more general type than a regular method. In case, when you use Function type it means the function will be used not only as a regular callable method but also as a constructable method like new Function(). But in case when you use arrow function () => {} it means the function will be used ONLY as a regular callable method (we assume that every class method invoked ONLY as a callable method and cannot be invoked as a constructor). So, problem with typings of @PromMethodCounter is that you invoked that decorator under the ONLY callable method, but decorator returns Function type that can be also a constructable method. It is forbidden to make a narrow type wider.
So, in TypeScript's strict mode
strict: "true"
Function
more general type than a regular method. In case, when you useFunction
type it means the function will be used not only as a regular callable method but also as a constructable method likenew Function()
. But in case when you use arrow function() => {}
it means the function will be used ONLY as a regular callable method (we assume that every class method invoked ONLY as a callable method and cannot be invoked as a constructor). So, problem with typings of@PromMethodCounter
is that you invoked that decorator under the ONLY callable method, but decorator returnsFunction
type that can be also a constructable method. It is forbidden to make a narrow type wider.