From 40844876eaee649f65adce3ee1ccbd2826d202ce Mon Sep 17 00:00:00 2001 From: Shuaib Hasan Akib Date: Sun, 17 Aug 2025 20:48:48 +0600 Subject: [PATCH] docs(docs-infra): mark properties as readonly if they shouldn't change (#63200) PR Close #63200 --- .../cookie-popup/cookie-popup.component.ts | 2 +- .../search-dialog/search-dialog.component.ts | 14 +++++++------- .../top-level-banner/top-level-banner.component.ts | 10 +++++----- .../viewers/docs-viewer/docs-viewer.component.ts | 4 ++-- adev/src/app/features/docs/docs.component.ts | 2 +- .../home-animation/home-animation.component.ts | 1 - .../home/components/home-editor.component.ts | 2 +- .../api-items-section.component.ts | 2 +- .../api-reference-details-page.component.ts | 4 ++-- .../api-reference-list.component.ts | 6 +++--- .../cli-reference-details-page.component.ts | 2 +- 11 files changed, 24 insertions(+), 25 deletions(-) diff --git a/adev/shared-docs/components/cookie-popup/cookie-popup.component.ts b/adev/shared-docs/components/cookie-popup/cookie-popup.component.ts index ce9b704badf..8916d5f3364 100644 --- a/adev/shared-docs/components/cookie-popup/cookie-popup.component.ts +++ b/adev/shared-docs/components/cookie-popup/cookie-popup.component.ts @@ -11,7 +11,7 @@ import {LOCAL_STORAGE} from '../../providers/index'; import {setCookieConsent} from '../../utils'; /** - * Decelare gtag as part of the window in this file as gtag is expected to already be loaded. + * Declare gtag as part of the window in this file as gtag is expected to already be loaded. */ declare const window: Window & typeof globalThis & {gtag?: Function}; diff --git a/adev/shared-docs/components/search-dialog/search-dialog.component.ts b/adev/shared-docs/components/search-dialog/search-dialog.component.ts index 62265efc15f..aa9312fe3fb 100644 --- a/adev/shared-docs/components/search-dialog/search-dialog.component.ts +++ b/adev/shared-docs/components/search-dialog/search-dialog.component.ts @@ -51,10 +51,10 @@ import {SearchHistoryComponent} from '../search-history/search-history.component styleUrls: ['./search-dialog.component.scss'], }) export class SearchDialog { - onClose = output(); - dialog = viewChild.required>('searchDialog'); - items = viewChildren(SearchItem); - textField = viewChild(TextField); + readonly onClose = output(); + readonly dialog = viewChild.required>('searchDialog'); + readonly items = viewChildren(SearchItem); + readonly textField = viewChild(TextField); readonly history = inject(SearchHistory); private readonly search = inject(Search); @@ -67,9 +67,9 @@ export class SearchDialog { this.injector, ).withWrap(); - searchQuery = this.search.searchQuery; - resultsResource = this.search.resultsResource; - searchResults = this.search.searchResults; + readonly searchQuery = this.search.searchQuery; + readonly resultsResource = this.search.resultsResource; + readonly searchResults = this.search.searchResults; // We use a FormControl instead of relying on NgModel+signal to avoid // the issue https://github.com/angular/angular/issues/13568 diff --git a/adev/shared-docs/components/top-level-banner/top-level-banner.component.ts b/adev/shared-docs/components/top-level-banner/top-level-banner.component.ts index d7ff54e6957..35209b7ea16 100644 --- a/adev/shared-docs/components/top-level-banner/top-level-banner.component.ts +++ b/adev/shared-docs/components/top-level-banner/top-level-banner.component.ts @@ -29,16 +29,16 @@ export class TopLevelBannerComponent { * separately for different events or instances. Without a unique ID, * closing one banner could inadvertently hide other banners for different events. */ - id = input.required(); + readonly id = input.required(); // Optional URL link that the banner should navigate to when clicked. - link = input(); + readonly link = input(); // Text content to be displayed in the banner. - text = input.required(); + readonly text = input.required(); // Optional expiry date. Setting the default expiry as a future date so we // don't have to deal with undefined signal values. - expiry = input(new Date('3000-01-01'), {transform: parseDate}); + readonly expiry = input(new Date('3000-01-01'), {transform: parseDate}); // Whether the user has closed the banner or the survey has expired. - hasClosed = linkedSignal(() => { + readonly hasClosed = linkedSignal(() => { const expired = Date.now() > this.expiry().getTime(); // Needs to be in a try/catch, because some browsers will diff --git a/adev/shared-docs/components/viewers/docs-viewer/docs-viewer.component.ts b/adev/shared-docs/components/viewers/docs-viewer/docs-viewer.component.ts index cf87721e51e..d11cd1e7cb4 100644 --- a/adev/shared-docs/components/viewers/docs-viewer/docs-viewer.component.ts +++ b/adev/shared-docs/components/viewers/docs-viewer/docs-viewer.component.ts @@ -61,8 +61,8 @@ export const GITHUB_CONTENT_URL = 'https://github.com/angular/angular/blob/main/ }, }) export class DocViewer { - docContent = input(); - hasToc = input(false); + readonly docContent = input(); + readonly hasToc = input(false); readonly contentLoaded = output(); private readonly destroyRef = inject(DestroyRef); diff --git a/adev/src/app/features/docs/docs.component.ts b/adev/src/app/features/docs/docs.component.ts index 182a995b11b..93678abd7ee 100644 --- a/adev/src/app/features/docs/docs.component.ts +++ b/adev/src/app/features/docs/docs.component.ts @@ -21,5 +21,5 @@ export default class DocsComponent { // In case when exists example-viewer placeholders, then ExampleViewer // components are going to be rendered. - docContent = input(); + readonly docContent = input(); } diff --git a/adev/src/app/features/home/components/home-animation/home-animation.component.ts b/adev/src/app/features/home/components/home-animation/home-animation.component.ts index 02ad98e591a..0b187c2643a 100644 --- a/adev/src/app/features/home/components/home-animation/home-animation.component.ts +++ b/adev/src/app/features/home/components/home-animation/home-animation.component.ts @@ -15,7 +15,6 @@ import { inject, Injector, input, - OnDestroy, output, signal, viewChildren, diff --git a/adev/src/app/features/home/components/home-editor.component.ts b/adev/src/app/features/home/components/home-editor.component.ts index 48972c1ce64..889229d2d96 100644 --- a/adev/src/app/features/home/components/home-editor.component.ts +++ b/adev/src/app/features/home/components/home-editor.component.ts @@ -35,7 +35,7 @@ export class CodeEditorComponent { private readonly environmentInjector = inject(EnvironmentInjector); private readonly destroyRef = inject(DestroyRef); - tutorialFiles = input.required(); + readonly tutorialFiles = input.required(); constructor() { this.loadEmbeddedEditor(); diff --git a/adev/src/app/features/references/api-items-section/api-items-section.component.ts b/adev/src/app/features/references/api-items-section/api-items-section.component.ts index 5e7ae9bed51..260dd8b323d 100644 --- a/adev/src/app/features/references/api-items-section/api-items-section.component.ts +++ b/adev/src/app/features/references/api-items-section/api-items-section.component.ts @@ -20,5 +20,5 @@ import {MatTooltipModule} from '@angular/material/tooltip'; changeDetection: ChangeDetectionStrategy.OnPush, }) export default class ApiItemsSection { - group = input.required(); + readonly group = input.required(); } diff --git a/adev/src/app/features/references/api-reference-details-page/api-reference-details-page.component.ts b/adev/src/app/features/references/api-reference-details-page/api-reference-details-page.component.ts index c56e60ae329..66c6c817a90 100644 --- a/adev/src/app/features/references/api-reference-details-page/api-reference-details-page.component.ts +++ b/adev/src/app/features/references/api-reference-details-page/api-reference-details-page.component.ts @@ -32,8 +32,8 @@ export default class ApiReferenceDetailsPage { private highlightedElement: HTMLElement | null = null; - docContent = input(); - urlFragment = toSignal(this.route.fragment); + readonly docContent = input(); + readonly urlFragment = toSignal(this.route.fragment); constructor() { effect(() => this.highlightCard()); diff --git a/adev/src/app/features/references/api-reference-list/api-reference-list.component.ts b/adev/src/app/features/references/api-reference-list/api-reference-list.component.ts index 2af6fefd1fb..136350612f3 100644 --- a/adev/src/app/features/references/api-reference-list/api-reference-list.component.ts +++ b/adev/src/app/features/references/api-reference-list/api-reference-list.component.ts @@ -65,9 +65,9 @@ export default class ApiReferenceList { private readonly injector = inject(EnvironmentInjector); // inputs - queryInput = input('', {alias: 'query'}); - typeInput = input(ALL_TYPES_KEY, {alias: 'type'}); - statusInput = input(DEFAULT_STATUS, {alias: 'status'}); + readonly queryInput = input('', {alias: 'query'}); + readonly typeInput = input(ALL_TYPES_KEY, {alias: 'type'}); + readonly statusInput = input(DEFAULT_STATUS, {alias: 'status'}); // inputs are route binded, they can reset to undefined // also we want a writable state, so we use a linked signal diff --git a/adev/src/app/features/references/cli-reference-details-page/cli-reference-details-page.component.ts b/adev/src/app/features/references/cli-reference-details-page/cli-reference-details-page.component.ts index ebbadfe7b36..d47190e7d86 100644 --- a/adev/src/app/features/references/cli-reference-details-page/cli-reference-details-page.component.ts +++ b/adev/src/app/features/references/cli-reference-details-page/cli-reference-details-page.component.ts @@ -17,5 +17,5 @@ import {DocContent, DocViewer} from '@angular/docs'; changeDetection: ChangeDetectionStrategy.OnPush, }) export default class CliReferenceDetailsPage { - docContent = input(); + readonly docContent = input(); }