Skip to content

Commit 056d17a

Browse files
JoostKalan-agius4
authored andcommitted
refactor(@angular/ssr): use ReadonlyMap instead of Readonly mapped type
The `Readonly` mapped type only introduces the `readonly` modifier for each property, but `Map` has mutating methods like `clear`, `delete` and `set` that would still remain usable. This commit switches those usages over to the `ReadonlyMap` type which doesn't have any of the mutating methods.
1 parent 929d483 commit 056d17a

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

goldens/public-api/angular/ssr/index.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// @public
88
export class AngularAppEngine {
9-
getHeaders(request: Request): Readonly<Map<string, string>>;
9+
getHeaders(request: Request): ReadonlyMap<string, string>;
1010
render(request: Request, requestContext?: unknown): Promise<Response | null>;
1111
static ɵhooks: Hooks;
1212
}

goldens/public-api/angular/ssr/node/index.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Type } from '@angular/core';
1212

1313
// @public
1414
export class AngularNodeAppEngine {
15-
getHeaders(request: IncomingMessage): Readonly<Map<string, string>>;
15+
getHeaders(request: IncomingMessage): ReadonlyMap<string, string>;
1616
render(request: IncomingMessage, requestContext?: unknown): Promise<Response | null>;
1717
}
1818

packages/angular/ssr/node/src/app-engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class AngularNodeAppEngine {
6666
}));
6767
* ```
6868
*/
69-
getHeaders(request: IncomingMessage): Readonly<Map<string, string>> {
69+
getHeaders(request: IncomingMessage): ReadonlyMap<string, string> {
7070
return this.angularAppEngine.getHeaders(createWebRequestFromNodeRequest(request));
7171
}
7272
}

packages/angular/ssr/src/app-engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class AngularAppEngine {
110110
* @returns A `Map` containing the HTTP headers as key-value pairs.
111111
* @note This function should be used exclusively for retrieving headers of SSG pages.
112112
*/
113-
getHeaders(request: Request): Readonly<Map<string, string>> {
113+
getHeaders(request: Request): ReadonlyMap<string, string> {
114114
if (this.manifest.staticPathsHeaders.size === 0) {
115115
return new Map();
116116
}

packages/angular/ssr/src/manifest.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface AngularAppEngineManifest {
3636
* - `key`: The base href for the entry point.
3737
* - `value`: A function that returns a promise resolving to an object of type `EntryPointExports`.
3838
*/
39-
readonly entryPoints: Readonly<Map<string, () => Promise<EntryPointExports>>>;
39+
readonly entryPoints: ReadonlyMap<string, () => Promise<EntryPointExports>>;
4040

4141
/**
4242
* The base path for the server application.
@@ -52,8 +52,9 @@ export interface AngularAppEngineManifest {
5252
* - `headerName`: The name of the HTTP header.
5353
* - `headerValue`: The value of the HTTP header.
5454
*/
55-
readonly staticPathsHeaders: Readonly<
56-
Map<string, readonly [headerName: string, headerValue: string][]>
55+
readonly staticPathsHeaders: ReadonlyMap<
56+
string,
57+
readonly [headerName: string, headerValue: string][]
5758
>;
5859
}
5960

@@ -67,7 +68,7 @@ export interface AngularAppManifest {
6768
* - `key`: The path of the asset.
6869
* - `value`: A function returning a promise that resolves to the file contents of the asset.
6970
*/
70-
readonly assets: Readonly<Map<string, () => Promise<string>>>;
71+
readonly assets: ReadonlyMap<string, () => Promise<string>>;
7172

7273
/**
7374
* The bootstrap mechanism for the server application.

0 commit comments

Comments
 (0)