diff --git a/src/components/markdown_editor/markdown_editor.tsx b/src/components/markdown_editor/markdown_editor.tsx index 3b83e14228..ebec30f822 100644 --- a/src/components/markdown_editor/markdown_editor.tsx +++ b/src/components/markdown_editor/markdown_editor.tsx @@ -260,7 +260,7 @@ export const OuiMarkdownEditor = forwardRef< const parsed = parser.processSync(value); return [parsed, null]; } catch (e) { - return [null, e]; + return [null, e as OuiMarkdownParseError]; } }, [parser, value]); diff --git a/src/components/search_bar/query/default_syntax.ts b/src/components/search_bar/query/default_syntax.ts index 354855d244..d1474eeafb 100644 --- a/src/components/search_bar/query/default_syntax.ts +++ b/src/components/search_bar/query/default_syntax.ts @@ -353,8 +353,10 @@ const validateFieldValue = ( try { schemaField.validate(value); } catch (e) { + const message = e instanceof Error ? e.message : e; + error( - `Invalid value \`${expression}\` set for field \`${field}\` - ${e.message}`, + `Invalid value \`${expression}\` set for field \`${field}\` - ${message}`, location ); } diff --git a/src/components/search_bar/search_bar.tsx b/src/components/search_bar/search_bar.tsx index 57cacc6056..f18d91ebd2 100644 --- a/src/components/search_bar/search_bar.tsx +++ b/src/components/search_bar/search_bar.tsx @@ -189,7 +189,11 @@ export class OuiSearchBar extends Component { this.notifyControllingParent({ query, queryText, error: null }); this.setState({ query, queryText, error: null }); } catch (e) { - const error: Error = { name: e.name, message: e.message }; + const error: Error = + e instanceof Error + ? { name: e.name, message: e.message } + : { name: 'Unexpected error', message: String(e) }; + this.notifyControllingParent({ query: null, queryText, error }); this.setState({ queryText, error }); } diff --git a/tsconfig.json b/tsconfig.json index 9bad02c5e7..54444a2ed5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -40,9 +40,6 @@ // Disallow inconsistently-cased references to the same file. "forceConsistentCasingInFileNames": true, - // Keep type of the variable in a catch clause as `any` - "useUnknownInCatchVariables": false, - // enables "core language features" "lib": [ // ESNext auto includes previous versions all the way back to es5