TypeScript: Typescript Unable to resolve signature of parameter of decorator in vscode
I’m getting the error when I’m decorating the class in nestjs service. I’m using typescript 4.9.4
The Typescript is compiling without errors, and I’m getting this problem only in VSCode.
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)
My tsconfig
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"removeComments": true,
"strictNullChecks": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2020",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
}
}
My Class
export class AuthService {
private readonly logger = new Logger('AuthService');
constructor(
private readonly jwtService: JwtService,
private readonly prisma: PrismaService,
private readonly passwordService: PasswordService,
private readonly configService: ConfigService,
private readonly twilioService: TwilioService,
private readonly userService: UsersService,
@InjectQueue('nest-worker') private nestWorkerQueue: Queue,
@InjectQueue('mailsend') private mailSend: Queue,
@Inject(CACHE_MANAGER) protected readonly cacheManager: Cache,
private readonly mailerService: MailService
) {}
I tried reinstalling typescript and removing node modules, but the problem persists.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 14
- Comments: 33 (1 by maintainers)
Commits related to this issue
- merge the client cleanup. Resolve unused imports. Add 4.9.5 typescript to root package.json to resolve errors within vscode on @inject - https://github.com/microsoft/TypeScript/issues/52396 — committed to usherlabs/logstore by rsoury a year ago
- merge the client cleanup. Resolve unused imports. Add 4.9.5 typescript to root package.json to resolve errors within vscode on @inject - https://github.com/microsoft/TypeScript/issues/52396 — committed to usherlabs/logstore-mirror by rsoury a year ago
This happened to me. And as you said, it is the
JavaScript and TypeScript Nightly
extension in vscode, but I didn’t disable it to fix this. Just select the typescript version you’re using so vscode know what you’re using. In your case is4.9.4
.To make sure you are using
typescript@4.9.4
:Open a JavaScript or TypeScript file in VS Code.
In the VS Code command palette, run the
TypeScript: Select TypeScript version
command. Make sure you have Use Workspace version selected.I added
"experimentalDecorators": true
to mycompilerOptions
intsconfig.json
. Worked with VSCodes typescript version 5.0.4Thanks!! you saved my day 🙌
If you are getting this warning while making a typegoose model, add these three options to your tsconfig.json.
@wayn3r Thanks, run
TypeScript: Select TypeScript version
and it worked for me. ✌️I was still getting the error:
Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.ts(1219)
for an
@NgModule()
decorator even afterTypeScript: Select TypeScript version
got rid of the initial error.What finally worked was setting:
in VSCode’s
settings.json
so the problem is JavaScript and TypeScript Nightly extension in VSCODE, when disabled the problem is gone.
It’s showing the same error to me TS1239: 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’.
The underlying issue is still not fixed though, and it might come as a problem for someone who need to use TypeScript 5.0+. @luluhoc can you open a new issue following the issue template?
To expedite the triage process, we need everyone to follow the issue template and instructions.
When you clicked “Create New Issue”, the issue form was pre-populated with a template and some instructions. We need you to read those instructions completely, follow them, and then fill in all the fields in that template.
We are not able to assist with issues that don’t follow the template instructions as they represent a significantly larger amount of work compared to issues which are correctly specified. Thank you for understanding.
I love u bro
I’m experiencing the same issue, it’s seems like a bug in decorators from 5.0. I’m having this error specifically with the tsyringe decorators
Hi, thanks for the fix.
One thing I don’t understand though is the fact that I already had this line
"typescript.tsdk": node_modules/typescript/lib"
in my project settings but it was not taken into account.Isn’t it a bug ?
Thanks for the solution bro;)
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#more-accurate-type-checking-for-parameter-decorators-in-constructors-under-experimentaldecorators
If @wayn3r solution didn’t solve your problem, you may want to check your tsconfig.json (which should already have “experimentalDecorators”: true) and make sure you have the following:
if the above didn’t solve your problem completely then check out this from Stackoverflow, it was really helpful https://stackoverflow.com/questions/38271273/experimental-decorators-warning-in-typescript-compilation