Update Typescript to the latest version (#32063)

* 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
This commit is contained in:
Mikhail Shustov 2019-02-28 17:21:47 +01:00 committed by GitHub
parent 890d255dfa
commit 8c6b1e5908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 67 additions and 57 deletions

View file

@ -406,7 +406,7 @@
"tslint-config-prettier": "^1.15.0", "tslint-config-prettier": "^1.15.0",
"tslint-microsoft-contrib": "^6.0.0", "tslint-microsoft-contrib": "^6.0.0",
"tslint-plugin-prettier": "^2.0.0", "tslint-plugin-prettier": "^2.0.0",
"typescript": "^3.0.3", "typescript": "^3.3.3333",
"vinyl-fs": "^3.0.2", "vinyl-fs": "^3.0.2",
"xml2js": "^0.4.19", "xml2js": "^0.4.19",
"xmlbuilder": "9.0.4", "xmlbuilder": "9.0.4",

View file

@ -10,7 +10,7 @@
"kbn:bootstrap": "yarn build" "kbn:bootstrap": "yarn build"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^3.0.3" "typescript": "^3.3.3333"
}, },
"peerDependencies": { "peerDependencies": {
"joi": "^13.5.2", "joi": "^13.5.2",

View file

@ -22,10 +22,10 @@
"@babel/preset-typescript": "^7.3.3", "@babel/preset-typescript": "^7.3.3",
"@kbn/babel-preset": "1.0.0", "@kbn/babel-preset": "1.0.0",
"@kbn/dev-utils": "1.0.0", "@kbn/dev-utils": "1.0.0",
"expect.js": "0.3.1",
"del": "^3.0.0", "del": "^3.0.0",
"expect.js": "0.3.1",
"getopts": "^2.2.3", "getopts": "^2.2.3",
"supports-color": "^6.1.0", "supports-color": "^6.1.0",
"typescript": "^3.0.3" "typescript": "^3.3.3333"
} }
} }

View file

@ -25,7 +25,7 @@
"del": "^3.0.0", "del": "^3.0.0",
"getopts": "^2.2.3", "getopts": "^2.2.3",
"supports-color": "^6.1.0", "supports-color": "^6.1.0",
"typescript": "^3.0.3" "typescript": "^3.3.3333"
}, },
"dependencies": { "dependencies": {
"intl-format-cache": "^2.1.0", "intl-format-cache": "^2.1.0",

View file

@ -61,7 +61,7 @@
"strong-log-transformer": "^2.1.0", "strong-log-transformer": "^2.1.0",
"tempy": "^0.2.1", "tempy": "^0.2.1",
"ts-loader": "^5.2.2", "ts-loader": "^5.2.2",
"typescript": "^3.0.3", "typescript": "^3.3.3333",
"unlazy-loader": "^0.1.3", "unlazy-loader": "^0.1.3",
"webpack": "^4.23.1", "webpack": "^4.23.1",
"webpack-cli": "^3.1.2", "webpack-cli": "^3.1.2",

View file

@ -82,8 +82,8 @@ it('types return values to prevent mutations in typescript', async () => {
).rejects.toThrowErrorMatchingInlineSnapshot(` ).rejects.toThrowErrorMatchingInlineSnapshot(`
"Command failed: tsc --noEmit "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(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 constant or a read-only property. index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a read-only property.
" "
`); `);
}); });

View file

