feat: transpile non-async Promise-returning methods with native async types#54
Merged
Merged
Conversation
… types Methods declared without 'async' but returning Promise<T> (e.g. pure WS delegators in ccxt pro) were previously transpiled with raw Promise<T> return types in C#/Java/Go, producing uncompilable output. Now they are detected via the declared return type and emitted with the same wrapped signatures as async methods: - C#: async Task / async Task<object> (+ awaited return expressions) - Java: CompletableFuture<T> with the async wrapper - Go: <-chan with the channel wrapper Sync methods without a Promise return type are unaffected.
carlotestor
force-pushed
the
non-async-promise-delegators
branch
from
July 9, 2026 10:08
dee655c to
232cabf
Compare
Author
|
✅ All tests passing on the latest commit ( This includes the 133 tests across the C#, Java and Go transpiler suites that specifically exercise the new non-async Promise-returning delegator handling — each one asserts the transpiled output is byte-identical to what the classic Also verified end-to-end against ccxt: transpiling all pro exchange files with this branch produces output identical to master + the current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In ccxt pro, pure WS delegator methods in
ts/src/pro/*.tsare declared withoutasyncbut returnPromise<T>directly, e.g.:Because the transpiler only keys async behaviour off the
asyncmodifier, these methods currently transpile to uncompilable output in C#/Java/Go (rawPromise<T>return types / missing wrappers), which forces ccxt to carry a workaround that rewrites the sources to addasyncbefore transpiling (see ccxt#29122).Changes
baseTranspilernow detects methods whose declared return type isPromise<T>even when theasyncmodifier is absent, and the language transpilers emit the same wrapped signatures as for async methods:async Task/async Task<object>, with returned Promise expressions awaitedCompletableFuture<T>with the existing async wrapper<-chanwith the existing channel wrapperSync methods without a Promise return type are unaffected.
Testing
tests/csharpTranspiler.test.ts,tests/goTranspiler.test.ts,tests/javaTranspiler.test.tscovering non-async Promise-returning delegators (single-line and multi-line bodies), verifying output is byte-identical to the equivalentasyncdeclarationnpm run testpasses overallbuild/reAsyncDelegators.tsworkaround — generated C#/Java/Go files are byte-identical, so the ccxt-side workaround can be deleteddist/was intentionally left untouched (following recent PRs where generated files are updated separately).