From 1663782954ef1de0e0bce0ba9d759f733bd95f2e Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 10 Mar 2022 16:05:13 +0530 Subject: [PATCH] Throw after fetching value --- postcss/css-compile-variables.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/postcss/css-compile-variables.js b/postcss/css-compile-variables.js index 195526ef..732ed8b3 100644 --- a/postcss/css-compile-variables.js +++ b/postcss/css-compile-variables.js @@ -44,13 +44,10 @@ function resolveDerivedVariable(decl, {variables, derive}) { const matches = variable.match(RE_VARIABLE_VALUE); if (matches) { const [wholeVariable, baseVariable, operation, argument] = matches; - if (!variables[baseVariable]) { - // hmm.. baseVariable should be in config..., maybe this is an alias? - if (!aliasMap.get(`--${baseVariable}`)) { - throw new Error(`Cannot derive from ${baseVariable} because it is neither defined in config nor is it an alias!`); - } - } const value = variables[baseVariable] ?? getValueFromAlias(baseVariable, variables); + if (!value) { + throw new Error(`Cannot derive from ${baseVariable} because it is neither defined in config nor is it an alias!`); + } const derivedValue = derive(value, operation, argument); resolvedMap.set(wholeVariable, derivedValue); }