config icon indicating copy to clipboard operation
config copied to clipboard

fix(type): config service get and getOrThrow methods return type

Open PongDev opened this issue 7 months ago • 0 comments

When a ConfigService type is provided, the return type should match the given type; otherwise, a compile error should occur.

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)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

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

What is the current behavior?

Issue Number: N/A

When the type of receiver variable and the type provided by ConfigService don't match, no error occurs.

What is the new behavior?

When a ConfigService type is provided, a typescript compile error will occur if return type and given type doesn't match.

Does this PR introduce a breaking change?

  • [x] Yes
  • [ ] No

If a variable type has previously provided but doesn't match the return type provided in ConfigService, typescript will produce a compile error and // @ts-ignore is required to ignore error.

Other information

PongDev avatar Jun 03 '25 10:06 PongDev