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

Question: Optional values #48

Open
MichaelHirn opened this issue Sep 24, 2020 · 0 comments
Open

Question: Optional values #48

MichaelHirn opened this issue Sep 24, 2020 · 0 comments

Comments

@MichaelHirn
Copy link

Hey @derbenoo, thanks for making this repo.

I was wondering if the following behavior is expected and if it can be changed.

Situation

@Configurable({ })
class Config extends BaseConfig<Config> {
  requiredValue: string
  optionalValue?: string
}

console.log(new Config({config: { requiredValue: 'abc' } }))
console.log(new Config({config: { requiredValue: 'abc', optionalValue: 'def' } }))

Expected Behavior

I expected console to print the following

Config { requiredValue: 'abc' }
Config { requiredValue: 'abc', optionalValue: 'def' }

Actual Behavior

But it actually prints this

Config { }
Config { }

I had to provide "dummy" default values in class Config { ... } to get the expected behavior, but it seems a bit strange that I have to change the class to this to get it to work as expected.

// this leads to the expected behavior
@Configurable({ })
class Config extends BaseConfig<Config> {
  requiredValue: string = ''
  optionalValue?: string = undefined
}

Can you advice if this is the desired behavior?

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

No branches or pull requests

1 participant