File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ module.exports = {
198198 if ( ! component ) {
199199 return ;
200200 }
201- markDisplayNameAsDeclared ( component . node . type === 'TSAsExpression' ? component . node . expression : component . node ) ;
201+ markDisplayNameAsDeclared ( astUtil . unwrapTSAsExpression ( component . node ) ) ;
202202 } ,
203203
204204 'FunctionExpression, FunctionDeclaration, ArrowFunctionExpression' ( node ) {
Original file line number Diff line number Diff line change @@ -339,15 +339,18 @@ function isAssignmentLHS(node) {
339339 ) ;
340340}
341341
342+ function isTSAsExpression ( node ) {
343+ return node && node . type === 'TSAsExpression' ;
344+ }
345+
342346/**
343347 * Extracts the expression node that is wrapped inside a TS type assertion
344348 *
345349 * @param {ASTNode } node - potential TS node
346350 * @returns {ASTNode } - unwrapped expression node
347351 */
348352function unwrapTSAsExpression ( node ) {
349- if ( node && node . type === 'TSAsExpression' ) return node . expression ;
350- return node ;
353+ return isTSAsExpression ( node ) ? node . expression : node ;
351354}
352355
353356function isTSTypeReference ( node ) {
@@ -450,6 +453,7 @@ module.exports = {
450453 isFunctionLike,
451454 inConstructor,
452455 isNodeFirstInLine,
456+ isTSAsExpression,
453457 unwrapTSAsExpression,
454458 traverseReturns,
455459 isTSTypeReference,
You can’t perform that action at this time.
0 commit comments