nestjs / config

Configuration module for Nest framework (node.js) 🍓
https://nestjs.com
MIT License
522 stars 91 forks source link

Wrong method signature for ConfigService.getOrThrow with the infer property set to true #1168

Closed MinaFayez9 closed 1 year ago

MinaFayez9 commented 1 year ago

Is there an existing issue for this?

Current behavior

interface EnvironmentVariables {
  PORT: number;
  TIMEOUT: string;
}

constructor(private configService: ConfigService<EnvironmentVariables>) {
  // port is of type EnvironmentVariables  not number
  const port = this.configService.getOrThrow('PORT', { infer: true });
}

After checking the node_modules\@nestjs\config\dist\config.service.d.ts

Minimum reproduction code

https://stackblitz.com/edit/nestjs-issue-minimum-repro-starter-zcprps?file=README.md

Steps to reproduce

Check main.ts

Expected behavior

Signature of getOrThrow should be getOrThrow<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, options: ConfigGetOptions): Exclude<R, undefined>;

Package

Other package

"@nestjs/config

NestJS version

9.2.1

Packages versions

"@nestjs/config": "^2.2.0"

Node.js version

18.13.0

In which operating systems have you tested?

Other

No response

micalevisk commented 1 year ago

Please provide a minimum reproduction repository. You can start from this minimal project on Stackblitz.

why reproductions are required

MinaFayez9 commented 1 year ago

It's a type error not a bug and it is very clear, so this is very bureaucratic Here is your "minimum reproduction repository"

kamilmysliwiec commented 1 year ago

Thank you @MinaFayez9. Would you like to create a PR for this issue? This looks like an easy fix (get() method works as expected)

MinaFayez9 commented 1 year ago

@kamilmysliwiec I am always happy to help, but after checking out the repo, I found that it was already fixed 5 months ago https://github.com/nestjs/config/commit/73074929cc87dc393c209746c3b4801be74fdff2

MinaFayez9 commented 1 year ago

I see now from npm that you never published a new release since 7 months, that's why the fix is not live

MinaFayez9 commented 1 year ago

So is there a known plan for when will you have a new publish/release ?

kamilmysliwiec commented 1 year ago

Published as 2.3.0