@@ -126,7 +126,7 @@ class Transformer extends Source {
126126 if ( node instanceof angular . Interpolation ) {
127127 const { expressions } = node ;
128128
129- // istanbul ignore next 3
129+ /* c8 ignore next 3 */
130130 if ( expressions . length !== 1 ) {
131131 throw new Error ( "Unexpected 'Interpolation'" ) ;
132132 }
@@ -373,7 +373,7 @@ class Transformer extends Source {
373373 { type : 'Identifier' , name : 'undefined' , ...node . sourceSpan } ,
374374 { hasParentParens : isInParentParens } ,
375375 ) ;
376- // istanbul ignore next
376+ /* c8 ignore next 4 */
377377 default :
378378 throw new Error (
379379 `Unexpected LiteralPrimitive value type ${ typeof value } ` ,
@@ -427,20 +427,35 @@ class Transformer extends Source {
427427 ) ;
428428 }
429429
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+ }
433449
434- const operator = isPrefixNot ? '!' : 'typeof' ;
435450 let { start } = node . sourceSpan ;
436451
437- if ( ! isPrefixNot ) {
452+ if ( operator === 'typeof' || operator === 'void' ) {
438453 const index = this . text . lastIndexOf ( operator , start ) ;
439454
440- // istanbul ignore next 7
455+ /* c8 ignore next 7 */
441456 if ( index === - 1 ) {
442457 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 (
444459 this . text ,
445460 ) } `,
446461 ) ;
@@ -449,6 +464,8 @@ class Transformer extends Source {
449464 start = index ;
450465 }
451466
467+ const expression = this . #transform< babel . Expression > ( node . expression ) ;
468+
452469 return this . #create< babel . UnaryExpression > (
453470 {
454471 type : 'UnaryExpression' ,
@@ -539,6 +556,15 @@ class Transformer extends Source {
539556 ) ;
540557 }
541558
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+
542568 if ( node instanceof angular . TemplateLiteral ) {
543569 const { elements, expressions } = node ;
544570
@@ -579,7 +605,11 @@ class Transformer extends Source {
579605 ) ;
580606 }
581607
582- // istanbul ignore next
608+ if ( node instanceof angular . ParenthesizedExpression ) {
609+ return this . #transformNode( node . expression ) ;
610+ }
611+
612+ /* c8 ignore next */
583613 throw new Error ( `Unexpected node type '${ node . constructor . name } '` ) ;
584614 }
585615}
@@ -608,7 +638,10 @@ type SupportedNodes =
608638 | angular . EmptyExpr
609639 | angular . PrefixNot
610640 | angular . TypeofExpression
611- | angular . TemplateLiteral ; // Including `TemplateLiteralElement`
641+ | angular . VoidExpression
642+ | angular . TemplateLiteral // Including `TemplateLiteralElement`
643+ | angular . TaggedTemplateLiteral
644+ | angular . ParenthesizedExpression ;
612645function transform ( node : SupportedNodes , text : string ) : NGNode {
613646 return new Transformer ( node , text ) . node ;
614647}
0 commit comments