11import type { NodePath } from "@babel/core" ;
2- import type { BlockStatement , ClassDeclaration , Program , TSInterfaceBody , TSMethodSignature , TSPropertySignature , TSType } from "@babel/types" ;
2+ import type { BlockStatement , ClassDeclaration , Identifier , Program , TSInterfaceBody , TSMethodSignature , TSPropertySignature , TSType } from "@babel/types" ;
33import { memberName } from "../utils.js" ;
44import { analyzeLibRef , isReactRef , LibRef } from "./lib.js" ;
55
66export type ComponentHead = {
7+ name ?: Identifier | undefined ;
78 superClassRef : LibRef ;
9+ isPure : boolean ;
810 props : NodePath < TSType > | undefined ;
911 propsEach : Map < string , NodePath < TSPropertySignature | TSMethodSignature > > ;
1012 states : Map < string , NodePath < TSPropertySignature | TSMethodSignature > > ;
@@ -35,6 +37,8 @@ export function analyzeHead(path: NodePath<ClassDeclaration>): ComponentHead | u
3537 return ;
3638 }
3739 if ( superClassRef . name === "Component" || superClassRef . name === "PureComponent" ) {
40+ const name = path . node . id ;
41+ const isPure = superClassRef . name === "PureComponent" ;
3842 let props : NodePath < TSType > | undefined ;
3943 let propsEach : Map < string , NodePath < TSPropertySignature | TSMethodSignature > > | undefined = undefined ;
4044 let states : Map < string , NodePath < TSPropertySignature | TSMethodSignature > > | undefined = undefined ;
@@ -52,7 +56,7 @@ export function analyzeHead(path: NodePath<ClassDeclaration>): ComponentHead | u
5256 }
5357 propsEach ??= new Map ( ) ;
5458 states ??= new Map ( ) ;
55- return { superClassRef, props, propsEach, states } ;
59+ return { name , superClassRef, isPure , props, propsEach, states } ;
5660 }
5761}
5862
0 commit comments