From f3a20e8a3e339390d03f3fbc89e48a49673bfadb Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 26 Nov 2018 07:59:33 -0800 Subject: [PATCH] Enable some of the lint rules and fix them. --- types/highcharts/highstock.d.ts | 15 +--- types/highcharts/index.d.ts | 120 +++++++++----------------------- types/highcharts/test/index.ts | 2 +- types/highcharts/tslint.json | 2 - 4 files changed, 37 insertions(+), 102 deletions(-) diff --git a/types/highcharts/highstock.d.ts b/types/highcharts/highstock.d.ts index 1b57d91a7d..70ebfcb5c1 100644 --- a/types/highcharts/highstock.d.ts +++ b/types/highcharts/highstock.d.ts @@ -121,8 +121,7 @@ declare namespace Highstock { } interface Chart { - new (options: Options): ChartObject; - new (options: Options, callback: (chart: ChartObject) => void): ChartObject; + new (options: Options, callback?: (chart: ChartObject) => void): ChartObject; } interface Static extends Highcharts.Static { @@ -134,13 +133,6 @@ declare namespace Highstock { declare global { interface JQuery { highcharts(type: "StockChart"): Highstock.ChartObject; - /** - * Creates a new Highcharts.Chart for the current JQuery selector; usually - * a div selected by $('#container') - * @param options Options for this chart - * @return current selector the current JQuery selector - */ - highcharts(type: "StockChart", options: Highstock.Options): JQuery; /** * Creates a new Highcharts.Chart for the current JQuery selector; usually * a div selected by $('#container') @@ -148,11 +140,10 @@ declare global { * @param callback Callback function used to manipulate the constructed chart instance * @return current selector the current JQuery selector */ - highcharts(type: "StockChart", options: Highstock.Options, callback: (chart: Highstock.ChartObject) => void): JQuery; + highcharts(type: "StockChart", options: Highstock.Options, callback?: (chart: Highstock.ChartObject) => void): JQuery; highcharts(type: string): Highcharts.ChartObject; - highcharts(type: string, options: Highcharts.Options): JQuery; - highcharts(type: string, options: Highcharts.Options, callback: (chart: Highcharts.ChartObject) => void): JQuery; + highcharts(type: string, options: Highcharts.Options, callback?: (chart: Highcharts.ChartObject) => void): JQuery; } } diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index 7f0f15591b..5214c4c54c 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -4647,11 +4647,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * A separate color for the negative part of the area. * @since 3.0 @@ -4753,7 +4753,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * The maximum allowed pixel width for a column, translated to the height of a bar in a bar chart. This prevents the * columns from becoming too wide when there is a small number of points in the chart. @@ -4764,7 +4764,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * The minimal height for a column or width for a bar. By default, 0 values are not shown. To visualize a 0 (or * close to zero) point, set the minimal point length to a pixel value like 3. In stacked column charts, @@ -4862,7 +4862,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * Maximum bubble size. Bubbles will automatically size between the minSize and maxSize to reflect the z value of * each bubble. Can be either pixels (when no unit is given), or a percentage of the smallest one of the plot width @@ -4874,7 +4874,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * Minimum bubble size. Bubbles will automatically size between the minSize and maxSize to reflect the z value of * each bubble. Can be either pixels (when no unit is given), or a percentage of the smallest one of the plot width @@ -5163,11 +5163,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * Allow the dial to overshoot the end of the perimeter axis by this many degrees. Say if the gauge axis goes from 0 * to 60, a value of 100, or 1000, will show 5 degrees beyond the end of the axis. Defaults to 0. @@ -5239,7 +5239,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * The maximum allowed pixel width for a column, translated to the height of a bar in a bar chart. This prevents the * columns from becoming too wide when there is a small number of points in the chart. @@ -5250,7 +5250,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * The row size - how many Y axis units each heatmap row should span. * @default 1 @@ -5272,11 +5272,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * Whether to apply steps to the line. Possible values are left, center and right. Prior to 2.3.5, only left was * supported. @@ -5350,11 +5350,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * The minimum size for a pie in response to auto margins. The pie will try to shrink to make room for data labels * in side the plot area, but only to this size. @@ -5405,11 +5405,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; } interface PyramidChart extends SeriesChart { @@ -5488,11 +5488,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; } /** @@ -5533,11 +5533,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; } /** @@ -5613,7 +5613,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * The maximum allowed pixel width for a column, translated to the height of a bar in a bar chart. This prevents the * columns from becoming too wide when there is a small number of points in the chart. @@ -5624,7 +5624,7 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * The sort index of the point inside the treemap level. * @since 4.1.10 @@ -5692,11 +5692,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * This option decides which algorithm is used for placement, and rotation of a word. The choice of algorith is * therefore a crucial part of the resulting layout of the wordcloud. It is possible for users to add their own @@ -5900,11 +5900,11 @@ declare namespace Highcharts { /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - maxFontSize: number | null; + maxFontSize?: number | null; /** * For area-like series, allow the font size to vary so that small areas get a smaller font size. The default applies this effect to area-like series but not line-like series. */ - minFontSize: number | null; + minFontSize?: number | null; /** * The name of the series as shown in the legend, tooltip etc. */ @@ -6729,16 +6729,10 @@ declare namespace Highcharts { /** * Set new categories for the axis. Redraws. * @param categories The new category names. + * @param redraw Whether to redraw the axis or wait for an explicit call to chart.redraw(). * @since 1.2.0 */ - setCategories(categories: string[]): void; - /** - * Set new categories for the axis. - * @param categories The new category names. - * @param redraw Whether to redraw the axis or wait for an explicit call to chart.redraw(). - * @since 1.2.0 - */ - setCategories(categories: string[], redraw: boolean): void; + setCategories(categories: string[], redraw?: boolean): void; /** * Set the minimum and maximum of the axes after render time. If the startOnTick and endOnTick options are true, the * minimum and maximum values are rounded off to the nearest tick. To prevent this, these options can be set to @@ -6848,22 +6842,6 @@ declare namespace Highcharts { * @since 3.0.8 */ drillUp(): void; - /** - * Exporting module required. Submit an SVG version of the chart to a server along with some parameters for - * conversion. - * @since 2.0 - */ - exportChart(): void; - /** - * Exporting module required. Submit an SVG version of the chart to a server along with some parameters for - * conversion. - * @param options Exporting options. Out of the exporting options, the following options can be given as parameters to the exportChart method. - * All options default to the values given in the exporting config options. filename: the filename for the export without extension, - * url: the URL for the server module to do the conversion, width: the width of the PNG or JPEG image generated on the server, - * type: the MIME type of the converted image, sourceWidth: the width of the source (in-page) chart, sourceHeight: the height of the source chart. - * @since 2.0 - */ - exportChart(options: ExportingOptions): void; /** * Exporting module required. Submit an SVG version of the chart to a server along with some parameters for * conversion. @@ -6874,31 +6852,17 @@ declare namespace Highcharts { * @param chartOptions Additional chart options for the exported chart. For example a different background color can be added here. * @since 2.0 */ - exportChart(options: ExportingOptions, chartOptions: Options): void; + exportChart(options?: ExportingOptions, chartOptions?: Options): void; /** * Export the chart to a PNG or SVG without sending it to a server. Requires * modules/exporting.js and modules/offline-exporting.js. - * @since 2.0 - */ - exportChartLocal(): void; - /** - * Export the chart to a PNG or SVG without sending it to a server. Requires - * modules/exporting.js and modules/offline-exporting.js. - * @param options Exporting options. Same as - * the exportChart params. - * @since 2.0 - */ - exportChartLocal(options: ExportingOptions): void; - /** - * Export the chart to a PNG or SVG without sending it to a server. - * Requires modules/exporting.js and modules/offline-exporting.js. * @param options Exporting options. Same as * the exportChart params. * @param chartOptions Additional chart options for the * exported chart. Same as the exportChart params. * @since 2.0 */ - exportChartLocal(options: ExportingOptions, chartOptions: Options): void; + exportChartLocal(options?: ExportingOptions, chartOptions?: Options): void; /** * Get an axis, series or point by its id as given in the configuration options. * @param id The id of the axis, series or point to get. @@ -7042,23 +7006,12 @@ declare namespace Highcharts { /** * This is the constructor for creating a new chart object. * @param options The chart options - */ - new (options: Options): ChartObject; - /** - * This is the constructor for creating a new chart object. - * @param options The chart options * @param callback A function to execute when the chart object is finished loading and rendering. In most cases the chart is built in one thread, * but in Internet Explorer version 8 or less the chart is sometimes initiated before the document is ready, * and in these cases the chart object will not be finished directly after callingnew Highcharts.Chart(). * s a consequence, code that relies on the newly built Chart object should always run in the callback. Defining a chart.event.load handler is equivalent. */ - new (options: Options, callback: (chart: ChartObject) => void): ChartObject; - /** - * This is the constructor for creating a new chart object. - * @param renderTo The id or a reference to a DOM element where the chart should be rendered (since v4.2.0). - * @param options The chart options - */ - new (renderTo: string | HTMLElement, options: Options): ChartObject; + new (options: Options, callback?: (chart: ChartObject) => void): ChartObject; /** * This is the constructor for creating a new chart object. * @param renderTo The id or a reference to a DOM element where the chart should be rendered (since v4.2.0). @@ -7068,7 +7021,7 @@ declare namespace Highcharts { * and in these cases the chart object will not be finished directly after callingnew Highcharts.Chart(). * As a consequence, code that relies on the newly built Chart object should always run in the callback. Defining a chart.event.load handler is equivalent. */ - new (renderTo: string | HTMLElement, options: Options, callback: (chart: ChartObject) => void): ChartObject; + new (renderTo: string | HTMLElement, options: Options, callback?: (chart: ChartObject) => void): ChartObject; } /** @@ -7642,13 +7595,6 @@ declare namespace Highcharts { declare global { interface JQuery { highcharts(): Highcharts.ChartObject; - /** - * Creates a new Highcharts.Chart for the current JQuery selector; usually - * a div selected by $('#container') - * @param options Options for this chart - * @return current {JQuery} selector the current JQuery selector - */ - highcharts(options: Highcharts.Options): JQuery; /** * Creates a new Highcharts.Chart for the current JQuery selector; usually * a div selected by $('#container') @@ -7656,7 +7602,7 @@ declare global { * @param callback Callback function used to manipulate the constructed chart instance * @return current {JQuery} selector the current JQuery selector */ - highcharts(options: Highcharts.Options, callback: (chart: Highcharts.ChartObject) => void): JQuery; + highcharts(options: Highcharts.Options, callback?: (chart: Highcharts.ChartObject) => void): JQuery; } } diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index 1eaa5da438..c1fd8b5676 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -48,7 +48,7 @@ function originalTests() { }] }); - chart1.addSeries({ + chart1.addSeries({ enableMouseTracking: true, data: [1, 2, 3, 4, 5], description: "some description" diff --git a/types/highcharts/tslint.json b/types/highcharts/tslint.json index cfc8218eab..d6b6fde9be 100644 --- a/types/highcharts/tslint.json +++ b/types/highcharts/tslint.json @@ -3,9 +3,7 @@ "rules": { // TODOs "ban-types": false, - "unified-signatures": false, "no-empty-interface": false, - "dt-header": false, "no-declare-current-package": false, "no-object-literal-type-assertion": false, "no-self-import": false,