We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Issue type:
nestjs-config version 0.6.3
@nestjs/common+core or other package versions
Given the following .env.local file,
.env.local
KEY1=3000 KEY2=false
When performing this:
const confValue = this.configService.get<number>("KEY1", 5000);
then confValue's type should be a number. At least that's what the get method's signature suggests and that's great.
confValue
get
However, when doing:
... then confValue is actually a string, which is confirmed by typeof confValue
typeof confValue
... which gets worse when dealing with booleans:
const confValue = this.configService.get<boolean>("KEY2", false); if (confValue) { // truthy expression which always returns true: if "false" => true }
Thanks for your help !
@Module({ imports: [ ConfigModule.forRoot({ envFilePath: ['.env.local'], cache: true }) ], controllers: [ ], providers: [MyManager], }) export class AppModule { }
@Injectable() export class MyManager { @Inject() private configService: ConfigService; public async doStuff(): Promise<void> { const confValue1 = this.configService.get<number>("KEY1", 5000); const confValue2 = this.configService.get<boolean>("KEY2", false); } }
The text was updated successfully, but these errors were encountered:
but nestjs-config never had this version. Maybe you're talking about @nestjs/config?
nestjs-config
@nestjs/config
$ npm info nestjs-config versions [ '1.0.0', '1.0.1', '1.1.0', '1.2.0', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.2.5', '1.2.6', '1.2.7', '1.2.8', '1.2.9-alpha', '1.2.9', '1.3.0', '1.3.2', '1.3.21', '1.4.0', '1.4.1', '1.4.2', '1.4.3', '1.4.4', '1.4.5', '1.4.6', '1.4.7', '1.4.8', '2.0.0-beta', '2.0.0-beta.1', '2.0.0-beta.2', '2.0.0-beta.3' ]
Sorry, something went wrong.
No branches or pull requests
Issue type:
nestjs-config version
0.6.3
@nestjs/common+core or other package versions
Excepted behavior
Given the following
.env.local
file,When performing this:
then
confValue
's type should be a number. At least that's what theget
method's signature suggests and that's great.Actual behavior or outcome (for issue)
However, when doing:
... then
confValue
is actually a string, which is confirmed bytypeof confValue
... which gets worse when dealing with booleans:
Thanks for your help !
Replication/Example
The text was updated successfully, but these errors were encountered: