From fa2fe25eb6a749d1605d6aa7abd11ef4f911c9f6 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Sat, 4 Jun 2022 03:35:25 +0300 Subject: [PATCH] Update catch types to be any for TypeScript 4.4 (#1444) Due to https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables, some TypeScript files failed to compile under TS 4.4 or later. --- node_package/src/buildConsoleReplay.ts | 2 +- node_package/src/clientStartup.ts | 4 ++-- node_package/src/serverRenderReactComponent.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node_package/src/buildConsoleReplay.ts b/node_package/src/buildConsoleReplay.ts index 638b8b251..35c33c035 100644 --- a/node_package/src/buildConsoleReplay.ts +++ b/node_package/src/buildConsoleReplay.ts @@ -24,7 +24,7 @@ export function consoleReplay(): string { if (val === undefined) { val = 'undefined'; } - } catch (e) { + } catch (e: any) { val = `${e.message}: ${arg}`; } diff --git a/node_package/src/clientStartup.ts b/node_package/src/clientStartup.ts index 9914814d1..024dc9ff8 100644 --- a/node_package/src/clientStartup.ts +++ b/node_package/src/clientStartup.ts @@ -174,7 +174,7 @@ You should return a React.Component always for the client side entry point.`); reactRender(domNode, reactElementOrRouterResult as ReactElement); } } - } catch (e) { + } catch (e: any) { e.message = `ReactOnRails encountered an error while rendering component: ${name}.\n` + `Original message: ${e.message}`; throw e; @@ -214,7 +214,7 @@ function unmount(el: Element): void { if(domNode === null){return;} try { ReactDOM.unmountComponentAtNode(domNode); - } catch (e) { + } catch (e: any) { console.info(`Caught error calling unmountComponentAtNode: ${e.message} for domNode`, domNode, e); } diff --git a/node_package/src/serverRenderReactComponent.ts b/node_package/src/serverRenderReactComponent.ts index eadd7d311..5477c0d19 100644 --- a/node_package/src/serverRenderReactComponent.ts +++ b/node_package/src/serverRenderReactComponent.ts @@ -83,7 +83,7 @@ as a renderFunction and not a simple React Function Component.`); } else { renderResult = processReactElement(); } - } catch (e) { + } catch (e: any) { if (throwJsErrors) { throw e; } @@ -115,7 +115,7 @@ as a renderFunction and not a simple React Function Component.`); consoleReplayScript, hasErrors, }; - } catch (e) { + } catch (e: any) { if (throwJsErrors) { throw e; }