From fb879551cc9387eacac37cc8955739bb08a8979b Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Thu, 8 Aug 2024 23:40:44 +0200 Subject: [PATCH] fix possible undefined sourceMapString --- src/js/tools/vendor/metro/utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/js/tools/vendor/metro/utils.ts b/src/js/tools/vendor/metro/utils.ts index 4bdfa8f223..0df6cde7de 100644 --- a/src/js/tools/vendor/metro/utils.ts +++ b/src/js/tools/vendor/metro/utils.ts @@ -80,10 +80,15 @@ export const createDefaultMetroSerializer = (): MetroSerializer => { return code; } - let sourceMapStringFunction; + let sourceMapStringFunction: typeof sourceMapString | undefined; if (typeof sourceMapString === 'function') { sourceMapStringFunction = sourceMapString; - } else if (typeof (sourceMapString as NewSourceMapStringExport).sourceMapString === 'function') { + } else if ( + typeof sourceMapString === 'object' && + sourceMapString != null && + 'sourceMapString' in sourceMapString && + typeof sourceMapString['sourceMapString'] === 'function' + ) { sourceMapStringFunction = (sourceMapString as NewSourceMapStringExport).sourceMapString; } else { throw new Error(`