diff --git a/src/compat.ts b/src/compat.ts index 5e9cb0de..34ec0f28 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -319,7 +319,7 @@ class Socket extends EventEmitter { } } } catch (err) { - if (!this._socket.closed && err.code !== "EBUSY") { + if (!this._socket.closed && (err as {code?: string}).code !== "EBUSY") { process.nextTick(() => this.emit("error", err)) } } @@ -340,7 +340,7 @@ class Socket extends EventEmitter { if (cb) cb() } catch (err) { if (cb) { - cb(err) + cb(err as Error) } else { this.emit("error", err) } diff --git a/src/index.ts b/src/index.ts index d38dcc74..8ba60008 100644 --- a/src/index.ts +++ b/src/index.ts @@ -290,7 +290,7 @@ function asyncIterator, U>(this: T) { try { return {value: await this.receive(), done: false} } catch (err) { - if (this.closed && err.code === "EAGAIN") { + if (this.closed && (err as {code?: string}).code === "EAGAIN") { /* Cast so we can omit 'value: undefined'. */ return {done: true} as IteratorReturnResult } else {