Skip to content

Commit

Permalink
get rid of return undefined as never with an error for a better err…
Browse files Browse the repository at this point in the history
…or stack trace
  • Loading branch information
xeho91 committed Jul 21, 2024
1 parent cdf0933 commit 65bf49e
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ export function transformExportMetaToDefineMeta(
): VariableDeclaration {
const { declaration, leadingComments, start, end } = exportMeta;
if (!declaration || declaration.type !== 'VariableDeclaration') {
// WARN: This would happen if there was a syntax error, I don't think we should document this error.
return undefined as never;
throw new Error("Invalid syntax - 'export meta' declaration was empty or not a variable declaration");
}
const { declarations } = declaration;
const { init } = declarations[0];

if (!init || init.type !== 'ObjectExpression') {
// WARN: This would happen if there was a syntax error, I don't think we should document this error.
return undefined as never;
throw new Error("Invalid syntax - 'export meta' init was empty or not an object expression");
}

const key = {
Expand Down

0 comments on commit 65bf49e

Please sign in to comment.