From 6eb6c4ea55eeb74e2afc0d899e6fe1604ea5d9f2 Mon Sep 17 00:00:00 2001 From: Dainel Yule Date: Mon, 2 Jul 2018 10:02:53 -0700 Subject: [PATCH] [@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 --- types/d3-transition/index.d.ts | 6 ++++++ types/d3-zoom/d3-zoom-tests.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/d3-transition/index.d.ts b/types/d3-transition/index.d.ts index eb60cec49f..2f935802bb 100644 --- a/types/d3-transition/index.d.ts +++ b/types/d3-transition/index.d.ts @@ -561,6 +561,12 @@ export interface Transition 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 = Selection | Transition; + /** * 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. diff --git a/types/d3-zoom/d3-zoom-tests.ts b/types/d3-zoom/d3-zoom-tests.ts index 8051898b8b..819f344422 100644 --- a/types/d3-zoom/d3-zoom-tests.ts +++ b/types/d3-zoom/d3-zoom-tests.ts @@ -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 = group; + const g: SVGRectElement[] | ArrayLike = group; return "ontouchstart" in this && datum.height > 0; });