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

Request of @babel/parser: allow return void of set accessor #16593

Closed
1 task
finscn opened this issue Jun 27, 2024 · 2 comments
Closed
1 task

Request of @babel/parser: allow return void of set accessor #16593

finscn opened this issue Jun 27, 2024 · 2 comments

Comments

@finscn
Copy link

finscn commented Jun 27, 2024

💻

  • Would you like to work on this feature?

What problem are you trying to solve?

when I parse the code :

set foo (value: number): void

babel tell me :
SyntaxError: A 'set' accessor cannot have a return type annotation.

But I think the void should be allowed

Describe the solution you'd like

allow return void of set accessor

Describe alternatives you've considered

none

Documentation, Adoption, Migration Strategy

No response

@babel-bot
Copy link
Collaborator

Hey @finscn! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@JLHwung
Copy link
Contributor

JLHwung commented Jun 27, 2024

For the following case, TypeScript 5.5.3 throws "A 'set' accessor cannot have a return type annotation." as well (playground).

interface Foo {
  set foo (value: number): void
}

If you strongly believe that a setter should allow return type as void, please open a feature request to the TypeScript repo.

@JLHwung JLHwung closed this as completed Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants