0

Context

I have been working on this project for almost a year now, with no issue injecting Winston logger Logger with the WINSTON_MODULE_PROVIDER token. I woke up last week to find that TypeScript now highlights this piece of code @Inject(WINSTON_MODULE_PROVIDER) as red, with this message:

Unable to resolve signature of parameter decorator when called as an expression. Argument of type 'undefined' is not assignable to parameter of type 'string | symbol'.ts(1239)
--
(alias) const WINSTON_MODULE_PROVIDER: "winston"
import WINSTON_MODULE_PROVIDER
--
No quick fixes available

Thinking it was VSCode, I closed the project to work on other things. Voila, I opened the project earlier today and it is still right there, staring me in the face. And the only thing I have updated so far is my VSCode.

However, thankfully, the project runs as usual.

Code snippet

import { Inject, Injectable } from '@nestjs/common';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
//...

@Injectable()
export class QueryTransactionsService {
  constructor(
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
    //...
  ) {}

  //...
}

Specs

Relevant dependencies

  • vscode: 1.77.0
  • node: 16.13.0
  • @nestjs/common: ^9.0.0
  • typescript: ^4.3.5
  • @types/node: ^16.0.0
  • ts-node: ^10.0.0
  • winston: ^3.8.2
  • nest-winston: ^1.7.0

TS Config

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": true,
    "noImplicitAny": true,
    "strictBindCallApply": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true
  }
}

Resolution Attempts

None of the below attempts worked to resolve this issue:

  1. Restart VSCode
  2. Reinstall all packages using npm i
  3. Run audit fix using npm audit fix
  4. Update TypeScript: Enable Prompt Use Workspace Tsdk to true on VSCode settings. Ref: Typescript Unable to resolve signature of parameter of decorator in vscode

0 Answers0