Skip to content

Commit a3938d5

Browse files
MeAkibthePunderWoman
authored andcommitted
docs(docs-infra): makes signal readonly (angular#63449)
PR Close angular#63449
1 parent 1199756 commit a3938d5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

adev/shared-docs/services/navigation-state.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class NavigationState {
119119
/**
120120
* return the actual navigation items, that is to say the one that match the current level
121121
*/
122-
private actualExpandedItems() {
122+
private actualExpandedItems(): NavigationItem[] {
123123
return this.expandedItems().slice(0, this.level());
124124
}
125125

adev/shared-docs/services/search-history.service.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ export class SearchHistory {
2929
private readonly localStorage = inject(LOCAL_STORAGE);
3030
private readonly history = signal<Map<string, HistoryItem>>(new Map());
3131

32-
private allItems = computed(() =>
32+
private readonly allItems = computed(() =>
3333
Array.from(this.history().values()).sort((a, b) => b.createdAt - a.createdAt),
3434
);
3535

36-
items = computed<{recent: HistoryItem[]; favorite: HistoryItem[]}>(() => ({
36+
readonly items = computed<{recent: HistoryItem[]; favorite: HistoryItem[]}>(() => ({
3737
recent: this.allItems().filter((v) => !v.isFavorite),
3838
favorite: this.allItems().filter((v) => v.isFavorite),
3939
}));
4040

41-
hasItems = computed(() => this.allItems().length > 0);
41+
readonly hasItems = computed(() => this.allItems().length > 0);
4242

4343
constructor() {
4444
this.loadHistory();
4545
}
4646

47-
addItem(item: SearchResultItem | HistoryItem) {
47+
addItem(item: SearchResultItem | HistoryItem): void {
4848
this.updateHistory((map) => {
4949
const labelHtml = (item.labelHtml || '').replace(/<\/?mark>/g, '');
5050

@@ -64,13 +64,13 @@ export class SearchHistory {
6464
});
6565
}
6666

67-
removeItem(item: SearchResultItem | HistoryItem) {
67+
removeItem(item: SearchResultItem | HistoryItem): void {
6868
this.updateHistory((map) => {
6969
map.delete(item.id);
7070
});
7171
}
7272

73-
makeFavorite(item: SearchResultItem | HistoryItem) {
73+
makeFavorite(item: SearchResultItem | HistoryItem): void {
7474
this.updateHistory((map) => {
7575
const updated = map.get(item.id);
7676
if (updated) {
@@ -83,7 +83,7 @@ export class SearchHistory {
8383
});
8484
}
8585

86-
private loadHistory() {
86+
private loadHistory(): void {
8787
let parsedData: HistoryItem[];
8888

8989
try {
@@ -100,7 +100,7 @@ export class SearchHistory {
100100
this.history.set(history);
101101
}
102102

103-
private updateHistory(updateFn: (map: Map<string, HistoryItem>) => void) {
103+
private updateHistory(updateFn: (map: Map<string, HistoryItem>) => void): void {
104104
const history = new Map(this.history());
105105
updateFn(history);
106106
this.history.set(history);

adev/shared-docs/services/search.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class Search {
4848
private readonly config = inject(ENVIRONMENT);
4949
private readonly client = inject(ALGOLIA_CLIENT);
5050

51-
resultsResource = resource({
51+
readonly resultsResource = resource({
5252
params: () => this.searchQuery() || undefined, // coerces empty string to undefined
5353
loader: async ({params: query, abortSignal}) => {
5454
// Until we have a better alternative we debounce by awaiting for a short delay.
@@ -97,7 +97,7 @@ export class Search {
9797
},
9898
});
9999

100-
searchResults = linkedSignal<SearchResultItem[] | undefined, SearchResultItem[]>({
100+
readonly searchResults = linkedSignal<SearchResultItem[] | undefined, SearchResultItem[]>({
101101
source: this.resultsResource.value,
102102
computation: (next, prev) => (!next && this.searchQuery() ? prev?.value : next) ?? [],
103103
});
@@ -219,7 +219,7 @@ function matched(snippet: SnippetResult | undefined): boolean {
219219
/**
220220
* Temporary helper to implement the debounce functionality on the search resource
221221
*/
222-
function wait(ms: number, signal: AbortSignal) {
222+
function wait(ms: number, signal: AbortSignal): Promise<void> {
223223
return new Promise<void>((resolve, reject) => {
224224
const timeout = setTimeout(() => resolve(), ms);
225225

0 commit comments

Comments
 (0)