@@ -10,18 +10,20 @@ const urlFromRequest = (request) => {
10
10
} ;
11
11
12
12
/**
13
+ * @template {Record<string, unknown>} [T=Record<string, unknown>]
13
14
* @typedef {object } PodiumHttpIncoming
14
15
* @property {string } name
15
16
* @property {object } context
16
17
* @property {object } view
17
18
* @property {URL } url
18
19
* @property {Array<import('./asset-css.js').CssAsset | string> } css
19
20
* @property {Array<import('./asset-js.js').JavaScriptAsset | string> } js
20
- * @property {object } [params]
21
+ * @property {T } [params]
21
22
* @property {boolean } [development]
22
23
* @property {boolean } [proxy]
23
24
*/
24
25
26
+ /** @template {Record<string, unknown>} [T=Record<string, unknown>] */
25
27
export default class HttpIncoming {
26
28
#development;
27
29
#response;
@@ -48,15 +50,17 @@ export default class HttpIncoming {
48
50
#js;
49
51
50
52
/**
53
+ * @constructor
51
54
* @param {object } [request={}] The incoming HTTP request
52
55
* @param {object } [response={}] The HTTP response
53
- * @param {object } [params={}] Parameters such as locale. Typically res.locals.
56
+ * @param {T } [params={}] Parameters such as locale. Typically res.locals.
54
57
*
55
58
* @example
56
59
* ```js
57
60
* const incoming = new HttpIncoming(req, res, res.locals);
58
61
* ```
59
62
*/
63
+ // @ts -expect-error Not happy about the generics, but this is safe
60
64
constructor ( request = { } , response = { } , params = { } ) {
61
65
this . #development = false ;
62
66
this . #response = response ;
@@ -143,6 +147,9 @@ export default class HttpIncoming {
143
147
throw new Error ( 'Cannot set read-only property.' ) ;
144
148
}
145
149
150
+ /**
151
+ * @returns {T }
152
+ */
146
153
get params ( ) {
147
154
return this . #params;
148
155
}
@@ -201,7 +208,7 @@ export default class HttpIncoming {
201
208
}
202
209
203
210
/**
204
- * @returns {PodiumHttpIncoming }
211
+ * @returns {PodiumHttpIncoming<T> }
205
212
*/
206
213
toJSON ( ) {
207
214
return {
0 commit comments