Skip to content

Commit

Permalink
Update Typescript to the latest version (elastic#32063)
Browse files Browse the repository at this point in the history
* bump typescript version to 3.3.3333

* fix tests after updating TS version

* suppress type errors until they fixed appropriately

* address comments

* add type def for UnconnectedKibanaLink

* remove fix @ts-ignore

* fix snapshot test. provide displayName
  • Loading branch information
mshustov committed Feb 28, 2019
1 parent e1a2fde commit 27bbd01
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 57 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
"tslint-config-prettier": "^1.15.0",
"tslint-microsoft-contrib": "^6.0.0",
"tslint-plugin-prettier": "^2.0.0",
"typescript": "^3.0.3",
"typescript": "^3.3.3333",
"vinyl-fs": "^3.0.2",
"xml2js": "^0.4.19",
"xmlbuilder": "9.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"typescript": "^3.0.3"
"typescript": "^3.3.3333"
},
"peerDependencies": {
"joi": "^13.5.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"@babel/preset-typescript": "^7.1.0",
"@kbn/babel-preset": "1.0.0",
"@kbn/dev-utils": "1.0.0",
"expect.js": "0.3.1",
"del": "^3.0.0",
"expect.js": "0.3.1",
"getopts": "^2.2.3",
"supports-color": "^6.1.0",
"typescript": "^3.0.3"
"typescript": "^3.3.3333"
}
}
2 changes: 1 addition & 1 deletion packages/kbn-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"del": "^3.0.0",
"getopts": "^2.2.3",
"supports-color": "^6.1.0",
"typescript": "^3.0.3"
"typescript": "^3.3.3333"
},
"dependencies": {
"intl-format-cache": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"strong-log-transformer": "^2.1.0",
"tempy": "^0.2.1",
"ts-loader": "^5.2.2",
"typescript": "^3.0.3",
"typescript": "^3.3.3333",
"unlazy-loader": "^0.1.3",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2",
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/injected_metadata/deep_freeze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ it('types return values to prevent mutations in typescript', async () => {
).rejects.toThrowErrorMatchingInlineSnapshot(`
"Command failed: tsc --noEmit
index.ts(30,11): error TS2540: Cannot assign to 'baz' because it is a constant or a read-only property.
index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a constant or a read-only property.
index.ts(30,11): error TS2540: Cannot assign to 'baz' because it is a read-only property.
index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a read-only property.
"
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ class HeaderHelpMenuUI extends Component<Props, State> {
);

return (
// @ts-ignore repositionOnScroll doesn't exist in EuiPopover
<EuiPopover
id="headerHelpMenu"
button={button}
isOpen={this.state.isOpen}
anchorPosition="downRight"
// @ts-ignore
repositionOnScroll
closePopover={this.closeMenu}
data-test-subj="helpMenuButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const mockPersistedLog = {
get: jest.fn(() => ['response:200']),
};

const mockPersistedLogFactory = jest.fn(() => {
const mockPersistedLogFactory = jest.fn<jest.Mocked<typeof mockPersistedLog>>(() => {
return mockPersistedLog;
});

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/vis/update_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getUpdateStatus<T extends Status>(
obj: any,
param: { vis: Vis; visData: any; uiState: PersistedState }
): { [reqStats in T]: boolean } {
const status = {} as { [reqStats in T]: boolean };
const status = {} as { [reqStats in Status]: boolean };

// If the vis type doesn't need update status, skip all calculations
if (requiresUpdateStatus.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/utils/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

export interface Emitter {
on: (args: any[]) => void;
off: (args: any[]) => void;
on: (...args: any[]) => void;
off: (...args: any[]) => void;
addListener: Emitter['on'];
removeListener: Emitter['off'];
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"tmp": "0.0.31",
"tree-kill": "^1.1.0",
"ts-loader": "^5.2.2",
"typescript": "^3.0.3",
"typescript": "^3.3.3333",
"vinyl-fs": "^3.0.2",
"xml-crypto": "^0.10.1",
"xml2js": "^0.4.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ interface Props extends KibanaHrefArgs {
*
* You must remember to pass in location in that case.
*/
export function UnconnectedKibanaLink({
export const UnconnectedKibanaLink: React.FunctionComponent<Props> = ({
location,
pathname,
hash,
query,
...props
}: Props) {
}) => {
const href = getKibanaHref({
location,
pathname,
hash,
query
});
return <EuiLink {...props} href={href} />;
}
};

UnconnectedKibanaLink.displayName = 'UnconnectedKibanaLink';

const withLocation = connect(
({ location }: { location: Location }) => ({ location }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export const RangeDatePicker = injectI18n(
id="QuickSelectPopover"
button={quickSelectButton}
isOpen={this.state.isPopoverOpen}
// @ts-ignore
closePopover={this.closePopover.bind(this)}
anchorPosition="downLeft"
ownFocus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const withStateFromLocation = <StateInLocation extends {}>({
const stateFromLocation = mapLocationToState(location);

return (
// @ts-ignore
<WrappedComponent
{...otherProps}
{...stateFromLocation}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/public/utils/typed_redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ type PlainActionCreator<WrappedActionCreator> = WrappedActionCreator extends ()
export const bindPlainActionCreators = <WrappedActionCreators extends ActionCreators>(
actionCreators: WrappedActionCreators
) => (dispatch: Dispatch) =>
bindActionCreators(actionCreators, dispatch) as {
(bindActionCreators(actionCreators, dispatch) as unknown) as {
[P in keyof WrappedActionCreators]: PlainActionCreator<WrappedActionCreators[P]>
};
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,21 @@ export class IndexPrivilegeForm extends Component<Props, State> {
<EuiFlexGroup direction="column">
{!this.props.isReservedRole && (
<EuiFlexItem>
<EuiSwitch
data-test-subj={`restrictDocumentsQuery${this.props.formIndex}`}
label={
<FormattedMessage
id="xpack.security.management.editRoles.indexPrivilegeForm.grantReadPrivilegesLabel"
defaultMessage="Grant read privileges to specific documents"
/>
}
{
// @ts-ignore
compressed={true}
checked={this.state.queryExpanded}
onChange={this.toggleDocumentQuery}
/>
<EuiSwitch
data-test-subj={`restrictDocumentsQuery${this.props.formIndex}`}
label={
<FormattedMessage
id="xpack.security.management.editRoles.indexPrivilegeForm.grantReadPrivilegesLabel"
defaultMessage="Grant read privileges to specific documents"
/>
}
compressed={true}
checked={this.state.queryExpanded}
onChange={this.toggleDocumentQuery}
/>
}
</EuiFlexItem>
)}
{this.state.queryExpanded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,21 @@ class SpacesMenuUI extends Component<Props, State> {
const { intl } = this.props;
return (
<div key="manageSpacesSearchField" className="spcMenu__searchFieldWrapper">
<EuiFieldSearch
placeholder={intl.formatMessage({
id: 'xpack.spaces.navControl.spacesMenu.findSpacePlaceholder',
defaultMessage: 'Find a space',
})}
incremental={true}
// FIXME needs updated typedef
{
// @ts-ignore
onSearch={this.onSearch}
onKeyDown={this.onSearchKeyDown}
onFocus={this.onSearchFocus}
compressed
/>
<EuiFieldSearch
placeholder={intl.formatMessage({
id: 'xpack.spaces.navControl.spacesMenu.findSpacePlaceholder',
defaultMessage: 'Find a space',
})}
incremental={true}
// FIXME needs updated typedef
onSearch={this.onSearch}
onKeyDown={this.onSearchKeyDown}
onFocus={this.onSearchFocus}
compressed
/>
}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class NavControlPopover extends Component<Props, State> {
}

return (
// @ts-ignore repositionOnScroll doesn't exist on EuiPopover
<EuiPopover
id={'spcMenuPopover'}
data-test-subj={`spacesNavSelector`}
Expand All @@ -88,7 +89,6 @@ export class NavControlPopover extends Component<Props, State> {
closePopover={this.closeSpaceSelector}
anchorPosition={this.props.anchorPosition}
panelPaddingSize="none"
// @ts-ignore
repositionOnScroll={true}
withTitle={this.props.anchorPosition.includes('down')}
ownFocus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,18 @@ class SpaceSelectorUI extends Component<Props, State> {
}
return (
<EuiFlexItem className="spcSpaceSelector__searchHolder">
<EuiFieldSearch
className="spcSpaceSelector__searchField"
placeholder={intl.formatMessage({
id: 'xpack.spaces.spaceSelector.findSpacePlaceholder',
defaultMessage: 'Find a space',
})}
incremental={true}
// @ts-ignore
onSearch={this.onSearch}
/>
{
// @ts-ignore onSearch doesn't exist on EuiFieldSearch
<EuiFieldSearch
className="spcSpaceSelector__searchField"
placeholder={intl.formatMessage({
id: 'xpack.spaces.spaceSelector.findSpacePlaceholder',
defaultMessage: 'Find a space',
})}
incremental={true}
onSearch={this.onSearch}
/>
}
</EuiFlexItem>
);
};
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22113,10 +22113,10 @@ typescript-fsa@^2.0.0, typescript-fsa@^2.5.0:
resolved "https://registry.yarnpkg.com/typescript-fsa/-/typescript-fsa-2.5.0.tgz#1baec01b5e8f5f34c322679d1327016e9e294faf"
integrity sha1-G67AG16PXzTDImedEycBbp4pT68=

typescript@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8"
integrity sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==
typescript@^3.3.3333:
version "3.3.3333"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3333.tgz#171b2c5af66c59e9431199117a3bcadc66fdcfd6"
integrity sha512-JjSKsAfuHBE/fB2oZ8NxtRTk5iGcg6hkYXMnZ3Wc+b2RSqejEqTaem11mHASMnFilHrax3sLK0GDzcJrekZYLw==

ua-parser-js@^0.7.18, ua-parser-js@^0.7.9:
version "0.7.18"
Expand Down

0 comments on commit 27bbd01

Please sign in to comment.