remove anys in drilldowns plugin (#111305)

This commit is contained in:
Vadim Kibana 2021-09-07 17:23:47 +02:00 committed by GitHub
parent 05d9bc53fb
commit 5e5dd07470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View file

@ -262,7 +262,7 @@ describe('UrlDrilldown', () => {
indexPatterns: [{ id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }],
}
);
const data: any = {
const data = {
data: [
createPoint({ field: 'field0', value: 'value0' }),
createPoint({ field: 'field1', value: 'value1' }),

View file

@ -54,7 +54,7 @@ export interface ContextValues {
panel: PanelValues;
}
function hasSavedObjectId(obj: Record<string, any>): obj is { savedObjectId: string } {
function hasSavedObjectId(obj: Record<string, unknown>): obj is { savedObjectId: string } {
return 'savedObjectId' in obj && typeof obj.savedObjectId === 'string';
}
@ -64,12 +64,13 @@ function hasSavedObjectId(obj: Record<string, any>): obj is { savedObjectId: str
*/
function getIndexPatternIds(output: EmbeddableOutput): string[] {
function hasIndexPatterns(
_output: Record<string, any>
_output: unknown
): _output is { indexPatterns: Array<{ id?: string }> } {
return (
'indexPatterns' in _output &&
Array.isArray(_output.indexPatterns) &&
_output.indexPatterns.length > 0
typeof _output === 'object' &&
!!_output &&
Array.isArray((_output as { indexPatterns: unknown[] }).indexPatterns) &&
(_output as { indexPatterns: Array<{ id?: string }> }).indexPatterns.length > 0
);
}
return hasIndexPatterns(output)

View file

@ -53,7 +53,10 @@ describe('VALUE_CLICK_TRIGGER', () => {
describe('handles undefined, null or missing values', () => {
test('undefined or missing values are removed from the result scope', () => {
const point = createPoint({ field: undefined } as any);
const point = createPoint(({ field: undefined } as unknown) as {
field: string;
value: string | null | number | boolean;
});
const eventScope = getEventScopeValues({
data: { data: [point] },
}) as ValueClickTriggerEventScope;

View file

@ -15,7 +15,7 @@ export const toPrimitiveOrUndefined = (v: unknown): Primitive | undefined => {
return String(v);
};
export const deleteUndefinedKeys = <T extends Record<string, any>>(obj: T): T => {
export const deleteUndefinedKeys = <T extends Record<string, unknown>>(obj: T): T => {
Object.keys(obj).forEach((key) => {
if (obj[key] === undefined) {
delete obj[key];