Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 16, 2025

This PR adds a new deAsyncify method to TypeScript functions, function types, and function calls, which is the opposite of the existing asyncify method.

Changes

  • Added deAsyncify() method to TSFunction that:

    • Removes the 'async' keyword from function declarations
    • Unwraps return types from Promise<T> to just T
  • Added deAsyncify() method to TSFunctionType that:

    • Unwraps return types from Promise<T> to just T
  • Added deAsyncify() method to FunctionCall that:

    • Removes 'await' keywords from function calls
    • Handles parenthesized await expressions

Usage

// Before
async function getData(): Promise<string> {
  const result = await fetchData();
  return result;
}

// After deAsyncify()
function getData(): string {
  const result = fetchData();
  return result;
}

This PR addresses the request to create a function that makes async TypeScript functions non-async, similar to how the asyncify function works but in reverse.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@tkfoss tkfoss deleted the gen/83fffe6a-5d06-4b5f-8b21-bfbd1fc903b3 branch March 19, 2025 21:50
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.

3 participants