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 to TypeScript v3.8-rc #57774

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/bfetch_explorer/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion examples/demo_search/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion examples/embeddable_examples/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion examples/embeddable_explorer/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion examples/search_explorer/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion examples/state_containers_examples/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -83,7 +83,7 @@
"**/@types/hapi": "^17.0.18",
"**/@types/angular": "^1.6.56",
"**/@types/hoist-non-react-statics": "^3.3.1",
"**/typescript": "3.7.2",
"**/typescript": "3.8.1-rc",
"**/graphql-toolkit/lodash": "^4.17.13",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-git/**/base64-js": "^1.2.1",
Expand Down Expand Up @@ -479,7 +479,7 @@
"supertest": "^3.1.0",
"supertest-as-promised": "^4.0.2",
"tree-kill": "^1.2.2",
"typescript": "3.7.2",
"typescript": "3.8.1-rc",
"typings-tester": "^0.3.2",
"vinyl-fs": "^3.0.3",
"xml2js": "^0.4.22",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-analytics/package.json
Expand Up @@ -17,6 +17,6 @@
"@babel/cli": "^7.5.5",
"@kbn/dev-utils": "1.0.0",
"@kbn/babel-preset": "1.0.0",
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
4 changes: 4 additions & 0 deletions packages/kbn-babel-preset/common_preset.js
Expand Up @@ -28,6 +28,10 @@ const plugins = [
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),

// Proposal is on stage 4 (https://github.com/tc39/proposal-export-ns-from)
// Need this since we are using TypeScript 3.8+
require.resolve('@babel/plugin-proposal-export-namespace-from'),

