ngxs-labs / emitter

:octopus: New pattern that provides the opportunity to feel free from actions
MIT License
110 stars 5 forks source link

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

Closed alexej-strelzow closed 1 month ago

alexej-strelzow commented 4 years ago

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

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 commented 4 years ago

please create github repo for reproduce

alexej-strelzow commented 4 years ago

@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 commented 4 years ago

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

            "optimization": true,
            "aot": true

I think that EmitterAction gets tree-shaken away.

alexej-strelzow commented 1 month ago

outdated -> closed