nestjsx/nestjs-config

Can not pass arguments to dotenv since typescript 3.4.1

cmathe opened this issue · 3 comments

Issue type:

  • question
  • bug report
  • feature request
  • documentation issue

nestjs-config version
1.3.21

@nestjs/common+core or other package versions

  • @nestjs/common: 6.1.1
  • @nestjs/core: 6.1.1

Excepted behavior

It should be possible to pass arguments to dotenv in order to configure it.
For example, it should be possible to change the .env files path.

Actual behavior or outcome (for issue)

It is not possible to pass arguments to dotenv because only modifyConfigName key is allowed in ConfigOptions interface.
It works properly with typescript 3.3.4000 but not with 3.4.1
It seems that ConfigOptions does not extends DotenvConfigOptions the same way with those two versions of typescript.

Replication/Example

  const config = process.env.CONFIG || ''; // allow us to provide configuration easily for local environment and CI environment
  return ConfigModule.load(path.resolve(__dirname, 'config', '**/!(*.d).{ts,js}'), {path: path.resolve(__dirname, `config/env/${config}.env`)});

Error

src/app.module.ts:34:85 - error TS2345: Argument of type '{ path: string; }' is not assignable to parameter of type 'ConfigOptions'.
      Object literal may only specify known properties, and 'path' does not exist in type 'ConfigOptions'.

    34   return ConfigModule.load(path.resolve(__dirname, 'config', '**/!(*.d).{ts,js}'), {path: path.resolve(__dirname, `config/env/${config}.env`)});

Comment

Changing nestjs dependencies release does not affect the behavior :

nestjs typescript nestjs-config status
6.1.x 3.3.4000 1.3.21 works
6.0.x 3.3.4000 1.3.21 works
6.1.x 3.4.1 or later 1.3.21 fails
6.0.x 3.4.1 or later 1.3.21 fails

Looks like greenkeeper made a PR but it's failing #93 I'll check this out

I've released a fix as v1.4.0 👍

Thanks