From d33bbbdb7f05f3d66fa750f4f6a13c758a60d814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 15 Apr 2022 10:33:14 -0700 Subject: [PATCH] Do not output `no units` when converting SassNumber to String (#115) --- lib/src/value/number.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/src/value/number.ts b/lib/src/value/number.ts index b1c303ed..422d5347 100644 --- a/lib/src/value/number.ts +++ b/lib/src/value/number.ts @@ -613,10 +613,16 @@ export class SassNumber extends Value { } } + const unitSize = newNumerators.size + newDenominators.size; return valueError( `Expected $this to have ${ - newNumerators.size + newDenominators.size > 1 ? 'units' : 'unit' - } ${unitString(newNumerators, newDenominators)}.`, + unitSize === 0 + ? 'no units' + : `unit${unitSize > 1 ? 's' : ''} ${unitString( + newNumerators, + newDenominators + )}` + }.`, params.name ); }; @@ -684,7 +690,7 @@ function unitString( denominators: List ): string { if (numerators.isEmpty() && denominators.isEmpty()) { - return 'no units'; + return ''; } if (denominators.isEmpty()) {