Skip to content

Commit

Permalink
cleanup useUnknownInCatchVariables
Browse files Browse the repository at this point in the history
Signed-off-by: Danila Gulderov <[email protected]>
  • Loading branch information
gulderov committed Jul 18, 2023
1 parent 8fba865 commit df82abe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/markdown_editor/markdown_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 3 additions & 1 deletion src/components/search_bar/query/default_syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ export class OuiSearchBar extends Component<OuiSearchBarProps, State> {
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 });
}
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df82abe

Please sign in to comment.