Follow-up fix after #4665 (#4666)

* Fix a small nit

* Correct a newly discovered type issue
This commit is contained in:
MOZGIII
2022-03-18 17:09:41 +02:00
committed by GitHub
parent 8a7fee5903
commit 9c2ed6297a
+4 -2
View File
@@ -7,7 +7,7 @@ import { RpcErrorInterface } from '../types';
const UNKNOWN = -99999;
function extend<Data, K extends keyof RpcError<Data>> (that: RpcError<Data>, name: K, value?: RpcError<Data>[K]): void {
function extend<Data, K extends keyof RpcError<Data>> (that: RpcError<Data>, name: K, value: RpcError<Data>[K]): void {
Object.defineProperty(that, name, {
configurable: true,
enumerable: false,
@@ -51,7 +51,9 @@ export default class RpcError<Data = never> extends Error implements RpcErrorInt
if (isFunction(Error.captureStackTrace)) {
Error.captureStackTrace(this, this.constructor);
} else {
extend(this, 'stack', (new Error(message)).stack);
const { stack } = new Error(message);
stack && extend(this, 'stack', stack);
}
}