Problems
src/Metano.Compiler.TypeScript/Transformation/TypeTransformer.cs (1894 LOC):
- Bug-shaped: `GroupTypesByFile(transpilableTypes)` invoked at line 345 (result hoisted) and again at line 360 inside the try block (assigned to `groups`). First call's result is overwritten and discarded.
- `TransformAll` is ~280 LOC orchestrating 8 phases (assembly probe, name-map clone, type-entry projection, interface-prefix strip, type-mapping context build, no-container scan, context build, parallel transform loop, post-merge of diagnostics + deps + cache write).
- `BuildTypeStatements` is a 100-LOC `if/else if` ladder dispatching on TypeKind.
- `TryEmitModuleViaIr` is 150 LOC mixing entry-point discovery + signature validation + body extraction + trailing-export rewrite.
Fix
- Delete the duplicate `GroupTypesByFile` call.
- Extract `TransformAll` phases: `BuildInitialNameMaps`, `RunPerGroupTransform`, `DrainCrossPackageMisses`, `DrainCrossPackageDependencies`. Parallel.For body becomes `TransformGroupOrReuseFromCache(int index, …)`.
- `BuildTypeStatements` → `TryEmit{Enum,Interface,Delegate,Exception,JsonContext,Module,Branded,PlainObject,Class}` chain.
- `TryEmitModuleViaIr` → `FindEntryPoint` + `ValidateEntryPointSignature` + `ExtractAndValidateEntryBody` + `EmitEntryPointBodyAsTopLevel` + `ApplyExportVarFromBody`.
Motivation
Adding any new emission shape (Stage 4 indexers landed forward-compat; Stage 5 operators is next) requires touching the same 1894-LOC file. Splitting drops navigability cliff below 600 LOC.
Behaviour-preserving refactor — golden tests under `targets/` must stay byte-identical.
Problems
src/Metano.Compiler.TypeScript/Transformation/TypeTransformer.cs(1894 LOC):Fix
Motivation
Adding any new emission shape (Stage 4 indexers landed forward-compat; Stage 5 operators is next) requires touching the same 1894-LOC file. Splitting drops navigability cliff below 600 LOC.
Behaviour-preserving refactor — golden tests under `targets/` must stay byte-identical.