dart-archive/angular_analyzer_plugin

Allow subtypes of EventEmitters in @Outputs

Closed this issue · 4 comments

Currently, code such as

class MyEventEmitter<T> extends EventEmitter<T> { ... }

...
   @Output MyEventEmitter<int> intEvents;

will fail.

Per @scheglov, its possible that EventEmitter itself is already a subtype of the required type, which may be simply Stream<T>.

Note as well that we should do this right, tracking where the subtype relationship specifies the type parameters, ie

class MyIntEventEmitter extends EventEmitter<int> { ... }

If this is considerably more work then a new ticket should be made for this edge case.

Upping the importance of this for two reasons: Firstly, per some discovery showing it comes up a lot. Secondly, when this goes wrong it currently has no fallback behavior and it complains about the $event variables when it can't identify their type.

Also confirmed that Stream is the required type, not EventEmitter.

Therefore the goals are twofold:

  1. support subtypes of Stream<T> while allowing for classes to specialized Streams (ie, extends Stream<int>), and
  2. use dynamic type when the event type can't be found

Ah! That is exactly what I was hoping would exist!

PR #89 merged