// Optional Chaining proposal is stage 3 (https://github.com/tc39/proposal-optional-chaining)
// Need this since we are using TypeScript 3.7+
require.resolve('@babel/plugin-proposal-optional-chaining'),
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-babel-preset/package.json
Expand Up @@ -5,6 +5,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.1",
"@babel/plugin-proposal-export-namespace-from": "^7.8.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/package.json
Expand Up @@ -10,7 +10,7 @@
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
},
"peerDependencies": {
"joi": "^13.5.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/package.json
Expand Up @@ -22,7 +22,7 @@
"tslib": "^1.9.3"
},
"devDependencies": {
"typescript": "3.7.2",
"typescript": "3.8.1-rc",
"@kbn/expect": "1.0.0",
"chance": "1.0.18"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-i18n/package.json
Expand Up @@ -21,7 +21,7 @@
"del": "^5.1.0",
"getopts": "^2.2.4",
"supports-color": "^7.0.0",
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
},
"dependencies": {
"intl-format-cache": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/package.json
Expand Up @@ -61,7 +61,7 @@
"strip-ansi": "^4.0.0",
"strong-log-transformer": "^2.1.0",
"tempy": "^0.3.0",
"typescript": "3.7.2",
"typescript": "3.8.1-rc",
"unlazy-loader": "^0.1.3",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
Expand Down
6 changes: 2 additions & 4 deletions src/core/index.ts
Expand Up @@ -16,7 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
import * as Public from './public';
import * as Server from './server';

export { Public, Server };
export * as Public from './public';
export * as Server from './server';
2 changes: 1 addition & 1 deletion src/core/public/chrome/ui/header/header_badge.tsx
Expand Up @@ -66,7 +66,7 @@ export class HeaderBadge extends Component<Props, State> {
<div className="chrHeaderBadge__wrapper">
<EuiBetaBadge
data-test-subj="headerBadge"
data-test-badge-label={this.state.badge.text}
data-test-badge-label={(this.state.badge.text as unknown) as undefined}
mshustov marked this conversation as resolved.
Show resolved Hide resolved
tabIndex={0}
label={this.state.badge.text}
tooltipContent={this.state.badge.tooltip}
Expand Down
1 change: 1 addition & 0 deletions src/dev/i18n/extractors/code.js
Expand Up @@ -76,6 +76,7 @@ export function* extractCodeMessages(buffer, reporter) {
'dynamicImport',
'nullishCoalescingOperator',
'optionalChaining',
'exportNamespaceFrom',
],
});
} catch (error) {
Expand Down
Expand Up @@ -38,7 +38,7 @@ import { migratePanelsTo730 } from '../../migrations/migrate_to_730_panels';
* Once we hit a major version, we can remove support for older style URLs and get rid of this logic.
*/
export function migrateAppState(
appState: { [key: string]: unknown } & DashboardAppState,
appState: { [key: string]: any } & DashboardAppState,
kibanaVersion: string
): DashboardAppState {
if (!appState.panels) {
Expand Down
Expand Up @@ -61,7 +61,7 @@ describe('metric_vis - createMetricVisTypeDefinition', () => {
// @ts-ignore
vis = new visualizationsStart.Vis(stubIndexPattern, {
type: 'metric',
aggs: [{ id: '1', type: 'top_hits', schema: 'metric', params: { field: 'ip' } }],
aggs: [{ id: '1', type: 'top_hits', schema: 'metric', params: { field: 'ip' } }] as any,
});

vis.params.dimensions = {
Expand Down
Expand Up @@ -70,18 +70,18 @@ const emptyCaption = '<br>';
function Panel({ interval, seriesList, renderComplete }: PanelProps) {
const kibana = useKibana<TimelionVisDependencies>();
const [chart, setChart] = useState(() => cloneDeep(seriesList.list));
const [canvasElem, setCanvasElem] = useState();
const [chartElem, setChartElem] = useState();
const [canvasElem, setCanvasElem] = useState<HTMLElement>();
Copy link
Contributor Author

@mshustov mshustov Feb 20, 2020

Choose a reason for hiding this comment

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

the file still contains some type errors. @timroes @sulemanof could someone take a look and fix the errors, please?

const [chartElem, setChartElem] = useState<HTMLElement>();

const [originalColorMap, setOriginalColorMap] = useState(() => new Map<Series, string>());

const [highlightedSeries, setHighlightedSeries] = useState<number | null>(null);
const [focusedSeries, setFocusedSeries] = useState();
const [plot, setPlot] = useState();
const [focusedSeries, setFocusedSeries] = useState<number | null>();
const [plot, setPlot] = useState<jquery.flot.plot>();

// Used to toggle the series, and for displaying values on hover
const [legendValueNumbers, setLegendValueNumbers] = useState();
const [legendCaption, setLegendCaption] = useState();
const [legendValueNumbers, setLegendValueNumbers] = useState<JQuery<HTMLElement>>();
const [legendCaption, setLegendCaption] = useState<JQuery<HTMLElement>>();

const canvasRef = useCallback(node => {
if (node !== null) {
Expand All @@ -97,7 +97,7 @@ function Panel({ interval, seriesList, renderComplete }: PanelProps) {

useEffect(
() => () => {
$(chartElem)
$(chartElem!)
.off('plotselected')
.off('plothover')
.off('mouseleave');
Expand Down Expand Up @@ -156,11 +156,11 @@ function Panel({ interval, seriesList, renderComplete }: PanelProps) {
caption.html(emptyCaption);
setLegendCaption(caption);

const canvasNode = $(canvasElem);
const canvasNode = $(canvasElem!);
canvasNode.find('div.legend table').append(caption);
setLegendValueNumbers(canvasNode.find('.ngLegendValueNumber'));

const legend = $(canvasElem).find('.ngLegendValue');
const legend = $(canvasElem!).find('.ngLegendValue');
if (legend) {
legend.click(toggleSeries);
legend.focus(focusSeries);
Expand Down Expand Up @@ -254,20 +254,20 @@ function Panel({ interval, seriesList, renderComplete }: PanelProps) {
(pos: Position) => {
unhighlightSeries();

const axes = plot.getAxes();
if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max) {
const axes = plot!.getAxes();
if (pos.x < axes.xaxis.min! || pos.x > axes.xaxis.max!) {
return;
}

const dataset = plot.getData();
const dataset = plot!.getData();
if (legendCaption) {
legendCaption.text(
moment(pos.x).format(get(dataset, '[0]._global.legend.timeFormat', DEFAULT_TIME_FORMAT))
);
}
for (let i = 0; i < dataset.length; ++i) {
const series = dataset[i];
const useNearestPoint = series.lines.show && !series.lines.steps;
const useNearestPoint = series.lines!.show && !series.lines!.steps;
const precision = get(series, '_meta.precision', 2);

if (series._hide) {
Expand All @@ -289,12 +289,12 @@ function Panel({ interval, seriesList, renderComplete }: PanelProps) {

if (y != null && legendValueNumbers) {
let label = y.toFixed(precision);
if (series.yaxis.tickFormatter) {
label = series.yaxis.tickFormatter(Number(label), series.yaxis);
if (series.yaxis!.tickFormatter) {
label = series.yaxis!.tickFormatter(Number(label), series.yaxis);
}
legendValueNumbers.eq(i).text(`(${label})`);
} else {
legendValueNumbers.eq(i).empty();
legendValueNumbers!.eq(i).empty();
}
}
},
Expand All @@ -314,7 +314,7 @@ function Panel({ interval, seriesList, renderComplete }: PanelProps) {
if (legendCaption) {
legendCaption.html(emptyCaption);
}
each(legendValueNumbers, (num: Node) => {
each(legendValueNumbers!, (num: Node) => {
$(num).empty();
});
}, [legendCaption, legendValueNumbers]);
Expand Down
Expand Up @@ -113,7 +113,7 @@ export function ShardFailureModal({ request, response, title, onClose }: Props)
</EuiButtonEmpty>
)}
</EuiCopy>
<EuiButton onClick={() => onClose()} fill data-test-sub="closeShardFailureModal">
<EuiButton onClick={() => onClose()} fill data-test-subj="closeShardFailureModal">
<FormattedMessage
id="data.search.searchSource.fetch.shardsFailedModal.close"
defaultMessage="Close"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/share/public/components/url_panel_content.tsx
Expand Up @@ -112,7 +112,7 @@ export class UrlPanelContent extends Component<Props, State> {
fullWidth
onClick={copy}
disabled={this.state.isCreatingShortUrl || this.state.url === ''}
data-share-url={this.state.url}
data-share-url={(this.state.url as unknown) as undefined}
data-test-subj="copyShareUrlButton"
size="s"
>
Expand Down
2 changes: 1 addition & 1 deletion test/plugin_functional/plugins/core_plugin_a/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion test/plugin_functional/plugins/core_plugin_b/package.json
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
Expand Up @@ -17,6 +17,6 @@
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
Expand Up @@ -17,6 +17,6 @@
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
"typescript": "3.8.1-rc"
}
}
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/apm/cypress/package.json
Expand Up @@ -15,7 +15,7 @@
"js-yaml": "^3.13.1",
"p-limit": "^2.2.1",
"ts-loader": "^6.1.0",
"typescript": "3.7.2",
"typescript": "3.8.1-rc",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elastic/apm-ui I need your help here to fix APMRequestHandlerContext which type is inferred as any
2020-02-17_10-40-24

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Looking into it!

Copy link
Member

Choose a reason for hiding this comment

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

@restrry I can't explain this - there's no reason I can see why this fails, and others don't. It feels like a TS bug, but I cannot pinpoint it.

Copy link
Member

Choose a reason for hiding this comment

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

btw - in my case, I don't see context as any, but the type for context.params is incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sqren is context.params type correct in your case?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. It seems like it's not. On master I get this:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it might be related to the fact that Params interface contains optional props only.
When I remove an empty object default from

TParams extends Params = {}

TS starts inferring context type, but not params
2020-02-20_11-38-44

Copy link
Member

Choose a reason for hiding this comment

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

I'm not here until Monday, and my only guess right now is that this is a TS bug (either in resolving or in showing an appropriate error). Can someone flag this with the TS team? If there's not much of a rush I can look into it Monday.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dgieselaar take your time, we are blocked by external dependencies as well

"webpack": "^4.41.5"
}
}
Expand Up @@ -45,6 +45,7 @@ const style: cytoscape.Stylesheet[] = [
isService(el) ? '80%' : '40%',
'background-width': (el: cytoscape.NodeSingular) =>
isService(el) ? '80%' : '40%',
// @ts-ignore no function allowed
'border-color': (el: cytoscape.NodeSingular) =>
el.hasClass('primary')
? theme.euiColorSecondary
Expand All @@ -54,17 +55,21 @@ const style: cytoscape.Stylesheet[] = [
// theme.euiFontFamily doesn't work here for some reason, so we're just
// specifying a subset of the fonts for the label text.
'font-family': 'Inter UI, Segoe UI, Helvetica, Arial, sans-serif',
// @ts-ignore no strings allowed
'font-size': theme.euiFontSizeXS,
height: nodeHeight,
label: 'data(label)',
// @ts-ignore no strings allowed
'min-zoomed-font-size': theme.euiSizeL,
'overlay-opacity': 0,
// @ts-ignore no function allowed
shape: (el: cytoscape.NodeSingular) =>
isService(el) ? 'ellipse' : 'diamond',
'text-background-color': theme.euiColorLightestShade,
'text-background-opacity': 0,
'text-background-padding': theme.paddingSizes.xs,
'text-background-shape': 'roundrectangle',
// @ts-ignore no strings allowed
'text-margin-y': theme.paddingSizes.s,
'text-max-width': '200px',
'text-valign': 'bottom',
Expand Down
Expand Up @@ -60,7 +60,7 @@ function getYTickFormatter(chart: GenericMetricsChart) {
case 'bytes': {
const max = Math.max(
...chart.series.map(({ data }) =>
Math.max(...data.map(({ y }) => y || 0))
Math.max(...data.map(({ y }: { y: number }) => y || 0))
)
);
return getFixedByteFormatter(max);
Expand Down