You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How does the IDE know how to complete the suggestions at ?A? and ?B? sites?
Turns out that ?A? is a DOM event and as such there is no easy way to know what the type of $event is other than having the IDE recognize that it is a DOM event. This implies that the IDE needs to have pre-existing schema. Such schema (#3426) is something that Angular2 compiler needs to have as well so that we can properly validate weather or not a particular element can event a particular DOM event. (Examples is input element emitting a change event). The goal should be to have the event schema for DOM be declared in a way which is tool-able so that tools can take advantage of it.
Completion on ?B? is of different kind, it is an event which is fired from the component element and which does not bubble. In such a case we have to look at the directive annotation so that we can derive the type for $event for completion.
@Component({...})
class MyComponent {
@Output() open: EventEmitter<SomeType> = new EventEmitter();
@Output() open: Stream<SomeType> = ...;
}
For an IDE the resolution logic would be to check the schema and derive the type there. If not found check for the directives on the element and see if they fire such an event and what the type is.
Well, that's the question - what type should event declarations be?
Something implementing Stream<T>?
If yes, then sure - extracting the event type T is trivial.
Yes. @angular/language-service will look at the event type to determine the type of the $event. Any deficiency here should be reported as a bug against langauge-service. Closing this.
Activity
scheglov commentedon Oct 26, 2015
What type should
openhave?EventEmitter<SomeType>orStream<SomeType>or ...? What if it isMyEmitterThatAlsoImplementsStream<int, SomeType, double>?mhevery commentedon Oct 26, 2015
All of your examples implement
Stream<T>, so the analyzer would have to walk the type hierarchy and then figure out whatTis.mhevery commentedon Oct 27, 2015
This is related to: #3427
scheglov commentedon Oct 27, 2015
Well, that's the question - what type should event declarations be?
Something implementing
Stream<T>?If yes, then sure - extracting the event type
Tis trivial.mhevery commentedon Oct 27, 2015
Yes.
scheglov commentedon Oct 27, 2015
Very good.
Yes, the proposed solution works for me.
Thank you!
robwormald commentedon Nov 16, 2015
FYI, after the refactor to EventEmitter in ca3986f it's now generic.
scheglov commentedon Nov 16, 2015
Nice!
Thank you.
DzmitryShylovich commentedon Mar 11, 2017
@chuckjaz does language service cover this use case?
chuckjaz commentedon Mar 13, 2017
Yes.
@angular/language-servicewill look at the event type to determine the type of the$event. Any deficiency here should be reported as a bug againstlangauge-service. Closing this.angular-automatic-lock-bot commentedon Sep 11, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.