import type { AnalysisContext, Node } from '@hey-api/codegen-core'; import type { py } from '../../py-compiler'; import { f } from '../utils/factories'; import type { BaseCtor, DropFirst, MixinCtor } from './types'; export interface ExprMethods extends Node { /** Accesses a property on the current expression (e.g., `this.foo`). */ attr(...args: DropFirst>): ReturnType; /** Calls the current expression (e.g., `fn(arg1, arg2)`). */ call(...args: DropFirst>): ReturnType; /** Produces a `return` statement returning the current expression. */ return(): ReturnType; /** Produces a subscript/slice expression (e.g., `expr[args]`). */ slice(...args: DropFirst>): ReturnType; } export function ExprMixin>(Base: TBase) { abstract class Expr extends Base { override analyze(ctx: AnalysisContext): void { super.analyze(ctx); } protected attr(...args: DropFirst>): ReturnType { // @ts-expect-error - fix this type return f.attr(this, ...args); } protected call(...args: DropFirst>): ReturnType { // @ts-expect-error - fix this type return f.call(this, ...args); } protected return(): ReturnType { // @ts-expect-error - fix this type return f.return(this); } protected slice(...args: DropFirst>): ReturnType { return f.slice(this, ...args); } } return Expr as unknown as MixinCtor; }