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

Angular 9 (ivy) - ReferenceError: EmitterAction is not defined #466

Open
alexej-strelzow opened this issue Feb 11, 2020 · 3 comments
Open

Comments

@alexej-strelzow
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => https://github.com/ngxs/store/blob/master/CONTRIBUTING.md
[ ] Other... Please describe:

Current behavior

import { EmitterAction, Receiver } from '@ngxs-labs/emitter';

@Receiver() public static setRegistered(ctx: StateContext<MasterStateModel>, action: EmitterAction<string>) {

the EmitterAction class cannot be found at runtime when compiled with Angular 9 -> ivy.
image
No bug at compile time.

Workaround:
@Receiver() public static setRegistered(ctx: StateContext<MasterStateModel>, action: any) {

any instead of EmitterAction

Expected behavior

Should work with type EmitterAction

Minimal reproduction of the problem with instructions

  • install Angular 9 (ivy enabled by default)
  • write an emitter
  • write a receiver
  • compile (with ivy)
  • open browser
  • error

What is the motivation / use case for changing the behavior?

Environment


Libs:
- @angular/core version: X.Y.Z
- @ngxs/store version: X.Y.Z

`  "dependencies": {
...
    "@angular/compiler": "~9.0.0",
    "@angular/core": "~9.0.0",
    "@clr/angular": "^3.0.0-next.7",
    "@clr/core": "^3.0.0-next.7",
    "@clr/ui": "^3.0.0-next.7",
    "@ngxs-labs/emitter": "~2.0.0",
    "@ngxs/storage-plugin": "~3.6.2",
    "@ngxs/store": "~3.6.2",
    "@webcomponents/custom-elements": "~1.3.2",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },`

Browser:
- [ x ] Chrome (desktop) version Version 79.0.3945.130 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:
@splincode
Copy link
Member

please create github repo for reproduce

@alexej-strelzow
Copy link
Author

@splincode this occurs when I inject a service into the state, actually it is enough to add the @Injectable() decorator - necessary when services get injected (see migration guide of NGXS). So without the decorator + constructor it works.

@State<MasterStateModel>({
  name: 'master',
  defaults: {
    apps: []
  }
})
@Injectable()
export class MasterState {
  constructor(@Inject(LOGGING_SERVICE) private _logger: LoggingInterface) {
    
  }
}

@alexej-strelzow
Copy link
Author

@splincode you also MUST have the following 2 flags in angular.json:

            "optimization": true,
            "aot": true

I think that EmitterAction gets tree-shaken away.

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

No branches or pull requests

2 participants