Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/async-rewriter2/src/async-writer-babel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ describe('AsyncWriter', () => {
});

it('throws sensible error messages for long expressions', () => {
expect(() => runTranspiledCode('var abcdefghijklmnopqrstuvwxyz; abcdefghijklmnopqrstuvwxyz()'))
expect(() => runTranspiledCode('globalThis.abcdefghijklmnopqrstuvwxyz = {}; abcdefghijklmnopqrstuvwxyz()'))
.to.throw('abcdefghijklm ... uvwxyz is not a function');
});
});
Expand Down
6 changes: 6 additions & 0 deletions packages/async-rewriter2/src/stages/transform-maybe-await.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,17 @@ export default ({ types: t }: { types: typeof BabelTypes }): babel.PluginObj<{ f
path.isParenthesizedExpression() ||
path.isUnaryExpression() ||
path.isSuper() || // Would probably break stuff
path.isThisExpression() ||
path.isAwaitExpression() || // No point in awaiting twice
path.parentPath.isAwaitExpression()) {
return;
}

// If it's an identifier and we know where it has been declared, it's fine as well
// because having seen a declaration means either being undefined or having seen
// an assignment as well.
if (path.isIdentifier() && path.scope.hasBinding(path.node.name)) return;

const { expressionHolder, isSyntheticPromise, assertNotSyntheticPromise } = identifierGroup;
const prettyOriginalString = limitStringLength(
path.node.start !== undefined ?
Expand Down