Update to TS v4 (#73924) (#76069)

* bump ts to v4

* MOAR RAM

* fix type errors for OSS

* first pass on x-pack errors

* second pass on x-pack type errors

* 3rd pass on x-pack type-errors

* mute errors if complex cases

* don't delete if spread suffices

* mute other complex cases

* make User fields optional

* fix optional types

* fix tests

* fix typings for time_range

* fix type errors in x-pack/tests

* rebuild kbn-pm

* remove leftovers from master update

* fix alert tests

* [Telemetry Checker] TS4 Fixes

* bump to 4.0.1-rc

* fix new errors in master

* bump typescript-eslint to version supporting TS v4 syntax

* fix merge commit errors

* update to the stable TS version 4.0.2

* bump ts-eslint to version supporting ts v4

* fix typo

* fix type errors after merge

* update ts in another new package.json

* TEMP: remove me

* Revert "TEMP: remove me"

This reverts commit dc0fc3bae6.

* [Telemetry] Update snapshot for new TS4 SyntaxKind

* bump prettier to support TS v4 syntax

* fix prettier rules

* last style change

* fix new type errors

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
# Conflicts:
#	packages/kbn-i18n/package.json
#	x-pack/plugins/uptime/public/components/settings/add_connector_flyout.tsx
#	x-pack/plugins/uptime/public/components/settings/alert_defaults_form.tsx
This commit is contained in:
Mikhail Shustov 2020-08-27 13:21:43 +03:00 committed by GitHub
parent 02b6ceaff5
commit 1c1dbe5c95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
193 changed files with 551 additions and 316 deletions

View file

@ -60,7 +60,8 @@ function getHasMatch(search?: string, savedAttributes?: BookSavedObjectAttribute
);
}
export class BookEmbeddable extends Embeddable<BookEmbeddableInput, BookEmbeddableOutput>
export class BookEmbeddable
extends Embeddable<BookEmbeddableInput, BookEmbeddableOutput>
implements ReferenceOrValueEmbeddable<BookByValueInput, BookByReferenceInput> {
public readonly type = BOOK_EMBEDDABLE;
private subscription: Subscription;

View file

@ -83,7 +83,7 @@
"**/@types/chai": "^4.2.11",
"**/cypress/@types/lodash": "^4.14.159",
"**/cypress/lodash": "^4.17.20",
"**/typescript": "3.9.5",
"**/typescript": "4.0.2",
"**/graphql-toolkit/lodash": "^4.17.15",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-git/**/base64-js": "^1.2.1",
@ -333,8 +333,8 @@
"@types/vinyl": "^2.0.4",
"@types/vinyl-fs": "^2.4.11",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"angular-aria": "^1.8.0",
"angular-mocks": "^1.7.9",
"angular-recursion": "^1.0.5",
@ -376,7 +376,7 @@
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-react-perf": "^3.2.3",
@ -438,7 +438,7 @@
"pkg-up": "^2.0.0",
"pngjs": "^3.4.0",
"postcss": "^7.0.32",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"prop-types": "15.6.0",
"proxyquire": "1.8.0",
"react-grid-layout": "^0.16.2",
@ -464,7 +464,7 @@
"tape": "^4.13.0",
"topojson-client": "3.0.0",
"tree-kill": "^1.2.2",
"typescript": "3.9.5",
"typescript": "4.0.2",
"typings-tester": "^0.3.2",
"ui-select": "0.19.8",
"vega": "^5.13.0",

View file

@ -15,8 +15,8 @@
},
"homepage": "https://github.com/elastic/kibana/tree/master/packages/eslint-config-kibana",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0",
"eslint-plugin-babel": "^5.3.0",

View file

@ -17,6 +17,6 @@
"@babel/cli": "^7.10.5",
"@kbn/dev-utils": "1.0.0",
"@kbn/babel-preset": "1.0.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -10,7 +10,7 @@
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"typescript": "3.9.5",
"typescript": "4.0.2",
"tsd": "^0.7.4"
},
"peerDependencies": {

View file

@ -25,7 +25,7 @@
"tslib": "^2.0.0"
},
"devDependencies": {
"typescript": "3.9.5",
"typescript": "4.0.2",
"@kbn/expect": "1.0.0",
"chance": "1.0.18"
}

View file

@ -21,7 +21,7 @@
"del": "^5.1.0",
"getopts": "^2.2.4",
"supports-color": "^6.1.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
},
"dependencies": {
"intl-format-cache": "^2.1.0",

View file

@ -20,7 +20,7 @@
"del": "^5.1.0",
"raw-loader": "3.1.0",
"supports-color": "^7.0.0",
"typescript": "3.9.5",
"typescript": "4.0.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
}

View file

@ -14,7 +14,7 @@
"execa": "^4.0.2",
"inquirer": "^7.3.3",
"normalize-path": "^3.0.0",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"vinyl": "^2.2.0",
"vinyl-fs": "^3.0.3"
},

View file

@ -35,7 +35,7 @@
"@types/through2": "^2.0.35",
"@types/through2-map": "^3.0.0",
"@types/vinyl": "^2.0.4",
"typescript": "3.9.5"
"typescript": "4.0.2"
},
"peerDependencies": {
"@kbn/babel-preset": "1.0.0"

View file

@ -562,6 +562,7 @@ module.exports = require("path");
* under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolingLogCollectingWriter = exports.parseLogLevel = exports.pickLevelFromFlags = exports.ToolingLogTextWriter = exports.ToolingLog = void 0;
var tooling_log_1 = __webpack_require__(6);
Object.defineProperty(exports, "ToolingLog", { enumerable: true, get: function () { return tooling_log_1.ToolingLog; } });
var tooling_log_text_writer_1 = __webpack_require__(110);

View file

@ -51,7 +51,7 @@
"multimatch": "^4.0.0",
"ncp": "^2.0.0",
"ora": "^1.4.0",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"read-pkg": "^5.2.0",
"rxjs": "^6.5.5",
"spawn-sync": "^1.0.15",
@ -59,7 +59,7 @@
"strip-ansi": "^4.0.0",
"strong-log-transformer": "^2.1.0",
"tempy": "^0.3.0",
"typescript": "3.9.5",
"typescript": "4.0.2",
"unlazy-loader": "^0.1.3",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",

View file

@ -18,6 +18,6 @@
},
"devDependencies": {
"markdown-it": "^10.0.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}
}

