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

Strip-types handing async arrow with multi-line type parameter #9698

Closed
acutmore opened this issue Oct 31, 2024 · 1 comment · Fixed by #9704
Closed

Strip-types handing async arrow with multi-line type parameter #9698

acutmore opened this issue Oct 31, 2024 · 1 comment · Fixed by #9704
Assignees
Labels
Milestone

Comments

@acutmore
Copy link

Describe the bug

Using @swc/wasm-typescript (strip-types mode), with input that contains an async arrow function that also has a type parameter that spans multiple lines the output JavaScript includes a syntax error.

Input code

let f = async <
   T
>(v: T) => v;

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2022",
    "loose": true,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.40&code=H4sIAAAAAAAAA8tJLVFIU7BVSCyuzEtWsOFSUFAI4bLTKLNSCNFUsLVTKLPmAgD0%2BerKIwAAAA%3D%3D&config=H4sIAAAAAAAAA1WPSw7DIAxE9zkF8rqLikUXvUMPgagTUfETdqSiKHcvJEDbHZ5h%2FMbbJAS8SMNdbOVZhqgSYRpzUSh7Vu%2BiAOeIpJOJDJfuMlVrVpbwkPbTAVZpQa4pJHmVsiXAhkBYZE4rNskZb%2Bb8i9TBxYREffOgOeUXi%2F%2FAqUHBhed6mO2UWvcscIPvpw4bi8HQoydrq2n%2FALtj80kWAQAA&strip-types=

SWC Info output

N/A

Expected behavior

The output to not contain a new line after the async keyword. e.g:

let f = async ( 
    
  v   ) => v;

Actual behavior

let f = async  
    
 (v   ) => v;

Version

1.7.40

Additional context

This edge case was originally found by @seralexeev and reported on ts-blank-space which hit the same issue: bloomberg/ts-blank-space#19

@swc-bot
Copy link
Collaborator

swc-bot commented Dec 4, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Dec 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

4 participants