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

fix: more robust generic arrow handling #30

Merged
merged 2 commits into from
Jan 15, 2025
Merged

fix: more robust generic arrow handling #30

merged 2 commits into from
Jan 15, 2025

Conversation

acutmore
Copy link
Collaborator

Describe your changes

fixes #29

Given:

return<T>
(v: T) => v

We need to ensure the arrow function is still returned after erasing the type argument. This is achieved by moving the opening parentheses up:

return(
 v: T) => v

Testing performed

Additional test fixtures have been added.

fixes #29

Signed-off-by: Ashley Claymore <[email protected]>
if (node.typeParameters && node.typeParameters.length) {
moveOpenParen = isAsync(node.modifiers) && spansLines(node.typeParameters.pos, node.typeParameters.end);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For some reason when I fixed a similar bug before I only applied the fix for async arrows. The return case hadn't occurred to me at the time.

@bakkot
Copy link

bakkot commented Jan 14, 2025

Possibly worth adding test for throw and yield as well? Obviously the current implementation makes that unnecessary but hey more tests.

Signed-off-by: Ashley Claymore <[email protected]>
@acutmore acutmore merged commit 14c8181 into main Jan 15, 2025
2 checks passed
@mkubilayk mkubilayk deleted the generic-arrows branch January 15, 2025 19:39
Copy link
Contributor

@mkubilayk mkubilayk left a comment

Choose a reason for hiding this comment

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

Late to the party but looks good!

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.

incorrect output for return followed by a type with a newline
4 participants