Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

crashHandler to ts, fix ts config and eslint config

kruzhambus7a4a2aa4f991
diff --git a/package.json b/package.json
index 86da8f11b..a26c32b9e 100644
--- a/package.json
+++ b/package.json
@@ -75,6 +75,16 @@
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/prefer-default-export": "off",
+ "import/extensions": [
+ "error",
+ "ignorePackages",
+ {
+ "js": "never",
+ "jsx": "never",
+ "ts": "never",
+ "tsx": "never"
+ }
+ ],
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/control-has-associated-label": "off",
"jsx-a11y/label-has-for": "off",
diff --git a/src/pages/CrashHandler/index.js b/src/pages/CrashHandler/index.tsx
similarity index 88%
rename from src/pages/CrashHandler/index.js
rename to src/pages/CrashHandler/index.tsx
index 5d4375ced..d3b161715 100644
--- a/src/pages/CrashHandler/index.js
+++ b/src/pages/CrashHandler/index.tsx
@@ -3,8 +3,19 @@ import _toString from 'lodash/toString'
import { ExclamationTriangleIcon, ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'
import { CONTACT_EMAIL } from 'redux/constants'
-class CrashHandler extends React.Component {
- constructor(props) {
+interface CrashHandlerProps {
+ children: React.ReactNode
+}
+
+interface CrashHandlerState {
+ appCrashed: boolean
+ crashStack: string
+ errorMessage: string
+ crashStackShown: boolean
+}
+
+class CrashHandler extends React.Component<CrashHandlerProps, CrashHandlerState> {
+ constructor(props: CrashHandlerProps) {
super(props)
this.state = {
appCrashed: false,
@@ -14,7 +25,7 @@ class CrashHandler extends React.Component {
}
}
- static getDerivedStateFromError(error) {
+ static getDerivedStateFromError(error: Error) {
return {
errorMessage: _toString(error),
crashStack: error?.stack,
@@ -24,6 +35,7 @@ class CrashHandler extends React.Component {
onCrashStackClick = () => {
this.setState((prevState) => ({
+ // @ts-ignore
crashStackShown: !prevState.crashStackShown,
}))
}
diff --git a/tsconfig.json b/tsconfig.json
index 217007fa7..19800c92c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,24 @@
{
"compilerOptions": {
+ "target": "ESNext",
+ "useDefineForClassFields": true,
+ "lib": [
+ "DOM",
+ "DOM.Iterable",
+ "ESNext"
+ ],
+ "allowSyntheticDefaultImports": true,
+ "module": "ESNext",
+ "moduleResolution": "Node",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "paths": {
+ "~/*": [
+ "./*"
+ ]
+ },
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
@@ -10,10 +29,8 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
- /* Language and Environment */
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
- "jsx": "react", /* Specify what JSX code is generated. */
+ /* Language and Environment */ /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
+ // "lib": [], /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
@@ -25,7 +42,6 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
- "module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "src", /* Specify the base directory to resolve non-relative module names. */