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

[swc-plugin-angular] Functional APIs (e.g. input()) are broken if a property is declared in the constructor #304

Open
yjaaidi opened this issue Apr 4, 2024 · 0 comments
Labels
enhancement New feature or request swc-angular

Comments

@yjaaidi
Copy link
Member

yjaaidi commented Apr 4, 2024

This doesn't work because the input is not decorated:

class MyCmp {
  title = input();
  constructor(private myService: MyService) {}
}

This happens because this is parsed by SWC as:

class MyCmp {
  title;
  private myService;
  constructor(myService) {
    this.myService = myService;
    this.title = input();
  }
}

We have to detect functional APIs in the constructor.

Meanwhile, the workaround is to use the inject() function which is the approach I'd recommend in general.

@yjaaidi yjaaidi assigned yjaaidi and unassigned yjaaidi Apr 4, 2024
@yjaaidi yjaaidi changed the title Functional APIs (e.g. input()) are broken if a property is declared in the constructor [swc-plugin-angular] Functional APIs (e.g. input()) are broken if a property is declared in the constructor Apr 4, 2024
@edbzn edbzn added enhancement New feature or request swc-angular and removed swc-plugin-angular labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request swc-angular
Projects
None yet
Development

No branches or pull requests

2 participants