@@ -73,8 +73,7 @@ interface TraversalState {
7373
7474const getReplacementNode = (
7575 state : TraversalState ,
76- placeholderId : string ,
77- placeholderType : string
76+ placeholderId : string
7877) : EsNode | EsNode [ ] | null => {
7978 const key = Number ( placeholderId . slice ( PLACEHOLDER_PREFIX . length ) ) ;
8079 const nodeCount = state . replacementNodes . length ;
@@ -95,9 +94,7 @@ const getReplacementNode = (
9594 const nodeType = Array . isArray ( replacementNode )
9695 ? `[${ replacementNode . map ( ( n ) => n . type ) } .join(', ')]`
9796 : replacementNode ?. type ;
98- throw new Error (
99- `Validation failed for template. Expected node of type '${ placeholderType } ' but received node of type '${ nodeType } '.`
100- ) ;
97+ throw new Error ( `Validation failed for templated node of type ${ nodeType } ` ) ;
10198 }
10299
103100 return replacementNode ;
@@ -106,7 +103,7 @@ const getReplacementNode = (
106103const visitors : Visitors < TraversalState > = {
107104 Identifier ( path , state ) {
108105 if ( path . node ?. name . startsWith ( PLACEHOLDER_PREFIX ) ) {
109- const replacementNode = getReplacementNode ( state , path . node . name , path . node . type ) ;
106+ const replacementNode = getReplacementNode ( state , path . node . name ) ;
110107
111108 if ( replacementNode === null ) {
112109 path . remove ( ) ;
@@ -131,11 +128,7 @@ const visitors: Visitors<TraversalState> = {
131128 path . node . value . startsWith ( PLACEHOLDER_PREFIX )
132129 ) {
133130 // A literal can only be replaced with a single node
134- const replacementNode = getReplacementNode (
135- state ,
136- path . node . value ,
137- path . node . type
138- ) as EsNode ;
131+ const replacementNode = getReplacementNode ( state , path . node . value ) as EsNode ;
139132
140133 path . replaceWith ( replacementNode ) ;
141134 }
0 commit comments