From 5cdf58b08284f17e6edd4e55ed69e08ffd6e048c Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Mon, 11 Nov 2024 01:23:32 +0100 Subject: [PATCH] Refactor tryNormalizeType function for cleaner code - Removed explicit 'if' check for null/empty value and simplified return statement. - Changed return type annotation from 'string' to '(string|null)' to reflect possible null return value. --- index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index a5f1109..4a00f79 100644 --- a/index.js +++ b/index.js @@ -251,17 +251,12 @@ function normalizeType (value) { * Try to normalize a type and remove parameters. * * @param {string} value - * @return {string} + * @return {(string|null)} * @private */ - function tryNormalizeType (value) { - if (!value) { - return null - } - try { - return normalizeType(value) + return value ? normalizeType(value) : null } catch (err) { return null }