From b052884ad407535495db104a8b3a4910f20140ef Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Mon, 15 Jun 2020 18:40:19 +0100 Subject: [PATCH] update unknownConfigKey error messages --- src/lsp/providers/diagnosticsProvider.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lsp/providers/diagnosticsProvider.ts b/src/lsp/providers/diagnosticsProvider.ts index 42609a0..aa02c02 100644 --- a/src/lsp/providers/diagnosticsProvider.ts +++ b/src/lsp/providers/diagnosticsProvider.ts @@ -279,9 +279,13 @@ function getUnknownConfigKeyDiagnostics( let keys = match.groups.key.split(/[.\[\]]/).filter(Boolean) let value = dlv(state.config, [...base, ...keys]) - // TODO: check that the type is valid - // e.g. objects are not valid - if (typeof value !== 'undefined') { + if ( + typeof value === 'string' || + typeof value === 'number' || + value instanceof String || + value instanceof Number || + Array.isArray(value) + ) { return null } @@ -304,7 +308,10 @@ function getUnknownConfigKeyDiagnostics( severity === 'error' ? DiagnosticSeverity.Error : 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.`, }) }) })