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

TypeScript project references for infra plugin #90118

Merged
merged 13 commits into from
Feb 8, 2021
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/common/inventory_models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export const ESTopHitsAggRT = rt.type({
top_hits: rt.object,
});

interface SnapshotTermsWithAggregation {
export interface SnapshotTermsWithAggregation {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of TS4023 (microsoft/TypeScript#5711) some additional interfaces need to be exported because we're emitting declarations:

x-pack/plugins/infra/server/routes/snapshot/lib/get_metrics_aggregations.ts:29:14 - error TS4023: Exported variable 'metricToAggregation' has or is using name 'SnapshotTermsWithAggregation' from external module "/Users/smith/Code/kibana/x-pack/plugins/infra/common/inventory_models/types" but cannot be named.

terms: { field: string };
aggregations: MetricsUIAggregation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isEqual } from 'lodash';
import { useState } from 'react';
import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer';

interface MetricThresholdPrefillOptions {
export interface MetricThresholdPrefillOptions {
groupBy: string | string[] | undefined;
filterQuery: string | undefined;
metrics: MetricsExplorerMetric[];
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/infra/public/components/document_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ const wrapWithSharedState = () => {
return null;
}

private getTitle(title: TitleProp) {
public getTitle(title: TitleProp) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is returning an anonymous class expression so private/protected are not permitted if we're emitting declarations. (TS4094/microsoft/TypeScript#30355)

return typeof title === 'function' ? title(titles[this.state.index - 1]) : title;
}

private pushTitle(title: string) {
public pushTitle(title: string) {
titles[this.state.index] = title;
}

private removeTitle() {
public removeTitle() {
titles.pop();
}

private updateDocumentTitle() {
public updateDocumentTitle() {
const title = (titles[titles.length - 1] || '') + TITLE_SUFFIX;
if (title !== document.title) {
document.title = title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const initialState = {

type State = Readonly<typeof initialState>;

export const CustomFieldPanel = class extends React.PureComponent<Props, State> {
export class CustomFieldPanel extends React.PureComponent<Props, State> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Export a named class instead of expression. (TS4094/microsoft/TypeScript#30355)

public static displayName = 'CustomFieldPanel';
public readonly state: State = initialState;
public render() {
Expand Down Expand Up @@ -85,4 +85,4 @@ export const CustomFieldPanel = class extends React.PureComponent<Props, State>
private handleFieldSelection = (selectedOptions: SelectedOption[]) => {
this.setState({ selectedOptions });
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface Props {
currentTime: number;
}

export const Node = class extends React.PureComponent<Props, State> {
export class Node extends React.PureComponent<Props, State> {
public readonly state: State = initialState;
public render() {
const { nodeType, node, options, squareSize, bounds, formatter, currentTime } = this.props;
Expand Down Expand Up @@ -163,7 +163,7 @@ export const Node = class extends React.PureComponent<Props, State> {
this.setState({ isPopoverOpen: false });
}
};
};
}

const NodeContainer = euiStyled.div`
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const initialState = {

type State = Readonly<typeof initialState>;

export const WaffleGroupByControls = class extends React.PureComponent<Props, State> {
export class WaffleGroupByControls extends React.PureComponent<Props, State> {
public static displayName = 'WaffleGroupByControls';
public readonly state: State = initialState;

Expand Down Expand Up @@ -191,7 +191,7 @@ export const WaffleGroupByControls = class extends React.PureComponent<Props, St
}
this.handleClose();
};
};
}

const StyledContextMenu = euiStyled(EuiContextMenu)`
width: 320px;
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/infra/public/utils/use_tracked_promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,22 +234,22 @@ export const useTrackedPromise = <Arguments extends any[], Result>(
return [promiseState, execute] as [typeof promiseState, typeof execute];
};

interface UninitializedPromiseState {
export interface UninitializedPromiseState {
state: 'uninitialized';
}

interface PendingPromiseState<ResolvedValue> {
export interface PendingPromiseState<ResolvedValue> {
state: 'pending';
promise: Promise<ResolvedValue>;
}

interface ResolvedPromiseState<ResolvedValue> {
export interface ResolvedPromiseState<ResolvedValue> {
state: 'resolved';
promise: Promise<ResolvedValue>;
value: ResolvedValue;
}

interface RejectedPromiseState<ResolvedValue, RejectedValue> {
export interface RejectedPromiseState<ResolvedValue, RejectedValue> {
state: 'rejected';
promise: Promise<ResolvedValue>;
value: RejectedValue;
Expand Down
36 changes: 36 additions & 0 deletions x-pack/plugins/infra/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"../../typings/**/*",
"common/**/*",
"public/**/*",
"scripts/**/*",
"server/**/*",
"types/**/*"
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/data/tsconfig.json" },
{ "path": "../../../src/plugins/embeddable/tsconfig.json" },
{ "path": "../../../src/plugins/home/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../../../src/plugins/vis_type_timeseries/tsconfig.json" },
{ "path": "../data_enhanced/tsconfig.json" },
{ "path": "../alerts/tsconfig.json" },
{ "path": "../features/tsconfig.json" },
{ "path": "../license_management/tsconfig.json" },
{ "path": "../ml/tsconfig.json" },
{ "path": "../observability/tsconfig.json" },
{ "path": "../spaces/tsconfig.json" },
{ "path": "../triggers_actions_ui/tsconfig.json" }
]
}
58 changes: 29 additions & 29 deletions x-pack/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,70 @@
"exclude": ["../typings/jest.d.ts"],
"references": [
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/telemetry_management_section/tsconfig.json" },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alphabetized these.

{ "path": "../../src/plugins/management/tsconfig.json" },
{ "path": "../../src/plugins/bfetch/tsconfig.json" },
{ "path": "../../src/plugins/charts/tsconfig.json" },
{ "path": "../../src/plugins/console/tsconfig.json" },
{ "path": "../../src/plugins/dashboard/tsconfig.json" },
{ "path": "../../src/plugins/discover/tsconfig.json" },
{ "path": "../../src/plugins/data/tsconfig.json" },
{ "path": "../../src/plugins/discover/tsconfig.json" },
{ "path": "../../src/plugins/embeddable/tsconfig.json" },
{ "path": "../../src/plugins/es_ui_shared/tsconfig.json" },
{ "path": "../../src/plugins/expressions/tsconfig.json" },
{ "path": "../../src/plugins/home/tsconfig.json" },
{ "path": "../../src/plugins/index_pattern_management/tsconfig.json" },
{ "path": "../../src/plugins/kibana_overview/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../src/plugins/legacy_export/tsconfig.json" },
{ "path": "../../src/plugins/management/tsconfig.json" },
{ "path": "../../src/plugins/navigation/tsconfig.json" },
{ "path": "../../src/plugins/newsfeed/tsconfig.json" },
{ "path": "../../src/plugins/saved_objects/tsconfig.json" },
{ "path": "../../src/plugins/saved_objects_management/tsconfig.json" },
{ "path": "../../src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "../../src/plugins/saved_objects/tsconfig.json" },
{ "path": "../../src/plugins/share/tsconfig.json" },
{ "path": "../../src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "../../src/plugins/telemetry_management_section/tsconfig.json" },
{ "path": "../../src/plugins/telemetry/tsconfig.json" },
{ "path": "../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../../src/plugins/url_forwarding/tsconfig.json" },
{ "path": "../../src/plugins/index_pattern_management/tsconfig.json" },

{ "path": "../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../plugins/actions/tsconfig.json" },
{ "path": "../plugins/alerts/tsconfig.json" },
{ "path": "../plugins/beats_management/tsconfig.json" },
{ "path": "../plugins/cloud/tsconfig.json" },
{ "path": "../plugins/code/tsconfig.json" },
{ "path": "../plugins/console_extensions/tsconfig.json" },
{ "path": "../plugins/data_enhanced/tsconfig.json" },
{ "path": "../plugins/enterprise_search/tsconfig.json" },
{ "path": "../plugins/global_search/tsconfig.json" },
{ "path": "../plugins/global_search_providers/tsconfig.json" },
{ "path": "../plugins/features/tsconfig.json" },
{ "path": "../plugins/embeddable_enhanced/tsconfig.json" },
{ "path": "../plugins/encrypted_saved_objects/tsconfig.json" },
{ "path": "../plugins/enterprise_search/tsconfig.json" },
{ "path": "../plugins/event_log/tsconfig.json" },
{ "path": "../plugins/licensing/tsconfig.json" },
{ "path": "../plugins/features/tsconfig.json" },
{ "path": "../plugins/global_search_bar/tsconfig.json" },
{ "path": "../plugins/global_search_providers/tsconfig.json" },
{ "path": "../plugins/global_search/tsconfig.json" },
{ "path": "../plugins/grokdebugger/tsconfig.json" },
{ "path": "../plugins/index_management/tsconfig.json" },
{ "path": "../plugins/infra/tsconfig.json" },
{ "path": "../plugins/ingest_pipelines/tsconfig.json" },
{ "path": "../plugins/lens/tsconfig.json" },
{ "path": "../plugins/license_management/tsconfig.json" },
{ "path": "../plugins/licensing/tsconfig.json" },
{ "path": "../plugins/ml/tsconfig.json" },
{ "path": "../plugins/observability/tsconfig.json" },
{ "path": "../plugins/painless_lab/tsconfig.json" },
{ "path": "../plugins/runtime_fields/tsconfig.json" },
{ "path": "../plugins/saved_objects_tagging/tsconfig.json" },
{ "path": "../plugins/security/tsconfig.json" },
{ "path": "../plugins/snapshot_restore/tsconfig.json" },
{ "path": "../plugins/spaces/tsconfig.json" },
{ "path": "../plugins/stack_alerts/tsconfig.json" },
{ "path": "../plugins/task_manager/tsconfig.json" },
{ "path": "../plugins/telemetry_collection_xpack/tsconfig.json" },
{ "path": "../plugins/triggers_actions_ui/tsconfig.json" },
{ "path": "../plugins/ui_actions_enhanced/tsconfig.json" },
{ "path": "../plugins/spaces/tsconfig.json" },
{ "path": "../plugins/security/tsconfig.json" },
{ "path": "../plugins/encrypted_saved_objects/tsconfig.json" },
{ "path": "../plugins/stack_alerts/tsconfig.json" },
{ "path": "../plugins/beats_management/tsconfig.json" },
{ "path": "../plugins/cloud/tsconfig.json" },
{ "path": "../plugins/saved_objects_tagging/tsconfig.json" },
{ "path": "../plugins/global_search_bar/tsconfig.json" },
{ "path": "../plugins/observability/tsconfig.json" },
{ "path": "../plugins/ingest_pipelines/tsconfig.json" },
{ "path": "../plugins/license_management/tsconfig.json" },
{ "path": "../plugins/snapshot_restore/tsconfig.json" },
{ "path": "../plugins/grokdebugger/tsconfig.json" },
{ "path": "../plugins/painless_lab/tsconfig.json" },
{ "path": "../plugins/watcher/tsconfig.json" },
{ "path": "../plugins/runtime_fields/tsconfig.json" },
{ "path": "../plugins/index_management/tsconfig.json" }
{ "path": "../plugins/watcher/tsconfig.json" }
]
}
2 changes: 2 additions & 0 deletions x-pack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"plugins/embeddable_enhanced/**/*",
"plugins/event_log/**/*",
"plugins/enterprise_search/**/*",
"plugins/infra/**/*",
"plugins/licensing/**/*",
"plugins/lens/**/*",
"plugins/maps/**/*",
Expand Down Expand Up @@ -114,6 +115,7 @@
{ "path": "./plugins/global_search/tsconfig.json" },
{ "path": "./plugins/graph/tsconfig.json" },
{ "path": "./plugins/grokdebugger/tsconfig.json" },
{ "path": "./plugins/infra/tsconfig.json" },
{ "path": "./plugins/ingest_pipelines/tsconfig.json" },
{ "path": "./plugins/lens/tsconfig.json" },
{ "path": "./plugins/license_management/tsconfig.json" },
Expand Down