Typescript syntax for a function that returns an observable or multiple type

I have a function that returns observables from all widgets. There are two types of widgets. Here is what I tried and the IDE does not complain, but my compiler does:

public getAllWidgets(): Observable<WidgetType1 | WidgetType2> { ... } 
+1
source share
1 answer

Observed <(WidgetType1 | WidgetType2) []>

An array was returned. The error was unclear.

+1
source

Source: https://habr.com/ru/post/1258754/


All Articles