FIx unneeded defensive code

This commit is contained in:
Adam Harvey
2020-12-09 15:56:27 -05:00
parent 59a8791158
commit 6fde301a99
+10 -16
View File
@@ -272,23 +272,17 @@ export class ConfigReader implements Config {
if (value === undefined) {
return this.fallback?.readConfigValue(key, validate);
}
if (value !== undefined) {
const result = validate(value);
if (result !== true) {
const {
key: keyName = key,
value: theValue = value,
const result = validate(value);
if (result !== true) {
const { key: keyName = key, value: theValue = value, expected } = result;
throw new TypeError(
errors.type(
this.fullKey(keyName),
this.context,
typeOf(theValue),
expected,
} = result;
throw new TypeError(
errors.type(
this.fullKey(keyName),
this.context,
typeOf(theValue),
expected,
),
);
}
),
);
}
return value as T;