willsoto/nestjs-prometheus

TypeScript error "Unable to resolve signature of parameter decorator when called as an expression"

ozelen opened this issue ยท 13 comments

On the sample code:

import { Injectable } from '@nestjs/common';
import { Counter } from 'prom-client';
import { InjectMetric } from '@willsoto/nestjs-prometheus';

@Injectable()
export class Service {
  constructor(@InjectMetric('metric_name') public counter: Counter<string>) {}
}

TS compiler throws an error:

Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'typeof Service' is not assignable to parameter of type 'Record<string, unknown>'.
    Index signature for type 'string' is missing in type 'typeof Service'

What version of TypeScript?

@willsoto , 4.3.5

Works for me on TS 4.9.5

4.3.5 is a very old version of TypeScript though. You should try upgrading and, if it's still broken, creating a minimal reproduction or a failing test case.

Agree. I updated TS version. Still see the error, but it's only visible in VSCode, not runtime. Like follows
image

Try reloading VSCode?

tried already, didn't help though. Weird thing...

Perhaps VSCode isn't using whatever tsconfig the runtime is using?

Looks like the plugin JavaScript and TypeScript Nightly works incorrectly. When I turned it off, the problem disappeared (along with some validation hinting though :), but VSC started performing much better).

๐Ÿ‘

With typescript v5 it fails with the same error when trying to build.

Please confirm it's not the same issue with the same resolution mentioned here: #1667 (comment)

If you believe it's actually an issue with v5, please open a new issue with a minimal reproduction of the problem.

Please confirm it's not the same issue with the same resolution mentioned here: #1667 (comment)

If you believe it's actually an issue with v5, please open a new issue with a minimal reproduction of the problem.

I have the same problem. This reproduces the problem. I have also fixed the problem and I am making a pull request for it right now.

๐ŸŽ‰ This issue has been resolved in version 5.1.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€