diff --git a/compiler/src/generators/typescript-state-machine.ts b/compiler/src/generators/typescript-state-machine.ts index 78ac8ae..f080866 100644 --- a/compiler/src/generators/typescript-state-machine.ts +++ b/compiler/src/generators/typescript-state-machine.ts @@ -474,6 +474,10 @@ function rewriteExpr(expr: string, stateVarNames: Set, mapVarNames: Set< return `new Set([...${collection}].filter(x => x !== ${key}))`; }); + // 5d1: not -> ! (negation operator) + // "not isOn" -> "!this.isOn" (will be prefixed by step 3) + ts = ts.replace(/\bnot\s+/g, '!'); + // 5e: Clean up trailing empty comparisons (===) — expression has no RHS after old() removal // "accounts[t.from].debits_posted ===" -> "accounts[t.from].debits_posted === accounts[t.from].debits_posted" ts = ts.replace(/(\S+)\s*===\s*$/g, '$1 === $1'); @@ -550,8 +554,8 @@ function tsType(t: any, speckName: string = '', enumMap?: Map) if (!t) return 'unknown'; if (t.type === 'primitive') { const map: Record = { - Nat: 'number', Int: 'number', Real: 'number', - Bool: 'boolean', String: 'string', Bytes: 'Uint8Array' + Nat: 'number', Int: 'number', Integer: 'number', Real: 'number', + Bool: 'boolean', Boolean: 'boolean', String: 'string', Bytes: 'Uint8Array' }; return map[t.name] || t.name.toLowerCase(); }