From 90309da6846727c66c8e3e03a5396eb6c475b712 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Wed, 21 Feb 2024 14:21:21 -0600 Subject: [PATCH] chore: use stricter function type for callback This change, which should have no user impact, improves the type for a local peer callback. This is one of the last remaining changes required to enable the [strictFunctionTypes] TypeScript compiler option. [strictFunctionTypes]: https://www.typescriptlang.org/tsconfig/#strictFunctionTypes --- src/local-peers.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/local-peers.js b/src/local-peers.js index 12cac8213..6ac14a5a3 100644 --- a/src/local-peers.js +++ b/src/local-peers.js @@ -410,7 +410,11 @@ export class LocalPeers extends TypedEmitter { for (const [type, id] of Object.entries(MESSAGE_TYPES)) { messages[id] = { encoding: cenc.raw, - onmessage: this.#handleMessage.bind(this, protomux, type), + onmessage: this.#handleMessage.bind( + this, + protomux, + /** @type {keyof typeof MESSAGE_TYPES} */ (type) + ), } }