Skip to content

Commit

Permalink
fix: update dependency typings
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed May 14, 2024
1 parent 1aeb7a8 commit 712c24c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion fixup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cat >> types/layout.d.ts <<!EOF
declare global {
namespace Express {
interface Response {
export interface Response {
podiumSend(fragment: string, ...args: unknown[]): Response;
}
}
Expand Down
25 changes: 7 additions & 18 deletions lib/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@

import {
HttpIncoming,
// @ts-ignore
template,
// @ts-ignore
isFunction,
// @ts-ignore
pathnameBuilder,
// @ts-ignore
uriIsRelative,
AssetCss,
AssetJs,
Expand Down Expand Up @@ -40,10 +36,10 @@ const pkg = JSON.parse(pkgJson);
* @typedef {Object} LayoutOptions
* @property {string} name - (required) layout name
* @property {string} pathname - (required) layout pathname
* @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)
* @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)
* @property {LayoutContext} [context] - Options to be passed on to the internal `@podium/context` constructor. See that module for details. (default null)
* @property {LayoutClientOptions} [client] - Options to be passed on to the internal `@podium/client` constructor. See that module for details. (default null)
* @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)
* @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)
*
*
* @typedef {Object} LayoutContext
Expand Down Expand Up @@ -116,7 +112,7 @@ export default class PodiumLayout {
* layout.log.fatal('fatal log to the console')
* ```
*
* @type {import('abslog').AbstractLogger}
* @type {import('abslog').ValidLogger}
*/
log;

Expand Down Expand Up @@ -147,7 +143,7 @@ export default class PodiumLayout {
* @see https://podium-lib.io/docs/layout/context
* @see https://podium-lib.io/docs/podlet/context
*
* @type {LayoutContext}
* @type {Context}
*/
context;

Expand Down Expand Up @@ -294,14 +290,12 @@ export default class PodiumLayout {

// Join metric streams
this.httpProxy.metrics.pipe(this.metrics);
// @ts-ignore
this.context.metrics.pipe(this.metrics);
this.client.metrics.pipe(this.metrics);

// Register proxy endpoints
// @ts-ignore
// @ts-expect-error Not typed yet. Coming in a future TypeScript Tuesday™
this.client.registry.on('set', (key, item) => {
// @ts-ignore
this.httpProxy.register(key, item.newVal);
});
}
Expand Down Expand Up @@ -561,7 +555,6 @@ export default class PodiumLayout {
incoming.css = [...this.cssRoute];
incoming.js = [...this.jsRoute];

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

Expand All @@ -587,7 +580,7 @@ export default class PodiumLayout {
middleware() {
return async (req, res, next) => {
const incoming = new HttpIncoming(req, res, res.locals);
// @ts-ignore
// @ts-expect-error The API here is a bit odd. You assign a string, but the `set` constructs a URL from it.
incoming.url = `${req.protocol}://${req.get('host')}${
req.originalUrl
}`;
Expand Down Expand Up @@ -660,11 +653,7 @@ export default class PodiumLayout {
#sanitize(uri, prefix = false) {
const pathname = prefix ? this.#pathname : '';
if (uri) {
// @ts-ignore
return uriIsRelative(uri)
? // @ts-ignore
pathnameBuilder(pathname, uri)
: uri;
return uriIsRelative(uri) ? pathnameBuilder(pathname, uri) : uri;
}
return uri;
}
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "tap --disable-coverage --allow-empty-coverage",
"test:snapshots": "tap --snapshot --disable-coverage --allow-empty-coverage",
"test:snapshots": "tap --snapshot --disable-coverage --allow-empty-coverage && tsc --project tsconfig.test.json",
"types": "tsc --declaration --emitDeclarationOnly && ./fixup.sh"
},
"dependencies": {
"@metrics/client": "2.5.2",
"@podium/client": "5.0.10",
"@podium/context": "5.0.4",
"@podium/proxy": "5.0.8",
"@podium/schemas": "5.0.0",
"@podium/utils": "5.0.3",
"abslog": "2.4.2",
"@podium/client": "5.0.20",
"@podium/context": "5.0.13",
"@podium/proxy": "5.0.15",
"@podium/schemas": "5.0.2",
"@podium/utils": "5.0.6",
"abslog": "2.4.4",
"ajv": "8.12.0",
"lodash.merge": "4.6.2",
"objobj": "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`tests/layout.js > TAP > Layout() - rendering using a string - with assets > must match snapshot 1`] = `
exports[`tests/layout.test.js > TAP > Layout() - rendering using a string - with assets > must match snapshot 1`] = `
<!doctype html>
<html lang="en-US">
<head>
Expand All @@ -25,6 +25,6 @@ exports[`tests/layout.js > TAP > Layout() - rendering using a string - with asse
</html>
`

exports[`tests/layout.js > TAP > Layout() - setting a custom view template > must match snapshot 1`] = `
exports[`tests/layout.test.js > TAP > Layout() - setting a custom view template > must match snapshot 1`] = `
<html><head>extra head stuff</head><body><div>should be wrapped in a doc</div></body></html>
`
3 changes: 1 addition & 2 deletions tests/layout.js → tests/layout.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-nocheck

/* eslint-disable no-param-reassign */

import tap from 'tap';
Expand Down Expand Up @@ -458,6 +456,7 @@ tap.test(
{
value: '/foo/bar',
data: {
// @ts-expect-error Testing conversion from older format
bar: 'a',
foo: 'b',
},
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"include": ["./tests/**/*.js"],
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true
}
}

0 comments on commit 712c24c

Please sign in to comment.