refactor(router): Add annotations to correct Router documentation (#38448)
The `@HostListener` functions and lifecycle hooks aren't intended to be public API but do need to appear in the `.d.ts` files or type checking will break. Adding the nodoc annotation will correctly hide this function on the docs site. Again, note that `@internal` cannot be used because the result would be that the functions then do not appear in the `.d.ts` files. This would break lifecycle hooks because the class would be seen as not implementing the interface correctly. This would also break `HostListener` because the compiled templates would attempt to call the `onClick` functions, but those would also not appear in the `d.ts` and would produce errors like "Property 'onClick' does not exist on type 'RouterLinkWithHref'". PR Close #38448
This commit is contained in:
parent
a80f654af9
commit
b769771d60
|
@ -202,6 +202,7 @@ export class RouterLink {
|
||||||
this.preserve = value;
|
this.preserve = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
onClick(): boolean {
|
onClick(): boolean {
|
||||||
const extras = {
|
const extras = {
|
||||||
|
@ -334,13 +335,16 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
|
||||||
this.preserve = value;
|
this.preserve = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngOnChanges(changes: {}): any {
|
ngOnChanges(changes: {}): any {
|
||||||
this.updateTargetUrlAndHref();
|
this.updateTargetUrlAndHref();
|
||||||
}
|
}
|
||||||
|
/** @nodoc */
|
||||||
ngOnDestroy(): any {
|
ngOnDestroy(): any {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
@HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey', '$event.shiftKey'])
|
@HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey', '$event.shiftKey'])
|
||||||
onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean {
|
onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean {
|
||||||
if (button !== 0 || ctrlKey || metaKey || shiftKey) {
|
if (button !== 0 || ctrlKey || metaKey || shiftKey) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngAfterContentInit(): void {
|
ngAfterContentInit(): void {
|
||||||
this.links.changes.subscribe(_ => this.update());
|
this.links.changes.subscribe(_ => this.update());
|
||||||
this.linksWithHrefs.changes.subscribe(_ => this.update());
|
this.linksWithHrefs.changes.subscribe(_ => this.update());
|
||||||
|
@ -115,9 +115,11 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
|
||||||
this.classes = classes.filter(c => !!c);
|
this.classes = classes.filter(c => !!c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
/** @nodoc */
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,12 @@ export class RouterOutlet implements OnDestroy, OnInit {
|
||||||
parentContexts.onChildOutletCreated(this.name, this);
|
parentContexts.onChildOutletCreated(this.name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.parentContexts.onChildOutletDestroyed(this.name);
|
this.parentContexts.onChildOutletDestroyed(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (!this.activated) {
|
if (!this.activated) {
|
||||||
// If the outlet was not instantiated at the time the route got activated we need to populate
|
// If the outlet was not instantiated at the time the route got activated we need to populate
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ export class Router {
|
||||||
this.lastSuccessfulId = -1;
|
this.lastSuccessfulId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @docsNotRequired */
|
/** @nodoc */
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ export class RouterPreloader implements OnDestroy {
|
||||||
return this.processRoutes(ngModule, this.router.config);
|
return this.processRoutes(ngModule, this.router.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.subscription) {
|
if (this.subscription) {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
|
|
@ -87,6 +87,7 @@ export class RouterScroller implements OnDestroy {
|
||||||
routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
|
routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @nodoc */
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
if (this.routerEventsSubscription) {
|
if (this.routerEventsSubscription) {
|
||||||
this.routerEventsSubscription.unsubscribe();
|
this.routerEventsSubscription.unsubscribe();
|
||||||
|
|
Loading…
Reference in New Issue