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-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",

View file

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

View file

@ -22,10 +22,10 @@
"@babel/preset-typescript": "^7.3.3",
"@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"
}
}

View file

@ -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",

View file

@ -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",

View file

@ -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.
"
`);
});

View file

@ -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"

View file

@ -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;
});

View file

@ -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) {

View file

@ -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'];
}

View file

@ -127,7 +127,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",

View file

@ -23,13 +23,13 @@ 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,
@ -37,7 +37,9 @@ export function UnconnectedKibanaLink({
query
});
return <EuiLink {...props} href={href} />;
}
};
UnconnectedKibanaLink.displayName = 'UnconnectedKibanaLink';
const withLocation = connect(
({ location }: { location: Location }) => ({ location }),

View file

@ -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

View file

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

View file

@ -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]>
};

View file

@ -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 && (

View file

@ -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>
);
};

View file

@ -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`}
@ -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

View file

@ -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>
);
};

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"
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:
version "0.7.18"