In this code, can someone explain the rule of thumb for, why/when there is a need for, what I believe is called, expression wrapping within Typescript?
i.e. the '(' ')' in <[Parent, (Children[])]>.
If I defined a tuple type for example and used that in the resolve implements/method signature of the main code, would you still need the '(' ')' wrapped around the array of Children?
Are there other scenarios in Typescript/Angular where 'expression wrapping' occurs too?
- Is the specific to Angular? For example the '?' type safe navigator I found out about is an Angular embellishment to Typescript, not yet part of the language. See here and here and here.
type parentChildTuple = [Parent, Children[] ]
- versus
type parentChildTuple = [Parent, (Children[]) ]
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
@Injectable()
export class DataComponentResolver implements Resolve<[Parent, (Children[])]> {
constructor() {
}
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<[Parent, (Children[])]> {
}
}
'?' type safe navigator
is not there for angular nor typescript. Everything in typescript will be there in Angular and vice versa.