/** * `kern migrate class-body` — convert handler-escaped class expressions to * first-class `class` nodes. * * Detects this shape: * * const name=AudioRecorder type=(any|object|unknown) [export=true] * handler <<< * class AudioRecorder [extends X] [implements Y] { * private fd: T = init; * ... * constructor(...) { ... } * foo(...) { ... } * } * >>> * * and rewrites it to a proper: * * class name=AudioRecorder [export=true] [extends=X] [implements=Y] * field name=fd type=T private=true value={{ init }} * constructor params="..." * handler <<< ... >>> * method name=foo params="..." returns=T * handler <<< ... >>> * * This is NOT byte-equivalent: the original emits * `export const X: any = class X { ... };` (class expression bound to const) * whereas the rewrite emits * `export class X { ... }` (class declaration) * * The two are behaviourally compatible at the call sites we care about * (constructor, methods, imports) but differ in hoisting and in the * value of `typeof X`. We only migrate when the original annotation was the * throwaway `any`/`object`/`unknown` — i.e. no existing code relied on the * type of the const, because the const had no useful type to begin with. */ export interface ClassBodyHit { headerLine: number; literal: string; valueAttr: string; } export interface ClassBodyResult { hits: ClassBodyHit[]; output: string; } /** * Main entry: walk .kern source text, rewrite every * `const ... handler <<< class X {...} >>>` block to a `class` node. */ export declare function rewriteClassBodies(source: string): ClassBodyResult;