Skip to content

Commit

Permalink
Fix TaggedTemplate evaluation bug
Browse files Browse the repository at this point in the history
This line of code causes a type error since `TaggedTemplateLiteral`s do not have a property called "expressions".

This change does what is probably expected. However, to maintain the existing behaviour, the line should instead be:

```js
const exprs: Array<undefined | NodePath<t.Node>> = path.isTemplateLiteral()
    ? path.get('expressions')
    : []
```
  • Loading branch information
nmn committed Nov 25, 2022
1 parent 65c8496 commit 126264c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/babel-traverse/src/path/evaluation.ts
Expand Up @@ -430,7 +430,11 @@ function evaluateQuasis(
let str = "";

let i = 0;
const exprs = path.get("expressions");
const exprs: Array<NodePath<t.Node>> = path.isTemplateLiteral()
? path.get('expressions')
: (path as NodePath<t.TaggedTemplateExpression>)
.get('quasi')
.get('expressions');

for (const elem of quasis) {
// not confident, evaluated an expression we don't like
Expand Down

0 comments on commit 126264c

Please sign in to comment.