Skip to content

Commit 3d1079c

Browse files
committed
Add SupportedNodes
1 parent bfa66eb commit 3d1079c

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

src/transform-node.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -589,34 +589,36 @@ class Transformer extends Source {
589589
}
590590

591591
// istanbul ignore next
592-
throw Object.assign(new Error('Unexpected node'), { node });
592+
throw new Error(`Unexpected node type '${node.constructor.name}'`);
593593
}
594594
}
595595

596596
// See `convertAst` in `@angular/compiler`
597-
// ASTWithSource (Not handled)
598-
// PropertyRead
599-
// PropertyWrite
600-
// KeyedWrite
601-
// Call
602-
// LiteralPrimitive
603-
// Unary
604-
// Binary
605-
// ThisReceiver (Not handled)
606-
// KeyedRead
607-
// Chain
608-
// LiteralMap
609-
// LiteralArray
610-
// Conditional
611-
// NonNullAssert
612-
// BindingPipe
613-
// SafeKeyedRead
614-
// SafePropertyRead
615-
// SafeCall
616-
// EmptyExpr
617-
// PrefixNot
618-
// TypeofExpression
619-
function transform(node: angular.AST, text: string): NGNode {
597+
type SupportedNodes =
598+
| angular.ASTWithSource // Not handled
599+
| angular.PropertyRead
600+
| angular.PropertyWrite
601+
| angular.KeyedWrite
602+
| angular.Call
603+
| angular.LiteralPrimitive
604+
| angular.Unary
605+
| angular.Binary
606+
| angular.ThisReceiver // Not handled
607+
| angular.KeyedRead
608+
| angular.Chain
609+
| angular.LiteralMap
610+
| angular.LiteralArray
611+
| angular.Conditional
612+
| angular.NonNullAssert
613+
| angular.BindingPipe
614+
| angular.SafeKeyedRead
615+
| angular.SafePropertyRead
616+
| angular.SafeCall
617+
| angular.EmptyExpr
618+
| angular.PrefixNot
619+
| angular.TypeofExpression
620+
| angular.TemplateLiteral; // Including `TemplateLiteralElement`
621+
function transform(node: SupportedNodes, text: string): NGNode {
620622
return new Transformer(node, text).node;
621623
}
622624

0 commit comments

Comments
 (0)