Skip to content

Commit

Permalink
Bump typescript to 4.6.4 (#879) (#1055)
Browse files Browse the repository at this point in the history
* typescript bump: 4.1.6

Signed-off-by: Danila Gulderov <[email protected]>

* typescript bump: 4.2.4

Signed-off-by: Danila Gulderov <[email protected]>

* typescript bump: 4.3.5

Signed-off-by: Danila Gulderov <[email protected]>

* typescript bump: 4.4.4

Signed-off-by: Danila Gulderov <[email protected]>

* typescript bump: 4.5.5

Signed-off-by: Danila Gulderov <[email protected]>

* typescript bump: 4.6.4

Signed-off-by: Danila Gulderov <[email protected]>

* CHANGELOG.md updated

Signed-off-by: Danila Gulderov <[email protected]>

* bump typescript-eslint/eslint-plugin: 5.62.0
bump typescript-eslint/parser: 5.62.0

node 16 is required for typescript-eslint: 6.0.0

Signed-off-by: Danila Gulderov <[email protected]>

* CHANGELOG.md update

Signed-off-by: Danila Gulderov <[email protected]>

* move typescript update to regular section

Signed-off-by: Danila Gulderov <[email protected]>

* changelog message improvement

Signed-off-by: Danila Gulderov <[email protected]>

* fix typings

Signed-off-by: Danila Gulderov <[email protected]>

* cleanup useUnknownInCatchVariables

Signed-off-by: Danila Gulderov <[email protected]>

* logical or => nullish coalescing

Signed-off-by: Danila Gulderov <[email protected]>

* wrap with String

Signed-off-by: Danila Gulderov <[email protected]>

* Update CHANGELOG.md

Move CHANGELOG entry to the unreleased section

Signed-off-by: Miki <[email protected]>

* Add back `onPinClick` check in `OuiPinnableListGroup`

Update pinnable_list_group.tsx

Signed-off-by: Miki <[email protected]>

* Enhance error message extraction in `validateFieldValue`

Update default_syntax.ts

Signed-off-by: Miki <[email protected]>

* Remove e.code from default_syntax.ts

Update default_syntax.ts

Signed-off-by: Miki <[email protected]>

* Lint default_syntax.ts

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Danila Gulderov <[email protected]>
Signed-off-by: Matt Provost <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: Matt Provost <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit 1fe770c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 04eacc1 commit d2d6939
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 133 deletions.
28 changes: 14 additions & 14 deletions i18ntokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -2543,14 +2543,14 @@
"highlighting": "string",
"loc": {
"start": {
"line": 125,
"line": 124,
"column": 4,
"index": 3690
"index": 3665
},
"end": {
"line": 125,
"line": 124,
"column": 75,
"index": 3761
"index": 3736
}
},
"filepath": "src/components/header/header_links/header_links.tsx"
Expand All @@ -2561,14 +2561,14 @@
"highlighting": "string",
"loc": {
"start": {
"line": 138,
"line": 137,
"column": 4,
"index": 4083
"index": 4058
},
"end": {
"line": 138,
"line": 137,
"column": 69,
"index": 4148
"index": 4123
}
},
"filepath": "src/components/header/header_links/header_links.tsx"
Expand Down Expand Up @@ -2653,12 +2653,12 @@
"start": {
"line": 143,
"column": 4,
"index": 4714
"index": 4700
},
"end": {
"line": 148,
"column": 44,
"index": 4899
"index": 4885
}
},
"filepath": "src/components/list_group/pinnable_list_group/pinnable_list_group.tsx"
Expand All @@ -2671,12 +2671,12 @@
"start": {
"line": 143,
"column": 4,
"index": 4714
"index": 4700
},
"end": {
"line": 148,
"column": 44,
"index": 4899
"index": 4885
}
},
"filepath": "src/components/list_group/pinnable_list_group/pinnable_list_group.tsx"
Expand Down Expand Up @@ -3535,12 +3535,12 @@
"start": {
"line": 267,
"column": 12,
"index": 7947
"index": 7990
},
"end": {
"line": 270,
"column": 14,
"index": 8069
"index": 8112
}
},
"filepath": "src/components/selectable/selectable_templates/selectable_template_sitewide.tsx"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
"@types/react-router-dom": "^5.3.3",
"@types/url-parse": "^1.4.8",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"autoprefixer": "^9.8.6",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
Expand Down Expand Up @@ -245,7 +245,7 @@
"start-server-and-test": "^2.0.0",
"style-loader": "^1.2.1",
"terser-webpack-plugin": "^4.1.0",
"typescript": "4.0.5",
"typescript": "4.6.4",
"url-loader": "^4.1.0",
"webpack": "npm:@amoo-miki/[email protected]",
"webpack-cli": "^3.3.12",
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/components/guide_section/guide_section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const GuideSection: FunctionComponent<GuideSection> = ({
const isPlaygroundUnsupported =
typeof window !== 'undefined' &&
typeof document !== 'undefined' &&
!!window.MSInputMethodContext &&
!!(window as any).MSInputMethodContext &&
// @ts-ignore doesn't exist?
!!document.documentMode;

Expand Down
6 changes: 1 addition & 5 deletions src/components/datagrid/data_grid_inmemory_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ export interface OuiDataGridInMemoryRendererProps {
function noop() {}

function getElementText(element: HTMLElement) {
return 'innerText' in element
? element.innerText
: // (this line left here to satisfy Prettier since a ts-ignore is used on the next line)
// @ts-ignore TypeScript thinks element.innerText always exists, however it doesn't in jest/jsdom environment
element.textContent || undefined;
return 'innerText' in element ? element.innerText : element.textContent || '';
}

export const OuiDataGridInMemoryRenderer: FunctionComponent<OuiDataGridInMemoryRendererProps> = ({
Expand Down
7 changes: 3 additions & 4 deletions src/components/header/header_links/header_links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ export const OuiHeaderLinks: FunctionComponent<OuiHeaderLinksProps> = ({
popoverProps,
...rest
}) => {
const { onClick: _onClick, iconType = 'apps', ...popoverButtonRest } = {
...popoverButtonProps,
};
const { onClick, iconType = 'apps', ...popoverButtonRest } =
popoverButtonProps ?? {};

const [mobileMenuIsOpen, setMobileMenuIsOpen] = useState(false);

const onMenuButtonClick: MouseEventHandler<
HTMLButtonElement & HTMLAnchorElement
> = (e) => {
_onClick && _onClick(e);
onClick?.(e);
setMobileMenuIsOpen(!mobileMenuIsOpen);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const prettyHtml = cheerio.load('');
function testIcon(props: PropsOf<OuiIcon>) {
return () => {
expect.assertions(1);
return new Promise((resolve) => {
return new Promise<void>((resolve) => {
const onIconLoad = () => {
component.update();
expect(prettyHtml(component.html())).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const OuiPinnableListGroup: FunctionComponent<OuiPinnableListGroupProps>
);

// Add the pinning action unless the item has it's own extra action
if (onPinClick && !itemProps.extraAction && pinnable) {
if (pinnable && !itemProps.extraAction) {
// Different displays for pinned vs unpinned
if (pinned) {
itemProps.extraAction = {
Expand All @@ -132,8 +132,8 @@ export const OuiPinnableListGroup: FunctionComponent<OuiPinnableListGroupProps>
'aria-label': pinTitle ? pinTitle(item) : pinExtraActionLabel,
};
}
// Return the item on click
itemProps.extraAction.onClick = () => onPinClick(item);
// On click, return the item
if (onPinClick) itemProps.extraAction.onClick = () => onPinClick(item);
}

return itemProps;
Expand Down
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
10 changes: 9 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,16 @@ const validateFieldValue = (
try {
schemaField.validate(value);
} catch (e) {
// While e.message is the normal convention, it is optional. e.name is used for completeness
const message = (e instanceof Error
? e.message || e.name
: String(e)
)?.trim();

error(
`Invalid value \`${expression}\` set for field \`${field}\` - ${e.message}`,
`Invalid value \`${expression}\` set for field \`${field}\`${
message ? ` - ${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
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const OuiSelectableTemplateSitewide: FunctionComponent<OuiSelectableTempl
searchProps={{
placeholder: searchPlaceholder,
isClearable: true,
...searchProps,
...(searchProps as Omit<typeof searchProps, 'className'>),
onFocus: searchOnFocus,
onBlur: searchOnBlur,
onInput: onSearchInput,
Expand Down
10 changes: 2 additions & 8 deletions src/components/suggest/suggest_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import React, {
FunctionComponent,
HTMLAttributes,
ButtonHTMLAttributes,
MouseEventHandler,
} from 'react';
import { CommonProps, ExclusiveUnion, keysOf } from '../common';
import classNames from 'classnames';
Expand Down Expand Up @@ -77,12 +76,7 @@ interface OuiSuggestItemPropsBase {
}

type PropsForDiv = Omit<HTMLAttributes<HTMLDivElement>, 'onClick'>;
type PropsForButton = Omit<
ButtonHTMLAttributes<HTMLButtonElement>,
'onClick' | 'type'
> & {
onClick: MouseEventHandler<HTMLButtonElement> | undefined;
};
type PropsForButton = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'>;

export type OuiSuggestItemProps = CommonProps &
OuiSuggestItemPropsBase &
Expand Down Expand Up @@ -193,8 +187,8 @@ export const OuiSuggestItem: FunctionComponent<OuiSuggestItemProps> = ({
if (onClick) {
return (
<button
onClick={onClick}
className={classes}
onClick={onClick}
{...(rest as PropsForButton)}>
{innerContent}
</button>
Expand Down
Loading

0 comments on commit d2d6939

Please sign in to comment.