'What does the "=" do in ```export class NgForOfContext<T, U extends NgIterable<T> = NgIterable<T>> {```

I was looking at the source for ngForOf in Angular and I came across this line:

export class NgForOfContext<T, U extends NgIterable<T> = NgIterable<T>> {

see: https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts#L14

I played around with the = operator and changed it to & and |. However, even with the typescript docs I couldn't figure out what the = operator actually does.

Kind Regards



Solution 1:[1]

If you don't pass anything to U, then U will fall back to NgIterable<T> as a default value.

See docs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eliya Cohen