diff --git a/typescript/fixtures/broken.cell b/typescript/fixtures/broken.cell index b59f0fe..3cf51c8 100644 --- a/typescript/fixtures/broken.cell +++ b/typescript/fixtures/broken.cell @@ -1,4 +1,4 @@ cell Broken { role: "broken"; - on(Ping p) { emit Pong; } + membrane { accepts: Ping; emits: Pong; } } diff --git a/typescript/transpiler.test.ts b/typescript/transpiler.test.ts index 9f3ec76..0fa5f28 100644 --- a/typescript/transpiler.test.ts +++ b/typescript/transpiler.test.ts @@ -101,6 +101,7 @@ describe('transpiler (file-level)', () => { const result = transpileCellFile({ file: bad }); assert.equal(result.ok, false); assert.ok(result.errors.length > 0); + assert.match(result.errors[0], /^line 1, column 1: Cell 'Broken' must declare/); }); it('returns filesystem error for missing file', () => { diff --git a/typescript/transpiler.ts b/typescript/transpiler.ts index 256c45b..cb02548 100644 --- a/typescript/transpiler.ts +++ b/typescript/transpiler.ts @@ -33,6 +33,11 @@ export interface TranspileResult { signals: string[]; } +function formatDiagnostic(diagnostic: { message: string; pos?: AST.Position }): string { + if (!diagnostic.pos) return diagnostic.message; + return `line ${diagnostic.pos.line}, column ${diagnostic.pos.col}: ${diagnostic.message}`; +} + function tsType(type?: AST.TypeExpr): string { if (!type) return 'unknown'; switch (type.kind) { @@ -229,7 +234,7 @@ export function transpileCellFile(opts: TranspileFileOptions): TranspileResult { }; } - const errors = diagnostics.filter(d => d.kind === 'error').map(d => d.message); + const errors = diagnostics.filter(d => d.kind === 'error').map(formatDiagnostic); if (errors.length > 0) { return { ok: false,