import type { Expression } from "./expression"; import type { ConstructorFunctionExpression, GetterFunctionExpression, MethodFunctionExpression, SetterFunctionExpression, } from "./function"; import type { ConstructorIdentifier, VariableIdentifier } from "./identifier"; import type { Key } from "./key"; import type { Statement } from "./statement"; export type ClassEntry = | MethodDefinition | PropertyDefinition | StaticBlock; export type ClassExpression = X & { type: "ClassExpression"; id: VariableIdentifier | null; superClass: Expression | null; body: ClassBody; }; export type AnonymousClassDeclaration = X & { type: "ClassDeclaration"; id: null; superClass: Expression | null; body: ClassBody; }; export type ClassDeclaration = X & { type: "ClassDeclaration"; id: VariableIdentifier; superClass: Expression | null; body: ClassBody; }; export type ClassBody = X & { type: "ClassBody"; body: Array>; }; // Method // export type MethodDefinition = | ConstructorMethodDefinition | PlainMethodDefinition | GetterMethodDefinition | SetterMethodDefinition; // ConstructorMethod // export type ConstructorMethodDefinition = X & { type: "MethodDefinition"; key: ConstructorIdentifier; value: ConstructorFunctionExpression; kind: "constructor"; computed: false; static: false; }; // PlainMethod // export type PlainMethodDefinition = | ComputedPlainMethodDefinition | NonComputedPlainMethodDefinition; export type ComputedPlainMethodDefinition = X & { type: "MethodDefinition"; key: Expression; value: MethodFunctionExpression; kind: "method"; computed: true; static: boolean; }; export type NonComputedPlainMethodDefinition = X & { type: "MethodDefinition"; key: Key; value: MethodFunctionExpression; kind: "method"; computed: false; static: boolean; }; // GetterMethod // export type GetterMethodDefinition = | ComputedGetterMethodDefinition | NonComputedGetterMethodDefinition; export type ComputedGetterMethodDefinition = X & { type: "MethodDefinition"; key: Expression; value: GetterFunctionExpression; kind: "get"; computed: true; static: boolean; }; export type NonComputedGetterMethodDefinition = X & { type: "MethodDefinition"; key: Key; value: GetterFunctionExpression; kind: "get"; computed: false; static: boolean; }; // SetterMethod // export type SetterMethodDefinition = | ComputedSetterMethodDefinition | NonComputedSetterMethodDefinition; export type ComputedSetterMethodDefinition = X & { type: "MethodDefinition"; key: Expression; value: SetterFunctionExpression; kind: "set"; computed: true; static: boolean; }; export type NonComputedSetterMethodDefinition = X & { type: "MethodDefinition"; key: Key; value: SetterFunctionExpression; kind: "set"; computed: false; static: boolean; }; // Property // export type PropertyDefinition = | ComputedPropertyDefinition | NonComputedPropertyDefinition; export type ComputedPropertyDefinition = X & { type: "PropertyDefinition"; key: Expression; value: Expression | null; computed: true; static: boolean; }; export type NonComputedPropertyDefinition = X & { type: "PropertyDefinition"; key: Key; value: Expression | null; computed: false; static: boolean; }; // StaticBlock // export type StaticBlock = X & { type: "StaticBlock"; body: Statement[]; };