View file

@ -18,7 +18,7 @@
"homepage": "https://github.com/jbudz/spec-to-console#readme",
"devDependencies": {
"jest": "^25.5.4",
"prettier": "^2.0.5"
"prettier": "^2.1.1"
},
"dependencies": {
"commander": "^2.11.0",

View file

@ -17,6 +17,6 @@
"normalize-path": "^3.0.0",
"@types/lodash": "^3.10.1",
"moment": "^2.24.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -9,7 +9,7 @@ Array [
"fetch": Object {
"typeDescriptor": Object {
"locale": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
},
@ -31,7 +31,7 @@ Array [
"fetch": Object {
"typeDescriptor": Object {
"locale": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
},
@ -53,7 +53,7 @@ Array [
"fetch": Object {
"typeDescriptor": Object {
"locale": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
},
@ -75,7 +75,7 @@ Array [
"fetch": Object {
"typeDescriptor": Object {
"locale": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
},
@ -99,11 +99,11 @@ Array [
"": Object {
"@@INDEX@@": Object {
"count_1": Object {
"kind": 140,
"kind": 143,
"type": "NumberKeyword",
},
"count_2": Object {
"kind": 140,
"kind": 143,
"type": "NumberKeyword",
},
},
@ -129,7 +129,7 @@ Array [
"fetch": Object {
"typeDescriptor": Object {
"locale": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
},
@ -151,43 +151,43 @@ Array [
"fetch": Object {
"typeDescriptor": Object {
"flat": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
"my_array": Object {
"total": Object {
"kind": 140,
"kind": 143,
"type": "NumberKeyword",
},
"type": Object {
"kind": 128,
"kind": 131,
"type": "BooleanKeyword",
},
},
"my_index_signature_prop": Object {
"": Object {
"@@INDEX@@": Object {
"kind": 140,
"kind": 143,
"type": "NumberKeyword",
},
},
},
"my_objects": Object {
"total": Object {
"kind": 140,
"kind": 143,
"type": "NumberKeyword",
},
"type": Object {
"kind": 128,
"kind": 131,
"type": "BooleanKeyword",
},
},
"my_str": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
"my_str_array": Object {
"kind": 143,
"kind": 146,
"type": "StringKeyword",
},
},

View file

@ -142,14 +142,11 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
}
if (ts.isUnionTypeNode(node)) {
const types = node.types.filter((typeNode) => {
return (
typeNode.kind !== ts.SyntaxKind.NullKeyword &&
typeNode.kind !== ts.SyntaxKind.UndefinedKeyword
);
});
const types = node.types.filter(discardNullOrUndefined);
const kinds = types.map((typeNode) => getDescriptor(typeNode, program));
const kinds = types
.map((typeNode) => getDescriptor(typeNode, program))
.filter(discardNullOrUndefined);
const uniqueKinds = uniq(kinds, 'kind');
@ -172,3 +169,9 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
throw new Error(`Unknown type ${ts.SyntaxKind[node.kind]}; ${node.getText()}`);
}
}
function discardNullOrUndefined(typeNode: ts.TypeNode | Descriptor | DescriptorValue) {
return (
typeNode.kind !== ts.SyntaxKind.NullKeyword && typeNode.kind !== ts.SyntaxKind.UndefinedKeyword
);
}

View file

@ -31,7 +31,7 @@ export default {
hits: [],
},
aggregations: {
'1': {
1: {
buckets: [
{
key_as_string: '2015-01-30T01:00:00.000Z',

View file

@ -31,7 +31,7 @@ export default {
hits: [],
},
aggregations: {
'1': {
1: {
buckets: {
'*-1024.0': {
to: 1024,

View file

@ -100,8 +100,8 @@ describe('Metrics', function () {
Object.defineProperty(process, 'pid', { get: pidMock }); //
const hapiEvent = {
requests: { '5603': { total: 22, disconnects: 0, statusCodes: { '200': 22 } } },
responseTimes: { '5603': { avg: 1.8636363636363635, max: 4 } },
requests: { 5603: { total: 22, disconnects: 0, statusCodes: { 200: 22 } } },
responseTimes: { 5603: { avg: 1.8636363636363635, max: 4 } },
osload: [2.20751953125, 2.02294921875, 1.89794921875],
osmem: { total: 17179869184, free: 102318080 },
osup: 1008991,
@ -150,9 +150,9 @@ describe('Metrics', function () {
it('parses event with missing fields / NaN for responseTimes.avg', async () => {
const hapiEvent = {
requests: {
'5603': { total: 22, disconnects: 0, statusCodes: { '200': 22 } },
5603: { total: 22, disconnects: 0, statusCodes: { 200: 22 } },
},
responseTimes: { '5603': { avg: NaN, max: 4 } },
responseTimes: { 5603: { avg: NaN, max: 4 } },
host: 'blahblah.local',
};

View file

@ -243,7 +243,7 @@ export class AdvancedSettingsComponent extends Component<
}
export const AdvancedSettings = (props: AdvancedSettingsProps) => {
const { query } = useParams();
const { query } = useParams<{ query: string }>();
return (
<AdvancedSettingsComponent
queryText={query || ''}

View file

@ -93,7 +93,7 @@ describe('Url autocomplete', () => {
(function () {
const endpoints = {
'1': {
1: {
patterns: ['a/b'],
methods: ['GET'],
},
@ -125,11 +125,11 @@ describe('Url autocomplete', () => {
(function () {
const endpoints = {
'1': {
1: {
patterns: ['a/b', 'a/b/{p}'],
methods: ['GET'],
},
'2': {
2: {
patterns: ['a/c'],
methods: ['GET'],
},
@ -176,14 +176,14 @@ describe('Url autocomplete', () => {
(function () {
const endpoints = {
'1': {
1: {
patterns: ['a/{p}'],
url_components: {
p: ['a', 'b'],
},
methods: ['GET'],
},
'2': {
2: {
patterns: ['a/c'],
methods: ['GET'],
},
@ -230,18 +230,18 @@ describe('Url autocomplete', () => {
(function () {
const endpoints = {
'1': {
1: {
patterns: ['a/{p}'],
url_components: {
p: ['a', 'b'],
},
methods: ['GET'],
},
'2': {
2: {
patterns: ['b/{p}'],
methods: ['GET'],
},
'3': {
3: {
patterns: ['b/{l}/c'],
methods: ['GET'],
url_components: {
@ -315,7 +315,7 @@ describe('Url autocomplete', () => {
(function () {
const endpoints = {
'1': {
1: {
patterns: ['a/b/{p}/c/e'],
methods: ['GET'],
},

View file

@ -53,7 +53,7 @@ interface DashboardAttributes extends SavedObjectAttributes {
interface DashboardAttributesTo720 extends SavedObjectAttributes {
panelsJSON: string;
description: string;
uiStateJSON: string;
uiStateJSON?: string;
version: number;
timeRestore: boolean;
useMargins?: boolean;

View file

@ -464,6 +464,7 @@ export class DashboardAppController {
);
} else if ('input' in incomingEmbeddable) {
const input = incomingEmbeddable.input;
// @ts-expect-error
delete input.id;
const explicitInput = {
savedVis: input,

View file

@ -350,12 +350,14 @@ describe('kuery AST API', () => {
expect(toElasticsearchQuery((null as unknown) as KueryNode, undefined)).toEqual(expected);
const noTypeNode = nodeTypes.function.buildNode('exists', 'foo');
// @ts-expect-error
delete noTypeNode.type;
expect(toElasticsearchQuery(noTypeNode)).toEqual(expected);
const unknownTypeNode = nodeTypes.function.buildNode('exists', 'foo');
// @ts-ignore
// @ts-expect-error
unknownTypeNode.type = 'notValid';
expect(toElasticsearchQuery(unknownTypeNode)).toEqual(expected);
});

View file

@ -78,7 +78,8 @@ interface SearchEmbeddableConfig {
filterManager: FilterManager;
}
export class SearchEmbeddable extends Embeddable<SearchInput, SearchOutput>
export class SearchEmbeddable
extends Embeddable<SearchInput, SearchOutput>
implements ISearchEmbeddable {
private readonly savedSearch: SavedSearch;
private $rootScope: ng.IRootScopeService;

View file

@ -35,10 +35,11 @@ import { isSavedObjectEmbeddableInput } from '../embeddables/saved_object_embedd
const getKeys = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;
export abstract class Container<
TChildInput extends Partial<EmbeddableInput> = {},
TContainerInput extends ContainerInput<TChildInput> = ContainerInput<TChildInput>,
TContainerOutput extends ContainerOutput = ContainerOutput
> extends Embeddable<TContainerInput, TContainerOutput>
TChildInput extends Partial<EmbeddableInput> = {},
TContainerInput extends ContainerInput<TChildInput> = ContainerInput<TChildInput>,
TContainerOutput extends ContainerOutput = ContainerOutput
>
extends Embeddable<TContainerInput, TContainerOutput>
implements IContainer<TChildInput, TContainerInput, TContainerOutput> {
public readonly isContainer: boolean = true;
protected readonly children: {

View file

@ -122,7 +122,7 @@ test('<KibanaContextProvider> provider provides default kibana-react context', (
test('<KibanaContextProvider> can set custom services in context', () => {
const Test: React.FC = () => {
const { services } = useKibana();
const { services } = useKibana<{ test: string }>();
expect(services.test).toBe('quux');
return null;
};
@ -137,7 +137,7 @@ test('<KibanaContextProvider> can set custom services in context', () => {
test('nested <KibanaContextProvider> override and merge services', () => {
const Test: React.FC = () => {
const { services } = useKibana();
const { services } = useKibana<{ foo: string; bar: string; baz: string }>();
expect(services.foo).toBe('foo2');
expect(services.bar).toBe('bar');
expect(services.baz).toBe('baz3');

View file

@ -43,11 +43,13 @@ export function getOpsStatsCollector(
metrics$.subscribe((_metrics) => {
const metrics = cloneDeep(_metrics);
// Ensure we only include the same data that Metricbeat collection would get
// @ts-expect-error
delete metrics.process.pid;
const responseTimes = {
average: metrics.response_times.avg_in_millis,
max: metrics.response_times.max_in_millis,
};
// @ts-expect-error
delete metrics.requests.statusCodes;
lastMetrics = {
...metrics,

View file

@ -22,18 +22,18 @@ import _ from 'lodash';
// geohash precision mapping of geohash grid cell dimensions (width x height, in meters) at equator.
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator
const gridAtEquator = {
'1': [5009400, 4992600],
'2': [1252300, 624100],
'3': [156500, 156000],
'4': [39100, 19500],
'5': [4900, 4900],
'6': [1200, 609.4],
'7': [152.9, 152.4],
'8': [38.2, 19],
'9': [4.8, 4.8],
'10': [1.2, 0.595],
'11': [0.149, 0.149],
'12': [0.037, 0.019],
1: [5009400, 4992600],
2: [1252300, 624100],
3: [156500, 156000],
4: [39100, 19500],
5: [4900, 4900],
6: [1200, 609.4],
7: [152.9, 152.4],
8: [38.2, 19],
9: [4.8, 4.8],
10: [1.2, 0.595],
11: [0.149, 0.149],
12: [0.037, 0.019],
};
export function gridDimensions(precision) {

View file

@ -55,7 +55,7 @@ export interface ShareContext {
* */
export interface ShareContextMenuPanelItem extends Omit<EuiContextMenuPanelItemDescriptor, 'name'> {
name: string; // EUI will accept a `ReactNode` for the `name` prop, but `ShareContentMenu` assumes a `string`.
sortOrder: number;
sortOrder?: number;
}
/**

View file

@ -22,8 +22,9 @@ import React, { useEffect, useCallback, useState } from 'react';
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow, EuiLink, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { IAggType, IndexPattern } from 'src/plugins/data/public';
import { DocLinksStart } from '../../../../core/public';
import { useKibana } from '../../../kibana_react/public';
import { ComboBoxGroupedOptions } from '../utils';
import { AGG_TYPE_ACTION_KEYS, AggTypeAction } from './agg_params_state';
@ -52,7 +53,7 @@ function DefaultEditorAggSelect({
onChangeAggType,
}: DefaultEditorAggSelectProps) {
const [isDirty, setIsDirty] = useState(false);
const { services } = useKibana();
const { services } = useKibana<{ docLinks: DocLinksStart }>();
const selectedOptions: ComboBoxGroupedOptions<IAggType> = value
? [{ label: value.title, target: value }]
: [];
@ -71,6 +72,7 @@ function DefaultEditorAggSelect({
let aggHelpLink: string | undefined;
if (has(value, 'name')) {
// @ts-expect-error
aggHelpLink = services.docLinks.links.aggs[value.name];
}

View file

@ -37,6 +37,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { isEqual, omit } from 'lodash';
import { useMount } from 'react-use';
import { DocLinksStart } from 'src/core/public';
import { useKibana } from '../../../../kibana_react/public';
import { AggParamEditorProps } from '../agg_param_props';
@ -67,7 +68,7 @@ function DateRangesParamEditor({
setValue,
setValidity,
}: AggParamEditorProps<DateRangeValues[]>) {
const { services } = useKibana();
const { services } = useKibana<{ docLinks: DocLinksStart }>();
const [ranges, setRanges] = useState(() =>
value.map((range) => ({ ...range, id: generateId() }))
);

View file

@ -21,7 +21,12 @@ import React, { useState } from 'react';
import { EuiForm, EuiButtonIcon, EuiFieldText, EuiFormRow, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { IAggConfig, Query, QueryStringInput } from '../../../../data/public';
import {
IAggConfig,
Query,
QueryStringInput,
DataPublicPluginStart,
} from '../../../../data/public';
import { useKibana } from '../../../../kibana_react/public';
interface FilterRowProps {
@ -49,7 +54,7 @@ function FilterRow({
onChangeValue,
onRemoveFilter,
}: FilterRowProps) {
const { services } = useKibana();
const { services } = useKibana<{ data: DataPublicPluginStart; appName: string }>();
const [showCustomLabel, setShowCustomLabel] = useState(false);
const filterLabel = i18n.translate('visDefaultEditor.controls.filters.filterLabel', {
defaultMessage: 'Filter {index}',

View file

@ -23,7 +23,8 @@ import { htmlIdGenerator, EuiButton, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { useMount } from 'react-use';
import { Query } from '../../../../data/public';
import { Query, DataPublicPluginStart } from '../../../../data/public';
import { IUiSettingsClient } from '../../../../../core/public';
import { useKibana } from '../../../../kibana_react/public';
import { FilterRow } from './filter';
import { AggParamEditorProps } from '../agg_param_props';
@ -64,7 +65,7 @@ function FiltersParamEditor({ agg, value = [], setValue }: AggParamEditorProps<F
setFilters(updatedFilters);
};
const { services } = useKibana();
const { services } = useKibana<{ uiSettings: IUiSettingsClient; data: DataPublicPluginStart }>();
const onAddFilter = () =>
updateFilters([

View file

@ -21,12 +21,13 @@ import React from 'react';
import { EuiRange, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { IUiSettingsClient } from '../../../../../core/public';
import { useKibana } from '../../../../kibana_react/public';
import { AggParamEditorProps } from '../agg_param_props';
function PrecisionParamEditor({ agg, value, setValue }: AggParamEditorProps<number>) {
const { services } = useKibana();
const { services } = useKibana<{ uiSettings: IUiSettingsClient }>();
const label = i18n.translate('visDefaultEditor.controls.precisionLabel', {
defaultMessage: 'Precision',
});

View file

@ -37,6 +37,7 @@ import { i18n } from '@kbn/i18n';
import { Vis } from 'src/plugins/visualizations/public';
import { SavedObject } from 'src/plugins/saved_objects/public';
import { ApplicationStart } from '../../../../../core/public';
import { useKibana } from '../../../../kibana_react/public';
interface LinkedSearchProps {
@ -55,7 +56,7 @@ export function LinkedSearch({ savedSearch, eventEmitter }: LinkedSearchProps) {
const [showPopover, setShowPopover] = useState(false);
const {
services: { application },
} = useKibana();
} = useKibana<{ application: ApplicationStart }>();
const closePopover = useCallback(() => setShowPopover(false), []);
const onClickButtonLink = useCallback(() => setShowPopover((v) => !v), []);

View file

@ -63,7 +63,7 @@ interface Mark {
type Renderer = 'svg' | 'canvas';
interface VegaSpecConfig extends KibanaConfig {
kibana: KibanaConfig;
kibana?: KibanaConfig;
padding: Padding;
projection: Projection;
autosize: AutoSize;
@ -103,8 +103,8 @@ export interface VegaSpec {
encoding?: Encoding;
mark?: string;
title?: string;
autosize: AutoSize;
projections: Projection[];
autosize?: AutoSize;
projections?: Projection[];
width?: number;
height?: number;
padding?: number | Padding;

View file

@ -243,13 +243,13 @@ The URL is an identifier only. Kibana and your browser will never access this UR
// and will be automatically updated on resize events.
// We delete width & height if the autosize is set to "fit"
// We also set useResize=true in case autosize=none, and width & height are not set
const autosize = this.spec.autosize.type || this.spec.autosize;
const autosize = this.spec.autosize?.type || this.spec.autosize;
if (autosize === 'fit' || (autosize === 'none' && !this.spec.width && !this.spec.height)) {
this.useResize = true;
}
}
if (this.useResize && this.spec.padding && this.spec.autosize.contains !== 'padding') {
if (this.useResize && this.spec.padding && this.spec.autosize?.contains !== 'padding') {
if (typeof this.spec.padding === 'object') {
this.paddingWidth += (+this.spec.padding.left || 0) + (+this.spec.padding.right || 0);
this.paddingHeight += (+this.spec.padding.top || 0) + (+this.spec.padding.bottom || 0);

View file

@ -113,6 +113,7 @@ export const buildPointSeriesData = (table: Table, dimensions: Dimensions) => {
chart.series = getSeries(table, chart);
// @ts-expect-error
delete chart.aspects;
return chart;
};

View file

@ -33,6 +33,7 @@ describe('React Vis Type', () => {
it('should throw if component is not set', () => {
expect(() => {
const missingConfig = cloneDeep(visConfig);
// @ts-expect-error TS knows it's a required property
delete missingConfig.visConfig.component;
new ReactVisType(missingConfig);
}).toThrow();

View file

@ -34,7 +34,7 @@ import { VisualizeServices } from '../types';
import { VisualizeEditorCommon } from './visualize_editor_common';
export const VisualizeEditor = () => {
const { id: visualizationIdFromUrl } = useParams();
const { id: visualizationIdFromUrl } = useParams<{ id: string }>();
const [originatingApp, setOriginatingApp] = useState<string>();
const { services } = useKibana<VisualizeServices>();
const [eventEmitter] = useState(new EventEmitter());

View file

@ -149,6 +149,7 @@ describe('useSavedVisInstance', () => {
pathname: VisualizeConstants.CREATE_PATH,
search: '?type=area&indexPattern=1a2b3c4d',
};
// @ts-ignore-error
delete mockSavedVisInstance.savedVis.id;
});

View file

@ -16,6 +16,6 @@
"@kbn/plugin-helpers": "9.0.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -10,6 +10,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}
}

View file

@ -14,6 +14,6 @@
"devDependencies": {
"@elastic/eui": "27.4.1",
"react": "^16.12.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,7 +12,7 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -15,6 +15,6 @@
"@elastic/eui": "27.4.1",
"@kbn/plugin-helpers": "9.0.2",
"react": "^16.12.0",
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.9.5"
"typescript": "4.0.2"
}
}

View file

@ -259,7 +259,7 @@
"topojson-client": "3.0.0",
"tree-kill": "^1.2.2",
"ts-loader": "^6.0.4",
"typescript": "3.9.5",
"typescript": "4.0.2",
"typescript-fsa": "^3.0.0",
"typescript-fsa-reducers": "^1.2.1",
"unstated": "^2.1.1",

View file

@ -76,8 +76,11 @@ describe('send_email module', () => {
rejectUnauthorizedCertificates: false,
}
);
// @ts-expect-error
delete sendEmailOptions.transport.service;
// @ts-expect-error
delete sendEmailOptions.transport.user;
// @ts-expect-error
delete sendEmailOptions.transport.password;
const result = await sendEmail(mockLogger, sendEmailOptions);
expect(result).toBe(sendMailMockResult);
@ -123,8 +126,11 @@ describe('send_email module', () => {
port: 1025,
},
});
// @ts-expect-error
delete sendEmailOptions.transport.service;
// @ts-expect-error
delete sendEmailOptions.transport.user;
// @ts-expect-error
delete sendEmailOptions.transport.password;
const result = await sendEmail(mockLogger, sendEmailOptions);
expect(result).toBe(sendMailMockResult);
@ -166,8 +172,11 @@ describe('send_email module', () => {
secure: true,
},
});
// @ts-expect-error
delete sendEmailOptions.transport.service;
// @ts-expect-error
delete sendEmailOptions.transport.user;
// @ts-expect-error
delete sendEmailOptions.transport.password;
const result = await sendEmail(mockLogger, sendEmailOptions);

View file

@ -9,7 +9,8 @@ import { ErrorThatHandlesItsOwnResponse } from './types';
export type PreconfiguredActionDisabledFrom = 'update' | 'delete';
export class PreconfiguredActionDisabledModificationError extends Error
export class PreconfiguredActionDisabledModificationError
extends Error
implements ErrorThatHandlesItsOwnResponse {
public readonly disabledFrom: PreconfiguredActionDisabledFrom;

View file

@ -316,22 +316,13 @@ function alertTypeWithVariables(id: string, context: string, state: string): Ale
producer: 'alerts',
};
if (!context && !state) {
return baseAlert;
}
if (!context && !state) return baseAlert;
const actionVariables = {
context: [{ name: context, description: `${id} context` }],
state: [{ name: state, description: `${id} state` }],
return {
...baseAlert,
actionVariables: {
...(context ? { context: [{ name: context, description: `${id} context` }] } : {}),
...(state ? { state: [{ name: state, description: `${id} state` }] } : {}),
},
};
if (!context) {
delete actionVariables.context;
}
if (!state) {
delete actionVariables.state;
}
return { ...baseAlert, actionVariables };
}

View file

@ -17,7 +17,7 @@
"p-limit": "^3.0.1",
"p-retry": "^4.2.0",
"ts-loader": "^7.0.5",
"typescript": "3.9.6",
"typescript": "4.0.2",
"wait-on": "^5.0.1",
"webpack": "^4.43.0",
"yargs": "^15.4.0"

View file

@ -74,6 +74,7 @@ Array [
const location = getLocation();
const routes = getTestRoutes();
// @ts-expect-error
delete routes[2].breadcrumb;
const breadcrumbs = getBreadcrumbs({ location, routes });

View file

@ -145,8 +145,8 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
defaultMessage: 'Error rate',
}),
iconClass: 'bell',
alertParamsExpression: lazy(() =>
import('./components/shared/ErrorRateAlertTrigger')
alertParamsExpression: lazy(
() => import('./components/shared/ErrorRateAlertTrigger')
),
validate: () => ({
errors: [],
@ -160,8 +160,8 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
defaultMessage: 'Transaction duration',
}),
iconClass: 'bell',
alertParamsExpression: lazy(() =>
import('./components/shared/TransactionDurationAlertTrigger')
alertParamsExpression: lazy(
() => import('./components/shared/TransactionDurationAlertTrigger')
),
validate: () => ({
errors: [],

View file

@ -110,6 +110,7 @@ export async function transactionGroupsFetcher(
const isTopTraces = options.type === 'top_traces';
// @ts-expect-error
delete projection.body.aggs;
// traces overview is hardcoded to 10000

View file

@ -52,10 +52,9 @@ export async function getLocalUIFilters({
buckets.map((bucket) => {
return {
name: bucket.key as string,
count:
'bucket_count' in bucket
? bucket.bucket_count.value
: bucket.doc_count,
count: bucket.bucket_count
? bucket.bucket_count.value
: bucket.doc_count,
};
}),
'count',

View file

@ -41,7 +41,7 @@ export interface CMBeat {
status?: BeatEvent;
enrollment_token: string;
active: boolean;
access_token: string;
access_token?: string;
verified_on?: string;
type: string;
version?: string;

View file

@ -72,7 +72,7 @@ export class CMBeatsDomain {
if (typeof userOrToken === 'string') {
const { verified: isAccessTokenValid } = this.tokens.verifyToken(
beat ? beat.access_token : '',
beat?.access_token ?? '',
userOrToken
);
if (!isAccessTokenValid) {

View file

@ -106,18 +106,18 @@ const cornerVertices = [
const resizeMultiplierHorizontal = { left: -1, center: 0, right: 1 };
const resizeMultiplierVertical = { top: -1, center: 0, bottom: 1 };
const xNames = { '-1': 'left', '0': 'center', '1': 'right' };
const yNames = { '-1': 'top', '0': 'center', '1': 'bottom' };
const xNames = { '-1': 'left', 0: 'center', 1: 'right' };
const yNames = { '-1': 'top', 0: 'center', 1: 'bottom' };
const bidirectionalCursors = {
'0': 'ns-resize',
'45': 'nesw-resize',
'90': 'ew-resize',
'135': 'nwse-resize',
'180': 'ns-resize',
'225': 'nesw-resize',
'270': 'ew-resize',
'315': 'nwse-resize',
0: 'ns-resize',
45: 'nesw-resize',
90: 'ew-resize',
135: 'nwse-resize',
180: 'ns-resize',
225: 'nesw-resize',
270: 'ew-resize',
315: 'nwse-resize',
};
const identityAABB = () => [

View file

@ -12,7 +12,7 @@ describe('getSiblingContext', () => {
resolvedArgs: {
'element-foo': {
expressionContext: {
'0': {
0: {
state: 'ready',
value: {
type: 'datatable',
@ -28,7 +28,7 @@ describe('getSiblingContext', () => {
},
error: null,
},
'1': {
1: {
state: 'ready',
value: {
type: 'datatable',
@ -44,7 +44,7 @@ describe('getSiblingContext', () => {
},
error: null,
},
'2': {
2: {
state: 'ready',
value: {
type: 'pointseries',

View file

@ -162,22 +162,22 @@ describe('resolved args reducer', () => {
resolvedArgs: {
'element-1': {
expressionContext: {
'1': {
1: {
state: 'ready',
value: 'test-1',
error: null,
},
'2': {
2: {
state: 'ready',
value: 'test-2',
error: null,
},
'3': {
3: {
state: 'ready',
value: 'test-3',
error: null,
},
'4': {
4: {
state: 'ready',
value: 'test-4',
error: null,

View file

@ -156,6 +156,7 @@ describe('"Explore underlying data" panel action', () => {
test('returns false if embeddable does not have index patterns', async () => {
const { action, output, context } = setup();
// @ts-expect-error
delete output.indexPatterns;
const isCompatible = await action.isCompatible(context);

View file

@ -25,7 +25,8 @@ export const ACTION_EXPLORE_DATA_CHART = 'ACTION_EXPLORE_DATA_CHART';
* This is "Explore underlying data" action which appears in popup context
* menu when user clicks a value in visualization or brushes a time range.
*/
export class ExploreDataChartAction extends AbstractExploreDataAction<ExploreDataChartActionContext>
export class ExploreDataChartAction
extends AbstractExploreDataAction<ExploreDataChartActionContext>
implements Action<ExploreDataChartActionContext> {
public readonly id = ACTION_EXPLORE_DATA_CHART;

View file

@ -140,6 +140,7 @@ describe('"Explore underlying data" panel action', () => {
test('returns false if embeddable does not have index patterns', async () => {
const { action, output, context } = setup();
// @ts-expect-error
delete output.indexPatterns;
const isCompatible = await action.isCompatible(context);

View file

@ -17,7 +17,8 @@ export const ACTION_EXPLORE_DATA = 'ACTION_EXPLORE_DATA';
* This is "Explore underlying data" action which appears in the context
* menu of a dashboard panel.
*/
export class ExploreDataContextMenuAction extends AbstractExploreDataAction<EmbeddableContext>
export class ExploreDataContextMenuAction
extends AbstractExploreDataAction<EmbeddableContext>
implements Action<EmbeddableContext> {
public readonly id = ACTION_EXPLORE_DATA;

View file

@ -101,6 +101,7 @@ describe('<EditPolicy />', () => {
},
},
};
delete expected.phases.delete.actions.wait_for_snapshot;
const latestRequest = server.requests[server.requests.length - 1];

View file

@ -90,6 +90,7 @@ export const coldPhaseToES = (
};
} else {
if (esPhase.actions.allocate) {
// @ts-expect-error
delete esPhase.actions.allocate.require;
}
}
@ -99,6 +100,7 @@ export const coldPhaseToES = (
esPhase.actions.allocate.number_of_replicas = parseInt(phase.selectedReplicaCount, 10);
} else {
if (esPhase.actions.allocate) {
// @ts-expect-error
delete esPhase.actions.allocate.number_of_replicas;
}
}

View file

@ -96,6 +96,7 @@ export const warmPhaseToES = (
// An index lifecycle switches to warm phase when rollover occurs, so you cannot specify a warm phase time
// They are mutually exclusive
if (phase.warmPhaseOnRollover) {
// @ts-expect-error
delete esPhase.min_age;
}
@ -109,6 +110,7 @@ export const warmPhaseToES = (
};
} else {
if (esPhase.actions.allocate) {
// @ts-expect-error
delete esPhase.actions.allocate.require;
}
}
@ -118,6 +120,7 @@ export const warmPhaseToES = (
esPhase.actions.allocate.number_of_replicas = parseInt(phase.selectedReplicaCount, 10);
} else {
if (esPhase.actions.allocate) {
// @ts-expect-error
delete esPhase.actions.allocate.number_of_replicas;
}
}

View file

@ -180,6 +180,7 @@ export const TemplateForm = ({
delete outputTemplate.template.aliases;
}
if (Object.keys(outputTemplate.template).length === 0) {
// @ts-expect-error
delete outputTemplate.template;
}

View file

@ -5,6 +5,8 @@
*/
import React, { useContext } from 'react';
import { ApplicationStart, DocLinksStart, HttpStart, NotificationsStart } from 'src/core/public';
import { AlertsContextProvider, AlertAdd } from '../../../../../triggers_actions_ui/public';
import { TriggerActionsContext } from '../../../utils/triggers_actions_context';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
@ -22,9 +24,16 @@ interface Props {
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
}
interface KibanaDeps {
notifications: NotificationsStart;
http: HttpStart;
docLinks: DocLinksStart;
application: ApplicationStart;
}
export const AlertFlyout = ({ options, nodeType, filter, visible, setVisible }: Props) => {
const { triggersActionsUI } = useContext(TriggerActionsContext);
const { services } = useKibana();
const { services } = useKibana<KibanaDeps>();
const { inventoryPrefill } = useAlertPrefillContext();
const { customMetrics } = inventoryPrefill;

View file

@ -5,6 +5,8 @@
*/
import React, { useContext } from 'react';
import { ApplicationStart, DocLinksStart, HttpStart, NotificationsStart } from 'src/core/public';
import { AlertsContextProvider, AlertAdd } from '../../../../../triggers_actions_ui/public';
import { TriggerActionsContext } from '../../../utils/triggers_actions_context';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
@ -20,9 +22,16 @@ interface Props {
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
}
interface KibanaDeps {
notifications: NotificationsStart;
http: HttpStart;
docLinks: DocLinksStart;
application: ApplicationStart;
}
export const AlertFlyout = (props: Props) => {
const { triggersActionsUI } = useContext(TriggerActionsContext);
const { services } = useKibana();
const { services } = useKibana<KibanaDeps>();
return (
<>
@ -33,7 +42,7 @@ export const AlertFlyout = (props: Props) => {
currentOptions: props.options,
series: props.series,
},
toastNotifications: services.notifications?.toasts,
toastNotifications: services.notifications.toasts,
http: services.http,
docLinks: services.docLinks,
capabilities: services.application.capabilities,

View file

@ -5,6 +5,8 @@
*/
import React, { useContext } from 'react';
import { ApplicationStart, DocLinksStart, HttpStart, NotificationsStart } from 'src/core/public';
import { AlertsContextProvider, AlertAdd } from '../../../../../triggers_actions_ui/public';
import { TriggerActionsContext } from '../../../utils/triggers_actions_context';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
@ -15,9 +17,16 @@ interface Props {
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
}
interface KibanaDeps {
notifications: NotificationsStart;
http: HttpStart;
docLinks: DocLinksStart;
application: ApplicationStart;
}
export const AlertFlyout = (props: Props) => {
const { triggersActionsUI } = useContext(TriggerActionsContext);
const { services } = useKibana();
const { services } = useKibana<KibanaDeps>();
return (
<>
@ -27,7 +36,7 @@ export const AlertFlyout = (props: Props) => {
metadata: {
isInternal: true,
},
toastNotifications: services.notifications?.toasts,
toastNotifications: services.notifications.toasts,
http: services.http,
docLinks: services.docLinks,
capabilities: services.application.capabilities,

View file

@ -20,6 +20,7 @@ import {
EuiImage,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { HttpStart } from 'src/core/public';
import { LoadingPage } from '../../loading_page';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
@ -27,7 +28,7 @@ import { euiStyled } from '../../../../../observability/public';
import { useTrialStatus } from '../../../hooks/use_trial_status';
export const SubscriptionSplashContent: React.FC = () => {
const { services } = useKibana();
const { services } = useKibana<{ http: HttpStart }>();
const { loadState, isTrialAvailable, checkTrialAvailability } = useTrialStatus();
useEffect(() => {

View file

@ -6,8 +6,9 @@
import { boolean } from 'io-ts';
import { i18n } from '@kbn/i18n';
import { useState } from 'react';
import { HttpStart, NotificationsStart } from 'src/core/public';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
import { API_BASE_PATH as LICENSE_MANAGEMENT_API_BASE_PATH } from '../../../license_management/common/constants';
import { useTrackedPromise } from '../utils/use_tracked_promise';
@ -20,7 +21,7 @@ interface UseTrialStatusState {
}
export function useTrialStatus(): UseTrialStatusState {
const { services } = useKibana();
const { services } = useKibana<{ http: HttpStart; notifications: NotificationsStart }>();
const [isTrialAvailable, setIsTrialAvailable] = useState<boolean>(false);
const [loadState, checkTrialAvailability] = useTrackedPromise(

View file

@ -9,6 +9,7 @@ import flowRight from 'lodash/flowRight';
import React from 'react';
import { Redirect, RouteComponentProps } from 'react-router-dom';
import { useMount } from 'react-use';
import { HttpStart } from 'src/core/public';
import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
import { findInventoryFields } from '../../../common/inventory_models';
import { InventoryItemType } from '../../../common/inventory_models/types';
@ -32,7 +33,7 @@ export const RedirectToNodeLogs = ({
},
location,
}: RedirectToNodeLogsType) => {
const { services } = useKibana();
const { services } = useKibana<{ http: HttpStart }>();
const { isLoading, loadSourceConfiguration, sourceConfiguration } = useLogSource({
fetch: services.http.fetch,
sourceId,

View file

@ -5,6 +5,7 @@
*/
import React from 'react';
import { HttpStart } from 'src/core/public';
import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
import { LogAnalysisCapabilitiesProvider } from '../../containers/logs/log_analysis';
import { LogSourceProvider } from '../../containers/logs/log_source';
@ -12,7 +13,7 @@ import { useSourceId } from '../../containers/source_id';
export const LogsPageProviders: React.FunctionComponent = ({ children }) => {
const [sourceId] = useSourceId();
const { services } = useKibana();
const { services } = useKibana<{ http: HttpStart }>();
return (
<LogSourceProvider sourceId={sourceId} fetch={services.http.fetch}>
<LogAnalysisCapabilitiesProvider>{children}</LogAnalysisCapabilitiesProvider>

View file

@ -8,7 +8,7 @@ import { CoreStart } from 'kibana/public';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
export function useCore(): CoreStart {
const { services } = useKibana();
const { services } = useKibana<CoreStart>();
if (services === null) {
throw new Error('KibanaContextProvider not initialized');
}

View file

@ -65,7 +65,7 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => {
} = useConfig();
const {
params: { policyId, pkgkey },
} = useRouteMatch();
} = useRouteMatch<{ policyId: string; pkgkey: string }>();
const { getHref, getPath } = useLink();
const history = useHistory();
const routeState = useIntraAppState<CreatePackagePolicyRouteState>();

View file

@ -53,7 +53,7 @@ export const EditPackagePolicyPage: React.FunctionComponent = () => {
} = useConfig();
const {
params: { policyId, packagePolicyId },
} = useRouteMatch();
} = useRouteMatch<{ policyId: string; packagePolicyId: string }>();
const history = useHistory();
const { getHref, getPath } = useLink();
const [isNavDrawerLocked, setIsNavDrawerLocked] = useState(false);

View file

@ -42,6 +42,7 @@ export const migrateAgentPolicyToV7100: SavedObjectMigrationFn<
AgentPolicy
> = (agentPolicyDoc) => {
agentPolicyDoc.attributes.package_policies = agentPolicyDoc.attributes.package_configs;
// @ts-expect-error
delete agentPolicyDoc.attributes.package_configs;
return agentPolicyDoc;
@ -66,6 +67,7 @@ export const migratePackagePolicyToV7100: SavedObjectMigrationFn<
PackagePolicy
> = (packagePolicyDoc) => {
packagePolicyDoc.attributes.policy_id = packagePolicyDoc.attributes.config_id;
// @ts-expect-error
delete packagePolicyDoc.attributes.config_id;
return packagePolicyDoc;

View file

@ -91,6 +91,7 @@ export const deserializeVerboseTestOutput = (
// The tag is added programatically as a way to map
// the results to each processor
// It is not something we need to surface to the user, so we delete it
// @ts-expect-error
delete result.tag;
processorResultsById[resultId] = result;

View file

@ -31,6 +31,7 @@ describe('create_endpoint_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "description"', () => {
const payload = getCreateEndpointListItemSchemaMock();
// @ts-expect-error
delete payload.description;
const decoded = createEndpointListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);
@ -43,6 +44,7 @@ describe('create_endpoint_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "name"', () => {
const payload = getCreateEndpointListItemSchemaMock();
// @ts-expect-error
delete payload.name;
const decoded = createEndpointListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);
@ -55,6 +57,7 @@ describe('create_endpoint_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "type"', () => {
const payload = getCreateEndpointListItemSchemaMock();
// @ts-expect-error
delete payload.type;
const decoded = createEndpointListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);
@ -145,6 +148,7 @@ describe('create_endpoint_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "entries"', () => {
const inputPayload = getCreateEndpointListItemSchemaMock();
const outputPayload = getCreateEndpointListItemSchemaMock();
// @ts-expect-error
delete inputPayload.entries;
outputPayload.entries = [];
const decoded = createEndpointListItemSchema.decode(inputPayload);

View file

@ -31,6 +31,7 @@ describe('create_exception_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "description"', () => {
const payload = getCreateExceptionListItemSchemaMock();
// @ts-expect-error
delete payload.description;
const decoded = createExceptionListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);
@ -43,6 +44,7 @@ describe('create_exception_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "name"', () => {
const payload = getCreateExceptionListItemSchemaMock();
// @ts-expect-error
delete payload.name;
const decoded = createExceptionListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);
@ -55,6 +57,7 @@ describe('create_exception_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "type"', () => {
const payload = getCreateExceptionListItemSchemaMock();
// @ts-expect-error
delete payload.type;
const decoded = createExceptionListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);
@ -67,6 +70,7 @@ describe('create_exception_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "list_id"', () => {
const inputPayload = getCreateExceptionListItemSchemaMock();
// @ts-expect-error
delete inputPayload.list_id;
const decoded = createExceptionListItemSchema.decode(inputPayload);
const checked = exactCheck(inputPayload, decoded);
@ -133,6 +137,7 @@ describe('create_exception_list_item_schema', () => {
test('it should fail validation when supplied an undefined for "entries"', () => {
const inputPayload = getCreateExceptionListItemSchemaMock();
const outputPayload = getCreateExceptionListItemSchemaMock();
// @ts-expect-error
delete inputPayload.entries;
outputPayload.entries = [];
const decoded = createExceptionListItemSchema.decode(inputPayload);

View file

@ -30,6 +30,7 @@ describe('delete_endpoint_list_item_schema', () => {
const payload: DeleteEndpointListItemSchema & {
namespace_type: string;
} = { ...getDeleteEndpointListItemSchemaMock(), namespace_type: 'single' };
// @ts-expect-error
delete payload.namespace_type;
const decoded = deleteEndpointListItemSchema.decode(payload);
const checked = exactCheck(payload, decoded);

Some files were not shown because too many files have changed in this diff Show more