From d1fcc1120aecb438529644f96bae3b2cc3e2e60f Mon Sep 17 00:00:00 2001 From: Lucas Willems Date: Wed, 22 Sep 2021 10:06:06 +0200 Subject: [PATCH] Don't allow undefined in Address constructor Currently this code is allowed: ``` new Address(undefined); ``` But this code doesn't make sense and is bug-prone. I discovered several bugs in my code because I passed `undefined` to `Address` constructor. --- src/address.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/address.ts b/src/address.ts index 565900af..2d15f396 100644 --- a/src/address.ts +++ b/src/address.ts @@ -23,10 +23,7 @@ export class Address { /** * Creates an address object, given a raw string (whether a hex pubkey or a Bech32 address), a sequence of bytes, or another Address object. */ - public constructor(value?: Address | Buffer | string) { - if (!value) { - return; - } + public constructor(value: Address | Buffer | string) { if (value instanceof Address) { return Address.fromAddress(value); }