Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into telemetry/sch…
Browse files Browse the repository at this point in the history
…ema_remove_number_type
  • Loading branch information
Bamieh committed Oct 29, 2020
2 parents 0065080 + 66d79ea commit 467ea47
Show file tree
Hide file tree
Showing 547 changed files with 12,294 additions and 8,878 deletions.
2 changes: 2 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ last 2 Chrome versions
last 2 Safari versions
> 0.25%
not ie 11
not op_mini all
not samsung 4

[dev]
last 1 chrome versions
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/v8_breaking_change.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ assignees: ''

---

<!--
****************************************
******* LABEL CHANGES NECESSARY ********
****************************************
Please add a "NeededFor:${TeamName}" label to denote the team that is
requesting the breaking change is surfaced in the Upgrade Assistant.
-->

## Change description

**Which release will ship the breaking change?**
Expand Down
5 changes: 3 additions & 2 deletions examples/embeddable_explorer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"public/**/*.ts",
"public/**/*.tsx",
"server/**/*.ts",
"../../typings/**/*",
"../../typings/**/*"
],
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/inspector/tsconfig.json" }
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/kbn-utility-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,10 @@ export type MethodKeysOf<T> = {
* Returns an object with public methods only.
*/
export type PublicMethodsOf<T> = Pick<T, MethodKeysOf<T>>;

/**
* Makes an object with readonly properties mutable.
*/
export type Writable<T> = {
-readonly [K in keyof T]: T[K];
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/

type DeeplyMockedKeys<T> = {
export type DeeplyMockedKeys<T> = {
[P in keyof T]: T[P] extends (...args: any[]) => any
? jest.MockInstance<ReturnType<T[P]>, Parameters<T[P]>>
: DeeplyMockedKeys<T[P]>;
} &
T;

type MockedKeys<T> = { [P in keyof T]: jest.Mocked<T[P]> };
export type MockedKeys<T> = { [P in keyof T]: jest.Mocked<T[P]> };
3 changes: 3 additions & 0 deletions packages/kbn-utility-types/jest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"types": "../target/jest/index.d.ts"
}
34 changes: 34 additions & 0 deletions packages/kbn-utility-types/test-d/method_keys_of.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.
*/

import { expectType } from 'tsd';
import { MethodKeysOf } from '../index';

class Test {
public name: string = '';
getName() {
return this.name;
}
// @ts-ignore
private getDoubleName() {
return this.name.repeat(2);
}
}

expectType<MethodKeysOf<Test>>('getName');
50 changes: 50 additions & 0 deletions packages/kbn-utility-types/test-d/public_methods_of.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.
*/

import { expectAssignable, expectNotAssignable } from 'tsd';
import { PublicMethodsOf } from '../index';

class Test {
public name: string = '';
getName() {
return this.name;
}
// @ts-ignore
private getDoubleName() {
return this.name.repeat(2);
}
}

expectAssignable<PublicMethodsOf<Test>>({
getName() {
return '';
},
});

expectNotAssignable<PublicMethodsOf<Test>>({
getName() {
return 1;
},
});

expectNotAssignable<PublicMethodsOf<Test>>({
getDoubleName() {
return 1;
},
});
29 changes: 29 additions & 0 deletions packages/kbn-utility-types/test-d/writable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.
*/

import { expectAssignable } from 'tsd';
import { Writable } from '../index';

type WritableArray = Writable<readonly string[]>;
expectAssignable<WritableArray>(['1']);

type WritableObject = Writable<{
readonly name: string;
}>;
expectAssignable<WritableObject>({ name: '1' });
5 changes: 3 additions & 2 deletions packages/kbn-utility-types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"stripInternal": true,
"declarationMap": true,
"types": [
"node"
"node",
"jest"
]
},
"include": ["index.ts", "test-d/**/*"],
"include": ["index.ts", "jest/**/*", "test-d/**/*"],
"exclude": [
"target"
]
Expand Down
1 change: 1 addition & 0 deletions src/core/public/apm_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

jest.mock('@elastic/apm-rum');
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { init, apm } from '@elastic/apm-rum';
import { ApmSystem } from './apm_system';

Expand Down
1 change: 1 addition & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './';

const createStartContractMock = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import type { MockedKeys } from '@kbn/utility-types/jest';
import {
NotificationsService,
NotificationsSetup,
Expand Down
1 change: 1 addition & 0 deletions src/core/public/overlays/overlay_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { OverlayService, OverlayStart } from './overlay_service';
import { overlayBannersServiceMock } from './banners/banners_service.mock';
import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock';
Expand Down
1 change: 1 addition & 0 deletions src/core/server/core_context.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { REPO_ROOT } from '@kbn/dev-utils';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { CoreContext } from './core_context';
import { Env, IConfigService } from './config';
import { configServiceMock, getEnvOptions } from './config/mocks';
Expand Down
Loading

0 comments on commit 467ea47

Please sign in to comment.