@@ -10,6 +10,7 @@ import {
1010 type StringLiteral ,
1111 isBlockStatement ,
1212 isCallExpression ,
13+ isExportDefaultDeclaration ,
1314 isIdentifier ,
1415 isIfStatement ,
1516 isImportDeclaration ,
@@ -201,8 +202,8 @@ function parseVueComponentName(filename: string) {
201202
202203 const exportDefaultDecliaration = scriptDescriptors
203204 . get ( filename )
204- ?. ast . body . find (
205- ( v ) => v . type === 'ExportDefaultDeclaration'
205+ ?. ast . body . find ( ( node ) =>
206+ isExportDefaultDeclaration ( node )
206207 ) as ExportDefaultDeclaration | null
207208
208209 if ( ! exportDefaultDecliaration ) return name
@@ -211,11 +212,11 @@ function parseVueComponentName(filename: string) {
211212
212213 const { declaration } = exportDefaultDecliaration
213214
214- if ( declaration . type === 'ObjectExpression' ) {
215+ if ( isObjectExpression ( declaration ) ) {
215216 defineComponentDeclaration = declaration
216217 } else if (
217- declaration . type === 'CallExpression' &&
218- declaration . callee . type === 'Identifier' &&
218+ isCallExpression ( declaration ) &&
219+ isIdentifier ( declaration . callee ) &&
219220 / _ * d e f i n e C o m p o n e n t / . test ( declaration . callee . name )
220221 ) {
221222 defineComponentDeclaration =
@@ -226,10 +227,10 @@ function parseVueComponentName(filename: string) {
226227
227228 for ( const prop of defineComponentDeclaration . properties ) {
228229 if (
229- prop . type === 'ObjectProperty' &&
230- prop . key . type === 'Identifier' &&
230+ isObjectProperty ( prop ) &&
231+ isIdentifier ( prop . key ) &&
231232 / ( _ _ ) ? n a m e / . test ( prop . key . name ) &&
232- prop . value . type === 'StringLiteral'
233+ isStringLiteral ( prop . value )
233234 ) {
234235 return prop . value . value
235236 }
0 commit comments