fix: add tokens when tokens: true is passed to parseExpression (#12939)

This commit is contained in:
Huáng Jùnliàng
2021-03-01 14:09:56 -05:00
committed by GitHub
parent 9844eeee84
commit efdca01409
2 changed files with 11 additions and 4 deletions

View File

@@ -148,7 +148,7 @@ export default class ExpressionParser extends LValParser {
}
// Convenience method to parse an Expression only
getExpression(): N.Expression {
getExpression(): N.Expression & N.ParserOutput {
let paramFlags = PARAM;
if (this.hasPlugin("topLevelAwait") && this.inModule) {
paramFlags |= PARAM_AWAIT;
@@ -162,6 +162,9 @@ export default class ExpressionParser extends LValParser {
}
expr.comments = this.state.comments;
expr.errors = this.state.errors;
if (this.options.tokens) {
expr.tokens = this.tokens;
}
return expr;
}