Home > Software engineering >  What does the "=" do in ```export class NgForOfContext<T, U extends NgIterable<T>
What does the "=" do in ```export class NgForOfContext<T, U extends NgIterable<T>

Time:04-21

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

CodePudding user response:

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

See docs

  • Related