digikare / nestjs-prom

A prometheus module for nestjs
160 stars 54 forks source link

Feature/prom method counter generic type #28

Closed nzamulov closed 4 years ago

nzamulov commented 4 years ago

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.

spike008t commented 4 years ago

Thank you for your contribution!