[@types/d3-transition] Add a new type to d3-transition that represents either a selection or transition (#26673)

* Add a new type to d3-transition that represents either a selection or transition.

* Fix linting errors with new type

* Fixed a build error in d3-zoom that was preventing submissions
This commit is contained in:
Dainel Yule
2018-07-02 10:02:53 -07:00
committed by Mohamed Hegazy
parent be78ef130f
commit 6eb6c4ea55
2 changed files with 7 additions and 1 deletions

View File

@@ -561,6 +561,12 @@ export interface Transition<GElement extends BaseType, Datum, PElement extends B
ease(easingFn: (normalizedTime: number) => number): this;
}
/**
* Represents the union of the Selection and Transition types for any usages that operate on both.
* Typically used for functions which take in either a selection or transition and set or update attributes.
*/
export type SelectionOrTransition<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> = Selection<GElement, Datum, PElement, PDatum> | Transition<GElement, Datum, PElement, PDatum>;
/**
* Returns a new transition with the specified name. If a name is not specified, null is used.
* The new transition is only exclusive with other transitions of the same name.

View File

@@ -166,7 +166,7 @@ svgZoom = svgZoom.touchable(true);
svgZoom = svgZoom.touchable(function(d, i, group) {
const that: SVGRectElement = this;
const datum: SVGDatum = d;
const g: SVGRectElement[] | NodeListOf<SVGRectElement> = group;
const g: SVGRectElement[] | ArrayLike<SVGRectElement> = group;
return "ontouchstart" in this && datum.height > 0;
});