@@ -275,54 +275,39 @@ class Transformer extends Source {
275275 } ) ;
276276 }
277277
278- if (
279- node instanceof angular . PrefixNot ||
280- node instanceof angular . TypeofExpression ||
281- node instanceof angular . VoidExpression
282- ) {
283- const operator =
284- node instanceof angular . PrefixNot
285- ? '!'
286- : node instanceof angular . TypeofExpression
287- ? 'typeof'
288- : node instanceof angular . VoidExpression
289- ? 'void'
290- : /* c8 ignore next @preserve */
291- undefined ;
292-
293- /* c8 ignore next 3 @preserve */
294- if ( ! operator ) {
295- throw new Error ( 'Unexpected expression.' ) ;
296- }
297-
298- let { start } = node . sourceSpan ;
299-
300- // https://github.com/angular/angular/issues/66174
301- if ( operator === 'typeof' || operator === 'void' ) {
302- const index = this . text . lastIndexOf ( operator , start ) ;
303-
304- /* c8 ignore next 7 @preserve */
305- if ( index === - 1 ) {
306- throw new Error (
307- `Cannot find operator '${ operator } ' from index ${ start } in ${ JSON . stringify (
308- this . text ,
309- ) } `,
310- ) ;
311- }
312-
313- start = index ;
314- }
278+ if ( node instanceof angular . PrefixNot ) {
279+ return createNode < babel . UnaryExpression > (
280+ {
281+ type : 'UnaryExpression' ,
282+ prefix : true ,
283+ operator : '!' ,
284+ argument : transformChild < babel . Expression > ( node . expression ) ,
285+ } ,
286+ node . sourceSpan ,
287+ ) ;
288+ }
315289
316- const expression = transformChild < babel . Expression > ( node . expression ) ;
290+ if ( node instanceof angular . TypeofExpression ) {
291+ return createNode < babel . UnaryExpression > (
292+ {
293+ type : 'UnaryExpression' ,
294+ prefix : true ,
295+ operator : 'typeof' ,
296+ argument : transformChild < babel . Expression > ( node . expression ) ,
297+ } ,
298+ node . sourceSpan ,
299+ ) ;
300+ }
317301
302+ if ( node instanceof angular . VoidExpression ) {
318303 return createNode < babel . UnaryExpression > (
319304 {
320305 type : 'UnaryExpression' ,
321306 prefix : true ,
322- operator,
323- argument : expression ,
307+ operator : 'void' ,
308+ argument : transformChild < babel . Expression > ( node . expression ) ,
324309 } ,
325- [ start , node . sourceSpan . end ] ,
310+ node . sourceSpan ,
326311 ) ;
327312 }
328313
0 commit comments