Skip to content

Commit

Permalink
fix: constrain isConditionalParameter type parameter (#8473)
Browse files Browse the repository at this point in the history
* Constrain `isConditionalParameter` type parameter

Fixes #8465

* Lint the code
  • Loading branch information
fcollonval authored Dec 18, 2022
1 parent 71b5856 commit 9d37ad4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/channeldef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,20 @@ export type StringValueDefWithCondition<F extends Field, T extends Type = Standa
>;
export type TypeForShape = 'nominal' | 'ordinal' | 'geojson';

export type Conditional<CD extends FieldDef<any> | DatumDef | ValueDef<any> | ExprRef | SignalRef> =
| ConditionalPredicate<CD>
| ConditionalParameter<CD>;
export type ConditionalTemplate = FieldDef<any> | DatumDef | ValueDef<any> | ExprRef | SignalRef;

export type ConditionalPredicate<CD extends FieldDef<any> | DatumDef | ValueDef<any> | ExprRef | SignalRef> = {
export type Conditional<CD extends ConditionalTemplate> = ConditionalPredicate<CD> | ConditionalParameter<CD>;

export type ConditionalPredicate<CD extends ConditionalTemplate> = {
/**
* Predicate for triggering the condition
*/
test: LogicalComposition<Predicate>;
} & CD;

export type ConditionalParameter<CD extends FieldDef<any> | DatumDef | ValueDef<any> | ExprRef | SignalRef> =
ParameterPredicate & CD;
export type ConditionalParameter<CD extends ConditionalTemplate> = ParameterPredicate & CD;

export function isConditionalParameter<T>(c: Conditional<T>): c is ConditionalParameter<T> {
export function isConditionalParameter<T extends ConditionalTemplate>(c: Conditional<T>): c is ConditionalParameter<T> {
return c['param'];
}

Expand Down

0 comments on commit 9d37ad4

Please sign in to comment.