Skip to content

Commit 23c4e9e

Browse files
gyaneshgouraw-oktasteaksdeveloperkunalleefreemanxyztusharpandey13
authored
Fix Typescript compilation for 4.6.3 (#896)
Duplicates PR #812 to run scans and resolve commit sign issue. --------- Signed-off-by: Frederik Prijck <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Steven Wexler <[email protected]> Co-authored-by: KunalOfficial <[email protected]> Co-authored-by: Lee Freeman <[email protected]> Co-authored-by: Tushar Pandey <[email protected]> Co-authored-by: Tushar Pandey <[email protected]> Co-authored-by: Frederik Prijck <[email protected]> Co-authored-by: Arpit Jain <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kunal Dawar <[email protected]> Co-authored-by: Subhankar Maiti <[email protected]> Co-authored-by: martinml <[email protected]> Co-authored-by: Rita Zerrizuela <[email protected]>
1 parent 81b2504 commit 23c4e9e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/utils.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ const CODE_RE = /[?&]code=[^&]+/;
44
const STATE_RE = /[?&]state=[^&]+/;
55
const ERROR_RE = /[?&]error=[^&]+/;
66

7+
interface WithError {
8+
error: string;
9+
}
10+
11+
interface WithErrorAndDescription {
12+
error: string;
13+
error_description: string;
14+
}
15+
716
export const hasAuthParams = (searchParams = window.location.search): boolean =>
817
(CODE_RE.test(searchParams) || ERROR_RE.test(searchParams)) &&
918
STATE_RE.test(searchParams);
@@ -19,15 +28,17 @@ const normalizeErrorFn =
1928
error !== null &&
2029
typeof error === 'object' &&
2130
'error' in error &&
22-
typeof error.error === 'string'
31+
typeof (error as WithError).error === 'string'
2332
) {
2433
if (
2534
'error_description' in error &&
26-
typeof error.error_description === 'string'
35+
typeof (error as WithErrorAndDescription).error_description === 'string'
2736
) {
28-
return new OAuthError(error.error, error.error_description);
37+
const e = error as WithErrorAndDescription;
38+
return new OAuthError(e.error, e.error_description);
2939
}
30-
return new OAuthError(error.error);
40+
const e = error as WithError;
41+
return new OAuthError(e.error);
3142
}
3243
return new Error(fallbackMessage);
3344
};

0 commit comments

Comments
 (0)