Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @targetName() signature on TypeScript 5 #1561

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gustavohenke
Copy link

Description

Title. Basically just makes it accept an undefined value for targetKey, which stops TypeScript from complaining about it.

Related Issue

#1556

Motivation and Context

I want to upgrade Typescript to v5 and use @targetName().

See https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#more-accurate-type-checking-for-parameter-decorators-in-constructors-under-experimentaldecorators

How Has This Been Tested?

Not a functional change, but rather a type change. That said, npm test still passes.
Furthermore, TypeScript v5.x.x no longer shows errors when using @targetName().

Types of changes

  • Updated docs / Refactor code / Added a tests case (non-breaking change)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the changelog.

@@ -3,7 +3,7 @@ import { Metadata } from '../planning/metadata';
import { tagParameter, DecoratorTarget } from './decorator_utils';

function targetName(name: string) {
return function (target: DecoratorTarget, targetKey: string, index: number) {
return function (target: DecoratorTarget, targetKey: string | undefined, index: number) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could even be this, and would still work

Suggested change
return function (target: DecoratorTarget, targetKey: string | undefined, index: number) {
return function (target: DecoratorTarget, targetKey: undefined, index: number) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant