Hello,
If I want to register a value of 0/null/false/empty string, it won't get resolved and it will fail.
Ex:
container.register({ token: 'foo', useValue: 0 });
container.resolve('foo') fails
The problem seems to be in container.ts : registerOne(provider).
if (provider.useValue) {
registryData.instance = provider.useValue;
}
I would suggest replacing it with
if (provider.useValue !== void 0) {
registryData.instance = provider.useValue;
}
or
if ('useValue' in provider) {
registryData.instance = provider.useValue;
}
to support undefined values.
Also, maybe check if a provider is valid (has only one of useClass/useValue/useFactory set on something different than undefined).
Thanks
Hello,
If I want to register a value of 0/null/false/empty string, it won't get resolved and it will fail.
Ex:
container.register({ token: 'foo', useValue: 0 });container.resolve('foo')failsThe problem seems to be in
container.ts : registerOne(provider).I would suggest replacing it with
or
to support undefined values.
Also, maybe check if a provider is valid (has only one of useClass/useValue/useFactory set on something different than undefined).
Thanks