SubscribeWithPriority unsubscription in app.component.ts

The thing is I found a way to unsubscribe a normal subscription in NgOnDestroy but it is not working with subscribeWithPriority.

this.platform.backButton
.pipe(takeUntil(this.ngDestroyed$))
.subscribeWithPriority(0, async () => {}

It returns an error:
Property 'subscribeWithPriority' does not exist on type 'Observable<BackButtonEventDetail>'

I think this is one of those (hopefully) rare cases where your best option is to pull rank on the type system with a type assertion:

(this.platform.backButton.pipe(takeUntil(this.ngDestroyed$)) as BackButtonEmitter)
   .subscribeWithPriority(0, () => {});

The pipe call unfortunately “washes” the more specific type of backButton (which contains the method you want) down to an Observable (which doesn’t, hence your error).