Skip to content

Commit

Permalink
fix possible undefined sourceMapString
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Aug 8, 2024
1 parent d553969 commit fb87955
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/js/tools/vendor/metro/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down

0 comments on commit fb87955

Please sign in to comment.