From 0964a15192399a27acd26c7a61b91b9ff1fc7077 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 20 Oct 2020 09:49:37 -0500 Subject: [PATCH 01/13] Add tsconfig for url_forwarding Also add missing pieces to kibana_react, as a follow-up to #80992. References #80508 References #81003 --- src/plugins/kibana_legacy/public/utils/private.d.ts | 2 ++ tsconfig.json | 3 ++- tsconfig.refs.json | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/kibana_legacy/public/utils/private.d.ts b/src/plugins/kibana_legacy/public/utils/private.d.ts index 3efc9cd5308f7..ab3c1e823f7ec 100644 --- a/src/plugins/kibana_legacy/public/utils/private.d.ts +++ b/src/plugins/kibana_legacy/public/utils/private.d.ts @@ -18,3 +18,5 @@ */ export type IPrivate = (provider: (...injectable: any[]) => T) => T; + +export function PrivateProvider(): void; diff --git a/tsconfig.json b/tsconfig.json index 92e5b9654acd7..96e15f664d6ec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,8 @@ "src/core/**/*", "src/plugins/kibana_legacy/**/*", "src/plugins/kibana_react/**/*", - "src/plugins/kibana_utils/**/*" + "src/plugins/kibana_utils/**/*", + "src/plugins/url_forwarding/**/*" // In the build we actually exclude **/public/**/* from this config so that // we can run the TSC on both this and the .browser version of this config // file, but if we did it during development IDEs would not be able to find diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 54bd07e4b134c..4e75d121b2115 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -3,7 +3,9 @@ "references": [ { "path": "./src/test_utils/tsconfig.json" }, { "path": "./src/core/tsconfig.json" }, - { "path": "./src/plugins/kibana_utils/tsconfig.json" }, + { "path": "./src/plugins/kibana_legacy/tsconfig.json" }, { "path": "./src/plugins/kibana_react/tsconfig.json" }, + { "path": "./src/plugins/kibana_utils/tsconfig.json" }, + { "path": "./src/plugins/url_forwarding/tsconfig.json" } ] } From c4410d94f16d0eb8ccb2849088f33295f46c1e24 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Wed, 21 Oct 2020 11:00:54 -0500 Subject: [PATCH 02/13] Add additional files --- src/core/public/chrome/chrome_service.mock.ts | 1 + .../notifications_service.mock.ts | 1 + .../public/overlays/overlay_service.mock.ts | 1 + src/core/typings.ts | 4 ++-- .../public/angular/kbn_top_nav.d.ts | 22 +++++++++++++++++++ .../public/angular/promises.d.ts | 20 +++++++++++++++++ .../public/angular/watch_multi.d.ts | 20 +++++++++++++++++ .../public/utils/kbn_accessible_click.d.ts | 20 +++++++++++++++++ .../utils/register_listen_event_listener.d.ts | 20 +++++++++++++++++ src/plugins/url_forwarding/tsconfig.json | 15 +++++++++++++ 10 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts create mode 100644 src/plugins/kibana_legacy/public/angular/promises.d.ts create mode 100644 src/plugins/kibana_legacy/public/angular/watch_multi.d.ts create mode 100644 src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts create mode 100644 src/plugins/kibana_legacy/public/utils/register_listen_event_listener.d.ts create mode 100644 src/plugins/url_forwarding/tsconfig.json diff --git a/src/core/public/chrome/chrome_service.mock.ts b/src/core/public/chrome/chrome_service.mock.ts index 9cd96763d2e79..683d153288185 100644 --- a/src/core/public/chrome/chrome_service.mock.ts +++ b/src/core/public/chrome/chrome_service.mock.ts @@ -18,6 +18,7 @@ */ import { BehaviorSubject } from 'rxjs'; import type { PublicMethodsOf } from '@kbn/utility-types'; +import { DeeplyMockedKeys } from '../../typings'; import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './'; const createStartContractMock = () => { diff --git a/src/core/public/notifications/notifications_service.mock.ts b/src/core/public/notifications/notifications_service.mock.ts index 990ab479d35c3..521ce52c90d0a 100644 --- a/src/core/public/notifications/notifications_service.mock.ts +++ b/src/core/public/notifications/notifications_service.mock.ts @@ -17,6 +17,7 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; +import { MockedKeys } from '../../typings'; import { NotificationsService, NotificationsSetup, diff --git a/src/core/public/overlays/overlay_service.mock.ts b/src/core/public/overlays/overlay_service.mock.ts index 66ba36b20b45c..72a51b0b14187 100644 --- a/src/core/public/overlays/overlay_service.mock.ts +++ b/src/core/public/overlays/overlay_service.mock.ts @@ -17,6 +17,7 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; +import { DeeplyMockedKeys } from '../../typings'; import { OverlayService, OverlayStart } from './overlay_service'; import { overlayBannersServiceMock } from './banners/banners_service.mock'; import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock'; diff --git a/src/core/typings.ts b/src/core/typings.ts index f271d0b03e0d3..fe182ddfb131b 100644 --- a/src/core/typings.ts +++ b/src/core/typings.ts @@ -17,11 +17,11 @@ * under the License. */ -type DeeplyMockedKeys = { +export type DeeplyMockedKeys = { [P in keyof T]: T[P] extends (...args: any[]) => any ? jest.MockInstance, Parameters> : DeeplyMockedKeys; } & T; -type MockedKeys = { [P in keyof T]: jest.Mocked }; +export type MockedKeys = { [P in keyof T]: jest.Mocked }; diff --git a/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts b/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts new file mode 100644 index 0000000000000..57224f9613e99 --- /dev/null +++ b/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export function createTopNavDirective(): unknown; +export const createTopNavHelper: (options: unknown) => (reactDirective: unknown) => unknown; +export function loadKbnTopNavDirectives(navUi: unknown): void; diff --git a/src/plugins/kibana_legacy/public/angular/promises.d.ts b/src/plugins/kibana_legacy/public/angular/promises.d.ts new file mode 100644 index 0000000000000..1a2ce66834d7b --- /dev/null +++ b/src/plugins/kibana_legacy/public/angular/promises.d.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export function PromiseServiceCreator($q: unknown, $timeout: unknown): (fn: unknown) => unknown; diff --git a/src/plugins/kibana_legacy/public/angular/watch_multi.d.ts b/src/plugins/kibana_legacy/public/angular/watch_multi.d.ts new file mode 100644 index 0000000000000..7c73abf2f9aa2 --- /dev/null +++ b/src/plugins/kibana_legacy/public/angular/watch_multi.d.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export function watchMultiDecorator($provide: unknown): void; diff --git a/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts b/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts new file mode 100644 index 0000000000000..d0942caaa37c0 --- /dev/null +++ b/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export function KbnAccessibleClickProvider(): void; diff --git a/src/plugins/kibana_legacy/public/utils/register_listen_event_listener.d.ts b/src/plugins/kibana_legacy/public/utils/register_listen_event_listener.d.ts new file mode 100644 index 0000000000000..eff9b4b871f56 --- /dev/null +++ b/src/plugins/kibana_legacy/public/utils/register_listen_event_listener.d.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export function registerListenEventListener($rootScope: unknown): void; diff --git a/src/plugins/url_forwarding/tsconfig.json b/src/plugins/url_forwarding/tsconfig.json new file mode 100644 index 0000000000000..8e867a6bad14f --- /dev/null +++ b/src/plugins/url_forwarding/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": ["public/**/*"], + "references": [ + { "path": "../../core/tsconfig.json" }, + { "path": "../kibana_legacy/tsconfig.json" } + ] +} From c03408c0d3ff49ba50a7f2f13538ddbebf1f41ec Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 10:24:56 -0500 Subject: [PATCH 03/13] Add tsconfig ref to x-pack --- x-pack/tsconfig.json | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index e0a0b63d3c6a5..a1d4419a15ad6 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -1,12 +1,6 @@ { "extends": "../tsconfig.base.json", - "include": [ - "mocks.ts", - "typings/**/*", - "plugins/**/*", - "test_utils/**/*", - "tasks/**/*" - ], + "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "test_utils/**/*", "tasks/**/*"], "exclude": [ "test/**/*", "plugins/security_solution/cypress/**/*", @@ -14,9 +8,10 @@ "plugins/apm/scripts/**/*", "plugins/licensing/**/*", "plugins/global_search/**/*", + "../src/plugins/kibana_legacy/**/*", "../src/plugins/usage_collection/**/*", - "../src/plugins/telemetry_collection_manager/**/*", - "../src/plugins/telemetry/**/*" + "../src/plugins/telemetry/**/*", + "../src/plugins/telemetry_collection_manager/**/*" ], "compilerOptions": { "paths": { @@ -30,13 +25,14 @@ }, "references": [ { "path": "../src/core/tsconfig.json" }, - { "path": "../src/plugins/kibana_utils/tsconfig.json" }, + { "path": "../src/plugins/kibana_legacy/tsconfig.json" }, { "path": "../src/plugins/kibana_react/tsconfig.json" }, - { "path": "./plugins/licensing/tsconfig.json" }, - { "path": "./plugins/global_search/tsconfig.json" }, - { "path": "../src/plugins/usage_collection/tsconfig.json" }, - { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, - { "path": "../src/plugins/telemetry/tsconfig.json" }, + { "path": "../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../src/plugins/newsfeed/tsconfig.json" }, + { "path": "../src/plugins/telemetry/tsconfig.json" }, + { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, + { "path": "../src/plugins/usage_collection/tsconfig.json" }, + { "path": "./plugins/licensing/tsconfig.json" }, + { "path": "./plugins/global_search/tsconfig.json" } ] } From 064a9e3fa8954dc3927087e76d0339bea7fba89f Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 10:29:38 -0500 Subject: [PATCH 04/13] add url_forwarding to xpack --- x-pack/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index b34d590fe19c0..5420a2beac196 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -34,7 +34,7 @@ { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, - { "path": "../src/plugins/usage_collection/tsconfig.json" }, + { "path": "../src/plugins/url_forwarding/tsconfig.json" }, { "path": "../src/plugins/usage_collection/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/licensing/tsconfig.json" } From 58c1085b4bd93184a3e0e2f463866c06a2ce3236 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 10:58:38 -0500 Subject: [PATCH 05/13] remove dup deply --- src/core/public/apm_system.test.ts | 3 ++- src/core/public/chrome/chrome_service.mock.ts | 1 - .../notifications_service.mock.ts | 1 - .../public/overlays/overlay_service.mock.ts | 1 - src/core/server/core_context.mock.ts | 1 + src/core/typings.ts | 27 ------------------- 6 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 src/core/typings.ts diff --git a/src/core/public/apm_system.test.ts b/src/core/public/apm_system.test.ts index f88cdd899ef81..fdf088fff28f1 100644 --- a/src/core/public/apm_system.test.ts +++ b/src/core/public/apm_system.test.ts @@ -18,7 +18,8 @@ */ jest.mock('@elastic/apm-rum'); -import { init, apm } from '@elastic/apm-rum'; +import { apm, init } from '@elastic/apm-rum'; +import { DeeplyMockedKeys } from '../typings'; import { ApmSystem } from './apm_system'; const initMock = init as jest.Mocked; diff --git a/src/core/public/chrome/chrome_service.mock.ts b/src/core/public/chrome/chrome_service.mock.ts index 683d153288185..9cd96763d2e79 100644 --- a/src/core/public/chrome/chrome_service.mock.ts +++ b/src/core/public/chrome/chrome_service.mock.ts @@ -18,7 +18,6 @@ */ import { BehaviorSubject } from 'rxjs'; import type { PublicMethodsOf } from '@kbn/utility-types'; -import { DeeplyMockedKeys } from '../../typings'; import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './'; const createStartContractMock = () => { diff --git a/src/core/public/notifications/notifications_service.mock.ts b/src/core/public/notifications/notifications_service.mock.ts index 521ce52c90d0a..990ab479d35c3 100644 --- a/src/core/public/notifications/notifications_service.mock.ts +++ b/src/core/public/notifications/notifications_service.mock.ts @@ -17,7 +17,6 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; -import { MockedKeys } from '../../typings'; import { NotificationsService, NotificationsSetup, diff --git a/src/core/public/overlays/overlay_service.mock.ts b/src/core/public/overlays/overlay_service.mock.ts index 72a51b0b14187..66ba36b20b45c 100644 --- a/src/core/public/overlays/overlay_service.mock.ts +++ b/src/core/public/overlays/overlay_service.mock.ts @@ -17,7 +17,6 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; -import { DeeplyMockedKeys } from '../../typings'; import { OverlayService, OverlayStart } from './overlay_service'; import { overlayBannersServiceMock } from './banners/banners_service.mock'; import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock'; diff --git a/src/core/server/core_context.mock.ts b/src/core/server/core_context.mock.ts index bbf04783278f7..8bbba586d46f5 100644 --- a/src/core/server/core_context.mock.ts +++ b/src/core/server/core_context.mock.ts @@ -18,6 +18,7 @@ */ import { REPO_ROOT } from '@kbn/dev-utils'; +import { DeeplyMockedKeys } from '../typings'; import { CoreContext } from './core_context'; import { Env, IConfigService } from './config'; import { configServiceMock, getEnvOptions } from './config/mocks'; diff --git a/src/core/typings.ts b/src/core/typings.ts deleted file mode 100644 index fe182ddfb131b..0000000000000 --- a/src/core/typings.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export type DeeplyMockedKeys = { - [P in keyof T]: T[P] extends (...args: any[]) => any - ? jest.MockInstance, Parameters> - : DeeplyMockedKeys; -} & - T; - -export type MockedKeys = { [P in keyof T]: jest.Mocked }; From 4f9ea686eb45f136d1a606a2258c1839e7fa741b Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 11:11:19 -0500 Subject: [PATCH 06/13] Add back typings --- src/core/public/apm_system.test.ts | 1 - src/core/typings.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/core/typings.ts diff --git a/src/core/public/apm_system.test.ts b/src/core/public/apm_system.test.ts index fdf088fff28f1..04810ef0d5936 100644 --- a/src/core/public/apm_system.test.ts +++ b/src/core/public/apm_system.test.ts @@ -19,7 +19,6 @@ jest.mock('@elastic/apm-rum'); import { apm, init } from '@elastic/apm-rum'; -import { DeeplyMockedKeys } from '../typings'; import { ApmSystem } from './apm_system'; const initMock = init as jest.Mocked; diff --git a/src/core/typings.ts b/src/core/typings.ts new file mode 100644 index 0000000000000..f271d0b03e0d3 --- /dev/null +++ b/src/core/typings.ts @@ -0,0 +1,27 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +type DeeplyMockedKeys = { + [P in keyof T]: T[P] extends (...args: any[]) => any + ? jest.MockInstance, Parameters> + : DeeplyMockedKeys; +} & + T; + +type MockedKeys = { [P in keyof T]: jest.Mocked }; From 6b0c78bade38e38d40f54a94e5d9733c4bcbfcc1 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 11:20:51 -0500 Subject: [PATCH 07/13] Remove import of deeplymockedkeys --- src/core/server/core_context.mock.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/server/core_context.mock.ts b/src/core/server/core_context.mock.ts index 8bbba586d46f5..bbf04783278f7 100644 --- a/src/core/server/core_context.mock.ts +++ b/src/core/server/core_context.mock.ts @@ -18,7 +18,6 @@ */ import { REPO_ROOT } from '@kbn/dev-utils'; -import { DeeplyMockedKeys } from '../typings'; import { CoreContext } from './core_context'; import { Env, IConfigService } from './config'; import { configServiceMock, getEnvOptions } from './config/mocks'; From 705a25bdd10675318d6d4dd69337cb3c7b8fc301 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 11:30:35 -0500 Subject: [PATCH 08/13] revert a change --- src/core/public/apm_system.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/public/apm_system.test.ts b/src/core/public/apm_system.test.ts index 04810ef0d5936..f88cdd899ef81 100644 --- a/src/core/public/apm_system.test.ts +++ b/src/core/public/apm_system.test.ts @@ -18,7 +18,7 @@ */ jest.mock('@elastic/apm-rum'); -import { apm, init } from '@elastic/apm-rum'; +import { init, apm } from '@elastic/apm-rum'; import { ApmSystem } from './apm_system'; const initMock = init as jest.Mocked; From 3d39bc469a87423805cb166c5b775f0f75172d16 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 22 Oct 2020 15:26:21 -0500 Subject: [PATCH 09/13] export deeply mocked keys --- src/core/public/apm_system.test.ts | 1 + src/core/public/chrome/chrome_service.mock.ts | 1 + src/core/public/notifications/notifications_service.mock.ts | 1 + src/core/public/overlays/overlay_service.mock.ts | 1 + src/core/server/core_context.mock.ts | 1 + src/core/server/elasticsearch/client/mocks.ts | 1 + src/core/server/mocks.ts | 1 + src/core/typings.ts | 4 ++-- 8 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/public/apm_system.test.ts b/src/core/public/apm_system.test.ts index f88cdd899ef81..8467076c31542 100644 --- a/src/core/public/apm_system.test.ts +++ b/src/core/public/apm_system.test.ts @@ -19,6 +19,7 @@ jest.mock('@elastic/apm-rum'); import { init, apm } from '@elastic/apm-rum'; +import { DeeplyMockedKeys } from '../typings'; import { ApmSystem } from './apm_system'; const initMock = init as jest.Mocked; diff --git a/src/core/public/chrome/chrome_service.mock.ts b/src/core/public/chrome/chrome_service.mock.ts index 9cd96763d2e79..683d153288185 100644 --- a/src/core/public/chrome/chrome_service.mock.ts +++ b/src/core/public/chrome/chrome_service.mock.ts @@ -18,6 +18,7 @@ */ import { BehaviorSubject } from 'rxjs'; import type { PublicMethodsOf } from '@kbn/utility-types'; +import { DeeplyMockedKeys } from '../../typings'; import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './'; const createStartContractMock = () => { diff --git a/src/core/public/notifications/notifications_service.mock.ts b/src/core/public/notifications/notifications_service.mock.ts index 990ab479d35c3..521ce52c90d0a 100644 --- a/src/core/public/notifications/notifications_service.mock.ts +++ b/src/core/public/notifications/notifications_service.mock.ts @@ -17,6 +17,7 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; +import { MockedKeys } from '../../typings'; import { NotificationsService, NotificationsSetup, diff --git a/src/core/public/overlays/overlay_service.mock.ts b/src/core/public/overlays/overlay_service.mock.ts index 66ba36b20b45c..72a51b0b14187 100644 --- a/src/core/public/overlays/overlay_service.mock.ts +++ b/src/core/public/overlays/overlay_service.mock.ts @@ -17,6 +17,7 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; +import { DeeplyMockedKeys } from '../../typings'; import { OverlayService, OverlayStart } from './overlay_service'; import { overlayBannersServiceMock } from './banners/banners_service.mock'; import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock'; diff --git a/src/core/server/core_context.mock.ts b/src/core/server/core_context.mock.ts index bbf04783278f7..8bbba586d46f5 100644 --- a/src/core/server/core_context.mock.ts +++ b/src/core/server/core_context.mock.ts @@ -18,6 +18,7 @@ */ import { REPO_ROOT } from '@kbn/dev-utils'; +import { DeeplyMockedKeys } from '../typings'; import { CoreContext } from './core_context'; import { Env, IConfigService } from './config'; import { configServiceMock, getEnvOptions } from './config/mocks'; diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index fb2826c787718..260efa40ac43c 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -18,6 +18,7 @@ */ import { Client, ApiResponse } from '@elastic/elasticsearch'; import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import { DeeplyMockedKeys } from '../../../typings'; import { ElasticsearchClient } from './types'; import { ICustomClusterClient } from './cluster_client'; diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index e47d06409894e..1c0584837dc3a 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -19,6 +19,7 @@ import { of } from 'rxjs'; import { duration } from 'moment'; import { ByteSizeValue } from '@kbn/config-schema'; +import { MockedKeys } from '../typings'; import { PluginInitializerContext, CoreSetup, CoreStart, StartServicesAccessor } from '.'; import { loggingSystemMock } from './logging/logging_system.mock'; import { loggingServiceMock } from './logging/logging_service.mock'; diff --git a/src/core/typings.ts b/src/core/typings.ts index f271d0b03e0d3..fe182ddfb131b 100644 --- a/src/core/typings.ts +++ b/src/core/typings.ts @@ -17,11 +17,11 @@ * under the License. */ -type DeeplyMockedKeys = { +export type DeeplyMockedKeys = { [P in keyof T]: T[P] extends (...args: any[]) => any ? jest.MockInstance, Parameters> : DeeplyMockedKeys; } & T; -type MockedKeys = { [P in keyof T]: jest.Mocked }; +export type MockedKeys = { [P in keyof T]: jest.Mocked }; From 7bd1e8fedec5f1d39873913028926b460403ffd2 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Mon, 26 Oct 2020 09:19:56 -0500 Subject: [PATCH 10/13] Fix kibana legacy angular types --- .../kibana_legacy/public/angular/kbn_top_nav.d.ts | 13 +++++++++++-- src/plugins/kibana_legacy/public/utils/private.d.ts | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts b/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts index 57224f9613e99..3d1dcdbef3f4b 100644 --- a/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts +++ b/src/plugins/kibana_legacy/public/angular/kbn_top_nav.d.ts @@ -17,6 +17,15 @@ * under the License. */ -export function createTopNavDirective(): unknown; -export const createTopNavHelper: (options: unknown) => (reactDirective: unknown) => unknown; +import { Injectable, IDirectiveFactory, IScope, IAttributes, IController } from 'angular'; + +export const createTopNavDirective: Injectable>; +export const createTopNavHelper: ( + options: unknown +) => Injectable>; export function loadKbnTopNavDirectives(navUi: unknown): void; diff --git a/src/plugins/kibana_legacy/public/utils/private.d.ts b/src/plugins/kibana_legacy/public/utils/private.d.ts index ab3c1e823f7ec..00b0220316ead 100644 --- a/src/plugins/kibana_legacy/public/utils/private.d.ts +++ b/src/plugins/kibana_legacy/public/utils/private.d.ts @@ -17,6 +17,8 @@ * under the License. */ +import { IServiceProvider } from 'angular'; + export type IPrivate = (provider: (...injectable: any[]) => T) => T; -export function PrivateProvider(): void; +export function PrivateProvider(): IServiceProvider; From f2d6374dd3ef5a21756df695186812cf2b157bd1 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Mon, 26 Oct 2020 10:12:08 -0500 Subject: [PATCH 11/13] Add another missing angular --- .../kibana_legacy/public/utils/kbn_accessible_click.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts b/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts index d0942caaa37c0..e4ef43fe8d443 100644 --- a/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts +++ b/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.d.ts @@ -17,4 +17,11 @@ * under the License. */ -export function KbnAccessibleClickProvider(): void; +import { Injectable, IDirectiveFactory, IScope, IAttributes, IController } from 'angular'; + +export const KbnAccessibleClickProvider: Injectable>; From f0209a9f61cc7a6c740c262b7e289b5490ba5700 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Mon, 26 Oct 2020 14:10:52 -0500 Subject: [PATCH 12/13] Add missing refs to xpack --- x-pack/tsconfig.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 5420a2beac196..e19fc6c55290a 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -3,8 +3,13 @@ "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "test_utils/**/*", "tasks/**/*"], "exclude": [ "../src/plugins/kibana_legacy/**/*", + "../src/plugins/kibana_react/**/*", + "../src/plugins/kibana_usage_collection/**/*", + "../src/plugins/kibana_utils/**/*", + "../src/plugins/newsfeed/**/*", "../src/plugins/telemetry/**/*", "../src/plugins/telemetry_collection_manager/**/*", + "../src/plugins/url_forwarding/**/*", "../src/plugins/usage_collection/**/*", "plugins/apm/e2e/cypress/**/*", "plugins/apm/scripts/**/*", @@ -30,10 +35,8 @@ { "path": "../src/plugins/kibana_usage_collection/tsconfig.json" }, { "path": "../src/plugins/kibana_utils/tsconfig.json" }, { "path": "../src/plugins/newsfeed/tsconfig.json" }, - { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, - { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, - { "path": "../src/plugins/telemetry/tsconfig.json" }, { "path": "../src/plugins/telemetry/tsconfig.json" }, + { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/url_forwarding/tsconfig.json" }, { "path": "../src/plugins/usage_collection/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, From 8651897a7d18d2775910f2f4f7558efed7fc2ca2 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 27 Oct 2020 10:17:37 -0500 Subject: [PATCH 13/13] remove unnecessary excludes from x-pack --- x-pack/tsconfig.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index ab72d7d0f067d..057441304f093 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -2,15 +2,6 @@ "extends": "../tsconfig.base.json", "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "test_utils/**/*", "tasks/**/*"], "exclude": [ - "../src/plugins/kibana_legacy/**/*", - "../src/plugins/kibana_react/**/*", - "../src/plugins/kibana_usage_collection/**/*", - "../src/plugins/kibana_utils/**/*", - "../src/plugins/newsfeed/**/*", - "../src/plugins/telemetry/**/*", - "../src/plugins/telemetry_collection_manager/**/*", - "../src/plugins/url_forwarding/**/*", - "../src/plugins/usage_collection/**/*", "plugins/apm/e2e/cypress/**/*", "plugins/apm/scripts/**/*", "plugins/global_search/**/*",