Skip to content

Lots of typing changes

Pre-release
Pre-release

Choose a tag to compare

@jtlan jtlan released this 06 Sep 02:39
· 6775 commits to master since this release

Good Evening,

This release consists mostly of changes that will be breaking to Typescript consumers. Changes not specific to Typescript:

  • Plottable.Animator.Default has been renamed to Plottable.Animator.Base.
  • Plottable.DataSource has been renamed to Plottable.Dataset. Accordingly, the getter/setter on Plot has been renamed to dataset().
  • The Util module is now _underscore-proected as _Util, as the fields it contains are not meant to be public facing. Other functions / instance variables / interfaces that are not meant to be public facing are now _underscore-protected as well.

Typescript-only API Breaks

Typing Refactor: Many Plottable classes, including Scales and Plots, now use paramaterized types. For example:

Abstract.Scale -> Abstract.Scale<D,R> where D indicates the type of the domain and R indicates the type of the range. Some examples follow:

  • Scale.InterpolatedColor has type Scale<number,string>
  • Scale.Quantitive<D> has type Scale<D,number>. You might think it should be Scale<number,number>, but it is actually parameterized because a Scale.Time is a QuantitiveScale
  • Scale.Ordinal has type Scale<string,number>.

There were according changes for Plots, e.g. XYPlot now has types X,Y (XYPlot<X,Y>). The X attribute is the type being projected on the X dimension, likewise for Y.

Typescript consumers will need to specify the types their scales and plots take. This will improve the ability of the compiler to detect type errors. As always, you can opt out by using anys. Here is an example of the new usage.

var plot: Plottable.Plot.Line<number, number>;
plot = new Plottable.Plot.Line<number, number>(data, xScale, yScale);
  • Plottable.Plot.StackedBar no longer extends from Plottable.Plot.NewStyleBarPlot