nest icon indicating copy to clipboard operation
nest copied to clipboard

Fixed type error in apply-decorators.ts

Open nikelborm opened this issue 1 year ago • 1 comments
trafficstars

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [x] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Other... Please describe:

What is the current behavior?

Throws typescript error

Argument of type 'string | symbol | undefined' is not assignable to parameter of type 'string | symbol'.
  Type 'undefined' is not assignable to type 'string | symbol'

Here: Screenshot from 2024-01-26 04-06-03

Because typescript definitions of Decorator types are as follows:

declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;

What is the new behavior?

Doesn't throw an error Screenshot from 2024-01-26 03-42-21

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

nikelborm avatar Jan 26 '24 00:01 nikelborm

Apply-decorators were introduced here https://github.com/nestjs/nest/pull/3113

nikelborm avatar Jan 26 '24 01:01 nikelborm