[Fixed] Can someone explain Thing<otherthing> syntax in Typescript or Angular?


I see this kind of syntax in Angular/Typescript demos:




What is going on here? What are the things on the left of the first < and what are the things inside? I’m not a complete moron here so I can see from these examples that there are variable types inside the <> and I get the concept in general of an Observable. What i’m asking here are what are the other things that could be either on the inside or on the left? ie, can i replace the word “Observable” with something else? Is there a list of those something else’s somewhere that I can look up? Can i replace “any” and “boolean” with other variable types, Is there a list of those? Also I’ve seem something like this:


What is this referring to?

I don’t even know if my question is Typescript related or Angular specific. Sorry for the vagueness here it’s just not well explained in any of the documentation I’ve been able to find.


That is a Generic type. If you have Observable<T> it means you have an Observable of type T where T can be any type, custom or otherwise. So Observable<boolean> is an Observable of booleans (a stream of boolean values). An Observable<string> is an Observable of strings (a stream of string values) and so on.

Read about Generic types here: https://www.typescriptlang.org/docs/handbook/2/generics.html

Leave a Reply

(*) Required, Your email will not be published