Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: transformation removes async keyword from function declaration #24

Closed
boromisp opened this issue Sep 19, 2024 · 2 comments · Fixed by #35
Closed

bug: transformation removes async keyword from function declaration #24

boromisp opened this issue Sep 19, 2024 · 2 comments · Fixed by #35

Comments

@boromisp
Copy link

async is removed with the export:

- export async function f() {
+ function f() {
  await fetch("https://example.com");
}

export async function g() {
  await f();
}

It also removes unused positional function arguments in some cases it shouldn't.
Here is a contrived example of that:

function f(
  options: Partial<{
    fn: (url: string, unused: number, qs: string) => string;
  }>
) {
  return options.fn?.("https://example.com", 123, "q=1");
}

export function g() {
  return f({
-    fn(url, unused, qs) {
+    fn(url, qs) {
      return url + (qs.length > 0 ? `?${qs}` : "");
    },
  });
}
@kazushisan
Copy link
Contributor

@boromisp thank you! I will work on a fix!

@kazushisan kazushisan changed the title Invalid code transformations bug: transformation removes async keyword from function declaration Sep 20, 2024
@kazushisan
Copy link
Contributor

I will separate the latter issue to #28

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 a pull request may close this issue.

2 participants