From 07497beb78d4711e8d0c4da83ce52ad15cc7e51d Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Tue, 22 Dec 2020 13:18:14 +0100
Subject: [PATCH 1/2] Fix some typing problems

- Using '' as default value is confusing when the function expects a number
  as parameter
- `validateRequiredValue` can take a number as well as a string as first
  parameter
---
 client/src/helpers/helpers.js    | 4 ++--
 client/src/helpers/validators.js | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js
index 0cefcfdf..58117a07 100644
--- a/client/src/helpers/helpers.js
+++ b/client/src/helpers/helpers.js
@@ -190,7 +190,7 @@ export const getIpList = (interfaces) => Object.values(interfaces)
     .reduce((acc, curr) => acc.concat(curr.ip_addresses), [])
     .sort();
 
-export const getDnsAddress = (ip, port = '') => {
+export const getDnsAddress = (ip, port = 0) => {
     const isStandardDnsPort = port === STANDARD_DNS_PORT;
     let address = ip;
 
@@ -205,7 +205,7 @@ export const getDnsAddress = (ip, port = '') => {
     return address;
 };
 
-export const getWebAddress = (ip, port = '') => {
+export const getWebAddress = (ip, port = 0) => {
     const isStandardWebPort = port === STANDARD_WEB_PORT;
     let address = `http://${ip}`;
 
diff --git a/client/src/helpers/validators.js b/client/src/helpers/validators.js
index f2fee026..2632df3f 100644
--- a/client/src/helpers/validators.js
+++ b/client/src/helpers/validators.js
@@ -16,7 +16,7 @@ import { getLastIpv4Octet, isValidAbsolutePath } from './form';
 // https://redux-form.com/8.3.0/examples/fieldlevelvalidation/
 // If the value is valid, the validation function should return undefined.
 /**
- * @param value {string}
+ * @param value {string|number}
  * @returns {undefined|string}
  */
 export const validateRequiredValue = (value) => {

From bc9be8d9eebdc8ab19607b8547d81736b32ba58c Mon Sep 17 00:00:00 2001
From: Artem Baskal <a.baskal@adguard.com>
Date: Thu, 24 Dec 2020 12:34:38 +0300
Subject: [PATCH 2/2] Update type definition

---
 client/src/helpers/helpers.js           | 10 ++++++++++
 client/src/install/Setup/AddressList.js |  7 ++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js
index 58117a07..7d44b400 100644
--- a/client/src/helpers/helpers.js
+++ b/client/src/helpers/helpers.js
@@ -190,6 +190,11 @@ export const getIpList = (interfaces) => Object.values(interfaces)
     .reduce((acc, curr) => acc.concat(curr.ip_addresses), [])
     .sort();
 
+/**
+ * @param {string} ip
+ * @param {number} [port]
+ * @returns {string}
+ */
 export const getDnsAddress = (ip, port = 0) => {
     const isStandardDnsPort = port === STANDARD_DNS_PORT;
     let address = ip;
@@ -205,6 +210,11 @@ export const getDnsAddress = (ip, port = 0) => {
     return address;
 };
 
+/**
+ * @param {string} ip
+ * @param {number} [port]
+ * @returns {string}
+ */
 export const getWebAddress = (ip, port = 0) => {
     const isStandardWebPort = port === STANDARD_WEB_PORT;
     let address = `http://${ip}`;
diff --git a/client/src/install/Setup/AddressList.js b/client/src/install/Setup/AddressList.js
index 15cf7113..ed58127c 100644
--- a/client/src/install/Setup/AddressList.js
+++ b/client/src/install/Setup/AddressList.js
@@ -41,16 +41,13 @@ const AddressList = ({
 AddressList.propTypes = {
     interfaces: PropTypes.object.isRequired,
     address: PropTypes.string.isRequired,
-    port: PropTypes.oneOfType([
-        PropTypes.string,
-        PropTypes.number,
-    ]),
+    port: PropTypes.number.isRequired,
     isDns: PropTypes.bool,
 };
 
 renderItem.propTypes = {
     ip: PropTypes.string.isRequired,
-    port: PropTypes.string.isRequired,
+    port: PropTypes.number.isRequired,
     isDns: PropTypes.bool.isRequired,
 };