From 094a813421cc1c5490719d797694c247bb968558 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Tue, 30 Jul 2024 23:33:23 -0400 Subject: [PATCH] simplify --- src/aggregate.ts | 4 ++-- src/compile/scale/parse.ts | 2 +- src/config.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/aggregate.ts b/src/aggregate.ts index f423bf5117..caedc16ff3 100644 --- a/src/aggregate.ts +++ b/src/aggregate.ts @@ -50,11 +50,11 @@ export type NonArgAggregateOp = Exclude; export type Aggregate = NonArgAggregateOp | ArgmaxDef | ArgminDef; export function isArgminDef(a: Aggregate | string): a is ArgminDef { - return !!a && hasKey(a, 'argmin'); + return hasKey(a, 'argmin'); } export function isArgmaxDef(a: Aggregate | string): a is ArgmaxDef { - return !!a && hasKey(a, 'argmax'); + return hasKey(a, 'argmax'); } export function isAggregateOp(a: string | ArgminDef | ArgmaxDef): a is AggregateOp { diff --git a/src/compile/scale/parse.ts b/src/compile/scale/parse.ts index b373d88fdf..13cb318f2d 100644 --- a/src/compile/scale/parse.ts +++ b/src/compile/scale/parse.ts @@ -54,7 +54,7 @@ function parseUnitScaleCore(model: UnitModel): ScaleComponentIndex { continue; } - let specifiedScale = (fieldOrDatumDef as any)?.scale; + let specifiedScale = fieldOrDatumDef && (fieldOrDatumDef as any).scale; if (fieldOrDatumDef && specifiedScale !== null && specifiedScale !== false) { specifiedScale ??= {}; const hasNestedOffsetScale = channelHasNestedOffsetScale(encoding, channel); diff --git a/src/config.ts b/src/config.ts index 1697d987e9..79dc4f3d99 100644 --- a/src/config.ts +++ b/src/config.ts @@ -734,8 +734,10 @@ export function stripAndRedirectConfig(config: Config) { redirectTitleConfig(config); // Remove empty config objects. - for (const prop of keys(config)) { + for (const prop in config) { + // @ts-ignore if (isObject(config[prop]) && isEmpty(config[prop])) { + // @ts-ignore delete config[prop]; } }