Open bashleigh opened 5 years ago
Work around
config.get('swagger.version', 'beta') as string
@bashleigh
Not quite sure what you're trying to approach, but here's what I came up with.
class ConfigService {
get<T, U = T | undefined | null>(param: T | T[], value: U): T | T[] | U {
// return something
}
}
const config = new ConfigService();
config.get<string>('hello', 'nestjs');
Issue type:
nestjs-config version
@nestjs/common+core or other package versions
Excepted behavior
I want to be able to use strict typing within my service. Using
config.get<string>('something', 'something')
will mean typestring | undefined
is used. Need to be able to specify default type likeget<string, string>()
whereget<T, U>(pattern: string, def?: U): T | U
Actual behavior or outcome (for issue)
Cannot compile because
string | undefined
doesn't matchstring
Replication/Example