Skip to content

Commit be0ea39

Browse files
authored
fix: update dependency typings (#474)
1 parent 1aeb7a8 commit be0ea39

File tree

6 files changed

+28
-31
lines changed

6 files changed

+28
-31
lines changed

fixup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
cat >> types/layout.d.ts <<!EOF
55
declare global {
66
namespace Express {
7-
interface Response {
7+
export interface Response {
88
podiumSend(fragment: string, ...args: unknown[]): Response;
99
}
1010
}

lib/layout.js

+6-18
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55

66
import {
77
HttpIncoming,
8-
// @ts-ignore
98
template,
10-
// @ts-ignore
119
isFunction,
12-
// @ts-ignore
1310
pathnameBuilder,
14-
// @ts-ignore
1511
uriIsRelative,
1612
AssetCss,
1713
AssetJs,
@@ -40,10 +36,10 @@ const pkg = JSON.parse(pkgJson);
4036
* @typedef {Object} LayoutOptions
4137
* @property {string} name - (required) layout name
4238
* @property {string} pathname - (required) layout pathname
43-
* @property {Console | import('abslog').AbstractLogger} [logger] - A logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
39+
* @property {import('abslog').AbstractLoggerOptions} [logger] - A logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
4440
* @property {LayoutContext} [context] - Options to be passed on to the internal `@podium/context` constructor. See that module for details. (default null)
4541
* @property {LayoutClientOptions} [client] - Options to be passed on to the internal `@podium/client` constructor. See that module for details. (default null)
46-
* @property {import("@podium/proxy").default.PodiumProxyOptions} [proxy] - Options to be passed on to the internal `@podium/proxy` constructor. See that module for details. (default null)
42+
* @property {import('@podium/proxy').PodiumProxyOptions} [proxy] - Options to be passed on to the internal `@podium/proxy` constructor. See that module for details. (default null)
4743
*
4844
*
4945
* @typedef {Object} LayoutContext
@@ -116,7 +112,7 @@ export default class PodiumLayout {
116112
* layout.log.fatal('fatal log to the console')
117113
* ```
118114
*
119-
* @type {import('abslog').AbstractLogger}
115+
* @type {import('abslog').ValidLogger}
120116
*/
121117
log;
122118

@@ -147,7 +143,7 @@ export default class PodiumLayout {
147143
* @see https://podium-lib.io/docs/layout/context
148144
* @see https://podium-lib.io/docs/podlet/context
149145
*
150-
* @type {LayoutContext}
146+
* @type {Context}
151147
*/
152148
context;
153149

@@ -294,14 +290,11 @@ export default class PodiumLayout {
294290

295291
// Join metric streams
296292
this.httpProxy.metrics.pipe(this.metrics);
297-
// @ts-ignore
298293
this.context.metrics.pipe(this.metrics);
299294
this.client.metrics.pipe(this.metrics);
300295

301296
// Register proxy endpoints
302-
// @ts-ignore
303297
this.client.registry.on('set', (key, item) => {
304-
// @ts-ignore
305298
this.httpProxy.register(key, item.newVal);
306299
});
307300
}
@@ -561,7 +554,6 @@ export default class PodiumLayout {
561554
incoming.css = [...this.cssRoute];
562555
incoming.js = [...this.jsRoute];
563556

564-
// @ts-ignore
565557
if (context) await this.context.process(incoming);
566558
if (proxy) await this.httpProxy.process(incoming);
567559

@@ -587,7 +579,7 @@ export default class PodiumLayout {
587579
middleware() {
588580
return async (req, res, next) => {
589581
const incoming = new HttpIncoming(req, res, res.locals);
590-
// @ts-ignore
582+
// @ts-expect-error The API here is a bit odd. You assign a string, but the `set` constructs a URL from it.
591583
incoming.url = `${req.protocol}://${req.get('host')}${
592584
req.originalUrl
593585
}`;
@@ -660,11 +652,7 @@ export default class PodiumLayout {
660652
#sanitize(uri, prefix = false) {
661653
const pathname = prefix ? this.#pathname : '';
662654
if (uri) {
663-
// @ts-ignore
664-
return uriIsRelative(uri)
665-
? // @ts-ignore
666-
pathnameBuilder(pathname, uri)
667-
: uri;
655+
return uriIsRelative(uri) ? pathnameBuilder(pathname, uri) : uri;
668656
}
669657
return uri;
670658
}

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@
3232
"scripts": {
3333
"lint": "eslint .",
3434
"lint:fix": "eslint --fix .",
35-
"test": "tap --disable-coverage --allow-empty-coverage",
35+
"test": "tap --disable-coverage --allow-empty-coverage && tsc --project tsconfig.test.json",
3636
"test:snapshots": "tap --snapshot --disable-coverage --allow-empty-coverage",
3737
"types": "tsc --declaration --emitDeclarationOnly && ./fixup.sh"
3838
},
3939
"dependencies": {
4040
"@metrics/client": "2.5.2",
41-
"@podium/client": "5.0.10",
42-
"@podium/context": "5.0.4",
43-
"@podium/proxy": "5.0.8",
44-
"@podium/schemas": "5.0.0",
45-
"@podium/utils": "5.0.3",
46-
"abslog": "2.4.2",
41+
"@podium/client": "5.0.21",
42+
"@podium/context": "5.0.13",
43+
"@podium/proxy": "5.0.16",
44+
"@podium/schemas": "5.0.2",
45+
"@podium/utils": "5.0.6",
46+
"abslog": "2.4.4",
4747
"ajv": "8.12.0",
4848
"lodash.merge": "4.6.2",
4949
"objobj": "1.0.0"
5050
},
5151
"devDependencies": {
5252
"@babel/eslint-parser": "7.23.3",
53-
"@podium/podlet": "5.1.2",
53+
"@podium/podlet": "5.1.4",
5454
"@podium/test-utils": "2.5.2",
5555
"@semantic-release/changelog": "6.0.3",
5656
"@semantic-release/commit-analyzer": "11.1.0",

tap-snapshots/tests/layout.js.test.cjs tap-snapshots/tests/layout.test.js.test.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Make sure to inspect the output below. Do not ignore changes!
66
*/
77
'use strict'
8-
exports[`tests/layout.js > TAP > Layout() - rendering using a string - with assets > must match snapshot 1`] = `
8+
exports[`tests/layout.test.js > TAP > Layout() - rendering using a string - with assets > must match snapshot 1`] = `
99
<!doctype html>
1010
<html lang="en-US">
1111
<head>
@@ -25,6 +25,6 @@ exports[`tests/layout.js > TAP > Layout() - rendering using a string - with asse
2525
</html>
2626
`
2727

28-
exports[`tests/layout.js > TAP > Layout() - setting a custom view template > must match snapshot 1`] = `
28+
exports[`tests/layout.test.js > TAP > Layout() - setting a custom view template > must match snapshot 1`] = `
2929
<html><head>extra head stuff</head><body><div>should be wrapped in a doc</div></body></html>
3030
`

tests/layout.js tests/layout.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @ts-nocheck
2-
31
/* eslint-disable no-param-reassign */
42

53
import tap from 'tap';
@@ -244,6 +242,7 @@ tap.test('Layout() - metrics properly decorated', (t) => {
244242
tap.test('.css() - call method with no arguments - should throw', (t) => {
245243
const layout = new Layout(DEFAULT_OPTIONS);
246244
t.throws(() => {
245+
// @ts-expect-error Testing bad input
247246
layout.css();
248247
}, 'Value for argument variable "value", "undefined", is not valid');
249248
t.end();
@@ -458,6 +457,7 @@ tap.test(
458457
{
459458
value: '/foo/bar',
460459
data: {
460+
// @ts-expect-error Testing conversion from older format
461461
bar: 'a',
462462
foo: 'b',
463463
},

tsconfig.test.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["./tests/**/*.js"],
4+
"compilerOptions": {
5+
"module": "nodenext",
6+
"moduleResolution": "nodenext",
7+
"noEmit": true
8+
}
9+
}

0 commit comments

Comments
 (0)