Skip to content

fix: signature of cds.tx#544

Merged
daogrady merged 2 commits into
mainfrom
fix/cds.tx
Apr 28, 2026
Merged

fix: signature of cds.tx#544
daogrady merged 2 commits into
mainfrom
fix/cds.tx

Conversation

@daogrady
Copy link
Copy Markdown
Contributor

Fixes internal issue 19620

Report confirmed in REPL:

Screenshot 2026-04-27 at 14 09 21

@hyperspace-insights
Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Fix Signature of cds.tx to Properly Infer Return Type

Bug Fix

🐛 Fixed the TypeScript type signatures of cds.tx and srv.tx so that the return type of the callback function is correctly inferred and propagated as the resolved type of the returned Promise. Previously, these overloads returned Promise<unknown> or Promise<any> regardless of the callback's return type.

Changes

  • apis/services.d.ts: Updated all tx overloads in both QueryAPI and the top-level cds facade to use a generic type parameter <T>, so that tx(fn) returns Promise<T> where T is the return type of fn.
  • test/typescript/apis/project/cds-services.ts: Added type-level tests to verify that cds.tx, cds.tx with context, srv.tx, and srv.tx with context all correctly resolve to Promise<number> when the callback returns a number.
  • CHANGELOG.md: Documented the change — cds.tx(ƒ) now returns the return type of ƒ.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.33

  • Correlation ID: 1d12eac5-034a-48ba-8888-e8e5cebd4d76
  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.6-sonnet
  • Output Template: Default Template
  • File Content Strategy: Full file content
  • Summary Prompt: Default Prompt

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR correctly improves the type signatures of cds.tx overloads to propagate the callback's return type instead of the previous opaque Promise<unknown>/Promise<any>. The main issue identified is that both the QueryAPI.tx and the top-level cds.tx signatures will produce a nested Promise<Promise<R>> when async callbacks are used — using Promise<Awaited<T>> instead of Promise<T> would fix this for both sync and async callers.

PR Bot Information

Version: 1.20.33

  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.6-sonnet
  • File Content Strategy: Full file content
  • Correlation ID: 1d12eac5-034a-48ba-8888-e8e5cebd4d76

Comment thread apis/services.d.ts Outdated
Comment thread apis/services.d.ts
@daogrady daogrady changed the title Fix signature of cds.tx fix: signature of cds.tx Apr 27, 2026
@daogrady daogrady enabled auto-merge (squash) April 27, 2026 12:16
@daogrady daogrady requested a review from chgeo April 28, 2026 05:43
@daogrady daogrady merged commit 0111641 into main Apr 28, 2026
12 of 16 checks passed
@daogrady daogrady deleted the fix/cds.tx branch April 28, 2026 07:42
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.

2 participants