Skip to content

Fix generated workflow typing for composite declaration emit#28

Merged
taras merged 4 commits intomainfrom
worktree-framework-typing-fix
Mar 24, 2026
Merged

Fix generated workflow typing for composite declaration emit#28
taras merged 4 commits intomainfrom
worktree-framework-typing-fix

Conversation

@taras
Copy link
Copy Markdown
Owner

@taras taras commented Mar 23, 2026

Summary

  • @tisyn/agent: Export DeclaredAgent<Ops> named type alias so agent() return type survives declaration emit without TS2742 (referencing internal dist/types.js paths)
  • @tisyn/ir: Add TisynFn<A, R> to Call() first parameter so Call(chat) works when chat: TisynFn<[], void> — no as never cast needed. Add IrInput = TisynExpr | Expr<any> covering all typed and untyped IR roots
  • @tisyn/runtime: Widen ExecuteOptions.ir to IrInput so phantom-typed constructor results (Call(), Q(), Fn()) are accepted without casts
  • @tisyn/compiler: Codegen now emits TisynFn<[paramTypes], returnType> annotations on workflow exports and DeclaredAgent<{...}> return types on factory functions. ParsedFunction extended to capture param/return types from source AST

Test plan

  • pnpm build — all packages build clean
  • pnpm test — all 788 tests pass across 10 packages
  • Regenerate example workflow.generated.ts and verify Call(chat) without as never
  • Verify example type-checks under composite: true / declaration: true

taras added 4 commits March 23, 2026 19:30
- Add DeclaredAgent<Ops> named type to @tisyn/agent so agent() return
  type survives declaration emit without referencing internal paths
- Add TisynFn<A, R> to Call() first parameter so TisynFn values can be
  passed directly without as-never casts
- Add IrInput = TisynExpr | Expr<any> to @tisyn/ir covering all typed
  and untyped IR roots
- Widen execute() ir type to IrInput, capturing validated IR from
  assertValidIr() for downstream use
- Compiler codegen now emits TisynFn annotations on workflow exports and
  DeclaredAgent return types on factory functions
- Extend ParsedFunction with paramTypes/returnType extracted from source
  AST
- Update semantic type-check test stubs to include DeclaredAgent,
  OperationSpec, TisynFn
Replace Expr<any> (which collapses to any) with explicit TypedIrNode
union. Add expectTypeOf positive/negative tests for IrInput, declaration-
emit regression test for TS2742, and Call(workflow) consumer typing test.
The test was only calling program.getSemanticDiagnostics() which can't
catch TS2742 (an emit-time naming failure). Now runs program.emit()
when declaration options are set and combines emit diagnostics with
semantic diagnostics.
@taras taras merged commit e447f04 into main Mar 24, 2026
1 check passed
@taras taras deleted the worktree-framework-typing-fix branch March 24, 2026 00:28
taras added a commit that referenced this pull request Mar 24, 2026
- Replace Call(chat as never) with Call(chat) in all 4 files now that
  Call() accepts TisynFn<A, R> directly
- Add extractMessage() runtime narrowing helper in phase4-e2e test
  instead of raw cast on protocol args payload
@taras taras mentioned this pull request Mar 24, 2026
3 tasks
taras added a commit that referenced this pull request Mar 24, 2026
- Replace Call(chat as never) with Call(chat) in all 4 files now that
  Call() accepts TisynFn<A, R> directly
- Add extractMessage() runtime narrowing helper in phase4-e2e test
  instead of raw cast on protocol args payload
taras added a commit that referenced this pull request Mar 27, 2026
- Replace Call(chat as never) with Call(chat) in all 4 files now that
  Call() accepts TisynFn<A, R> directly
- Add extractMessage() runtime narrowing helper in phase4-e2e test
  instead of raw cast on protocol args payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant