update unknownConfigKey error messages

master
Brad Cornes 2020-06-15 18:40:19 +01:00
parent 20c41600db
commit b052884ad4
1 changed files with 11 additions and 4 deletions

View File

@ -279,9 +279,13 @@ function getUnknownConfigKeyDiagnostics(
let keys = match.groups.key.split(/[.\[\]]/).filter(Boolean) let keys = match.groups.key.split(/[.\[\]]/).filter(Boolean)
let value = dlv(state.config, [...base, ...keys]) let value = dlv(state.config, [...base, ...keys])
// TODO: check that the type is valid if (
// e.g. objects are not valid typeof value === 'string' ||
if (typeof value !== 'undefined') { typeof value === 'number' ||
value instanceof String ||
value instanceof Number ||
Array.isArray(value)
) {
return null return null
} }
@ -304,7 +308,10 @@ function getUnknownConfigKeyDiagnostics(
severity === 'error' severity === 'error'
? DiagnosticSeverity.Error ? DiagnosticSeverity.Error
: DiagnosticSeverity.Warning, : DiagnosticSeverity.Warning,
message: `Unknown ${match.groups.helper} key: ${match.groups.key}`, message:
typeof value === 'undefined'
? `'${match.groups.key}' does not exist in your theme config.`
: `'${match.groups.key}' was found but does not resolve to a string.`,
}) })
}) })
}) })