From 12d0ac2ff0c9ba6e9ee03a81e83d3dd0092b1b34 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Fri, 18 Feb 2022 13:08:44 +0300 Subject: [PATCH] Fix null property TypeScript error --- src/components/pages/NewUserPage.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/pages/NewUserPage.tsx b/src/components/pages/NewUserPage.tsx index 4e4622a561..bf1e5327c5 100644 --- a/src/components/pages/NewUserPage.tsx +++ b/src/components/pages/NewUserPage.tsx @@ -111,6 +111,14 @@ const NewUserPage: FunctionComponent = () => { userInput.Name = (page.querySelector('#txtUsername') as HTMLInputElement).value; userInput.Password = (page.querySelector('#txtPassword') as HTMLInputElement).value; window.ApiClient.createUser(userInput).then(function (user) { + if (!user.Id) { + throw new Error('Unexpected null user.Id'); + } + + if (!user.Policy) { + throw new Error('Unexpected null user.Policy'); + } + user.Policy.EnableAllFolders = (page.querySelector('.chkEnableAllFolders') as HTMLInputElement).checked; user.Policy.EnabledFolders = [];