Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Typescript to the latest version #32063

Merged
merged 7 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -62,7 +62,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 @@ -126,7 +126,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,21 @@ 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} />;
}
};

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here callback is defined as private closePopover = (type: string, from?: string, to?: string) => {
but closePopover in <EuiPopover doesn't pass any arguments. tried to fix it with making all params optional

private closePopover = (type?: string, from?: string, to?: string) => {

but it leads to other errors in this file, so suppressed for now

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably author could help with this error

Type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<{}, StaticContext, any> & Pick<WrappedComponentProps, Exclude<keyof WrappedComponentProps, keyof StateInLocation | "pushStateInLocation" | "replaceStateInLocation">>> & StateInLocation & { ...; }' is not assignable to type 'IntrinsicAttributes & WrappedComponentProps & { children?: ReactNode; }'.
        Type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<{}, StaticContext, any> & Pick<WrappedComponentProps, Exclude<keyof WrappedComponentProps, keyof StateInLocation | "pushStateInLocation" | "replaceStateInLocation">>> & StateInLocation & { ...; }' is not assignable to type 'WrappedComponentProps'.

<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
Copy link
Contributor

@kobelb kobelb Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to be able to put the // @ts-ignore directly above the invalid prop, which meant if we had another invalid prop we'd get a TSC error. Moving this to on top of the EuiFieldSearch allows the entire element to be invalid. Do you know why we can't do the previous approach any longer?

Copy link
Contributor Author

@mshustov mshustov Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kobelb
unfortunately not. They has changed reporting mechanism for missing property error microsoft/TypeScript#26423

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not finding any alternatives at this point in time, but it does eliminate the targeting ignoring that we used to be able to perform, which means we really shouldn't be relying on ts-ignore in these situations. I'll open a PR to fix the type defs in EUI and get rid of these in a subsequent PR.

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 @@ -23457,10 +23457,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"
Expand Down