@@ -126,7 +126,7 @@ class Transformer extends Source {
126
126
if ( node instanceof angular . Interpolation ) {
127
127
const { expressions } = node ;
128
128
129
- // istanbul ignore next 3
129
+ /* c8 ignore next 3 */
130
130
if ( expressions . length !== 1 ) {
131
131
throw new Error ( "Unexpected 'Interpolation'" ) ;
132
132
}
@@ -373,7 +373,7 @@ class Transformer extends Source {
373
373
{ type : 'Identifier' , name : 'undefined' , ...node . sourceSpan } ,
374
374
{ hasParentParens : isInParentParens } ,
375
375
) ;
376
- // istanbul ignore next
376
+ /* c8 ignore next 4 */
377
377
default :
378
378
throw new Error (
379
379
`Unexpected LiteralPrimitive value type ${ typeof value } ` ,
@@ -427,20 +427,35 @@ class Transformer extends Source {
427
427
) ;
428
428
}
429
429
430
- const isPrefixNot = node instanceof angular . PrefixNot ;
431
- if ( isPrefixNot || node instanceof angular . TypeofExpression ) {
432
- const expression = this . #transform< babel . Expression > ( node . expression ) ;
430
+ if (
431
+ node instanceof angular . PrefixNot ||
432
+ node instanceof angular . TypeofExpression ||
433
+ node instanceof angular . VoidExpression
434
+ ) {
435
+ const operator =
436
+ node instanceof angular . PrefixNot
437
+ ? '!'
438
+ : node instanceof angular . TypeofExpression
439
+ ? 'typeof'
440
+ : node instanceof angular . VoidExpression
441
+ ? 'void'
442
+ : /* c8 ignore next */
443
+ undefined ;
444
+
445
+ /* c8 ignore next 3 */
446
+ if ( ! operator ) {
447
+ throw new Error ( 'Unexpected expression.' ) ;
448
+ }
433
449
434
- const operator = isPrefixNot ? '!' : 'typeof' ;
435
450
let { start } = node . sourceSpan ;
436
451
437
- if ( ! isPrefixNot ) {
452
+ if ( operator === 'typeof' || operator === 'void' ) {
438
453
const index = this . text . lastIndexOf ( operator , start ) ;
439
454
440
- // istanbul ignore next 7
455
+ /* c8 ignore next 7 */
441
456
if ( index === - 1 ) {
442
457
throw new Error (
443
- `Cannot find operator ${ operator } from index ${ start } in ${ JSON . stringify (
458
+ `Cannot find operator ' ${ operator } ' from index ${ start } in ${ JSON . stringify (
444
459
this . text ,
445
460
) } `,
446
461
) ;
@@ -449,6 +464,8 @@ class Transformer extends Source {
449
464
start = index ;
450
465
}
451
466
467
+ const expression = this . #transform< babel . Expression > ( node . expression ) ;
468
+
452
469
return this . #create< babel . UnaryExpression > (
453
470
{
454
471
type : 'UnaryExpression' ,
@@ -539,6 +556,15 @@ class Transformer extends Source {
539
556
) ;
540
557
}
541
558
559
+ if ( node instanceof angular . TaggedTemplateLiteral ) {
560
+ return this . #create< babel . TaggedTemplateExpression > ( {
561
+ type : 'TaggedTemplateExpression' ,
562
+ tag : this . #transform( node . tag ) as babel . Expression ,
563
+ quasi : this . #transform( node . template ) as babel . TemplateLiteral ,
564
+ ...node . sourceSpan ,
565
+ } ) ;
566
+ }
567
+
542
568
if ( node instanceof angular . TemplateLiteral ) {
543
569
const { elements, expressions } = node ;
544
570
@@ -579,7 +605,11 @@ class Transformer extends Source {
579
605
) ;
580
606
}
581
607
582
- // istanbul ignore next
608
+ if ( node instanceof angular . ParenthesizedExpression ) {
609
+ return this . #transformNode( node . expression ) ;
610
+ }
611
+
612
+ /* c8 ignore next */
583
613
throw new Error ( `Unexpected node type '${ node . constructor . name } '` ) ;
584
614
}
585
615
}
@@ -608,7 +638,10 @@ type SupportedNodes =
608
638
| angular . EmptyExpr
609
639
| angular . PrefixNot
610
640
| angular . TypeofExpression
611
- | angular . TemplateLiteral ; // Including `TemplateLiteralElement`
641
+ | angular . VoidExpression
642
+ | angular . TemplateLiteral // Including `TemplateLiteralElement`
643
+ | angular . TaggedTemplateLiteral
644
+ | angular . ParenthesizedExpression ;
612
645
function transform ( node : SupportedNodes , text : string ) : NGNode {
613
646
return new Transformer ( node , text ) . node ;
614
647
}
0 commit comments