@ -127,12 +127,12 @@ class HeaderHelpMenuUI extends Component<Props, State> {
); );
return ( return (
// @ts-ignore repositionOnScroll doesn't exist in EuiPopover
<EuiPopover <EuiPopover
id="headerHelpMenu" id="headerHelpMenu"
button={button} button={button}
isOpen={this.state.isOpen} isOpen={this.state.isOpen}
anchorPosition="downRight" anchorPosition="downRight"
// @ts-ignore
repositionOnScroll repositionOnScroll
closePopover={this.closeMenu} closePopover={this.closeMenu}
data-test-subj="helpMenuButton" data-test-subj="helpMenuButton"

View file

@ -40,7 +40,7 @@ const mockPersistedLog = {
get: jest.fn(() => ['response:200']), get: jest.fn(() => ['response:200']),
}; };
const mockPersistedLogFactory = jest.fn(() => { const mockPersistedLogFactory = jest.fn<jest.Mocked<typeof mockPersistedLog>>(() => {
return mockPersistedLog; return mockPersistedLog;
}); });

View file

@ -60,7 +60,7 @@ function getUpdateStatus<T extends Status>(
obj: any, obj: any,
param: { vis: Vis; visData: any; uiState: PersistedState } param: { vis: Vis; visData: any; uiState: PersistedState }
): { [reqStats in T]: boolean } { ): { [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 the vis type doesn't need update status, skip all calculations
if (requiresUpdateStatus.length === 0) { if (requiresUpdateStatus.length === 0) {

View file

@ -18,8 +18,8 @@
*/ */
export interface Emitter { export interface Emitter {
on: (args: any[]) => void; on: (...args: any[]) => void;
off: (args: any[]) => void; off: (...args: any[]) => void;
addListener: Emitter['on']; addListener: Emitter['on'];
removeListener: Emitter['off']; removeListener: Emitter['off'];
} }

View file

@ -127,7 +127,7 @@
"tmp": "0.0.31", "tmp": "0.0.31",
"tree-kill": "^1.1.0", "tree-kill": "^1.1.0",
"ts-loader": "^5.2.2", "ts-loader": "^5.2.2",
"typescript": "^3.0.3", "typescript": "^3.3.3333",
"vinyl-fs": "^3.0.2", "vinyl-fs": "^3.0.2",
"xml-crypto": "^0.10.1", "xml-crypto": "^0.10.1",
"xml2js": "^0.4.19", "xml2js": "^0.4.19",

View file

@ -23,13 +23,13 @@ interface Props extends KibanaHrefArgs {
* *
* You must remember to pass in location in that case. * You must remember to pass in location in that case.
*/ */
export function UnconnectedKibanaLink({ export const UnconnectedKibanaLink: React.FunctionComponent<Props> = ({
location, location,
pathname, pathname,
hash, hash,
query, query,
...props ...props
}: Props) { }) => {
const href = getKibanaHref({ const href = getKibanaHref({
location, location,
pathname, pathname,
@ -37,7 +37,9 @@ export function UnconnectedKibanaLink({
query query
}); });
return <EuiLink {...props} href={href} />; return <EuiLink {...props} href={href} />;
} };
UnconnectedKibanaLink.displayName = 'UnconnectedKibanaLink';
const withLocation = connect( const withLocation = connect(
({ location }: { location: Location }) => ({ location }), ({ location }: { location: Location }) => ({ location }),

View file

@ -255,6 +255,7 @@ export const RangeDatePicker = injectI18n(
id="QuickSelectPopover" id="QuickSelectPopover"
button={quickSelectButton} button={quickSelectButton}
isOpen={this.state.isPopoverOpen} isOpen={this.state.isPopoverOpen}
// @ts-ignore
closePopover={this.closePopover.bind(this)} closePopover={this.closePopover.bind(this)}
anchorPosition="downLeft" anchorPosition="downLeft"
ownFocus ownFocus

View file

@ -50,6 +50,7 @@ export const withStateFromLocation = <StateInLocation extends {}>({
const stateFromLocation = mapLocationToState(location); const stateFromLocation = mapLocationToState(location);
return ( return (
// @ts-ignore
<WrappedComponent <WrappedComponent
{...otherProps} {...otherProps}
{...stateFromLocation} {...stateFromLocation}

View file

@ -65,6 +65,6 @@ type PlainActionCreator<WrappedActionCreator> = WrappedActionCreator extends ()
export const bindPlainActionCreators = <WrappedActionCreators extends ActionCreators>( export const bindPlainActionCreators = <WrappedActionCreators extends ActionCreators>(
actionCreators: WrappedActionCreators actionCreators: WrappedActionCreators
) => (dispatch: Dispatch) => ) => (dispatch: Dispatch) =>
bindActionCreators(actionCreators, dispatch) as { (bindActionCreators(actionCreators, dispatch) as unknown) as {
[P in keyof WrappedActionCreators]: PlainActionCreator<WrappedActionCreators[P]> [P in keyof WrappedActionCreators]: PlainActionCreator<WrappedActionCreators[P]>
}; };

View file

@ -196,19 +196,21 @@ export class IndexPrivilegeForm extends Component<Props, State> {
<EuiFlexGroup direction="column"> <EuiFlexGroup direction="column">
{!this.props.isReservedRole && ( {!this.props.isReservedRole && (
<EuiFlexItem> <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 // @ts-ignore
compressed={true} <EuiSwitch
checked={this.state.queryExpanded} data-test-subj={`restrictDocumentsQuery${this.props.formIndex}`}
onChange={this.toggleDocumentQuery} 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> </EuiFlexItem>
)} )}
{this.state.queryExpanded && ( {this.state.queryExpanded && (

View file

@ -106,19 +106,21 @@ class SpacesMenuUI extends Component<Props, State> {
const { intl } = this.props; const { intl } = this.props;
return ( return (
<div key="manageSpacesSearchField" className="spcMenu__searchFieldWrapper"> <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 // @ts-ignore
onSearch={this.onSearch} <EuiFieldSearch
onKeyDown={this.onSearchKeyDown} placeholder={intl.formatMessage({
onFocus={this.onSearchFocus} id: 'xpack.spaces.navControl.spacesMenu.findSpacePlaceholder',
compressed defaultMessage: 'Find a space',
/> })}
incremental={true}
// FIXME needs updated typedef
onSearch={this.onSearch}
onKeyDown={this.onSearchKeyDown}
onFocus={this.onSearchFocus}
compressed
/>
}
</div> </div>
); );
}; };

View file

@ -80,6 +80,7 @@ export class NavControlPopover extends Component<Props, State> {
} }
return ( return (
// @ts-ignore repositionOnScroll doesn't exist on EuiPopover
<EuiPopover <EuiPopover
id={'spcMenuPopover'} id={'spcMenuPopover'}
data-test-subj={`spacesNavSelector`} data-test-subj={`spacesNavSelector`}
@ -88,7 +89,6 @@ export class NavControlPopover extends Component<Props, State> {
closePopover={this.closeSpaceSelector} closePopover={this.closeSpaceSelector}
anchorPosition={this.props.anchorPosition} anchorPosition={this.props.anchorPosition}
panelPaddingSize="none" panelPaddingSize="none"
// @ts-ignore
repositionOnScroll={true} repositionOnScroll={true}
withTitle={this.props.anchorPosition.includes('down')} withTitle={this.props.anchorPosition.includes('down')}
ownFocus ownFocus

View file

@ -160,16 +160,18 @@ class SpaceSelectorUI extends Component<Props, State> {
} }
return ( return (
<EuiFlexItem className="spcSpaceSelector__searchHolder"> <EuiFlexItem className="spcSpaceSelector__searchHolder">
<EuiFieldSearch {
className="spcSpaceSelector__searchField" // @ts-ignore onSearch doesn't exist on EuiFieldSearch
placeholder={intl.formatMessage({ <EuiFieldSearch
id: 'xpack.spaces.spaceSelector.findSpacePlaceholder', className="spcSpaceSelector__searchField"
defaultMessage: 'Find a space', placeholder={intl.formatMessage({
})} id: 'xpack.spaces.spaceSelector.findSpacePlaceholder',
incremental={true} defaultMessage: 'Find a space',
// @ts-ignore })}
onSearch={this.onSearch} incremental={true}
/> onSearch={this.onSearch}
/>
}
</EuiFlexItem> </EuiFlexItem>
); );
}; };

View file

@ -23594,10 +23594,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" resolved "https://registry.yarnpkg.com/typescript-fsa/-/typescript-fsa-2.5.0.tgz#1baec01b5e8f5f34c322679d1327016e9e294faf"
integrity sha1-G67AG16PXzTDImedEycBbp4pT68= integrity sha1-G67AG16PXzTDImedEycBbp4pT68=
typescript@^3.0.3: typescript@^3.3.3333:
version "3.0.3" version "3.3.3333"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3333.tgz#171b2c5af66c59e9431199117a3bcadc66fdcfd6"
integrity sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg== integrity sha512-JjSKsAfuHBE/fB2oZ8NxtRTk5iGcg6hkYXMnZ3Wc+b2RSqejEqTaem11mHASMnFilHrax3sLK0GDzcJrekZYLw==
ua-parser-js@^0.7.18: ua-parser-js@^0.7.18:
version "0.7.18" version "0.7.18"