From 730393928c0de536fc827c64c72609eac92f11fe Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 22 Oct 2018 09:13:40 -0700 Subject: [PATCH 001/174] Add maxFontSize and minFontSize to series that have it. --- types/highcharts/index.d.ts | 110 +++++++++++++++++++++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index dcde50413d..d3036a869a 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -4644,6 +4644,14 @@ declare namespace Highcharts { * allows setting a separate color for the line without altering the fillColor. */ lineColor?: string | Gradient; + /** + * 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; + /** + * 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; /** * A separate color for the negative part of the area. * @since 3.0 @@ -4742,6 +4750,10 @@ declare namespace Highcharts { * @since 2.3.0 */ grouping?: boolean; + /** + * 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; /** * 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. @@ -4749,6 +4761,10 @@ declare namespace Highcharts { * @since 4.1.8 */ maxPointWidth?: 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; /** * 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, @@ -4843,6 +4859,10 @@ declare namespace Highcharts { * @since 3.0 */ displayNegative?: boolean; + /** + * 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; /** * 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 @@ -4851,6 +4871,10 @@ declare namespace Highcharts { * @since 3.0 */ maxSize?: string | number; + /** + * 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; /** * 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 @@ -5136,6 +5160,14 @@ declare namespace Highcharts { * Options for the dial or arrow pointer of the gauge. */ dial?: Dial; + /** + * 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; + /** + * 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; /** * 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. @@ -5204,6 +5236,10 @@ declare namespace Highcharts { * @default 50 */ cropTreshold?: number; + /** + * 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; /** * 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. @@ -5211,6 +5247,10 @@ declare namespace Highcharts { * @since 4.1.8 */ maxPointWidth?: 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; /** * The row size - how many Y axis units each heatmap row should span. * @default 1 @@ -5229,6 +5269,14 @@ declare namespace Highcharts { } interface LineChart extends SeriesChart { + /** + * 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; + /** + * 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; /** * Whether to apply steps to the line. Possible values are left, center and right. Prior to 2.3.5, only left was * supported. @@ -5299,6 +5347,14 @@ declare namespace Highcharts { * @since 2.0 */ innerSize?: number | string; + /** + * 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; + /** + * 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; /** * 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. @@ -5346,6 +5402,14 @@ declare namespace Highcharts { * @default 0 */ lineWidth?: number; + /** + * 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; + /** + * 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; } interface PyramidChart extends SeriesChart { @@ -5420,7 +5484,16 @@ declare namespace Highcharts { width?: number | string; } - interface ScatterChart extends SeriesChart { } + interface ScatterChart extends SeriesChart { + /** + * 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; + /** + * 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; + } /** * A gauge showing values using a filled arc with colors indicating the value. The solid gauge plots values against the @@ -5456,7 +5529,16 @@ declare namespace Highcharts { wrap?: boolean; } - interface SplineChart extends SeriesChart { } + interface SplineChart extends SeriesChart { + /** + * 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; + /** + * 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; + } /** * The size of the point shape is determined by its value relative to its siblings values. Requires the module @@ -5528,6 +5610,10 @@ declare namespace Highcharts { * Set options on specific levels. Takes precedence over series options, but not point options. */ levels?: TreeMapLevel[]; + /** + * 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; /** * 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. @@ -5535,6 +5621,10 @@ declare namespace Highcharts { * @since 4.1.8 */ maxPointWidth?: 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; /** * The sort index of the point inside the treemap level. * @since 4.1.10 @@ -5599,6 +5689,14 @@ declare namespace Highcharts { * @since 5.0.12 */ exposeElementToA11y?: boolean; + /** + * 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; + /** + * 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; /** * 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 @@ -5799,6 +5897,14 @@ declare namespace Highcharts { * The sequential index of the series in the legend. */ legendIndex?: number; + /** + * 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; + /** + * 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; /** * The name of the series as shown in the legend, tooltip etc. */ From 7cda494c6987dec64f6ceb59dccb14341d3ea49f Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 22 Oct 2018 09:21:02 -0700 Subject: [PATCH 002/174] Update version at top of file. --- types/highcharts/index.d.ts | 334 +++++++++++++++++++++++++++--------- 1 file changed, 255 insertions(+), 79 deletions(-) diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index d3036a869a..7da3ac752d 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Highcharts 5.0.13 +// Type definitions for Highcharts 5.0.32 // Project: http://www.highcharts.com/ // Definitions by: Damiano Gambarotto // Dan Lewi Harkestad @@ -292,7 +292,7 @@ declare namespace Highcharts { * @default null * @since 2.3 */ - innerRadius?: number | string | null; + innerRadius?: number | string | null; /** * Text labels for the plot bands */ @@ -494,12 +494,12 @@ declare namespace Highcharts { shadow?: | boolean | { - color?: string | Gradient; - offsetX?: number; - offsetY?: number; - opacity?: number; - width?: number; - }; + color?: string | Gradient; + offsetX?: number; + offsetY?: number; + opacity?: number; + width?: number; + }; /** * The name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object. * @default "callout" @@ -1294,7 +1294,7 @@ declare namespace Highcharts { * Use this in cases where a linear gradient between a minColor and maxColor is not sufficient. * The stops is an array of tuples, where the first item is a float between 0 and 1 assigning the relative position in the gradient, and the second item is the color. */ - stops?: Array>; + stops?: Array>; /** * The amount of ticks to draw on the axis. This opens up for aligning the ticks of multiple charts or panes within * a chart. This option overrides the tickPixelInterval option. @@ -1859,7 +1859,9 @@ declare namespace Highcharts { interface Gradient { linearGradient?: LinearGradient | number[]; radialGradient?: { - cx: number; cy: number; r: number; + cx: number; + cy: number; + r: number; }; stops?: any[][]; /** @@ -2015,7 +2017,7 @@ declare namespace Highcharts { /** * The button stroke width */ - 'stroke-width'?: number; + "stroke-width"?: number; /** * The border radius */ @@ -3416,7 +3418,7 @@ declare namespace Highcharts { * @default ['50%', '50%'] * @since 2.3.0 */ - center?: Array; + center?: Array; /** * The end angle of the polar X axis or gauge value axis, given in degrees where 0 is north. * @default startAngle + 360 @@ -4033,7 +4035,7 @@ declare namespace Highcharts { halo?: boolean | Halo; } - interface PieStates extends BarStates, LineStates { } + interface PieStates extends BarStates, LineStates {} interface AreaZone { /** @@ -4682,11 +4684,9 @@ declare namespace Highcharts { dataLabels?: RangeDataLabels; } - interface AreaSplineChart extends AreaChart { - } + interface AreaSplineChart extends AreaChart {} - interface AreaSplineRangeChart extends AreaRangeChart { - } + interface AreaSplineRangeChart extends AreaRangeChart {} interface BarChart extends SeriesChart { /** @@ -4925,8 +4925,7 @@ declare namespace Highcharts { zThreshold?: number; } - interface ColumnChart extends BarChart { - } + interface ColumnChart extends BarChart {} /** * The column range is a cartesian series type with higher and lower Y values along an X axis. Requires @@ -5874,7 +5873,14 @@ declare namespace Highcharts { * [3, 7, 8] * */ - data?: Array; + data?: Array< + | number + | [number, number] + | [string, number] + | [string, number, number] + | [number, number, number] + | DataPoint + >; /** * A description of the series to add to the screen reader information about the series. * @since 5.0.0 @@ -5942,31 +5948,73 @@ declare namespace Highcharts { zIndex?: number; } - interface SeriesOptions extends IndividualSeriesOptions, SeriesChart { } + interface SeriesOptions extends IndividualSeriesOptions, SeriesChart {} - interface AreaChartSeriesOptions extends IndividualSeriesOptions, AreaChart { } - interface AreaRangeChartSeriesOptions extends IndividualSeriesOptions, AreaRangeChart { } - interface AreaSplineChartSeriesOptions extends IndividualSeriesOptions, AreaSplineChart { } - interface AreaSplineRangeChartSeriesOptions extends IndividualSeriesOptions, AreaSplineRangeChart { } - interface BarChartSeriesOptions extends IndividualSeriesOptions, BarChart { } - interface BoxPlotChartSeriesOptions extends IndividualSeriesOptions, BoxPlotChart { } - interface BubbleChartSeriesOptions extends IndividualSeriesOptions, BubbleChart { } - interface ColumnChartSeriesOptions extends IndividualSeriesOptions, ColumnChart { } - interface ColumnRangeChartSeriesOptions extends IndividualSeriesOptions, ColumnRangeChart { } - interface ErrorBarChartSeriesOptions extends IndividualSeriesOptions, ErrorBarChart { } - interface FunnelChartSeriesOptions extends IndividualSeriesOptions, FunnelChart { } - interface GaugeChartSeriesOptions extends IndividualSeriesOptions, GaugeChart { } - interface HeatMapSeriesOptions extends IndividualSeriesOptions, HeatMapChart { } - interface LineChartSeriesOptions extends IndividualSeriesOptions, LineChart { } - interface PieChartSeriesOptions extends IndividualSeriesOptions, PieChart { } - interface PolygonChartSeriesOptions extends IndividualSeriesOptions, PolygonChart { } - interface PyramidChartSeriesOptions extends IndividualSeriesOptions, PyramidChart { } - interface ScatterChartSeriesOptions extends IndividualSeriesOptions, ScatterChart { } - interface SolidGaugeChartSeriesOptions extends IndividualSeriesOptions, SolidGaugeChart { } - interface SplineChartSeriesOptions extends IndividualSeriesOptions, SplineChart { } - interface TreeMapChartSeriesOptions extends IndividualSeriesOptions, TreeMapChart { } - interface WaterFallChartSeriesOptions extends IndividualSeriesOptions, WaterFallChart { } - interface WordCloudChartSeriesOptions extends IndividualSeriesOptions, WordCloudChart { } + interface AreaChartSeriesOptions + extends IndividualSeriesOptions, + AreaChart {} + interface AreaRangeChartSeriesOptions + extends IndividualSeriesOptions, + AreaRangeChart {} + interface AreaSplineChartSeriesOptions + extends IndividualSeriesOptions, + AreaSplineChart {} + interface AreaSplineRangeChartSeriesOptions + extends IndividualSeriesOptions, + AreaSplineRangeChart {} + interface BarChartSeriesOptions extends IndividualSeriesOptions, BarChart {} + interface BoxPlotChartSeriesOptions + extends IndividualSeriesOptions, + BoxPlotChart {} + interface BubbleChartSeriesOptions + extends IndividualSeriesOptions, + BubbleChart {} + interface ColumnChartSeriesOptions + extends IndividualSeriesOptions, + ColumnChart {} + interface ColumnRangeChartSeriesOptions + extends IndividualSeriesOptions, + ColumnRangeChart {} + interface ErrorBarChartSeriesOptions + extends IndividualSeriesOptions, + ErrorBarChart {} + interface FunnelChartSeriesOptions + extends IndividualSeriesOptions, + FunnelChart {} + interface GaugeChartSeriesOptions + extends IndividualSeriesOptions, + GaugeChart {} + interface HeatMapSeriesOptions + extends IndividualSeriesOptions, + HeatMapChart {} + interface LineChartSeriesOptions + extends IndividualSeriesOptions, + LineChart {} + interface PieChartSeriesOptions extends IndividualSeriesOptions, PieChart {} + interface PolygonChartSeriesOptions + extends IndividualSeriesOptions, + PolygonChart {} + interface PyramidChartSeriesOptions + extends IndividualSeriesOptions, + PyramidChart {} + interface ScatterChartSeriesOptions + extends IndividualSeriesOptions, + ScatterChart {} + interface SolidGaugeChartSeriesOptions + extends IndividualSeriesOptions, + SolidGaugeChart {} + interface SplineChartSeriesOptions + extends IndividualSeriesOptions, + SplineChart {} + interface TreeMapChartSeriesOptions + extends IndividualSeriesOptions, + TreeMapChart {} + interface WaterFallChartSeriesOptions + extends IndividualSeriesOptions, + WaterFallChart {} + interface WordCloudChartSeriesOptions + extends IndividualSeriesOptions, + WordCloudChart {} interface DataPoint { /** @@ -6321,7 +6369,12 @@ declare namespace Highcharts { * * @default null */ - crosshairs?: boolean | [boolean, boolean] | CrosshairObject | [CrosshairObject, CrosshairObject] | null; + crosshairs?: + | boolean + | [boolean, boolean] + | CrosshairObject + | [CrosshairObject, CrosshairObject] + | null; /** * Enable or disable the tooltip. * @default true @@ -6380,7 +6433,11 @@ declare namespace Highcharts { * The return should be an object containing x and y values, for example { x: 100, y: 100 }. * @since 2.2.4 */ - positioner?(labelWidth: number, labelHeight: number, point: PlotPoint): { x: number; y: number; }; + positioner?( + labelWidth: number, + labelHeight: number, + point: PlotPoint + ): { x: number; y: number }; /** * Whether to apply a drop shadow to the tooltip. * @default true @@ -6751,7 +6808,13 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 1.2.0 */ - setExtremes(min?: number, max?: number, redraw?: boolean, animation?: boolean | Animation, eventArguments?: any): void; + setExtremes( + min?: number, + max?: number, + redraw?: boolean, + animation?: boolean | Animation, + eventArguments?: any + ): void; /** * Update the title of the axis after render time. * @param title The new title options on the same format as given in xAxis.title. @@ -6800,7 +6863,12 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 3.0 */ - addAxis(options: AxisOptions, isX?: boolean, redraw?: boolean, animation?: boolean | Animation): AxisObject; + addAxis( + options: AxisOptions, + isX?: boolean, + redraw?: boolean, + animation?: boolean | Animation + ): AxisObject; /** * Set a new credits label for the chart. * @param A configuration object for the credits as defined at credits. @@ -6815,7 +6883,11 @@ declare namespace Highcharts { * @param [boolean] redraw * @since 1.2.0 */ - addSeries(options: T, redraw?: boolean, animation?: boolean | Animation): SeriesObject; + addSeries( + options: T, + redraw?: boolean, + animation?: boolean | Animation + ): SeriesObject; /** * Add a series to the chart as drilldown from a specific point in the parent series. This method is used for async * drilldown, when clicking a point in a series should result in loading and displaying a more high-resolution @@ -6824,7 +6896,10 @@ declare namespace Highcharts { * @param seriesOptions The series options, as documented under plotOptions.series and under the plotOptions for each series type. * @since 3.0.8 */ - addSeriesAsDrilldown(point: PointObject, seriesOptions: IndividualSeriesOptions): void; + addSeriesAsDrilldown( + point: PointObject, + seriesOptions: IndividualSeriesOptions + ): void; chartHeight?: number; chartWidth?: number; /** @@ -6898,7 +6973,10 @@ declare namespace Highcharts { * 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. @@ -6975,7 +7053,11 @@ declare namespace Highcharts { * @param animation Defaults to true. When true, the resize will be animated with default animation options. * The animation can also be a configuration object with properties duration and easing. */ - setSize(width: number, height: number, animation?: boolean | Animation): void; + setSize( + width: number, + height: number, + animation?: boolean | Animation + ): void; /** * Set a new title or subtitle for the chart * @param title A configuration object for the new title as defined at #title. @@ -6983,7 +7065,11 @@ declare namespace Highcharts { * @param [boolean] redraw Whether to redraw the chart. Defaults to true. * @since 2.1.0 */ - setTitle(title: TitleOptions, subtitle?: SubtitleOptions, redraw?: boolean): void; + setTitle( + title: TitleOptions, + subtitle?: SubtitleOptions, + redraw?: boolean + ): void; /** * Dim the chart's plot area and show a loading label text. Options for the loading screen are defined at * options.loading. A custom text can be given as a parameter for loading. @@ -7015,7 +7101,12 @@ declare namespace Highcharts { * @param [(boolean | AnimationOptions)] animation Whether to apply animation, and optionally animation configuration. * @since 5.0.0 */ - update(options: Options, redraw?: boolean, oneToOne?: boolean, animation?: boolean | AnimationOptions): void; + update( + options: Options, + redraw?: boolean, + oneToOne?: boolean, + animation?: boolean | AnimationOptions + ): void; /** * This method is deprecated as of 2.0.1. Updating the chart position after a move operation is no longer necessary. * @since 1.2.5 @@ -7052,7 +7143,10 @@ declare namespace Highcharts { * 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; + 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 +7162,11 @@ 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; } /** @@ -7121,7 +7219,7 @@ declare namespace Highcharts { * @return An object containing x, y, width and height values for the element. * @since 2.0 */ - getBBox(): { x: number; y: number; height: number; width: number; }; + getBBox(): { x: number; y: number; height: number; width: number }; /** * Apply an event handler to the element * @param eventType The event type to attach, for example 'click', 'mouseover', 'touch'. @@ -7160,7 +7258,14 @@ declare namespace Highcharts { * @param end The ending angle of the arc in radians, where 0 is to the right and -Math.PI/2 is up. * @since 2.0 */ - arc(centerX: number, centerY: number, outerRadius: number, innerRadius: number, start: number, end: number): ElementObject; + arc( + centerX: number, + centerY: number, + outerRadius: number, + innerRadius: number, + start: number, + end: number + ): ElementObject; /** * Draw circle on the renderer canvas. * @param centerX The x position of the circle's center in the SVG element. @@ -7200,7 +7305,13 @@ declare namespace Highcharts { * @param height The height of the image. * @since 2.0 */ - image(source: string, x: number, y: number, width: number, height: number): ElementObject; + image( + source: string, + x: number, + y: number, + width: number, + height: number + ): ElementObject; /** * Draw a label, which is an extended text element with support for border and background. Highcharts creates a g * element with a text and a path or rect inside, to make it behave somewhat like a HTML div. Border and background @@ -7218,7 +7329,17 @@ declare namespace Highcharts { * @param [string] className A class name for the g element surrounding the label. * @since 2.0 */ - label(str: string, x: number, y: number, shape?: string, anchorX?: number, anchorY?: number, useHTML?: boolean, baseline?: boolean, className?: string): ElementObject; + label( + str: string, + x: number, + y: number, + shape?: string, + anchorX?: number, + anchorY?: number, + useHTML?: boolean, + baseline?: boolean, + className?: string + ): ElementObject; /** * Add a path based on SVG's path commands. In SVG capable browsers all path commands are supported, but in VML only * a subset is supported: absolute moveTo (M), absolute lineTo (L), absolute curveTo (C) and close (Z). @@ -7234,7 +7355,13 @@ declare namespace Highcharts { * @param cornerRadius The corner radius of all the rectangle's corners. * @since 2.0 */ - rect(x: number, y: number, width: number, height: number, cornerRadius: number): ElementObject; + rect( + x: number, + y: number, + width: number, + height: number, + cornerRadius: number + ): ElementObject; /** * Draw text. The text can contain a subset of HTML, like spans and anchors and some basic text styling of these. * For more advanced features like border and background, use label instead. @@ -7262,7 +7389,11 @@ declare namespace Highcharts { } interface Renderer { - new (parentNode: HTMLElement, width: number, height: number): RendererObject; + new ( + parentNode: HTMLElement, + width: number, + height: number + ): RendererObject; } interface Static { @@ -7274,12 +7405,19 @@ declare namespace Highcharts { * As Highcharts.Chart, but without need for the new keyword. * @since 4.2.0 */ - chart(options: Options, callback?: (chart: ChartObject) => void): ChartObject; + chart( + options: Options, + callback?: (chart: ChartObject) => void + ): ChartObject; /** * As Highcharts.Chart, but without need for the new keyword. * @since 4.2.0 */ - chart(renderTo: string | HTMLElement, options: Options, callback?: (chart: ChartObject) => void): ChartObject; + chart( + renderTo: string | HTMLElement, + options: Options, + callback?: (chart: ChartObject) => void + ): ChartObject; /** * An array containing the current chart objects in the page. A chart's position in the array is preserved * throughout the page's lifetime. When a chart is destroyed, the array item becomes undefined. @@ -7318,7 +7456,12 @@ declare namespace Highcharts { * @param decimalPoint The decimal point. Defaults to '.' or to the string specified globally in options.lang.decimalPoint. * @param thousandsSep The thousands separator. Defaults to ' ' or to the string specified globally in options.lang.thousandsSep. */ - numberFormat(value: number, decimals?: number, decimalPoint?: string, thousandsSep?: string): string; + numberFormat( + value: number, + decimals?: number, + decimalPoint?: string, + thousandsSep?: string + ): string; /** * Sets the options globally for all charts created after this has been called. Takes an options JavaScript object * structure as the argument. These options are merged with the default options and the result is returned. @@ -7343,7 +7486,11 @@ declare namespace Highcharts { * @param type The type of behavior you are extending. * @param cb The function that executes when the behavior occurs. */ - wrap(prototype: any, type: string, cb: (proceed: Function, ...args: any[]) => void): void; + wrap( + prototype: any, + type: string, + cb: (proceed: Function, ...args: any[]) => void + ): void; /** * Add an event listener. @@ -7356,9 +7503,11 @@ declare namespace Highcharts { * @param cb The function callback to execute when the event is fired. * @returns A callback function to remove the added event. */ - addEvent(element: HTMLElement | ElementObject | object, - type: string, - cb: (evt: Event) => void): () => void; + addEvent( + element: HTMLElement | ElementObject | object, + type: string, + cb: (evt: Event) => void + ): () => void; /** * Fire an event that was registered with @@ -7370,10 +7519,12 @@ declare namespace Highcharts { * @param eventArguments Custom event arguments that are passed on as an argument to the event handler. * @param defaultFunction The default function to execute if the other listeners haven't returned false. */ - fireEvent(element: HTMLElement | ElementObject | object, - type: string, - eventArguments?: any, - defaultFunction?: () => void): void; + fireEvent( + element: HTMLElement | ElementObject | object, + type: string, + eventArguments?: any, + defaultFunction?: () => void + ): void; distribute(array: any[], value: number): void; @@ -7443,7 +7594,11 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 1.2.0 */ - slice(sliced?: boolean, redraw?: boolean, animation?: boolean | Animation): void; + slice( + sliced?: boolean, + redraw?: boolean, + animation?: boolean | Animation + ): void; /** * The total of a stack for stacked series, or pie in pie charts. */ @@ -7459,7 +7614,11 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 1.2.0 */ - update(options: number | [number, number] | DataPoint, redraw?: boolean, animation?: boolean | Animation): void; + update( + options: number | [number, number] | DataPoint, + redraw?: boolean, + animation?: boolean | Animation + ): void; /** * The x value for the point. * @since 1.2.0 @@ -7500,7 +7659,12 @@ declare namespace Highcharts { * Use this option for live charts monitoring a value over time. * @since 1.2.0 */ - addPoint(options: number | [number, number] | DataPoint, redraw?: boolean, shift?: boolean, animation?: boolean | Animation): void; + addPoint( + options: number | [number, number] | DataPoint, + redraw?: boolean, + shift?: boolean, + animation?: boolean | Animation + ): void; /** * Read only. The chart that the series belongs to. * @since 1.2.0 @@ -7544,7 +7708,11 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 4.1.0 */ - removePoint(index: number, redraw?: boolean, animation?: boolean | Animation): void; + removePoint( + index: number, + redraw?: boolean, + animation?: boolean | Animation + ): void; /** * Select or unselect the series. This means its selected property is set,the checkbox in the legend is toggled and * when selected, the series is returned in the chart.getSelectedSeries() method. @@ -7569,7 +7737,12 @@ declare namespace Highcharts { * This option prevents this, and makes setData behave like it did prior to Highcharts 3.0.10. * @since 1.2.0 */ - setData(data: number[] | number[][] | DataPoint[], redraw?: boolean, animation?: boolean | Animation, updatePoints?: boolean): void; + setData( + data: number[] | number[][] | DataPoint[], + redraw?: boolean, + animation?: boolean | Animation, + updatePoints?: boolean + ): void; /** * A utility function to show or hide the series with an optional redraw. * @param [boolean] visible - Whether to show or hide the series. If undefined, the visibility is toggled. @@ -7656,7 +7829,10 @@ 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; } } From 2083505b395c2742083e085386ea96a503eb70af Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 22 Oct 2018 09:31:35 -0700 Subject: [PATCH 003/174] Revert the formatting --- types/highcharts/index.d.ts | 332 +++++++++--------------------------- 1 file changed, 78 insertions(+), 254 deletions(-) diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index 7da3ac752d..644dc1a169 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -292,7 +292,7 @@ declare namespace Highcharts { * @default null * @since 2.3 */ - innerRadius?: number | string | null; + innerRadius?: number | string | null; /** * Text labels for the plot bands */ @@ -494,12 +494,12 @@ declare namespace Highcharts { shadow?: | boolean | { - color?: string | Gradient; - offsetX?: number; - offsetY?: number; - opacity?: number; - width?: number; - }; + color?: string | Gradient; + offsetX?: number; + offsetY?: number; + opacity?: number; + width?: number; + }; /** * The name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object. * @default "callout" @@ -1294,7 +1294,7 @@ declare namespace Highcharts { * Use this in cases where a linear gradient between a minColor and maxColor is not sufficient. * The stops is an array of tuples, where the first item is a float between 0 and 1 assigning the relative position in the gradient, and the second item is the color. */ - stops?: Array>; + stops?: Array>; /** * The amount of ticks to draw on the axis. This opens up for aligning the ticks of multiple charts or panes within * a chart. This option overrides the tickPixelInterval option. @@ -1859,9 +1859,7 @@ declare namespace Highcharts { interface Gradient { linearGradient?: LinearGradient | number[]; radialGradient?: { - cx: number; - cy: number; - r: number; + cx: number; cy: number; r: number; }; stops?: any[][]; /** @@ -2017,7 +2015,7 @@ declare namespace Highcharts { /** * The button stroke width */ - "stroke-width"?: number; + 'stroke-width'?: number; /** * The border radius */ @@ -3418,7 +3416,7 @@ declare namespace Highcharts { * @default ['50%', '50%'] * @since 2.3.0 */ - center?: Array; + center?: Array; /** * The end angle of the polar X axis or gauge value axis, given in degrees where 0 is north. * @default startAngle + 360 @@ -4035,7 +4033,7 @@ declare namespace Highcharts { halo?: boolean | Halo; } - interface PieStates extends BarStates, LineStates {} + interface PieStates extends BarStates, LineStates { } interface AreaZone { /** @@ -4684,9 +4682,11 @@ declare namespace Highcharts { dataLabels?: RangeDataLabels; } - interface AreaSplineChart extends AreaChart {} + interface AreaSplineChart extends AreaChart { + } - interface AreaSplineRangeChart extends AreaRangeChart {} + interface AreaSplineRangeChart extends AreaRangeChart { + } interface BarChart extends SeriesChart { /** @@ -4925,7 +4925,8 @@ declare namespace Highcharts { zThreshold?: number; } - interface ColumnChart extends BarChart {} + interface ColumnChart extends BarChart { + } /** * The column range is a cartesian series type with higher and lower Y values along an X axis. Requires @@ -5873,14 +5874,7 @@ declare namespace Highcharts { * [3, 7, 8] * */ - data?: Array< - | number - | [number, number] - | [string, number] - | [string, number, number] - | [number, number, number] - | DataPoint - >; + data?: Array; /** * A description of the series to add to the screen reader information about the series. * @since 5.0.0 @@ -5948,73 +5942,31 @@ declare namespace Highcharts { zIndex?: number; } - interface SeriesOptions extends IndividualSeriesOptions, SeriesChart {} + interface SeriesOptions extends IndividualSeriesOptions, SeriesChart { } - interface AreaChartSeriesOptions - extends IndividualSeriesOptions, - AreaChart {} - interface AreaRangeChartSeriesOptions - extends IndividualSeriesOptions, - AreaRangeChart {} - interface AreaSplineChartSeriesOptions - extends IndividualSeriesOptions, - AreaSplineChart {} - interface AreaSplineRangeChartSeriesOptions - extends IndividualSeriesOptions, - AreaSplineRangeChart {} - interface BarChartSeriesOptions extends IndividualSeriesOptions, BarChart {} - interface BoxPlotChartSeriesOptions - extends IndividualSeriesOptions, - BoxPlotChart {} - interface BubbleChartSeriesOptions - extends IndividualSeriesOptions, - BubbleChart {} - interface ColumnChartSeriesOptions - extends IndividualSeriesOptions, - ColumnChart {} - interface ColumnRangeChartSeriesOptions - extends IndividualSeriesOptions, - ColumnRangeChart {} - interface ErrorBarChartSeriesOptions - extends IndividualSeriesOptions, - ErrorBarChart {} - interface FunnelChartSeriesOptions - extends IndividualSeriesOptions, - FunnelChart {} - interface GaugeChartSeriesOptions - extends IndividualSeriesOptions, - GaugeChart {} - interface HeatMapSeriesOptions - extends IndividualSeriesOptions, - HeatMapChart {} - interface LineChartSeriesOptions - extends IndividualSeriesOptions, - LineChart {} - interface PieChartSeriesOptions extends IndividualSeriesOptions, PieChart {} - interface PolygonChartSeriesOptions - extends IndividualSeriesOptions, - PolygonChart {} - interface PyramidChartSeriesOptions - extends IndividualSeriesOptions, - PyramidChart {} - interface ScatterChartSeriesOptions - extends IndividualSeriesOptions, - ScatterChart {} - interface SolidGaugeChartSeriesOptions - extends IndividualSeriesOptions, - SolidGaugeChart {} - interface SplineChartSeriesOptions - extends IndividualSeriesOptions, - SplineChart {} - interface TreeMapChartSeriesOptions - extends IndividualSeriesOptions, - TreeMapChart {} - interface WaterFallChartSeriesOptions - extends IndividualSeriesOptions, - WaterFallChart {} - interface WordCloudChartSeriesOptions - extends IndividualSeriesOptions, - WordCloudChart {} + interface AreaChartSeriesOptions extends IndividualSeriesOptions, AreaChart { } + interface AreaRangeChartSeriesOptions extends IndividualSeriesOptions, AreaRangeChart { } + interface AreaSplineChartSeriesOptions extends IndividualSeriesOptions, AreaSplineChart { } + interface AreaSplineRangeChartSeriesOptions extends IndividualSeriesOptions, AreaSplineRangeChart { } + interface BarChartSeriesOptions extends IndividualSeriesOptions, BarChart { } + interface BoxPlotChartSeriesOptions extends IndividualSeriesOptions, BoxPlotChart { } + interface BubbleChartSeriesOptions extends IndividualSeriesOptions, BubbleChart { } + interface ColumnChartSeriesOptions extends IndividualSeriesOptions, ColumnChart { } + interface ColumnRangeChartSeriesOptions extends IndividualSeriesOptions, ColumnRangeChart { } + interface ErrorBarChartSeriesOptions extends IndividualSeriesOptions, ErrorBarChart { } + interface FunnelChartSeriesOptions extends IndividualSeriesOptions, FunnelChart { } + interface GaugeChartSeriesOptions extends IndividualSeriesOptions, GaugeChart { } + interface HeatMapSeriesOptions extends IndividualSeriesOptions, HeatMapChart { } + interface LineChartSeriesOptions extends IndividualSeriesOptions, LineChart { } + interface PieChartSeriesOptions extends IndividualSeriesOptions, PieChart { } + interface PolygonChartSeriesOptions extends IndividualSeriesOptions, PolygonChart { } + interface PyramidChartSeriesOptions extends IndividualSeriesOptions, PyramidChart { } + interface ScatterChartSeriesOptions extends IndividualSeriesOptions, ScatterChart { } + interface SolidGaugeChartSeriesOptions extends IndividualSeriesOptions, SolidGaugeChart { } + interface SplineChartSeriesOptions extends IndividualSeriesOptions, SplineChart { } + interface TreeMapChartSeriesOptions extends IndividualSeriesOptions, TreeMapChart { } + interface WaterFallChartSeriesOptions extends IndividualSeriesOptions, WaterFallChart { } + interface WordCloudChartSeriesOptions extends IndividualSeriesOptions, WordCloudChart { } interface DataPoint { /** @@ -6369,12 +6321,7 @@ declare namespace Highcharts { * * @default null */ - crosshairs?: - | boolean - | [boolean, boolean] - | CrosshairObject - | [CrosshairObject, CrosshairObject] - | null; + crosshairs?: boolean | [boolean, boolean] | CrosshairObject | [CrosshairObject, CrosshairObject] | null; /** * Enable or disable the tooltip. * @default true @@ -6433,11 +6380,7 @@ declare namespace Highcharts { * The return should be an object containing x and y values, for example { x: 100, y: 100 }. * @since 2.2.4 */ - positioner?( - labelWidth: number, - labelHeight: number, - point: PlotPoint - ): { x: number; y: number }; + positioner?(labelWidth: number, labelHeight: number, point: PlotPoint): { x: number; y: number; }; /** * Whether to apply a drop shadow to the tooltip. * @default true @@ -6808,13 +6751,7 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 1.2.0 */ - setExtremes( - min?: number, - max?: number, - redraw?: boolean, - animation?: boolean | Animation, - eventArguments?: any - ): void; + setExtremes(min?: number, max?: number, redraw?: boolean, animation?: boolean | Animation, eventArguments?: any): void; /** * Update the title of the axis after render time. * @param title The new title options on the same format as given in xAxis.title. @@ -6863,12 +6800,7 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 3.0 */ - addAxis( - options: AxisOptions, - isX?: boolean, - redraw?: boolean, - animation?: boolean | Animation - ): AxisObject; + addAxis(options: AxisOptions, isX?: boolean, redraw?: boolean, animation?: boolean | Animation): AxisObject; /** * Set a new credits label for the chart. * @param A configuration object for the credits as defined at credits. @@ -6883,11 +6815,7 @@ declare namespace Highcharts { * @param [boolean] redraw * @since 1.2.0 */ - addSeries( - options: T, - redraw?: boolean, - animation?: boolean | Animation - ): SeriesObject; + addSeries(options: T, redraw?: boolean, animation?: boolean | Animation): SeriesObject; /** * Add a series to the chart as drilldown from a specific point in the parent series. This method is used for async * drilldown, when clicking a point in a series should result in loading and displaying a more high-resolution @@ -6896,10 +6824,7 @@ declare namespace Highcharts { * @param seriesOptions The series options, as documented under plotOptions.series and under the plotOptions for each series type. * @since 3.0.8 */ - addSeriesAsDrilldown( - point: PointObject, - seriesOptions: IndividualSeriesOptions - ): void; + addSeriesAsDrilldown(point: PointObject, seriesOptions: IndividualSeriesOptions): void; chartHeight?: number; chartWidth?: number; /** @@ -6973,10 +6898,7 @@ declare namespace Highcharts { * 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. @@ -7053,11 +6975,7 @@ declare namespace Highcharts { * @param animation Defaults to true. When true, the resize will be animated with default animation options. * The animation can also be a configuration object with properties duration and easing. */ - setSize( - width: number, - height: number, - animation?: boolean | Animation - ): void; + setSize(width: number, height: number, animation?: boolean | Animation): void; /** * Set a new title or subtitle for the chart * @param title A configuration object for the new title as defined at #title. @@ -7065,11 +6983,7 @@ declare namespace Highcharts { * @param [boolean] redraw Whether to redraw the chart. Defaults to true. * @since 2.1.0 */ - setTitle( - title: TitleOptions, - subtitle?: SubtitleOptions, - redraw?: boolean - ): void; + setTitle(title: TitleOptions, subtitle?: SubtitleOptions, redraw?: boolean): void; /** * Dim the chart's plot area and show a loading label text. Options for the loading screen are defined at * options.loading. A custom text can be given as a parameter for loading. @@ -7101,12 +7015,7 @@ declare namespace Highcharts { * @param [(boolean | AnimationOptions)] animation Whether to apply animation, and optionally animation configuration. * @since 5.0.0 */ - update( - options: Options, - redraw?: boolean, - oneToOne?: boolean, - animation?: boolean | AnimationOptions - ): void; + update(options: Options, redraw?: boolean, oneToOne?: boolean, animation?: boolean | AnimationOptions): void; /** * This method is deprecated as of 2.0.1. Updating the chart position after a move operation is no longer necessary. * @since 1.2.5 @@ -7143,10 +7052,7 @@ declare namespace Highcharts { * 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; + 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). @@ -7162,11 +7068,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; } /** @@ -7219,7 +7121,7 @@ declare namespace Highcharts { * @return An object containing x, y, width and height values for the element. * @since 2.0 */ - getBBox(): { x: number; y: number; height: number; width: number }; + getBBox(): { x: number; y: number; height: number; width: number; }; /** * Apply an event handler to the element * @param eventType The event type to attach, for example 'click', 'mouseover', 'touch'. @@ -7258,14 +7160,7 @@ declare namespace Highcharts { * @param end The ending angle of the arc in radians, where 0 is to the right and -Math.PI/2 is up. * @since 2.0 */ - arc( - centerX: number, - centerY: number, - outerRadius: number, - innerRadius: number, - start: number, - end: number - ): ElementObject; + arc(centerX: number, centerY: number, outerRadius: number, innerRadius: number, start: number, end: number): ElementObject; /** * Draw circle on the renderer canvas. * @param centerX The x position of the circle's center in the SVG element. @@ -7305,13 +7200,7 @@ declare namespace Highcharts { * @param height The height of the image. * @since 2.0 */ - image( - source: string, - x: number, - y: number, - width: number, - height: number - ): ElementObject; + image(source: string, x: number, y: number, width: number, height: number): ElementObject; /** * Draw a label, which is an extended text element with support for border and background. Highcharts creates a g * element with a text and a path or rect inside, to make it behave somewhat like a HTML div. Border and background @@ -7329,17 +7218,7 @@ declare namespace Highcharts { * @param [string] className A class name for the g element surrounding the label. * @since 2.0 */ - label( - str: string, - x: number, - y: number, - shape?: string, - anchorX?: number, - anchorY?: number, - useHTML?: boolean, - baseline?: boolean, - className?: string - ): ElementObject; + label(str: string, x: number, y: number, shape?: string, anchorX?: number, anchorY?: number, useHTML?: boolean, baseline?: boolean, className?: string): ElementObject; /** * Add a path based on SVG's path commands. In SVG capable browsers all path commands are supported, but in VML only * a subset is supported: absolute moveTo (M), absolute lineTo (L), absolute curveTo (C) and close (Z). @@ -7355,13 +7234,7 @@ declare namespace Highcharts { * @param cornerRadius The corner radius of all the rectangle's corners. * @since 2.0 */ - rect( - x: number, - y: number, - width: number, - height: number, - cornerRadius: number - ): ElementObject; + rect(x: number, y: number, width: number, height: number, cornerRadius: number): ElementObject; /** * Draw text. The text can contain a subset of HTML, like spans and anchors and some basic text styling of these. * For more advanced features like border and background, use label instead. @@ -7389,11 +7262,7 @@ declare namespace Highcharts { } interface Renderer { - new ( - parentNode: HTMLElement, - width: number, - height: number - ): RendererObject; + new (parentNode: HTMLElement, width: number, height: number): RendererObject; } interface Static { @@ -7405,19 +7274,12 @@ declare namespace Highcharts { * As Highcharts.Chart, but without need for the new keyword. * @since 4.2.0 */ - chart( - options: Options, - callback?: (chart: ChartObject) => void - ): ChartObject; + chart(options: Options, callback?: (chart: ChartObject) => void): ChartObject; /** * As Highcharts.Chart, but without need for the new keyword. * @since 4.2.0 */ - chart( - renderTo: string | HTMLElement, - options: Options, - callback?: (chart: ChartObject) => void - ): ChartObject; + chart(renderTo: string | HTMLElement, options: Options, callback?: (chart: ChartObject) => void): ChartObject; /** * An array containing the current chart objects in the page. A chart's position in the array is preserved * throughout the page's lifetime. When a chart is destroyed, the array item becomes undefined. @@ -7456,12 +7318,7 @@ declare namespace Highcharts { * @param decimalPoint The decimal point. Defaults to '.' or to the string specified globally in options.lang.decimalPoint. * @param thousandsSep The thousands separator. Defaults to ' ' or to the string specified globally in options.lang.thousandsSep. */ - numberFormat( - value: number, - decimals?: number, - decimalPoint?: string, - thousandsSep?: string - ): string; + numberFormat(value: number, decimals?: number, decimalPoint?: string, thousandsSep?: string): string; /** * Sets the options globally for all charts created after this has been called. Takes an options JavaScript object * structure as the argument. These options are merged with the default options and the result is returned. @@ -7486,11 +7343,7 @@ declare namespace Highcharts { * @param type The type of behavior you are extending. * @param cb The function that executes when the behavior occurs. */ - wrap( - prototype: any, - type: string, - cb: (proceed: Function, ...args: any[]) => void - ): void; + wrap(prototype: any, type: string, cb: (proceed: Function, ...args: any[]) => void): void; /** * Add an event listener. @@ -7503,11 +7356,9 @@ declare namespace Highcharts { * @param cb The function callback to execute when the event is fired. * @returns A callback function to remove the added event. */ - addEvent( - element: HTMLElement | ElementObject | object, - type: string, - cb: (evt: Event) => void - ): () => void; + addEvent(element: HTMLElement | ElementObject | object, + type: string, + cb: (evt: Event) => void): () => void; /** * Fire an event that was registered with @@ -7519,12 +7370,10 @@ declare namespace Highcharts { * @param eventArguments Custom event arguments that are passed on as an argument to the event handler. * @param defaultFunction The default function to execute if the other listeners haven't returned false. */ - fireEvent( - element: HTMLElement | ElementObject | object, - type: string, - eventArguments?: any, - defaultFunction?: () => void - ): void; + fireEvent(element: HTMLElement | ElementObject | object, + type: string, + eventArguments?: any, + defaultFunction?: () => void): void; distribute(array: any[], value: number): void; @@ -7594,11 +7443,7 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 1.2.0 */ - slice( - sliced?: boolean, - redraw?: boolean, - animation?: boolean | Animation - ): void; + slice(sliced?: boolean, redraw?: boolean, animation?: boolean | Animation): void; /** * The total of a stack for stacked series, or pie in pie charts. */ @@ -7614,11 +7459,7 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 1.2.0 */ - update( - options: number | [number, number] | DataPoint, - redraw?: boolean, - animation?: boolean | Animation - ): void; + update(options: number | [number, number] | DataPoint, redraw?: boolean, animation?: boolean | Animation): void; /** * The x value for the point. * @since 1.2.0 @@ -7659,12 +7500,7 @@ declare namespace Highcharts { * Use this option for live charts monitoring a value over time. * @since 1.2.0 */ - addPoint( - options: number | [number, number] | DataPoint, - redraw?: boolean, - shift?: boolean, - animation?: boolean | Animation - ): void; + addPoint(options: number | [number, number] | DataPoint, redraw?: boolean, shift?: boolean, animation?: boolean | Animation): void; /** * Read only. The chart that the series belongs to. * @since 1.2.0 @@ -7708,11 +7544,7 @@ declare namespace Highcharts { * The animation can also be a configuration object with properties duration and easing. * @since 4.1.0 */ - removePoint( - index: number, - redraw?: boolean, - animation?: boolean | Animation - ): void; + removePoint(index: number, redraw?: boolean, animation?: boolean | Animation): void; /** * Select or unselect the series. This means its selected property is set,the checkbox in the legend is toggled and * when selected, the series is returned in the chart.getSelectedSeries() method. @@ -7737,12 +7569,7 @@ declare namespace Highcharts { * This option prevents this, and makes setData behave like it did prior to Highcharts 3.0.10. * @since 1.2.0 */ - setData( - data: number[] | number[][] | DataPoint[], - redraw?: boolean, - animation?: boolean | Animation, - updatePoints?: boolean - ): void; + setData(data: number[] | number[][] | DataPoint[], redraw?: boolean, animation?: boolean | Animation, updatePoints?: boolean): void; /** * A utility function to show or hide the series with an optional redraw. * @param [boolean] visible - Whether to show or hide the series. If undefined, the visibility is toggled. @@ -7829,10 +7656,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; } } From 38983e317ac39a234d6bc4106f7f4d0767211800 Mon Sep 17 00:00:00 2001 From: AzSiAz Date: Mon, 22 Oct 2018 19:58:14 +0200 Subject: [PATCH 004/174] Add overloading to `get` method --- types/cheerio/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index cb8031705e..7f76146257 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Cheerio v0.22.0 // Project: https://github.com/cheeriojs/cheerio -// Definitions by: Bret Little , VILIC VANE , Wayne Maurer , Umar Nizamani , LiJinyao , Chennakrishna +// Definitions by: Bret Little , VILIC VANE , Wayne Maurer , Umar Nizamani , LiJinyao , Chennakrishna , AzSiAz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Cheerio { @@ -112,8 +112,10 @@ interface Cheerio { eq(index: number): Cheerio; get(): string[]; + get(): T[]; get(): CheerioElement[]; get(index: number): CheerioElement; + get(index: number): T; index(): number; index(selector: string): number; From a8b6dfd99e9637403c2204d0f2fe8e53f9c8eed3 Mon Sep 17 00:00:00 2001 From: AzSiAz Date: Mon, 22 Oct 2018 20:10:40 +0200 Subject: [PATCH 005/174] Revert "Add overloading to `get` method" This reverts commit 38983e317ac39a234d6bc4106f7f4d0767211800. --- types/cheerio/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index 7f76146257..5f8b89fe60 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -112,10 +112,8 @@ interface Cheerio { eq(index: number): Cheerio; get(): string[]; - get(): T[]; get(): CheerioElement[]; get(index: number): CheerioElement; - get(index: number): T; index(): number; index(selector: string): number; From 023af83ed4d02ef61234532448ac49d8c27dad5b Mon Sep 17 00:00:00 2001 From: AzSiAz Date: Mon, 22 Oct 2018 20:11:22 +0200 Subject: [PATCH 006/174] Add correct overloading to `get` method --- types/cheerio/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index 5f8b89fe60..b04e0f009d 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -111,6 +111,7 @@ interface Cheerio { eq(index: number): Cheerio; + get(): any[] get(): string[]; get(): CheerioElement[]; get(index: number): CheerioElement; From feac0654fa67b2692dfe156420acb0396f98c446 Mon Sep 17 00:00:00 2001 From: Chris O'Toole Date: Wed, 7 Nov 2018 10:09:01 -0500 Subject: [PATCH 007/174] Add "onChildMouseDown" "onChildMouseUp", and "onChildMouseMove" to google-map-react definitions --- package.json | 2 +- types/google-map-react/index.d.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 09fe064d48..2bd57a4c7c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "definitely-typed", - "version": "0.0.3", + "version": "0.0.4", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped", "repository": { "type": "git", diff --git a/types/google-map-react/index.d.ts b/types/google-map-react/index.d.ts index a917ae426e..56686c94c1 100644 --- a/types/google-map-react/index.d.ts +++ b/types/google-map-react/index.d.ts @@ -131,6 +131,9 @@ export interface Props { onChildClick?(hoverKey: any, childProps: any): void; onChildMouseEnter?(hoverKey: any, childProps: any): void; onChildMouseLeave?(hoverKey: any, childProps: any): void; + onChildMouseDown?(childKey: any, childProps: any, mouse: any): void; + onChildMouseUp?(childKey: any, childProps: any, mouse: any): void; + onChildMouseMove?(childKey: any, childProps: any, mouse: any): void; onDrag?(args: any): void; onZoomAnimationStart?(args: any): void; onZoomAnimationEnd?(args: any): void; From 1343e45412283277fc9b8d6effeee7a76eaee136 Mon Sep 17 00:00:00 2001 From: juwar Date: Fri, 9 Nov 2018 07:30:07 -0800 Subject: [PATCH 008/174] Remove patch version --- types/highcharts/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index 644dc1a169..58154954a3 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Highcharts 5.0.32 +// Type definitions for Highcharts 5.0 // Project: http://www.highcharts.com/ // Definitions by: Damiano Gambarotto // Dan Lewi Harkestad From 8f2e78835f3e38c4a5b15a51dd2aa453a2031c47 Mon Sep 17 00:00:00 2001 From: Fellipe Chagas Date: Fri, 9 Nov 2018 15:19:11 -0200 Subject: [PATCH 009/174] Improves react-navigation typings --- types/react-navigation/index.d.ts | 121 +++++++++++++++++------------- 1 file changed, 68 insertions(+), 53 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 846ea56a9e..512059e29c 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -27,6 +27,7 @@ // Max Davidson // Lachlan Young // Jason Killian +// Fellipe Chagas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -94,6 +95,9 @@ export interface NavigationState { */ index: number; routes: NavigationRoute[]; + isTransitioning: boolean; + key: string; + params: NavigationParams; } export interface DrawerNavigationState extends NavigationState { @@ -129,6 +133,8 @@ export interface NavigationLeafRoute { * e.g. `{ car_id: 123 }` in a route that displays a car. */ params?: Params; + routes: NavigationRoute[]; + isTransitioning: boolean; } export type NavigationStateRoute< @@ -280,28 +286,28 @@ export interface NavigationInitAction extends NavigationInitActionPayload { } export interface NavigationReplaceActionPayload { - key?: string; - newKey?: string; - routeName: string; - params?: NavigationParams; - action?: NavigationNavigateAction; + key?: string; + newKey?: string; + routeName: string; + params?: NavigationParams; + action?: NavigationNavigateAction; } export interface NavigationReplaceAction { - type: 'Navigation/REPLACE'; - key: string; - routeName: string; - params?: NavigationParams; - action?: NavigationNavigateAction; + type: 'Navigation/REPLACE'; + key: string; + routeName: string; + params?: NavigationParams; + action?: NavigationNavigateAction; } export interface NavigationCompleteTransitionActionPayload { - key?: string; + key?: string; } export interface NavigationCompleteTransitionAction { - type: 'Navigation/COMPLETE_TRANSITION'; - key: string; + type: 'Navigation/COMPLETE_TRANSITION'; + key: string; } export interface NavigationResetActionPayload { @@ -343,33 +349,33 @@ export interface NavigationPopToTopAction } export interface NavigationPushActionPayload { - routeName: string; - params?: NavigationParams; - action?: NavigationNavigateAction; - key?: string; + routeName: string; + params?: NavigationParams; + action?: NavigationNavigateAction; + key?: string; } export interface NavigationPushAction { - type: 'Navigation/PUSH'; - routeName: string; - params?: NavigationParams; - action?: NavigationNavigateAction; - key?: string; + type: 'Navigation/PUSH'; + routeName: string; + params?: NavigationParams; + action?: NavigationNavigateAction; + key?: string; } export interface NavigationOpenDrawerAction { - key?: string; - type: 'Navigation/OPEN_DRAWER'; + key?: string; + type: 'Navigation/OPEN_DRAWER'; } export interface NavigationCloseDrawerAction { - key?: string; - type: 'Navigation/CLOSE_DRAWER'; + key?: string; + type: 'Navigation/CLOSE_DRAWER'; } export interface NavigationToggleDrawerAction { - key?: string; - type: 'Navigation/TOGGLE_DRAWER'; + key?: string; + type: 'Navigation/TOGGLE_DRAWER'; } export interface NavigationStackViewConfig { @@ -655,9 +661,12 @@ export interface NavigationScreenProp { pop: (n?: number, params?: { immediate?: boolean }) => boolean; popToTop: (params?: { immediate?: boolean }) => boolean; isFocused: () => boolean; + router?: NavigationRouter; + dangerouslyGetParent: () => NavigationScreenProp | undefined; } export interface NavigationNavigatorProps { + detached?: boolean; navigation?: NavigationProp; screenProps?: { [key: string]: any }; navigationOptions?: O; @@ -728,6 +737,9 @@ export interface NavigationTransitionSpec { easing?: (t: number) => number; // A timing function such as `Animated.timing`. timing?: (value: AnimatedValue, config: any) => any; + friction?: number; + tension?: number; + useNativeDriver?: boolean; } /** @@ -1065,41 +1077,41 @@ export namespace NavigationActions { * DrawerActions */ export namespace DrawerActions { - const OPEN_DRAWER: 'Navigation/OPEN_DRAWER'; - const CLOSE_DRAWER: 'Navigation/CLOSE_DRAWER'; - const TOGGLE_DRAWER: 'Navigation/TOGGLE_DRAWER'; + const OPEN_DRAWER: 'Navigation/OPEN_DRAWER'; + const CLOSE_DRAWER: 'Navigation/CLOSE_DRAWER'; + const TOGGLE_DRAWER: 'Navigation/TOGGLE_DRAWER'; - function openDrawer(): NavigationOpenDrawerAction; - function closeDrawer(): NavigationCloseDrawerAction; - function toggleDrawer(): NavigationToggleDrawerAction; + function openDrawer(): NavigationOpenDrawerAction; + function closeDrawer(): NavigationCloseDrawerAction; + function toggleDrawer(): NavigationToggleDrawerAction; } /** * StackActions */ export namespace StackActions { - const POP: 'Navigation/POP'; - const POP_TO_TOP: 'Navigation/POP_TO_TOP'; - const PUSH: 'Navigation/PUSH'; - const RESET: 'Navigation/RESET'; - const REPLACE: 'Navigation/REPLACE'; - const COMPLETE_TRANSITION: 'Navigation/COMPLETE_TRANSITION'; + const POP: 'Navigation/POP'; + const POP_TO_TOP: 'Navigation/POP_TO_TOP'; + const PUSH: 'Navigation/PUSH'; + const RESET: 'Navigation/RESET'; + const REPLACE: 'Navigation/REPLACE'; + const COMPLETE_TRANSITION: 'Navigation/COMPLETE_TRANSITION'; - function pop(options: NavigationPopActionPayload): NavigationPopAction; - function popToTop( - options: NavigationPopToTopActionPayload - ): NavigationPopToTopAction; + function pop(options: NavigationPopActionPayload): NavigationPopAction; + function popToTop( + options: NavigationPopToTopActionPayload + ): NavigationPopToTopAction; - function push(options: NavigationPushActionPayload): NavigationPushAction; - function reset(options: NavigationResetActionPayload): NavigationResetAction; + function push(options: NavigationPushActionPayload): NavigationPushAction; + function reset(options: NavigationResetActionPayload): NavigationResetAction; - function replace( - options: NavigationReplaceActionPayload - ): NavigationReplaceAction; + function replace( + options: NavigationReplaceActionPayload + ): NavigationReplaceAction; - function completeTransition( - payload: NavigationCompleteTransitionActionPayload - ): NavigationCompleteTransitionAction; + function completeTransition( + payload: NavigationCompleteTransitionActionPayload + ): NavigationCompleteTransitionAction; } /** @@ -1124,6 +1136,7 @@ export interface TransitionerProps { transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps ) => any; + descriptors: { [key: string]: NavigationDescriptor }; style?: StyleProp; } @@ -1169,11 +1182,13 @@ export interface NavigationDescriptor { state: NavigationLeafRoute | NavigationStateRoute; navigation: NavigationScreenProp; options: NavigationScreenOptions; - getComponent: () => React.ComponentType; + getComponent: () => React.ComponentType & { navigationOptions: N }; } export type NavigationView = React.ComponentType<{ descriptors: { [key: string]: NavigationDescriptor }; + navigationConfig: O; + screenProps?: { [key: string]: any }; } & NavigationInjectedProps>; export function createNavigator( From eea8aaf433a16830c0bb9b99aa0a73b15afb9b79 Mon Sep 17 00:00:00 2001 From: Fellipe Chagas Date: Fri, 9 Nov 2018 15:58:46 -0200 Subject: [PATCH 010/174] Adjusts compilation errors --- types/react-navigation/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 512059e29c..e51629f3af 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1136,7 +1136,7 @@ export interface TransitionerProps { transitionProps: NavigationTransitionProps, prevTransitionProps?: NavigationTransitionProps ) => any; - descriptors: { [key: string]: NavigationDescriptor }; + descriptors?: { [key: string]: NavigationDescriptor }; style?: StyleProp; } @@ -1182,7 +1182,7 @@ export interface NavigationDescriptor { state: NavigationLeafRoute | NavigationStateRoute; navigation: NavigationScreenProp; options: NavigationScreenOptions; - getComponent: () => React.ComponentType & { navigationOptions: N }; + getComponent: () => React.ComponentType; } export type NavigationView = React.ComponentType<{ From ac84fc6c7f22b49cfe4066d080109e02fdf76db9 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 9 Nov 2018 22:02:35 +0100 Subject: [PATCH 011/174] Add initial definitions for kdbxweb --- types/kdbxweb/index.d.ts | 461 +++++++++++++++++++++++++++++++++ types/kdbxweb/kdbxweb-tests.ts | 18 ++ types/kdbxweb/tsconfig.json | 23 ++ types/kdbxweb/tslint.json | 1 + 4 files changed, 503 insertions(+) create mode 100644 types/kdbxweb/index.d.ts create mode 100644 types/kdbxweb/kdbxweb-tests.ts create mode 100644 types/kdbxweb/tsconfig.json create mode 100644 types/kdbxweb/tslint.json diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts new file mode 100644 index 0000000000..2787ba7a1f --- /dev/null +++ b/types/kdbxweb/index.d.ts @@ -0,0 +1,461 @@ +// Type definitions for kdbxweb 1.2 +// Project: https://github.com/keeweb/kdbxweb#readme +// Definitions by: Roang-zero1 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import Crypto from "crypto"; + +/*~ If this module is a UMD module that exposes a global variable 'myLib' when + *~ loaded outside a module loader environment, declare that global here. + *~ Otherwise, delete this declaration. + */ +export as namespace kdbxweb; + +export interface Settings { + binaries: boolean; + customIcons: boolean; + historyRules: boolean; +} + +export interface ObjectMap { + objects: object[]; + remote: object[]; + deleted: object[]; +} + +export interface editingState { + added: [Date]; + deleted: [Date]; +} + +export interface editingStateDict { + meta: editingState; + [uuid: string]: editingState; +} + +export class Credentials { + constructor( + password: ProtectedValue, + keyFile: string | ArrayBuffer | Uint8Array + ); + + getHash(): Promise; + + setKeyFile(keyFile: ArrayBuffer | Uint8Array | null): Promise; + + setPassword(password: ProtectedValue | null): Promise; + + static createKeyFileWithHash(hash: string): Uint8Array; + + static createRandomKeyFile(): Uint8Array; +} + +export class Int64 { + constructor(lo: number, hi: number); + + valueOf(): number; + + static from(value: number): Int64; +} + +export class Kdbx { + constructor(); + + addDeletedObject(uuid: KdbxUuid, dt: Date): void; + + cleanup(settings: Settings): void; + + createBinary( + value: ProtectedValue | ArrayBuffer + ): Promise; + + createDefaultGroup(): void; + + createEntry(group: Group): Entry; + + createGroup(group: Group, name: string): Group; + + createRecycleBin(): void; + + getDefaultGroup(): Group; + + getGroup(uuid: KdbxUuid | string, parentGroup: Group): Group | undefined; + + getLocalEditState(): editingStateDict; + + merge(remote: Kdbx): void; + + move(object: Entry | Group, toGroup: Group, atIndex: number): void; + + remove(object: Entry | Group): void; + + removeLocalEditState(): void; + + save(): Promise; + + saveXml(): Promise; + + setLocalEditState(editingState: editingStateDict): void; + + upgrade(): void; + + static create(credentials: Credentials, name: string): Kdbx; + + static load(data: ArrayBuffer, credentials: Credentials): Promise; + + static loadXml(data: string, credentials: Credentials): Promise; +} + +export class KdbxError { + constructor(code: number, message: string); + + // Native method; no parameter or return type inference available + toString(): string; +} + +export class KdbxUuid { + constructor(ab: string | ArrayBuffer); + + equals(other: KdbxUuid): boolean; + + toBytes(): Uint8Array | undefined; + + toString(): string; + + valueOf(): string | undefined; + + static random(): KdbxUuid; +} + +export class ProtectedValue { + constructor(value: ArrayBuffer, salt: ArrayBuffer); + + clone(): ProtectedValue; + + getBinary(): Uint8Array; + + getHash(): Promise; + + getText(): string; + + includes(str: string): boolean; + + setSalt(newSalt: ArrayBuffer): void; + + toString(): string; + + static fromBinary(binary: ArrayBuffer): ProtectedValue; + + static fromString(str: string): ProtectedValue; +} + +export class VarDictionary { + constructor(); + + get(key: string): any; + + keys(): string[]; + + remove(key: string): void; + + set(key: string, type: number, value: any): void; + + write(stm: BinaryStream): void; + + static ValueType: { + Bool: number; + Bytes: number; + Int32: number; + Int64: number; + String: number; + UInt32: number; + UInt64: number; + }; + + static read(stm: BinaryStream): VarDictionary; +} + +export const Consts: { + AutoTypeObfuscationOptions: { + None: number; + UseClipboard: number; + }; + CipherId: { + Aes: string; + ChaCha20: string; + }; + CompressionAlgorithm: { + GZip: number; + None: number; + }; + CrsAlgorithm: { + ArcFourVariant: number; + ChaCha20: number; + Null: number; + Salsa20: number; + }; + Defaults: { + HistoryMaxItems: number; + HistoryMaxSize: number; + KeyEncryptionRounds: number; + MntncHistoryDays: number; + RecycleBinName: string; + }; + ErrorCodes: { + BadSignature: string; + FileCorrupt: string; + InvalidArg: string; + InvalidKey: string; + InvalidVersion: string; + MergeError: string; + NotImplemented: string; + Unsupported: string; + }; + Icons: { + Apple: number; + Archive: number; + BlackBerry: number; + Book: number; + CDRom: number; + Certificate: number; + Checked: number; + ClipboardReady: number; + Clock: number; + Configuration: number; + Console: number; + Digicam: number; + Disk: number; + Drive: number; + DriveWindows: number; + EMail: number; + EMailBox: number; + EMailSearch: number; + Energy: number; + EnergyCareful: number; + Expired: number; + Feather: number; + Folder: number; + FolderOpen: number; + FolderPackage: number; + Home: number; + Homebanking: number; + IRCommunication: number; + Identity: number; + Info: number; + Key: number; + List: number; + LockOpen: number; + MarkedDirectory: number; + Memory: number; + Money: number; + Monitor: number; + MultiKeys: number; + NetworkServer: number; + Note: number; + Notepad: number; + Package: number; + PaperFlag: number; + PaperLocked: number; + PaperNew: number; + PaperQ: number; + PaperReady: number; + Parts: number; + Pen: number; + Printer: number; + ProgramIcons: number; + Run: number; + Scanner: number; + Screen: number; + Settings: number; + Star: number; + TerminalEncrypted: number; + Thumbnail: number; + Tool: number; + TrashBin: number; + Tux: number; + UserCommunication: number; + UserKey: number; + Warning: number; + Wiki: number; + World: number; + WorldComputer: number; + WorldSocket: number; + WorldStar: number; + }; + KdfId: { + Aes: string; + Argon2: string; + }; + Signatures: { + FileMagic: number; + Sig2Kdb: number; + Sig2Kdbx: number; + }; +}; + +export namespace ByteUtils { + function arrayBufferEquals(ab1: ArrayBuffer, ab2: ArrayBuffer): boolean; + + function arrayToBuffer(arr: Uint8Array | ArrayBuffer): ArrayBuffer; + + function base64ToBytes(str: string): Uint8Array; + + function bytesToBase64(arr: Uint8Array | ArrayBuffer): string; + + function bytesToHex(arr: Uint8Array | ArrayBuffer): string; + + function bytesToString(arr: Uint8Array | ArrayBuffer): string; + + function hexToBytes(hex: string): Uint8Array; + + function stringToBytes(str: string): Uint8Array; + + function zeroBuffer(buffer: Uint8Array | ArrayBuffer): void; +} + +export namespace CryptoEngine { + const subtle: any; + + const webCrypto: any; + + function argon2( + password: ArrayBuffer, + salt: ArrayBuffer, + memory: number, + iterations: number, + length: number, + parallelism: number, + type: number, + version: number + ): Promise; + + function chacha20( + data: ArrayBuffer, + key: ArrayBuffer, + iv: ArrayBuffer + ): Promise; + + function configure( + newSubtle: SubtleCrypto | null, + newWebCrypto: Crypto | null, + newNodeCrypto: Crypto | null + ): void; + + function createAesCbc(): any; + + function hmacSha256( + key: ArrayBuffer, + data: ArrayBuffer + ): Promise; + + function random(len: number): Uint8Array; + + function sha256(data: ArrayBuffer): Promise; + + function sha512(data: ArrayBuffer): Promise; +} + +export namespace Random { + function getBytes(len: number): Uint8Array; +} + +export class BinaryStream { + constructor(arrayBuffer: ArrayBuffer); + + getByteLength(): number; + + getFloat32(littleEdian?: boolean): number; + + getFloat64(littleEdian?: boolean): number; + + getInt16(littleEdian?: boolean): number; + + getInt32(littleEdian?: boolean): number; + + getInt8(littleEdian?: boolean): number; + + getPos(): number; + + getUint16(littleEdian?: boolean): number; + + getUint32(littleEdian?: boolean): number; + + getUint64(littleEdian?: boolean): number; + + getUint8(littleEdian?: boolean): number; + + getWrittenBytes(): ArrayBuffer; + + readBytes(size: number): ArrayBuffer; + + readBytesNoAdvance(startPos: number, endPos: number): ArrayBuffer; + + readBytesToEnd(): ArrayBuffer; + + setFloat32(value: number, littleEdian?: boolean): void; + + setFloat64(value: number, littleEdian?: boolean): void; + + setInt16(value: number, littleEdian?: boolean): void; + + setInt32(value: number, littleEdian?: boolean): void; + + setInt8(value: number, littleEdian?: boolean): void; + + setUint16(value: number, littleEdian?: boolean): void; + + setUint32(value: number, littleEdian?: boolean): void; + + setUint64(value: number, littleEdian?: boolean): void; + + setUint8(value: number, littleEdian?: boolean): void; + + writeBytes(bytes: ArrayBuffer | Uint8Array): void; +} + +export class Context { + constructor(opts: Kdbx); + + setXmlDate(node: Node, dt: Date): void; +} + +export class Group { + constructor(); + + static create(name: string, parentGroup: Group): Group; + static read(xmlNode: Node, ctx: Context, parentGroup: Group): Group; + + write(parentNode: Node, ctx: Context): void; + forEach( + callback: ( + thisArg: (value: any) => void, + entry: Entry | undefined + ) => void, + thisArg: (value: any) => void + ): void; + merge(objectMap: ObjectMap): void; + copyFrom(group: Group): void; +} + +export class Entry { + constructor(); + + static create(meta: Meta, parentGroup: Group): Entry; + static read(xmlNode: Node, ctx: Context, parentGroup: Group): Entry; + + write(parentNode: Node, ctx: Context): void; + pushHistory(): void; + removeHistory(index: number, count: number): void; + copyFrom(entry: Entry): void; + merge(objectMap: ObjectMap): void; +} + +export class Meta { + constructor(); + + static create(): Meta; + static read(xmlNode: Node, ctx: Context): Meta; + + write(parentNode: Node, ctx: Context): void; + merge(remote: Meta, objectMap: ObjectMap): void; +} diff --git a/types/kdbxweb/kdbxweb-tests.ts b/types/kdbxweb/kdbxweb-tests.ts new file mode 100644 index 0000000000..d667117b6b --- /dev/null +++ b/types/kdbxweb/kdbxweb-tests.ts @@ -0,0 +1,18 @@ +import * as kdbxweb from "kdbxweb"; + +const dataarr = new ArrayBuffer(0); + +const credentials = new kdbxweb.Credentials( + kdbxweb.ProtectedValue.fromString("demo"), + "nFWx&e5SzT" +); + +kdbxweb.Kdbx.load(dataarr, credentials).then(db => db); +kdbxweb.Kdbx.loadXml("data", credentials).then(db => db); + +const newDb = kdbxweb.Kdbx.create(credentials, 'My new db'); +const group = newDb.createGroup(newDb.getDefaultGroup(), 'subgroup'); +const entry = newDb.createEntry(group); + +newDb.save().then(dataAsArrayBuffer => dataAsArrayBuffer); +newDb.saveXml().then(xmlAsString => xmlAsString); diff --git a/types/kdbxweb/tsconfig.json b/types/kdbxweb/tsconfig.json new file mode 100644 index 0000000000..6c6083b077 --- /dev/null +++ b/types/kdbxweb/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "kdbxweb-tests.ts" + ] +} diff --git a/types/kdbxweb/tslint.json b/types/kdbxweb/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/kdbxweb/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 2009fc1c826aae33afd1ac1c571707fa57bc328f Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 19:34:31 +0100 Subject: [PATCH 012/174] Add library for dom elements --- types/kdbxweb/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/kdbxweb/tsconfig.json b/types/kdbxweb/tsconfig.json index 6c6083b077..77578b1129 100644 --- a/types/kdbxweb/tsconfig.json +++ b/types/kdbxweb/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, From e9b486b9065591cb640120fbd92e1d1ad9c39159 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:22:08 +0100 Subject: [PATCH 013/174] Remove unnecessary import --- types/kdbxweb/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 2787ba7a1f..376e0bafde 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Roang-zero1 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Crypto from "crypto"; - /*~ If this module is a UMD module that exposes a global variable 'myLib' when *~ loaded outside a module loader environment, declare that global here. *~ Otherwise, delete this declaration. From 702978e8c6188eaaa4baf7f2d5e93a4afb94ee4d Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:24:01 +0100 Subject: [PATCH 014/174] Add KdbxObject type --- types/kdbxweb/index.d.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 376e0bafde..c781470283 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -9,6 +9,8 @@ */ export as namespace kdbxweb; +export type KdbxObject = Entry | Group; + export interface Settings { binaries: boolean; customIcons: boolean; @@ -16,9 +18,9 @@ export interface Settings { } export interface ObjectMap { - objects: object[]; - remote: object[]; - deleted: object[]; + objects: KdbxObject[]; + remote: KdbxObject[]; + deleted: KdbxObject[]; } export interface editingState { @@ -59,6 +61,8 @@ export class Int64 { export class Kdbx { constructor(); + deletedObjects: KdbxObject[]; + addDeletedObject(uuid: KdbxUuid, dt: Date): void; cleanup(settings: Settings): void; @@ -83,9 +87,9 @@ export class Kdbx { merge(remote: Kdbx): void; - move(object: Entry | Group, toGroup: Group, atIndex: number): void; + move(object: KdbxObject, toGroup: Group, atIndex?: number): void; - remove(object: Entry | Group): void; + remove(object: KdbxObject): void; removeLocalEditState(): void; From bfbd5e652499e05b03bb2d657b9f462bbe0905c1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:24:38 +0100 Subject: [PATCH 015/174] Update settings interface --- types/kdbxweb/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index c781470283..9530ad3fa8 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -12,9 +12,9 @@ export as namespace kdbxweb; export type KdbxObject = Entry | Group; export interface Settings { - binaries: boolean; - customIcons: boolean; - historyRules: boolean; + binaries?: boolean; + customIcons?: boolean; + historyRules?: boolean; } export interface ObjectMap { From 4e753b47a47b0417dc9a510f357004290f323d13 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:25:10 +0100 Subject: [PATCH 016/174] Add binaries class --- types/kdbxweb/index.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 9530ad3fa8..3f04965a59 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -23,6 +23,11 @@ export interface ObjectMap { deleted: KdbxObject[]; } +export interface BinaryInforamtion { + ref: string; + value: ProtectedValue | ArrayBuffer; +} + export interface editingState { added: [Date]; deleted: [Date]; @@ -61,6 +66,7 @@ export class Int64 { export class Kdbx { constructor(); + binaries: Binaries; deletedObjects: KdbxObject[]; addDeletedObject(uuid: KdbxUuid, dt: Date): void; @@ -415,6 +421,17 @@ export class BinaryStream { writeBytes(bytes: ArrayBuffer | Uint8Array): void; } +export class Binaries { + constructor(); + + hash(): Promise; + getBinaryHash( + binary: ProtectedValue | ArrayBuffer | Uint8Array + ): Promise; + assignIds(): void; + add(value: ProtectedValue | ArrayBuffer): Promise; +} + export class Context { constructor(opts: Kdbx); From 2224bdf11a6e5420ab6777b22570044af354bd83 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:27:47 +0100 Subject: [PATCH 017/174] Add class properties --- types/kdbxweb/index.d.ts | 93 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 3f04965a59..0e52af89c0 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -58,6 +58,9 @@ export class Credentials { export class Int64 { constructor(lo: number, hi: number); + lo: number; + hi: number; + valueOf(): number; static from(value: number): Int64; @@ -66,7 +69,12 @@ export class Int64 { export class Kdbx { constructor(); + header: Header; + credentials: Credentials; + meta: Meta; + xml: Document; binaries: Binaries; + groups: Group[]; deletedObjects: KdbxObject[]; addDeletedObject(uuid: KdbxUuid, dt: Date): void; @@ -117,6 +125,10 @@ export class Kdbx { export class KdbxError { constructor(code: number, message: string); + name: "KdbxError"; + code: number; + message: string; + // Native method; no parameter or return type inference available toString(): string; } @@ -124,6 +136,9 @@ export class KdbxError { export class KdbxUuid { constructor(ab: string | ArrayBuffer); + id: string | undefined; + empty: boolean; + equals(other: KdbxUuid): boolean; toBytes(): Uint8Array | undefined; @@ -441,6 +456,22 @@ export class Context { export class Group { constructor(); + uuid: string; + name: string; + notes: string; + icon: number; + customIcon: KdbxUuid; + times: Times; + expanded: boolean; + defaultAutoTypeSeq: string; + enableAutoType: boolean; + enableSearching: boolean; + lastTopVisibleEntry: KdbxUuid; + groups: Group[]; + entries: Entry[]; + parentGroup: Group; + customData: any; + static create(name: string, parentGroup: Group): Group; static read(xmlNode: Node, ctx: Context, parentGroup: Group): Group; @@ -459,6 +490,21 @@ export class Group { export class Entry { constructor(); + uuid: string; + icon: any; + customIcon: any; + fgColor: any; + bgColor: any; + overrideUrl: any; + tags: any[]; + times: Times; + fields: { [name: string]: any }; + binaries: {}; + autoType: any; + history: any[]; + parentGroup: Group; + customData: any; + static create(meta: Meta, parentGroup: Group): Entry; static read(xmlNode: Node, ctx: Context, parentGroup: Group): Entry; @@ -478,3 +524,50 @@ export class Meta { write(parentNode: Node, ctx: Context): void; merge(remote: Meta, objectMap: ObjectMap): void; } + +export class Header { + constructor(); + + compression: number; + crsAlgorithm: number; + dataCipherUuid: KdbxUuid; + encryptionIV: any; + endPos: number; + kdfParameters: VarDictionary; + keyEncryptionRounds: number; + masterSeed: Uint8Array; + protectedStreamKey: any; + publicCustomData: any; + streamStartBytes: any; + transformSeed: any; + versionMajor: number; + versionMinor: number; + + static read(stm: BinaryStream, ctx: Context): Header; + static create(): Header; + + generateSalts(): void; + readInnerHeader(stm: BinaryStream, ctx: Context): void; + upgrade(): void; + write(stm: BinaryStream): void; + writeInnerHeader(stm: BinaryStream, ctx: Context): void; +} + +export class Times { + constructor(); + + creationTime: Date; + lastModTime: Date; + lastAccessTime: Date; + expiryTime: Date; + expires: boolean; + usageCount: number; + locationChanged: Date; + + static create(): Times; + static read(xmlNode: Node): Times; + + clone(): Times; + update(): void; + write(parentNode: Node, ctx: Context): void; +} From 4ea7a5f73578f7230fc6f54e5c3d025a2e74fe7a Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:28:07 +0100 Subject: [PATCH 018/174] Update CryptoEngine namespace --- types/kdbxweb/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 0e52af89c0..f846123cbb 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -337,9 +337,9 @@ export namespace ByteUtils { } export namespace CryptoEngine { - const subtle: any; - - const webCrypto: any; + const subtle: SubtleCrypto | null; + const webCrypto: Crypto | null; + const NodeCrypto: Crypto | null; function argon2( password: ArrayBuffer, From 3902c860b7edf771017802786a9cbcb0168f68c2 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:28:23 +0100 Subject: [PATCH 019/174] Fix getGroup delcaration --- types/kdbxweb/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index f846123cbb..2b5952fa0e 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -95,7 +95,7 @@ export class Kdbx { getDefaultGroup(): Group; - getGroup(uuid: KdbxUuid | string, parentGroup: Group): Group | undefined; + getGroup(uuid: KdbxUuid | string, parentGroup?: Group): Group | undefined; getLocalEditState(): editingStateDict; From 8cb32a28e6b6e0e131325e0ebfcd7f60476bda8d Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:36:42 +0100 Subject: [PATCH 020/174] Update Entry properties --- types/kdbxweb/index.d.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 2b5952fa0e..e7860b1e92 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -490,18 +490,26 @@ export class Group { export class Entry { constructor(); - uuid: string; - icon: any; - customIcon: any; - fgColor: any; - bgColor: any; - overrideUrl: any; - tags: any[]; + uuid: KdbxUuid; + icon: number; + customIcon: KdbxUuid; + fgColor: string; + bgColor: string; + overrideUrl: string; + tags: string[]; times: Times; - fields: { [name: string]: any }; + fields: { [key: string]: any }; binaries: {}; - autoType: any; - history: any[]; + autoType: { + enabled: boolean; + obfuscation: number; + defaultSequence: string; + items: { + windows: string; + keystrokeSequence: string; + }; + }; + history: Entry[]; parentGroup: Group; customData: any; From 13502ed0fd81121e1206821b520f29a1587bfc83 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:49:16 +0100 Subject: [PATCH 021/174] Update header --- types/kdbxweb/index.d.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index e7860b1e92..76f7ad1e88 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -2,11 +2,8 @@ // Project: https://github.com/keeweb/kdbxweb#readme // Definitions by: Roang-zero1 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2' just under the header -/*~ If this module is a UMD module that exposes a global variable 'myLib' when - *~ loaded outside a module loader environment, declare that global here. - *~ Otherwise, delete this declaration. - */ export as namespace kdbxweb; export type KdbxObject = Entry | Group; From f96d6bb925853867ba0df91c29f489fa8037e71d Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:50:02 +0100 Subject: [PATCH 022/174] Add types --- types/kdbxweb/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 76f7ad1e88..90aa997fb7 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -172,13 +172,13 @@ export class ProtectedValue { export class VarDictionary { constructor(); - get(key: string): any; + get(key: string): object; keys(): string[]; remove(key: string): void; - set(key: string, type: number, value: any): void; + set(key: string, type: number, value: object): void; write(stm: BinaryStream): void; @@ -467,7 +467,7 @@ export class Group { groups: Group[]; entries: Entry[]; parentGroup: Group; - customData: any; + customData: {}; static create(name: string, parentGroup: Group): Group; static read(xmlNode: Node, ctx: Context, parentGroup: Group): Group; @@ -495,7 +495,7 @@ export class Entry { overrideUrl: string; tags: string[]; times: Times; - fields: { [key: string]: any }; + fields: { [key: string]: ProtectedValue | string }; binaries: {}; autoType: { enabled: boolean; @@ -508,7 +508,7 @@ export class Entry { }; history: Entry[]; parentGroup: Group; - customData: any; + customData: {}; static create(meta: Meta, parentGroup: Group): Entry; static read(xmlNode: Node, ctx: Context, parentGroup: Group): Entry; From 7b887b047d662793ec6bdaaaa799c60cc38b07b3 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:57:43 +0100 Subject: [PATCH 023/174] Update tests --- types/kdbxweb/kdbxweb-tests.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/types/kdbxweb/kdbxweb-tests.ts b/types/kdbxweb/kdbxweb-tests.ts index d667117b6b..dfc8167b4b 100644 --- a/types/kdbxweb/kdbxweb-tests.ts +++ b/types/kdbxweb/kdbxweb-tests.ts @@ -8,11 +8,27 @@ const credentials = new kdbxweb.Credentials( ); kdbxweb.Kdbx.load(dataarr, credentials).then(db => db); -kdbxweb.Kdbx.loadXml("data", credentials).then(db => db); +kdbxweb.Kdbx.loadXml("data", credentials).then(db => db); -const newDb = kdbxweb.Kdbx.create(credentials, 'My new db'); -const group = newDb.createGroup(newDb.getDefaultGroup(), 'subgroup'); +const newDb = kdbxweb.Kdbx.create(credentials, "My new db"); +const defaultGroup = newDb.getDefaultGroup(); +const group = newDb.createGroup(defaultGroup, "subgroup"); +const anotherGroup = newDb.createGroup(group, "subgroup-2"); +const yetAnotherGroup = newDb.createGroup(group, "subgroup-3"); +const deepGroup = defaultGroup.groups[0].groups[0]; + +if (newDb.getGroup(yetAnotherGroup.uuid)){ + newDb.remove(yetAnotherGroup); +} const entry = newDb.createEntry(group); +newDb.move(entry, anotherGroup); +newDb.remove(entry); newDb.save().then(dataAsArrayBuffer => dataAsArrayBuffer); newDb.saveXml().then(xmlAsString => xmlAsString); + +newDb.cleanup({ + customIcons: true +}); + +newDb.upgrade(); From 2fda9144831406ccc783172a7ff14fa049b91287 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 20:58:38 +0100 Subject: [PATCH 024/174] Fix linting issues --- types/kdbxweb/index.d.ts | 2 +- types/kdbxweb/kdbxweb-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 90aa997fb7..67dbac91f4 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/keeweb/kdbxweb#readme // Definitions by: Roang-zero1 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2' just under the header +// TypeScript Version: 2.2 export as namespace kdbxweb; diff --git a/types/kdbxweb/kdbxweb-tests.ts b/types/kdbxweb/kdbxweb-tests.ts index dfc8167b4b..86a312adb7 100644 --- a/types/kdbxweb/kdbxweb-tests.ts +++ b/types/kdbxweb/kdbxweb-tests.ts @@ -17,7 +17,7 @@ const anotherGroup = newDb.createGroup(group, "subgroup-2"); const yetAnotherGroup = newDb.createGroup(group, "subgroup-3"); const deepGroup = defaultGroup.groups[0].groups[0]; -if (newDb.getGroup(yetAnotherGroup.uuid)){ +if (newDb.getGroup(yetAnotherGroup.uuid)) { newDb.remove(yetAnotherGroup); } const entry = newDb.createEntry(group); From 2a58861813cc188a501116d5220119c558946918 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 21:36:22 +0100 Subject: [PATCH 025/174] Fix uuid types --- types/kdbxweb/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 67dbac91f4..0d9e7201fe 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -32,7 +32,7 @@ export interface editingState { export interface editingStateDict { meta: editingState; - [uuid: string]: editingState; + [uuid: KdbxUuid]: editingState; } export class Credentials { @@ -453,7 +453,7 @@ export class Context { export class Group { constructor(); - uuid: string; + uuid: KdbxUuid; name: string; notes: string; icon: number; From bc1b05a692c420e5b0987fbdca6662c0d85fbf83 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 22:02:51 +0100 Subject: [PATCH 026/174] Update property types --- types/kdbxweb/index.d.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 0d9e7201fe..ce4892e4f2 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -7,6 +7,7 @@ export as namespace kdbxweb; export type KdbxObject = Entry | Group; +export type StringProtected = ProtectedValue | string; export interface Settings { binaries?: boolean; @@ -86,7 +87,7 @@ export class Kdbx { createEntry(group: Group): Entry; - createGroup(group: Group, name: string): Group; + createGroup(group: Group, name: StringProtected): Group; createRecycleBin(): void; @@ -454,13 +455,13 @@ export class Group { constructor(); uuid: KdbxUuid; - name: string; - notes: string; + name: StringProtected; + notes: StringProtected; icon: number; customIcon: KdbxUuid; times: Times; expanded: boolean; - defaultAutoTypeSeq: string; + defaultAutoTypeSeq: StringProtected; enableAutoType: boolean; enableSearching: boolean; lastTopVisibleEntry: KdbxUuid; @@ -469,7 +470,7 @@ export class Group { parentGroup: Group; customData: {}; - static create(name: string, parentGroup: Group): Group; + static create(name: StringProtected, parentGroup: Group): Group; static read(xmlNode: Node, ctx: Context, parentGroup: Group): Group; write(parentNode: Node, ctx: Context): void; @@ -490,12 +491,12 @@ export class Entry { uuid: KdbxUuid; icon: number; customIcon: KdbxUuid; - fgColor: string; - bgColor: string; - overrideUrl: string; + fgColor: StringProtected; + bgColor: StringProtected; + overrideUrl: StringProtected; tags: string[]; times: Times; - fields: { [key: string]: ProtectedValue | string }; + fields: { [key: string]: StringProtected }; binaries: {}; autoType: { enabled: boolean; From f0e3d17c298fed30e78e03a35e66d7bbcf4645f1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 10 Nov 2018 22:14:53 +0100 Subject: [PATCH 027/174] Fix index signature parameter --- types/kdbxweb/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index ce4892e4f2..805a45a2b0 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -33,7 +33,7 @@ export interface editingState { export interface editingStateDict { meta: editingState; - [uuid: KdbxUuid]: editingState; + [uuid: string]: editingState; } export class Credentials { From 7d0a6c9d6797412a73dcd97f21ce29f56002cdd4 Mon Sep 17 00:00:00 2001 From: Shuhei Tsukaomoto Date: Sun, 11 Nov 2018 19:29:21 +0900 Subject: [PATCH 028/174] [react-map-gl]: update to 4.0 --- types/react-map-gl/index.d.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/types/react-map-gl/index.d.ts b/types/react-map-gl/index.d.ts index 136f9352bb..6a215225d7 100644 --- a/types/react-map-gl/index.d.ts +++ b/types/react-map-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-map-gl 3.3 +// Type definitions for react-map-gl 4.0 // Project: https://github.com/uber/react-map-gl#readme // Definitions by: Robert Imig // Fabio Berta @@ -18,7 +18,11 @@ export interface Viewport { } export interface MapError { + error?: { message: string; + status: number; + }; + status: number; } export interface MapRequest { @@ -145,6 +149,17 @@ export interface InteractiveMapProps extends StaticMapProps { onHover?: (event: MapEvent) => void; onClick?: (event: MapEvent) => void; + onDblClick?: (event: MapEvent) => void; + onMouseDown?: (event: MapEvent) => void; + onMouseMove?: (event: MapEvent) => void; + onMouseUp?: (event: MapEvent) => void; + onTouchStart?: (event: MapEvent) => void; + onTouchMove?: (event: MapEvent) => void; + onTouchEnd?: (event: MapEvent) => void; + onMouseEnter?: (event: MapEvent) => void; + onMouseLeave?: (event: MapEvent) => void; + onWheel?: (event: MapEvent) => void; + onMouseOut?: (event: MapEvent) => void; onContextMenu?: (event: MapEvent) => void; @@ -186,6 +201,9 @@ export interface MarkerProps extends BaseControlProps { latitude: number; offsetLeft?: number; offsetTop?: number; + onDrag: (event: any) => void; + onDragStart: (event: any) => void; + onDragEnd: (event: any) => void; } export class Marker extends BaseControl {} @@ -201,6 +219,7 @@ export interface PopupProps extends BaseControlProps { closeOnClick?: boolean; anchor?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right'; dynamicPosition?: boolean; + sortByDepth?: boolean; onClose?: () => void; } @@ -251,8 +270,6 @@ export class SVGOverlay extends BaseControl {} export namespace experimental { interface Options { - // TODO(deprecate): remove this when `onChangeViewport` gets deprecated - onChangeViewport?: (viewport: Viewport) => void; // TODO(deprecate): remove this when `touchZoomRotate` gets deprecated touchZoomRotate?: boolean; From e714e43f06cd24acf7066b41ed0941b2b2a20960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Aguilar=20Hern=C3=A1ndez?= Date: Mon, 12 Nov 2018 03:36:03 -0500 Subject: [PATCH 029/174] * Renamed property according with docs * Moved types to other file --- types/better-sqlite3/better-sqlite3-tests.ts | 2 + types/better-sqlite3/index.d.ts | 84 +------------------- types/better-sqlite3/tsconfig.json | 1 + types/better-sqlite3/types.d.ts | 80 +++++++++++++++++++ 4 files changed, 86 insertions(+), 81 deletions(-) create mode 100644 types/better-sqlite3/types.d.ts diff --git a/types/better-sqlite3/better-sqlite3-tests.ts b/types/better-sqlite3/better-sqlite3-tests.ts index 34ee6808c3..5d8b95ecf7 100644 --- a/types/better-sqlite3/better-sqlite3-tests.ts +++ b/types/better-sqlite3/better-sqlite3-tests.ts @@ -1,7 +1,9 @@ import Database = require('better-sqlite3'); +import { RunResult } from 'better-sqlite3/types'; const integer = Database.Integer(1); const err = new Database.SqliteError('ok', 'ok'); +const result: RunResult = { changes: 1, lastInsertRowid: 1 }; let db = Database('.'); db = new Database('.', {memory: true}); diff --git a/types/better-sqlite3/index.d.ts b/types/better-sqlite3/index.d.ts index 899a85a2e2..d120209765 100644 --- a/types/better-sqlite3/index.d.ts +++ b/types/better-sqlite3/index.d.ts @@ -1,89 +1,11 @@ -// Type definitions for better-sqlite3 3.1 +// Type definitions for better-sqlite3 5.0 // Project: http://github.com/JoshuaWise/better-sqlite3 // Definitions by: Ben Davies // Mathew Rumsey +// Santiago Aguilar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Integer = require('integer'); - -interface RunResult { - changes: number; - lastInsertROWID: Integer.IntLike; -} - -declare class Statement { - database: Database; - source: string; - returnsData: boolean; - constructor(db: Database, sources: string[]); - - run(...params: any[]): RunResult; - get(...params: any[]): any; - all(...params: any[]): any[]; - each(params: any, cb: (row: any) => void): void; - each(cb: (row: any) => void): void; - each(...params: any[]): void; - pluck(toggleState?: boolean): this; - bind(...params: any[]): this; - safeIntegers(toggleState?: boolean): this; -} - -declare class Transaction { - database: Database; - source: string; - constructor(db: Database, sources: string[]); - - run(...params: any[]): RunResult; - bind(...params: any[]): this; - safeIntegers(toggleState?: boolean): this; -} - -interface DatabaseOptions { - memory?: boolean; - readonly?: boolean; - fileMustExist?: boolean; -} - -interface RegistrationOptions { - name?: string; - varargs?: boolean; - deterministic?: boolean; - safeIntegers?: boolean; -} - -interface Database { - memory: boolean; - readonly: boolean; - name: string; - open: boolean; - inTransaction: boolean; - - prepare(source: string): Statement; - transaction(sources: string[]): Transaction; - exec(source: string): this; - pragma(source: string, simplify?: boolean): any; - checkpoint(databaseName?: string): this; - register(cb: (...params: any[]) => any): this; - register(options: RegistrationOptions, cb: (...params: any[]) => any): this; - close(): this; - defaultSafeIntegers(toggleState?: boolean): this; -} - -declare class SqliteError implements Error { - name: string; - message: string; - code: string; - constructor(message: string, code: string); -} - -interface DatabaseConstructor { - new(filename: string, options?: DatabaseOptions): Database; - (filename: string, options?: DatabaseOptions): Database; - prototype: Database; - - Integer: typeof Integer; - SqliteError: typeof SqliteError; -} +import { DatabaseConstructor } from "./types"; declare const Database: DatabaseConstructor; export = Database; diff --git a/types/better-sqlite3/tsconfig.json b/types/better-sqlite3/tsconfig.json index 30a480355b..891afa0aad 100644 --- a/types/better-sqlite3/tsconfig.json +++ b/types/better-sqlite3/tsconfig.json @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", + "types.d.ts", "better-sqlite3-tests.ts" ] } \ No newline at end of file diff --git a/types/better-sqlite3/types.d.ts b/types/better-sqlite3/types.d.ts new file mode 100644 index 0000000000..61f376b0bf --- /dev/null +++ b/types/better-sqlite3/types.d.ts @@ -0,0 +1,80 @@ +import Integer = require("integer"); + +export interface RunResult { + changes: number; + lastInsertRowid: Integer.IntLike; +} + +export class Statement { + database: Database; + source: string; + returnsData: boolean; + constructor(db: Database, sources: string[]); + + run(...params: any[]): RunResult; + get(...params: any[]): any; + all(...params: any[]): any[]; + each(params: any, cb: (row: any) => void): void; + each(cb: (row: any) => void): void; + each(...params: any[]): void; + pluck(toggleState?: boolean): this; + bind(...params: any[]): this; + safeIntegers(toggleState?: boolean): this; +} + +export class Transaction { + database: Database; + source: string; + constructor(db: Database, sources: string[]); + + run(...params: any[]): RunResult; + bind(...params: any[]): this; + safeIntegers(toggleState?: boolean): this; +} + +export interface DatabaseOptions { + memory?: boolean; + readonly?: boolean; + fileMustExist?: boolean; +} + +export interface RegistrationOptions { + name?: string; + varargs?: boolean; + deterministic?: boolean; + safeIntegers?: boolean; +} + +export interface Database { + memory: boolean; + readonly: boolean; + name: string; + open: boolean; + inTransaction: boolean; + + prepare(source: string): Statement; + transaction(sources: string[]): Transaction; + exec(source: string): this; + pragma(source: string, simplify?: boolean): any; + checkpoint(databaseName?: string): this; + register(cb: (...params: any[]) => any): this; + register(options: RegistrationOptions, cb: (...params: any[]) => any): this; + close(): this; + defaultSafeIntegers(toggleState?: boolean): this; +} + +export class SqliteError implements Error { + name: string; + message: string; + code: string; + constructor(message: string, code: string); +} + +export interface DatabaseConstructor { + new (filename: string, options?: DatabaseOptions): Database; + (filename: string, options?: DatabaseOptions): Database; + prototype: Database; + + Integer: typeof Integer; + SqliteError: typeof SqliteError; +} From 980b86eed1eea61b54c716c67dde90fce38ab7e8 Mon Sep 17 00:00:00 2001 From: Alex Lipatov Date: Mon, 12 Nov 2018 06:16:42 -0500 Subject: [PATCH 030/174] Update middleware callbaback signature to take 4 arguments instead of 2 --- types/swagger-express-middleware/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/swagger-express-middleware/index.d.ts b/types/swagger-express-middleware/index.d.ts index acc36d3356..11c4e31c21 100644 --- a/types/swagger-express-middleware/index.d.ts +++ b/types/swagger-express-middleware/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for swagger-express-middleware 1.x // Project: https://github.com/BigstickCarpet/swagger-express-middleware // Definitions by: Alexandre Roba +// Updated by: Tromgy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -39,8 +40,9 @@ declare module "swagger-express-middleware" { (apiDefinitionPathOrObject: string | SwaggerObject, appOrRouter: Application | Router, cb: SwaggerMiddlewareConstructorCallback): SwaggerMiddleware; } interface SwaggerMiddlewareConstructorCallback { - (err: any, middleware: SwaggerMiddleware): void; + (err: any, middleware: SwaggerMiddleware, api: any, parser: any): void; } + export interface SwaggerMiddleware { /** * Annotates the HTTP request (the `req` object) with Swagger metadata. From 11f845bdfc61f1bcee44e37f432f155b881ef408 Mon Sep 17 00:00:00 2001 From: Alex Lipatov Date: Mon, 12 Nov 2018 07:26:41 -0500 Subject: [PATCH 031/174] Update test to use new callback argument. --- .../swagger-express-middleware/PetStore.yaml | 45 +++++++++++++++++++ types/swagger-express-middleware/index.d.ts | 2 +- .../swagger-express-middleware-tests.ts | 17 ++++++- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 types/swagger-express-middleware/PetStore.yaml diff --git a/types/swagger-express-middleware/PetStore.yaml b/types/swagger-express-middleware/PetStore.yaml new file mode 100644 index 0000000000..ae4f16b3b1 --- /dev/null +++ b/types/swagger-express-middleware/PetStore.yaml @@ -0,0 +1,45 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: Swagger Petstore + description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification + termsOfService: 'http://swagger.io/terms/' + contact: + name: Swagger API Team + license: + name: MIT +host: petstore.swagger.io +basePath: /api +schemes: + - http +consumes: + - application/json +produces: + - application/json +paths: + /pets: + get: + description: Returns all pets from the system that the user has access to + produces: + - application/json + responses: + '200': + description: A list of pets. + schema: + type: array + items: + $ref: '#/definitions/Pet' +definitions: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string diff --git a/types/swagger-express-middleware/index.d.ts b/types/swagger-express-middleware/index.d.ts index 11c4e31c21..80d56ae812 100644 --- a/types/swagger-express-middleware/index.d.ts +++ b/types/swagger-express-middleware/index.d.ts @@ -1,7 +1,7 @@ // Type definitions for swagger-express-middleware 1.x // Project: https://github.com/BigstickCarpet/swagger-express-middleware // Definitions by: Alexandre Roba -// Updated by: Tromgy +// Tromgy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/swagger-express-middleware/swagger-express-middleware-tests.ts b/types/swagger-express-middleware/swagger-express-middleware-tests.ts index 1a01d8475d..8717755725 100644 --- a/types/swagger-express-middleware/swagger-express-middleware-tests.ts +++ b/types/swagger-express-middleware/swagger-express-middleware-tests.ts @@ -4,7 +4,7 @@ import SwaggerExpressMiddleware = require("swagger-express-middleware"); let app = express(); let router = express.Router(); -SwaggerExpressMiddleware("PetStore.yaml", app, (err: any, middleware: SwaggerExpressMiddleware.SwaggerMiddleware) => { +SwaggerExpressMiddleware("PetStore.yaml", app, (err: any, middleware: SwaggerExpressMiddleware.SwaggerMiddleware, api) => { let filesOptions: SwaggerExpressMiddleware.FilesOptions = { useBasePath: false, apiPath: "/api-docs/", @@ -30,6 +30,20 @@ SwaggerExpressMiddleware("PetStore.yaml", app, (err: any, middleware: SwaggerExp } + // Demonstrates use of the swagger basePath, it is available from the third argument of the callback + // Complile and run this sample, then do a GET from http://localhost:8000/api/pets + // If for instance you create version 2 of your API, but in this new version "GET pets" implementation + // does not change, you only need to change the basePath to "/api/v2" in the + // swagger YAML file, and this method will still be called. + app.get(`${api.basePath}/pets`, (req, res, next) => { + res.json( + [ + { id: 'pet_1', name: 'Itchy' }, + { id: 'pet_2', name: 'Scratchy' } + ] + ); + }); + app.use( middleware.metadata(router), middleware.CORS(), @@ -991,4 +1005,3 @@ let uberApiDefinition: SwaggerExpressMiddleware.SwaggerObject = } } } - From 79605fcbf13c7785f3f9409cf29d741721c62bf4 Mon Sep 17 00:00:00 2001 From: Stefano Bourscheid Date: Tue, 13 Nov 2018 14:26:48 +0100 Subject: [PATCH 032/174] Add subs types declaration --- types/react-native-video/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/react-native-video/index.d.ts b/types/react-native-video/index.d.ts index 190d731394..698d919d1c 100644 --- a/types/react-native-video/index.d.ts +++ b/types/react-native-video/index.d.ts @@ -32,6 +32,12 @@ export interface LoadError { }; } +declare const TextTrackType: { + SRT: "application/x-subrip", + TTML: "application/ttml+xml", + VTT: "text/vtt" +} + export interface VideoProperties extends ViewProps { /* Native only */ src?: any; From bb14e16ea403e8e56e38b8b2219f84d091b481e9 Mon Sep 17 00:00:00 2001 From: Stefano Bourscheid Date: Tue, 13 Nov 2018 16:30:56 +0100 Subject: [PATCH 033/174] Add support for 3.1 subs props --- types/react-native-video/index.d.ts | 157 +++++++++++++++------------- 1 file changed, 84 insertions(+), 73 deletions(-) diff --git a/types/react-native-video/index.d.ts b/types/react-native-video/index.d.ts index 698d919d1c..f20cd68664 100644 --- a/types/react-native-video/index.d.ts +++ b/types/react-native-video/index.d.ts @@ -1,13 +1,11 @@ -// Type definitions for react-native-video 2.0 +// Type definitions for react-native-video 2.0 and 3.1 // Project: https://github.com/react-native-community/react-native-video // Definitions by: HuHuanming // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from 'react'; -import { - ViewProps -} from 'react-native'; +import { ViewProps } from 'react-native'; export interface OnLoadData { canPlayFastForward: boolean; @@ -33,80 +31,93 @@ export interface LoadError { } declare const TextTrackType: { - SRT: "application/x-subrip", - TTML: "application/ttml+xml", - VTT: "text/vtt" -} + SRT: 'application/x-subrip'; + TTML: 'application/ttml+xml'; + VTT: 'text/vtt'; +}; export interface VideoProperties extends ViewProps { - /* Native only */ - src?: any; - seek?: number; - fullscreen?: boolean; - onVideoLoadStart?(): void; - onVideoLoad?(): void; - onVideoBuffer?(): void; - onVideoError?(): void; - onVideoProgress?(): void; - onVideoSeek?(): void; - onVideoEnd?(): void; - onTimedMetadata?(): void; - onVideoFullscreenPlayerWillPresent?(): void; - onVideoFullscreenPlayerDidPresent?(): void; - onVideoFullscreenPlayerWillDismiss?(): void; - onVideoFullscreenPlayerDidDismiss?(): void; + /* Native only */ + src?: any; + seek?: number; + fullscreen?: boolean; + onVideoLoadStart?(): void; + onVideoLoad?(): void; + onVideoBuffer?(): void; + onVideoError?(): void; + onVideoProgress?(): void; + onVideoSeek?(): void; + onVideoEnd?(): void; + onTimedMetadata?(): void; + onVideoFullscreenPlayerWillPresent?(): void; + onVideoFullscreenPlayerDidPresent?(): void; + onVideoFullscreenPlayerWillDismiss?(): void; + onVideoFullscreenPlayerDidDismiss?(): void; - /* Wrapper component */ - // Opaque type returned by require('./video.mp4') - source: { uri?: string } | number; - resizeMode?: string; - poster?: string; - repeat?: boolean; - paused?: boolean; - muted?: boolean; - volume?: number; - rate?: number; - playInBackground?: boolean; - playWhenInactive?: boolean; - ignoreSilentSwitch?: 'ignore' | 'obey'; - disableFocus?: boolean; - controls?: boolean; - currentTime?: number; - progressUpdateInterval?: number; - useTextureView?: boolean; - allowsExternalPlayback?: boolean; - onLoadStart?(): void; - onLoad?(data: OnLoadData): void; - onBuffer?(): void; - onError?(error: LoadError): void; - onProgress?(data: { - currentTime: number; - playableDuration: number; - seekableDuration: number; - }): void; - onSeek?(): void; - onEnd?(): void; - onFullscreenPlayerWillPresent?(): void; - onFullscreenPlayerDidPresent?(): void; - onFullscreenPlayerWillDismiss?(): void; - onFullscreenPlayerDidDismiss?(): void; - onReadyForDisplay?(): void; - onPlaybackStalled?(): void; - onPlaybackResume?(): void; - onPlaybackRateChange?(): void; - onAudioFocusChanged?(): void; - onAudioBecomingNoisy?(): void; + /* Wrapper component */ + // Opaque type returned by require('./video.mp4') + source: { uri?: string } | number; + resizeMode?: string; + poster?: string; + repeat?: boolean; + paused?: boolean; + muted?: boolean; + volume?: number; + rate?: number; + playInBackground?: boolean; + playWhenInactive?: boolean; + ignoreSilentSwitch?: 'ignore' | 'obey'; + disableFocus?: boolean; + controls?: boolean; + currentTime?: number; + progressUpdateInterval?: number; + useTextureView?: boolean; + allowsExternalPlayback?: boolean; - /* Required by react-native */ - scaleX?: number; - scaleY?: number; - translateX?: number; - translateY?: number; - rotation?: number; + onLoadStart?(): void; + onLoad?(data: OnLoadData): void; + onBuffer?(): void; + onError?(error: LoadError): void; + onProgress?(data: { + currentTime: number; + playableDuration: number; + seekableDuration: number; + }): void; + onSeek?(): void; + onEnd?(): void; + onFullscreenPlayerWillPresent?(): void; + onFullscreenPlayerDidPresent?(): void; + onFullscreenPlayerWillDismiss?(): void; + onFullscreenPlayerDidDismiss?(): void; + onReadyForDisplay?(): void; + onPlaybackStalled?(): void; + onPlaybackResume?(): void; + onPlaybackRateChange?(): void; + onAudioFocusChanged?(): void; + onAudioBecomingNoisy?(): void; + + /* 3.0 onwards */ + selectedTextTrack?: { + type: 'system' | 'disabled' | 'title' | 'language' | 'index'; + value?: string | number; + }; + textTracks?: { + title?: string; + language?: string; + type: 'application/x-subrip' | 'application/ttml+xml' | 'text/vtt'; + uri: string; + }[]; + + /* Required by react-native */ + scaleX?: number; + scaleY?: number; + translateX?: number; + translateY?: number; + rotation?: number; } export default class Video extends React.Component { - seek(time: number, tolerance?: number): void; - presentFullscreenPlayer(): void; - dismissFullscreenPlayer(): void; + seek(time: number, tolerance?: number): void; + presentFullscreenPlayer(): void; + dismissFullscreenPlayer(): void; } From 136608196335a0b2dfdffbcdb6a818eda82d863f Mon Sep 17 00:00:00 2001 From: Stefano Bourscheid Date: Tue, 13 Nov 2018 16:36:13 +0100 Subject: [PATCH 034/174] Fix CI errors --- types/react-native-video/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native-video/index.d.ts b/types/react-native-video/index.d.ts index f20cd68664..726169caca 100644 --- a/types/react-native-video/index.d.ts +++ b/types/react-native-video/index.d.ts @@ -30,7 +30,7 @@ export interface LoadError { }; } -declare const TextTrackType: { +export const TextTrackType: { SRT: 'application/x-subrip'; TTML: 'application/ttml+xml'; VTT: 'text/vtt'; @@ -101,12 +101,12 @@ export interface VideoProperties extends ViewProps { type: 'system' | 'disabled' | 'title' | 'language' | 'index'; value?: string | number; }; - textTracks?: { + textTracks?: Array<{ title?: string; language?: string; type: 'application/x-subrip' | 'application/ttml+xml' | 'text/vtt'; uri: string; - }[]; + }>; /* Required by react-native */ scaleX?: number; From f125ffc14e21869c7d8a71a2c5a620b24a978b4c Mon Sep 17 00:00:00 2001 From: Alex Lipatov Date: Tue, 13 Nov 2018 19:10:43 -0500 Subject: [PATCH 035/174] Make more specific type definitions. --- types/swagger-express-middleware/index.d.ts | 7 ++++++- .../swagger-express-middleware-tests.ts | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/swagger-express-middleware/index.d.ts b/types/swagger-express-middleware/index.d.ts index 80d56ae812..4d83cebfb0 100644 --- a/types/swagger-express-middleware/index.d.ts +++ b/types/swagger-express-middleware/index.d.ts @@ -40,7 +40,7 @@ declare module "swagger-express-middleware" { (apiDefinitionPathOrObject: string | SwaggerObject, appOrRouter: Application | Router, cb: SwaggerMiddlewareConstructorCallback): SwaggerMiddleware; } interface SwaggerMiddlewareConstructorCallback { - (err: any, middleware: SwaggerMiddleware, api: any, parser: any): void; + (err: any, middleware: SwaggerMiddleware, api: SwaggerObject, parser: SwaggerParser): void; } export interface SwaggerMiddleware { @@ -363,6 +363,11 @@ declare module "swagger-express-middleware" { externalDocs?: ExternalDocumentationObject } + export interface SwaggerParser { + $refs: any + schema: SwaggerObject + } + type MimeTypes = string[] export interface InfoObject { diff --git a/types/swagger-express-middleware/swagger-express-middleware-tests.ts b/types/swagger-express-middleware/swagger-express-middleware-tests.ts index 8717755725..37bbf66ec7 100644 --- a/types/swagger-express-middleware/swagger-express-middleware-tests.ts +++ b/types/swagger-express-middleware/swagger-express-middleware-tests.ts @@ -4,7 +4,9 @@ import SwaggerExpressMiddleware = require("swagger-express-middleware"); let app = express(); let router = express.Router(); -SwaggerExpressMiddleware("PetStore.yaml", app, (err: any, middleware: SwaggerExpressMiddleware.SwaggerMiddleware, api) => { +SwaggerExpressMiddleware("PetStore.yaml", app, (err: any, + middleware: SwaggerExpressMiddleware.SwaggerMiddleware, + api: SwaggerExpressMiddleware.SwaggerObject) => { let filesOptions: SwaggerExpressMiddleware.FilesOptions = { useBasePath: false, apiPath: "/api-docs/", From 0218259e41efedfd2253da837ea5cc49988c9ac8 Mon Sep 17 00:00:00 2001 From: Alex Lipatov Date: Tue, 13 Nov 2018 19:28:03 -0500 Subject: [PATCH 036/174] Remove sample swagger file (used in the test) - apparently Travis doesn't know it is actually used. --- .../swagger-express-middleware/PetStore.yaml | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 types/swagger-express-middleware/PetStore.yaml diff --git a/types/swagger-express-middleware/PetStore.yaml b/types/swagger-express-middleware/PetStore.yaml deleted file mode 100644 index ae4f16b3b1..0000000000 --- a/types/swagger-express-middleware/PetStore.yaml +++ /dev/null @@ -1,45 +0,0 @@ -swagger: '2.0' -info: - version: 1.0.0 - title: Swagger Petstore - description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification - termsOfService: 'http://swagger.io/terms/' - contact: - name: Swagger API Team - license: - name: MIT -host: petstore.swagger.io -basePath: /api -schemes: - - http -consumes: - - application/json -produces: - - application/json -paths: - /pets: - get: - description: Returns all pets from the system that the user has access to - produces: - - application/json - responses: - '200': - description: A list of pets. - schema: - type: array - items: - $ref: '#/definitions/Pet' -definitions: - Pet: - type: object - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string From a0df8f39a019eeded79d2a5c6abf1a90fd5b0f7a Mon Sep 17 00:00:00 2001 From: Mihai Dinculescu Date: Thu, 15 Nov 2018 12:07:20 +0000 Subject: [PATCH 037/174] redux-immutable-state-invariant: redux 4 support. --- types/redux-immutable-state-invariant/index.d.ts | 4 ++-- types/redux-immutable-state-invariant/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/redux-immutable-state-invariant/index.d.ts b/types/redux-immutable-state-invariant/index.d.ts index 6ad2a0e588..64c3fa6851 100644 --- a/types/redux-immutable-state-invariant/index.d.ts +++ b/types/redux-immutable-state-invariant/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for redux-immutable-state-invariant v2.0.0 +// Type definitions for redux-immutable-state-invariant v2.1.0 // Project: https://github.com/leoasis/redux-immutable-state-invariant -// Definitions by: Remo H. Jansen , Ben Rogers +// Definitions by: Remo H. Jansen , Ben Rogers , Mihai Dinculescu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Redux from "redux"; diff --git a/types/redux-immutable-state-invariant/package.json b/types/redux-immutable-state-invariant/package.json index 6d68bf2f9b..998f8e9b38 100644 --- a/types/redux-immutable-state-invariant/package.json +++ b/types/redux-immutable-state-invariant/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "redux": "^3.6.0" + "redux": "^3.6.0 || ^4.0.0" } } From 1d5101593cc01612f67c9bbd07f814f01c94a67b Mon Sep 17 00:00:00 2001 From: Mihai Dinculescu Date: Thu, 15 Nov 2018 12:20:14 +0000 Subject: [PATCH 038/174] Add TypeScript version. --- types/redux-immutable-state-invariant/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/redux-immutable-state-invariant/index.d.ts b/types/redux-immutable-state-invariant/index.d.ts index 64c3fa6851..502f7e65bf 100644 --- a/types/redux-immutable-state-invariant/index.d.ts +++ b/types/redux-immutable-state-invariant/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/leoasis/redux-immutable-state-invariant // Definitions by: Remo H. Jansen , Ben Rogers , Mihai Dinculescu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as Redux from "redux"; From e4b6fecfdc601e8a9b85bb567171c0806d82c344 Mon Sep 17 00:00:00 2001 From: Hiroshi Ioka Date: Fri, 16 Nov 2018 08:35:26 +0900 Subject: [PATCH 039/174] @types/koa-bodyparser: use any for Request.body Also, fix Request.rawBody and library version. --- types/koa-bodyparser/index.d.ts | 10 ++++++---- types/koa-bodyparser/koa-bodyparser-tests.ts | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/types/koa-bodyparser/index.d.ts b/types/koa-bodyparser/index.d.ts index deb1eb04e9..9687f15ff9 100644 --- a/types/koa-bodyparser/index.d.ts +++ b/types/koa-bodyparser/index.d.ts @@ -1,6 +1,8 @@ -// Type definitions for koa-bodyparser 5.0 +// Type definitions for koa-bodyparser 4.2 // Project: https://github.com/koajs/bodyparser -// Definitions by: Jerry Chin , Anup Kishore +// Definitions by: Jerry Chin +// Anup Kishore +// Hiroshi Ioka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -18,8 +20,8 @@ import * as Koa from "koa"; declare module "koa" { interface Request { - body: {} | null | undefined; - rawBody: {} | null | undefined; + body: any; + rawBody: string; } } diff --git a/types/koa-bodyparser/koa-bodyparser-tests.ts b/types/koa-bodyparser/koa-bodyparser-tests.ts index e38eb112dd..6b14693914 100644 --- a/types/koa-bodyparser/koa-bodyparser-tests.ts +++ b/types/koa-bodyparser/koa-bodyparser-tests.ts @@ -7,6 +7,7 @@ app.use(bodyParser({ strict: false })); app.use((ctx) => { console.log(ctx.request.body); + console.log(ctx.request.body.ok); console.log(ctx.request.rawBody); }); From 1e5d13c5544fc148545dba075306ecc49aee0c1f Mon Sep 17 00:00:00 2001 From: Christophe Hurpeau Date: Fri, 16 Nov 2018 21:43:44 +0100 Subject: [PATCH 040/174] webpack: NormalModuleReplacementPlugin doesnt seems deprecated doc here: https://webpack.js.org/plugins/normal-module-replacement-plugin/ --- types/webpack/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 357c63e330..f5beb1dc63 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1394,7 +1394,6 @@ declare namespace webpack { constructor(); } - /** @deprecated use webpack.NoEmitOnErrorsPlugin */ class NormalModuleReplacementPlugin extends Plugin { constructor(resourceRegExp: any, newResource: any); } From cd38ae33dea2dd375ae01a31399d85eeb1f219a6 Mon Sep 17 00:00:00 2001 From: islishude Date: Sat, 17 Nov 2018 12:41:11 +0800 Subject: [PATCH 041/174] [node]: add props to repl.Context --- types/node/index.d.ts | 4 +++- types/node/node-tests.ts | 6 ++++++ types/node/v9/index.d.ts | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index fdda9e948a..221dd5baad 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2501,7 +2501,9 @@ declare module "readline" { } declare module "vm" { - interface Context { } + interface Context { + [key: string]: any; + } interface BaseOptions { /** * Specifies the filename used in stack traces produced by this script. diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 20159c70d9..0ae3866a8a 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3675,6 +3675,12 @@ import * as p from "process"; function test() { throw new repl.Recoverable(new Error("test")); } + + _server.context.key0 = 1; + _server.context.key1 = "string"; + _server.context.key2 = true; + _server.context.key3 = []; + _server.context.key4 = {}; } } diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 4678c59c74..b620ac9ce1 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -2390,7 +2390,9 @@ declare module "readline" { } declare module "vm" { - export interface Context { } + export interface Context { + [key: string]: any; + } export interface ScriptOptions { filename?: string; lineOffset?: number; From 25c1531d1cf4b4e6ebc0d708b65529b7be89d0a9 Mon Sep 17 00:00:00 2001 From: loveky Date: Sat, 17 Nov 2018 23:08:51 +0800 Subject: [PATCH 042/174] Update definition for webpack-chain to match version 5.0 --- types/webpack-chain/index.d.ts | 4 ++-- types/webpack-chain/webpack-chain-tests.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/webpack-chain/index.d.ts b/types/webpack-chain/index.d.ts index 033ef9951f..d821d13417 100644 --- a/types/webpack-chain/index.d.ts +++ b/types/webpack-chain/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack-chain 4.8 +// Type definitions for webpack-chain 5.0 // Project: https://github.com/mozilla-neutrino/webpack-chain // Definitions by: Eirikur Nilsson , Paul Sachs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -209,7 +209,7 @@ declare namespace Config { flagIncludedChunks(value: boolean): this; mergeDuplicateChunks(value: boolean): this; minimize(value: boolean): this; - minimizer(value: webpack.Plugin[]): this; + minimizer(name: string): Plugin; namedChunks(value: boolean): this; namedModules(value: boolean): this; nodeEnv(value: boolean | string): this; diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index f1d0daa5e2..b655df07ea 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -173,7 +173,9 @@ config .flagIncludedChunks(true) .mergeDuplicateChunks(true) .minimize(true) - .minimizer([]) + .minimizer('foo') + .use(webpack.DefinePlugin) + .end() .namedChunks(true) .namedModules(true) .nodeEnv(true) From c6b16d03af70d28b26eccdf2a452984f14d10b5f Mon Sep 17 00:00:00 2001 From: Shuhei Tsukaomoto Date: Sun, 18 Nov 2018 16:24:48 +0900 Subject: [PATCH 043/174] update: add MjolnirEvent. --- types/react-map-gl/index.d.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/types/react-map-gl/index.d.ts b/types/react-map-gl/index.d.ts index 6a215225d7..7f59244154 100644 --- a/types/react-map-gl/index.d.ts +++ b/types/react-map-gl/index.d.ts @@ -78,6 +78,22 @@ export interface MapEvent { features: Array<{}>; } +export interface MjolnirEvent { + type: string; + offsetCenter: {x: number, y: number}; + deltaX: number; + deltaY: number; + delta: number; + scale: number; + rotation: number; + pointerType: string; + metaKey: boolean; + rightButton: boolean; + stopPropagation: () => void; + preventDefault: () => void; + srcEvent: any; +} + export interface Center { x: number; y: number; @@ -201,9 +217,9 @@ export interface MarkerProps extends BaseControlProps { latitude: number; offsetLeft?: number; offsetTop?: number; - onDrag: (event: any) => void; - onDragStart: (event: any) => void; - onDragEnd: (event: any) => void; + onDrag: (event: MjolnirEvent) => void; + onDragStart: (event: MjolnirEvent) => void; + onDragEnd: (event: MjolnirEvent) => void; } export class Marker extends BaseControl {} From 43ced3fe679143e0e60eb966d1d03db48991925a Mon Sep 17 00:00:00 2001 From: Fabio Berta Date: Sun, 18 Nov 2018 12:58:37 +0100 Subject: [PATCH 044/174] update for 4.0 --- types/react-map-gl/index.d.ts | 269 ++++++++++++---------- types/react-map-gl/react-map-gl-tests.tsx | 18 +- 2 files changed, 150 insertions(+), 137 deletions(-) diff --git a/types/react-map-gl/index.d.ts b/types/react-map-gl/index.d.ts index 7f59244154..4522ddf729 100644 --- a/types/react-map-gl/index.d.ts +++ b/types/react-map-gl/index.d.ts @@ -9,12 +9,13 @@ import * as React from 'react'; import * as MapboxGL from 'mapbox-gl'; import * as GeoJSON from 'geojson'; -export interface Viewport { +export interface ViewState { latitude: number; longitude: number; zoom: number; bearing?: number; pitch?: number; + altitude?: number; } export interface MapError { @@ -31,31 +32,37 @@ export interface MapRequest { credentials?: string; } -export interface MapboxProps extends Partial { - container?: {}; +export interface MapboxProps extends Partial { + container?: object; + gl?: object; mapboxApiAccessToken?: string; attributionControl?: boolean; preserveDrawingBuffer?: boolean; + reuseMaps?: boolean; + transformRequest?: (url?: string, resourceType?: string) => MapRequest; + mapOptions?: object; + mapStyle?: string | object; + visible?: boolean; onLoad?: () => void; onError?: (e: MapError) => void; - reuseMaps?: boolean; reuseMap?: boolean; - transformRequest?: (url?: string, resourceType?: string) => MapRequest; - - mapStyle?: string | {}; - - width: number; - height: number; - - viewState?: Viewport; - - altitude?: number; // Note: Non-public API, see https://github.com/mapbox/mapbox-gl-js/issues/1137 + width: number | string; + height: number | string; + viewState?: ViewState; } export interface StaticMapProps extends MapboxProps { + onResize?: (dimensions: { width: number; height: number }) => void; preventStyleDiffing?: boolean; - visible?: boolean; + disableTokenWarning?: boolean; className?: string; + style?: object; + visibilityConstraints?: { + minZoom?: number; + maxZoom?: number; + minPitch?: number; + maxPitch?: number; + }; } export interface QueryRenderedFeaturesParams { @@ -68,30 +75,71 @@ export class StaticMap extends React.Component { queryRenderedFeatures(geometry?: MapboxGL.PointLike | MapboxGL.PointLike[], parameters?: QueryRenderedFeaturesParams): Array>; } -export interface InteractiveMapState { +export interface ExtraState { isDragging: boolean; isHovering: boolean; } -export interface MapEvent { - lngLat: [number, number]; - features: Array<{}>; +export interface PositionInput { + pos: [number, number]; } -export interface MjolnirEvent { - type: string; - offsetCenter: {x: number, y: number}; - deltaX: number; - deltaY: number; - delta: number; - scale: number; - rotation: number; - pointerType: string; - metaKey: boolean; - rightButton: boolean; - stopPropagation: () => void; - preventDefault: () => void; - srcEvent: any; +export interface MapControllerOptions { + onViewportChange?: (viewState: ViewState) => void; + onStateChange?: (state: MapState) => void; + eventManager?: any; + isInteractive: boolean; + scrollZoom?: boolean; + dragPan?: boolean; + dragRotate?: boolean; + doubleClickZoom?: boolean; + touchZoom?: boolean; + touchRotate?: boolean; + keyboard?: boolean; +} + +export interface ViewportProps { + width: number; + height: number; + latitude: number; + longitude: number; + zoom: number; + bearing: number; + pitch: number; + altitude: number; + maxZoom: number; + minZoom: number; + maxPitch: number; + minPitch: number; + transitionDuration?: number; + transitionInterpolator?: TransitionInterpolator; + transitionInterruption?: TRANSITION_EVENTS; + transitionEasing?: EasingFunction; +} + +export interface InteractiveState { + startPanLngLat?: [number, number]; + startZoomLngLat?: [number, number]; + startBearing?: number; + startPitch?: number; + startZoom?: number; +} + +export type MapStateProps = Partial; + +export class MapState { + constructor(props: MapStateProps); + getViewportProps(): ViewportProps; + getInteractiveState(): InteractiveState; + panStart(input: PositionInput): MapState; + pan(input: PositionInput & { startPos?: [number, number] }): MapState; + panEnd(): MapState; + rotateStart(input: PositionInput): MapState; + rotate(input: { deltaScaleX?: number; deltaScaleY?: number }): MapState; + rotateEnd(): MapState; + zoomStart(input: PositionInput): MapState; + zoom(input: PositionInput & { scale: number; startPos?: [number, number] }): MapState; + zoomEnd(): MapState; } export interface Center { @@ -113,11 +161,30 @@ export interface MapControlEvent { delta?: number; } -export interface BaseMapControls { +export interface BaseMapController { events: string[]; handleEvent(event: MapControlEvent): void; } +export class MapController implements BaseMapController { + events: string[]; + handleEvent(event: MapControlEvent): void; + getMapState(overrides: Partial): MapState; + setOptions(options: MapControllerOptions): void; + setState(newState: MapState): void; + updateViewport(newMapState: MapState, extraProps: any, extraState: ExtraState): void; +} + +export interface PointerEvent { + type: string; + point: [number, number]; + lngLat: [number, number]; + target: any; + srcEvent: any; + // backward compatibility: v3 interface + features: any[]; +} + export type EasingFunction = (t: number) => number; export enum TRANSITION_EVENTS { @@ -135,7 +202,7 @@ export class LinearInterpolator extends TransitionInterpolator { export class FlyToInterpolator extends TransitionInterpolator {} export interface ViewStateChangeInfo { - viewState: Viewport; + viewState: ViewState; } export interface InteractiveMapProps extends StaticMapProps { @@ -143,10 +210,9 @@ export interface InteractiveMapProps extends StaticMapProps { minZoom?: number; maxPitch?: number; minPitch?: number; - - onViewportChange?: (viewport: Viewport) => void; onViewStateChange?: (info: ViewStateChangeInfo) => void; - + onViewportChange?: (viewState: ViewState) => void; + onInteractionStateChange?: (state: ExtraState) => void; transitionDuration?: number; transitionInterpolator?: TransitionInterpolator; transitionInterruption?: TRANSITION_EVENTS; @@ -154,7 +220,6 @@ export interface InteractiveMapProps extends StaticMapProps { onTransitionStart?: () => void; onTransitionInterrupt?: () => void; onTransitionEnd?: () => void; - scrollZoom?: boolean; dragPan?: boolean; dragRotate?: boolean; @@ -162,37 +227,25 @@ export interface InteractiveMapProps extends StaticMapProps { touchZoom?: boolean; touchRotate?: boolean; keyboard?: boolean; - - onHover?: (event: MapEvent) => void; - onClick?: (event: MapEvent) => void; - onDblClick?: (event: MapEvent) => void; - onMouseDown?: (event: MapEvent) => void; - onMouseMove?: (event: MapEvent) => void; - onMouseUp?: (event: MapEvent) => void; - onTouchStart?: (event: MapEvent) => void; - onTouchMove?: (event: MapEvent) => void; - onTouchEnd?: (event: MapEvent) => void; - onMouseEnter?: (event: MapEvent) => void; - onMouseLeave?: (event: MapEvent) => void; - onWheel?: (event: MapEvent) => void; - onMouseOut?: (event: MapEvent) => void; - - onContextMenu?: (event: MapEvent) => void; - + onHover?: (event: PointerEvent) => void; + onClick?: (event: PointerEvent) => void; + onDblClick?: (event: PointerEvent) => void; + onContextMenu?: (event: PointerEvent) => void; + onMouseDown?: (event: PointerEvent) => void; + onMouseMove?: (event: PointerEvent) => void; + onMouseUp?: (event: PointerEvent) => void; + onTouchStart?: (event: PointerEvent) => void; + onTouchMove?: (event: PointerEvent) => void; + onTouchEnd?: (event: PointerEvent) => void; + onMouseEnter?: (event: PointerEvent) => void; + onMouseLeave?: (event: PointerEvent) => void; + onMouseOut?: (event: PointerEvent) => void; + onWheel?: (event: PointerEvent) => void; touchAction?: string; - clickRadius?: number; - - getCursor?: (state: InteractiveMapState) => void; - - visibilityConstraints?: { - minZoom?: number; - maxZoom?: number; - minPitch?: number; - maxPitch?: number; - }; - - mapControls?: BaseMapControls; + interactiveLayerIds?: string[]; + getCursor?: (state: ExtraState) => void; + controller?: MapController; } export class InteractiveMap extends React.Component { @@ -211,15 +264,21 @@ export interface BaseControlProps { export class BaseControl extends React.Component {} +export interface DragEvent { + lngLat: [number, number]; + [key: string]: any; +} + export interface MarkerProps extends BaseControlProps { className?: string; longitude: number; latitude: number; offsetLeft?: number; offsetTop?: number; - onDrag: (event: MjolnirEvent) => void; - onDragStart: (event: MjolnirEvent) => void; - onDragEnd: (event: MjolnirEvent) => void; + draggable?: boolean; + onDrag?: (event: DragEvent) => void; + onDragEnd?: (event: DragEvent) => void; + onDragStart?: (event: DragEvent) => void; } export class Marker extends BaseControl {} @@ -228,6 +287,7 @@ export interface PopupProps extends BaseControlProps { className?: string; longitude: number; latitude: number; + altitude?: number; offsetLeft?: number; offsetTop?: number; tipSize?: number; @@ -244,13 +304,22 @@ export class Popup extends BaseControl {} export interface NavigationControlProps extends BaseControlProps { className?: string; onViewStateChange: (info: ViewStateChangeInfo) => void; - onViewportChange: (viewport: Viewport) => void; + onViewportChange: (viewport: ViewState) => void; showCompass?: boolean; showZoom?: boolean; } export class NavigationControl extends BaseControl {} +export interface DraggableControlProps extends BaseControlProps { + draggable?: boolean; + onDrag?: (event: DragEvent) => void; + onDragEnd?: (event: DragEvent) => void; + onDragStart?: (event: DragEvent) => void; +} + +export class DraggableControl extends BaseControl {} + export interface HTMLRedrawOptions { width: number; height: number; @@ -283,59 +352,3 @@ export interface SVGOverlayProps extends BaseControlProps { } export class SVGOverlay extends BaseControl {} - -export namespace experimental { - interface Options { - // TODO(deprecate): remove this when `touchZoomRotate` gets deprecated - touchZoomRotate?: boolean; - - onViewStateChange?: (info: ViewStateChangeInfo) => void; - onViewportChange?: (viewport: Viewport) => void; - onStateChange?: (state: MapState) => void; - eventManager?: any; - scrollZoom?: boolean; - dragPan?: boolean; - dragRotate?: boolean; - doubleClickZoom?: boolean; - touchZoom?: boolean; - touchRotate?: boolean; - keyboard?: boolean; - } - - class MapState implements Viewport { - width: number; - height: number; - latitude: number; - longitude: number; - zoom: number; - bearing?: number; - pitch?: number; - altitude?: number; - - maxZoom?: number; - minZoom?: number; - maxPitch?: number; - minPitch?: number; - - transitionDuration?: number; - transitionInterpolator?: TransitionInterpolator; - transitionInterruption?: TRANSITION_EVENTS; - transitionEasing?: EasingFunction; - - startPanLngLat?: [number, number]; - startZoomLngLat?: [number, number]; - startBearing?: number; - startPitch?: number; - startZoom?: number; - } - - class MapControls implements BaseMapControls { - events: string[]; - - handleEvent(event: MapControlEvent): void; - getMapState(overrides: Partial): MapState; - setOptions(options: Options): void; - setState(newState: MapState): void; - updateViewport(newMapState: MapState, extraProps: any, extraState: InteractiveMapState): void; - } -} diff --git a/types/react-map-gl/react-map-gl-tests.tsx b/types/react-map-gl/react-map-gl-tests.tsx index 7eb5bfd590..c9024287c9 100644 --- a/types/react-map-gl/react-map-gl-tests.tsx +++ b/types/react-map-gl/react-map-gl-tests.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { - Viewport, + ViewState, InteractiveMap, CanvasOverlay, SVGOverlay, @@ -13,12 +13,12 @@ import { import * as MapboxGL from "mapbox-gl"; interface State { - viewport: Viewport; + viewState: ViewState; } class MyMap extends React.Component<{}, State> { readonly state: State = { - viewport: { + viewState: { bearing: 0, latitude: 0, longitude: 0, @@ -31,14 +31,14 @@ class MyMap extends React.Component<{}, State> { return (
{ + redraw={opts => { const { ctx, height, @@ -51,7 +51,7 @@ class MyMap extends React.Component<{}, State> { }} /> {}} + redraw={opts => {}} captureScroll={true} captureDrag={true} captureClick={true} @@ -61,7 +61,7 @@ class MyMap extends React.Component<{}, State> { redraw={() => {}} /> { + redraw={opts => { const { height, project, @@ -79,7 +79,7 @@ class MyMap extends React.Component<{}, State> { redraw={() => {}} /> { + redraw={opts => { const { height, project, @@ -98,7 +98,7 @@ class MyMap extends React.Component<{}, State> { /> Date: Mon, 19 Nov 2018 11:09:15 +0800 Subject: [PATCH 045/174] chore: styling code --- types/node/index.d.ts | 2 +- types/node/node-tests.ts | 10 +++++----- types/node/v9/index.d.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 221dd5baad..66c319c895 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2501,7 +2501,7 @@ declare module "readline" { } declare module "vm" { - interface Context { + interface Context { [key: string]: any; } interface BaseOptions { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 0ae3866a8a..7e3c491802 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3676,11 +3676,11 @@ import * as p from "process"; throw new repl.Recoverable(new Error("test")); } - _server.context.key0 = 1; - _server.context.key1 = "string"; - _server.context.key2 = true; - _server.context.key3 = []; - _server.context.key4 = {}; + _server.context['key0'] = 1; + _server.context['key1'] = ""; + _server.context['key2'] = true; + _server.context['key3'] = []; + _server.context['key4'] = {}; } } diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index b620ac9ce1..3660d87725 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -2390,7 +2390,7 @@ declare module "readline" { } declare module "vm" { - export interface Context { + export interface Context { [key: string]: any; } export interface ScriptOptions { From 1bc50af06d237a0e9dad12339213bf6290383cae Mon Sep 17 00:00:00 2001 From: Adam Binford Date: Mon, 19 Nov 2018 12:01:59 -0500 Subject: [PATCH 046/174] Added types for react-leaflet-markercluster --- types/react-leaflet-markercluster/index.d.ts | 13 ++++++++ .../react-leaflet-markercluster-tests.tsx | 30 +++++++++++++++++++ .../react-leaflet-markercluster/tsconfig.json | 24 +++++++++++++++ types/react-leaflet-markercluster/tslint.json | 1 + 4 files changed, 68 insertions(+) create mode 100644 types/react-leaflet-markercluster/index.d.ts create mode 100644 types/react-leaflet-markercluster/react-leaflet-markercluster-tests.tsx create mode 100644 types/react-leaflet-markercluster/tsconfig.json create mode 100644 types/react-leaflet-markercluster/tslint.json diff --git a/types/react-leaflet-markercluster/index.d.ts b/types/react-leaflet-markercluster/index.d.ts new file mode 100644 index 0000000000..989605f27c --- /dev/null +++ b/types/react-leaflet-markercluster/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for react-leaflet-markercluster 2.0 +// Project: https://github.com/YUzhva/react-leaflet-markercluster +// Definitions by: Adam Binford +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import 'leaflet.markercluster'; +import * as Leaflet from 'leaflet'; +import * as ReactLeaflet from 'react-leaflet'; + +export type MarkerClusterGroupProps = ReactLeaflet.MapLayerProps & Leaflet.MarkerClusterGroupOptions; + +export default class MarkerClusterGroup

extends ReactLeaflet.MapLayer

{ } diff --git a/types/react-leaflet-markercluster/react-leaflet-markercluster-tests.tsx b/types/react-leaflet-markercluster/react-leaflet-markercluster-tests.tsx new file mode 100644 index 0000000000..9fc901c527 --- /dev/null +++ b/types/react-leaflet-markercluster/react-leaflet-markercluster-tests.tsx @@ -0,0 +1,30 @@ +import * as React from 'react'; +import * as Leaflet from 'leaflet'; +import MarkerClusterGroup from 'react-leaflet-markercluster'; + +const MarkerCluster = ( + Leaflet.divIcon({ html: `${cluster.getChildCount()}` }) }/> +); diff --git a/types/react-leaflet-markercluster/tsconfig.json b/types/react-leaflet-markercluster/tsconfig.json new file mode 100644 index 0000000000..071c9c734d --- /dev/null +++ b/types/react-leaflet-markercluster/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-leaflet-markercluster-tests.tsx" + ] +} diff --git a/types/react-leaflet-markercluster/tslint.json b/types/react-leaflet-markercluster/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-leaflet-markercluster/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 58ab88a2b4b47553bb8ed3fc372a03630003f0c2 Mon Sep 17 00:00:00 2001 From: Flo Luccioni Date: Tue, 20 Nov 2018 12:06:47 +0100 Subject: [PATCH 047/174] feat(mapbox): add missing styleLayer definition --- types/mapbox/index.d.ts | 15 +++++++++++++++ types/mapbox/mapbox-tests.ts | 2 ++ 2 files changed, 17 insertions(+) diff --git a/types/mapbox/index.d.ts b/types/mapbox/index.d.ts index 334d644e21..97da469e4a 100644 --- a/types/mapbox/index.d.ts +++ b/types/mapbox/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Mapbox 1.6 // Project: https://www.mapbox.com/mapbox.js/ // Definitions by: Maxime Fabre +// Florian Luccioni // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -153,6 +154,20 @@ declare global { getGeoJSON(): any; } + // StyleLayer + ////////////////////////////////////////////////////////////////////// + + /** + * L.mapbox.styleLayer provides a way to integrate styles created with Mapbox Studio into your map. + */ + function styleLayer(url: string, options?: StyleLayerOptions): StyleLayer; + + interface StyleLayerOptions extends Leaflet.TileLayerOptions { + sanitizer?(template: string): string; + } + + type StyleLayer = Leaflet.TileLayer; + ////////////////////////////////////////////////////////////////////// ////////////////////////////// GEOCODING ///////////////////////////// ////////////////////////////////////////////////////////////////////// diff --git a/types/mapbox/mapbox-tests.ts b/types/mapbox/mapbox-tests.ts index ab9ad6c5de..a9610ba5c4 100644 --- a/types/mapbox/mapbox-tests.ts +++ b/types/mapbox/mapbox-tests.ts @@ -4,6 +4,8 @@ const mapboxTiles = L.tileLayer('https://{s}.tiles.mapbox.com/v3/examples.map-i8 const map = L.map('map').addLayer(mapboxTiles).setView(new L.LatLng([42.3610, -71.0587]), 15); +const lightTiles = L.mapbox.styleLayer('mapbox://styles/mapbox/light-v9').addTo(map); + const coordinates = document.getElementById('coordinates'); const marker = L.marker(new L.LatLng([0, 0]), { From 97c198362b7ab34c42f49ef95200826162a23524 Mon Sep 17 00:00:00 2001 From: Fabio Berta Date: Tue, 20 Nov 2018 21:01:56 +0100 Subject: [PATCH 048/174] fix indention --- types/react-map-gl/index.d.ts | 75 +++++++++++++++++------------------ 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/types/react-map-gl/index.d.ts b/types/react-map-gl/index.d.ts index 4522ddf729..3fea6a3ea9 100644 --- a/types/react-map-gl/index.d.ts +++ b/types/react-map-gl/index.d.ts @@ -19,11 +19,8 @@ export interface ViewState { } export interface MapError { - error?: { - message: string; + error?: { message: string; status: number }; status: number; - }; - status: number; } export interface MapRequest { @@ -81,7 +78,7 @@ export interface ExtraState { } export interface PositionInput { - pos: [number, number]; + pos: [number, number]; } export interface MapControllerOptions { @@ -99,47 +96,47 @@ export interface MapControllerOptions { } export interface ViewportProps { - width: number; - height: number; - latitude: number; - longitude: number; - zoom: number; - bearing: number; - pitch: number; - altitude: number; - maxZoom: number; - minZoom: number; - maxPitch: number; - minPitch: number; - transitionDuration?: number; - transitionInterpolator?: TransitionInterpolator; - transitionInterruption?: TRANSITION_EVENTS; - transitionEasing?: EasingFunction; + width: number; + height: number; + latitude: number; + longitude: number; + zoom: number; + bearing: number; + pitch: number; + altitude: number; + maxZoom: number; + minZoom: number; + maxPitch: number; + minPitch: number; + transitionDuration?: number; + transitionInterpolator?: TransitionInterpolator; + transitionInterruption?: TRANSITION_EVENTS; + transitionEasing?: EasingFunction; } export interface InteractiveState { - startPanLngLat?: [number, number]; - startZoomLngLat?: [number, number]; - startBearing?: number; - startPitch?: number; - startZoom?: number; + startPanLngLat?: [number, number]; + startZoomLngLat?: [number, number]; + startBearing?: number; + startPitch?: number; + startZoom?: number; } export type MapStateProps = Partial; export class MapState { - constructor(props: MapStateProps); - getViewportProps(): ViewportProps; - getInteractiveState(): InteractiveState; - panStart(input: PositionInput): MapState; - pan(input: PositionInput & { startPos?: [number, number] }): MapState; - panEnd(): MapState; - rotateStart(input: PositionInput): MapState; - rotate(input: { deltaScaleX?: number; deltaScaleY?: number }): MapState; - rotateEnd(): MapState; - zoomStart(input: PositionInput): MapState; - zoom(input: PositionInput & { scale: number; startPos?: [number, number] }): MapState; - zoomEnd(): MapState; + constructor(props: MapStateProps); + getViewportProps(): ViewportProps; + getInteractiveState(): InteractiveState; + panStart(input: PositionInput): MapState; + pan(input: PositionInput & { startPos?: [number, number] }): MapState; + panEnd(): MapState; + rotateStart(input: PositionInput): MapState; + rotate(input: { deltaScaleX?: number; deltaScaleY?: number }): MapState; + rotateEnd(): MapState; + zoomStart(input: PositionInput): MapState; + zoom(input: PositionInput & { scale: number; startPos?: [number, number] }): MapState; + zoomEnd(): MapState; } export interface Center { @@ -202,7 +199,7 @@ export class LinearInterpolator extends TransitionInterpolator { export class FlyToInterpolator extends TransitionInterpolator {} export interface ViewStateChangeInfo { - viewState: ViewState; + viewState: ViewState; } export interface InteractiveMapProps extends StaticMapProps { From 1b9be406451a0a5a51d8d9fc3f365644c4e6dcce Mon Sep 17 00:00:00 2001 From: Kenza Iraki Date: Tue, 20 Nov 2018 16:48:36 -0500 Subject: [PATCH 049/174] Fixed missing/inaccurate properties in analytics-node --- types/analytics-node/index.d.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/types/analytics-node/index.d.ts b/types/analytics-node/index.d.ts index 6834087ff7..cc9e5386e2 100644 --- a/types/analytics-node/index.d.ts +++ b/types/analytics-node/index.d.ts @@ -22,8 +22,8 @@ declare namespace AnalyticsNode { }, timestamp?: Date; messageId?: string; - anonymousId: string | number; - userId: string | number; + anonymousId?: string | number; + userId?: string | number; } interface Data { @@ -47,7 +47,8 @@ declare namespace AnalyticsNode { /* The identify method lets you tie a user to their actions and record traits about them. */ identify(message: { - userId: string | number; + userId?: string | number; + anonymousId?: string | number; traits?: Object; timestamp?: Date; context?: Object; @@ -56,7 +57,8 @@ declare namespace AnalyticsNode { /* The track method lets you record the actions your users perform. */ track(message: { - userId: string | number; + userId?: string | number; + anonymousId?: string | number; event: string; properties?: Object; timestamp?: Date; @@ -67,7 +69,8 @@ declare namespace AnalyticsNode { /* The page method lets you record page views on your website, along with optional extra information about the page being viewed. */ page(message: { - userId: string | number; + userId?: string | number; + anonymousId?: string | number; category?: string; name?: string; properties?: Object; @@ -79,19 +82,20 @@ declare namespace AnalyticsNode { /* alias is how you associate one identity with another. */ alias(message: { previousId: string | number; - userId: string | number; + userId?: string | number; + anonymousId?: string | number; integrations?: Integrations; }, callback?: (err: Error, data: Data) => void): Analytics; /* Group calls can be used to associate individual users with shared accounts or companies. */ group(message: { - userId: string | number; + userId?: string | number; + anonymousId?: string | number; groupId: string | number; traits?: Object; context?: Object; timestamp?: Date; - anonymous_id?: string | number; integrations?: Integrations; }, callback?: (err: Error, data: Data) => void): Analytics; From d92f3cdad08c4a315a726483e6885ea8102115c3 Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Mon, 5 Nov 2018 14:34:57 +0100 Subject: [PATCH 050/174] Add typings for react-native-safe-area --- types/react-native-safe-area/index.d.ts | 35 +++++++++++++++++++ .../react-native-safe-area-tests.ts | 4 +++ types/react-native-safe-area/tsconfig.json | 22 ++++++++++++ types/react-native-safe-area/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 types/react-native-safe-area/index.d.ts create mode 100644 types/react-native-safe-area/react-native-safe-area-tests.ts create mode 100644 types/react-native-safe-area/tsconfig.json create mode 100644 types/react-native-safe-area/tslint.json diff --git a/types/react-native-safe-area/index.d.ts b/types/react-native-safe-area/index.d.ts new file mode 100644 index 0000000000..dcb65e346c --- /dev/null +++ b/types/react-native-safe-area/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for react-native-safe-area 0.5 +// Project: https://github.com/miyabi/react-native-safe-area#readme +// Definitions by: Pavlos Vinieratos +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module 'react-native-safe-area' { + type Direction = + | 'top' + | 'bottom' + | 'left' + | 'right' + | 'topLeft' // DEPRECATED + | 'topAndLeft' + | 'topRight' // DEPRECATED + | 'topAndRight' + | 'bottomLeft' // DEPRECATED + | 'bottomAndLeft' + | 'bottomRight' // DEPRECATED + | 'bottomAndRight' + | 'vertical' + | 'horizontal' + | 'verticalAndLeft' + | 'verticalAndRight' + | 'horizontalAndTop' + | 'horizontalAndBottom' + | 'all'; + + export function withSafeArea( + WrappedComponent: React.ComponentType, + applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset' = 'margin', + direction: Direction = 'all', + ): React.ComponentType; +} diff --git a/types/react-native-safe-area/react-native-safe-area-tests.ts b/types/react-native-safe-area/react-native-safe-area-tests.ts new file mode 100644 index 0000000000..bcdbddc5f3 --- /dev/null +++ b/types/react-native-safe-area/react-native-safe-area-tests.ts @@ -0,0 +1,4 @@ +import { View } from 'react-native' +import { withSafeArea } from 'react-native-safe-area'; + +const SafeAreaView = withSafeArea(View) diff --git a/types/react-native-safe-area/tsconfig.json b/types/react-native-safe-area/tsconfig.json new file mode 100644 index 0000000000..9e2cfb5b7c --- /dev/null +++ b/types/react-native-safe-area/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-native-safe-area-tests.ts" + ] +} diff --git a/types/react-native-safe-area/tslint.json b/types/react-native-safe-area/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-safe-area/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From eb33d259b6b5792db40e46ed2bfc2046ad9950d4 Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Wed, 21 Nov 2018 11:16:22 +0100 Subject: [PATCH 051/174] newer version of typescript --- types/react-native-safe-area/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-native-safe-area/index.d.ts b/types/react-native-safe-area/index.d.ts index dcb65e346c..7eaaf3b15e 100644 --- a/types/react-native-safe-area/index.d.ts +++ b/types/react-native-safe-area/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/miyabi/react-native-safe-area#readme // Definitions by: Pavlos Vinieratos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 /// From 572eae2e09138880bddde21b40c1aa836f5bff98 Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Wed, 21 Nov 2018 11:31:32 +0100 Subject: [PATCH 052/174] add `strictFunctionTypes` --- types/react-native-safe-area/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-native-safe-area/tsconfig.json b/types/react-native-safe-area/tsconfig.json index 9e2cfb5b7c..6a88cd1448 100644 --- a/types/react-native-safe-area/tsconfig.json +++ b/types/react-native-safe-area/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 7a449c042ee9923551d0857ebd266a6eb7accd2b Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Wed, 21 Nov 2018 11:55:28 +0100 Subject: [PATCH 053/174] bunch of lint fixes --- types/react-native-safe-area/index.d.ts | 66 +++++++++++-------- .../react-native-safe-area-tests.ts | 4 +- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/types/react-native-safe-area/index.d.ts b/types/react-native-safe-area/index.d.ts index 7eaaf3b15e..923c5ae1bf 100644 --- a/types/react-native-safe-area/index.d.ts +++ b/types/react-native-safe-area/index.d.ts @@ -2,35 +2,47 @@ // Project: https://github.com/miyabi/react-native-safe-area#readme // Definitions by: Pavlos Vinieratos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0 +// TypeScript Version: 2.8 /// -declare module 'react-native-safe-area' { - type Direction = - | 'top' - | 'bottom' - | 'left' - | 'right' - | 'topLeft' // DEPRECATED - | 'topAndLeft' - | 'topRight' // DEPRECATED - | 'topAndRight' - | 'bottomLeft' // DEPRECATED - | 'bottomAndLeft' - | 'bottomRight' // DEPRECATED - | 'bottomAndRight' - | 'vertical' - | 'horizontal' - | 'verticalAndLeft' - | 'verticalAndRight' - | 'horizontalAndTop' - | 'horizontalAndBottom' - | 'all'; +import { EmitterSubscription } from 'react-native'; - export function withSafeArea( - WrappedComponent: React.ComponentType, - applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset' = 'margin', - direction: Direction = 'all', - ): React.ComponentType; +// from `TypeDefinition.js` +export interface SafeAreaInsets { top: number; left: number; bottom: number; right: number; } + +// from `SafeArea.[ios|android].js` +declare namespace SafeArea { + function getSafeAreaInsetsForRootView(): Promise<{ safeAreaInsets: SafeAreaInsets }>; + function addEventListener(eventType: string, listener: (...args: any[]) => any, context?: any): EmitterSubscription; + function removeEventListener(eventType: string, listener: (...args: any[]) => any): void; } +export default SafeArea; + +// from `withSafeArea.js` +export type Direction = + | 'top' + | 'bottom' + | 'left' + | 'right' + | 'topLeft' // DEPRECATED + | 'topAndLeft' + | 'topRight' // DEPRECATED + | 'topAndRight' + | 'bottomLeft' // DEPRECATED + | 'bottomAndLeft' + | 'bottomRight' // DEPRECATED + | 'bottomAndRight' + | 'vertical' + | 'horizontal' + | 'verticalAndLeft' + | 'verticalAndRight' + | 'horizontalAndTop' + | 'horizontalAndBottom' + | 'all'; + +export function withSafeArea( + WrappedComponent: React.ComponentType, + applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset' = 'margin', + direction: Direction = 'all', +): React.ComponentType; diff --git a/types/react-native-safe-area/react-native-safe-area-tests.ts b/types/react-native-safe-area/react-native-safe-area-tests.ts index bcdbddc5f3..0dc931d026 100644 --- a/types/react-native-safe-area/react-native-safe-area-tests.ts +++ b/types/react-native-safe-area/react-native-safe-area-tests.ts @@ -1,4 +1,4 @@ -import { View } from 'react-native' +import { View } from 'react-native'; import { withSafeArea } from 'react-native-safe-area'; -const SafeAreaView = withSafeArea(View) +const SafeAreaView = withSafeArea(View); From 8809b6a41bb6b2c95ecdbd13b41c2b09c8bc7a8a Mon Sep 17 00:00:00 2001 From: Chris Arnesen Date: Wed, 21 Nov 2018 21:34:30 +0700 Subject: [PATCH 054/174] Update types for npm package "ini" --- types/ini/index.d.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/types/ini/index.d.ts b/types/ini/index.d.ts index f534ff1b8d..4efacfe182 100644 --- a/types/ini/index.d.ts +++ b/types/ini/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for ini v1.3.3 // Project: https://github.com/isaacs/ini // Definitions by: Marcin Porębski +// Chris Arnesen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface EncodeOptions { @@ -8,9 +9,13 @@ interface EncodeOptions { whitespace: boolean } -export function decode(inistring: string): any; -export function parse(initstring: string): any; -export function encode(object: any, options?: EncodeOptions): string; -export function stringify(object: any, options?: EncodeOptions): string; +export function decode(str: string): { + [key: string]: any; +}; +export function parse(str: string): { + [key: string]: any; +}; +export function encode(object: any, options?: EncodeOptions | string): string; +export function stringify(object: any, options?: EncodeOptions | string): string; export function safe(val: string): string; export function unsafe(val: string): string; From 53563af88d1854b96c617f2b7777a8bc1812afbf Mon Sep 17 00:00:00 2001 From: BlondeLlama Date: Wed, 21 Nov 2018 16:00:10 +0100 Subject: [PATCH 055/174] added moveTolerance to mapOptions added moveTolerance to mapOptions --- types/openlayers/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index 3214bad15c..b0356122e4 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -12494,6 +12494,7 @@ export namespace olx { renderer?: (ol.RendererType | Array<(ol.RendererType | string)> | string); target?: (Element | string); view?: ol.View; + moveTolerance?: number; } /** From a7409f00a6c2b558d1f4fdd4d27b9b78609dbebc Mon Sep 17 00:00:00 2001 From: BlondeLlama Date: Wed, 21 Nov 2018 16:33:09 +0100 Subject: [PATCH 056/174] DefinitelyTyped/types/ol/ol-tests.ts: changed cast to as any changed due no-angle-bracket-type-assertion rule --- types/ol/ol-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/ol/ol-tests.ts b/types/ol/ol-tests.ts index ca099420cd..be19e61a2b 100644 --- a/types/ol/ol-tests.ts +++ b/types/ol/ol-tests.ts @@ -303,7 +303,7 @@ import VectorTile from 'ol/vectortile'; import View from 'ol/view'; // Map -const map: ol.Map = new Map( {}); +const map: ol.Map = new Map({} as any); declare const mapView: View; declare const layerBase: LayerBase; declare const control: ControlControl; @@ -320,6 +320,6 @@ declare const size: ol.Size; declare const position: ol.Pixel; view = map.getView(); view.getProjection(); -view.animate( {}); -view.calculateExtent( 'size'); +view.animate({} as any); +view.calculateExtent('size' as any); view.centerOn(coordinate, size, position); From bcffa191b1a4d6edd6cbde017b767ecc6cbbd556 Mon Sep 17 00:00:00 2001 From: BlondeLlama Date: Wed, 21 Nov 2018 16:35:05 +0100 Subject: [PATCH 057/174] DefinitelyTyped/edit/master/types/openlayers/openlayers-tests.ts: Changed cast to as ol.geom.Circle Due no-angle-bracket-type-assertion rule. --- types/openlayers/openlayers-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/openlayers/openlayers-tests.ts b/types/openlayers/openlayers-tests.ts index d631a9e9bb..9fb6f0bb3b 100644 --- a/types/openlayers/openlayers-tests.ts +++ b/types/openlayers/openlayers-tests.ts @@ -175,7 +175,7 @@ loadingStrategy = ol.loadingstrategy.tile(tilegrid); // ol.geom.Circle // booleanValue = circle.intersectsExtent(extent); -circle = circle.transform(projectionLike, projectionLike); +circle = circle.transform(projectionLike, projectionLike) as ol.geom.Circle; // // From c24ef742cd0a5db698bbbedd5c3a986dbef5e509 Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Wed, 21 Nov 2018 17:34:59 +0100 Subject: [PATCH 058/174] Update index.d.ts --- types/react-native-safe-area/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native-safe-area/index.d.ts b/types/react-native-safe-area/index.d.ts index 923c5ae1bf..a6e922e083 100644 --- a/types/react-native-safe-area/index.d.ts +++ b/types/react-native-safe-area/index.d.ts @@ -43,6 +43,6 @@ export type Direction = export function withSafeArea( WrappedComponent: React.ComponentType, - applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset' = 'margin', - direction: Direction = 'all', + applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset', + direction: Direction, ): React.ComponentType; From 3564a9defa54d717e5ad7bc5185d7a399000f05d Mon Sep 17 00:00:00 2001 From: Joel Spriggs Date: Wed, 21 Nov 2018 12:05:52 -0500 Subject: [PATCH 059/174] Adding Transaction constructor for PreparedStatement Object Type --- types/mssql/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/mssql/index.d.ts b/types/mssql/index.d.ts index d4558737ba..891186f7ee 100644 --- a/types/mssql/index.d.ts +++ b/types/mssql/index.d.ts @@ -316,6 +316,7 @@ export declare class PreparedStatement extends events.EventEmitter { public parameters: IRequestParameters; public stream: any; public constructor(connection?: ConnectionPool); + public constructor(transaction: Transaction); public input(name: string, type: (() => ISqlType) | ISqlType): PreparedStatement; public output(name: string, type: (() => ISqlType) | ISqlType): PreparedStatement; public prepare(statement?: string): Promise; From befddb5226914f270ed8528e025250618b65dd7d Mon Sep 17 00:00:00 2001 From: Tom Milligan Date: Wed, 21 Nov 2018 17:10:14 +0000 Subject: [PATCH 060/174] recharts: added tooltip.payload.payload --- types/recharts/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index a9301374f1..34e3cbcb88 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -796,6 +796,7 @@ export interface TooltipPayload { fill?: string; dataKey?: DataKey; formatter?: TooltipFormatter; + payload?: any; } export interface TooltipProps extends Animatable { From 9203ef2f42de2362024c1257771cf60c5b8224ef Mon Sep 17 00:00:00 2001 From: Joel Spriggs Date: Wed, 21 Nov 2018 12:20:25 -0500 Subject: [PATCH 061/174] adding test for new constructor --- types/mssql/mssql-tests.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/mssql/mssql-tests.ts b/types/mssql/mssql-tests.ts index 72bbc15126..18ad4b3ad9 100644 --- a/types/mssql/mssql-tests.ts +++ b/types/mssql/mssql-tests.ts @@ -189,6 +189,16 @@ function test_request_constructor() { var request4 = new sql.Request(); } +function test_prepared_statement_constructor() { + // Request can be constructed with a connection, preparedStatment, transaction or no arguments + var connection: sql.ConnectionPool = new sql.ConnectionPool(config); + var preparedStatment = new sql.PreparedStatement(connection); + var transaction = new sql.Transaction(connection); + + var preparedSatement1 = new sql.PreparedStatement(connection); + var preparedSatement2 = new sql.PreparedStatement(transaction); +} + function test_classes_extend_eventemitter() { var connection: sql.ConnectionPool = new sql.ConnectionPool(config); var transaction = new sql.Transaction(); From d721ef55ed58a3feb80173389d6b16ed0ddea824 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Wed, 21 Nov 2018 12:41:41 -0500 Subject: [PATCH 062/174] Remove error-causing module declarations from CodeMirror --- types/codemirror/codemirror-comment.d.ts | 4 ---- types/codemirror/codemirror-panel.d.ts | 4 ---- types/codemirror/codemirror-showhint.d.ts | 4 ---- 3 files changed, 12 deletions(-) diff --git a/types/codemirror/codemirror-comment.d.ts b/types/codemirror/codemirror-comment.d.ts index 47b99fd989..706e42e807 100644 --- a/types/codemirror/codemirror-comment.d.ts +++ b/types/codemirror/codemirror-comment.d.ts @@ -41,7 +41,3 @@ declare module "codemirror" { fullLines?: boolean; } } - -declare module "codemirror/addon/comment/comment" { - export = CodeMirror; -} diff --git a/types/codemirror/codemirror-panel.d.ts b/types/codemirror/codemirror-panel.d.ts index 2059c8ff72..a361992641 100644 --- a/types/codemirror/codemirror-panel.d.ts +++ b/types/codemirror/codemirror-panel.d.ts @@ -45,7 +45,3 @@ declare module "codemirror" { } } - -declare module "codemirror/addon/display/panel" { - export = CodeMirror; -} diff --git a/types/codemirror/codemirror-showhint.d.ts b/types/codemirror/codemirror-showhint.d.ts index c6f367d0d2..dfbbcdc4e1 100644 --- a/types/codemirror/codemirror-showhint.d.ts +++ b/types/codemirror/codemirror-showhint.d.ts @@ -76,7 +76,3 @@ declare module "codemirror" { hintOptions?: ShowHintOptions; } } - -declare module "codemirror/addon/hint/show-hint" { - export = CodeMirror; -} From 41fabf6ad3b9fdea68a8510b318bedd27032d218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 21 Nov 2018 17:40:34 +0000 Subject: [PATCH 063/174] [simple-oauth2] Fix typing of authorizeURL params --- types/simple-oauth2/index.d.ts | 13 +++++++------ types/simple-oauth2/simple-oauth2-tests.ts | 12 ++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/types/simple-oauth2/index.d.ts b/types/simple-oauth2/index.d.ts index 19a1ff2698..8091a56f2d 100644 --- a/types/simple-oauth2/index.d.ts +++ b/types/simple-oauth2/index.d.ts @@ -3,13 +3,14 @@ // Definitions by: Michael Müller , // Troy Lamerton // Martín Rodriguez +// Linus Unnebäck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 /** Creates a new simple-oauth2 client with the passed configuration */ -export function create(options: ModuleOptions): OAuthClient; +export function create(options: ModuleOptions): OAuthClient; -export interface ModuleOptions { +export interface ModuleOptions { client: { /** Service registered client id. Required. */ id: string, @@ -18,7 +19,7 @@ export interface ModuleOptions { /** Parameter name used to send the client secret. Default to client_secret. */ secretParamName?: string, /** Parameter name used to send the client id. Default to client_id. */ - idParamName?: string + idParamName?: ClientIdName }; auth: { /** String used to set the host to request the tokens to. Required. */ @@ -91,7 +92,7 @@ export interface ClientCredentialTokenConfig { scope?: string | string[]; } -export interface OAuthClient { +export interface OAuthClient { authorizationCode: { /** * Redirect the user to the autorization page @@ -99,8 +100,8 @@ export interface OAuthClient { */ authorizeURL( params?: { - /** A key-value pair where key is ModuleOptions#client.idParamName and the value represents the Client-ID */ - [ idParamName: string ]: string | undefined + /** A string that represents the Client-ID */ + [key in ClientIdName]?: string } & { /** A string that represents the registered application URI where the user is redirected after authentication */ redirect_uri?: string, diff --git a/types/simple-oauth2/simple-oauth2-tests.ts b/types/simple-oauth2/simple-oauth2-tests.ts index e066ad41c0..c33564b7cd 100644 --- a/types/simple-oauth2/simple-oauth2-tests.ts +++ b/types/simple-oauth2/simple-oauth2-tests.ts @@ -17,6 +17,12 @@ const credentials: oauth2lib.ModuleOptions = { const oauth2 = oauth2lib.create(credentials); +// Test custom `idParamName` +{ + const oauth2 = oauth2lib.create({ client: { id: 'x', secret: 'x', idParamName: 'foobar' }, auth: { tokenHost: 'x' } }); + oauth2.authorizationCode.authorizeURL({ foobar: 'x' }); +} + // #Authorization Code flow (async () => { // Authorization oauth2 URI @@ -26,6 +32,12 @@ const oauth2 = oauth2lib.create(credentials); state: '' }); + oauth2.authorizationCode.authorizeURL({ + redirect_uri: 'http://localhost:3000/callback', + scope: ['', ''], + state: '' + }); + // Redirect example using Express (see http://expressjs.com/api.html#res.redirect) // res.redirect(authorizationUri); From 77435f54949eb4ce6131baf2fb97b9721cc834f4 Mon Sep 17 00:00:00 2001 From: Marc LaFleur Date: Wed, 21 Nov 2018 15:19:54 -0500 Subject: [PATCH 064/174] Fleshed out NewmanRunExecutionAssertionError Added several missing properties to the NewmanRunExecutionAssertionError interface --- types/newman/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/newman/index.d.ts b/types/newman/index.d.ts index cd2801c375..440e89284c 100644 --- a/types/newman/index.d.ts +++ b/types/newman/index.d.ts @@ -168,9 +168,12 @@ export interface NewmanRunExecutionAssertion { error: NewmanRunExecutionAssertionError; } export interface NewmanRunExecutionAssertionError { + name: string; + index: number; + test: string; message: string; -} -export interface NewmanRunFailure { + stack: string; +}export interface NewmanRunFailure { error: NewmanRunExecutionAssertionError; /** The event where the failure occurred */ at: string; From 288c389f75701aab929c6cc09d01b40c855e9d28 Mon Sep 17 00:00:00 2001 From: Marc LaFleur Date: Wed, 21 Nov 2018 15:25:57 -0500 Subject: [PATCH 065/174] Bumped version --- types/newman/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/newman/index.d.ts b/types/newman/index.d.ts index 440e89284c..7bd7aef744 100644 --- a/types/newman/index.d.ts +++ b/types/newman/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for newman 3.10 +// Type definitions for newman 3.11 // Project: https://github.com/postmanlabs/newman // Definitions by: Leonid Logvinov // Graham McGregor From 8734181e0caf193d3eb8bc65847d23c9b89e9ac3 Mon Sep 17 00:00:00 2001 From: Adam Binford Date: Wed, 21 Nov 2018 18:12:23 -0500 Subject: [PATCH 066/174] react-leaflet-markercluster: Use reference import --- types/react-leaflet-markercluster/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-leaflet-markercluster/index.d.ts b/types/react-leaflet-markercluster/index.d.ts index 989605f27c..5db583d409 100644 --- a/types/react-leaflet-markercluster/index.d.ts +++ b/types/react-leaflet-markercluster/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import 'leaflet.markercluster'; +/// import * as Leaflet from 'leaflet'; import * as ReactLeaflet from 'react-leaflet'; From fd336a9567db83817d54ea8603aeee180d8f9d08 Mon Sep 17 00:00:00 2001 From: Adam Lavin Date: Thu, 22 Nov 2018 00:01:22 +0000 Subject: [PATCH 067/174] styled-system: Remove all type exports, and pull in values from csstype --- types/styled-system/dist/space.d.ts | 35 +- types/styled-system/dist/styles.d.ts | 471 ++++++--------------------- types/styled-system/package.json | 6 + 3 files changed, 127 insertions(+), 385 deletions(-) create mode 100644 types/styled-system/package.json diff --git a/types/styled-system/dist/space.d.ts b/types/styled-system/dist/space.d.ts index 9165ff39a7..9632ed7e45 100644 --- a/types/styled-system/dist/space.d.ts +++ b/types/styled-system/dist/space.d.ts @@ -1,7 +1,7 @@ +import * as CSS from 'csstype'; +export type TLengthStyledSystem = string | 0 | number; export type ResponsiveValue = T | Array; -export type SpaceValue = number | string; - /** * Converts shorthand margin and padding props to margin and padding CSS declarations * @@ -11,37 +11,36 @@ export type SpaceValue = number | string; * - String values are passed as raw CSS values. * - Array values are converted into responsive values. */ -export type ResponsiveSpaceValue = ResponsiveValue; -export interface SpaceProps { +export interface SpaceProps { /** Margin on top, left, bottom and right */ - m?: ResponsiveSpaceValue; + m?: ResponsiveValue>; /** Margin for the top */ - mt?: ResponsiveSpaceValue; + mt?: ResponsiveValue>; /** Margin for the right */ - mr?: ResponsiveSpaceValue; + mr?: ResponsiveValue>; /** Margin for the bottom */ - mb?: ResponsiveSpaceValue; + mb?: ResponsiveValue>; /** Margin for the left */ - ml?: ResponsiveSpaceValue; + ml?: ResponsiveValue>; /** Margin for the left and right */ - mx?: ResponsiveSpaceValue; + mx?: ResponsiveValue>; /** Margin for the top and bottom */ - my?: ResponsiveSpaceValue; + my?: ResponsiveValue>; /** Padding on top, left, bottom and right */ - p?: ResponsiveSpaceValue; + p?: ResponsiveValue>; /** Padding for the top */ - pt?: ResponsiveSpaceValue; + pt?: ResponsiveValue>; /** Padding for the right */ - pr?: ResponsiveSpaceValue; + pr?: ResponsiveValue>; /** Padding for the bottom */ - pb?: ResponsiveSpaceValue; + pb?: ResponsiveValue>; /** Padding for the left */ - pl?: ResponsiveSpaceValue; + pl?: ResponsiveValue>; /** Padding for the left and right */ - px?: ResponsiveSpaceValue; + px?: ResponsiveValue>; /** Padding for the top and bottom */ - py?: ResponsiveSpaceValue; + py?: ResponsiveValue>; } export function space(...args: any[]): any; diff --git a/types/styled-system/dist/styles.d.ts b/types/styled-system/dist/styles.d.ts index a06a923d11..59f8077ec9 100644 --- a/types/styled-system/dist/styles.d.ts +++ b/types/styled-system/dist/styles.d.ts @@ -1,9 +1,8 @@ -import { ResponsiveValue, ResponsiveSpaceValue, SpaceValue } from './space'; +import * as CSS from 'csstype'; +import { ResponsiveValue, TLengthStyledSystem } from './space'; export * from './space'; -export type GlobalStyleValues = "inherit" | "initial" | "unset"; - export interface BaseTheme { breakpoints?: number[]; space?: number[]; @@ -17,10 +16,7 @@ export interface BaseTheme { * Font Size */ -export type FontSizeValue = number | string; -export type ResponsiveFontSizeValue = ResponsiveValue; - -export interface FontSizeProps { +export interface FontSizeProps { /** * The fontSize utility parses a component's `fontSize` prop and converts it into a CSS font-size declaration. * @@ -30,7 +26,7 @@ export interface FontSizeProps { * - And array values are converted into responsive values. * */ - fontSize?: ResponsiveFontSizeValue; + fontSize?: ResponsiveValue>; } export function fontSize(...args: any[]): any; @@ -38,8 +34,6 @@ export function fontSize(...args: any[]): any; /** * Color */ -export type ColorValue = string; -export type ResponsiveColorValue = ResponsiveValue; export interface TextColorProps { /** @@ -51,12 +45,12 @@ export interface TextColorProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/color) */ - color?: ResponsiveColorValue; + color?: ResponsiveValue; } export function textColor(...args: any[]): any; -export interface BgColorProps { +export interface BgColorProps { /** * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. * By default the raw value of the prop is returned. @@ -66,7 +60,7 @@ export interface BgColorProps { * * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) */ - bg?: ResponsiveColorValue; + bg?: ResponsiveValue>; } export function bgColor(...args: any[]): any; @@ -78,39 +72,23 @@ export function color(...args: any[]): any; /** * Typography */ -export type TypographyValue = string; -export type ResponsiveTypographyValue = ResponsiveValue; - export interface FontFamilyProps { - fontFamily?: ResponsiveTypographyValue; + fontFamily?: ResponsiveValue; } export function fontFamily(...args: any[]): any; -export type TextAlignValue = - | "left" - | "right" - | "center" - | "justify" - | "justify-all" - | "start" - | "end" - | "match-parent"; -export type ResponsiveTextAlignValue = ResponsiveValue; - export interface TextAlignProps { /** * The text-align CSS property specifies the horizontal alignment of an inline or table-cell box. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) */ - textAlign?: ResponsiveTextAlignValue; + textAlign?: ResponsiveValue; } export function textAlign(...args: any[]): any; -export type LineHeightValue = number | string; -export type ResponsiveLineHeightValue = ResponsiveValue; -export interface LineHeightProps { +export interface LineHeightProps { /** * The line-height CSS property sets the amount of space used for lines, such as in text. On block-level elements, * it specifies the minimum height of line boxes within the element. @@ -119,19 +97,10 @@ export interface LineHeightProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) */ - lineHeight?: ResponsiveLineHeightValue; + lineHeight?: ResponsiveValue>; } export function lineHeight(...args: any[]): any; -export type FontWeightValue = - | GlobalStyleValues - | "normal" - | "bold" - | "lighter" - | "bolder" - | number; -export type ResponsiveFontWeightValue = ResponsiveValue; - export interface FontWeightProps { /** * The font-weight CSS property specifies the weight (or boldness) of the font. @@ -140,13 +109,11 @@ export interface FontWeightProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) */ - fontWeight?: ResponsiveFontWeightValue; + fontWeight?: ResponsiveValue; } export function fontWeight(...args: any[]): any; -export type FontStyleValue = string; -export type ResponsiveFontStyleValue = ResponsiveValue; export interface FontStyleProps { /** * The font-style CSS property specifies whether a font should be styled with a normal, italic, @@ -154,19 +121,17 @@ export interface FontStyleProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) */ - fontStyle?: ResponsiveFontStyleValue; + fontStyle?: ResponsiveValue; } export function fontStyle(...args: any[]): any; -export type LetterSpacingValue = number | string; -export type ResponsiveLetterSpacingValue = ResponsiveValue; -export interface LetterSpacingProps { +export interface LetterSpacingProps { /** * The letter-spacing CSS property sets the spacing behavior between text characters. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) */ - letterSpacing?: ResponsiveLetterSpacingValue; + letterSpacing?: ResponsiveValue>; } export function letterSpacing(...args: any[]): any; @@ -174,15 +139,6 @@ export function letterSpacing(...args: any[]): any; * Layout */ -export type DisplayValue = - | "none" - | "inline" - | "block" - | "contents" - | "flex" - | "grid" - | "inline-block"; -export type ResponsiveDisplayValue = ResponsiveValue; export interface DisplayProps { /** * The display CSS property defines the display type of an element, which consists of the two basic qualities @@ -191,36 +147,36 @@ export interface DisplayProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) */ - display?: ResponsiveDisplayValue; + display?: ResponsiveValue; } export function display(...args: any[]): any; -export interface MaxWidthProps { +export interface MaxWidthProps { /** * The max-width CSS property sets the maximum width of an element. * It prevents the used value of the width property from becoming larger than the value specified by max-width. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) */ - maxWidth?: ResponsiveSpaceValue; + maxWidth?: ResponsiveValue>; } export function maxWidth(...args: any[]): any; -export interface MinWidthProps { +export interface MinWidthProps { /** * The min-width CSS property sets the minimum width of an element. * It prevents the used value of the width property from becoming smaller than the value specified for min-width. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) */ - minWidth?: ResponsiveSpaceValue; + minWidth?: ResponsiveValue>; } export function minWidth(...args: any[]): any; -export interface WidthProps { +export interface WidthProps { /** * The width utility parses a component's `width` prop and converts it into a CSS width declaration. * @@ -229,57 +185,57 @@ export interface WidthProps { * - String values are passed as raw CSS values. * - And arrays are converted to responsive width styles. */ - width?: ResponsiveSpaceValue; + width?: ResponsiveValue>; } export function width(...args: any[]): any; -export interface MaxHeightProps { +export interface MaxHeightProps { /** * The max-height CSS property sets the maximum height of an element. It prevents the used value of the height * property from becoming larger than the value specified for max-height. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) */ - maxHeight?: ResponsiveSpaceValue; + maxHeight?: ResponsiveValue>; } export function maxHeight(...args: any[]): any; -export interface MinHeightProps { +export interface MinHeightProps { /** * The min-height CSS property sets the minimum height of an element. It prevents the used value of the height * property from becoming smaller than the value specified for min-height. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) */ - minHeight?: ResponsiveSpaceValue; + minHeight?: ResponsiveValue>; } export function minHeight(...args: any[]): any; -export interface HeightProps { +export interface HeightProps { /** * The height CSS property specifies the height of an element. By default, the property defines the height of the * content area. If box-sizing is set to border-box, however, it instead determines the height of the border area. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/height) */ - height?: ResponsiveSpaceValue; + height?: ResponsiveValue>; } export function height(...args: any[]): any; // TODO: Document, I couldn't find any info on these two properties... -export interface SizeWidthProps { - size?: ResponsiveSpaceValue; +export interface SizeWidthProps { + size?: ResponsiveValue>; } export function sizeWidth(...args: any[]): any; -export interface SizeHeightProps { - size?: ResponsiveSpaceValue; +export interface SizeHeightProps { + size?: ResponsiveValue>; } export function sizeHeight(...args: any[]): any; @@ -288,38 +244,22 @@ export interface SizeProps extends SizeHeightProps, SizeWidthProps {} export function size(...args: any[]): any; -export type RatioValue = SpaceValue; -export type ResponsiveRatioValue = ResponsiveValue; - export interface RatioProps { /** * The ration is height: 0 & paddingBottom */ - ratio?: ResponsiveRatioValue; + ratio?: ResponsiveValue; } export function ratio(...args: any[]): any; -export type VerticalAlignValue = - | "baseline" - | "sub" - | "super" - | "text-top" - | "text-bottom" - | "middle" - | "top" - | "bottom" - | string - | number; -export type ResponsiveVerticalAlignValue = ResponsiveValue; - -export interface VerticalAlignProps { +export interface VerticalAlignProps { /** * The vertical-align CSS property specifies sets vertical alignment of an inline or table-cell box. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) */ - verticalAlign?: ResponsiveVerticalAlignValue; + verticalAlign?: ResponsiveValue>; } export function verticalAlign(...args: any[]): any; @@ -328,25 +268,6 @@ export function verticalAlign(...args: any[]): any; * Flexbox */ -export type AlignItemsValue = - | "normal" - | "stretch" - | "center" - | "start" - | "end" - | "flex-start" - | "flex-end" - | "self-start" - | "self-end" - | "left" - | "right" - | "baseline" - | "first baseline" - | "last baseline" - | "safe center" - | "unsafe center"; -export type ResponsiveAlignItemsValue = ResponsiveValue; - export interface AlignItemsProps { /** * The CSS align-items property sets the align-self value on all direct children as a group. The align-self @@ -357,30 +278,11 @@ export interface AlignItemsProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) */ - alignItems?: ResponsiveAlignItemsValue; + alignItems?: ResponsiveValue; } export function alignItems(...args: any[]): any; -export type AlignContentValue = - | GlobalStyleValues - | "center" - | "start" - | "end" - | "flex-start" - | "flex-end" - | "normal" - | "baseline" - | "first baseline" - | "last baseline" - | "space-between" - | "space-around" - | "space-evenly" - | "stretch" - | "safe center" - | "unsafe center"; -export type ResponsiveAlignContentValue = ResponsiveValue; - export interface AlignContentProps { /** * The CSS align-content property sets how the browser distributes space between and around content items @@ -388,14 +290,11 @@ export interface AlignContentProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) */ - alignContent?: ResponsiveAlignContentValue; + alignContent?: ResponsiveValue; } export function alignContent(...args: any[]): any; -export type JustifyItemsValue = string; -export type ResponsiveJustifyItemsValue = ResponsiveValue; - export interface JustifyItemsProps { /** * The CSS justify-items property defines the default justify-self for all items of the box, giving them all @@ -403,30 +302,9 @@ export interface JustifyItemsProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) */ - justifyItems?: ResponsiveJustifyItemsValue; + justifyItems?: ResponsiveValue; } -export type JustifyContentValue = - | "center" - | "start" - | "end" - | "flex-start" - | "flex-end" - | "left" - | "right" - | "baseline" - | "first baseline" - | "last baseline" - | "space-between" - | "space-around" - | "space-evenly" - | "stretch" - | "safe center" - | "unsafe center"; -export type ResponsiveJustifyContentValue = ResponsiveValue< - JustifyContentValue ->; - export interface JustifyContentProps { /** * The CSS justify-content property defines how the browser distributes space between and around content items @@ -434,14 +312,11 @@ export interface JustifyContentProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) */ - justifyContent?: ResponsiveJustifyContentValue; + justifyContent?: ResponsiveValue; } export function justifyContent(...args: any[]): any; -export type FlexWrapValue = "nowrap" | "wrap" | "wrap-reverse"; -export type ResponsiveFlexWrapValue = ResponsiveValue; - export interface FlexWrapProps { /** * The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. @@ -449,40 +324,21 @@ export interface FlexWrapProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) */ - flexWrap?: ResponsiveFlexWrapValue; + flexWrap?: ResponsiveValue; } export function flexWrap(...args: any[]): any; -export type FlexBasisValue = - | GlobalStyleValues - | "auto" - | "fill" - | "max-content" - | "min-content" - | "fit-content" - | "content"; -export type ResponsiveFlexBasisValue = ResponsiveValue; - -export interface FlexBasisProps { +export interface FlexBasisProps { // TODO: The FlexBasisValue currently really only exists for documentation // purposes, because flex-basis also accepts `Nem` and `Npx` strings. // Not sure there’s a way to still have the union values show up as // auto-completion results. - flexBasis?: ResponsiveFlexBasisValue | string; + flexBasis?: ResponsiveValue>; } export function flexBasis(...args: any[]): any; -export type FlexDirectionValue = - | GlobalStyleValues - | "row" - | "row-reverse" - | "column" - | "column-reverse"; - -export type ResponsiveFlexDirectionValue = ResponsiveValue; - export interface FlexDirectionProps { /** * The flex-direction CSS property specifies how flex items are placed in the flex container defining the main @@ -490,48 +346,23 @@ export interface FlexDirectionProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) */ - flexDirection?: ResponsiveFlexDirectionValue; + flexDirection?: ResponsiveValue; } export function flexDirection(...args: any[]): any; -export type FlexValue = number | string; -export type ResponsiveFlexValue = ResponsiveValue; - -export interface FlexProps { +export interface FlexProps { /** * The flex CSS property specifies how a flex item will grow or shrink so as to fit the space available in * its flex container. This is a shorthand property that sets flex-grow, flex-shrink, and flex-basis. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) */ - flex?: ResponsiveFlexValue; + flex?: ResponsiveValue>; } export function flex(...args: any[]): any; -export type JustifySelfValue = - | GlobalStyleValues - | "auto" - | "normal" - | "stretch" - | "center" - | "start" - | "end" - | "flex-start" - | "flex-end" - | "self-start" - | "self-end" - | "left" - | "right" - | "baseline" - | "first baseline" - | "last baseline" - | "safe center" - | "unsafe center"; - -export type ResponsiveJustifySelfValue = ResponsiveValue; - export interface JustifySelfProps { /** * The CSS justify-self property set the way a box is justified inside its alignment container along @@ -539,31 +370,11 @@ export interface JustifySelfProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) */ - justifySelf?: ResponsiveJustifySelfValue; + justifySelf?: ResponsiveValue; } export function justifySelf(...args: any[]): any; -export type AlignSelfValue = - | "auto" - | "normal" - | "center" - | "start" - | "end" - | "self-start" - | "self-end" - | "flex-start" - | "flex-end" - | "left" - | "right" - | "baseline" - | "first baseline" - | "last baseline" - | "stretch" - | "safe center" - | "unsafe center"; -export type ResponsiveAlignSelfValue = ResponsiveValue; - export interface AlignSelfProps { /** * The align-self CSS property aligns flex items of the current flex line overriding the align-items value. @@ -573,14 +384,11 @@ export interface AlignSelfProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) */ - alignSelf?: ResponsiveAlignSelfValue; + alignSelf?: ResponsiveValue; } export function alignSelf(...args: any[]): any; -export type OrderValue = GlobalStyleValues | number; -export type ResponsiveOrderValue = ResponsiveValue; - export interface OrderProps { /** * The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container @@ -588,7 +396,7 @@ export interface OrderProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/order) */ - order?: ResponsiveOrderValue; + order?: ResponsiveValue; } export function order(...args: any[]): any; @@ -597,10 +405,7 @@ export function order(...args: any[]): any; * Grid Layout */ -export type GridGapValue = number | string; -export type ResponsiveGridGapValue = ResponsiveValue; - -export interface GridGapProps { +export interface GridGapProps { /** * The gap CSS property sets the gaps (gutters) between rows and columns. It is a shorthand for row-gap * and column-gap. @@ -609,12 +414,12 @@ export interface GridGapProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) */ - gridGap?: ResponsiveGridGapValue; + gridGap?: ResponsiveValue>; } export function gridGap(...args: any[]): any; -export interface GridColumnGapProps { +export interface GridColumnGapProps { /** * The column-gap CSS property sets the size of the gap (gutter) between an element's columns. * @@ -622,12 +427,12 @@ export interface GridColumnGapProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) */ - gridColumnGap?: ResponsiveGridGapValue; + gridColumnGap?: ResponsiveValue>; } export function gridColumnGap(...args: any[]): any; -export interface GridRowGapProps { +export interface GridRowGapProps { /** * The row-gap CSS property sets the size of the gap (gutter) between an element's rows. * @@ -635,14 +440,11 @@ export interface GridRowGapProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) */ - gridRowGap?: ResponsiveGridGapValue; + gridRowGap?: ResponsiveValue>; } export function gridRowGap(...args: any[]): any; -export type GridCellValue = string; -export type ResponsiveGridCellValue = ResponsiveValue; - export interface GridColumnProps { /** * The grid-column CSS property is a shorthand property for grid-column-start and grid-column-end specifying @@ -651,7 +453,7 @@ export interface GridColumnProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column) */ - gridColumn?: ResponsiveGridCellValue; + gridColumn?: ResponsiveValue; } export function gridColumn(...args: any[]): any; @@ -664,14 +466,11 @@ export interface GridRowProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) */ - gridRow?: ResponsiveGridCellValue; + gridRow?: ResponsiveValue; } export function gridRow(...args: any[]): any; -export type GridAutoValue = string; -export type ResponsiveGridAutoValue = ResponsiveValue; - export interface GridAutoFlowProps { /** * The grid-auto-flow CSS property controls how the auto-placement algorithm works, specifying exactly @@ -679,54 +478,51 @@ export interface GridAutoFlowProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) */ - gridAutoFlow?: ResponsiveGridAutoValue; + gridAutoFlow?: ResponsiveValue; } export function gridAutoFlow(...args: any[]): any; -export interface GridAutoColumnsProps { +export interface GridAutoColumnsProps { /** * The grid-auto-columns CSS property specifies the size of an implicitly-created grid column track. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) */ - gridAutoColumns?: ResponsiveGridAutoValue; + gridAutoColumns?: ResponsiveValue>; } export function gridAutoColumns(...args: any[]): any; -export interface GridAutoRowsProps { +export interface GridAutoRowsProps { /** * The grid-auto-rows CSS property specifies the size of an implicitly-created grid row track. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) */ - gridAutoRows?: ResponsiveGridAutoValue; + gridAutoRows?: ResponsiveValue>; } export function gridAutoRows(...args: any[]): any; -export type GridTemplateValue = string; -export type ResponsiveGridTemplateValue = ResponsiveValue; - -export interface GridTemplatesColumnsProps { +export interface GridTemplatesColumnsProps { /** * The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) */ - gridTemplateColumns?: ResponsiveGridTemplateValue; + gridTemplateColumns?: ResponsiveValue>; } export function gridTemplateColumns(...args: any[]): any; -export interface GridTemplatesRowsProps { +export interface GridTemplatesRowsProps { /** * The grid-template-rows CSS property defines the line names and track sizing functions of the grid rows. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-template-rows) */ - gridTemplateRows?: ResponsiveGridTemplateValue; + gridTemplateRows?: ResponsiveValue>; } export function gridTemplateRows(...args: any[]): any; @@ -737,7 +533,7 @@ export interface GridTemplatesAreasProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) */ - gridTemplateAreas?: ResponsiveGridTemplateValue; + gridTemplateAreas?: ResponsiveValue; } export function gridTemplateAreas(...args: any[]): any; @@ -750,7 +546,7 @@ export interface GridAreaProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) */ - gridArea?: ResponsiveGridTemplateValue; + gridArea?: ResponsiveValue; } export function gridArea(...args: any[]): any; @@ -759,65 +555,62 @@ export function gridArea(...args: any[]): any; * Borders */ -export type BorderValue = string | number; -export type ResponsiveBorderValue = ResponsiveValue; - -export interface BorderProps { +export interface BorderProps { /** * The border CSS property sets an element's border. It's a shorthand for border-width, border-style, * and border-color. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border) */ - border?: ResponsiveBorderValue; + border?: ResponsiveValue>; } export function border(...args: any[]): any; -export interface BorderTopProps { +export interface BorderTopProps { /** * The border-top CSS property is a shorthand that sets the values of border-top-width, border-top-style, * and border-top-color. These properties describe an element's top border. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top) */ - borderTop?: ResponsiveBorderValue; + borderTop?: ResponsiveValue>; } export function borderTop(...args: any[]): any; -export interface BorderRightProps { +export interface BorderRightProps { /** * The border-right CSS property is a shorthand that sets border-right-width, border-right-style, * and border-right-color. These properties set an element's right border. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right) */ - borderRight?: ResponsiveBorderValue; + borderRight?: ResponsiveValue>; } export function borderRight(...args: any[]): any; -export interface BorderBottomProps { +export interface BorderBottomProps { /** * The border-bottom CSS property sets an element's bottom border. It's a shorthand for * border-bottom-width, border-bottom-style and border-bottom-color. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom) */ - borderBottom?: ResponsiveBorderValue; + borderBottom?: ResponsiveValue>; } export function borderBottom(...args: any[]): any; -export interface BorderLeftProps { +export interface BorderLeftProps { /** * The border-left CSS property is a shorthand that sets the values of border-left-width, * border-left-style, and border-left-color. These properties describe an element's left border. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left) */ - borderLeft?: ResponsiveBorderValue; + borderLeft?: ResponsiveValue>; } export function borderLeft(...args: any[]): any; @@ -826,38 +619,29 @@ export interface BordersProps extends BorderTopProps, BorderRightProps, BorderBo export function borders(...args: any[]): any; -export type BorderColorValue = string; -export type ResponsiveBorderColorValue = ResponsiveValue; - export interface BorderColorProps { /** * The border-color shorthand CSS property sets the color of all sides of an element's border. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-color) */ - borderColor?: ResponsiveBorderColorValue; + borderColor?: ResponsiveValue; } export function borderColor(...args: any[]): any; -export type BorderRadiusValue = string | number; -export type ResponsiveBorderRadiusValue = ResponsiveValue; - -export interface BorderRadiusProps { +export interface BorderRadiusProps { /** * The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single * radius to make circular corners, or two radii to make elliptical corners. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) */ - borderRadius?: ResponsiveBorderRadiusValue; + borderRadius?: ResponsiveValue>; } export function borderRadius(...args: any[]): any; -export type BoxShadowValue = string | number; -export type ResponsiveBoxShadowValue = ResponsiveValue; - export interface BoxShadowProps { /** * The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects @@ -866,14 +650,11 @@ export interface BoxShadowProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) */ - boxShadow?: ResponsiveBoxShadowValue; + boxShadow?: ResponsiveValue; } export function boxShadow(...arg: any[]): any; -export type OpacityValue = string | number; -export type ResponsiveOpacityValue = ResponsiveValue; - export interface OpacityProps { /** * The opacity CSS property sets the transparency of an element or the degree to which content @@ -881,14 +662,11 @@ export interface OpacityProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) */ - opacity?: ResponsiveOpacityValue; + opacity?: ResponsiveValue; } export function opacity(...arg: any[]): any; -export type OverflowValue = string | number; -export type ResponsiveOverflowValue = ResponsiveValue; - export interface OverflowProps { /** * The overflow CSS property sets what to do when an element's content is too big to fit in its block @@ -896,7 +674,7 @@ export interface OverflowProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow) */ - overflow?: ResponsiveOverflowValue; + overflow?: ResponsiveValue; } export function overflow(...arg: any[]): any; @@ -904,68 +682,53 @@ export function overflow(...arg: any[]): any; * Background */ -export type BackgroundValue = string; -export type ResponsiveBackgroundValue = ResponsiveValue; - -export interface BackgroundProps { +export interface BackgroundProps { /** * The background shorthand CSS property sets all background style properties at once, * such as color, image, origin and size, repeat method, and others. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background) */ - background?: ResponsiveBackgroundValue; + background?: ResponsiveValue>; } export function background(...args: any[]): any; -export type BackgroundImageValue = string; -export type ResponsiveBackgroundImageValue = ResponsiveValue; - export interface BackgroundImageProps { /** * The background-image CSS property sets one or more background images on an element. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) */ - backgroundImage?: ResponsiveBackgroundImageValue; + backgroundImage?: ResponsiveValue; } export function backgroundImage(...args: any[]): any; -export type BackgroundSizeValue = string; -export type ResponsiveBackgroundSizeValue = ResponsiveValue; - -export interface BackgroundSizeProps { +export interface BackgroundSizeProps { /** * The background-size CSS property sets the size of the element's background image. The * image can be left to its natural size, stretched, or constrained to fit the available space. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) */ - backgroundSize?: ResponsiveBackgroundSizeValue; + backgroundSize?: ResponsiveValue>; } export function backgroundSize(...args: any[]): any; -export type BackgroundPositionValue = string; -export type ResponsiveBackgroundPositionValue = ResponsiveValue; - -export interface BackgroundPositionProps { +export interface BackgroundPositionProps { /** * The background-position CSS property sets the initial position for each background image. The * position is relative to the position layer set by background-origin. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) */ - backgroundPosition?: ResponsiveBackgroundPositionValue; + backgroundPosition?: ResponsiveValue>; } export function backgroundPosition(...args: any[]): any; -export type BackgroundRepeatValue = string; -export type ResponsiveBackgroundRepeatValue = ResponsiveValue; - export interface BackgroundRepeatProps { /** * The background-repeat CSS property sets how background images are repeated. A background @@ -973,7 +736,7 @@ export interface BackgroundRepeatProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) */ - backgroundRepeat?: ResponsiveBackgroundRepeatValue; + backgroundRepeat?: ResponsiveValue; } export function backgroundRepeat(...args: any[]): any; @@ -982,14 +745,6 @@ export function backgroundRepeat(...args: any[]): any; * Position */ -export type PositionValue = - | "static" - | "relative" - | "absolute" - | "sticky" - | "fixed"; -export type ResponsivePositionValue = ResponsiveValue; - export interface PositionProps { /** * The position CSS property specifies how an element is positioned in a document. @@ -997,14 +752,11 @@ export interface PositionProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/position) */ - position?: ResponsivePositionValue; + position?: ResponsiveValue; } export function position(...args: any[]): any; -export type ZIndexValue = GlobalStyleValues | "auto" | number; -export type ResponsiveZIndexValue = ResponsiveValue; - export interface ZIndexProps { /** * The z-index CSS property sets the z-order of a positioned element and its descendants or @@ -1012,88 +764,73 @@ export interface ZIndexProps { * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index) */ - zIndex?: ZIndexValue; + zIndex?: ResponsiveValue; } export function zIndex(...args: any[]): any; -export type TopValue = string | number; -export type ResponsiveTopValue = ResponsiveValue; - -export interface TopProps { +export interface TopProps { /** * The top CSS property participates in specifying the vertical position of a * positioned element. It has no effect on non-positioned elements. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) */ - top?: ResponsiveTopValue; + top?: ResponsiveValue>; } export function top(...args: any[]): any; -export type RightValue = string | number; -export type ResponsiveRightValue = ResponsiveValue; - -export interface RightProps { +export interface RightProps { /** * The right CSS property participates in specifying the horizontal position of a * positioned element. It has no effect on non-positioned elements. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/right) */ - right?: ResponsiveRightValue; + right?: ResponsiveValue>; } export function right(...args: any[]): any; -export type BottomValue = string | number; -export type ResponsiveBottomValue = ResponsiveValue; - -export interface BottomProps { +export interface BottomProps { /** * The bottom CSS property participates in specifying the vertical position of a * positioned element. It has no effect on non-positioned elements. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) */ - bottom?: ResponsiveBottomValue; + bottom?: ResponsiveValue>; } export function bottom(...args: any[]): any; -export type LeftValue = string | number; -export type ResponsiveLeftValue = ResponsiveValue; - -export interface LeftProps { +export interface LeftProps { /** * The left CSS property participates in specifying the horizontal position * of a positioned element. It has no effect on non-positioned elements. * * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/left) */ - left?: ResponsiveLeftValue; + left?: ResponsiveValue>; } export function left(...args: any[]): any; -export type Variant = string; -export type ResponsiveVariant = ResponsiveValue; - export interface TextStyleProps { - textStyle?: ResponsiveVariant; + textStyle?: ResponsiveValue; } export function textStyle(...args: any[]): any; export interface ColorStyleProps { - colors?: ResponsiveVariant; + colors?: ResponsiveValue; } export function colorStyle(...args: any[]): any; export interface ButtonStyleProps { - variant?: ResponsiveVariant; + variant?: ResponsiveValue; } export function buttonStyle(...args: any[]): any; diff --git a/types/styled-system/package.json b/types/styled-system/package.json new file mode 100644 index 0000000000..e6696d08e7 --- /dev/null +++ b/types/styled-system/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "csstype": "^2.2.0" + } +} From 4804c30a554acf49f27e96ab7e03523f2d3687c7 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 22 Nov 2018 10:57:17 +0900 Subject: [PATCH 068/174] 'encode' also accepts string. --- types/ngeohash/index.d.ts | 2 +- types/ngeohash/ngeohash-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ngeohash/index.d.ts b/types/ngeohash/index.d.ts index 25c8f29e5b..af498162ce 100644 --- a/types/ngeohash/index.d.ts +++ b/types/ngeohash/index.d.ts @@ -12,7 +12,7 @@ declare namespace ngeohash { type GeographicBoundingBox = [number, number, number, number]; type NSEW = [number, number]; - function encode(latitude: number, longitude: number, precision?: number): string; + function encode(latitude: number|string, longitude: number|string, precision?: number): string; function decode(hashstring: string): GeographicPoint; function decode_bbox(hashstring: string): GeographicBoundingBox; function bboxes(minlat: number, minlon: number, maxlat: number, maxlon: number, precision?: number): Array; diff --git a/types/ngeohash/ngeohash-tests.ts b/types/ngeohash/ngeohash-tests.ts index 34ad34d7cf..5c77ae94df 100644 --- a/types/ngeohash/ngeohash-tests.ts +++ b/types/ngeohash/ngeohash-tests.ts @@ -1,6 +1,7 @@ import geohash = require('ngeohash'); console.log(geohash.encode(37.8324, 112.5584)); +console.log(geohash.encode('37.8324', '112.5584')); // prints ww8p1r4t8 var latlon = geohash.decode('ww8p1r4t8'); From f646aa114ad2afeabfca8d4e832555636fdcdd46 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 22 Nov 2018 11:11:47 +0900 Subject: [PATCH 069/174] Fix union type style. --- types/ngeohash/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ngeohash/index.d.ts b/types/ngeohash/index.d.ts index af498162ce..7fa05a0f4e 100644 --- a/types/ngeohash/index.d.ts +++ b/types/ngeohash/index.d.ts @@ -12,7 +12,7 @@ declare namespace ngeohash { type GeographicBoundingBox = [number, number, number, number]; type NSEW = [number, number]; - function encode(latitude: number|string, longitude: number|string, precision?: number): string; + function encode(latitude: number | string, longitude: number | string, precision?: number): string; function decode(hashstring: string): GeographicPoint; function decode_bbox(hashstring: string): GeographicBoundingBox; function bboxes(minlat: number, minlon: number, maxlat: number, maxlon: number, precision?: number): Array; From 47a9cf1ac5339062c8e1320cc619b35f694d144e Mon Sep 17 00:00:00 2001 From: Malash Date: Wed, 21 Nov 2018 14:25:14 +0800 Subject: [PATCH 070/174] [weixin-app] fix api params --- types/weixin-app/index.d.ts | 42 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/types/weixin-app/index.d.ts b/types/weixin-app/index.d.ts index 9a41debd2a..2e2eb35481 100644 --- a/types/weixin-app/index.d.ts +++ b/types/weixin-app/index.d.ts @@ -936,7 +936,7 @@ declare namespace wx { /** 本地缓存中的指定的 key */ key: string; /** 接口调用的回调函数,res = {data: key对应的内容} */ - success(res: DataResponse): void; + success(res: { data: Record | string | undefined }): void; } /** * 从本地缓存中异步获取指定 key 对应的内容。 @@ -3058,12 +3058,33 @@ declare namespace wx { * 登录态过期后开发者可以再调用wx.login获取新的用户登录态。 */ function checkSession(options: CheckSessionOption): void; + + // scope 列表 + type Scope = + | "scope.userInfo" + | "scope.userLocation" + | "scope.address" + | "scope.invoiceTitle" + | "scope.invoice" + | "scope.werun" + | "scope.record" + | "scope.writePhotosAlbum" + | "scope.camera"; + + // 开放接口-----设置 + interface AuthorizeOption { + scope: Scope; + success?(res: ErrMsgResponse): void; + fail?(): void; + complete?(): void; + } + /** * 提前向用户发起授权请求。 * 调用后会立刻弹窗询问用户是否同意授权小程序使用某项功能或获取用户的某些数据, * 但不会实际调用对应接口。如果用户之前已经同意授权,则不会出现弹窗,直接返回成功。 */ - function authorize(options: AuthSetting): void; + function authorize(options: AuthorizeOption): void; // 开放接口-----用户信息 interface UserInfo { nickName: string; @@ -3283,22 +3304,9 @@ declare namespace wx { * */ function openCard(options: OpenCardOptions): void; - // 开放接口-----设置 - interface AuthSetting { - scope: - | "scope.userInfo" - | "scope.userLocation" - | "scope.address" - | "scope.invoiceTitle" - | "scope.werun" - | "scope.record" - | "scope.writePhotosAlbum"; - success?(res: ErrMsgResponse): void; - fail?(): void; - complete?(): void; - } + interface OpenSettingOptions extends BaseOptions { - success?(res: { authSetting: AuthSetting }): void; + success?(res: { authSetting: { [key in Scope]: string} }): void; } /** * 调起客户端小程序设置界面,返回用户设置的操作结果。 From 9414e3cb3a771a2f6b6b32b9290c70dee343ec23 Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Wed, 21 Nov 2018 23:51:57 -0500 Subject: [PATCH 071/174] react, react-dom: Enable strictFunctionTypes. (#30748) Fixes https://stackoverflow.com/q/53298949 . --- types/react-addons-test-utils/index.d.ts | 4 ++-- types/react-dom/react-dom-tests.tsx | 2 +- types/react-dom/test-utils/index.d.ts | 14 +++++++++----- types/react-dom/tsconfig.json | 2 +- types/react/index.d.ts | 3 +-- types/react/test/index.ts | 19 ++++++++++++++----- types/react/tsconfig.json | 2 +- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/types/react-addons-test-utils/index.d.ts b/types/react-addons-test-utils/index.d.ts index 0531c5e3f6..19df32f3dc 100644 --- a/types/react-addons-test-utils/index.d.ts +++ b/types/react-addons-test-utils/index.d.ts @@ -160,11 +160,11 @@ declare namespace TestUtils { root: Component, tagName: string): Element; - export function scryRenderedComponentsWithType, C extends ComponentClass<{}>>( + export function scryRenderedComponentsWithType, C extends ComponentClass>( root: Component, type: ClassType): T[]; - export function findRenderedComponentWithType, C extends ComponentClass<{}>>( + export function findRenderedComponentWithType, C extends ComponentClass>( root: Component, type: ClassType): T; diff --git a/types/react-dom/react-dom-tests.tsx b/types/react-dom/react-dom-tests.tsx index ff5ef5850e..c7ccb0052d 100644 --- a/types/react-dom/react-dom-tests.tsx +++ b/types/react-dom/react-dom-tests.tsx @@ -7,7 +7,7 @@ import * as ReactTestUtils from 'react-dom/test-utils'; declare function describe(desc: string, f: () => void): void; declare function it(desc: string, f: () => void): void; -class TestComponent extends React.Component { } +class TestComponent extends React.Component<{x: string}> { } describe('ReactDOM', () => { it('render', () => { diff --git a/types/react-dom/test-utils/index.d.ts b/types/react-dom/test-utils/index.d.ts index caa5605ef5..f60d088515 100644 --- a/types/react-dom/test-utils/index.d.ts +++ b/types/react-dom/test-utils/index.d.ts @@ -59,7 +59,7 @@ export interface SyntheticEventData extends OptionalEventProperties { export type EventSimulator = (element: Element | Component, eventData?: SyntheticEventData) => void; export interface MockedComponentClass { - new (props: {}): any; + new (props: any): any; } export interface ShallowRenderer { @@ -160,8 +160,12 @@ export function renderIntoDocument( element: DOMElement): T; export function renderIntoDocument( element: SFCElement): void; -export function renderIntoDocument>( - element: CElement): T; +// If we replace `P` with `any` in this overload, then some tests fail because +// calls to `renderIntoDocument` choose the last overload on the +// subtype-relation pass and get an undesirably broad return type. Using `P` +// allows this overload to match on the subtype-relation pass. +export function renderIntoDocument>( + element: CElement): T; export function renderIntoDocument

( element: ReactElement

): Component

| Element | void; @@ -257,7 +261,7 @@ export function findRenderedDOMComponentWithTag( /** * Finds all instances of components with type equal to `componentClass`. */ -export function scryRenderedComponentsWithType( +export function scryRenderedComponentsWithType, C extends ComponentClass>( root: Component, type: ClassType): T[]; @@ -266,7 +270,7 @@ export function scryRenderedComponentsWithType( +export function findRenderedComponentWithType, C extends ComponentClass>( root: Component, type: ClassType): T; diff --git a/types/react-dom/tsconfig.json b/types/react-dom/tsconfig.json index 0d21b07029..f63325026f 100644 --- a/types/react-dom/tsconfig.json +++ b/types/react-dom/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, - "strictFunctionTypes": false, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 938413e41b..25f3c710ae 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -492,8 +492,7 @@ declare namespace React { */ type ClassType, C extends ComponentClass

> = C & - (new (props: P, context?: any) => T) & - (new (props: P, context?: any) => { props: P }); + (new (props: P, context?: any) => T); // // Component Specs and Lifecycle diff --git a/types/react/test/index.ts b/types/react/test/index.ts index de043082fb..97d61118b9 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -49,6 +49,10 @@ const props: Props & React.ClassAttributes = { foo: 42 }; +const scProps: SCProps = { + foo: 42 +}; + declare const container: Element; // @@ -258,9 +262,9 @@ const domFactoryElement: React.DOMElement, Element> = const element: React.CElement = React.createElement(ModernComponent, props); const elementNoState: React.CElement = React.createElement(ModernComponentNoState, props); const elementNullProps: React.CElement<{}, ModernComponentNoPropsAndState> = React.createElement(ModernComponentNoPropsAndState, null); -const functionComponentElement: React.FunctionComponentElement = React.createElement(FunctionComponent, props); +const functionComponentElement: React.FunctionComponentElement = React.createElement(FunctionComponent, scProps); const functionComponentElementNullProps: React.FunctionComponentElement = React.createElement(FunctionComponent4, null); -const legacyStatelessComponentElement: React.SFCElement = React.createElement(FunctionComponent, props); +const legacyStatelessComponentElement: React.SFCElement = React.createElement(FunctionComponent, scProps); const legacyStatelessComponentElementNullProps: React.SFCElement = React.createElement(FunctionComponent4, null); const domElement: React.DOMElement, HTMLDivElement> = React.createElement("div"); const domElementNullProps = React.createElement("div", null); @@ -393,7 +397,12 @@ const ForwardingRefComponent = React.forwardRef((props: {}, ref: React.Ref = React.createRef(); - return React.createElement(ForwardingRefComponent, { ref }); + // Without the explicit type argument, TypeScript infers `{ref: React.RefObject}` + // from the second argument because both of the inferences generated by the first argument + // (both to the `P` in the call signature and the `P` in `defaultProps`) have low priority. + // Then we get a type error because `ForwardingRefComponent.defaultProps` has the wrong type. + // Can/should this be fixed somehow? + return React.createElement>(ForwardingRefComponent, { ref }); } // @@ -633,11 +642,11 @@ const foundComponents: ModernComponent[] = TestUtils.scryRenderedComponentsWithT // ReactTestUtils custom type guards -const emptyElement1: React.ReactElement<{}> = React.createElement(ModernComponent); +const emptyElement1: React.ReactElement = React.createElement(ModernComponent); if (TestUtils.isElementOfType(emptyElement1, FunctionComponent)) { emptyElement1.props.foo; } -const emptyElement2: React.ReactElement<{}> = React.createElement(FunctionComponent); +const emptyElement2: React.ReactElement = React.createElement(FunctionComponent); if (TestUtils.isElementOfType(emptyElement2, FunctionComponent)) { emptyElement2.props.foo; } diff --git a/types/react/tsconfig.json b/types/react/tsconfig.json index 55d0627c78..e39916b9e4 100644 --- a/types/react/tsconfig.json +++ b/types/react/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitAny": true, "noImplicitThis": false, "strictNullChecks": true, - "strictFunctionTypes": false, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 3f00b0355d6eeb6c5f25b48511ef6450a0f2e9ca Mon Sep 17 00:00:00 2001 From: Matt Ferderer Date: Wed, 21 Nov 2018 23:50:31 -0600 Subject: [PATCH 072/174] Added Amount and made some optional Adjusted based off use on Stripe Element examples by Stripe on GitHub. It somewhat looks that TokenData could even be any object but not sure on this. --- types/stripejs/token.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/stripejs/token.d.ts b/types/stripejs/token.d.ts index e3a3a51590..dac3308393 100644 --- a/types/stripejs/token.d.ts +++ b/types/stripejs/token.d.ts @@ -56,11 +56,16 @@ export interface TokenData { */ name: string; + /** + * The amount paid, not a decimal. In USD this is in cents. + */ + amount: number; + /** * Fields for billing address information. */ address_line1: string; - address_line2: string; + address_line2?: string; address_city: string; address_state: string; address_zip: string; @@ -69,7 +74,7 @@ export interface TokenData { * A two character country code identifying the country * @example 'US' */ - address_country: string; + address_country?: string; /** * Used to add a card to an account From 046d432fb27464ec0a707d6039b15e0b7213ab63 Mon Sep 17 00:00:00 2001 From: Matt Ferderer Date: Wed, 21 Nov 2018 23:55:18 -0600 Subject: [PATCH 073/174] Add payment request button See usage here - https://github.com/stripe/elements-examples/blob/master/js/example5.js --- types/stripejs/element.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/stripejs/element.d.ts b/types/stripejs/element.d.ts index 4a1e7b3c46..c6cfda71e4 100644 --- a/types/stripejs/element.d.ts +++ b/types/stripejs/element.d.ts @@ -163,7 +163,7 @@ export interface StripeElement { * The type of element that can be created by the ElementCreator * @see ElementCreator */ -export type ElementType = 'card' | 'cardNumber' | 'cardExpiry' | 'cardCvc' | 'postalCode'; +export type ElementType = 'card' | 'cardNumber' | 'cardExpiry' | 'cardCvc' | 'postalCode' | 'paymentRequestButton'; // --- ELEMENT EVENTS --- // export interface OnChange { @@ -295,6 +295,7 @@ export interface PaymentButtonOptions { complete?: PaymentRequestButtonStyle; empty?: PaymentRequestButtonStyle; invalid?: PaymentRequestButtonStyle; + paymentRequestButton?: PaymentRequestButtonStyle; }; } From f9c7057c7a3a35f22bb93d8ef8b96bbbb176c515 Mon Sep 17 00:00:00 2001 From: Matt Ferderer Date: Wed, 21 Nov 2018 23:56:29 -0600 Subject: [PATCH 074/174] Added self to get notifications on changes --- types/stripejs/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/stripejs/index.d.ts b/types/stripejs/index.d.ts index f2a7ab21aa..0ee2016af2 100644 --- a/types/stripejs/index.d.ts +++ b/types/stripejs/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for stripe.js 3.0 // Project: https://stripe.com/ // Definitions by: Robin van Tienhoven +// Matt Ferderer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From ff1e9ee2539e54035e80739b0eb9605cb6222703 Mon Sep 17 00:00:00 2001 From: Wose Date: Thu, 22 Nov 2018 09:46:16 -0500 Subject: [PATCH 075/174] Switch Mongoose post hook overload order Fixes incorrect selection of function overload --- types/mongoose/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 5963be87ed..aa24ca16b1 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -811,11 +811,11 @@ declare module "mongoose" { * @param fn callback */ post(method: string, fn: ( - error: mongodb.MongoError, doc: T, next: (err?: NativeError) => void - ) => void): this; + doc: T, next: (err?: NativeError) => void + ) => void): this; post(method: string, fn: ( - doc: T, next: (err?: NativeError) => void + error: mongodb.MongoError, doc: T, next: (err?: NativeError) => void ) => void): this; /** From 7191616daf83a72a4636724ffe998b4c21f82579 Mon Sep 17 00:00:00 2001 From: Wose Date: Thu, 22 Nov 2018 10:16:38 -0500 Subject: [PATCH 076/174] Update types in mongoose-tests.ts for post hook arguments --- types/mongoose/mongoose-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index c8873f85b3..f713ba8538 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -491,12 +491,12 @@ preHookTestSchemaArr.push( ); schema -.post('save', function (error, doc, next) { +.post('save', function (error: mongoose.Error, doc: mongoose.Document, next: (err?: mongoose.NativeError) => void) { error.stack; doc.model; next.apply; }) -.post('save', function (doc: mongoose.Document, next: Function) { +.post('save', function (doc: mongoose.Document, next: (err?: mongoose.NativeError) => void) { doc.model; next(new Error()); }) From eb5938ec968187d0b956e9383704e94422733c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Alvergnat?= Date: Sat, 17 Nov 2018 17:09:33 +0100 Subject: [PATCH 077/174] Add types for yeoman-assert --- types/yeoman-assert/index.d.ts | 156 +++++++++++++++++++++ types/yeoman-assert/tsconfig.json | 23 +++ types/yeoman-assert/tslint.json | 3 + types/yeoman-assert/yeoman-assert-tests.ts | 34 +++++ 4 files changed, 216 insertions(+) create mode 100644 types/yeoman-assert/index.d.ts create mode 100644 types/yeoman-assert/tsconfig.json create mode 100644 types/yeoman-assert/tslint.json create mode 100644 types/yeoman-assert/yeoman-assert-tests.ts diff --git a/types/yeoman-assert/index.d.ts b/types/yeoman-assert/index.d.ts new file mode 100644 index 0000000000..cff816ff39 --- /dev/null +++ b/types/yeoman-assert/index.d.ts @@ -0,0 +1,156 @@ +// Type definitions for yeoman-assert 3.1 +// Project: https://github.com/yeoman/yeoman-assert +// Definitions by: Toilal +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import assert = require('assert'); + +declare module 'assert' { + /** + * Assert that a file exists or that each files in the array exists + * @param path path to a file or an array of paths to files + * @example + * assert.file('templates/user.hbs'); + * assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']); + */ + function file(path: string | string[]): void; + + /** + * Assert that a file doesn't exist + * @param file path to a file + * @example + * assert.noFile('templates/user.hbs'); + * assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']); + */ + function noFile(file: string | string[]): void; + + /** + * Assert that a file's content matches a regex or string + * @param file path to a file + * @param reg regex / string that will be used to search the file + * @example + * assert.fileContent('models/user.js', /App\.User = DS\.Model\.extend/); + * assert.fileContent('models/user.js', 'App.User = DS.Model.extend'); + */ + function fileContent(file: string | string[], reg: string | RegExp): void; + + /** + * Assert that each file in an array of file-regex pairs matches its corresponding regex + * @param pairs an array of arrays, where each subarray is a [String, RegExp] pair + * @example + * var arg = [ + * [ 'models/user.js', /App\.User = DS\.Model\.extend/ ], + * [ 'controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/ ] + * ] + * assert.fileContent(arg); + */ + function fileContent(pairs: Array<[string, RegExp]>): void; + + /** + * Assert that a file's content is the same as the given string + * @param file path to a file + * @param expectedContent the expected content of the file + * @example + * assert.equalsFileContent( + * 'data.js', + * 'const greeting = "Hello";\nexport default { greeting }' + * ); + */ + function equalsFileContent(file: string, expectedContent: string): void; + + /** + * Assert that each file in an array of file-string pairs equals its corresponding string + * @param pairs an array of arrays, where each subarray is a [String, String] pair + * @example + * assert.equalsFileContent([ + * ['data.js', 'const greeting = "Hello";\nexport default { greeting }'], + * ['user.js', 'export default {\n name: 'Coleman',\n age: 0\n}'] + * ]); + */ + function equalsFileContent(pairs: Array<[string, string]>): void; + + /** + * Assert that a file's content does not match a regex / string + * @param file path to a file + * @param reg regex / string that will be used to search the file + * @example + * assert.noFileContent('models/user.js', /App\.User = DS\.Model\.extend/); + * assert.noFileContent('models/user.js', 'App.User = DS.Model.extend'); + */ + function noFileContent(file: string | string[], reg: RegExp | string): void; + + /** + * Assert that each file in an array of file-regex pairs does not match its corresponding regex + * @param pairs an array of arrays, where each subarray is a [String, RegExp] pair + * var arg = [ + * [ 'models/user.js', /App\.User \ DS\.Model\.extend/ ], + * [ 'controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/ ] + * ] + * assert.noFileContent(arg); + */ + function noFileContent(pairs: Array<[string, RegExp]>): void; + + /** + * Assert that two strings are equal after standardization of newlines + * @param value a string + * @param expected the expected value of the string + * @example + * assert.textEqual('I have a yellow cat', 'I have a yellow cat'); + */ + function textEqual(value: string, expected: string): void; + + /** + * Assert an Object implements an interface + * @param subject subject implementing the façade + * @param methods a façace, hash or array of keys to be implemented + */ + function implement(subject: object, methods: object | string[]): void; + + /** + * Assert an Object doesn't implements any method of an interface + * @param subject subject not implementing the methods + * @param methods hash or array of method names to be implemented + */ + function notImplement(subject: object, methods: object | string[]): void; + + /** + * Assert an object contains the provided keys + * @param obj Object that should match the given pattern + * @param content An object of key/values the object should contains + */ + function objectContent(obj: object, content: object): void; + + /** + * Assert an object does not contain the provided keys + * @param obj Object that should not match the given pattern + * @param content An object of key/values the object should not contain + */ + function noObjectContent(obj: object, content: object): void; + + /** + * Assert a JSON file contains the provided keys + * @param filename + * @param content An object of key/values the file should contains + */ + function JSONFileContent(filename: string, content: object): void; + + /** + * @see JSONFileContent + */ + function jsonFileContent(filename: string, content: object): void; + + /** + * Assert a JSON file does not contain the provided keys + * @param filename + * @param content An object of key/values the file should not contain + */ + function noJSONFileContent(filename: string, content: object): void; + + /** + * @see noJSONFileContent + */ + function noJsonFileContent(filename: string, content: object): void; +} + +export = assert; diff --git a/types/yeoman-assert/tsconfig.json b/types/yeoman-assert/tsconfig.json new file mode 100644 index 0000000000..95612ba7ca --- /dev/null +++ b/types/yeoman-assert/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "yeoman-assert-tests.ts" + ] +} diff --git a/types/yeoman-assert/tslint.json b/types/yeoman-assert/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/yeoman-assert/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/yeoman-assert/yeoman-assert-tests.ts b/types/yeoman-assert/yeoman-assert-tests.ts new file mode 100644 index 0000000000..87732f1f7b --- /dev/null +++ b/types/yeoman-assert/yeoman-assert-tests.ts @@ -0,0 +1,34 @@ +import * as assert from 'yeoman-assert'; + +assert.file('path'); +assert.file(['path', 'path2']); + +assert.noFile('path'); +assert.noFile(['path', 'path2']); + +assert.fileContent('file', /abc/g); +assert.fileContent(['file', 'file2'], 'abc'); + +assert.equalsFileContent('file', 'expectedContent'); +assert.equalsFileContent([['file', 'expectedContent'], ['file2', 'expectedContent2']]); + +assert.noFileContent('file', /abc/g); +assert.noFileContent(['file', 'file2'], 'abc'); + +assert.textEqual('value', 'expected'); +assert.implement({value: 'test'}, {other: 'test2'}); +assert.implement({value: 'test'}, ['test2', 'test3']); + +assert.notImplement({value: 'test'}, {other: 'test2'}); +assert.notImplement({value: 'test'}, ['test2', 'test3']); + +assert.objectContent({value: 'test'}, {value: 'test2'}); +assert.noObjectContent({value: 'test'}, {value: 'test2'}); + +assert.JSONFileContent('filename', {root: 'content'}); +assert.jsonFileContent('filename', {root: 'content'}); + +assert.noJSONFileContent('filename', {root: 'content'}); +assert.noJsonFileContent('filename', {root: 'content'}); + +assert.equal('test', 'expected'); From 402324af7b7157e809f604d4536e7fd9cda24ca2 Mon Sep 17 00:00:00 2001 From: Wose Date: Thu, 22 Nov 2018 11:35:25 -0500 Subject: [PATCH 078/174] Fix extra spaces in previous commit (mongoose-posthook-overload) --- types/mongoose/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index aa24ca16b1..3672b75b8f 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -811,8 +811,8 @@ declare module "mongoose" { * @param fn callback */ post(method: string, fn: ( - doc: T, next: (err?: NativeError) => void - ) => void): this; + doc: T, next: (err?: NativeError) => void + ) => void): this; post(method: string, fn: ( error: mongodb.MongoError, doc: T, next: (err?: NativeError) => void From c2fac6d23595aebaae11bbb4e45b598ceae29bd0 Mon Sep 17 00:00:00 2001 From: Kon Pik <485881+konpikwastaken@users.noreply.github.com> Date: Thu, 22 Nov 2018 09:14:42 -0800 Subject: [PATCH 079/174] Updating definitions for combined-stream v1.0.7 (#30295) * updates * PR feedback * updated PR changes --- .../combined-stream/combined-stream-tests.ts | 35 +++++++++++----- types/combined-stream/index.d.ts | 40 +++++++++---------- 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/types/combined-stream/combined-stream-tests.ts b/types/combined-stream/combined-stream-tests.ts index ffdc0eaac7..540db77b68 100644 --- a/types/combined-stream/combined-stream-tests.ts +++ b/types/combined-stream/combined-stream-tests.ts @@ -1,17 +1,17 @@ -import CombinedStream = require("combined-stream"); -import { createReadStream, createWriteStream } from "fs"; +import CombinedStream = require('combined-stream'); +import { createReadStream, createWriteStream } from 'fs'; const stream1 = new CombinedStream(); -stream1.append(createReadStream("tsconfig.json")); -stream1.append(createReadStream("tslint.json")); -stream1.append(createReadStream("index.d.ts")); +stream1.append(createReadStream('tsconfig.json')); +stream1.append(createReadStream('tslint.json')); +stream1.append(createReadStream('index.d.ts')); -stream1.pipe(createWriteStream("combined.txt")); +stream1.pipe(createWriteStream('combined.txt')); const stream2 = CombinedStream.create({ maxDataSize: 1 << 32, - pauseStreams: false, + pauseStreams: false }); stream1.destroy(); @@ -19,12 +19,29 @@ stream1.destroy(); // should log true console.log(CombinedStream.isStreamLike(stream2)); -stream2.on("data", (data) => { +stream2.on('data', data => { console.log(data); }); -stream2.pipe(createWriteStream("combined.txt")); +stream2.pipe(createWriteStream('combined.txt')); stream2.write(CombinedStream.name); stream2.destroy(); + +const arrowFunction = (): CombinedStream => { + const stream3 = new CombinedStream(); + + // test next function + stream3.append(next => { + stream3.append('hello world'); + next(createReadStream('')); + }); + + // next function with no next + stream3.append(() => { + stream3.append('hello again'); + }); + + return stream3; +}; diff --git a/types/combined-stream/index.d.ts b/types/combined-stream/index.d.ts index 271814a4af..b82b399e7f 100644 --- a/types/combined-stream/index.d.ts +++ b/types/combined-stream/index.d.ts @@ -1,19 +1,27 @@ // Type definitions for combined-stream 1.0 // Project: https://github.com/felixge/node-combined-stream -// Definitions by: Felix Geisendörfer , Tomek Łaziuk +// Definitions by: Felix Geisendörfer , Tomek Łaziuk , Kon Pik // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -import { Stream } from "stream"; +import { Stream } from 'stream'; -declare class CombinedStream extends Stream implements CombinedStream.Options { +type Appendable = NodeJS.ReadableStream | NodeJS.WritableStream | Buffer | string | NextFunction; +type NextFunction = (next: (stream: Appendable) => any) => any; + +interface Options { + maxDataSize?: number; + pauseStreams?: boolean; +} + +declare class CombinedStream extends Stream implements Options { readonly writable: boolean; readonly readable: boolean; readonly dataSize: number; maxDataSize: number; pauseStreams: boolean; - append(stream: NodeJS.ReadableStream | NodeJS.WritableStream | Buffer | string): this; + append(stream: Appendable): this; write(data: any): void; pause(): void; resume(): void; @@ -34,23 +42,15 @@ declare class CombinedStream extends Stream implements CombinedStream.Options { _emitError(error: Error): void; // events - on(event: "close" | "end" | "resume" | "pause", cb: () => void): this; - on(event: "error", cb: (err: Error) => void): this; - on(event: "data", cb: (data: any) => void): this; - once(event: "close" | "end" | "resume" | "pause", cb: () => void): this; - once(event: "error", cb: (err: Error) => void): this; - once(event: "data", cb: (data: any) => void): this; -} + on(event: 'close' | 'end' | 'resume' | 'pause', cb: () => void): this; + on(event: 'error', cb: (err: Error) => void): this; + on(event: 'data', cb: (data: any) => void): this; + once(event: 'close' | 'end' | 'resume' | 'pause', cb: () => void): this; + once(event: 'error', cb: (err: Error) => void): this; + once(event: 'data', cb: (data: any) => void): this; -declare namespace CombinedStream { - interface Options { - maxDataSize?: number; - pauseStreams?: boolean; - } - - function create(options?: Options): CombinedStream; - - function isStreamLike(stream: any): stream is Stream; + static create(options?: Options): CombinedStream; + static isStreamLike(stream: any): stream is Stream; } export = CombinedStream; From a6be7b57b6776a1ece8dabbdc991042275144f92 Mon Sep 17 00:00:00 2001 From: Benny van Reeven Date: Thu, 22 Nov 2018 20:15:06 +0100 Subject: [PATCH 080/174] Add minimumBytes property to file-type --- types/file-type/file-type-tests.ts | 2 ++ types/file-type/index.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/types/file-type/file-type-tests.ts b/types/file-type/file-type-tests.ts index ecfd658a1a..640d2c8fb0 100644 --- a/types/file-type/file-type-tests.ts +++ b/types/file-type/file-type-tests.ts @@ -2,3 +2,5 @@ import fileType = require("file-type"); fileType(new Buffer([0xFF, 0xD8, 0xFF])); fileType(new Uint8Array([0xFF, 0xD8, 0xFF])); + +const minimumBytes: number = fileType.minimumBytes; diff --git a/types/file-type/index.d.ts b/types/file-type/index.d.ts index c7f95c256e..2a0deee26a 100644 --- a/types/file-type/index.d.ts +++ b/types/file-type/index.d.ts @@ -15,4 +15,6 @@ declare namespace FileType { ext: string; mime: string; } + + const minimumBytes: number; } From 1cd0b9e3df80430b42c3886f696dfb2e79a24e86 Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Thu, 22 Nov 2018 11:22:47 -0800 Subject: [PATCH 081/174] Bump library version to 1.8 to prepare for 2.00 react-datepicker recently released a 2.00 release with lots of breaking changes. The current typings file is version 1.1. Before updating the typings version to 2.00, it makes sense to bring the current typings version up to 1.8 (the latest library version before 2.0) to make it easier for future pre-2.0 library users to find the correct typings version to use. To see why this is needed, imagine a future developer who is sticking with version 1.8 of the library to defer rewriting from Moment to Date. If you're that developer, should you use version 1.1 or 2.0 of the typings? If we bump the typings version to 1.8, then that choice is obvious. This PR doesn't make any typings or tests changes-- it only bumps the library version in the first header line so that the version of the resulting @types/react-datepicker package will also be 1.8. --- types/react-datepicker/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-datepicker/index.d.ts b/types/react-datepicker/index.d.ts index 23e542d322..4af6cae9b2 100644 --- a/types/react-datepicker/index.d.ts +++ b/types/react-datepicker/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-datepicker 1.1 +// Type definitions for react-datepicker 1.8 // Project: https://github.com/Hacker0x01/react-datepicker // Definitions by: Rajab Shakirov , // Andrey Balokha , @@ -7,6 +7,7 @@ // Roy Xue // Koala Human // Sean Kelley +// Justin Grant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 From dabc2bf03a3acd325f92078c2139bd5d37dd9424 Mon Sep 17 00:00:00 2001 From: Fellipe Chagas Date: Thu, 22 Nov 2018 18:41:13 -0200 Subject: [PATCH 082/174] Adds JSDocs to the new NavigationLeafRoute params --- types/react-navigation/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index e51629f3af..615d79353d 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -133,7 +133,13 @@ export interface NavigationLeafRoute { * e.g. `{ car_id: 123 }` in a route that displays a car. */ params?: Params; + /** + * Array containing the navigator's routes + */ routes: NavigationRoute[]; + /** + * Flag that indicates the transition state of the route + */ isTransitioning: boolean; } From fe3f2298c762fae51ed5a2882967c26434fa86dc Mon Sep 17 00:00:00 2001 From: Jessica Date: Fri, 23 Nov 2018 14:48:52 +0900 Subject: [PATCH 083/174] Add failing test --- types/styled-components/test/index.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx index e435d90011..50a17b7069 100644 --- a/types/styled-components/test/index.tsx +++ b/types/styled-components/test/index.tsx @@ -99,6 +99,21 @@ const fadeIn = keyframes` } `; +const showAnimation = css` + opacity: 1; + transform: scale(1) translateY(0); +`; + +const hideAnimation = css` + opacity: 0; + transform: scale(0.95, 0.8) translateY(20px); +`; + +const entryAnimation = keyframes` + from { ${hideAnimation} } + to { ${showAnimation} } +`; + const animationRule = css` ${fadeIn} 1s infinite alternate; `; From ad2da6f44867a1b9bd1d248c68452a77dd65697e Mon Sep 17 00:00:00 2001 From: Jessica Date: Fri, 23 Nov 2018 14:52:35 +0900 Subject: [PATCH 084/174] Add overload to fix test --- types/styled-components/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/styled-components/index.d.ts b/types/styled-components/index.d.ts index a842c94c63..1b26568498 100644 --- a/types/styled-components/index.d.ts +++ b/types/styled-components/index.d.ts @@ -287,6 +287,10 @@ export type ThemedStyledInterface = ThemedBaseStyledInterface< export type StyledInterface = ThemedStyledInterface; export interface BaseThemedCssFunction { + ( + first: TemplateStringsArray | NonNullable, + ...interpolations: SimpleInterpolation[] + ): FlattenSimpleInterpolation; ( first: | TemplateStringsArray From 4dd9510a504875fb79a399d468e8f39e892af617 Mon Sep 17 00:00:00 2001 From: Jessica Date: Fri, 23 Nov 2018 15:05:46 +0900 Subject: [PATCH 085/174] Strengthen type of ReactType to also validate intrinsic elements --- types/react/index.d.ts | 12 ++++++++---- types/react/test/tsx.tsx | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 25f3c710ae..522a106944 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -50,7 +50,11 @@ declare namespace React { // React Elements // ---------------------------------------------------------------------- - type ReactType

= string | ComponentType

; + type ReactType

= + { + [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never + }[keyof JSX.IntrinsicElements] | + ComponentType

; type ComponentType

= ComponentClass

| FunctionComponent

; type Key = string | number; @@ -713,17 +717,17 @@ declare namespace React { * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded, * or ComponentPropsWithoutRef when refs are not supported. */ - type ComponentProps> = + type ComponentProps = T extends ComponentType ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : {}; - type ComponentPropsWithRef> = + type ComponentPropsWithRef = T extends ComponentClass ? PropsWithoutRef

& RefAttributes> : PropsWithRef>; - type ComponentPropsWithoutRef> = + type ComponentPropsWithoutRef = PropsWithoutRef>; // will show `Memo(${Component.displayName || Component.name})` in devtools by default, diff --git a/types/react/test/tsx.tsx b/types/react/test/tsx.tsx index f344fb2838..a8ca2ae1ea 100644 --- a/types/react/test/tsx.tsx +++ b/types/react/test/tsx.tsx @@ -325,3 +325,10 @@ type ImgPropsWithRefRef = ImgPropsWithRef['ref']; type ImgPropsWithoutRef = React.ComponentPropsWithoutRef<'img'>; // $ExpectType false type ImgPropsHasRef = 'ref' extends keyof ImgPropsWithoutRef ? true : false; + +const HasClassName: React.ReactType<{ className?: string }> = 'a'; +const HasFoo: React.ReactType<{ foo: boolean }> = 'a'; // $ExpectError +const HasFoo2: React.ReactType<{ foo: boolean }> = (props: { foo: boolean }) => null; +const HasFoo3: React.ReactType<{ foo: boolean }> = (props: { foo: string }) => null; // $ExpectError +const HasHref: React.ReactType<{ href?: string }> = 'a'; +const HasHref2: React.ReactType<{ href?: string }> = 'div'; // $ExpectError From deab75bde42b5a82aeb951f5a2edaa09922853f4 Mon Sep 17 00:00:00 2001 From: AzSiAz Date: Fri, 23 Nov 2018 10:06:23 +0100 Subject: [PATCH 086/174] requested correction --- types/cheerio/index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index b04e0f009d..6c893021a3 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -111,10 +111,8 @@ interface Cheerio { eq(index: number): Cheerio; - get(): any[] - get(): string[]; - get(): CheerioElement[]; - get(index: number): CheerioElement; + get(): any[]; + get(index: number): any; index(): number; index(selector: string): number; From 294e39f046ff91c20f653edf23a1f4522ee37de0 Mon Sep 17 00:00:00 2001 From: luz-alphacode Date: Fri, 23 Nov 2018 18:27:15 +0800 Subject: [PATCH 087/174] [@type/paper] fillColor/strokeColor/shaderColor can be null to set it off --- types/paper/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/paper/index.d.ts b/types/paper/index.d.ts index 016581f16c..d3c818b112 100644 --- a/types/paper/index.d.ts +++ b/types/paper/index.d.ts @@ -1491,7 +1491,7 @@ declare module paper { /** * The color of the stroke. */ - strokeColor: Color | string; + strokeColor: Color | string | null; /** * The width of the stroke. @@ -1539,7 +1539,7 @@ declare module paper { /** * The fill color of the item. */ - fillColor: Color | string; + fillColor: Color | string | null; /** * The fill-rule with which the shape gets filled. Please note that only modern browsers support fill-rules other than 'nonzero'. @@ -1551,7 +1551,7 @@ declare module paper { /** * The shadow color. */ - shadowColor: Color | string; + shadowColor: Color | string | null; /** * The shadow’s blur radius. From d1e1def886504a65ed94965fb9d4bd5cc78ec273 Mon Sep 17 00:00:00 2001 From: Bastien Chevallier Date: Fri, 23 Nov 2018 12:08:45 +0100 Subject: [PATCH 088/174] Update react-tag-input type Based on this documentation : https://github.com/prakhar1989/react-tags#readme --- types/react-tag-input/index.d.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/types/react-tag-input/index.d.ts b/types/react-tag-input/index.d.ts index 39654e5b31..380ab93693 100644 --- a/types/react-tag-input/index.d.ts +++ b/types/react-tag-input/index.d.ts @@ -18,20 +18,26 @@ export interface ReactTagsProps { handleAddition: ((tag: {id: string, text: string}) => void); handleDelete: ((i: number) => void); handleDrag?: ((tag: { id: string; text: string; }, currPos: number, newPos: number) => void); - handleInputChange?: ((value: string) => void); handleFilterSuggestions?: ((textInputValue: string, possibleSuggestionsArray: Array<{ id: string, text: string }>) => Array<{ id: string, text: string }>); - handleInputBlur?: ((textInputValue: string) => void); + handleTagClick?: ((i: number) => void); autofocus?: boolean; allowDeleteFromEmptyInput?: boolean; + handleInputChange?: ((value: string) => void); + handleInputFocus?: ((value: string) => void); + handleInputBlur?: ((textInputValue: string) => void); minQueryLength?: number; removeComponent?: React.Component; autocomplete?: boolean | 1; readOnly?: boolean; - maxLength?: number; name?: string; id?: string; + maxLength?: number; + + inline?: boolean; + allowUnique?: boolean; + allowDragDrop?: boolean; } export class WithContext extends React.Component { } From 179975f7d52965b9897cd466146d4d14d36a0f0e Mon Sep 17 00:00:00 2001 From: Bastien Chevallier Date: Fri, 23 Nov 2018 12:18:06 +0100 Subject: [PATCH 089/174] Fix trailing space --- types/react-tag-input/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-tag-input/index.d.ts b/types/react-tag-input/index.d.ts index 380ab93693..f659faedf3 100644 --- a/types/react-tag-input/index.d.ts +++ b/types/react-tag-input/index.d.ts @@ -34,7 +34,7 @@ export interface ReactTagsProps { name?: string; id?: string; maxLength?: number; - + inline?: boolean; allowUnique?: boolean; allowDragDrop?: boolean; From b4dee98a6c42291a8e25fd49125dcf7df69f03bf Mon Sep 17 00:00:00 2001 From: Pavlos Vinieratos Date: Fri, 23 Nov 2018 12:31:17 +0100 Subject: [PATCH 090/174] make optional, since they have a default value --- types/react-native-safe-area/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native-safe-area/index.d.ts b/types/react-native-safe-area/index.d.ts index a6e922e083..fd38aec0a5 100644 --- a/types/react-native-safe-area/index.d.ts +++ b/types/react-native-safe-area/index.d.ts @@ -43,6 +43,6 @@ export type Direction = export function withSafeArea( WrappedComponent: React.ComponentType, - applyTo: 'margin' | 'padding' | 'absolutePosition' | 'contentInset', - direction: Direction, + applyTo?: 'margin' | 'padding' | 'absolutePosition' | 'contentInset', + direction?: Direction, ): React.ComponentType; From 36a32d8a728c5d69685b115703b4d06c5c91b87d Mon Sep 17 00:00:00 2001 From: Jessica Franco Date: Fri, 23 Nov 2018 22:31:04 +0900 Subject: [PATCH 091/174] Correct name in credits (#30772) --- types/emoji-mart/index.d.ts | 2 +- types/qhistory/index.d.ts | 2 +- types/react-loadable/index.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/emoji-mart/index.d.ts b/types/emoji-mart/index.d.ts index 38acd9e021..a92bcb77ff 100644 --- a/types/emoji-mart/index.d.ts +++ b/types/emoji-mart/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for emoji-mart 2.8 // Project: https://github.com/missive/emoji-mart -// Definitions by: Diogo Franco +// Definitions by: Jessica Franco // Nick Winans // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/qhistory/index.d.ts b/types/qhistory/index.d.ts index 84bd4e6d83..6269c25e82 100644 --- a/types/qhistory/index.d.ts +++ b/types/qhistory/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for qhistory 1.0 // Project: https://github.com/pshrmn/qhistory#readme -// Definitions by: Diogo Franco +// Definitions by: Jessica Franco // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index b27a4de764..bf8af8e794 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-loadable 5.4 // Project: https://github.com/thejameskyle/react-loadable#readme -// Definitions by: Diogo Franco +// Definitions by: Jessica Franco // Oden S. // Ian Ker-Seymer // Tomek Łaziuk From 184879995c1fb1d1f4a8803246fd0ecc41166a4d Mon Sep 17 00:00:00 2001 From: rvitorsantos Date: Fri, 23 Nov 2018 11:38:27 -0200 Subject: [PATCH 092/174] Add typing for Abstract Grant Type * Add typing for Abstract Grant Type * Add parameter extendedGrantTypes in TokenModel interface --- types/oauth2-server/index.d.ts | 61 +++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/types/oauth2-server/index.d.ts b/types/oauth2-server/index.d.ts index 27a863051f..4d4715b41f 100644 --- a/types/oauth2-server/index.d.ts +++ b/types/oauth2-server/index.d.ts @@ -2,7 +2,8 @@ // Project: https://github.com/oauthjs/node-oauth2-server // Definitions by: Robbie Van Gorkom , // Charles Irick , -// Daniel Fischer +// Daniel Fischer , +// Vitor Santos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -112,6 +113,59 @@ declare namespace OAuth2Server { redirect(url: string): void; } + abstract class AbstractGrantType { + + /** + * Instantiates AbstractGrantType using the supplied options. + * + */ + constructor(options: TokenOptions) + + /** + * Generate access token. Calls Model#generateAccessToken() if implemented. + * + */ + generateAccessToken(client: Client, user: User, scope: string | string[]): Promise; + + /** + * Generate refresh token. Calls + * + */ + generateRefreshToken(client: Client, user: User, scope: string | string[]): Promise; + + /** + * Get access token expiration date. + * + */ + getAccessTokenExpiresAt(): Date; + + /** + * Get refresh token expiration date. + * + */ + getRefreshTokenExpiresAt(): Date; + + /** + * Get scope from the request body. + * + */ + getScope(request: Request): string; + + /** + * Validate requested scope. Calls Model#validateScope() if implemented. + * + */ + validateScope(user: User, client: Client, scope: string | string[]): Promise; + + /** + * Retrieve info from the request and client and return token + * + */ + abstract handle(request: Request, client: Client): Promise; + + } + + interface ServerOptions extends AuthenticateOptions, AuthorizeOptions, TokenOptions { /** * Model object @@ -183,6 +237,11 @@ declare namespace OAuth2Server { * Always revoke the used refresh token and issue a new one for the refresh_token grant. */ alwaysIssueNewRefreshToken?: boolean; + + /** + * Additional supported grant types. + */ + extendedGrantTypes?: {[key: string]: typeof AbstractGrantType }; } /** From 7c04ee0c8a64870649ce8c618399f26ee9fd9dde Mon Sep 17 00:00:00 2001 From: Mihai Dinculescu Date: Fri, 23 Nov 2018 14:04:06 +0000 Subject: [PATCH 093/174] Code review changes. --- .../index.d.ts | 2 +- .../redux-immutable-state-invariant-tests.ts | 1 - .../tslint.json | 78 +------------------ 3 files changed, 2 insertions(+), 79 deletions(-) diff --git a/types/redux-immutable-state-invariant/index.d.ts b/types/redux-immutable-state-invariant/index.d.ts index 502f7e65bf..b4e7bcd0e2 100644 --- a/types/redux-immutable-state-invariant/index.d.ts +++ b/types/redux-immutable-state-invariant/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for redux-immutable-state-invariant v2.1.0 +// Type definitions for redux-immutable-state-invariant 2.1 // Project: https://github.com/leoasis/redux-immutable-state-invariant // Definitions by: Remo H. Jansen , Ben Rogers , Mihai Dinculescu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/redux-immutable-state-invariant/redux-immutable-state-invariant-tests.ts b/types/redux-immutable-state-invariant/redux-immutable-state-invariant-tests.ts index f6c26b6777..98abf5ac59 100644 --- a/types/redux-immutable-state-invariant/redux-immutable-state-invariant-tests.ts +++ b/types/redux-immutable-state-invariant/redux-immutable-state-invariant-tests.ts @@ -1,4 +1,3 @@ - import { applyMiddleware } from "redux"; import immutableStateInvariantMiddleware from "redux-immutable-state-invariant"; diff --git a/types/redux-immutable-state-invariant/tslint.json b/types/redux-immutable-state-invariant/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/redux-immutable-state-invariant/tslint.json +++ b/types/redux-immutable-state-invariant/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From 2a7faa683c4a80cb6f0a76f0dcc3180a79317911 Mon Sep 17 00:00:00 2001 From: Nicolas Biehler Date: Fri, 23 Nov 2018 15:35:35 +0100 Subject: [PATCH 094/174] fix: extend elasticsearch alias params As shown in elasticsearch documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#filtered), an alias can have a routing value and a filter specified. --- types/elasticsearch/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index 0d16cc6a4b..62202dbc90 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -1400,11 +1400,15 @@ export interface IndicesUpdateAliasesParamsAction { index?: string; indices?: string[]; alias: string; + routing?: string; + filter?: object; }; remove?: { index?: string; indices?: string[]; alias: string; + routing?: string; + filter?: object; }; remove_index?: { index: string; From cc8f6fcd7c73631c582b611359fadd0241e81cce Mon Sep 17 00:00:00 2001 From: Jessica Date: Sat, 24 Nov 2018 00:08:22 +0900 Subject: [PATCH 095/174] Fix incorrect type caught by stricter ReactType --- types/react-native-scrollable-tab-view/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-scrollable-tab-view/index.d.ts b/types/react-native-scrollable-tab-view/index.d.ts index 9be23aa66c..d992012856 100644 --- a/types/react-native-scrollable-tab-view/index.d.ts +++ b/types/react-native-scrollable-tab-view/index.d.ts @@ -125,7 +125,7 @@ export default class ScrollableTabView extends React.Component = T & { - tabLabel: React.ReactType; + tabLabel: React.ReactChild; }; export interface DefaultTabBarProps { From 8beb9e99a78464b855da7011872ba15575e023d6 Mon Sep 17 00:00:00 2001 From: Jessica Date: Sat, 24 Nov 2018 00:08:43 +0900 Subject: [PATCH 096/174] Fix test, add test to demonstrate how custom elements will work --- .../react-test-renderer-tests.ts | 8 ++++---- types/react/test/tsx.tsx | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/types/react-test-renderer/react-test-renderer-tests.ts b/types/react-test-renderer/react-test-renderer-tests.ts index 45568c81a7..83dc510e2b 100644 --- a/types/react-test-renderer/react-test-renderer-tests.ts +++ b/types/react-test-renderer/react-test-renderer-tests.ts @@ -43,14 +43,14 @@ function testInstance(inst: ReactTestInstance) { inst.props = { prop1: "p", }; - inst.type = "t"; - testInstance(inst.find(n => n.type === "t")); + inst.type = "a"; + testInstance(inst.find(n => n.type === "a")); testInstance(inst.findByProps({ prop1: "p" })); - testInstance(inst.findByType("t")); + testInstance(inst.findByType("a")); testInstance(inst.findByType(TestComponent)); inst.findAll(n => n.type === "t", { deep: true }).map(testInstance); inst.findAllByProps({ prop1: "p" }, { deep: true }).map(testInstance); - inst.findAllByType("t", { deep: true }).map(testInstance); + inst.findAllByType("a", { deep: true }).map(testInstance); inst.findAllByType(TestComponent, { deep: true }).map(testInstance); } diff --git a/types/react/test/tsx.tsx b/types/react/test/tsx.tsx index a8ca2ae1ea..60fcb6dccc 100644 --- a/types/react/test/tsx.tsx +++ b/types/react/test/tsx.tsx @@ -332,3 +332,16 @@ const HasFoo2: React.ReactType<{ foo: boolean }> = (props: { foo: boolean }) => const HasFoo3: React.ReactType<{ foo: boolean }> = (props: { foo: string }) => null; // $ExpectError const HasHref: React.ReactType<{ href?: string }> = 'a'; const HasHref2: React.ReactType<{ href?: string }> = 'div'; // $ExpectError + +const CustomElement: React.ReactType = 'my-undeclared-element'; // $ExpectError + +// custom elements now need to be declared as intrinsic elements +declare global { + namespace JSX { + interface IntrinsicElements { + 'my-declared-element': {}; + } + } +} + +const CustomElement2: React.ReactType = 'my-declared-element'; From adad38a0d50d2e53925bab47a87d09b1b9e4506d Mon Sep 17 00:00:00 2001 From: Vitor Santos Date: Fri, 23 Nov 2018 13:16:16 -0200 Subject: [PATCH 097/174] Fixed lint errors and incomplete comment --- types/oauth2-server/index.d.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/types/oauth2-server/index.d.ts b/types/oauth2-server/index.d.ts index 4d4715b41f..a846c489a2 100644 --- a/types/oauth2-server/index.d.ts +++ b/types/oauth2-server/index.d.ts @@ -114,7 +114,6 @@ declare namespace OAuth2Server { } abstract class AbstractGrantType { - /** * Instantiates AbstractGrantType using the supplied options. * @@ -128,7 +127,7 @@ declare namespace OAuth2Server { generateAccessToken(client: Client, user: User, scope: string | string[]): Promise; /** - * Generate refresh token. Calls + * Generate refresh token. Calls Model#generateRefreshToken() if implemented. * */ generateRefreshToken(client: Client, user: User, scope: string | string[]): Promise; @@ -162,10 +161,8 @@ declare namespace OAuth2Server { * */ abstract handle(request: Request, client: Client): Promise; - } - interface ServerOptions extends AuthenticateOptions, AuthorizeOptions, TokenOptions { /** * Model object @@ -241,7 +238,7 @@ declare namespace OAuth2Server { /** * Additional supported grant types. */ - extendedGrantTypes?: {[key: string]: typeof AbstractGrantType }; + extendedGrantTypes?: { [key: string]: typeof AbstractGrantType }; } /** From 2547248db261d514b845f3698d6c5036a410456a Mon Sep 17 00:00:00 2001 From: Yves Kaufmann Date: Fri, 23 Nov 2018 17:23:57 +0100 Subject: [PATCH 098/174] [mongodb] Add authMechanism parameter and replaces line comments with block comments --- types/mongodb/index.d.ts | 582 +++++++++++++++++++++++++-------- types/mongodb/mongodb-tests.ts | 13 +- 2 files changed, 446 insertions(+), 149 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index ab4d2f4c02..1ac38c79d5 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -79,7 +79,7 @@ export interface ClientSession extends EventEmitter { /** The server id associated with this session */ id: any; /** - * Aborts the currently active transaction in this session. + * Aborts the currently active transaction in this session. * @param {MongoCallback} [cb] Optional callback for completion of this operation */ abortTransaction(cb?: MongoCallback): Promise; @@ -89,7 +89,7 @@ export interface ClientSession extends EventEmitter { */ advanceOperationTime(operamtionTime: Timestamp): void; /** - * Commits the currently active transaction in this session. + * Commits the currently active transaction in this session. * @param {MongoCallback} [cb] Optional callback for completion of this operation */ commitTransaction(cb?: MongoCallback): Promise; @@ -110,7 +110,7 @@ export interface ClientSession extends EventEmitter { * Used to determine if this session equals another * * @param {ClientSession} session A class representing a client session on the server - * @returns {boolean} if the sessions are equal + * @returns {boolean} if the sessions are equal */ equals(session: ClientSession): boolean; @@ -118,13 +118,13 @@ export interface ClientSession extends EventEmitter { incrementTransactionNumber(): void; /** - * @returns {boolean} this session is currently in a transaction or not + * @returns {boolean} this session is currently in a transaction or not */ inTransaction(): boolean; /** * Starts a new transaction with the given options. - * @param {TransactionOptions} options + * @param {TransactionOptions} options * @memberof ClientSession */ startTransaction(options?: TransactionOptions): void; @@ -219,10 +219,10 @@ export class MongoError extends Error { * client/user (eg. "Email address must be unique" instead of "Both email * address and username must be unique") - which caters for a better (app) * user experience. - * + * * Details: https://github.com/Automattic/mongoose/issues/2129 (issue for * mongoose, but the same applies for the native mongodb driver) - * + * * Note that in mongoose (the link above) the prop in question is called * 'message' while in mongodb it is called 'errmsg'. This can be seen in * multiple places in the source code, for example here: @@ -231,6 +231,7 @@ export class MongoError extends Error { errmsg?: string; } + /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#.connect */ export interface MongoClientOptions extends DbCreateOptions, @@ -240,57 +241,120 @@ export interface MongoClientOptions extends SocketOptions, SSLOptions, HighAvailabilityOptions { - // The logging level (error/warn/info/debug) + + /** + * The logging level (error/warn/info/debug) + */ loggerLevel?: string; - // Custom logger object - logger?: Object; - // Default: false; + + /** + * Custom logger object + */ + logger?: Object | log; + + /** + * Validate MongoClient passed in options for correctness. + * Default: false + */ validateOptions?: Object; - // The name of the application that created this MongoClient instance. - appname?: string; + + /** + * The name of the application that created this MongoClient instance. + */ + appname?: string; + + /** + * Authentifikation credentials + */ auth?: { + /** + * The username for auth + */ user: string; + /** + * The password for auth + */ password: string; - }, - // Determines whether or not to use the new url parser - useNewUrlParser?: boolean + }; + + /** + * Determines whether or not to use the new url parser + */ + useNewUrlParser?: boolean; + + /** + * Mechanism for authentication: MDEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 + */ + authMechanism?: 'MDEFAULT' | 'GSSAPI' | 'PLAIN' | 'MONGODB-X509' | 'SCRAM-SHA-1' | string; } export interface SSLOptions { - // Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + /** + * Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + */ ciphers?: string; - // Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + /** + * Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + */ ecdhCurve?: string; - // Default:5; Number of connections for each server instance + /** + * Default:5; Number of connections for each server instance + */ poolSize?: number; - // If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections + /** + * If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections + */ minSize?: number; - // Use ssl connection (needs to have a mongod server with ssl support) + /** + * Use ssl connection (needs to have a mongod server with ssl support) + */ ssl?: boolean; - // Default: true; Validate mongod server certificate against ca (mongod server >=2.4 with ssl support required) + /** + * Default: true; Validate mongod server certificate against ca (mongod server >=2.4 with ssl support required) + */ sslValidate?: boolean; - // Default: true; Server identity checking during SSL + /** + * Default: true; Server identity checking during SSL + */ checkServerIdentity?: boolean | Function; - // Array of valid certificates either as Buffers or Strings + /** + * Array of valid certificates either as Buffers or Strings + */ sslCA?: Array; - // SSL Certificate revocation list binary buffer + /** + * SSL Certificate revocation list binary buffer + */ sslCRL?: Array; - // SSL Certificate binary buffer + /** + * SSL Certificate binary buffer + */ sslCert?: Buffer | string; - // SSL Key file binary buffer + /** + * SSL Key file binary buffer + */ sslKey?: Buffer | string; - // SSL Certificate pass phrase + /** + * SSL Certificate pass phrase + */ sslPass?: Buffer | string; - // String containing the server name requested via TLS SNI. + /** + * String containing the server name requested via TLS SNI. + */ servername?: string; } export interface HighAvailabilityOptions { - // Default: true; Turn on high availability monitoring. + /** + * Default: true; Turn on high availability monitoring. + */ ha?: boolean; - // Default: 10000; The High availability period for replicaset inquiry + /** + * Default: 10000; The High availability period for replicaset inquiry + */ haInterval?: number; - // Default: false; + /** + * Default: false; + */ domainsEnabled?: boolean; } @@ -299,7 +363,12 @@ export class ReadPreference { constructor(mode: string, tags: Object); mode: string; tags: any; - options: { maxStalenessSeconds?: number }; // Max Secondary Read Stalleness in Seconds + options: { + /** + * Max Secondary Read Stalleness in Seconds + */ + maxStalenessSeconds?: number + }; static PRIMARY: string; static PRIMARY_PREFERRED: string; static SECONDARY: string; @@ -311,86 +380,159 @@ export class ReadPreference { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html */ export interface DbCreateOptions extends CommonOptions { - // If the database authentication is dependent on another databaseName. + /** + * If the database authentication is dependent on another databaseName. + */ authSource?: string; - // Default: false; Force server to create _id fields instead of client. + /** + * Default: false; Force server to create _id fields instead of client. + */ forceServerObjectId?: boolean; - // Default: false; Use c++ bson parser. + /** + * Default: false; Use c++ bson parser. + */ native_parser?: boolean; - // Serialize functions on any object. + /** + * Serialize functions on any object. + */ serializeFunctions?: boolean; - // Specify if the BSON serializer should ignore undefined fields. + /** + * Specify if the BSON serializer should ignore undefined fields. + */ ignoreUndefined?: boolean; - // Return document results as raw BSON buffers. + /** + * Return document results as raw BSON buffers. + */ raw?: boolean; - // Default: true; Promotes Long values to number if they fit inside the 53 bits resolution. + /** + * Default: true; Promotes Long values to number if they fit inside the 53 bits resolution. + */ promoteLongs?: boolean; - // Default: false; Promotes Binary BSON values to native Node Buffers + /** + * Default: false; Promotes Binary BSON values to native Node Buffers + */ promoteBuffers?: boolean; - // the prefered read preference. use 'ReadPreference' class. + /** + * the prefered read preference. use 'ReadPreference' class. + */ readPreference?: ReadPreference | string; - // Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types. + /** + * Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types. + */ promoteValues?: Object; - // Custom primary key factory to generate _id values (see Custom primary keys). + /** + * Custom primary key factory to generate _id values (see Custom primary keys). + */ pkFactory?: Object; - // ES6 compatible promise constructor + /** + * ES6 compatible promise constructor + */ promiseLibrary?: Object; /** https://docs.mongodb.com/manual/reference/read-concern/#read-concern */ readConcern?: ReadConcern; - // Sets a cap on how many operations the driver will buffer up before giving up on getting a - // working connection, default is -1 which is unlimited. + /** + * Sets a cap on how many operations the driver will buffer up before giving up on getting a + */ + /** + * working connection, default is -1 which is unlimited. + */ bufferMaxEntries?: number; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Server.html */ export interface SocketOptions { - // Reconnect on error. default:false + /** + * Reconnect on error. default:false + */ autoReconnect?: boolean; - // TCP Socket NoDelay option. default:true + /** + * TCP Socket NoDelay option. default:true + */ noDelay?: boolean; - // TCP KeepAlive enabled on the socket. default:true + /** + * TCP KeepAlive enabled on the socket. default:true + */ keepAlive?: boolean; - // TCP KeepAlive initial delay before sending first keep-alive packet when idle. default:300000 + /** + * TCP KeepAlive initial delay before sending first keep-alive packet when idle. default:300000 + */ keepAliveInitialDelay?: number; - // TCP Connection timeout setting. default 0 + /** + * TCP Connection timeout setting. default 0 + */ connectTimeoutMS?: number; - // Version of IP stack. Can be 4, 6 or null. default: null. - // If null, will attempt to connect with IPv6, and will fall back to IPv4 on failure - // refer to http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html + /** + * Version of IP stack. Can be 4, 6 or null. default: null. + */ + /** + * If null, will attempt to connect with IPv6, and will fall back to IPv4 on failure + */ + /** + * refer to http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html + */ family?: 4 | 6 | null; - // TCP Socket timeout setting. default 0 + /** + * TCP Socket timeout setting. default 0 + */ socketTimeoutMS?: number; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Server.html */ export interface ServerOptions extends SSLOptions { - // Default: 30; + /** + * Default: 30; + */ reconnectTries?: number; - // Default: 1000; + /** + * Default: 1000; + */ reconnectInterval?: number; - // Default: true; + /** + * Default: true; + */ monitoring?: boolean + + /** + * Socket Options + */ socketOptions?: SocketOptions; - // Default: 10000; The High availability period for replicaset inquiry + + /** + * Default: 10000; The High availability period for replicaset inquiry + */ haInterval?: number; - // Default: false; + /** + * Default: false; + */ domainsEnabled?: boolean; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Mongos.html */ export interface MongosOptions extends SSLOptions, HighAvailabilityOptions { - // Default: 15; Cutoff latency point in MS for MongoS proxy selection + /** + * Default: 15; Cutoff latency point in MS for MongoS proxy selection + */ acceptableLatencyMS?: number; + + /** + * Socket Options + */ socketOptions?: SocketOptions; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/ReplSet.html */ export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions { - // The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + /** + * The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + */ maxStalenessSeconds?: number; - // The name of the replicaset to connect to. + /** + * The name of the replicaset to connect to. + */ replicaSet?: string; - // Default: 15 ; Range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms) + /** + * Default: 15 ; Range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms) + */ secondaryAcceptableLatencyMS?: number; connectWithNoPrimary?: boolean; socketOptions?: SocketOptions; @@ -482,28 +624,40 @@ export interface CommonOptions extends WriteConcern { session?: ClientSession; } -// Deprecated http://mongodb.github.io/node-mongodb-native/3.1/api/Server.html +/** + * @deprecated + * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Server.html + */ export class Server extends EventEmitter { constructor(host: string, port: number, options?: ServerOptions); connections(): Array; } -// Deprecated http://mongodb.github.io/node-mongodb-native/3.1/api/ReplSet.html +/** + * @deprecated + * @see http://mongodb.github.io/node-mongodb-native/3.1/api/ReplSet.html + */ export class ReplSet extends EventEmitter { constructor(servers: Array, options?: ReplSetOptions); connections(): Array; } -// Deprecated http://mongodb.github.io/node-mongodb-native/3.1/api/ReplSet.html +/** + * @deprecated + * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Mongos.html + */ export class Mongos extends EventEmitter { constructor(servers: Array, options?: MongosOptions); connections(): Array; } -/** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#addUser */ +/** + * @deprecated + * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#addUser + */ export interface DbAddUserOptions extends CommonOptions { customData?: Object; roles?: Object[]; @@ -543,27 +697,48 @@ export interface DbCollectionOptions extends CommonOptions { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createIndex */ export interface IndexOptions extends CommonOptions { - // Creates an unique index. + /** + * Creates an unique index. + */ unique?: boolean; - // Creates a sparse index. + /** + * Creates a sparse index. + */ sparse?: boolean; - // Creates the index in the background, yielding whenever possible. + /** + * Creates the index in the background, yielding whenever possible. + */ background?: boolean; - // A unique index cannot be created on a key that has pre-existing duplicate values. - // If you would like to create the index anyway, keeping the first document the database indexes and - // deleting all subsequent documents that have duplicate value + /** + * A unique index cannot be created on a key that has pre-existing duplicate values. + * + * If you would like to create the index anyway, keeping the first document the database indexes and + * deleting all subsequent documents that have duplicate value + */ dropDups?: boolean; - // For geo spatial indexes set the lower bound for the co-ordinates. + /** + * For geo spatial indexes set the lower bound for the co-ordinates. + */ min?: number; - // For geo spatial indexes set the high bound for the co-ordinates. + /** + * For geo spatial indexes set the high bound for the co-ordinates. + */ max?: number; - // Specify the format version of the indexes. + /** + * Specify the format version of the indexes. + */ v?: number; - // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + /** + * Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + */ expireAfterSeconds?: number; - // Override the auto generated index name (useful if the resulting name is larger than 128 bytes) + /** + * Override the auto generated index name (useful if the resulting name is larger than 128 bytes) + */ name?: string; - // Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + /** + * Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + */ partialFilterExpression?: any; collation?: Object; default_language?: string @@ -619,17 +794,27 @@ export interface FSyncOptions extends CommonOptions { fsync?: boolean } -// Documentation : http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html +/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html */ export interface Collection { - // Get the collection name. + /** + * Get the collection name. + */ collectionName: string; - // Get the full collection namespace. + /** + * Get the full collection namespace. + */ namespace: string; - // The current write concern values. + /** + * The current write concern values. + */ writeConcern: any; - // The current read concern values. + /** + * The current read concern values. + */ readConcern: ReadConcern; - // Get current index hint for collection. + /** + * Get current index hint for collection. + */ hint: any; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate */ aggregate(callback: MongoCallback>): AggregationCursor; @@ -880,40 +1065,70 @@ export type FilterQuery = { [P in keyof T]?: T[P] | Condition; } | { [key: string]: any }; -// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ +/** http://docs.mongodb.org/manual/reference/command/collStats/ */ export interface CollStats { - // Namespace. + /** + * Namespace. + */ ns: string; - // Number of documents. + /** + * Number of documents. + */ count: number; - // Collection size in bytes. + /** + * Collection size in bytes. + */ size: number; - // Average object size in bytes. + /** + * Average object size in bytes. + */ avgObjSize: number; - // (Pre)allocated space for the collection in bytes. + /** + * (Pre)allocated space for the collection in bytes. + */ storageSize: number; - // Number of extents (contiguously allocated chunks of datafile space). + /** + * Number of extents (contiguously allocated chunks of datafile space). + */ numExtents: number; - // Number of indexes. + /** + * Number of indexes. + */ nindexes: number; - // Size of the most recently created extent in bytes. + /** + * Size of the most recently created extent in bytes. + */ lastExtentSize: number; - // Padding can speed up updates if documents grow. + /** + * Padding can speed up updates if documents grow. + */ paddingFactor: number; - // A number that indicates the user-set flags on the collection. userFlags only appears when using the mmapv1 storage engine. + /** + * A number that indicates the user-set flags on the collection. userFlags only appears when using the mmapv1 storage engine. + */ userFlags?: number; - // Total index size in bytes. + /** + * Total index size in bytes. + */ totalIndexSize: number; - // Size of specific indexes in bytes. + /** + * Size of specific indexes in bytes. + */ indexSizes: { _id_: number; [index: string]: number; }; - // `true` if the collection is capped. + /** + * `true` if the collection is capped. + */ capped: boolean; - // The maximum number of documents that may be present in a capped collection. + /** + * The maximum number of documents that may be present in a capped collection. + */ max: number; - // The maximum size of a capped collection. + /** + * The maximum size of a capped collection. + */ maxSize: number; wiredTiger?: WiredTigerData; indexDetails?: any; @@ -1059,18 +1274,28 @@ export interface WiredTigerData { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#aggregate */ export interface CollectionAggregationOptions { readPreference?: ReadPreference | string; - // Return the query as cursor, on 2.6 > it returns as a real cursor - // on pre 2.6 it returns as an emulated cursor. + /** + * Return the query as cursor, on 2.6 > it returns as a real cursor + * on pre 2.6 it returns as an emulated cursor. + */ cursor?: { batchSize?: number }; - // Explain returns the aggregation execution plan (requires mongodb 2.6 >). + /** + * Explain returns the aggregation execution plan (requires mongodb 2.6 >). + */ explain?: boolean; - // lets the server know if it can use disk to store - // temporary results for the aggregation (requires mongodb 2.6 >). + /** + * Lets the server know if it can use disk to store + * temporary results for the aggregation (requires mongodb 2.6 >). + */ allowDiskUse?: boolean; - // specifies a cumulative time limit in milliseconds for processing operations - // on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + /** + * specifies a cumulative time limit in milliseconds for processing operations + * on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + */ maxTimeMS?: number; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + /** + * Allow driver to bypass schema validation in MongoDB 3.2 or higher. + */ bypassDocumentValidation?: boolean; raw?: boolean; promoteLongs?: boolean; @@ -1084,23 +1309,37 @@ export interface CollectionAggregationOptions { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#insertMany */ export interface CollectionInsertManyOptions extends CommonOptions { - // Serialize functions on any object. + /** + * Serialize functions on any object. + */ serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. + /** + * Force server to assign _id values instead of driver. + */ forceServerObjectId?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + /** + * Allow driver to bypass schema validation in MongoDB 3.2 or higher. + */ bypassDocumentValidation?: boolean; - // If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. + /** + * If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. + */ ordered?: boolean; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#bulkWrite */ export interface CollectionBulkWriteOptions extends CommonOptions { - // Serialize functions on any object. + /** + * Serialize functions on any object. + */ serializeFunctions?: boolean; - // Execute write operation in ordered or unordered fashion. + /** + * Execute write operation in ordered or unordered fashion. + */ ordered?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + /** + * Allow driver to bypass schema validation in MongoDB 3.2 or higher. + */ bypassDocumentValidation?: boolean; //Force server to assign _id values instead of driver. forceServerObjectId?: boolean; @@ -1120,13 +1359,21 @@ export interface BulkWriteOpResultObject { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#count */ export interface MongoCountPreferences { - // The limit of documents to count. + /** + * The limit of documents to count. + */ limit?: number; - // The number of documents to skip for the count. + /** + * The number of documents to skip for the count. + */ skip?: boolean; - // An index name hint for the query. + /** + * An index name hint for the query. + */ hint?: string; - // The preferred read preference + /** + * The preferred read preference + */ readPreference?: ReadPreference | string; maxTimeMS?: number; session?: ClientSession; @@ -1292,7 +1539,10 @@ export interface FindOneOptions { limit?: number; sort?: Array | Object; projection?: Object; - fields?: Object; // Deprecated Use options.projection instead + /** + * @deprecated Use options.projection instead + */ + fields?: Object; skip?: number; hint?: Object; explain?: boolean; @@ -1328,7 +1578,9 @@ export interface InsertWriteOpResult { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#insertOne */ export interface CollectionInsertOneOptions extends CommonOptions { - // Serialize functions on any object. + /** + * Serialize functions on any object. + */ serializeFunctions?: boolean; //Force server to assign _id values instead of driver. forceServerObjectId?: boolean; @@ -1683,17 +1935,29 @@ export class GridFSBucketWriteStream extends Writable { /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketWriteStream.html */ export interface GridFSBucketWriteStreamOptions { - /** Custom file id for the GridFS file. */ + /** + * Custom file id for the GridFS file. + **/ id?: GridFSBucketWriteStreamId, - /** The chunk size to use, in bytes */ + /** + * The chunk size to use, in bytes + */ chunkSizeBytes?: number, - /** The write concern */ + /** + * The write concern + */ w?: number, - /** The write concern timeout */ + /** + * The write concern timeout + */ wtimeout?: number, - /** The journal write concern */ + /** + * The journal write concern + */ j?: number - /** Default false; If true, disables adding an md5 field to file data */ + /** + * Default false; If true, disables adding an md5 field to file data + */ disableMD5?: boolean } @@ -1732,8 +1996,14 @@ export interface ChangeStreamOptions { type GridFSBucketWriteStreamId = string | number | Object | ObjectID; export interface LoggerOptions { - loggerLevel?: string // Custom logger function - logger?: log // Override default global log level. + /** + * Custom logger function + */ + loggerLevel?: string + /** + * Override default global log level. + */ + logger?: log } export type log = (message?: string, state?: LoggerState) => void @@ -1749,30 +2019,54 @@ export interface LoggerState { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Logger.html */ export class Logger { constructor(className: string, options?: LoggerOptions) - // Log a message at the debug level + /** + * Log a message at the debug level + */ debug(message: string, state: LoggerState): void - // Log a message at the warn level + /** + * Log a message at the warn level + */ warn(message: string, state: LoggerState): void - // Log a message at the info level + /** + * Log a message at the info level + */ info(message: string, state: LoggerState): void - // Log a message at the error level + /** + * Log a message at the error level + */ error(message: string, state: LoggerState): void - // Is the logger set at info level + /** + * Is the logger set at info level + */ isInfo(): boolean - // Is the logger set at error level + /** + * Is the logger set at error level + */ isError(): boolean - // Is the logger set at error level + /** + * Is the logger set at error level + */ isWarn(): boolean - // Is the logger set at debug level + /** + * Is the logger set at debug level + */ isDebug(): boolean - // Resets the logger to default settings, error and no filtered classes + /** + * Resets the logger to default settings, error and no filtered classes + */ static reset(): void - // Get the current logger function + /** + * Get the current logger function + */ static currentLogger(): log //Set the current logger function static setCurrentLogger(log: log): void - // Set what classes to log. + /** + * Set what classes to log. + */ static filter(type: string, values: string[]): void - // Set the current log level + /** + * Set the current log level + */ static setLevel(level: string): void } diff --git a/types/mongodb/mongodb-tests.ts b/types/mongodb/mongodb-tests.ts index b9b4a63c8d..ea755a8eb1 100644 --- a/types/mongodb/mongodb-tests.ts +++ b/types/mongodb/mongodb-tests.ts @@ -7,6 +7,7 @@ const connectionString = 'mongodb://127.0.0.1:27017/test'; var format = require('util').format; let options: mongodb.MongoClientOptions = { authSource: ' ', + loggerLevel: 'debug', w: 1, wtimeout: 300, j: true, @@ -21,7 +22,6 @@ let options: mongodb.MongoClientOptions = { reconnectTries: 123456, reconnectInterval: 123456, - ssl: true, sslValidate: false, checkServerIdentity: function () { }, @@ -31,12 +31,14 @@ let options: mongodb.MongoClientOptions = { sslKey: new Buffer(999), sslPass: new Buffer(999), promoteBuffers: false, - useNewUrlParser: false + useNewUrlParser: false, + authMechanism: 'SCRAM-SHA-1', + forceServerObjectId: false } MongoClient.connect(connectionString, options, function (err: mongodb.MongoError, client: mongodb.MongoClient) { if (err) throw err; const db = client.db('test'); - + var collection = db.collection('test_insert'); collection.insertOne({ a: 2 }, function (err: mongodb.MongoError, docs: any) { @@ -263,11 +265,11 @@ async function transfer(client: mongodb.MongoClient, from: any, to: any, amount: // `session.abortTransaction()` will undo the above `findOneAndUpdate()` throw new Error('Insufficient funds: ' + (A.balance + amount)); } - + const B = await db.collection('Account'). findOneAndUpdate({ name: to }, { $inc: { balance: amount } }, opts). then(res => res.value); - + await session.commitTransaction(); session.endSession(); return { from: A, to: B }; @@ -287,3 +289,4 @@ mongodb.connect(connectionString).then((client) => { ); }); + From 12a360ab0cee924cbf658f3b23cfdf3645368015 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 23 Nov 2018 19:49:32 +0100 Subject: [PATCH 099/174] Update index.d.ts Remove umd namespace --- types/kdbxweb/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/kdbxweb/index.d.ts b/types/kdbxweb/index.d.ts index 805a45a2b0..f2f487156c 100644 --- a/types/kdbxweb/index.d.ts +++ b/types/kdbxweb/index.d.ts @@ -4,8 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export as namespace kdbxweb; - export type KdbxObject = Entry | Group; export type StringProtected = ProtectedValue | string; From 4e31c72dfdc1f7f61ef666a6667b8bcfff6a0824 Mon Sep 17 00:00:00 2001 From: Yves Kaufmann Date: Fri, 23 Nov 2018 21:33:48 +0100 Subject: [PATCH 100/174] [MONGODB] Fixes possible authMechanism values --- types/mongodb/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 1ac38c79d5..e516e4d31f 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -283,9 +283,9 @@ export interface MongoClientOptions extends useNewUrlParser?: boolean; /** - * Mechanism for authentication: MDEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 + * Mechanism for authentication: DEFAULT, GSSAPI, PLAIN, MONGODB-X509, 'MONGODB-CR', SCRAM-SHA-1 or SCRAM-SHA-256 */ - authMechanism?: 'MDEFAULT' | 'GSSAPI' | 'PLAIN' | 'MONGODB-X509' | 'SCRAM-SHA-1' | string; + authMechanism?: 'DEFAULT' | 'GSSAPI' | 'PLAIN' | 'MONGODB-X509' | 'MONGODB-CR' | 'SCRAM-SHA-1' | 'SCRAM-SHA-256' | string; } export interface SSLOptions { From 47a677d74878a66f09b1b6ea0168184068f73aed Mon Sep 17 00:00:00 2001 From: Matt Ferderer Date: Fri, 23 Nov 2018 15:29:05 -0600 Subject: [PATCH 101/174] Fixed amount token property to be optional --- types/stripejs/token.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/stripejs/token.d.ts b/types/stripejs/token.d.ts index dac3308393..89da22bf8e 100644 --- a/types/stripejs/token.d.ts +++ b/types/stripejs/token.d.ts @@ -59,7 +59,7 @@ export interface TokenData { /** * The amount paid, not a decimal. In USD this is in cents. */ - amount: number; + amount?: number; /** * Fields for billing address information. From e0a0256b1706edcbe9079d492c34e28f3682ad4a Mon Sep 17 00:00:00 2001 From: Sibiraj Date: Sat, 24 Nov 2018 12:49:36 +0530 Subject: [PATCH 102/174] fix(prettier): use correct parser type for SupportLanguages --- types/prettier/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index 3a64129364..71bb080e9f 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -256,7 +256,7 @@ export function clearConfigCache(): void; export interface SupportLanguage { name: string; since?: string; - parsers: string[]; + parsers: BuiltInParserName[]; group?: string; tmScope: string; aceMode: string; From 55ab68c976231b6c2d0c34e6761d5f91c7027383 Mon Sep 17 00:00:00 2001 From: Sibiraj <20282546+sibiraj-s@users.noreply.github.com> Date: Sat, 24 Nov 2018 16:13:17 +0530 Subject: [PATCH 103/174] fix: update types to support external plugins --- types/prettier/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index 71bb080e9f..6cef2ef27a 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -256,7 +256,7 @@ export function clearConfigCache(): void; export interface SupportLanguage { name: string; since?: string; - parsers: BuiltInParserName[]; + parsers: BuiltInParserName[] | string[]; group?: string; tmScope: string; aceMode: string; From ec0977d8d5f20dd2a41c859cdbf5f4c0c4e12337 Mon Sep 17 00:00:00 2001 From: Igor Stepanov Date: Sat, 24 Nov 2018 15:24:34 +0300 Subject: [PATCH 104/174] @types/got: add TimeoutError interface Add `got.TimeoutError` in accordance with sindresorhus/got@da4f23699dead63f17b5e27f9cadd9e4cb95e9a9 --- types/got/got-tests.ts | 1 + types/got/index.d.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index 934adfc9a8..55680e7d27 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -269,3 +269,4 @@ got('http://todomvc.com', { retry: 2 }); got('http://todomvc.com', { retry: { retries: 2, methods: ['GET'], statusCodes: [408, 504], maxRetryAfter: 1 } }); got('http://todomvc.com', { throwHttpErrors: false }); got('http://todomvc.com', { hooks: { beforeRequest: [ () => 'foo']} }); +got('http://todomvc.com', { timeout: 1 }).catch((e) => e instanceof got.TimeoutError); diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 6b0929fdcf..d0cfc682dc 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -53,6 +53,10 @@ declare class CancelError extends StdError { name: 'CancelError'; } +declare class TimeoutError extends StdError { + name: 'TimeoutError'; +} + declare class StdError extends Error { code?: string; host?: string; @@ -75,6 +79,7 @@ declare const got: got.GotFn & MaxRedirectsError: typeof MaxRedirectsError; UnsupportedProtocolError: typeof UnsupportedProtocolError; CancelError: typeof CancelError; + TimeoutError: typeof TimeoutError; }; interface InternalRequestOptions extends https.RequestOptions { @@ -215,7 +220,7 @@ declare namespace got { removeListener(event: 'uploadProgress', listener: (progress: Progress) => void): this; } - type GotError = RequestError | ReadError | ParseError | HTTPError | MaxRedirectsError | UnsupportedProtocolError | CancelError; + type GotError = RequestError | ReadError | ParseError | HTTPError | MaxRedirectsError | UnsupportedProtocolError | CancelError | TimeoutError; interface Progress { percent: number; From 0f79f9e451ad86718cf3baaca65b5c229bab7593 Mon Sep 17 00:00:00 2001 From: Albert Kurniawan Date: Wed, 14 Nov 2018 21:16:39 +0000 Subject: [PATCH 105/174] Remove morcerf from codeowners --- .github/CODEOWNERS | 6 +++--- types/connect-redis/index.d.ts | 1 - types/react/index.d.ts | 1 - types/react/v15/index.d.ts | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index df45a8a9e7..0305e57c9b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -644,7 +644,7 @@ /types/connect-mongo/ @Syati /types/connect-mongodb-session/ @NattapongSiri /types/connect-pg-simple/ @pasieronen -/types/connect-redis/ @xstoudi @morcerf +/types/connect-redis/ @xstoudi /types/connect-slashes/ @samherrmann /types/connect-timeout/ @cyrilschumacher /types/consola/ @Jungwoo-An @@ -3691,8 +3691,8 @@ /types/rdflib/ @cenotelie /types/re-base/ @jordandrako /types/reach__router/ @kingdaro -/types/react/v15/ @bbenezech @pzavolinsky @digiguru @ericanderson @morcerf @tkrotoff @DovydasNavickas @onigoetz -/types/react/ @johnnyreilly @bbenezech @pzavolinsky @digiguru @ericanderson @morcerf @tkrotoff @DovydasNavickas @onigoetz @theruther4d @guilhermehubner @ferdaber @jrakotoharisoa @pascaloliv @hotell @franklixuefei +/types/react/v15/ @bbenezech @pzavolinsky @digiguru @ericanderson @tkrotoff @DovydasNavickas @onigoetz +/types/react/ @johnnyreilly @bbenezech @pzavolinsky @digiguru @ericanderson @tkrotoff @DovydasNavickas @onigoetz @theruther4d @guilhermehubner @ferdaber @jrakotoharisoa @pascaloliv @hotell @franklixuefei /types/react-adal/ @dkorolev1 /types/react-albus/ @sseppola @conradreuter @kuirak /types/react-alert/v2/ @ssyrell diff --git a/types/connect-redis/index.d.ts b/types/connect-redis/index.d.ts index 5675512795..c5a26de73a 100644 --- a/types/connect-redis/index.d.ts +++ b/types/connect-redis/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for connect-redis // Project: https://npmjs.com/package/connect-redis // Definitions by: Xavier Stouder -// Albert Kurniawan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 25f3c710ae..ebcb097eda 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -8,7 +8,6 @@ // Patricio Zavolinsky // Digiguru // Eric Anderson -// Albert Kurniawan // Tanguy Krotoff // Dovydas Navickas // Stéphane Goetz diff --git a/types/react/v15/index.d.ts b/types/react/v15/index.d.ts index 78ec7d8951..ce2a523123 100644 --- a/types/react/v15/index.d.ts +++ b/types/react/v15/index.d.ts @@ -8,7 +8,6 @@ // Patricio Zavolinsky // Digiguru // Eric Anderson -// Albert Kurniawan // Tanguy Krotoff // Dovydas Navickas // Stéphane Goetz From 55aca0b31c103ca32fed346e63532cee17b00834 Mon Sep 17 00:00:00 2001 From: Ehab Khaireldin Date: Sat, 24 Nov 2018 19:58:45 +0100 Subject: [PATCH 106/174] johnny-five LCD class types --- types/johnny-five/index.d.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/types/johnny-five/index.d.ts b/types/johnny-five/index.d.ts index 6a00952153..a770cd2126 100644 --- a/types/johnny-five/index.d.ts +++ b/types/johnny-five/index.d.ts @@ -365,22 +365,22 @@ export declare class LCD { rows: number; cols: number; - print(message: string): void; - useChar(char: string): void; - clear(): void; - cursor(row: number, col: number): void; - home(): void; - on(): void; - off(): void; - display(): void; - noDisplay(): void; - blink(): void; - noBlink(): void; - autoscroll(): void; - noAutoscroll(): void; - bgColor(color: any): void; - noBacklight(): void; - backlight(): void; + print(message: string): this; + useChar(char: string): this; + clear(): this; + cursor(row: number, col: number): this; + home(): this; + on(): this; + off(): this; + display(): this; + noDisplay(): this; + blink(): this; + noBlink(): this; + autoscroll(): this; + noAutoscroll(): this; + bgColor(color: any): this; + noBacklight(): this; + backlight(): this; } export interface LedOption { From e8a26cf2519bdf874690b3324751c03a0e4a99d2 Mon Sep 17 00:00:00 2001 From: Al Calzone Date: Sun, 25 Nov 2018 13:16:41 +0100 Subject: [PATCH 107/174] Add definition for removeAllListeners to noble --- types/noble/index.d.ts | 2 ++ types/noble/noble-tests.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/types/noble/index.d.ts b/types/noble/index.d.ts index 61ca1f2113..5b4af235e7 100644 --- a/types/noble/index.d.ts +++ b/types/noble/index.d.ts @@ -30,6 +30,8 @@ export declare function removeListener(event: "scanStop", listener: () => void): export declare function removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter; export declare function removeListener(event: string, listener: Function): events.EventEmitter; +export declare function removeAllListeners(event?: string): events.EventEmitter; + export declare var state:string; export declare class Peripheral extends events.EventEmitter { diff --git a/types/noble/noble-tests.ts b/types/noble/noble-tests.ts index 0c8dcf6c20..a4441eba6e 100644 --- a/types/noble/noble-tests.ts +++ b/types/noble/noble-tests.ts @@ -35,6 +35,12 @@ noble.removeListener("discover", (peripheral: noble.Peripheral): void => { peripheral.disconnect((): void => {}); }); +noble.removeAllListeners("stateChange"); +noble.removeAllListeners("scanStart"); +noble.removeAllListeners("scanStop"); +noble.removeAllListeners("discover"); +noble.removeAllListeners(); + var peripheral: noble.Peripheral = new noble.Peripheral(); peripheral.uuid = "12ad4e81"; peripheral.advertisement = { From 99f291773163b608b3a339961584f9638c907bbe Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Wed, 14 Nov 2018 18:52:43 +0100 Subject: [PATCH 108/174] Add typings for ioBroker adapters --- types/iobroker/index.d.ts | 1387 ++++++++++++++++++++++++++++++ types/iobroker/iobroker-tests.ts | 0 types/iobroker/tsconfig.json | 22 + types/iobroker/tslint.json | 1 + 4 files changed, 1410 insertions(+) create mode 100644 types/iobroker/index.d.ts create mode 100644 types/iobroker/iobroker-tests.ts create mode 100644 types/iobroker/tsconfig.json create mode 100644 types/iobroker/tslint.json diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts new file mode 100644 index 0000000000..fab5a5a107 --- /dev/null +++ b/types/iobroker/index.d.ts @@ -0,0 +1,1387 @@ +/// +import fs = require("fs"); + +// tslint:disable:no-namespace +declare global { + namespace ioBroker { + + enum StateQuality { + good = 0x00, // or undefined or null + bad = 0x01, + general_problem = 0x01, + general_device_problem = 0x41, + general_sensor_problem = 0x81, + device_not_connected = 0x42, + sensor_not_connected = 0x82, + device_reports_error = 0x44, + sensor_reports_error = 0x84, + } + + interface State { + /** The value of the state. */ + val: any; + + /** Direction flag: false for desired value and true for actual value. Default: false. */ + ack: boolean; + + /** Unix timestamp. Default: current time */ + ts: number; + + /** Unix timestamp of the last time the value changed */ + lc: number; + + /** Name of the adapter instance which set the value, e.g. "system.adapter.web.0" */ + from: string; + + /** Optional time in seconds after which the state is reset to null */ + expire?: number; + + /** Optional quality of the state value */ + q?: StateQuality; + + /** Optional comment */ + c?: string; + } + + /** Provides low-level access to the ioBroker states DB */ + interface States { + + /** + * Returns a list of states with the given ids + * @param keys IDs of the states to be retrieved + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getStates(keys: string[], callback: GetStatesCallback2, dontModify?: any): void; + + /** + * Returns the state with the given id + * @param id ID of the state to be retrieved + * @param callback Is called when the operation has finished (successfully or not) + */ + getState(id: string, callback: GetStateCallback): void; + + /** + * Stores a state in the db + * @param id ID of the state to be stored + * @param state The state to be stored in the db + * @param callback Is called when the operation has finished (successfully or not) + */ + setState(id: string, state?: string | number | boolean | State | Partial, callback?: SetStateCallback): void; + + /** + * Updates a state in memory without triggering a save + * @param id ID of the state to be stored + * @param state The state to be updated + * @param callback Is called when the operation has finished (successfully or not) + */ + setRawState(id: string, state: State, callback?: SetStateCallback): void; + + /** + * Deletes a state + * @param id ID of the state to be stored + * @param callback Is called when the operation has finished (successfully or not) + */ + delState(id: string, callback: DeleteStateCallback): void; + + /** + * Retrieves all ids of states matching @link{pattern} + * @param pattern The pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; + + /** + * Subscribe to changes of all states matching @link{pattern} + * @param pattern The pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + */ + subscribe(pattern: string, cb: EmptyCallback): void; + /** + * Unsubscribe from changes of all states matching @link{pattern} + * @param pattern The pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + */ + unsubscribe(pattern: string, cb: EmptyCallback): void; + + /** + * Register an adapter instance as subscribable. + * This means that the instance can read information about all subscriptions to its states + * and will be notified of changes. + * @param instance Adapter instance to register, e.g. "admin.0" + * @param cb Is called when the operation has finished (successfully or not) + */ + registerAdapterSubs(instance: string, cb?: (error: null, success: boolean) => void): void; + + /** + * Unregister an adapter instance as subscribable. + * @param instance Adapter instance to unregister, e.g. "admin.0" + * @param cb Is called when the operation has finished (successfully or not) + */ + unregisterAdapterSubs(instance: string, cb?: (error: null, success: boolean) => void): void; + + /** + * EDUCATED GUESS: Notify all clients about changes to an object + * @param type object type + * @param id State/object id + * @param obj The changed object + */ + publishAll(type: string, id: string, obj: Message): void; + + // TODO: Documentation for these functions is missing + pushMessage(id: string, state: Message, callback: SetStateCallback): void; + lenMessage(id: string, callback: GenericCallback): void; + getMessage(id: string, callback: GenericCallback): void; + delMessage(id: string, messageId: number, callback: ErrorCallback): void; + clearAllMessages(callback?: EmptyCallback): void; + subscribeMessage(id: string, cb: EmptyCallback): void; + unsubscribeMessage(id: string, cb: EmptyCallback): void; + + pushLog(id: string, log: Log, callback: SetStateCallback): void; + lenLog(id: string, callback: GenericCallback): void; + getLog(id: string, callback: GenericCallback): void; + delLog(id: string, logId: string, callback: ErrorCallback): void; + clearAllLogs(callback?: EmptyCallback): void; + subscribeLog(id: string, cb: EmptyCallback): void; + unsubscribeLog(id: string, cb: EmptyCallback): void; + + getSession(id: string, callback: GetSessionCallback): void; + setSession(id: string, expire: number, callback?: EmptyCallback): void; + setSession(id: string, expire: number, obj: Session, callback?: EmptyCallback): void; + destroySession(id: string, callback?: EmptyCallback): void; + + /** + * Retrieves a copy of the object with the given ID + * @param id Id of the object to find + * @param callback Is called when the operation has finished (successfully or not) + */ + getConfig(id: string, callback: GetObjectCallback): void; + + /** + * Returns a list of config keys matching + * @param pattern Pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; + + /** + * Returns a list of objects with the given ids + * @param keys IDs of the objects to be retrieved + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; + + /** + * Creates or overwrites a config object in the object db + * @param id ID of the object + * @param obj Object to store + * @param callback Is called when the operation has finished (successfully or not) + */ + setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; + + /** + * Deletes a config object in the object db + * @param id ID of the object + * @param callback Is called when the operation has finished (successfully or not) + */ + delConfig(id: string, callback: ErrorCallback): void; + + /** + * Subscribe to config object changes + * @param pattern The pattern to match against + */ + subscribeConfig(pattern: string, callback: EmptyCallback): void; + + /** + * Unsubscribe from config object changes + * @param pattern The pattern to match against + */ + unsubscribeConfig(pattern: string, callback: EmptyCallback): void; + + /** + * Writes a binary state into Redis + * @param id The id of the state + * @param data The data to be written + * @param callback Is called when the operation has finished (successfully or not) + */ + setBinaryState(id: string, data: Buffer, callback: SetStateCallback): void; + + /** + * Reads a binary state from Redis + * @param id The id of the state + * @param callback Is called when the operation has finished (successfully or not) + */ + getBinaryState(id: string, callback: GetBinaryStateCallback): void; + + /** + * Deletes a binary state from Redis + * @param id The id of the state to be deleted + * @param callback Is called when the operation has finished (successfully or not) + */ + delBinaryState(id: string, callback: DeleteStateCallback): void; + + /** Destructor of the class. Call this before shutting down */ + destroy(): void; + + } // end interface States + + type Session = any; // TODO: implement + + type ObjectType = "state" | "channel" | "device"; + type CommonType = "number" | "string" | "boolean" | "array" | "object" | "mixed" | "file"; + + // Maybe this should extend Record, + // but the extra properties aren't defined anywhere, + // so I'd rather force the user to explicitly state + // he knows what he's doing by casting to any + interface ObjectCommon { + /** name of this object */ + name: string; + + // Icon and role aren't defined in SCHEMA.md, + // but they are being used by some adapters + /** Icon for this object */ + icon?: string; + /** role of the object */ + role?: string; + } + + interface StateCommon extends ObjectCommon { + /** Type of this state. See https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#state-commonrole for a detailed description */ + type?: CommonType; + /** minimum value */ + min?: number; + /** maximum value */ + max?: number; + /** unit of the value */ + unit?: string; + /** the default value */ + def?: any; + /** description of this state */ + desc?: string; + + /** if this state is readable */ + read: boolean; + /** if this state is writable */ + write: boolean; + /** role of the state (used in user interfaces to indicate which widget to choose) */ + role: string; + + /** + * Dictionary of possible values for this state in the form + *

+			 * {
+			 *     "internal value 1": "displayed value 1",
+			 *     "internal value 2": "displayed value 2",
+			 *     ...
+			 * }
+			 * 
+ * In old ioBroker versions, this could also be a string of the form + * "val1:text1;val2:text2" (now deprecated) + */ + states?: Record | string; + + /** ID of a helper state indicating if the handler of this state is working */ + workingID?: string; + + /** attached history information */ + history?: any; + } + interface ChannelCommon extends ObjectCommon { + /** description of this channel */ + desc?: string; + } + type OtherCommon = ObjectCommon & { + [propName: string]: any; + }; + + interface BaseObject { + /** The ID of this object */ + _id?: string; + native: Record; + enums?: Record; + type: string; // specified in the derived interfaces + common: ObjectCommon; + acl?: ObjectACL; + } + + interface StateObject extends BaseObject { + type: "state"; + common: StateCommon; + acl?: StateACL; + } + interface PartialStateObject extends Partial> { + common?: Partial; + acl?: Partial; + } + + interface ChannelObject extends BaseObject { + type: "channel"; + common: ChannelCommon; + } + interface PartialChannelObject extends Partial> { + common?: Partial; + } + + interface DeviceObject extends BaseObject { + type: "device"; + common: ObjectCommon; // TODO: any definition for device? + } + interface PartialDeviceObject extends Partial> { + common?: Partial; + } + + interface OtherObject extends BaseObject { + type: "adapter" | "config" | "enum" | "group" | "host" | "info" | "instance" | "meta" | "script" | "user"; + common: OtherCommon; + } + interface PartialOtherObject extends Partial> { + common?: Partial; + } + + type Object = StateObject | ChannelObject | DeviceObject | OtherObject; + type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject; + + /** Defines access rights for a single file */ + interface FileACL { + /** Full name of the user who owns this file, e.g. "system.user.admin" */ + owner: string; + /** Full name of the group who owns this file, e.g. "system.group.administrator" */ + ownerGroup: string; + /** Linux-type permissions defining access to this file */ + permissions: number; + } + /** Defines access rights for a single file, applied to a user or group */ + interface EvaluatedFileACL extends FileACL { + /** Whether the user may read the file */ + read: boolean; + /** Whether the user may write the file */ + write: boolean; + } + + /** Defines access rights for a single object */ + interface ObjectACL { + /** Full name of the user who owns this object, e.g. "system.user.admin" */ + owner: string; + /** Full name of the group who owns this object, e.g. "system.group.administrator" */ + ownerGroup: string; + /** Linux-type permissions defining access to this object */ + object: number; + } + /** Defines access rights for a single state object */ + interface StateACL extends ObjectACL { + /** Linux-type permissions defining access to this state */ + state: number; + } + + /** Defines access rights for a single object type */ + interface ObjectOperationPermissions { + /** Whether a user may enumerate objects of this type */ + list: boolean; + /** Whether a user may read objects of this type */ + read: boolean; + /** Whether a user may write objects of this type */ + write: boolean; + /** Whether a user may create objects of this type */ + create: boolean; + /** Whether a user may delete objects of this type */ + "delete": boolean; + } + + /** Defines the rights a user or group has to change objects */ + interface ObjectPermissions { + /** The access rights for files */ + file: ObjectOperationPermissions; + /** The access rights for objects */ + object: ObjectOperationPermissions; + /** The access rights for users/groups */ + users: ObjectOperationPermissions; + /** The access rights for states */ + state?: ObjectOperationPermissions; + } + /** Defined the complete set of access rights a user has */ + interface PermissionSet extends ObjectPermissions { + /** The name of the user this ACL is for */ + user: string; + /** The name of the groups this ACL was merged from */ + groups: string[]; + /** The access rights for certain commands */ + other: { + execute: boolean, + http: boolean, + sendto: boolean, + }; + } + + interface Permission { + /** The type of the permission */ + type: string; + /** Which kind of operation is required */ + operation: string; + } + interface ObjectOrStatePermission extends Permission { + type: "object" | "file" | "users" | "state"; + operation: "list" | "read" | "write" | "create" | "delete"; + } + interface OtherPermission extends Permission { + type: "other"; + operation: "execute" | "http" | "sendto"; + } + interface CommandsPermissions { + // TODO: Are all properties required or is a partial object ok? + getObject: ObjectOrStatePermission; + getObjects: ObjectOrStatePermission; + getObjectView: ObjectOrStatePermission; + setObject: ObjectOrStatePermission; + subscribeObjects: ObjectOrStatePermission; + unsubscribeObjects: ObjectOrStatePermission; + getStates: ObjectOrStatePermission; + getState: ObjectOrStatePermission; + setState: ObjectOrStatePermission; + getStateHistory: ObjectOrStatePermission; + subscribe: ObjectOrStatePermission; + unsubscribe: ObjectOrStatePermission; + getVersion: Permission; + httpGet: OtherPermission; + sendTo: OtherPermission; + sendToHost: OtherPermission; + readFile: ObjectOrStatePermission; + readFile64: ObjectOrStatePermission; + writeFile: ObjectOrStatePermission; + writeFile64: ObjectOrStatePermission; + unlink: ObjectOrStatePermission; + rename: ObjectOrStatePermission; + mkdir: ObjectOrStatePermission; + readDir: ObjectOrStatePermission; + chmodFile: ObjectOrStatePermission; + authEnabled: Permission; + disconnect: Permission; + listPermissions: Permission; + getUserPermissions: ObjectOrStatePermission; + } + + type UserGroup = any; // TODO find out how this looks like + // interface UserGroup { } + + /** Contains information about a user */ + interface User { + /** Which groups this user belongs to */ + groups: UserGroup[]; + /** Access rights of this user */ + acl: ObjectPermissions; + } + + /** Parameters for @link{Objects.getObjectView} */ + interface GetObjectViewParams { + /** First id to include in the return list */ + startkey: string; + /** Last id to include in the return list */ + endkey: string; + } + + /** Parameters for @link{Objects.getObjectList} */ + interface GetObjectListParams extends GetObjectViewParams { + /** Whether docs should be included in the return list */ // TODO: What are docs? + include_docs: boolean; + } + + /** Provides low-level access to the ioBroker objects db */ + interface Objects { + /** + * For a given user, returns the groups he belongs to, and his access rights + * @param user Name of the user. Has to start with "system.user." + * @param callback The callback function to be invoked with the return values + */ + getUserGroup(user: string, callback: GetUserGroupCallback): void; + + /** + * Determines the mime type for a given file extension + * @param ext File extension, including the leading dot, e.g. ".zip" + */ + getMimeType(ext: string): {mimeType: string, isBinary: boolean}; + + /** + * Writes a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param data Contents of the file + * @param options (optional) MIME type of the file (string). Or some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + writeFile(id: string, name: string, data: Buffer | string, callback: ErrorCallback): void; + writeFile(id: string, name: string, data: Buffer | string, options: string | any, callback: ErrorCallback): void; + + /** + * Reads a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + readFile(id: string, name: string, callback: ReadFileCallback): void; + readFile(id: string, name: string, options: any, callback: ReadFileCallback): void; + + /** + * Deletes a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + unlink(id: string, name: string, callback: ErrorCallback): void; + unlink(id: string, name: string, options: any, callback: ErrorCallback): void; + /** + * Deletes a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + delFile(id: string, name: string, callback: ErrorCallback): void; + delFile(id: string, name: string, options: any, callback: ErrorCallback): void; + + /** + * Finds all files and directories starting with + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File or directory name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + readDir(id: string, name: string, callback: ReadDirCallback): void; + readDir(id: string, name: string, options: any, callback: ReadDirCallback): void; + + /** + * Renames a file or directory + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param oldName Old file or directory name + * @param newName Name to rename to + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + rename(id: string, oldName: string, newName: string, callback: ErrorCallback): void; + rename(id: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; + + /** + * Creates an empty file with the given name + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + touch(id: string, name: string, callback: ErrorCallback): void; + touch(id: string, name: string, options: any, callback: ErrorCallback): void; + + /** + * Deletes all files in the root directory matching + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + rm(id: string, name: string, callback: RmCallback): void; + rm(id: string, name: string, options: any, callback: RmCallback): void; + + /** + * Creates an empty directory with the given name + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Directory name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + mkDir(id: string, name: string, callback: ErrorCallback): void; + mkDir(id: string, name: string, options: any, callback: ErrorCallback): void; + + /** + * Takes possession all files in the root directory matching + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + chownFile(id: string, name: string, callback: ChownFileCallback): void; + chownFile(id: string, name: string, options: any, callback: ChownFileCallback): void; + + /** + * Changes access rights of all files in the root directory matching + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Pattern to match against + * @param options Mode of the access change as a number or hexadecimal string + * @param callback Is called when the operation has finished (successfully or not) + */ + chmodFile(id: string, name: string, options: {mode: number | string} | Record, callback: ChownFileCallback): void; + + // not documented. enabled = true seems to disable the cache + // enableFileCache(enabled, options, callback) + + /** + * Subscribe to object changes + * @param pattern The pattern to match against + */ + subscribeConfig(pattern: string, callback: EmptyCallback): void; + subscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; + /** + * Subscribe to object changes + * @param pattern The pattern to match against + */ + subscribe(pattern: string, callback: EmptyCallback): void; + subscribe(pattern: string, options: any, callback: EmptyCallback): void; + + /** + * Unsubscribe from object changes + * @param pattern The pattern to match against + */ + unsubscribeConfig(pattern: string, callback: EmptyCallback): void; + unsubscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; + /** + * Unsubscribe from object changes + * @param pattern The pattern to match against + */ + unsubscribe(pattern: string, callback: EmptyCallback): void; + unsubscribe(pattern: string, options: any, callback: EmptyCallback): void; + + /** + * Takes possession of all objects matching + * @param pattern Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + chownObject(pattern: string, callback: ChownObjectCallback): void; + chownObject(pattern: string, options: any, callback: ChownObjectCallback): void; + + /** + * Changes access rights of all objects matching + * @param pattern Pattern to match against + * @param options Mode of the access change as a number or hexadecimal string + * @param callback Is called when the operation has finished (successfully or not) + */ + chmodObject(pattern: string, callback: ChownObjectCallback): void; + chmodObject(pattern: string, options: any, callback: ChownObjectCallback): void; + + /** + * Retrieves a copy of the object with the given ID + * @param id Id of the object to find + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObject(id: string, callback: GetObjectCallback): void; + getObject(id: string, options: any, callback: GetObjectCallback): void; + /** + * Retrieves a copy of the object with the given ID + * @param id Id of the object to find + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getConfig(id: string, callback: GetObjectCallback): void; + getConfig(id: string, options: any, callback: GetObjectCallback): void; + + /** + * Returns a list of config keys matching + * @param pattern Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; + getConfigKeys(pattern: string, options: any, callback: GetConfigKeysCallback, dontModify?: any): void; + + /** + * Returns a list of objects with the given ids + * @param keys IDs of the objects to be retrieved + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getObjects(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; + getObjects(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; + /** + * Returns a list of objects with the given ids + * @param keys IDs of the objects to be retrieved + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; + getConfigs(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; + + /** + * Creates or overwrites an object in the object db + * @param id ID of the object + * @param obj Object to store + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + setObject(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; + setObject(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; + /** + * Creates or overwrites an object in the object db + * @param id ID of the object + * @param obj Object to store + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; + setConfig(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; + + /** + * Deletes an object in the object db + * @param id ID of the object + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + delObject(id: string, callback: ErrorCallback): void; + delObject(id: string, options: any, callback: ErrorCallback): void; + /** + * Deletes an object in the object db + * @param id ID of the object + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + delConfig(id: string, callback: ErrorCallback): void; + delConfig(id: string, options: any, callback: ErrorCallback): void; + + /** + * Returns a list of objects with id between params.startkey and params.endkey + * @param params Parameters determining the objects included in the return list. Null to include all objects + * @param options (optional) If the returned list should be sorted. And some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObjectList(params: GetObjectListParams | null, callback: GetObjectListCallback): void; + getObjectList(params: GetObjectListParams | null, options: { sorted?: boolean } | Record, callback: GetObjectListCallback): void; + + /** + * Query a predefined object view (similar to SQL stored procedures) and return the results + * For a detailed description refer to https://github.com/ioBroker/ioBroker/wiki/Adapter-Development-Documentation#object-fields + * or http://guide.couchdb.org/editions/1/en/views.html + * @param design The namespace of the object view, as defined in io-package.json. Usually the adapter name, e.g. "hm-rpc" + * @param search The name of the object view. + * @param params Parameters to additionally filter out objects from the return list. Null to include all objects + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObjectView(design: string, search: string, params: GetObjectViewParams | null, callback: GetObjectViewCallback): void; + getObjectView(design: string, search: string, params: GetObjectViewParams | null, options: any, callback: GetObjectViewCallback): void; + + /** + * Extends an object in the object db with new properties + * @param id ID of the object + * @param obj Object to extend the original one with. May be just parts of an object. + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + extendObject(id: string, obj: PartialObject, callback: ExtendObjectCallback): void; + extendObject(id: string, obj: PartialObject, options: any, callback: ExtendObjectCallback): void; + + /** + * Finds an object by ID or name. If multiple objects were found, return the first one + * @param idOrName ID or name of the object + * @param type If != null, only return an object with a common.type equal to this + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + findObject(idOrName: string, type: CommonType | null, callback: FindObjectCallback): void; + findObject(idOrName: string, type: CommonType | null, options: any, callback: FindObjectCallback): void; + + // I'd rather not document a function with the name "destroyDB" + + /** Destructor of the class. Call this before shutting down. */ + destroy(): void; + + } // end interface Objects + + type LogLevel = "silly" | "debug" | "info" | "warn" | "error"; + interface Logger { + /** log message with silly level */ + silly(message: string): void; + /** log message with debug level */ + debug(message: string): void; + /** log message with info level (default output level for all adapters) */ + info(message: string): void; + /** log message with warning severity */ + warn(message: string): void; + /** log message with error severity */ + error(message: string): void; + + /** Verbosity of the log output */ + level: LogLevel; + } + + interface Certificates { + /** private key file */ + key: string | Buffer; + /** public certificate */ + cert: string | Buffer; + /** chained CA certificates */ + ca: (string | Buffer)[]; + } + + /** Callback information for a passed message */ + interface MessageCallbackInfo { + /** The original message payload */ + message: string | object; + /** ID of this callback */ + id: number; + // ??? + ack: boolean; + /** Timestamp of this message */ + time: number; + } + type MessageCallback = (result?: any) => void; + + /** A message being passed between adapter instances */ + interface Message { + /** The command to be executed */ + command: string; + /** The message payload */ + message: string | object; + /** The source of this message */ + from: string; + /** ID of this message */ + _id: number; + /** Callback information. This is set when the source expects a response */ + callback: MessageCallbackInfo; + } + + type Log = any; // TODO: define this https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/states/statesInMemServer.js#L873 + + type EnumList = string | string[]; + + type Enum = any; // TODO: implement this + + interface DirectoryEntry { + file: string; + stats: fs.Stats; + isDir: boolean; + acl: any; // access control list object + modifiedAt: number; + createdAt: number; + } + + interface GetHistoryOptions { + instance?: string; + start?: number; + end?: number; + step?: number; + count?: number; + from?: boolean; + ack?: boolean; + q?: boolean; + addID?: boolean; + limit?: number; + ignoreNull: boolean; + sessionId?: any; + aggregate?: "minmax" | "min" | "max" | "average" | "total" | "count" | "none"; + } + + interface AdapterOptions { + /** The name of the adapter */ + name: string; + + /** path to adapter */ + dirname?: string; + + /** if the global system config should be included in the created object. Default: false */ + systemConfig?: boolean; + + /** provide alternative global configuration for the adapter. Default: null */ + config?: any; + + /** instance of the created adapter. Default: null */ + instance?: number; + + /** If the adapter needs access to the formatDate function to format dates according to the global settings. Default: false */ + useFormatDate?: boolean; + + /** If the adapter collects logs from all adapters (experts only). Default: false */ + logTransporter?: boolean; + + /** Handler for changes of subscribed objects */ + objectChange?: ObjectChangeHandler; + /** Handler for received adapter messages. Can only be used if messagebox in io-package.json is set to true. */ + message?: MessageHandler; + /** Handler for changes of subscribed states */ + stateChange?: StateChangeHandler; + /** Will be called when the adapter is intialized */ + ready?: () => void; + /** Will be called on adapter termination */ + unload?: (callback: EmptyCallback) => void; + + /** if true, stateChange will be called with an id that has no namespace, e.g. "state" instead of "adapter.0.state". Default: false */ + noNamespace?: boolean; + } // end interface AdapterOptions + + // tslint:disable-next-line:no-empty-interface + interface AdapterConfig { + // This is a stub to be augmented in every adapter + } + + interface Adapter { + /** The name of the adapter */ + name: string; + /** The name of the host where the adapter is running */ + host: string; + /** instance number of this adapter instance */ + instance: number; + /** Namespace of adapter objects: "." */ + readonly namespace: string; + /** native part of the adapter settings */ + config: AdapterConfig; + /** common part of the adapter settings */ + common: any; + /** system part of the adapter settings */ + systemConfig?: any; + /** path to the adapter folder */ + adapterDir: string; + /** content of io-package.json */ + ioPack: any; + /** content of package.json */ + pack: any; + /** access to the logging functions */ + log: Logger; + /** adapter version */ + version: any; + states: States; + objects: Objects; + /** if the adapter is connected to the host */ + connected: boolean; + + /* =============================== + Functions defined in adapter.js + =============================== */ + + /** + * Helper function that looks for first free TCP port starting with the given one. + * @param port - The port to start with + * @param callback - gets called when a free port is found + */ + getPort(port: number, callback: (port: number) => void): void; + + /** Stops the adapter. Note: Is not always defined. */ + stop?: () => void; + + // ============================== + // GENERAL + + /** Validates username and password */ + checkPassword(user: string, password: string, callback: (result: boolean) => void): void; + checkPassword(user: string, password: string, options: any, callback: (result: boolean) => void): void; + /** Sets a new password for the given user */ + setPassword(user: string, password: string, options?: any, callback?: (err?: any) => void): void; + /** Checks if a user exists and is in the given group. */ + checkGroup(user: string, group: string, callback: (result: boolean) => void): void; + checkGroup(user: string, group: string, options: any, callback: (result: boolean) => void): void; + /** Determines the users permissions */ + calculatePermissions(user: string, commandsPermissions: CommandsPermissions, callback: (result: PermissionSet) => void): void; + calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: any, callback: (result: PermissionSet) => void): void; + /** Returns SSL certificates by name (private key, public cert and chained certificate) for creation of HTTPS servers */ + getCertificates(publicName: string, privateName: string, chainedName: string, callback: (err: string | null, certs?: Certificates, useLetsEncryptCert?: boolean) => void): void; + + /** + * Sends a message to a specific instance or all instances of some specific adapter. + * @param instanceName The instance to send this message to. + * If the ID of an instance is given (e.g. "admin.0"), only this instance will receive the message. + * If the name of an adapter is given (e.g. "admin"), all instances of this adapter will receive it. + * @param command (optional) Command name of the target instance. Default: "send" + * @param message The message (e.g. params) to send. + */ + sendTo(instanceName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + sendTo(instanceName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + + /** + * Sends a message to a specific host or all hosts. + */ + sendToHost(hostName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + sendToHost(hostName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + + /** Convert ID to {device: D, channel: C, state: S} */ + idToDCS(id: string): { + device: string; + channel: string; + state: string; + }; + + // ============================== + // own objects + + /** Reads an object from the object db */ + getObject(id: string, callback: GetObjectCallback): void; + getObject(id: string, options: any, callback: GetObjectCallback): void; + /** Creates or overwrites an object in the object db */ + setObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Creates an object in the object db. Existing objects are not overwritten. */ + setObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Get all states, channels and devices of this adapter */ + getAdapterObjects(callback: (objects: Record) => void): void; + /** Extend an object and create it if it might not exist */ + extendObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; + /** + * Deletes an object from the object db + * @param id - The id of the object without namespace + */ + delObject(id: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // foreign objects + + // tslint:disable:unified-signatures + /** Reads an object (which might not belong to this adapter) from the object db */ + getForeignObject(id: string, callback: GetObjectCallback): void; + getForeignObject(id: string, options: any, callback: GetObjectCallback): void; + /** Get foreign objects by pattern, by specific type and resolve their enums. */ + getForeignObjects(pattern: string, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, options: any, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, options: any, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: any, callback: GetObjectsCallback): void; + /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ + setForeignObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ + setForeignObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ + extendForeignObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; + // tslint:enable:unified-signatures + /** + * Finds an object by its ID or name + * @param type - common.type of the state + */ + findForeignObject(idOrName: string, type: string, callback: FindObjectCallback): void; + findForeignObject(idOrName: string, type: string, options: any, callback: FindObjectCallback): void; + /** + * Deletes an object (which might not belong to this adapter) from the object db + * @param id - The id of the object including namespace + */ + delForeignObject(id: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // states + /** Writes a value into the states DB. */ + setState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; + /** Writes a value into the states DB only if it has changed. */ + setStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB. */ + setForeignState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ + setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; + + /** Read a value from the states DB. */ + getState(id: string, callback: GetStateCallback): void; + getState(id: string, options: any, callback: GetStateCallback): void; + /** Read a value (which might not belong to this adapter) from the states DB. */ + getForeignState(id: string, callback: GetStateCallback): void; + getForeignState(id: string, options: any, callback: GetStateCallback): void; + /** Read all states of this adapter which match the given pattern */ + getStates(pattern: string, callback: GetStatesCallback): void; + getStates(pattern: string, options: any, callback: GetStatesCallback): void; + /** Read all states (which might not belong to this adapter) which match the given pattern */ + getForeignStates(pattern: string, callback: GetStatesCallback): void; + getForeignStates(pattern: string, options: any, callback: GetStatesCallback): void; + + /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ + delState(id: string, options?: any, callback?: ErrorCallback): void; + /** Deletes a state from the states DB, but not the associated object */ + delForeignState(id: string, options?: any, callback?: ErrorCallback): void; + + getHistory(id: string, options: GetHistoryOptions, callback: GetHistoryCallback): void; + + // MISSING: + // pushFifo and similar https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4105 + // logRedirect https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4294 + // requireLog https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4336 + // processLog https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4360 + + /** + * Writes a binary state into Redis + * @param id The id of the state + * @param binary The data to be written + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + setBinaryState(id: string, binary: Buffer, callback: SetStateCallback): void; + setBinaryState(id: string, binary: Buffer, options: any, callback: SetStateCallback): void; + /** + * Reads a binary state from Redis + * @param id The id of the state + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getBinaryState(id: string, callback: GetBinaryStateCallback): void; + getBinaryState(id: string, options: any, callback: GetBinaryStateCallback): void; + + // ============================== + // enums + + /** Returns the enum tree, filtered by the optional enum name */ + getEnum(callback: GetEnumCallback): void; + getEnum(name: string, callback: GetEnumCallback): void; + getEnum(name: string, options: any, callback: GetEnumCallback): void; + getEnums(callback: GetEnumsCallback): void; + getEnums(enumList: EnumList, callback: GetEnumsCallback): void; + getEnums(enumList: EnumList, options: any, callback: GetEnumsCallback): void; + + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // subscriptions + + /** Subscribe to changes of objects in this instance */ + subscribeObjects(pattern: string, options?: any): void; + /** Subscribe to changes of objects (which might not belong to this adapter) */ + subscribeForeignObjects(pattern: string, options?: any): void; + /** Unsubscribe from changes of objects in this instance */ + unsubscribeObjects(pattern: string, options?: any): void; + /** Unsubscribe from changes of objects (which might not belong to this adapter) */ + unsubscribeForeignObjects(pattern: string, options?: any): void; + + /** Subscribe to changes of states in this instance */ + subscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; + /** Subscribe to changes of states (which might not belong to this adapter) */ + subscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; + /** + * Subscribe from changes of states in this instance + * @param pattern - Must match the pattern used to subscribe + */ + unsubscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; + /** + * Subscribe from changes of states (which might not belong to this adapter) + * @param pattern - Must match the pattern used to subscribe + */ + unsubscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // devices and channels + + /** creates an object with type device */ + createDevice(deviceName: string, common?: any, native?: any, options?: any, callback?: SetObjectCallback): void; + /** deletes a device, its channels and states */ + deleteDevice(deviceName: string, options?: any, callback?: ErrorCallback): void; + /** gets the devices of this instance */ + + /** creates an object with type channel */ + createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; + /** deletes a channel and its states */ + deleteChannel(channelName: string, options?: any, callback?: ErrorCallback): void; + deleteChannel(parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + + /** creates a state and the corresponding object */ + createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; + /** deletes a state */ + deleteState(stateName: string, options?: any, callback?: ErrorCallback): void; + deleteState(parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + + /** + * Returns a list of all devices in this adapter instance + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getDevices(callback: GetObjectsCallback3): void; + getDevices(options: any, callback: GetObjectsCallback3): void; + + /** + * Returns a list of all channels in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getChannels(callback: GetObjectsCallback3): void; + getChannels(parentDevice: string | null, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; + /** + * Returns a list of all channels in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getChannelsOf(callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string | null, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; + + /** + * Returns a list of all states in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param parentChannel (optional) Name of the parent channel to filter the channels by + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getStatesOf(callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, parentChannel: string | null, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, parentChannel: string | null, options: any, callback: GetObjectsCallback3): void; + + // ============================== + // filesystem + + /** + * reads the content of directory from DB for given adapter and path + * @param adapter - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to direcory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + readDir(adapterName: string, path: string, callback: ReadDirCallback): void; + readDir(adapterName: string, path: string, options: any, callback: ReadDirCallback): void; + mkDir(adapterName: string, path: string, callback: ErrorCallback): void; + mkDir(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + + readFile(adapterName: string, path: string, callback: ReadFileCallback): void; + readFile(adapterName: string, path: string, options: any, callback: ReadFileCallback): void; + writeFile(adapterName: string, path: string, data: Buffer | string, callback: ErrorCallback): void; + writeFile(adapterName: string, path: string, data: Buffer | string, options: any, callback: ErrorCallback): void; // options see https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/objects/objectsInMemServer.js#L599 + + delFile(adapterName: string, path: string, callback: ErrorCallback): void; + delFile(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + unlink(adapterName: string, path: string, callback: ErrorCallback): void; + unlink(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + + rename(adapterName: string, oldName: string, newName: string, callback: ErrorCallback): void; + rename(adapterName: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; + + /** + * Changes access rights of all files in the adapter directory + * @param adapter Name of the adapter instance, e.g. "admin.0". Defaults to the namespace of this adapter. + * @param path Pattern to match the file path against + * @param options Mode of the access change as a number or hexadecimal string + * @param callback Is called when the operation has finished (successfully or not) + */ + chmodFile(adapter: string | null, path: string, options: {mode: number | string} | Record, callback: ChownFileCallback): void; + + // ============================== + // formatting + + formatValue(value: number | string, format: any): string; + formatValue(value: number | string, decimals: number, format: any): string; + formatDate(dateObj: string | Date | number, format: string): string; + formatDate(dateObj: string | Date | number, isDuration: boolean | string, format: string): string; + } // end interface Adapter + + type ObjectChangeHandler = (id: string, obj: ioBroker.Object) => void; + type StateChangeHandler = (id: string, obj: State) => void; + type MessageHandler = (obj: Message) => void; + + type EmptyCallback = () => void; + type ErrorCallback = (err?: string) => void; + // TODO: Redefine callbacks as subclass of GenericCallback + type GenericCallback = (err: string | null, result?: T) => void; + + type SetObjectCallback = (err: string | null, obj: { id: string }) => void; + type GetObjectCallback = (err: string | null, obj: ioBroker.Object) => void; + type GetEnumCallback = (err: string | null, enums: Record, requestedEnum: string) => void; + type GetEnumsCallback = ( + err: string | null, + result: { + [groupName: string]: Record, + }, + ) => void; + type GetObjectsCallback = (err: string | null, objects: Record) => void; + + type FindObjectCallback = ( + /** If an error happened, this contains the message */ + err: string | null, + /** If an object was found, this contains the ID */ + id?: string, + /** If an object was found, this contains the common.name */ + name?: string, + ) => void; + + interface GetObjectsItem { + /** The ID of this object */ + id: string; + /** A copy of the object from the DB */ + value: T; + } + // This is a version used by GetDevices/GetChannelsOf/GetStatesOf + type GetObjectsCallback3 = (err: string | null, result?: GetObjectsItem[]) => void; + + type GetStateCallback = (err: string | null, state: State) => void; + type GetStatesCallback = (err: string | null, states: Record) => void; + /** Version of the callback used by States.getStates */ + type GetStatesCallback2 = (err: string | null, states: State[]) => void; + type GetBinaryStateCallback = (err: string | null, state?: Buffer) => void; + type SetStateCallback = (err: string | null, id?: string) => void; + type SetStateChangedCallback = (err: string | null, id: string, notChanged: boolean) => void; + type DeleteStateCallback = (err: string | null, id?: string) => void; + type GetHistoryCallback = (err: string | null, result: (State & { id?: string })[], step: number, sessionId?: string) => void; + + /** Contains the return values of readDir */ + interface ReadDirResult { + /** Name of the file or directory */ + file: string; + /** File system stats */ + stats: fs.Stats; + /** Whether this is a directory or a file */ + isDir: boolean; + /** Access rights */ + acl: EvaluatedFileACL; + /** Date of last modification */ + modifiedAt: number; + /** Date of creation */ + createdAt: number; + } + type ReadDirCallback = (err: string | null, entries?: ReadDirResult[]) => void; + type ReadFileCallback = (err: string | null, file?: Buffer | string, mimeType?: string) => void; + + /** Contains the return values of chownFile */ + interface ChownFileResult { + /** The parent directory of the processed file or directory */ + path: string; + /** Name of the file or directory */ + file: string; + /** File system stats */ + stats: fs.Stats; + /** Whether this is a directory or a file */ + isDir: boolean; + /** Access rights */ + acl: FileACL; + /** Date of last modification */ + modifiedAt: number; + /** Date of creation */ + createdAt: number; + } + type ChownFileCallback = (err: string | null, entries?: ChownFileResult[], id?: string) => void; + + /** Contains the return values of rm */ + interface RmResult { + /** The parent directory of the deleted file or directory */ + path: string; + /** The name of the deleted file or directory */ + file: string; + /** Whether the deleted object was a directory or a file */ + isDir: boolean; + } + type RmCallback = (err: string | null, entries?: RmResult[]) => void; + + type GetUserGroupCallback = (objectsInstance: Objects, user: User, groups: UserGroup[], acl: ObjectPermissions) => void; + + type ChownObjectCallback = (err: string | null, list?: ioBroker.Object[]) => void; + + type GetConfigKeysCallback = (err: string | null, list?: string[]) => void; + // this is a version of the callback used by Objects.getObjects + type GetObjectsCallback2 = (err: string | null, objects?: (ioBroker.Object | { err: string })[]) => void; + + interface GetObjectViewItem { + /** The ID of this object */ + id: string; + /** A copy of the object from the DB or some aggregation result */ + value: ioBroker.Object | any; + } + type GetObjectViewCallback = (err: string | null, result?: { rows: GetObjectViewItem[] }) => void; + + interface GetObjectListItem extends GetObjectViewItem { + /** A copy of the object */ + value: ioBroker.Object; + /** The same as @link{value} */ + doc: ioBroker.Object; + } + type GetObjectListCallback = (err: string | null, result?: { rows: GetObjectListItem[] }) => void; + + type ExtendObjectCallback = (err: string | null, result?: {id: string, value: ioBroker.Object}, id?: string ) => void; + + type GetSessionCallback = (session: Session) => void; + + } // end namespace ioBroker +} // end declare global diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/iobroker/tsconfig.json b/types/iobroker/tsconfig.json new file mode 100644 index 0000000000..3388e650ec --- /dev/null +++ b/types/iobroker/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "iobroker-tests.ts" + ] +} diff --git a/types/iobroker/tslint.json b/types/iobroker/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/iobroker/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From ef89cb895e589686e2f6f0efee1fdf7ed73f034b Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Thu, 15 Nov 2018 10:58:26 +0100 Subject: [PATCH 109/174] Fix lint errors --- types/iobroker/index.d.ts | 2769 +++++++++++++++--------------- types/iobroker/iobroker-tests.ts | 5 + types/iobroker/tsconfig.json | 1 + types/iobroker/tslint.json | 9 +- 4 files changed, 1401 insertions(+), 1383 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index fab5a5a107..baa8424d9b 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -1,1387 +1,1392 @@ +// Ambient type definitions for adapters for ioBroker +// Note: This is not the definition for the package `iobroker`, +// which is just an installer, not a library. +// The definitions are based on ioBroker.js-controller v1.4.2 +// Project: https://github.com/ioBroker/ioBroker +// Definitions by: AlCalzone +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + /// -import fs = require("fs"); +import * as fs from "fs"; // tslint:disable:no-namespace declare global { - namespace ioBroker { - - enum StateQuality { - good = 0x00, // or undefined or null - bad = 0x01, - general_problem = 0x01, - general_device_problem = 0x41, - general_sensor_problem = 0x81, - device_not_connected = 0x42, - sensor_not_connected = 0x82, - device_reports_error = 0x44, - sensor_reports_error = 0x84, - } - - interface State { - /** The value of the state. */ - val: any; - - /** Direction flag: false for desired value and true for actual value. Default: false. */ - ack: boolean; - - /** Unix timestamp. Default: current time */ - ts: number; - - /** Unix timestamp of the last time the value changed */ - lc: number; - - /** Name of the adapter instance which set the value, e.g. "system.adapter.web.0" */ - from: string; - - /** Optional time in seconds after which the state is reset to null */ - expire?: number; - - /** Optional quality of the state value */ - q?: StateQuality; - - /** Optional comment */ - c?: string; - } - - /** Provides low-level access to the ioBroker states DB */ - interface States { - - /** - * Returns a list of states with the given ids - * @param keys IDs of the states to be retrieved - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getStates(keys: string[], callback: GetStatesCallback2, dontModify?: any): void; - - /** - * Returns the state with the given id - * @param id ID of the state to be retrieved - * @param callback Is called when the operation has finished (successfully or not) - */ - getState(id: string, callback: GetStateCallback): void; - - /** - * Stores a state in the db - * @param id ID of the state to be stored - * @param state The state to be stored in the db - * @param callback Is called when the operation has finished (successfully or not) - */ - setState(id: string, state?: string | number | boolean | State | Partial, callback?: SetStateCallback): void; - - /** - * Updates a state in memory without triggering a save - * @param id ID of the state to be stored - * @param state The state to be updated - * @param callback Is called when the operation has finished (successfully or not) - */ - setRawState(id: string, state: State, callback?: SetStateCallback): void; - - /** - * Deletes a state - * @param id ID of the state to be stored - * @param callback Is called when the operation has finished (successfully or not) - */ - delState(id: string, callback: DeleteStateCallback): void; - - /** - * Retrieves all ids of states matching @link{pattern} - * @param pattern The pattern to match against - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; - - /** - * Subscribe to changes of all states matching @link{pattern} - * @param pattern The pattern to match against - * @param callback Is called when the operation has finished (successfully or not) - */ - subscribe(pattern: string, cb: EmptyCallback): void; - /** - * Unsubscribe from changes of all states matching @link{pattern} - * @param pattern The pattern to match against - * @param callback Is called when the operation has finished (successfully or not) - */ - unsubscribe(pattern: string, cb: EmptyCallback): void; - - /** - * Register an adapter instance as subscribable. - * This means that the instance can read information about all subscriptions to its states - * and will be notified of changes. - * @param instance Adapter instance to register, e.g. "admin.0" - * @param cb Is called when the operation has finished (successfully or not) - */ - registerAdapterSubs(instance: string, cb?: (error: null, success: boolean) => void): void; - - /** - * Unregister an adapter instance as subscribable. - * @param instance Adapter instance to unregister, e.g. "admin.0" - * @param cb Is called when the operation has finished (successfully or not) - */ - unregisterAdapterSubs(instance: string, cb?: (error: null, success: boolean) => void): void; - - /** - * EDUCATED GUESS: Notify all clients about changes to an object - * @param type object type - * @param id State/object id - * @param obj The changed object - */ - publishAll(type: string, id: string, obj: Message): void; - - // TODO: Documentation for these functions is missing - pushMessage(id: string, state: Message, callback: SetStateCallback): void; - lenMessage(id: string, callback: GenericCallback): void; - getMessage(id: string, callback: GenericCallback): void; - delMessage(id: string, messageId: number, callback: ErrorCallback): void; - clearAllMessages(callback?: EmptyCallback): void; - subscribeMessage(id: string, cb: EmptyCallback): void; - unsubscribeMessage(id: string, cb: EmptyCallback): void; - - pushLog(id: string, log: Log, callback: SetStateCallback): void; - lenLog(id: string, callback: GenericCallback): void; - getLog(id: string, callback: GenericCallback): void; - delLog(id: string, logId: string, callback: ErrorCallback): void; - clearAllLogs(callback?: EmptyCallback): void; - subscribeLog(id: string, cb: EmptyCallback): void; - unsubscribeLog(id: string, cb: EmptyCallback): void; - - getSession(id: string, callback: GetSessionCallback): void; - setSession(id: string, expire: number, callback?: EmptyCallback): void; - setSession(id: string, expire: number, obj: Session, callback?: EmptyCallback): void; - destroySession(id: string, callback?: EmptyCallback): void; - - /** - * Retrieves a copy of the object with the given ID - * @param id Id of the object to find - * @param callback Is called when the operation has finished (successfully or not) - */ - getConfig(id: string, callback: GetObjectCallback): void; - - /** - * Returns a list of config keys matching - * @param pattern Pattern to match against - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; - - /** - * Returns a list of objects with the given ids - * @param keys IDs of the objects to be retrieved - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; - - /** - * Creates or overwrites a config object in the object db - * @param id ID of the object - * @param obj Object to store - * @param callback Is called when the operation has finished (successfully or not) - */ - setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; - - /** - * Deletes a config object in the object db - * @param id ID of the object - * @param callback Is called when the operation has finished (successfully or not) - */ - delConfig(id: string, callback: ErrorCallback): void; - - /** - * Subscribe to config object changes - * @param pattern The pattern to match against - */ - subscribeConfig(pattern: string, callback: EmptyCallback): void; - - /** - * Unsubscribe from config object changes - * @param pattern The pattern to match against - */ - unsubscribeConfig(pattern: string, callback: EmptyCallback): void; - - /** - * Writes a binary state into Redis - * @param id The id of the state - * @param data The data to be written - * @param callback Is called when the operation has finished (successfully or not) - */ - setBinaryState(id: string, data: Buffer, callback: SetStateCallback): void; - - /** - * Reads a binary state from Redis - * @param id The id of the state - * @param callback Is called when the operation has finished (successfully or not) - */ - getBinaryState(id: string, callback: GetBinaryStateCallback): void; - - /** - * Deletes a binary state from Redis - * @param id The id of the state to be deleted - * @param callback Is called when the operation has finished (successfully or not) - */ - delBinaryState(id: string, callback: DeleteStateCallback): void; - - /** Destructor of the class. Call this before shutting down */ - destroy(): void; - - } // end interface States - - type Session = any; // TODO: implement - - type ObjectType = "state" | "channel" | "device"; - type CommonType = "number" | "string" | "boolean" | "array" | "object" | "mixed" | "file"; - - // Maybe this should extend Record, - // but the extra properties aren't defined anywhere, - // so I'd rather force the user to explicitly state - // he knows what he's doing by casting to any - interface ObjectCommon { - /** name of this object */ - name: string; - - // Icon and role aren't defined in SCHEMA.md, - // but they are being used by some adapters - /** Icon for this object */ - icon?: string; - /** role of the object */ - role?: string; - } - - interface StateCommon extends ObjectCommon { - /** Type of this state. See https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#state-commonrole for a detailed description */ - type?: CommonType; - /** minimum value */ - min?: number; - /** maximum value */ - max?: number; - /** unit of the value */ - unit?: string; - /** the default value */ - def?: any; - /** description of this state */ - desc?: string; - - /** if this state is readable */ - read: boolean; - /** if this state is writable */ - write: boolean; - /** role of the state (used in user interfaces to indicate which widget to choose) */ - role: string; - - /** - * Dictionary of possible values for this state in the form - *
-			 * {
-			 *     "internal value 1": "displayed value 1",
-			 *     "internal value 2": "displayed value 2",
-			 *     ...
-			 * }
-			 * 
- * In old ioBroker versions, this could also be a string of the form - * "val1:text1;val2:text2" (now deprecated) - */ - states?: Record | string; - - /** ID of a helper state indicating if the handler of this state is working */ - workingID?: string; - - /** attached history information */ - history?: any; - } - interface ChannelCommon extends ObjectCommon { - /** description of this channel */ - desc?: string; - } - type OtherCommon = ObjectCommon & { - [propName: string]: any; - }; - - interface BaseObject { - /** The ID of this object */ - _id?: string; - native: Record; - enums?: Record; - type: string; // specified in the derived interfaces - common: ObjectCommon; - acl?: ObjectACL; - } - - interface StateObject extends BaseObject { - type: "state"; - common: StateCommon; - acl?: StateACL; - } - interface PartialStateObject extends Partial> { - common?: Partial; - acl?: Partial; - } - - interface ChannelObject extends BaseObject { - type: "channel"; - common: ChannelCommon; - } - interface PartialChannelObject extends Partial> { - common?: Partial; - } - - interface DeviceObject extends BaseObject { - type: "device"; - common: ObjectCommon; // TODO: any definition for device? - } - interface PartialDeviceObject extends Partial> { - common?: Partial; - } - - interface OtherObject extends BaseObject { - type: "adapter" | "config" | "enum" | "group" | "host" | "info" | "instance" | "meta" | "script" | "user"; - common: OtherCommon; - } - interface PartialOtherObject extends Partial> { - common?: Partial; - } - - type Object = StateObject | ChannelObject | DeviceObject | OtherObject; - type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject; - - /** Defines access rights for a single file */ - interface FileACL { - /** Full name of the user who owns this file, e.g. "system.user.admin" */ - owner: string; - /** Full name of the group who owns this file, e.g. "system.group.administrator" */ - ownerGroup: string; - /** Linux-type permissions defining access to this file */ - permissions: number; - } - /** Defines access rights for a single file, applied to a user or group */ - interface EvaluatedFileACL extends FileACL { - /** Whether the user may read the file */ - read: boolean; - /** Whether the user may write the file */ - write: boolean; - } - - /** Defines access rights for a single object */ - interface ObjectACL { - /** Full name of the user who owns this object, e.g. "system.user.admin" */ - owner: string; - /** Full name of the group who owns this object, e.g. "system.group.administrator" */ - ownerGroup: string; - /** Linux-type permissions defining access to this object */ - object: number; - } - /** Defines access rights for a single state object */ - interface StateACL extends ObjectACL { - /** Linux-type permissions defining access to this state */ - state: number; - } - - /** Defines access rights for a single object type */ - interface ObjectOperationPermissions { - /** Whether a user may enumerate objects of this type */ - list: boolean; - /** Whether a user may read objects of this type */ - read: boolean; - /** Whether a user may write objects of this type */ - write: boolean; - /** Whether a user may create objects of this type */ - create: boolean; - /** Whether a user may delete objects of this type */ - "delete": boolean; - } - - /** Defines the rights a user or group has to change objects */ - interface ObjectPermissions { - /** The access rights for files */ - file: ObjectOperationPermissions; - /** The access rights for objects */ - object: ObjectOperationPermissions; - /** The access rights for users/groups */ - users: ObjectOperationPermissions; - /** The access rights for states */ - state?: ObjectOperationPermissions; - } - /** Defined the complete set of access rights a user has */ - interface PermissionSet extends ObjectPermissions { - /** The name of the user this ACL is for */ - user: string; - /** The name of the groups this ACL was merged from */ - groups: string[]; - /** The access rights for certain commands */ - other: { - execute: boolean, - http: boolean, - sendto: boolean, - }; - } - - interface Permission { - /** The type of the permission */ - type: string; - /** Which kind of operation is required */ - operation: string; - } - interface ObjectOrStatePermission extends Permission { - type: "object" | "file" | "users" | "state"; - operation: "list" | "read" | "write" | "create" | "delete"; - } - interface OtherPermission extends Permission { - type: "other"; - operation: "execute" | "http" | "sendto"; - } - interface CommandsPermissions { - // TODO: Are all properties required or is a partial object ok? - getObject: ObjectOrStatePermission; - getObjects: ObjectOrStatePermission; - getObjectView: ObjectOrStatePermission; - setObject: ObjectOrStatePermission; - subscribeObjects: ObjectOrStatePermission; - unsubscribeObjects: ObjectOrStatePermission; - getStates: ObjectOrStatePermission; - getState: ObjectOrStatePermission; - setState: ObjectOrStatePermission; - getStateHistory: ObjectOrStatePermission; - subscribe: ObjectOrStatePermission; - unsubscribe: ObjectOrStatePermission; - getVersion: Permission; - httpGet: OtherPermission; - sendTo: OtherPermission; - sendToHost: OtherPermission; - readFile: ObjectOrStatePermission; - readFile64: ObjectOrStatePermission; - writeFile: ObjectOrStatePermission; - writeFile64: ObjectOrStatePermission; - unlink: ObjectOrStatePermission; - rename: ObjectOrStatePermission; - mkdir: ObjectOrStatePermission; - readDir: ObjectOrStatePermission; - chmodFile: ObjectOrStatePermission; - authEnabled: Permission; - disconnect: Permission; - listPermissions: Permission; - getUserPermissions: ObjectOrStatePermission; - } - - type UserGroup = any; // TODO find out how this looks like - // interface UserGroup { } - - /** Contains information about a user */ - interface User { - /** Which groups this user belongs to */ - groups: UserGroup[]; - /** Access rights of this user */ - acl: ObjectPermissions; - } - - /** Parameters for @link{Objects.getObjectView} */ - interface GetObjectViewParams { - /** First id to include in the return list */ - startkey: string; - /** Last id to include in the return list */ - endkey: string; - } - - /** Parameters for @link{Objects.getObjectList} */ - interface GetObjectListParams extends GetObjectViewParams { - /** Whether docs should be included in the return list */ // TODO: What are docs? - include_docs: boolean; - } - - /** Provides low-level access to the ioBroker objects db */ - interface Objects { - /** - * For a given user, returns the groups he belongs to, and his access rights - * @param user Name of the user. Has to start with "system.user." - * @param callback The callback function to be invoked with the return values - */ - getUserGroup(user: string, callback: GetUserGroupCallback): void; - - /** - * Determines the mime type for a given file extension - * @param ext File extension, including the leading dot, e.g. ".zip" - */ - getMimeType(ext: string): {mimeType: string, isBinary: boolean}; - - /** - * Writes a file. - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name File name - * @param data Contents of the file - * @param options (optional) MIME type of the file (string). Or some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - writeFile(id: string, name: string, data: Buffer | string, callback: ErrorCallback): void; - writeFile(id: string, name: string, data: Buffer | string, options: string | any, callback: ErrorCallback): void; - - /** - * Reads a file. - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name File name - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - readFile(id: string, name: string, callback: ReadFileCallback): void; - readFile(id: string, name: string, options: any, callback: ReadFileCallback): void; - - /** - * Deletes a file. - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name File name - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - unlink(id: string, name: string, callback: ErrorCallback): void; - unlink(id: string, name: string, options: any, callback: ErrorCallback): void; - /** - * Deletes a file. - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name File name - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - delFile(id: string, name: string, callback: ErrorCallback): void; - delFile(id: string, name: string, options: any, callback: ErrorCallback): void; - - /** - * Finds all files and directories starting with - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name File or directory name - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - readDir(id: string, name: string, callback: ReadDirCallback): void; - readDir(id: string, name: string, options: any, callback: ReadDirCallback): void; - - /** - * Renames a file or directory - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param oldName Old file or directory name - * @param newName Name to rename to - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - rename(id: string, oldName: string, newName: string, callback: ErrorCallback): void; - rename(id: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; - - /** - * Creates an empty file with the given name - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name File name - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - touch(id: string, name: string, callback: ErrorCallback): void; - touch(id: string, name: string, options: any, callback: ErrorCallback): void; - - /** - * Deletes all files in the root directory matching - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name Pattern to match against - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - rm(id: string, name: string, callback: RmCallback): void; - rm(id: string, name: string, options: any, callback: RmCallback): void; - - /** - * Creates an empty directory with the given name - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name Directory name - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - mkDir(id: string, name: string, callback: ErrorCallback): void; - mkDir(id: string, name: string, options: any, callback: ErrorCallback): void; - - /** - * Takes possession all files in the root directory matching - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name Pattern to match against - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - chownFile(id: string, name: string, callback: ChownFileCallback): void; - chownFile(id: string, name: string, options: any, callback: ChownFileCallback): void; - - /** - * Changes access rights of all files in the root directory matching - * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" - * @param name Pattern to match against - * @param options Mode of the access change as a number or hexadecimal string - * @param callback Is called when the operation has finished (successfully or not) - */ - chmodFile(id: string, name: string, options: {mode: number | string} | Record, callback: ChownFileCallback): void; - - // not documented. enabled = true seems to disable the cache - // enableFileCache(enabled, options, callback) - - /** - * Subscribe to object changes - * @param pattern The pattern to match against - */ - subscribeConfig(pattern: string, callback: EmptyCallback): void; - subscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; - /** - * Subscribe to object changes - * @param pattern The pattern to match against - */ - subscribe(pattern: string, callback: EmptyCallback): void; - subscribe(pattern: string, options: any, callback: EmptyCallback): void; - - /** - * Unsubscribe from object changes - * @param pattern The pattern to match against - */ - unsubscribeConfig(pattern: string, callback: EmptyCallback): void; - unsubscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; - /** - * Unsubscribe from object changes - * @param pattern The pattern to match against - */ - unsubscribe(pattern: string, callback: EmptyCallback): void; - unsubscribe(pattern: string, options: any, callback: EmptyCallback): void; - - /** - * Takes possession of all objects matching - * @param pattern Pattern to match against - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - chownObject(pattern: string, callback: ChownObjectCallback): void; - chownObject(pattern: string, options: any, callback: ChownObjectCallback): void; - - /** - * Changes access rights of all objects matching - * @param pattern Pattern to match against - * @param options Mode of the access change as a number or hexadecimal string - * @param callback Is called when the operation has finished (successfully or not) - */ - chmodObject(pattern: string, callback: ChownObjectCallback): void; - chmodObject(pattern: string, options: any, callback: ChownObjectCallback): void; - - /** - * Retrieves a copy of the object with the given ID - * @param id Id of the object to find - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getObject(id: string, callback: GetObjectCallback): void; - getObject(id: string, options: any, callback: GetObjectCallback): void; - /** - * Retrieves a copy of the object with the given ID - * @param id Id of the object to find - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getConfig(id: string, callback: GetObjectCallback): void; - getConfig(id: string, options: any, callback: GetObjectCallback): void; - - /** - * Returns a list of config keys matching - * @param pattern Pattern to match against - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; - getConfigKeys(pattern: string, options: any, callback: GetConfigKeysCallback, dontModify?: any): void; - - /** - * Returns a list of objects with the given ids - * @param keys IDs of the objects to be retrieved - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getObjects(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; - getObjects(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; - /** - * Returns a list of objects with the given ids - * @param keys IDs of the objects to be retrieved - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - * @param dontModify unused - */ - getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; - getConfigs(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; - - /** - * Creates or overwrites an object in the object db - * @param id ID of the object - * @param obj Object to store - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - setObject(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; - setObject(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; - /** - * Creates or overwrites an object in the object db - * @param id ID of the object - * @param obj Object to store - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; - setConfig(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; - - /** - * Deletes an object in the object db - * @param id ID of the object - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - delObject(id: string, callback: ErrorCallback): void; - delObject(id: string, options: any, callback: ErrorCallback): void; - /** - * Deletes an object in the object db - * @param id ID of the object - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - delConfig(id: string, callback: ErrorCallback): void; - delConfig(id: string, options: any, callback: ErrorCallback): void; - - /** - * Returns a list of objects with id between params.startkey and params.endkey - * @param params Parameters determining the objects included in the return list. Null to include all objects - * @param options (optional) If the returned list should be sorted. And some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getObjectList(params: GetObjectListParams | null, callback: GetObjectListCallback): void; - getObjectList(params: GetObjectListParams | null, options: { sorted?: boolean } | Record, callback: GetObjectListCallback): void; - - /** - * Query a predefined object view (similar to SQL stored procedures) and return the results - * For a detailed description refer to https://github.com/ioBroker/ioBroker/wiki/Adapter-Development-Documentation#object-fields - * or http://guide.couchdb.org/editions/1/en/views.html - * @param design The namespace of the object view, as defined in io-package.json. Usually the adapter name, e.g. "hm-rpc" - * @param search The name of the object view. - * @param params Parameters to additionally filter out objects from the return list. Null to include all objects - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getObjectView(design: string, search: string, params: GetObjectViewParams | null, callback: GetObjectViewCallback): void; - getObjectView(design: string, search: string, params: GetObjectViewParams | null, options: any, callback: GetObjectViewCallback): void; - - /** - * Extends an object in the object db with new properties - * @param id ID of the object - * @param obj Object to extend the original one with. May be just parts of an object. - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - extendObject(id: string, obj: PartialObject, callback: ExtendObjectCallback): void; - extendObject(id: string, obj: PartialObject, options: any, callback: ExtendObjectCallback): void; - - /** - * Finds an object by ID or name. If multiple objects were found, return the first one - * @param idOrName ID or name of the object - * @param type If != null, only return an object with a common.type equal to this - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - findObject(idOrName: string, type: CommonType | null, callback: FindObjectCallback): void; - findObject(idOrName: string, type: CommonType | null, options: any, callback: FindObjectCallback): void; - - // I'd rather not document a function with the name "destroyDB" - - /** Destructor of the class. Call this before shutting down. */ - destroy(): void; - - } // end interface Objects - - type LogLevel = "silly" | "debug" | "info" | "warn" | "error"; - interface Logger { - /** log message with silly level */ - silly(message: string): void; - /** log message with debug level */ - debug(message: string): void; - /** log message with info level (default output level for all adapters) */ - info(message: string): void; - /** log message with warning severity */ - warn(message: string): void; - /** log message with error severity */ - error(message: string): void; - - /** Verbosity of the log output */ - level: LogLevel; - } - - interface Certificates { - /** private key file */ - key: string | Buffer; - /** public certificate */ - cert: string | Buffer; - /** chained CA certificates */ - ca: (string | Buffer)[]; - } - - /** Callback information for a passed message */ - interface MessageCallbackInfo { - /** The original message payload */ - message: string | object; - /** ID of this callback */ - id: number; - // ??? - ack: boolean; - /** Timestamp of this message */ - time: number; - } - type MessageCallback = (result?: any) => void; - - /** A message being passed between adapter instances */ - interface Message { - /** The command to be executed */ - command: string; - /** The message payload */ - message: string | object; - /** The source of this message */ - from: string; - /** ID of this message */ - _id: number; - /** Callback information. This is set when the source expects a response */ - callback: MessageCallbackInfo; - } - - type Log = any; // TODO: define this https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/states/statesInMemServer.js#L873 - - type EnumList = string | string[]; - - type Enum = any; // TODO: implement this - - interface DirectoryEntry { - file: string; - stats: fs.Stats; - isDir: boolean; - acl: any; // access control list object - modifiedAt: number; - createdAt: number; - } - - interface GetHistoryOptions { - instance?: string; - start?: number; - end?: number; - step?: number; - count?: number; - from?: boolean; - ack?: boolean; - q?: boolean; - addID?: boolean; - limit?: number; - ignoreNull: boolean; - sessionId?: any; - aggregate?: "minmax" | "min" | "max" | "average" | "total" | "count" | "none"; - } - - interface AdapterOptions { - /** The name of the adapter */ - name: string; - - /** path to adapter */ - dirname?: string; - - /** if the global system config should be included in the created object. Default: false */ - systemConfig?: boolean; - - /** provide alternative global configuration for the adapter. Default: null */ - config?: any; - - /** instance of the created adapter. Default: null */ - instance?: number; - - /** If the adapter needs access to the formatDate function to format dates according to the global settings. Default: false */ - useFormatDate?: boolean; - - /** If the adapter collects logs from all adapters (experts only). Default: false */ - logTransporter?: boolean; - - /** Handler for changes of subscribed objects */ - objectChange?: ObjectChangeHandler; - /** Handler for received adapter messages. Can only be used if messagebox in io-package.json is set to true. */ - message?: MessageHandler; - /** Handler for changes of subscribed states */ - stateChange?: StateChangeHandler; - /** Will be called when the adapter is intialized */ - ready?: () => void; - /** Will be called on adapter termination */ - unload?: (callback: EmptyCallback) => void; - - /** if true, stateChange will be called with an id that has no namespace, e.g. "state" instead of "adapter.0.state". Default: false */ - noNamespace?: boolean; - } // end interface AdapterOptions - - // tslint:disable-next-line:no-empty-interface - interface AdapterConfig { - // This is a stub to be augmented in every adapter - } - - interface Adapter { - /** The name of the adapter */ - name: string; - /** The name of the host where the adapter is running */ - host: string; - /** instance number of this adapter instance */ - instance: number; - /** Namespace of adapter objects: "." */ - readonly namespace: string; - /** native part of the adapter settings */ - config: AdapterConfig; - /** common part of the adapter settings */ - common: any; - /** system part of the adapter settings */ - systemConfig?: any; - /** path to the adapter folder */ - adapterDir: string; - /** content of io-package.json */ - ioPack: any; - /** content of package.json */ - pack: any; - /** access to the logging functions */ - log: Logger; - /** adapter version */ - version: any; - states: States; - objects: Objects; - /** if the adapter is connected to the host */ - connected: boolean; - - /* =============================== - Functions defined in adapter.js - =============================== */ - - /** - * Helper function that looks for first free TCP port starting with the given one. - * @param port - The port to start with - * @param callback - gets called when a free port is found - */ - getPort(port: number, callback: (port: number) => void): void; - - /** Stops the adapter. Note: Is not always defined. */ - stop?: () => void; - - // ============================== - // GENERAL - - /** Validates username and password */ - checkPassword(user: string, password: string, callback: (result: boolean) => void): void; - checkPassword(user: string, password: string, options: any, callback: (result: boolean) => void): void; - /** Sets a new password for the given user */ - setPassword(user: string, password: string, options?: any, callback?: (err?: any) => void): void; - /** Checks if a user exists and is in the given group. */ - checkGroup(user: string, group: string, callback: (result: boolean) => void): void; - checkGroup(user: string, group: string, options: any, callback: (result: boolean) => void): void; - /** Determines the users permissions */ - calculatePermissions(user: string, commandsPermissions: CommandsPermissions, callback: (result: PermissionSet) => void): void; - calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: any, callback: (result: PermissionSet) => void): void; - /** Returns SSL certificates by name (private key, public cert and chained certificate) for creation of HTTPS servers */ - getCertificates(publicName: string, privateName: string, chainedName: string, callback: (err: string | null, certs?: Certificates, useLetsEncryptCert?: boolean) => void): void; - - /** - * Sends a message to a specific instance or all instances of some specific adapter. - * @param instanceName The instance to send this message to. - * If the ID of an instance is given (e.g. "admin.0"), only this instance will receive the message. - * If the name of an adapter is given (e.g. "admin"), all instances of this adapter will receive it. - * @param command (optional) Command name of the target instance. Default: "send" - * @param message The message (e.g. params) to send. - */ - sendTo(instanceName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - sendTo(instanceName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - - /** - * Sends a message to a specific host or all hosts. - */ - sendToHost(hostName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - sendToHost(hostName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - - /** Convert ID to {device: D, channel: C, state: S} */ - idToDCS(id: string): { - device: string; - channel: string; - state: string; - }; - - // ============================== - // own objects - - /** Reads an object from the object db */ - getObject(id: string, callback: GetObjectCallback): void; - getObject(id: string, options: any, callback: GetObjectCallback): void; - /** Creates or overwrites an object in the object db */ - setObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; - /** Creates an object in the object db. Existing objects are not overwritten. */ - setObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; - /** Get all states, channels and devices of this adapter */ - getAdapterObjects(callback: (objects: Record) => void): void; - /** Extend an object and create it if it might not exist */ - extendObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; - /** - * Deletes an object from the object db - * @param id - The id of the object without namespace - */ - delObject(id: string, options?: any, callback?: ErrorCallback): void; - - // ============================== - // foreign objects - - // tslint:disable:unified-signatures - /** Reads an object (which might not belong to this adapter) from the object db */ - getForeignObject(id: string, callback: GetObjectCallback): void; - getForeignObject(id: string, options: any, callback: GetObjectCallback): void; - /** Get foreign objects by pattern, by specific type and resolve their enums. */ - getForeignObjects(pattern: string, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, options: any, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, type: ObjectType, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, type: ObjectType, options: any, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: any, callback: GetObjectsCallback): void; - /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ - setForeignObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; - /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ - setForeignObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; - /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ - extendForeignObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; - // tslint:enable:unified-signatures - /** - * Finds an object by its ID or name - * @param type - common.type of the state - */ - findForeignObject(idOrName: string, type: string, callback: FindObjectCallback): void; - findForeignObject(idOrName: string, type: string, options: any, callback: FindObjectCallback): void; - /** - * Deletes an object (which might not belong to this adapter) from the object db - * @param id - The id of the object including namespace - */ - delForeignObject(id: string, options?: any, callback?: ErrorCallback): void; - - // ============================== - // states - /** Writes a value into the states DB. */ - setState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; - /** Writes a value into the states DB only if it has changed. */ - setStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; - /** Writes a value (which might not belong to this adapter) into the states DB. */ - setForeignState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; - /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ - setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; - - /** Read a value from the states DB. */ - getState(id: string, callback: GetStateCallback): void; - getState(id: string, options: any, callback: GetStateCallback): void; - /** Read a value (which might not belong to this adapter) from the states DB. */ - getForeignState(id: string, callback: GetStateCallback): void; - getForeignState(id: string, options: any, callback: GetStateCallback): void; - /** Read all states of this adapter which match the given pattern */ - getStates(pattern: string, callback: GetStatesCallback): void; - getStates(pattern: string, options: any, callback: GetStatesCallback): void; - /** Read all states (which might not belong to this adapter) which match the given pattern */ - getForeignStates(pattern: string, callback: GetStatesCallback): void; - getForeignStates(pattern: string, options: any, callback: GetStatesCallback): void; - - /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ - delState(id: string, options?: any, callback?: ErrorCallback): void; - /** Deletes a state from the states DB, but not the associated object */ - delForeignState(id: string, options?: any, callback?: ErrorCallback): void; - - getHistory(id: string, options: GetHistoryOptions, callback: GetHistoryCallback): void; - - // MISSING: - // pushFifo and similar https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4105 - // logRedirect https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4294 - // requireLog https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4336 - // processLog https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4360 - - /** - * Writes a binary state into Redis - * @param id The id of the state - * @param binary The data to be written - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - setBinaryState(id: string, binary: Buffer, callback: SetStateCallback): void; - setBinaryState(id: string, binary: Buffer, options: any, callback: SetStateCallback): void; - /** - * Reads a binary state from Redis - * @param id The id of the state - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getBinaryState(id: string, callback: GetBinaryStateCallback): void; - getBinaryState(id: string, options: any, callback: GetBinaryStateCallback): void; - - // ============================== - // enums - - /** Returns the enum tree, filtered by the optional enum name */ - getEnum(callback: GetEnumCallback): void; - getEnum(name: string, callback: GetEnumCallback): void; - getEnum(name: string, options: any, callback: GetEnumCallback): void; - getEnums(callback: GetEnumsCallback): void; - getEnums(enumList: EnumList, callback: GetEnumsCallback): void; - getEnums(enumList: EnumList, options: any, callback: GetEnumsCallback): void; - - addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; - deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; - - addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; - deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; - - // ============================== - // subscriptions - - /** Subscribe to changes of objects in this instance */ - subscribeObjects(pattern: string, options?: any): void; - /** Subscribe to changes of objects (which might not belong to this adapter) */ - subscribeForeignObjects(pattern: string, options?: any): void; - /** Unsubscribe from changes of objects in this instance */ - unsubscribeObjects(pattern: string, options?: any): void; - /** Unsubscribe from changes of objects (which might not belong to this adapter) */ - unsubscribeForeignObjects(pattern: string, options?: any): void; - - /** Subscribe to changes of states in this instance */ - subscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; - /** Subscribe to changes of states (which might not belong to this adapter) */ - subscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; - /** - * Subscribe from changes of states in this instance - * @param pattern - Must match the pattern used to subscribe - */ - unsubscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; - /** - * Subscribe from changes of states (which might not belong to this adapter) - * @param pattern - Must match the pattern used to subscribe - */ - unsubscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; - - // ============================== - // devices and channels - - /** creates an object with type device */ - createDevice(deviceName: string, common?: any, native?: any, options?: any, callback?: SetObjectCallback): void; - /** deletes a device, its channels and states */ - deleteDevice(deviceName: string, options?: any, callback?: ErrorCallback): void; - /** gets the devices of this instance */ - - /** creates an object with type channel */ - createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; - /** deletes a channel and its states */ - deleteChannel(channelName: string, options?: any, callback?: ErrorCallback): void; - deleteChannel(parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; - - /** creates a state and the corresponding object */ - createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; - /** deletes a state */ - deleteState(stateName: string, options?: any, callback?: ErrorCallback): void; - deleteState(parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; - deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; - - /** - * Returns a list of all devices in this adapter instance - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getDevices(callback: GetObjectsCallback3): void; - getDevices(options: any, callback: GetObjectsCallback3): void; - - /** - * Returns a list of all channels in this adapter instance - * @param parentDevice (optional) Name of the parent device to filter the channels by - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getChannels(callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; - /** - * Returns a list of all channels in this adapter instance - * @param parentDevice (optional) Name of the parent device to filter the channels by - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getChannelsOf(callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; - - /** - * Returns a list of all states in this adapter instance - * @param parentDevice (optional) Name of the parent device to filter the channels by - * @param parentChannel (optional) Name of the parent channel to filter the channels by - * @param options (optional) Some internal options. - * @param callback Is called when the operation has finished (successfully or not) - */ - getStatesOf(callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, options: any, callback: GetObjectsCallback3): void; - - // ============================== - // filesystem - - /** - * reads the content of directory from DB for given adapter and path - * @param adapter - adapter name. If adapter name is null, default will be the name of the current adapter. - * @param path - path to direcory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". - */ - readDir(adapterName: string, path: string, callback: ReadDirCallback): void; - readDir(adapterName: string, path: string, options: any, callback: ReadDirCallback): void; - mkDir(adapterName: string, path: string, callback: ErrorCallback): void; - mkDir(adapterName: string, path: string, options: any, callback: ErrorCallback): void; - - readFile(adapterName: string, path: string, callback: ReadFileCallback): void; - readFile(adapterName: string, path: string, options: any, callback: ReadFileCallback): void; - writeFile(adapterName: string, path: string, data: Buffer | string, callback: ErrorCallback): void; - writeFile(adapterName: string, path: string, data: Buffer | string, options: any, callback: ErrorCallback): void; // options see https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/objects/objectsInMemServer.js#L599 - - delFile(adapterName: string, path: string, callback: ErrorCallback): void; - delFile(adapterName: string, path: string, options: any, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, options: any, callback: ErrorCallback): void; - - rename(adapterName: string, oldName: string, newName: string, callback: ErrorCallback): void; - rename(adapterName: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; - - /** - * Changes access rights of all files in the adapter directory - * @param adapter Name of the adapter instance, e.g. "admin.0". Defaults to the namespace of this adapter. - * @param path Pattern to match the file path against - * @param options Mode of the access change as a number or hexadecimal string - * @param callback Is called when the operation has finished (successfully or not) - */ - chmodFile(adapter: string | null, path: string, options: {mode: number | string} | Record, callback: ChownFileCallback): void; - - // ============================== - // formatting - - formatValue(value: number | string, format: any): string; - formatValue(value: number | string, decimals: number, format: any): string; - formatDate(dateObj: string | Date | number, format: string): string; - formatDate(dateObj: string | Date | number, isDuration: boolean | string, format: string): string; - } // end interface Adapter - - type ObjectChangeHandler = (id: string, obj: ioBroker.Object) => void; - type StateChangeHandler = (id: string, obj: State) => void; - type MessageHandler = (obj: Message) => void; - - type EmptyCallback = () => void; - type ErrorCallback = (err?: string) => void; - // TODO: Redefine callbacks as subclass of GenericCallback - type GenericCallback = (err: string | null, result?: T) => void; - - type SetObjectCallback = (err: string | null, obj: { id: string }) => void; - type GetObjectCallback = (err: string | null, obj: ioBroker.Object) => void; - type GetEnumCallback = (err: string | null, enums: Record, requestedEnum: string) => void; - type GetEnumsCallback = ( - err: string | null, - result: { - [groupName: string]: Record, - }, - ) => void; - type GetObjectsCallback = (err: string | null, objects: Record) => void; - - type FindObjectCallback = ( - /** If an error happened, this contains the message */ - err: string | null, - /** If an object was found, this contains the ID */ - id?: string, - /** If an object was found, this contains the common.name */ - name?: string, - ) => void; - - interface GetObjectsItem { - /** The ID of this object */ - id: string; - /** A copy of the object from the DB */ - value: T; - } - // This is a version used by GetDevices/GetChannelsOf/GetStatesOf - type GetObjectsCallback3 = (err: string | null, result?: GetObjectsItem[]) => void; - - type GetStateCallback = (err: string | null, state: State) => void; - type GetStatesCallback = (err: string | null, states: Record) => void; - /** Version of the callback used by States.getStates */ - type GetStatesCallback2 = (err: string | null, states: State[]) => void; - type GetBinaryStateCallback = (err: string | null, state?: Buffer) => void; - type SetStateCallback = (err: string | null, id?: string) => void; - type SetStateChangedCallback = (err: string | null, id: string, notChanged: boolean) => void; - type DeleteStateCallback = (err: string | null, id?: string) => void; - type GetHistoryCallback = (err: string | null, result: (State & { id?: string })[], step: number, sessionId?: string) => void; - - /** Contains the return values of readDir */ - interface ReadDirResult { - /** Name of the file or directory */ - file: string; - /** File system stats */ - stats: fs.Stats; - /** Whether this is a directory or a file */ - isDir: boolean; - /** Access rights */ - acl: EvaluatedFileACL; - /** Date of last modification */ - modifiedAt: number; - /** Date of creation */ - createdAt: number; - } - type ReadDirCallback = (err: string | null, entries?: ReadDirResult[]) => void; - type ReadFileCallback = (err: string | null, file?: Buffer | string, mimeType?: string) => void; - - /** Contains the return values of chownFile */ - interface ChownFileResult { - /** The parent directory of the processed file or directory */ - path: string; - /** Name of the file or directory */ - file: string; - /** File system stats */ - stats: fs.Stats; - /** Whether this is a directory or a file */ - isDir: boolean; - /** Access rights */ - acl: FileACL; - /** Date of last modification */ - modifiedAt: number; - /** Date of creation */ - createdAt: number; - } - type ChownFileCallback = (err: string | null, entries?: ChownFileResult[], id?: string) => void; - - /** Contains the return values of rm */ - interface RmResult { - /** The parent directory of the deleted file or directory */ - path: string; - /** The name of the deleted file or directory */ - file: string; - /** Whether the deleted object was a directory or a file */ - isDir: boolean; - } - type RmCallback = (err: string | null, entries?: RmResult[]) => void; - - type GetUserGroupCallback = (objectsInstance: Objects, user: User, groups: UserGroup[], acl: ObjectPermissions) => void; - - type ChownObjectCallback = (err: string | null, list?: ioBroker.Object[]) => void; - - type GetConfigKeysCallback = (err: string | null, list?: string[]) => void; - // this is a version of the callback used by Objects.getObjects - type GetObjectsCallback2 = (err: string | null, objects?: (ioBroker.Object | { err: string })[]) => void; - - interface GetObjectViewItem { - /** The ID of this object */ - id: string; - /** A copy of the object from the DB or some aggregation result */ - value: ioBroker.Object | any; - } - type GetObjectViewCallback = (err: string | null, result?: { rows: GetObjectViewItem[] }) => void; - - interface GetObjectListItem extends GetObjectViewItem { - /** A copy of the object */ - value: ioBroker.Object; - /** The same as @link{value} */ - doc: ioBroker.Object; - } - type GetObjectListCallback = (err: string | null, result?: { rows: GetObjectListItem[] }) => void; - - type ExtendObjectCallback = (err: string | null, result?: {id: string, value: ioBroker.Object}, id?: string ) => void; - - type GetSessionCallback = (session: Session) => void; - - } // end namespace ioBroker + namespace ioBroker { + enum StateQuality { + good = 0x00, // or undefined or null + bad = 0x01, + general_problem = 0x01, + general_device_problem = 0x41, + general_sensor_problem = 0x81, + device_not_connected = 0x42, + sensor_not_connected = 0x82, + device_reports_error = 0x44, + sensor_reports_error = 0x84, + } + + interface State { + /** The value of the state. */ + val: any; + + /** Direction flag: false for desired value and true for actual value. Default: false. */ + ack: boolean; + + /** Unix timestamp. Default: current time */ + ts: number; + + /** Unix timestamp of the last time the value changed */ + lc: number; + + /** Name of the adapter instance which set the value, e.g. "system.adapter.web.0" */ + from: string; + + /** Optional time in seconds after which the state is reset to null */ + expire?: number; + + /** Optional quality of the state value */ + q?: StateQuality; + + /** Optional comment */ + c?: string; + } + + /** Provides low-level access to the ioBroker states DB */ + interface States { + /** + * Returns a list of states with the given ids + * @param keys IDs of the states to be retrieved + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getStates(keys: string[], callback: GetStatesCallback2, dontModify?: any): void; + + /** + * Returns the state with the given id + * @param id ID of the state to be retrieved + * @param callback Is called when the operation has finished (successfully or not) + */ + getState(id: string, callback: GetStateCallback): void; + + /** + * Stores a state in the db + * @param id ID of the state to be stored + * @param state The state to be stored in the db + * @param callback Is called when the operation has finished (successfully or not) + */ + setState(id: string, state?: string | number | boolean | State | Partial, callback?: SetStateCallback): void; + + /** + * Updates a state in memory without triggering a save + * @param id ID of the state to be stored + * @param state The state to be updated + * @param callback Is called when the operation has finished (successfully or not) + */ + setRawState(id: string, state: State, callback?: SetStateCallback): void; + + /** + * Deletes a state + * @param id ID of the state to be stored + * @param callback Is called when the operation has finished (successfully or not) + */ + delState(id: string, callback: DeleteStateCallback): void; + + /** + * Retrieves all ids of states matching @link{pattern} + * @param pattern The pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; + + /** + * Subscribe to changes of all states matching @link{pattern} + * @param pattern The pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + */ + subscribe(pattern: string, cb: EmptyCallback): void; + /** + * Unsubscribe from changes of all states matching @link{pattern} + * @param pattern The pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + */ + unsubscribe(pattern: string, cb: EmptyCallback): void; + + /** + * Register an adapter instance as subscribable. + * This means that the instance can read information about all subscriptions to its states + * and will be notified of changes. + * @param instance Adapter instance to register, e.g. "admin.0" + * @param cb Is called when the operation has finished (successfully or not) + */ + registerAdapterSubs(instance: string, cb?: (error: null, success: boolean) => void): void; + + /** + * Unregister an adapter instance as subscribable. + * @param instance Adapter instance to unregister, e.g. "admin.0" + * @param cb Is called when the operation has finished (successfully or not) + */ + unregisterAdapterSubs(instance: string, cb?: (error: null, success: boolean) => void): void; + + /** + * EDUCATED GUESS: Notify all clients about changes to an object + * @param type object type + * @param id State/object id + * @param obj The changed object + */ + publishAll(type: string, id: string, obj: Message): void; + + // TODO: Documentation for these functions is missing + pushMessage(id: string, state: Message, callback: SetStateCallback): void; + lenMessage(id: string, callback: GenericCallback): void; + getMessage(id: string, callback: GenericCallback): void; + delMessage(id: string, messageId: number, callback: ErrorCallback): void; + clearAllMessages(callback?: EmptyCallback): void; + subscribeMessage(id: string, cb: EmptyCallback): void; + unsubscribeMessage(id: string, cb: EmptyCallback): void; + + pushLog(id: string, log: Log, callback: SetStateCallback): void; + lenLog(id: string, callback: GenericCallback): void; + getLog(id: string, callback: GenericCallback): void; + delLog(id: string, logId: string, callback: ErrorCallback): void; + clearAllLogs(callback?: EmptyCallback): void; + subscribeLog(id: string, cb: EmptyCallback): void; + unsubscribeLog(id: string, cb: EmptyCallback): void; + + getSession(id: string, callback: GetSessionCallback): void; + setSession(id: string, expire: number, callback?: EmptyCallback): void; + setSession(id: string, expire: number, obj: Session, callback?: EmptyCallback): void; + destroySession(id: string, callback?: EmptyCallback): void; + + /** + * Retrieves a copy of the object with the given ID + * @param id Id of the object to find + * @param callback Is called when the operation has finished (successfully or not) + */ + getConfig(id: string, callback: GetObjectCallback): void; + + /** + * Returns a list of config keys matching + * @param pattern Pattern to match against + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; + + /** + * Returns a list of objects with the given ids + * @param keys IDs of the objects to be retrieved + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; + + /** + * Creates or overwrites a config object in the object db + * @param id ID of the object + * @param obj Object to store + * @param callback Is called when the operation has finished (successfully or not) + */ + setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; + + /** + * Deletes a config object in the object db + * @param id ID of the object + * @param callback Is called when the operation has finished (successfully or not) + */ + delConfig(id: string, callback: ErrorCallback): void; + + /** + * Subscribe to config object changes + * @param pattern The pattern to match against + */ + subscribeConfig(pattern: string, callback: EmptyCallback): void; + + /** + * Unsubscribe from config object changes + * @param pattern The pattern to match against + */ + unsubscribeConfig(pattern: string, callback: EmptyCallback): void; + + /** + * Writes a binary state into Redis + * @param id The id of the state + * @param data The data to be written + * @param callback Is called when the operation has finished (successfully or not) + */ + setBinaryState(id: string, data: Buffer, callback: SetStateCallback): void; + + /** + * Reads a binary state from Redis + * @param id The id of the state + * @param callback Is called when the operation has finished (successfully or not) + */ + getBinaryState(id: string, callback: GetBinaryStateCallback): void; + + /** + * Deletes a binary state from Redis + * @param id The id of the state to be deleted + * @param callback Is called when the operation has finished (successfully or not) + */ + delBinaryState(id: string, callback: DeleteStateCallback): void; + + /** Destructor of the class. Call this before shutting down */ + destroy(): void; + } // end interface States + + type Session = any; // TODO: implement + + type ObjectType = "state" | "channel" | "device"; + type CommonType = "number" | "string" | "boolean" | "array" | "object" | "mixed" | "file"; + + // Maybe this should extend Record, + // but the extra properties aren't defined anywhere, + // so I'd rather force the user to explicitly state + // he knows what he's doing by casting to any + interface ObjectCommon { + /** name of this object */ + name: string; + + // Icon and role aren't defined in SCHEMA.md, + // but they are being used by some adapters + /** Icon for this object */ + icon?: string; + /** role of the object */ + role?: string; + } + + interface StateCommon extends ObjectCommon { + /** Type of this state. See https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#state-commonrole for a detailed description */ + type?: CommonType; + /** minimum value */ + min?: number; + /** maximum value */ + max?: number; + /** unit of the value */ + unit?: string; + /** the default value */ + def?: any; + /** description of this state */ + desc?: string; + + /** if this state is readable */ + read: boolean; + /** if this state is writable */ + write: boolean; + /** role of the state (used in user interfaces to indicate which widget to choose) */ + role: string; + + /** + * Dictionary of possible values for this state in the form + *
+             * {
+             *     "internal value 1": "displayed value 1",
+             *     "internal value 2": "displayed value 2",
+             *     ...
+             * }
+             * 
+ * In old ioBroker versions, this could also be a string of the form + * "val1:text1;val2:text2" (now deprecated) + */ + states?: Record | string; + + /** ID of a helper state indicating if the handler of this state is working */ + workingID?: string; + + /** attached history information */ + history?: any; + } + interface ChannelCommon extends ObjectCommon { + /** description of this channel */ + desc?: string; + } + type OtherCommon = ObjectCommon & { + [propName: string]: any; + }; + + interface BaseObject { + /** The ID of this object */ + _id?: string; + native: Record; + enums?: Record; + type: string; // specified in the derived interfaces + common: ObjectCommon; + acl?: ObjectACL; + } + + interface StateObject extends BaseObject { + type: "state"; + common: StateCommon; + acl?: StateACL; + } + interface PartialStateObject extends Partial> { + common?: Partial; + acl?: Partial; + } + + interface ChannelObject extends BaseObject { + type: "channel"; + common: ChannelCommon; + } + interface PartialChannelObject extends Partial> { + common?: Partial; + } + + interface DeviceObject extends BaseObject { + type: "device"; + common: ObjectCommon; // TODO: any definition for device? + } + interface PartialDeviceObject extends Partial> { + common?: Partial; + } + + interface OtherObject extends BaseObject { + type: "adapter" | "config" | "enum" | "group" | "host" | "info" | "instance" | "meta" | "script" | "user"; + common: OtherCommon; + } + interface PartialOtherObject extends Partial> { + common?: Partial; + } + + type Object = StateObject | ChannelObject | DeviceObject | OtherObject; + type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject; + + /** Defines access rights for a single file */ + interface FileACL { + /** Full name of the user who owns this file, e.g. "system.user.admin" */ + owner: string; + /** Full name of the group who owns this file, e.g. "system.group.administrator" */ + ownerGroup: string; + /** Linux-type permissions defining access to this file */ + permissions: number; + } + /** Defines access rights for a single file, applied to a user or group */ + interface EvaluatedFileACL extends FileACL { + /** Whether the user may read the file */ + read: boolean; + /** Whether the user may write the file */ + write: boolean; + } + + /** Defines access rights for a single object */ + interface ObjectACL { + /** Full name of the user who owns this object, e.g. "system.user.admin" */ + owner: string; + /** Full name of the group who owns this object, e.g. "system.group.administrator" */ + ownerGroup: string; + /** Linux-type permissions defining access to this object */ + object: number; + } + /** Defines access rights for a single state object */ + interface StateACL extends ObjectACL { + /** Linux-type permissions defining access to this state */ + state: number; + } + + /** Defines access rights for a single object type */ + interface ObjectOperationPermissions { + /** Whether a user may enumerate objects of this type */ + list: boolean; + /** Whether a user may read objects of this type */ + read: boolean; + /** Whether a user may write objects of this type */ + write: boolean; + /** Whether a user may create objects of this type */ + create: boolean; + /** Whether a user may delete objects of this type */ + "delete": boolean; + } + + /** Defines the rights a user or group has to change objects */ + interface ObjectPermissions { + /** The access rights for files */ + file: ObjectOperationPermissions; + /** The access rights for objects */ + object: ObjectOperationPermissions; + /** The access rights for users/groups */ + users: ObjectOperationPermissions; + /** The access rights for states */ + state?: ObjectOperationPermissions; + } + /** Defined the complete set of access rights a user has */ + interface PermissionSet extends ObjectPermissions { + /** The name of the user this ACL is for */ + user: string; + /** The name of the groups this ACL was merged from */ + groups: string[]; + /** The access rights for certain commands */ + other: { + execute: boolean, + http: boolean, + sendto: boolean, + }; + } + + interface Permission { + /** The type of the permission */ + type: string; + /** Which kind of operation is required */ + operation: string; + } + interface ObjectOrStatePermission extends Permission { + type: "object" | "file" | "users" | "state"; + operation: "list" | "read" | "write" | "create" | "delete"; + } + interface OtherPermission extends Permission { + type: "other"; + operation: "execute" | "http" | "sendto"; + } + interface CommandsPermissions { + // TODO: Are all properties required or is a partial object ok? + getObject: ObjectOrStatePermission; + getObjects: ObjectOrStatePermission; + getObjectView: ObjectOrStatePermission; + setObject: ObjectOrStatePermission; + subscribeObjects: ObjectOrStatePermission; + unsubscribeObjects: ObjectOrStatePermission; + getStates: ObjectOrStatePermission; + getState: ObjectOrStatePermission; + setState: ObjectOrStatePermission; + getStateHistory: ObjectOrStatePermission; + subscribe: ObjectOrStatePermission; + unsubscribe: ObjectOrStatePermission; + getVersion: Permission; + httpGet: OtherPermission; + sendTo: OtherPermission; + sendToHost: OtherPermission; + readFile: ObjectOrStatePermission; + readFile64: ObjectOrStatePermission; + writeFile: ObjectOrStatePermission; + writeFile64: ObjectOrStatePermission; + unlink: ObjectOrStatePermission; + rename: ObjectOrStatePermission; + mkdir: ObjectOrStatePermission; + readDir: ObjectOrStatePermission; + chmodFile: ObjectOrStatePermission; + authEnabled: Permission; + disconnect: Permission; + listPermissions: Permission; + getUserPermissions: ObjectOrStatePermission; + } + + type UserGroup = any; // TODO find out how this looks like + // interface UserGroup { } + + /** Contains information about a user */ + interface User { + /** Which groups this user belongs to */ + groups: UserGroup[]; + /** Access rights of this user */ + acl: ObjectPermissions; + } + + /** Parameters for @link{Objects.getObjectView} */ + interface GetObjectViewParams { + /** First id to include in the return list */ + startkey: string; + /** Last id to include in the return list */ + endkey: string; + } + + /** Parameters for @link{Objects.getObjectList} */ + interface GetObjectListParams extends GetObjectViewParams { + /** Whether docs should be included in the return list */ // TODO: What are docs? + include_docs: boolean; + } + + /** Provides low-level access to the ioBroker objects db */ + interface Objects { + /** + * For a given user, returns the groups he belongs to, and his access rights + * @param user Name of the user. Has to start with "system.user." + * @param callback The callback function to be invoked with the return values + */ + getUserGroup(user: string, callback: GetUserGroupCallback): void; + + /** + * Determines the mime type for a given file extension + * @param ext File extension, including the leading dot, e.g. ".zip" + */ + getMimeType(ext: string): { mimeType: string, isBinary: boolean }; + + /** + * Writes a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param data Contents of the file + * @param options (optional) MIME type of the file (string). Or some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + writeFile(id: string, name: string, data: Buffer | string, callback: ErrorCallback): void; + writeFile(id: string, name: string, data: Buffer | string, options: string | {}, callback: ErrorCallback): void; + + /** + * Reads a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + readFile(id: string, name: string, callback: ReadFileCallback): void; + readFile(id: string, name: string, options: any, callback: ReadFileCallback): void; + + /** + * Deletes a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + unlink(id: string, name: string, callback: ErrorCallback): void; + unlink(id: string, name: string, options: any, callback: ErrorCallback): void; + /** + * Deletes a file. + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + delFile(id: string, name: string, callback: ErrorCallback): void; + delFile(id: string, name: string, options: any, callback: ErrorCallback): void; + + /** + * Finds all files and directories starting with + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File or directory name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + readDir(id: string, name: string, callback: ReadDirCallback): void; + readDir(id: string, name: string, options: any, callback: ReadDirCallback): void; + + /** + * Renames a file or directory + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param oldName Old file or directory name + * @param newName Name to rename to + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + rename(id: string, oldName: string, newName: string, callback: ErrorCallback): void; + rename(id: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; + + /** + * Creates an empty file with the given name + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name File name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + touch(id: string, name: string, callback: ErrorCallback): void; + touch(id: string, name: string, options: any, callback: ErrorCallback): void; + + /** + * Deletes all files in the root directory matching + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + rm(id: string, name: string, callback: RmCallback): void; + rm(id: string, name: string, options: any, callback: RmCallback): void; + + /** + * Creates an empty directory with the given name + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Directory name + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + mkDir(id: string, name: string, callback: ErrorCallback): void; + mkDir(id: string, name: string, options: any, callback: ErrorCallback): void; + + /** + * Takes possession all files in the root directory matching + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + chownFile(id: string, name: string, callback: ChownFileCallback): void; + chownFile(id: string, name: string, options: any, callback: ChownFileCallback): void; + + /** + * Changes access rights of all files in the root directory matching + * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" + * @param name Pattern to match against + * @param options Mode of the access change as a number or hexadecimal string + * @param callback Is called when the operation has finished (successfully or not) + */ + chmodFile(id: string, name: string, options: { mode: number | string } | Record, callback: ChownFileCallback): void; + + // not documented. enabled = true seems to disable the cache + // enableFileCache(enabled, options, callback) + + /** + * Subscribe to object changes + * @param pattern The pattern to match against + */ + subscribeConfig(pattern: string, callback: EmptyCallback): void; + subscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; + /** + * Subscribe to object changes + * @param pattern The pattern to match against + */ + subscribe(pattern: string, callback: EmptyCallback): void; + subscribe(pattern: string, options: any, callback: EmptyCallback): void; + + /** + * Unsubscribe from object changes + * @param pattern The pattern to match against + */ + unsubscribeConfig(pattern: string, callback: EmptyCallback): void; + unsubscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; + /** + * Unsubscribe from object changes + * @param pattern The pattern to match against + */ + unsubscribe(pattern: string, callback: EmptyCallback): void; + unsubscribe(pattern: string, options: any, callback: EmptyCallback): void; + + /** + * Takes possession of all objects matching + * @param pattern Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + chownObject(pattern: string, callback: ChownObjectCallback): void; + chownObject(pattern: string, options: any, callback: ChownObjectCallback): void; + + /** + * Changes access rights of all objects matching + * @param pattern Pattern to match against + * @param options Mode of the access change as a number or hexadecimal string + * @param callback Is called when the operation has finished (successfully or not) + */ + chmodObject(pattern: string, callback: ChownObjectCallback): void; + chmodObject(pattern: string, options: any, callback: ChownObjectCallback): void; + + /** + * Retrieves a copy of the object with the given ID + * @param id Id of the object to find + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObject(id: string, callback: GetObjectCallback): void; + getObject(id: string, options: any, callback: GetObjectCallback): void; + /** + * Retrieves a copy of the object with the given ID + * @param id Id of the object to find + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getConfig(id: string, callback: GetObjectCallback): void; + getConfig(id: string, options: any, callback: GetObjectCallback): void; + + /** + * Returns a list of config keys matching + * @param pattern Pattern to match against + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; + getConfigKeys(pattern: string, options: any, callback: GetConfigKeysCallback, dontModify?: any): void; + + /** + * Returns a list of objects with the given ids + * @param keys IDs of the objects to be retrieved + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getObjects(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; + getObjects(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; + /** + * Returns a list of objects with the given ids + * @param keys IDs of the objects to be retrieved + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + * @param dontModify unused + */ + getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; + getConfigs(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; + + /** + * Creates or overwrites an object in the object db + * @param id ID of the object + * @param obj Object to store + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + setObject(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; + setObject(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; + /** + * Creates or overwrites an object in the object db + * @param id ID of the object + * @param obj Object to store + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; + setConfig(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; + + /** + * Deletes an object in the object db + * @param id ID of the object + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + delObject(id: string, callback: ErrorCallback): void; + delObject(id: string, options: any, callback: ErrorCallback): void; + /** + * Deletes an object in the object db + * @param id ID of the object + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + delConfig(id: string, callback: ErrorCallback): void; + delConfig(id: string, options: any, callback: ErrorCallback): void; + + /** + * Returns a list of objects with id between params.startkey and params.endkey + * @param params Parameters determining the objects included in the return list. Null to include all objects + * @param options (optional) If the returned list should be sorted. And some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObjectList(params: GetObjectListParams | null, callback: GetObjectListCallback): void; + getObjectList(params: GetObjectListParams | null, options: { sorted?: boolean } | Record, callback: GetObjectListCallback): void; + + /** + * Query a predefined object view (similar to SQL stored procedures) and return the results + * For a detailed description refer to https://github.com/ioBroker/ioBroker/wiki/Adapter-Development-Documentation#object-fields + * or http://guide.couchdb.org/editions/1/en/views.html + * @param design The namespace of the object view, as defined in io-package.json. Usually the adapter name, e.g. "hm-rpc" + * @param search The name of the object view. + * @param params Parameters to additionally filter out objects from the return list. Null to include all objects + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObjectView(design: string, search: string, params: GetObjectViewParams | null, callback: GetObjectViewCallback): void; + getObjectView(design: string, search: string, params: GetObjectViewParams | null, options: any, callback: GetObjectViewCallback): void; + + /** + * Extends an object in the object db with new properties + * @param id ID of the object + * @param obj Object to extend the original one with. May be just parts of an object. + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + extendObject(id: string, obj: PartialObject, callback: ExtendObjectCallback): void; + extendObject(id: string, obj: PartialObject, options: any, callback: ExtendObjectCallback): void; + + /** + * Finds an object by ID or name. If multiple objects were found, return the first one + * @param idOrName ID or name of the object + * @param type If != null, only return an object with a common.type equal to this + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + findObject(idOrName: string, type: CommonType | null, callback: FindObjectCallback): void; + findObject(idOrName: string, type: CommonType | null, options: any, callback: FindObjectCallback): void; + + // I'd rather not document a function with the name "destroyDB" + + /** Destructor of the class. Call this before shutting down. */ + destroy(): void; + } // end interface Objects + + type LogLevel = "silly" | "debug" | "info" | "warn" | "error"; + interface Logger { + /** log message with silly level */ + silly(message: string): void; + /** log message with debug level */ + debug(message: string): void; + /** log message with info level (default output level for all adapters) */ + info(message: string): void; + /** log message with warning severity */ + warn(message: string): void; + /** log message with error severity */ + error(message: string): void; + + /** Verbosity of the log output */ + level: LogLevel; + } + + interface Certificates { + /** private key file */ + key: string | Buffer; + /** public certificate */ + cert: string | Buffer; + /** chained CA certificates */ + ca: Array; + } + + /** Callback information for a passed message */ + interface MessageCallbackInfo { + /** The original message payload */ + message: string | object; + /** ID of this callback */ + id: number; + // ??? + ack: boolean; + /** Timestamp of this message */ + time: number; + } + type MessageCallback = (result?: any) => void; + + /** A message being passed between adapter instances */ + interface Message { + /** The command to be executed */ + command: string; + /** The message payload */ + message: string | object; + /** The source of this message */ + from: string; + /** ID of this message */ + _id: number; + /** Callback information. This is set when the source expects a response */ + callback: MessageCallbackInfo; + } + + type Log = any; // TODO: define this https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/states/statesInMemServer.js#L873 + + type EnumList = string | string[]; + + type Enum = any; // TODO: implement this + + interface DirectoryEntry { + file: string; + stats: fs.Stats; + isDir: boolean; + acl: any; // access control list object + modifiedAt: number; + createdAt: number; + } + + interface GetHistoryOptions { + instance?: string; + start?: number; + end?: number; + step?: number; + count?: number; + from?: boolean; + ack?: boolean; + q?: boolean; + addID?: boolean; + limit?: number; + ignoreNull: boolean; + sessionId?: any; + aggregate?: "minmax" | "min" | "max" | "average" | "total" | "count" | "none"; + } + + interface AdapterOptions { + /** The name of the adapter */ + name: string; + + /** path to adapter */ + dirname?: string; + + /** if the global system config should be included in the created object. Default: false */ + systemConfig?: boolean; + + /** provide alternative global configuration for the adapter. Default: null */ + config?: any; + + /** instance of the created adapter. Default: null */ + instance?: number; + + /** If the adapter needs access to the formatDate function to format dates according to the global settings. Default: false */ + useFormatDate?: boolean; + + /** If the adapter collects logs from all adapters (experts only). Default: false */ + logTransporter?: boolean; + + /** Handler for changes of subscribed objects */ + objectChange?: ObjectChangeHandler; + /** Handler for received adapter messages. Can only be used if messagebox in io-package.json is set to true. */ + message?: MessageHandler; + /** Handler for changes of subscribed states */ + stateChange?: StateChangeHandler; + /** Will be called when the adapter is intialized */ + ready?: () => void; + /** Will be called on adapter termination */ + unload?: (callback: EmptyCallback) => void; + + /** if true, stateChange will be called with an id that has no namespace, e.g. "state" instead of "adapter.0.state". Default: false */ + noNamespace?: boolean; + } // end interface AdapterOptions + + // tslint:disable-next-line:no-empty-interface + interface AdapterConfig { + // This is a stub to be augmented in every adapter + } + + interface Adapter { + /** The name of the adapter */ + name: string; + /** The name of the host where the adapter is running */ + host: string; + /** instance number of this adapter instance */ + instance: number; + /** Namespace of adapter objects: "." */ + readonly namespace: string; + /** native part of the adapter settings */ + config: AdapterConfig; + /** common part of the adapter settings */ + common: any; + /** system part of the adapter settings */ + systemConfig?: any; + /** path to the adapter folder */ + adapterDir: string; + /** content of io-package.json */ + ioPack: any; + /** content of package.json */ + pack: any; + /** access to the logging functions */ + log: Logger; + /** adapter version */ + version: any; + states: States; + objects: Objects; + /** if the adapter is connected to the host */ + connected: boolean; + + /* =============================== + Functions defined in adapter.js + =============================== */ + + /** + * Helper function that looks for first free TCP port starting with the given one. + * @param port - The port to start with + * @param callback - gets called when a free port is found + */ + getPort(port: number, callback: (port: number) => void): void; + + /** Stops the adapter. Note: Is not always defined. */ + stop?: () => void; + + // ============================== + // GENERAL + + /** Validates username and password */ + checkPassword(user: string, password: string, callback: (result: boolean) => void): void; + checkPassword(user: string, password: string, options: any, callback: (result: boolean) => void): void; + /** Sets a new password for the given user */ + setPassword(user: string, password: string, options?: any, callback?: (err?: any) => void): void; + /** Checks if a user exists and is in the given group. */ + checkGroup(user: string, group: string, callback: (result: boolean) => void): void; + checkGroup(user: string, group: string, options: any, callback: (result: boolean) => void): void; + /** Determines the users permissions */ + calculatePermissions(user: string, commandsPermissions: CommandsPermissions, callback: (result: PermissionSet) => void): void; + calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: any, callback: (result: PermissionSet) => void): void; + /** Returns SSL certificates by name (private key, public cert and chained certificate) for creation of HTTPS servers */ + getCertificates(publicName: string, privateName: string, chainedName: string, callback: (err: string | null, certs?: Certificates, useLetsEncryptCert?: boolean) => void): void; + + /** + * Sends a message to a specific instance or all instances of some specific adapter. + * @param instanceName The instance to send this message to. + * If the ID of an instance is given (e.g. "admin.0"), only this instance will receive the message. + * If the name of an adapter is given (e.g. "admin"), all instances of this adapter will receive it. + * @param command (optional) Command name of the target instance. Default: "send" + * @param message The message (e.g. params) to send. + */ + sendTo(instanceName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + sendTo(instanceName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + + /** + * Sends a message to a specific host or all hosts. + */ + sendToHost(hostName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + sendToHost(hostName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + + /** Convert ID to {device: D, channel: C, state: S} */ + idToDCS(id: string): { + device: string; + channel: string; + state: string; + }; + + // ============================== + // own objects + + /** Reads an object from the object db */ + getObject(id: string, callback: GetObjectCallback): void; + getObject(id: string, options: any, callback: GetObjectCallback): void; + /** Creates or overwrites an object in the object db */ + setObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Creates an object in the object db. Existing objects are not overwritten. */ + setObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Get all states, channels and devices of this adapter */ + getAdapterObjects(callback: (objects: Record) => void): void; + /** Extend an object and create it if it might not exist */ + extendObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; + /** + * Deletes an object from the object db + * @param id - The id of the object without namespace + */ + delObject(id: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // foreign objects + + // tslint:disable:unified-signatures + /** Reads an object (which might not belong to this adapter) from the object db */ + getForeignObject(id: string, callback: GetObjectCallback): void; + getForeignObject(id: string, options: any, callback: GetObjectCallback): void; + /** Get foreign objects by pattern, by specific type and resolve their enums. */ + getForeignObjects(pattern: string, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, options: any, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, options: any, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: any, callback: GetObjectsCallback): void; + /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ + setForeignObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ + setForeignObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ + extendForeignObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; + // tslint:enable:unified-signatures + /** + * Finds an object by its ID or name + * @param type - common.type of the state + */ + findForeignObject(idOrName: string, type: string, callback: FindObjectCallback): void; + findForeignObject(idOrName: string, type: string, options: any, callback: FindObjectCallback): void; + /** + * Deletes an object (which might not belong to this adapter) from the object db + * @param id - The id of the object including namespace + */ + delForeignObject(id: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // states + /** Writes a value into the states DB. */ + setState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; + /** Writes a value into the states DB only if it has changed. */ + setStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB. */ + setForeignState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ + setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; + + /** Read a value from the states DB. */ + getState(id: string, callback: GetStateCallback): void; + getState(id: string, options: any, callback: GetStateCallback): void; + /** Read a value (which might not belong to this adapter) from the states DB. */ + getForeignState(id: string, callback: GetStateCallback): void; + getForeignState(id: string, options: any, callback: GetStateCallback): void; + /** Read all states of this adapter which match the given pattern */ + getStates(pattern: string, callback: GetStatesCallback): void; + getStates(pattern: string, options: any, callback: GetStatesCallback): void; + /** Read all states (which might not belong to this adapter) which match the given pattern */ + getForeignStates(pattern: string, callback: GetStatesCallback): void; + getForeignStates(pattern: string, options: any, callback: GetStatesCallback): void; + + /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ + delState(id: string, options?: any, callback?: ErrorCallback): void; + /** Deletes a state from the states DB, but not the associated object */ + delForeignState(id: string, options?: any, callback?: ErrorCallback): void; + + getHistory(id: string, options: GetHistoryOptions, callback: GetHistoryCallback): void; + + // MISSING: + // pushFifo and similar https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4105 + // logRedirect https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4294 + // requireLog https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4336 + // processLog https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4360 + + /** + * Writes a binary state into Redis + * @param id The id of the state + * @param binary The data to be written + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + setBinaryState(id: string, binary: Buffer, callback: SetStateCallback): void; + setBinaryState(id: string, binary: Buffer, options: any, callback: SetStateCallback): void; + /** + * Reads a binary state from Redis + * @param id The id of the state + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getBinaryState(id: string, callback: GetBinaryStateCallback): void; + getBinaryState(id: string, options: any, callback: GetBinaryStateCallback): void; + + // ============================== + // enums + + /** Returns the enum tree, filtered by the optional enum name */ + getEnum(callback: GetEnumCallback): void; + getEnum(name: string, callback: GetEnumCallback): void; + getEnum(name: string, options: any, callback: GetEnumCallback): void; + getEnums(callback: GetEnumsCallback): void; + getEnums(enumList: EnumList, callback: GetEnumsCallback): void; + getEnums(enumList: EnumList, options: any, callback: GetEnumsCallback): void; + + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // subscriptions + + /** Subscribe to changes of objects in this instance */ + subscribeObjects(pattern: string, options?: any): void; + /** Subscribe to changes of objects (which might not belong to this adapter) */ + subscribeForeignObjects(pattern: string, options?: any): void; + /** Unsubscribe from changes of objects in this instance */ + unsubscribeObjects(pattern: string, options?: any): void; + /** Unsubscribe from changes of objects (which might not belong to this adapter) */ + unsubscribeForeignObjects(pattern: string, options?: any): void; + + /** Subscribe to changes of states in this instance */ + subscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; + /** Subscribe to changes of states (which might not belong to this adapter) */ + subscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; + /** + * Subscribe from changes of states in this instance + * @param pattern - Must match the pattern used to subscribe + */ + unsubscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; + /** + * Subscribe from changes of states (which might not belong to this adapter) + * @param pattern - Must match the pattern used to subscribe + */ + unsubscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; + + // ============================== + // devices and channels + + /** creates an object with type device */ + createDevice(deviceName: string, common?: any, native?: any, options?: any, callback?: SetObjectCallback): void; + /** deletes a device, its channels and states */ + deleteDevice(deviceName: string, options?: any, callback?: ErrorCallback): void; + /** gets the devices of this instance */ + + /** creates an object with type channel */ + createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; + /** deletes a channel and its states */ + deleteChannel(channelName: string, options?: any, callback?: ErrorCallback): void; + deleteChannel(parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + + /** creates a state and the corresponding object */ + createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; + /** deletes a state */ + deleteState(stateName: string, options?: any, callback?: ErrorCallback): void; + deleteState(parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + + /** + * Returns a list of all devices in this adapter instance + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getDevices(callback: GetObjectsCallback3): void; + getDevices(options: any, callback: GetObjectsCallback3): void; + + /** + * Returns a list of all channels in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getChannels(callback: GetObjectsCallback3): void; + getChannels(parentDevice: string | null, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; + /** + * Returns a list of all channels in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getChannelsOf(callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string | null, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; + + /** + * Returns a list of all states in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param parentChannel (optional) Name of the parent channel to filter the channels by + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getStatesOf(callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, parentChannel: string | null, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, parentChannel: string | null, options: any, callback: GetObjectsCallback3): void; + + // ============================== + // filesystem + + /** + * reads the content of directory from DB for given adapter and path + * @param adapter - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to direcory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + readDir(adapterName: string, path: string, callback: ReadDirCallback): void; + readDir(adapterName: string, path: string, options: any, callback: ReadDirCallback): void; + mkDir(adapterName: string, path: string, callback: ErrorCallback): void; + mkDir(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + + readFile(adapterName: string, path: string, callback: ReadFileCallback): void; + readFile(adapterName: string, path: string, options: any, callback: ReadFileCallback): void; + writeFile(adapterName: string, path: string, data: Buffer | string, callback: ErrorCallback): void; + // options see https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/objects/objectsInMemServer.js#L599 + writeFile(adapterName: string, path: string, data: Buffer | string, options: any, callback: ErrorCallback): void; + + delFile(adapterName: string, path: string, callback: ErrorCallback): void; + delFile(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + unlink(adapterName: string, path: string, callback: ErrorCallback): void; + unlink(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + + rename(adapterName: string, oldName: string, newName: string, callback: ErrorCallback): void; + rename(adapterName: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; + + /** + * Changes access rights of all files in the adapter directory + * @param adapter Name of the adapter instance, e.g. "admin.0". Defaults to the namespace of this adapter. + * @param path Pattern to match the file path against + * @param options Mode of the access change as a number or hexadecimal string + * @param callback Is called when the operation has finished (successfully or not) + */ + chmodFile(adapter: string | null, path: string, options: { mode: number | string } | Record, callback: ChownFileCallback): void; + + // ============================== + // formatting + + formatValue(value: number | string, format: any): string; + formatValue(value: number | string, decimals: number, format: any): string; + formatDate(dateObj: string | Date | number, format: string): string; + formatDate(dateObj: string | Date | number, isDuration: boolean | string, format: string): string; + } // end interface Adapter + + type ObjectChangeHandler = (id: string, obj: ioBroker.Object) => void; + type StateChangeHandler = (id: string, obj: State) => void; + type MessageHandler = (obj: Message) => void; + + type EmptyCallback = () => void; + type ErrorCallback = (err?: string) => void; + // TODO: Redefine callbacks as subclass of GenericCallback + type GenericCallback = (err: string | null, result?: T) => void; + + type SetObjectCallback = (err: string | null, obj: { id: string }) => void; + type GetObjectCallback = (err: string | null, obj: ioBroker.Object) => void; + type GetEnumCallback = (err: string | null, enums: Record, requestedEnum: string) => void; + type GetEnumsCallback = ( + err: string | null, + result: { + [groupName: string]: Record, + }, + ) => void; + type GetObjectsCallback = (err: string | null, objects: Record) => void; + + type FindObjectCallback = ( + /** If an error happened, this contains the message */ + err: string | null, + /** If an object was found, this contains the ID */ + id?: string, + /** If an object was found, this contains the common.name */ + name?: string, + ) => void; + + interface GetObjectsItem { + /** The ID of this object */ + id: string; + /** A copy of the object from the DB */ + value: T; + } + // This is a version used by GetDevices/GetChannelsOf/GetStatesOf + type GetObjectsCallback3 = (err: string | null, result?: Array>) => void; + + type GetStateCallback = (err: string | null, state: State) => void; + type GetStatesCallback = (err: string | null, states: Record) => void; + /** Version of the callback used by States.getStates */ + type GetStatesCallback2 = (err: string | null, states: State[]) => void; + type GetBinaryStateCallback = (err: string | null, state?: Buffer) => void; + type SetStateCallback = (err: string | null, id?: string) => void; + type SetStateChangedCallback = (err: string | null, id: string, notChanged: boolean) => void; + type DeleteStateCallback = (err: string | null, id?: string) => void; + type GetHistoryCallback = (err: string | null, result: Array<(State & { id?: string })>, step: number, sessionId?: string) => void; + + /** Contains the return values of readDir */ + interface ReadDirResult { + /** Name of the file or directory */ + file: string; + /** File system stats */ + stats: fs.Stats; + /** Whether this is a directory or a file */ + isDir: boolean; + /** Access rights */ + acl: EvaluatedFileACL; + /** Date of last modification */ + modifiedAt: number; + /** Date of creation */ + createdAt: number; + } + type ReadDirCallback = (err: string | null, entries?: ReadDirResult[]) => void; + type ReadFileCallback = (err: string | null, file?: Buffer | string, mimeType?: string) => void; + + /** Contains the return values of chownFile */ + interface ChownFileResult { + /** The parent directory of the processed file or directory */ + path: string; + /** Name of the file or directory */ + file: string; + /** File system stats */ + stats: fs.Stats; + /** Whether this is a directory or a file */ + isDir: boolean; + /** Access rights */ + acl: FileACL; + /** Date of last modification */ + modifiedAt: number; + /** Date of creation */ + createdAt: number; + } + type ChownFileCallback = (err: string | null, entries?: ChownFileResult[], id?: string) => void; + + /** Contains the return values of rm */ + interface RmResult { + /** The parent directory of the deleted file or directory */ + path: string; + /** The name of the deleted file or directory */ + file: string; + /** Whether the deleted object was a directory or a file */ + isDir: boolean; + } + type RmCallback = (err: string | null, entries?: RmResult[]) => void; + + type GetUserGroupCallback = (objectsInstance: Objects, user: User, groups: UserGroup[], acl: ObjectPermissions) => void; + + type ChownObjectCallback = (err: string | null, list?: ioBroker.Object[]) => void; + + type GetConfigKeysCallback = (err: string | null, list?: string[]) => void; + // this is a version of the callback used by Objects.getObjects + type GetObjectsCallback2 = (err: string | null, objects?: Array<(ioBroker.Object | { err: string })>) => void; + + interface GetObjectViewItem { + /** The ID of this object */ + id: string; + /** A copy of the object from the DB or some aggregation result */ + value: ioBroker.Object | {}; // TODO: find out how the non-Object return result looks like + } + type GetObjectViewCallback = (err: string | null, result?: { rows: GetObjectViewItem[] }) => void; + + interface GetObjectListItem extends GetObjectViewItem { + /** A copy of the object */ + value: ioBroker.Object; + /** The same as @link{value} */ + doc: ioBroker.Object; + } + type GetObjectListCallback = (err: string | null, result?: { rows: GetObjectListItem[] }) => void; + + type ExtendObjectCallback = (err: string | null, result?: { id: string, value: ioBroker.Object }, id?: string) => void; + + type GetSessionCallback = (session: Session) => void; + } // end namespace ioBroker } // end declare global diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index e69de29bb2..c8b9f0d43e 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -0,0 +1,5 @@ +// Help! what to test here? + +declare const adapter: ioBroker.Adapter; + +adapter.setState("not.a.state", true); diff --git a/types/iobroker/tsconfig.json b/types/iobroker/tsconfig.json index 3388e650ec..5d7e32bdb6 100644 --- a/types/iobroker/tsconfig.json +++ b/types/iobroker/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/iobroker/tslint.json b/types/iobroker/tslint.json index 3db14f85ea..9a4b76fd9c 100644 --- a/types/iobroker/tslint.json +++ b/types/iobroker/tslint.json @@ -1 +1,8 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dtslint.json", + "rules": { + // This package has its own type `Object` which is not equal to the global `Object` type + // To avoid any confusion, it is referenced as `ioBroker.Object` instead of just `Object` + "no-unnecessary-qualifier": false + } +} From 19d8ec03ecc29e6a6159156cb7868876b42593c2 Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Thu, 15 Nov 2018 12:05:20 +0100 Subject: [PATCH 110/174] Try fix tests --- types/iobroker/index.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index baa8424d9b..8e6976a991 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -1,12 +1,13 @@ -// Ambient type definitions for adapters for ioBroker -// Note: This is not the definition for the package `iobroker`, -// which is just an installer, not a library. -// The definitions are based on ioBroker.js-controller v1.4.2 +// Type definitions for ioBroker adapters // Project: https://github.com/ioBroker/ioBroker // Definitions by: AlCalzone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +// Note: This is not the definition for the package `iobroker`, +// which is just an installer, not a library. +// The definitions are based on ioBroker.js-controller v1.4.2 + /// import * as fs from "fs"; From 47bd9f8a70cfa53da16b6dbdb236ac508c0483e1 Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Thu, 15 Nov 2018 12:11:45 +0100 Subject: [PATCH 111/174] Try to fix tests again --- types/iobroker/index.d.ts | 4 ++-- types/iobroker/tslint.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index 8e6976a991..313d7e9718 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ioBroker adapters +// Type definitions for ioBroker 1.4 // Project: https://github.com/ioBroker/ioBroker // Definitions by: AlCalzone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,7 +6,7 @@ // Note: This is not the definition for the package `iobroker`, // which is just an installer, not a library. -// The definitions are based on ioBroker.js-controller v1.4.2 +// The definitions may change with updates to ioBroker.js-controller /// import * as fs from "fs"; diff --git a/types/iobroker/tslint.json b/types/iobroker/tslint.json index 9a4b76fd9c..bdafdd99b4 100644 --- a/types/iobroker/tslint.json +++ b/types/iobroker/tslint.json @@ -1,5 +1,5 @@ { - "extends": "dtslint/dtslint.json", + "extends": "dtslint/dt.json", "rules": { // This package has its own type `Object` which is not equal to the global `Object` type // To avoid any confusion, it is referenced as `ioBroker.Object` instead of just `Object` From 26b7fc9609d7edea4b1b50f9cc1a9f28f22bc1ef Mon Sep 17 00:00:00 2001 From: Al Calzone Date: Sun, 25 Nov 2018 16:00:57 +0100 Subject: [PATCH 112/174] Update ioBroker typings and tests * Replace any with unknown in many places * Add several overloads * Add tests --- types/iobroker/index.d.ts | 256 ++++++++++++++++++------------- types/iobroker/iobroker-tests.ts | 200 +++++++++++++++++++++++- 2 files changed, 350 insertions(+), 106 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index 313d7e9718..cee6ce75a6 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/ioBroker/ioBroker // Definitions by: AlCalzone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 3.0 // Note: This is not the definition for the package `iobroker`, // which is just an installer, not a library. @@ -307,7 +307,7 @@ declare global { interface BaseObject { /** The ID of this object */ - _id?: string; + _id: string; native: Record; enums?: Record; type: string; // specified in the derived interfaces @@ -350,6 +350,11 @@ declare global { } type Object = StateObject | ChannelObject | DeviceObject | OtherObject; + // In set[Foreign]Object[NotExists] methods, the ID and acl of the object is optional + interface SettableObject extends Pick> { + _id?: ioBroker.Object["_id"]; + acl?: ioBroker.Object["acl"]; + } type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject; /** Defines access rights for a single file */ @@ -519,7 +524,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ writeFile(id: string, name: string, data: Buffer | string, callback: ErrorCallback): void; - writeFile(id: string, name: string, data: Buffer | string, options: string | {}, callback: ErrorCallback): void; + writeFile(id: string, name: string, data: Buffer | string, options: string | unknown, callback: ErrorCallback): void; /** * Reads a file. @@ -529,7 +534,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ readFile(id: string, name: string, callback: ReadFileCallback): void; - readFile(id: string, name: string, options: any, callback: ReadFileCallback): void; + readFile(id: string, name: string, options: unknown, callback: ReadFileCallback): void; /** * Deletes a file. @@ -539,7 +544,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ unlink(id: string, name: string, callback: ErrorCallback): void; - unlink(id: string, name: string, options: any, callback: ErrorCallback): void; + unlink(id: string, name: string, options: unknown, callback: ErrorCallback): void; /** * Deletes a file. * @param id Name of the root directory. This should be the adapter instance, e.g. "admin.0" @@ -548,7 +553,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ delFile(id: string, name: string, callback: ErrorCallback): void; - delFile(id: string, name: string, options: any, callback: ErrorCallback): void; + delFile(id: string, name: string, options: unknown, callback: ErrorCallback): void; /** * Finds all files and directories starting with @@ -558,7 +563,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ readDir(id: string, name: string, callback: ReadDirCallback): void; - readDir(id: string, name: string, options: any, callback: ReadDirCallback): void; + readDir(id: string, name: string, options: unknown, callback: ReadDirCallback): void; /** * Renames a file or directory @@ -569,7 +574,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ rename(id: string, oldName: string, newName: string, callback: ErrorCallback): void; - rename(id: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; + rename(id: string, oldName: string, newName: string, options: unknown, callback: ErrorCallback): void; /** * Creates an empty file with the given name @@ -579,7 +584,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ touch(id: string, name: string, callback: ErrorCallback): void; - touch(id: string, name: string, options: any, callback: ErrorCallback): void; + touch(id: string, name: string, options: unknown, callback: ErrorCallback): void; /** * Deletes all files in the root directory matching @@ -589,7 +594,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ rm(id: string, name: string, callback: RmCallback): void; - rm(id: string, name: string, options: any, callback: RmCallback): void; + rm(id: string, name: string, options: unknown, callback: RmCallback): void; /** * Creates an empty directory with the given name @@ -599,7 +604,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ mkDir(id: string, name: string, callback: ErrorCallback): void; - mkDir(id: string, name: string, options: any, callback: ErrorCallback): void; + mkDir(id: string, name: string, options: unknown, callback: ErrorCallback): void; /** * Takes possession all files in the root directory matching @@ -609,7 +614,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ chownFile(id: string, name: string, callback: ChownFileCallback): void; - chownFile(id: string, name: string, options: any, callback: ChownFileCallback): void; + chownFile(id: string, name: string, options: unknown, callback: ChownFileCallback): void; /** * Changes access rights of all files in the root directory matching @@ -628,26 +633,26 @@ declare global { * @param pattern The pattern to match against */ subscribeConfig(pattern: string, callback: EmptyCallback): void; - subscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; + subscribeConfig(pattern: string, options: unknown, callback: EmptyCallback): void; /** * Subscribe to object changes * @param pattern The pattern to match against */ subscribe(pattern: string, callback: EmptyCallback): void; - subscribe(pattern: string, options: any, callback: EmptyCallback): void; + subscribe(pattern: string, options: unknown, callback: EmptyCallback): void; /** * Unsubscribe from object changes * @param pattern The pattern to match against */ unsubscribeConfig(pattern: string, callback: EmptyCallback): void; - unsubscribeConfig(pattern: string, options: any, callback: EmptyCallback): void; + unsubscribeConfig(pattern: string, options: unknown, callback: EmptyCallback): void; /** * Unsubscribe from object changes * @param pattern The pattern to match against */ unsubscribe(pattern: string, callback: EmptyCallback): void; - unsubscribe(pattern: string, options: any, callback: EmptyCallback): void; + unsubscribe(pattern: string, options: unknown, callback: EmptyCallback): void; /** * Takes possession of all objects matching @@ -656,7 +661,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ chownObject(pattern: string, callback: ChownObjectCallback): void; - chownObject(pattern: string, options: any, callback: ChownObjectCallback): void; + chownObject(pattern: string, options: unknown, callback: ChownObjectCallback): void; /** * Changes access rights of all objects matching @@ -665,7 +670,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ chmodObject(pattern: string, callback: ChownObjectCallback): void; - chmodObject(pattern: string, options: any, callback: ChownObjectCallback): void; + chmodObject(pattern: string, options: unknown, callback: ChownObjectCallback): void; /** * Retrieves a copy of the object with the given ID @@ -674,7 +679,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getObject(id: string, callback: GetObjectCallback): void; - getObject(id: string, options: any, callback: GetObjectCallback): void; + getObject(id: string, options: unknown, callback: GetObjectCallback): void; /** * Retrieves a copy of the object with the given ID * @param id Id of the object to find @@ -682,7 +687,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getConfig(id: string, callback: GetObjectCallback): void; - getConfig(id: string, options: any, callback: GetObjectCallback): void; + getConfig(id: string, options: unknown, callback: GetObjectCallback): void; /** * Returns a list of config keys matching @@ -692,7 +697,7 @@ declare global { * @param dontModify unused */ getConfigKeys(pattern: string, callback: GetConfigKeysCallback, dontModify?: any): void; - getConfigKeys(pattern: string, options: any, callback: GetConfigKeysCallback, dontModify?: any): void; + getConfigKeys(pattern: string, options: unknown, callback: GetConfigKeysCallback, dontModify?: any): void; /** * Returns a list of objects with the given ids @@ -702,7 +707,7 @@ declare global { * @param dontModify unused */ getObjects(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; - getObjects(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; + getObjects(keys: string[], options: unknown, callback: GetObjectsCallback2, dontModify?: any): void; /** * Returns a list of objects with the given ids * @param keys IDs of the objects to be retrieved @@ -711,7 +716,7 @@ declare global { * @param dontModify unused */ getConfigs(keys: string[], callback: GetObjectsCallback2, dontModify?: any): void; - getConfigs(keys: string[], options: any, callback: GetObjectsCallback2, dontModify?: any): void; + getConfigs(keys: string[], options: unknown, callback: GetObjectsCallback2, dontModify?: any): void; /** * Creates or overwrites an object in the object db @@ -720,8 +725,8 @@ declare global { * @param options (optional) Some internal options. * @param callback Is called when the operation has finished (successfully or not) */ - setObject(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; - setObject(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; + setObject(id: string, obj: ioBroker.SettableObject, callback: SetObjectCallback): void; + setObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback: SetObjectCallback): void; /** * Creates or overwrites an object in the object db * @param id ID of the object @@ -729,8 +734,8 @@ declare global { * @param options (optional) Some internal options. * @param callback Is called when the operation has finished (successfully or not) */ - setConfig(id: string, obj: ioBroker.Object, callback: SetObjectCallback): void; - setConfig(id: string, obj: ioBroker.Object, options: any, callback: SetObjectCallback): void; + setConfig(id: string, obj: ioBroker.SettableObject, callback: SetObjectCallback): void; + setConfig(id: string, obj: ioBroker.SettableObject, options: unknown, callback: SetObjectCallback): void; /** * Deletes an object in the object db @@ -739,7 +744,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ delObject(id: string, callback: ErrorCallback): void; - delObject(id: string, options: any, callback: ErrorCallback): void; + delObject(id: string, options: unknown, callback: ErrorCallback): void; /** * Deletes an object in the object db * @param id ID of the object @@ -747,7 +752,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ delConfig(id: string, callback: ErrorCallback): void; - delConfig(id: string, options: any, callback: ErrorCallback): void; + delConfig(id: string, options: unknown, callback: ErrorCallback): void; /** * Returns a list of objects with id between params.startkey and params.endkey @@ -769,7 +774,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getObjectView(design: string, search: string, params: GetObjectViewParams | null, callback: GetObjectViewCallback): void; - getObjectView(design: string, search: string, params: GetObjectViewParams | null, options: any, callback: GetObjectViewCallback): void; + getObjectView(design: string, search: string, params: GetObjectViewParams | null, options: unknown, callback: GetObjectViewCallback): void; /** * Extends an object in the object db with new properties @@ -779,7 +784,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ extendObject(id: string, obj: PartialObject, callback: ExtendObjectCallback): void; - extendObject(id: string, obj: PartialObject, options: any, callback: ExtendObjectCallback): void; + extendObject(id: string, obj: PartialObject, options: unknown, callback: ExtendObjectCallback): void; /** * Finds an object by ID or name. If multiple objects were found, return the first one @@ -789,7 +794,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ findObject(idOrName: string, type: CommonType | null, callback: FindObjectCallback): void; - findObject(idOrName: string, type: CommonType | null, options: any, callback: FindObjectCallback): void; + findObject(idOrName: string, type: CommonType | null, options: unknown, callback: FindObjectCallback): void; // I'd rather not document a function with the name "destroyDB" @@ -910,9 +915,9 @@ declare global { /** Handler for changes of subscribed states */ stateChange?: StateChangeHandler; /** Will be called when the adapter is intialized */ - ready?: () => void; + ready?: ReadyHandler; /** Will be called on adapter termination */ - unload?: (callback: EmptyCallback) => void; + unload?: UnloadHandler; /** if true, stateChange will be called with an id that has no namespace, e.g. "state" instead of "adapter.0.state". Default: false */ noNamespace?: boolean; @@ -972,15 +977,15 @@ declare global { /** Validates username and password */ checkPassword(user: string, password: string, callback: (result: boolean) => void): void; - checkPassword(user: string, password: string, options: any, callback: (result: boolean) => void): void; + checkPassword(user: string, password: string, options: unknown, callback: (result: boolean) => void): void; /** Sets a new password for the given user */ - setPassword(user: string, password: string, options?: any, callback?: (err?: any) => void): void; + setPassword(user: string, password: string, options?: unknown, callback?: (err?: any) => void): void; /** Checks if a user exists and is in the given group. */ checkGroup(user: string, group: string, callback: (result: boolean) => void): void; - checkGroup(user: string, group: string, options: any, callback: (result: boolean) => void): void; + checkGroup(user: string, group: string, options: unknown, callback: (result: boolean) => void): void; /** Determines the users permissions */ calculatePermissions(user: string, commandsPermissions: CommandsPermissions, callback: (result: PermissionSet) => void): void; - calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: any, callback: (result: PermissionSet) => void): void; + calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: unknown, callback: (result: PermissionSet) => void): void; /** Returns SSL certificates by name (private key, public cert and chained certificate) for creation of HTTPS servers */ getCertificates(publicName: string, privateName: string, chainedName: string, callback: (err: string | null, certs?: Certificates, useLetsEncryptCert?: boolean) => void): void; @@ -1013,20 +1018,24 @@ declare global { /** Reads an object from the object db */ getObject(id: string, callback: GetObjectCallback): void; - getObject(id: string, options: any, callback: GetObjectCallback): void; + getObject(id: string, options: unknown, callback: GetObjectCallback): void; /** Creates or overwrites an object in the object db */ - setObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + setObject(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; + setObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; /** Creates an object in the object db. Existing objects are not overwritten. */ - setObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + setObjectNotExists(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; + setObjectNotExists(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; /** Get all states, channels and devices of this adapter */ getAdapterObjects(callback: (objects: Record) => void): void; /** Extend an object and create it if it might not exist */ - extendObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; + extendObject(id: string, objPart: PartialObject, callback?: SetObjectCallback): void; + extendObject(id: string, objPart: PartialObject, options: unknown, callback?: SetObjectCallback): void; /** * Deletes an object from the object db * @param id - The id of the object without namespace */ - delObject(id: string, options?: any, callback?: ErrorCallback): void; + delObject(id: string, callback?: ErrorCallback): void; + delObject(id: string, options: unknown, callback?: ErrorCallback): void; // ============================== // foreign objects @@ -1034,61 +1043,83 @@ declare global { // tslint:disable:unified-signatures /** Reads an object (which might not belong to this adapter) from the object db */ getForeignObject(id: string, callback: GetObjectCallback): void; - getForeignObject(id: string, options: any, callback: GetObjectCallback): void; + getForeignObject(id: string, options: unknown, callback: GetObjectCallback): void; /** Get foreign objects by pattern, by specific type and resolve their enums. */ getForeignObjects(pattern: string, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, options: any, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, options: unknown, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, type: ObjectType, options: any, callback: GetObjectsCallback): void; - getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: any, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, options: unknown, callback: GetObjectsCallback): void; + getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: unknown, callback: GetObjectsCallback): void; /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ - setForeignObject(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + setForeignObject(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; + setForeignObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ - setForeignObjectNotExists(id: string, obj: ioBroker.Object, options?: any, callback?: SetObjectCallback): void; + setForeignObjectNotExists(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; + setForeignObjectNotExists(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ - extendForeignObject(id: string, objPart: PartialObject, options?: any, callback?: SetObjectCallback): void; + extendForeignObject(id: string, objPart: PartialObject, callback?: SetObjectCallback): void; + extendForeignObject(id: string, objPart: PartialObject, options: unknown, callback?: SetObjectCallback): void; // tslint:enable:unified-signatures /** * Finds an object by its ID or name * @param type - common.type of the state */ findForeignObject(idOrName: string, type: string, callback: FindObjectCallback): void; - findForeignObject(idOrName: string, type: string, options: any, callback: FindObjectCallback): void; + findForeignObject(idOrName: string, type: string, options: unknown, callback: FindObjectCallback): void; /** * Deletes an object (which might not belong to this adapter) from the object db * @param id - The id of the object including namespace */ - delForeignObject(id: string, options?: any, callback?: ErrorCallback): void; + delForeignObject(id: string, callback?: ErrorCallback): void; + delForeignObject(id: string, options: unknown, callback?: ErrorCallback): void; // ============================== // states + + // Multiple signatures help understanding what the parameters are about + // tslint:disable:unified-signatures /** Writes a value into the states DB. */ - setState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; + setState(id: string, state: string | number | boolean | State | Partial, callback?: SetStateCallback): void; + setState(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateCallback): void; + setState(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateCallback): void; + setState(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateCallback): void; /** Writes a value into the states DB only if it has changed. */ - setStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; + setStateChanged(id: string, state: string | number | boolean | State | Partial, callback?: SetStateChangedCallback): void; + setStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateChangedCallback): void; + setStateChanged(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateChangedCallback): void; + setStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateChangedCallback): void; /** Writes a value (which might not belong to this adapter) into the states DB. */ - setForeignState(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateCallback): void; + setForeignState(id: string, state: string | number | boolean | State | Partial, callback?: SetStateCallback): void; + setForeignState(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateCallback): void; + setForeignState(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateCallback): void; + setForeignState(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateCallback): void; /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ - setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack?: boolean, options?: any, callback?: SetStateChangedCallback): void; + setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, callback?: SetStateChangedCallback): void; + setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateChangedCallback): void; + setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateChangedCallback): void; + setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateChangedCallback): void; + // tslint:enable:unified-signatures /** Read a value from the states DB. */ getState(id: string, callback: GetStateCallback): void; - getState(id: string, options: any, callback: GetStateCallback): void; + getState(id: string, options: unknown, callback: GetStateCallback): void; /** Read a value (which might not belong to this adapter) from the states DB. */ getForeignState(id: string, callback: GetStateCallback): void; - getForeignState(id: string, options: any, callback: GetStateCallback): void; + getForeignState(id: string, options: unknown, callback: GetStateCallback): void; /** Read all states of this adapter which match the given pattern */ getStates(pattern: string, callback: GetStatesCallback): void; - getStates(pattern: string, options: any, callback: GetStatesCallback): void; + getStates(pattern: string, options: unknown, callback: GetStatesCallback): void; /** Read all states (which might not belong to this adapter) which match the given pattern */ getForeignStates(pattern: string, callback: GetStatesCallback): void; - getForeignStates(pattern: string, options: any, callback: GetStatesCallback): void; + getForeignStates(pattern: string, options: unknown, callback: GetStatesCallback): void; /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ - delState(id: string, options?: any, callback?: ErrorCallback): void; + delState(id: string, callback?: ErrorCallback): void; + delState(id: string, options: unknown, callback?: ErrorCallback): void; /** Deletes a state from the states DB, but not the associated object */ - delForeignState(id: string, options?: any, callback?: ErrorCallback): void; + delForeignState(id: string, callback?: ErrorCallback): void; + delForeignState(id: string, options: unknown, callback?: ErrorCallback): void; getHistory(id: string, options: GetHistoryOptions, callback: GetHistoryCallback): void; @@ -1106,7 +1137,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ setBinaryState(id: string, binary: Buffer, callback: SetStateCallback): void; - setBinaryState(id: string, binary: Buffer, options: any, callback: SetStateCallback): void; + setBinaryState(id: string, binary: Buffer, options: unknown, callback: SetStateCallback): void; /** * Reads a binary state from Redis * @param id The id of the state @@ -1114,7 +1145,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getBinaryState(id: string, callback: GetBinaryStateCallback): void; - getBinaryState(id: string, options: any, callback: GetBinaryStateCallback): void; + getBinaryState(id: string, options: unknown, callback: GetBinaryStateCallback): void; // ============================== // enums @@ -1122,65 +1153,65 @@ declare global { /** Returns the enum tree, filtered by the optional enum name */ getEnum(callback: GetEnumCallback): void; getEnum(name: string, callback: GetEnumCallback): void; - getEnum(name: string, options: any, callback: GetEnumCallback): void; + getEnum(name: string, options: unknown, callback: GetEnumCallback): void; getEnums(callback: GetEnumsCallback): void; getEnums(enumList: EnumList, callback: GetEnumsCallback): void; - getEnums(enumList: EnumList, options: any, callback: GetEnumsCallback): void; + getEnums(enumList: EnumList, options: unknown, callback: GetEnumsCallback): void; - addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; - deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; - addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; - deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; // ============================== // subscriptions /** Subscribe to changes of objects in this instance */ - subscribeObjects(pattern: string, options?: any): void; + subscribeObjects(pattern: string, options?: unknown): void; /** Subscribe to changes of objects (which might not belong to this adapter) */ - subscribeForeignObjects(pattern: string, options?: any): void; + subscribeForeignObjects(pattern: string, options?: unknown): void; /** Unsubscribe from changes of objects in this instance */ - unsubscribeObjects(pattern: string, options?: any): void; + unsubscribeObjects(pattern: string, options?: unknown): void; /** Unsubscribe from changes of objects (which might not belong to this adapter) */ - unsubscribeForeignObjects(pattern: string, options?: any): void; + unsubscribeForeignObjects(pattern: string, options?: unknown): void; /** Subscribe to changes of states in this instance */ - subscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; + subscribeStates(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Subscribe to changes of states (which might not belong to this adapter) */ - subscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; + subscribeForeignStates(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** * Subscribe from changes of states in this instance * @param pattern - Must match the pattern used to subscribe */ - unsubscribeStates(pattern: string, options?: any, callback?: ErrorCallback): void; + unsubscribeStates(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** * Subscribe from changes of states (which might not belong to this adapter) * @param pattern - Must match the pattern used to subscribe */ - unsubscribeForeignStates(pattern: string, options?: any, callback?: ErrorCallback): void; + unsubscribeForeignStates(pattern: string, options?: unknown, callback?: ErrorCallback): void; // ============================== // devices and channels /** creates an object with type device */ - createDevice(deviceName: string, common?: any, native?: any, options?: any, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common?: any, native?: any, options?: unknown, callback?: SetObjectCallback): void; /** deletes a device, its channels and states */ - deleteDevice(deviceName: string, options?: any, callback?: ErrorCallback): void; + deleteDevice(deviceName: string, options?: unknown, callback?: ErrorCallback): void; /** gets the devices of this instance */ /** creates an object with type channel */ - createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; + createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: unknown, callback?: SetObjectCallback): void; /** deletes a channel and its states */ - deleteChannel(channelName: string, options?: any, callback?: ErrorCallback): void; - deleteChannel(parentDevice: string, channelName: string, options?: any, callback?: ErrorCallback): void; + deleteChannel(channelName: string, options?: unknown, callback?: ErrorCallback): void; + deleteChannel(parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; /** creates a state and the corresponding object */ - createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: any, callback?: SetObjectCallback): void; + createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: unknown, callback?: SetObjectCallback): void; /** deletes a state */ - deleteState(stateName: string, options?: any, callback?: ErrorCallback): void; - deleteState(parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; - deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: any, callback?: ErrorCallback): void; + deleteState(stateName: string, options?: unknown, callback?: ErrorCallback): void; + deleteState(parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; + deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; /** * Returns a list of all devices in this adapter instance @@ -1188,7 +1219,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getDevices(callback: GetObjectsCallback3): void; - getDevices(options: any, callback: GetObjectsCallback3): void; + getDevices(options: unknown, callback: GetObjectsCallback3): void; /** * Returns a list of all channels in this adapter instance @@ -1198,7 +1229,7 @@ declare global { */ getChannels(callback: GetObjectsCallback3): void; getChannels(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string | null, options: unknown, callback: GetObjectsCallback3): void; /** * Returns a list of all channels in this adapter instance * @param parentDevice (optional) Name of the parent device to filter the channels by @@ -1207,7 +1238,7 @@ declare global { */ getChannelsOf(callback: GetObjectsCallback3): void; getChannelsOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, options: any, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string | null, options: unknown, callback: GetObjectsCallback3): void; /** * Returns a list of all states in this adapter instance @@ -1219,7 +1250,7 @@ declare global { getStatesOf(callback: GetObjectsCallback3): void; getStatesOf(parentDevice: string | null, callback: GetObjectsCallback3): void; getStatesOf(parentDevice: string | null, parentChannel: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, options: any, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string | null, parentChannel: string | null, options: unknown, callback: GetObjectsCallback3): void; // ============================== // filesystem @@ -1230,23 +1261,23 @@ declare global { * @param path - path to direcory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". */ readDir(adapterName: string, path: string, callback: ReadDirCallback): void; - readDir(adapterName: string, path: string, options: any, callback: ReadDirCallback): void; + readDir(adapterName: string, path: string, options: unknown, callback: ReadDirCallback): void; mkDir(adapterName: string, path: string, callback: ErrorCallback): void; - mkDir(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + mkDir(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; readFile(adapterName: string, path: string, callback: ReadFileCallback): void; - readFile(adapterName: string, path: string, options: any, callback: ReadFileCallback): void; + readFile(adapterName: string, path: string, options: unknown, callback: ReadFileCallback): void; writeFile(adapterName: string, path: string, data: Buffer | string, callback: ErrorCallback): void; // options see https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/objects/objectsInMemServer.js#L599 - writeFile(adapterName: string, path: string, data: Buffer | string, options: any, callback: ErrorCallback): void; + writeFile(adapterName: string, path: string, data: Buffer | string, options: unknown, callback: ErrorCallback): void; delFile(adapterName: string, path: string, callback: ErrorCallback): void; - delFile(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + delFile(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; unlink(adapterName: string, path: string, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, options: any, callback: ErrorCallback): void; + unlink(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; rename(adapterName: string, oldName: string, newName: string, callback: ErrorCallback): void; - rename(adapterName: string, oldName: string, newName: string, options: any, callback: ErrorCallback): void; + rename(adapterName: string, oldName: string, newName: string, options: unknown, callback: ErrorCallback): void; /** * Changes access rights of all files in the adapter directory @@ -1264,11 +1295,30 @@ declare global { formatValue(value: number | string, decimals: number, format: any): string; formatDate(dateObj: string | Date | number, format: string): string; formatDate(dateObj: string | Date | number, isDuration: boolean | string, format: string): string; + + // ============================================= + // Events exposed through EventEmitter interface + // ============================================= + on(event: "ready", handler: ReadyHandler): this; + on(event: "unload", handler: UnloadHandler): this; + on(event: "stateChange", handler: StateChangeHandler): this; + on(event: "objectChange", handler: ObjectChangeHandler): this; + on(event: "message", handler: MessageHandler): this; + + removeListener(event: "ready", handler: ReadyHandler): this; + removeListener(event: "unload", handler: UnloadHandler): this; + removeListener(event: "stateChange", handler: StateChangeHandler): this; + removeListener(event: "objectChange", handler: ObjectChangeHandler): this; + removeListener(event: "message", handler: MessageHandler): this; + + removeAllListeners(event?: "ready" | "unload" | "stateChange" | "objectChange" | "message"): this; } // end interface Adapter - type ObjectChangeHandler = (id: string, obj: ioBroker.Object) => void; - type StateChangeHandler = (id: string, obj: State) => void; + type ReadyHandler = () => void; + type ObjectChangeHandler = (id: string, obj: ioBroker.Object | null | undefined) => void; + type StateChangeHandler = (id: string, obj: State | null | undefined) => void; type MessageHandler = (obj: Message) => void; + type UnloadHandler = (callback: EmptyCallback) => void; type EmptyCallback = () => void; type ErrorCallback = (err?: string) => void; @@ -1276,7 +1326,7 @@ declare global { type GenericCallback = (err: string | null, result?: T) => void; type SetObjectCallback = (err: string | null, obj: { id: string }) => void; - type GetObjectCallback = (err: string | null, obj: ioBroker.Object) => void; + type GetObjectCallback = (err: string | null, obj: ioBroker.Object | null | undefined) => void; type GetEnumCallback = (err: string | null, enums: Record, requestedEnum: string) => void; type GetEnumsCallback = ( err: string | null, @@ -1304,7 +1354,7 @@ declare global { // This is a version used by GetDevices/GetChannelsOf/GetStatesOf type GetObjectsCallback3 = (err: string | null, result?: Array>) => void; - type GetStateCallback = (err: string | null, state: State) => void; + type GetStateCallback = (err: string | null, state: State | null | undefined) => void; type GetStatesCallback = (err: string | null, states: Record) => void; /** Version of the callback used by States.getStates */ type GetStatesCallback2 = (err: string | null, states: State[]) => void; @@ -1374,7 +1424,7 @@ declare global { /** The ID of this object */ id: string; /** A copy of the object from the DB or some aggregation result */ - value: ioBroker.Object | {}; // TODO: find out how the non-Object return result looks like + value: ioBroker.Object | unknown; // TODO: find out how the non-Object return result looks like } type GetObjectViewCallback = (err: string | null, result?: { rows: GetObjectViewItem[] }) => void; diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index c8b9f0d43e..997775c76f 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -1,5 +1,199 @@ -// Help! what to test here? +// For now, this "utils" module is necessary, as it is included in every adapter +// Once this PR is merged and @types/iobroker is available, it will become part of +// `iobroker.adapter-core`, which brings typings for it +declare const utils: { + readonly controllerDir: string; + getConfig(): string; -declare const adapter: ioBroker.Adapter; + // tslint:disable:unified-signatures + adapter(adapterName: string): ioBroker.Adapter; + adapter(adapterOptions: ioBroker.AdapterOptions): ioBroker.Adapter; + // tslint:enable:unified-signatures +}; -adapter.setState("not.a.state", true); +declare function assertNever(val: never): never; + +// Let the tests begin +let adapter: ioBroker.Adapter; + +// Test constructors +adapter = utils.adapter("my-adapter-name"); +adapter = utils.adapter({ + name: "my-adapter-name" +}); +adapter = utils.adapter({ + name: "my-adapter-name", + ready: readyHandler, + stateChange: stateChangeHandler, + objectChange: objectChangeHandler, + message: messageHandler, + unload: unloadHandler, +}); + +// Test EventEmitter definitions +adapter + .on("ready", readyHandler) + .on("stateChange", stateChangeHandler) + .on("objectChange", objectChangeHandler) + .on("message", messageHandler) + .on("unload", unloadHandler) + ; +adapter + .removeListener("ready", readyHandler) + .removeListener("stateChange", stateChangeHandler) + .removeListener("objectChange", objectChangeHandler) + .removeListener("message", messageHandler) + .removeListener("unload", unloadHandler) + ; +adapter.removeAllListeners(); + +function readyHandler() { } + +function stateChangeHandler(id: string, state: ioBroker.State | null | undefined) { + // Test State properties + if (state) { + state.ack; + state.c && state.c.toLowerCase(); + state.expire && state.expire.toFixed(); + state.from.toLowerCase(); + state.lc.toFixed(); + state.q && state.q.toFixed(); + state.ts.toFixed(); + state.val; + } +} + +function objectChangeHandler(id: string, object: ioBroker.Object | null | undefined) { + // Test properties of all objects + if (object) { + object._id.toLowerCase(); + object.common.name.toLowerCase(); + object.common.role && object.common.role.toLowerCase(); + object.common.icon && object.common.icon.toLowerCase(); + object.native.toString(); + object.enums && object.enums.toString(); + if (object.acl) { + object.acl.object.toFixed(); + object.acl.owner.toLowerCase(); + object.acl.ownerGroup.toLowerCase(); + } + // Test different object kinds + switch (object.type) { + case "adapter": + case "config": + case "enum": + case "group": + case "host": + case "info": + case "instance": + case "meta": + case "script": + case "user": + // nothing special here, update these tests when we have specialized definitions + break; + + case "state": + if (object.acl) object.acl.state.toFixed(); + object.common.def; + object.common.desc && object.common.desc.toLowerCase(); + object.common.history; + object.common.max && object.common.max.toFixed(); + object.common.min && object.common.min.toFixed(); + object.common.read.valueOf(); + object.common.states && object.common.states.toString(); + object.common.type && object.common.type.toLowerCase(); + object.common.unit && object.common.unit.toLowerCase(); + object.common.workingID && object.common.workingID.toLowerCase(); + object.common.write.valueOf(); + break; + + case "channel": + object.common.desc && object.common.desc.toLowerCase(); + break; + + case "device": + // nothing special here, update these tests when we have specialized definitions + break; + } + } +} + +function messageHandler(msg: ioBroker.Message) { + msg._id.toFixed(); + msg.callback.ack.valueOf(); + msg.callback.id.toFixed(); + msg.callback.message.toString(); + msg.callback.time.toFixed(); + msg.command.toLowerCase(); + msg.from.toLowerCase(); + msg.message.toString(); +} + +function unloadHandler(callback: ioBroker.EmptyCallback) { + adapter.log.info("shutting down"); + callback(); +} + +// Test the most important methods +adapter.setState("state.name", "value"); +adapter.setState("state.name", "value", true); +adapter.setState("state.name", "value", (err, id) => { }); +adapter.setState("state.name", { val: "value", ack: true }); +adapter.setState("state.name", { val: "value", ack: true }, (err, id) => { }); + +adapter.setStateChanged("state.name", "value"); +adapter.setStateChanged("state.name", "value", true); +adapter.setStateChanged("state.name", "value", (err, id) => { }); +adapter.setStateChanged("state.name", { val: "value", ack: true }); +adapter.setStateChanged("state.name", { val: "value", ack: true }, (err, id) => { }); + +adapter.setForeignState("state.name", "value"); +adapter.setForeignState("state.name", "value", true); +adapter.setForeignState("state.name", "value", (err, id) => { }); +adapter.setForeignState("state.name", { val: "value", ack: true }); +adapter.setForeignState("state.name", { val: "value", ack: true }, (err, id) => { }); + +adapter.setForeignStateChanged("state.name", "value"); +adapter.setForeignStateChanged("state.name", "value", true); +adapter.setForeignStateChanged("state.name", "value", (err, id) => { }); +adapter.setForeignStateChanged("state.name", { val: "value", ack: true }); +adapter.setForeignStateChanged("state.name", { val: "value", ack: true }, (err, id) => { }); + +adapter.setObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }); +adapter.setObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); +adapter.setForeignObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }); +adapter.setForeignObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); + +adapter.setObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }); +adapter.setObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); +adapter.setForeignObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }); +adapter.setForeignObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); + +adapter.getObject("obj.id", (err, obj) => { }); +adapter.getForeignObject("obj.id", (err, obj) => { }); + +adapter.subscribeObjects("*"); +adapter.subscribeStates("*"); +adapter.subscribeForeignObjects("*"); +adapter.subscribeForeignStates("*"); +adapter.unsubscribeObjects("*"); +adapter.unsubscribeStates("*"); +adapter.unsubscribeForeignObjects("*"); +adapter.unsubscribeForeignStates("*"); + +adapter.log.info("msg"); +adapter.log.debug("msg"); +adapter.log.warn("msg"); +adapter.log.error("msg"); +adapter.log.silly("msg"); + +switch (adapter.log.level) { + case "debug": + case "error": + case "info": + case "silly": + case "warn": + break; + default: + assertNever(adapter.log.level); +} From e6ad7248578be028804e73688a6348fadca31b77 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Sun, 25 Nov 2018 18:41:50 +0300 Subject: [PATCH 113/174] tus-js-client: fix fingerprint type --- types/tus-js-client/index.d.ts | 2 +- types/tus-js-client/tus-js-client-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/tus-js-client/index.d.ts b/types/tus-js-client/index.d.ts index defb27fea0..4cbb34a818 100644 --- a/types/tus-js-client/index.d.ts +++ b/types/tus-js-client/index.d.ts @@ -6,7 +6,7 @@ export interface UploadOptions { endpoint: string; - fingerprint?: string; + fingerprint?: (file: File, options?: UploadOptions) => string; resume?: boolean; metadata?: { [key: string]: string }; onProgress?: ((bytesSent: number, bytesTotal: number) => void) | null; diff --git a/types/tus-js-client/tus-js-client-tests.ts b/types/tus-js-client/tus-js-client-tests.ts index a13d9da12f..237f1df233 100644 --- a/types/tus-js-client/tus-js-client-tests.ts +++ b/types/tus-js-client/tus-js-client-tests.ts @@ -10,7 +10,7 @@ const file = new File(["foo"], "foo.txt", { const upload = new Tus.Upload(file, { endpoint: "", - fingerprint: "fingerprint", + fingerprint: (file: File) => file.name, resume: true, metadata: { filename: "foo.txt" From 715d23525775a2625e052b50b92e0068e2a40d2b Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Nov 2018 11:04:43 -0600 Subject: [PATCH 114/174] Added beforeSave and afterSave to hook definitions --- types/sequelize/index.d.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 88ed87efae..f25aacc3e4 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -2295,8 +2295,8 @@ declare namespace sequelize { * interfaces. * * beforeValidate, afterValidate, beforeBulkCreate, beforeBulkDestroy, beforeBulkUpdate, beforeCreate, - * beforeDestroy, beforeUpdate, afterCreate, afterDestroy, afterUpdate, afterBulkCreate, afterBulkDestroy and - * afterBulkUpdate. + * beforeDestroy, beforeSave, beforeUpdate, afterCreate, afterDestroy, afterSave, afterUpdate, afterBulkCreate, + * afterBulkDestroy and afterBulkUpdate. */ interface HooksDefineOptions { @@ -2310,6 +2310,8 @@ declare namespace sequelize { afterDelete?: (instance: TInstance, options: Object, fn?: Function) => any; beforeUpdate?: (instance: TInstance, options: Object, fn?: Function) => any; afterUpdate?: (instance: TInstance, options: Object, fn?: Function) => any; + beforeSave?: (instance: TInstance, options: Object, fn?: Function) => any; + afterSave?: (instance: TInstance, options: Object, fn?: Function) => any; beforeBulkCreate?: (instances: TInstance[], options: Object, fn?: Function) => any; afterBulkCreate?: (instances: TInstance[], options: Object, fn?: Function) => any; beforeBulkDestroy?: (options: Object, fn?: Function) => any; @@ -5272,9 +5274,10 @@ declare namespace sequelize { /** * An object of hook function that are called before and after certain lifecycle events. * The possible hooks are: beforeValidate, afterValidate, beforeBulkCreate, beforeBulkDestroy, - * beforeBulkUpdate, beforeCreate, beforeDestroy, beforeUpdate, afterCreate, afterDestroy, afterUpdate, - * afterBulkCreate, afterBulkDestory and afterBulkUpdate. See Hooks for more information about hook - * functions and their signatures. Each property can either be a function, or an array of functions. + * beforeBulkUpdate, beforeCreate, beforeDestroy, beforeSave, beforeUpdate, afterCreate, afterDestroy, + * afterSave, afterUpdate, afterBulkCreate, afterBulkDestory and afterBulkUpdate. + * See Hooks for more information about hook functions and their signatures. Each property can either + * be a function, or an array of functions. */ hooks?: HooksDefineOptions; From 839378616bfdf97838212e7f5443d9d4775a21c7 Mon Sep 17 00:00:00 2001 From: Yves Kaufmann Date: Sun, 25 Nov 2018 18:57:36 +0100 Subject: [PATCH 115/174] remove double block comments --- types/mongodb/index.d.ts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index e516e4d31f..b31a8dd7b9 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -261,11 +261,11 @@ export interface MongoClientOptions extends /** * The name of the application that created this MongoClient instance. */ - appname?: string; + appname?: string; - /** - * Authentifikation credentials - */ + /** + * Authentifikation credentials + */ auth?: { /** * The username for auth @@ -280,7 +280,7 @@ export interface MongoClientOptions extends /** * Determines whether or not to use the new url parser */ - useNewUrlParser?: boolean; + useNewUrlParser?: boolean; /** * Mechanism for authentication: DEFAULT, GSSAPI, PLAIN, MONGODB-X509, 'MONGODB-CR', SCRAM-SHA-1 or SCRAM-SHA-256 @@ -428,12 +428,12 @@ export interface DbCreateOptions extends CommonOptions { * ES6 compatible promise constructor */ promiseLibrary?: Object; - /** https://docs.mongodb.com/manual/reference/read-concern/#read-concern */ + /** + * https://docs.mongodb.com/manual/reference/read-concern/#read-concern + **/ readConcern?: ReadConcern; /** * Sets a cap on how many operations the driver will buffer up before giving up on getting a - */ - /** * working connection, default is -1 which is unlimited. */ bufferMaxEntries?: number; @@ -463,11 +463,8 @@ export interface SocketOptions { connectTimeoutMS?: number; /** * Version of IP stack. Can be 4, 6 or null. default: null. - */ - /** + * * If null, will attempt to connect with IPv6, and will fall back to IPv4 on failure - */ - /** * refer to http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html */ family?: 4 | 6 | null; @@ -514,9 +511,9 @@ export interface MongosOptions extends SSLOptions, HighAvailabilityOptions { */ acceptableLatencyMS?: number; - /** - * Socket Options - */ + /** + * Socket Options + */ socketOptions?: SocketOptions; } From 6ffa94cda5b88a9cdefeb8a680c591e8e0c27439 Mon Sep 17 00:00:00 2001 From: Larry Gadea Date: Sun, 25 Nov 2018 20:36:20 -0500 Subject: [PATCH 116/174] [puppeteer] fix v1.10.0 definition of waitForTarget hello! i'm using the fancy new waitForTarget and the definition appears to be slightly off. `options` is optional and the return is a `Target` Promise, not `void`. looking at the `BrowserContext` version, it's the same problem due to the new `Timeoutable` changes made in this recent version. i changed the one definition locally and the world did not seem to explode. i'm using Github's nasty PR generator, let me know if you'd prefer i edit this with the template. thanks! --- types/puppeteer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index bfd14d9c35..cbb31f2fd0 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -1715,7 +1715,7 @@ export interface Page extends EventEmitter, FrameBase { } export interface TargetAwaiter { - waitForTarget(predicate: (target: Target) => boolean, options: Timeoutable): Promise; + waitForTarget(predicate: (target: Target) => boolean, options?: Timeoutable): Promise; } /** A Browser is created when Puppeteer connects to a Chromium instance, either through puppeteer.launch or puppeteer.connect. */ From bcd33769d53c79fc0840b4e8900e08d1cf22d878 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Mon, 26 Nov 2018 15:43:36 +0900 Subject: [PATCH 117/174] Fix abuse of generic type --- types/vfile/index.d.ts | 24 ++++++++++-------------- types/vfile/vfile-tests.ts | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/types/vfile/index.d.ts b/types/vfile/index.d.ts index 2ef3b03f19..792644dacc 100644 --- a/types/vfile/index.d.ts +++ b/types/vfile/index.d.ts @@ -10,26 +10,25 @@ import * as Unist from 'unist'; declare namespace vfile { - type Contents = string | Buffer; + type VFileContents = string | Buffer; interface NodeWithPosition extends Unist.Node { position: Unist.Position; [key: string]: any; } - interface VFileParamsBase { - data?: D; - contents?: Contents; + interface VFileOptions { + contents?: VFileContents; path?: string; basename?: string; stem?: string; extname?: string; dirname?: string; cwd?: string; + data?: any; + [key: string]: any; } - type VFileParams = VFileParamsBase & C; - /** * File-related message describing something at certain position. */ @@ -102,12 +101,11 @@ declare namespace vfile { */ type ToString = (encoding?: BufferEncoding) => string; - interface VFileBase { + interface VFile { /** * @param options If `options` is `string` or `Buffer`, treats it as `{contents: options}`. If `options` is a `VFile`, returns it. All other options are set on the newly created `vfile`. */ - (input?: Contents): VFile; - (input?: VFile | VFileParams): VFile; + (input?: VFileContents | F | VFileOptions): F; message: Message; fail: Fail; info: Info; @@ -119,7 +117,7 @@ declare namespace vfile { * Place to store custom information. * It's OK to store custom data directly on the `vfile`, moving it to `data` gives a little more privacy. */ - data: C['data']; + data: any; /** * List of messages associated with the file. */ @@ -127,7 +125,7 @@ declare namespace vfile { /** * Raw value. */ - contents: Contents; + contents: VFileContents; /** * Path of `vfile`. * Cannot be nullified. @@ -161,8 +159,6 @@ declare namespace vfile { cwd: string; toString: ToString; } - - type VFile = VFileBase & C; } /** @@ -170,6 +166,6 @@ declare namespace vfile { * Path related properties are set in the following order (least specific to most specific): `history`, `path`, `basename`, `stem`, `extname`, `dirname`. * It’s not possible to set either `dirname` or `extname` without setting either `history`, `path`, `basename`, or `stem` as well. */ -declare const vfile: vfile.VFile<{}>; +declare const vfile: vfile.VFile; export = vfile; diff --git a/types/vfile/vfile-tests.ts b/types/vfile/vfile-tests.ts index 0b19246ae8..4d146237b1 100644 --- a/types/vfile/vfile-tests.ts +++ b/types/vfile/vfile-tests.ts @@ -1,4 +1,4 @@ -import vfile = require("vfile"); +import vfile = require('vfile'); import * as Unist from 'unist'; // Instantiation @@ -7,21 +7,30 @@ vfile('string'); vfile(Buffer.from('string')); vfile(vfile()); vfile({ stem: 'readme', extname: '.md' }); -vfile({ custom: 'data' }); try { vfile({ extname: '.md' }); } catch (e) { console.log('Error: set extname without path'); } -const file = vfile<{custom: string, data: {custom: number}}>({ +interface CustomVFile extends vfile.VFile { + custom: string; + data: { + custom: number; + }; +} + +const file = vfile({ path: '~/example.txt', contents: 'Alpha *braavo* charlie.', custom: 'Custom tango', data: { custom: 12345 - }, + } }); +const customIsString: string = file.custom; +const dataCustomIsNumber: number = file.data.custom; +const copiedFile: CustomVFile = vfile(file); file.path; // => '~/example.txt' file.dirname; // => '~' From 66d08e2f06fc28506c6d1a9e7fc86e524d43f0a3 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Mon, 26 Nov 2018 15:44:03 +0900 Subject: [PATCH 118/174] Include instruction how to extend vfiles --- types/vfile/readme.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 types/vfile/readme.md diff --git a/types/vfile/readme.md b/types/vfile/readme.md new file mode 100644 index 0000000000..349503cef8 --- /dev/null +++ b/types/vfile/readme.md @@ -0,0 +1,32 @@ +## VFile typescript Docs + +Below are some examples of how to use these Definitions.
+Scenarios where the Typescript code is identical to plain Javascript code are omitted. + +### Extending VFile + +```ts +import vfile = require('vfile') + +// 1. Define extended vfile interface +interface CustomVFile extends vfile.VFile { + custom: string; + data: { + custom: number; + }; +} + +// 2. Provide the extended interface to generic type parameter +// So it can be used for return value +const file: CustomVFile = vfile({ + path: '~/example.txt', + contents: 'Alpha *braavo* charlie.', + custom: 'Custom tango', + data: { + custom: 12345 + } +}); + +// vfile recognize extended VFile values. So it will return same type. +const copiedFile: CustomVFile = vfile(file); +``` From f6a42a5032d678cfe4c210e72eb5da78107a2bd7 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Mon, 26 Nov 2018 15:49:41 +0900 Subject: [PATCH 119/174] Update vfile version --- types/vfile/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vfile/index.d.ts b/types/vfile/index.d.ts index 792644dacc..ce8f1dce38 100644 --- a/types/vfile/index.d.ts +++ b/types/vfile/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for VFile 2.2 +// Type definitions for VFile 3.0 // Project: https://github.com/vfile/vfile // Definitions by: bizen241 // Junyoung Choi From 3ac5fe40247b925b313457259f42b486130e8a0d Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Mon, 26 Nov 2018 15:51:15 +0900 Subject: [PATCH 120/174] Update vfile-location too because it is using vfile --- types/vfile-location/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/vfile-location/index.d.ts b/types/vfile-location/index.d.ts index e8ad37bc32..b991528c7e 100644 --- a/types/vfile-location/index.d.ts +++ b/types/vfile-location/index.d.ts @@ -1,12 +1,13 @@ // Type definitions for vfile-location 2.0 // Project: https://github.com/vfile/vfile-location // Definitions by: Ika +// Junyoung Choi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 import * as VFile from "vfile"; -declare function vfileLocation(vfile: string | VFile.VFile<{}>): vfileLocation.Location; +declare function vfileLocation(vfile: string | VFile.VFile): vfileLocation.Location; declare namespace vfileLocation { interface Location { From 264964b9a8676d3e81204914927fd81d1e439e6c Mon Sep 17 00:00:00 2001 From: obedm503 Date: Mon, 26 Nov 2018 01:10:58 -0600 Subject: [PATCH 121/174] Add `onError` prop to `IntlProvider` --- types/react-intl/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 17e738bb2a..a4cb8be9b5 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -9,6 +9,7 @@ // Krister Kari // Martin Raedlinger // Kanitkorn Sujautra +// obedm503 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -46,6 +47,7 @@ declare namespace ReactIntl { messages: React.Requireable; defaultLocale: React.Requireable; defaultFormats: React.Requireable; + onError?: (error: string) => void } interface IntlFormat { @@ -78,6 +80,7 @@ declare namespace ReactIntl { defaultLocale: string; defaultFormats: any; now(): number; + onError: (error: string) => void; } interface InjectedIntlProps { From a2f88a9bc1295aa2c58700065536ac055b58308a Mon Sep 17 00:00:00 2001 From: obedm503 Date: Mon, 26 Nov 2018 01:11:36 -0600 Subject: [PATCH 122/174] Add usage of `onError` prop --- types/react-intl/react-intl-tests.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index b3b23bb38f..74da23a12a 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -401,7 +401,15 @@ class TestApp extends React.Component { hello: "Hello, {name}!" }; return ( - + console.error(error)} + > From 879ff2682e6118dcead7d40021087bbaa9b5bd3d Mon Sep 17 00:00:00 2001 From: obedm503 Date: Mon, 26 Nov 2018 01:19:58 -0600 Subject: [PATCH 123/174] Increase minor version --- types/react-intl/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index a4cb8be9b5..3dc7e9dc59 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -11,7 +11,7 @@ // Kanitkorn Sujautra // obedm503 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.9 declare namespace ReactIntl { type DateSource = Date | string | number; From f69a5047986aed0669f04d8172cc5bbba2d6c4a8 Mon Sep 17 00:00:00 2001 From: obedm503 Date: Mon, 26 Nov 2018 01:36:23 -0600 Subject: [PATCH 124/174] cleanup and test --- types/react-intl/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 3dc7e9dc59..2c25a55b1f 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -47,7 +47,7 @@ declare namespace ReactIntl { messages: React.Requireable; defaultLocale: React.Requireable; defaultFormats: React.Requireable; - onError?: (error: string) => void + onError: React.Requireable; } interface IntlFormat { @@ -80,7 +80,7 @@ declare namespace ReactIntl { defaultLocale: string; defaultFormats: any; now(): number; - onError: (error: string) => void; + onError(error: string): void; } interface InjectedIntlProps { @@ -200,6 +200,7 @@ declare namespace ReactIntl { defaultFormats?: any; textComponent?: any; initialNow?: any; + onError?: (error: string) => void; } } From 4cfb90807578b054644d81453ca145b90df00c86 Mon Sep 17 00:00:00 2001 From: Alexandre Piel Date: Mon, 26 Nov 2018 09:14:35 +0100 Subject: [PATCH 125/174] make jest ProvidesCallback optinal --- types/jest/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 2b378a6048..d434b5e198 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -251,7 +251,7 @@ declare namespace jest { * @param fn The function for your test * @param timeout The timeout for an async function test */ - (name: string, fn: ProvidesCallback, timeout?: number): void; + (name: string, fn?: ProvidesCallback, timeout?: number): void; /** * Only runs this test in the current file. */ From 9d01bdd867de647f6469fd6e5e830295e8585c65 Mon Sep 17 00:00:00 2001 From: John Plusje Date: Mon, 26 Nov 2018 15:24:11 +0100 Subject: [PATCH 126/174] Add declarations for stoppable 1.1 --- types/stoppable/index.d.ts | 9 +++++++-- types/stoppable/stoppable-tests.ts | 11 +++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/types/stoppable/index.d.ts b/types/stoppable/index.d.ts index 395dd828c8..b15444c7ba 100644 --- a/types/stoppable/index.d.ts +++ b/types/stoppable/index.d.ts @@ -1,11 +1,16 @@ -// Type definitions for stoppable 1.0 +// Type definitions for stoppable 1.1 // Project: https://github.com/hunterloftis/stoppable // Definitions by: Eric Byers +// John Plusjé // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// import { Server } from 'http'; -declare function stoppable(server: Server, grace?: number): Server; +interface StoppableServer extends Server { + stop(callback?: (e: Error, gracefully: boolean) => void): void; +} + +declare function stoppable(server: Server, grace?: number): StoppableServer; export = stoppable; diff --git a/types/stoppable/stoppable-tests.ts b/types/stoppable/stoppable-tests.ts index 84cf826bef..89ebf64f6d 100644 --- a/types/stoppable/stoppable-tests.ts +++ b/types/stoppable/stoppable-tests.ts @@ -1,8 +1,11 @@ import * as http from 'http'; import stoppable = require('stoppable'); -const server: http.Server = stoppable(http.createServer()); -server.close(); +const server = stoppable(http.createServer()); +server.stop(); -const server2: http.Server = stoppable(http.createServer(), 10000); -server2.close(); +const server2 = stoppable(http.createServer(), 10000); +server2.stop(); + +const server3 = stoppable(http.createServer()); +server.stop((err, gracefully) => {}); From 5a89441def4da6974049400ae5733aa398400db4 Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 26 Nov 2018 07:31:17 -0800 Subject: [PATCH 127/174] Updates --- types/highcharts/highcharts-more.d.ts | 5 -- types/highcharts/highstock.d.ts | 8 --- types/highcharts/index.d.ts | 52 +++++++++---------- types/highcharts/modules/boost.d.ts | 5 -- types/highcharts/modules/drilldown.d.ts | 5 -- types/highcharts/modules/exporting.d.ts | 5 -- types/highcharts/modules/map/index.d.ts | 5 -- .../modules/no-data-to-display.d.ts | 5 -- .../highcharts/modules/offline-exporting.d.ts | 5 -- 9 files changed, 26 insertions(+), 69 deletions(-) diff --git a/types/highcharts/highcharts-more.d.ts b/types/highcharts/highcharts-more.d.ts index 630dbb5622..aaa2da832c 100644 --- a/types/highcharts/highcharts-more.d.ts +++ b/types/highcharts/highcharts-more.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highcharts 4.2.6 -// Project: http://www.highcharts.com/ -// Definitions by: Maciej Suchecki -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import * as Highcharts from "highcharts"; declare function HighchartsMore(H: Highcharts.Static): Highcharts.Static; diff --git a/types/highcharts/highstock.d.ts b/types/highcharts/highstock.d.ts index cc92bebe36..1b57d91a7d 100644 --- a/types/highcharts/highstock.d.ts +++ b/types/highcharts/highstock.d.ts @@ -1,11 +1,3 @@ -// Type definitions for Highstock 2.1.6 -// Project: http://www.highcharts.com/ - -// Definitions by: David Deutsch -// Dave Baumann -// Richard Ison -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import * as Highcharts from "highcharts"; declare namespace Highstock { diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index 58154954a3..7f0f15591b 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + minFontSize: number | null; /** * The name of the series as shown in the legend, tooltip etc. */ diff --git a/types/highcharts/modules/boost.d.ts b/types/highcharts/modules/boost.d.ts index e0a3480f95..2e4da45b13 100644 --- a/types/highcharts/modules/boost.d.ts +++ b/types/highcharts/modules/boost.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highcharts 4.2.6 (boost module) -// Project: http://www.highcharts.com/ -// Definitions by: Daniel Martin -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import { Static } from "highcharts"; declare function HighchartsBoost(H: Static): Static; diff --git a/types/highcharts/modules/drilldown.d.ts b/types/highcharts/modules/drilldown.d.ts index adf9bae6f8..46115cb4ad 100644 --- a/types/highcharts/modules/drilldown.d.ts +++ b/types/highcharts/modules/drilldown.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highcharts Drilldown 4.2.7 -// Project: http://www.highcharts.com/ -// Definitions by: Konstantin Rohde -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import { Static } from "highcharts"; declare function HighchartsDrilldown(H: Static): Static; diff --git a/types/highcharts/modules/exporting.d.ts b/types/highcharts/modules/exporting.d.ts index b4b0124a66..18f9615d41 100644 --- a/types/highcharts/modules/exporting.d.ts +++ b/types/highcharts/modules/exporting.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highcharts 4.2.6 (exporting module) -// Project: http://www.highcharts.com/ -// Definitions by: Maciej Suchecki -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import { Static } from "highcharts"; declare function HighchartsExporting(H: Static): Static; diff --git a/types/highcharts/modules/map/index.d.ts b/types/highcharts/modules/map/index.d.ts index ecf553945b..12b2ca0a7e 100644 --- a/types/highcharts/modules/map/index.d.ts +++ b/types/highcharts/modules/map/index.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highmaps 4.2.7 -// Project: http://www.highcharts.com/products/highmaps -// Definitions by: Albert Ozimek -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import * as highcharts from 'highcharts'; import * as geojson from 'geojson'; diff --git a/types/highcharts/modules/no-data-to-display.d.ts b/types/highcharts/modules/no-data-to-display.d.ts index f79ce249d1..bb8d406e03 100644 --- a/types/highcharts/modules/no-data-to-display.d.ts +++ b/types/highcharts/modules/no-data-to-display.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highcharts No Data to Display 4.2.7 -// Project: http://www.highcharts.com/ -// Definitions by: Andrey Zolotin , Rowell Heria -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import { Static } from "highcharts"; declare module "highcharts" { diff --git a/types/highcharts/modules/offline-exporting.d.ts b/types/highcharts/modules/offline-exporting.d.ts index ee38e1c91b..5f536a8588 100644 --- a/types/highcharts/modules/offline-exporting.d.ts +++ b/types/highcharts/modules/offline-exporting.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Highcharts 4.2.6 (offline exporting module) -// Project: http://www.highcharts.com/ -// Definitions by: Daniel Martin -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import { Static } from "highcharts"; declare function HighchartsOfflineExporting(H: Static): Static; From f3a20e8a3e339390d03f3fbc89e48a49673bfadb Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 26 Nov 2018 07:59:33 -0800 Subject: [PATCH 128/174] 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, From 84e48532798da9e4488bf047e7595ff8996a7380 Mon Sep 17 00:00:00 2001 From: Alex Lipatov Date: Mon, 26 Nov 2018 11:56:22 -0500 Subject: [PATCH 129/174] Use swagger-parser's namespace as type instead of defining our own. --- types/swagger-express-middleware/index.d.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/types/swagger-express-middleware/index.d.ts b/types/swagger-express-middleware/index.d.ts index 4d83cebfb0..d6b5789e3e 100644 --- a/types/swagger-express-middleware/index.d.ts +++ b/types/swagger-express-middleware/index.d.ts @@ -32,6 +32,9 @@ app.listen(8000, function () { declare module "swagger-express-middleware" { import { Application, Router, RequestHandler, Request, Response } from "express"; + import * as parser from "swagger-parser"; + + type SwaggerParser = typeof parser.SwaggerParser; let s: s.SwaggerMiddlewareConstructor; @@ -363,11 +366,6 @@ declare module "swagger-express-middleware" { externalDocs?: ExternalDocumentationObject } - export interface SwaggerParser { - $refs: any - schema: SwaggerObject - } - type MimeTypes = string[] export interface InfoObject { From f69313ade8615953ace3f73eeb27bf0480a9166a Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 26 Nov 2018 10:01:54 -0800 Subject: [PATCH 130/174] Remove no-angle-bracket-type-assertion issues --- types/highcharts/test/highstock.ts | 2 +- types/highcharts/test/index.ts | 240 ++++++++++++++--------------- 2 files changed, 121 insertions(+), 121 deletions(-) diff --git a/types/highcharts/test/highstock.ts b/types/highcharts/test/highstock.ts index f1a464f491..e80e0cb7a3 100644 --- a/types/highcharts/test/highstock.ts +++ b/types/highcharts/test/highstock.ts @@ -66,7 +66,7 @@ $(() => { } }, - series: [ { + series: [{ name: 'USD to EUR', data: someData, lineColor: "blue" diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index c1fd8b5676..2bb429ec7a 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -40,12 +40,12 @@ function originalTests() { renderTo: "container" }, xAxis: {}, - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], description: "foo", type: "line", allowPointSelect: true - }] + } as Highcharts.LineChartSeriesOptions] }); chart1.addSeries({ @@ -61,7 +61,7 @@ function originalTests() { height: 400, spacingRight: 20 }, - xAxis: [ { + xAxis: [{ description: 'x-foo', min: 1, max: 1000, @@ -71,7 +71,7 @@ function originalTests() { gridLineWidth: 1, type: 'logarithmic' }], - yAxis: [ { + yAxis: [{ description: 'y-foo', min: 1, max: 1000, @@ -85,7 +85,7 @@ function originalTests() { legend: { enabled: false }, - series: [ { + series: [{ data: [ [550, 870], [738, 362], [719, 711], [547, 665], [595, 197], [332, 144], [581, 555], [196, 862], [6, 837], [400, 924], [888, 148], [785, 730], @@ -114,12 +114,12 @@ function originalTests() { renderTo: "container" }, xAxis: {}, - series: [ { + series: [{ data: [[1, 1, 2], [2, 2, 3], [3, 2, 3]], description: "foo", type: "columnrange", allowPointSelect: true - }] + } as Highcharts.ColumnRangeChartSeriesOptions] }); const chart4 = new Highcharts.Chart({ @@ -127,12 +127,12 @@ function originalTests() { renderTo: "container" }, xAxis: {}, - series: [ { + series: [{ data: [["01-01-2018", 1, 2], ["02-01-2018", 2, 3], ["03-01-2018", 2, 3]], description: "column range data", type: "columnrange", allowPointSelect: true - }] + } as Highcharts.ColumnRangeChartSeriesOptions] }); const div: HTMLDivElement = null as any; @@ -146,7 +146,7 @@ function originalTests() { }, xAxis: [{ }], - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }] }; @@ -164,47 +164,47 @@ function originalTests() { const renderToIdChart = new Highcharts.Chart("container", { xAxis: {}, - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], type: "line", allowPointSelect: true - }] + } as Highcharts.LineChartSeriesOptions] }); const renderToElementChart = new Highcharts.Chart(div, { xAxis: {}, - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], type: "line", allowPointSelect: true - }] + } as Highcharts.LineChartSeriesOptions] }); const createWithFunction = Highcharts.chart({ xAxis: {}, - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], type: "line", allowPointSelect: true - }] + } as Highcharts.LineChartSeriesOptions] }); const createWithFunctionRenderToId = Highcharts.chart("container", { xAxis: {}, - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], type: "line", allowPointSelect: true - }] + } as Highcharts.LineChartSeriesOptions] }); const createWithFunctionRenderToElement = Highcharts.chart(div, { xAxis: {}, - series: [ { + series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], type: "line", allowPointSelect: true - }] + } as Highcharts.LineChartSeriesOptions] }); } @@ -245,7 +245,7 @@ function test_ChartOptions() { duration: 500, easing: "linear" }, - backgroundColor: { + backgroundColor: { linearGradient: { x1: 0, y1: 0, @@ -261,7 +261,7 @@ function test_ChartOptions() { colorCount: 42, defaultSeriesType: "deprecated", description: "an arbitrary description", - events: { + events: { addSeries: () => { }, afterPrint: () => { }, beforePrint: () => { }, @@ -281,21 +281,21 @@ function test_ChartOptions() { marginLeft: 10, marginRight: 10, marginTop: 10, - options3d: { + options3d: { alpha: 20, beta: 20, depth: 50, enabled: true, frame: { - back: { + back: { color: "black", size: 2 }, - bottom: { + bottom: { color: "black", size: 2 }, - side: { + side: { color: "black", size: 2 } @@ -309,7 +309,7 @@ function test_ChartOptions() { plotBackgroundImage: "http://image.url/image.jpg", plotBorderColor: "grey", plotBorderWidth: 5, - plotShadow: { + plotShadow: { color: "magenta", offsetX: 10, offsetY: 10, @@ -319,15 +319,15 @@ function test_ChartOptions() { polar: true, reflow: false, renderTo: "elementId", - resetZoomButton: { - position: { + resetZoomButton: { + position: { align: "left", verticalAlign: "top", x: 5, y: 5 }, relativeTo: "chart", - theme: { + theme: { display: "hidden", fill: "black", stroke: "white", @@ -394,7 +394,7 @@ function test_ChartOptions() { }); // animation example - $('#container').highcharts( { + $('#container').highcharts({ chart: { animation: { duration: 1500, @@ -479,7 +479,7 @@ function test_ChartOptions() { chart: { events: { addSeries() { - const label = ( this).renderer.label('A series was added, about to redraw chart', 100, 120) + const label = (this as Highcharts.ChartObject).renderer.label('A series was added, about to redraw chart', 100, 120) .attr({ fill: Highcharts.getOptions().colors[0], padding: 10, @@ -729,21 +729,21 @@ function test_Data() { } }, series: [ - { + { lineWidth: 1 }, - { + { type: 'areaspline', color: '#c4392d', negativeColor: '#5679c4', fillOpacity: 0.5 - } + } as Highcharts.AreaSplineChartSeriesOptions ] }); // limited data example $('#container').highcharts({ - data: { + data: { csv: document.getElementById('csv').innerHTML, startRow: 114, endRow: 134, @@ -753,7 +753,7 @@ function test_Data() { xAxis: { allowDecimals: false }, - series: [ { + series: [{ name: 'Annual mean' }] }); @@ -784,14 +784,14 @@ function test_Drilldown() { type: 'category' }, plotOptions: { - series: { + series: { borderWidth: 0, dataLabels: { enabled: true } - } + } as Highcharts.ColumnChart }, - series: [ { + series: [{ name: '2010', data: [{ name: 'Republican', @@ -806,7 +806,7 @@ function test_Drilldown() { y: 4, drilldown: 'other-2010' }] - }, { + }, { name: '2014', data: [{ name: 'Republican', @@ -823,7 +823,7 @@ function test_Drilldown() { }] }], drilldown: { - series: [ { + series: [{ id: 'republican-2010', data: [ ['East', 4], @@ -831,7 +831,7 @@ function test_Drilldown() { ['North', 1], ['South', 4] ] - }, { + }, { id: 'democrats-2010', data: [ ['East', 6], @@ -839,7 +839,7 @@ function test_Drilldown() { ['North', 2], ['South', 4] ] - }, { + }, { id: 'other-2010', data: [ ['East', 2], @@ -847,7 +847,7 @@ function test_Drilldown() { ['North', 3], ['South', 2] ] - }, { + }, { id: 'republican-2014', data: [ ['East', 2], @@ -855,7 +855,7 @@ function test_Drilldown() { ['North', 1], ['South', 7] ] - }, { + }, { id: 'democrats-2014', data: [ ['East', 4], @@ -863,7 +863,7 @@ function test_Drilldown() { ['North', 5], ['South', 3] ] - }, { + }, { id: 'other-2014', data: [ ['East', 7], @@ -881,14 +881,14 @@ function test_Drilldown() { type: 'column' }, plotOptions: { - series: { + series: { borderWidth: 0, dataLabels: { enabled: true } - } + } as Highcharts.ColumnChart }, - series: [ { + series: [{ name: 'Things', colorByPoint: true, data: [{ @@ -903,7 +903,7 @@ function test_Drilldown() { name: 'Cars', y: 4 }] - }], + } as Highcharts.ColumnChartSeriesOptions], drilldown: { activeAxisLabelStyle: { textDecoration: 'none', @@ -976,7 +976,7 @@ function test_Exporting() { series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }], - exporting: { + exporting: { error: () => { console.log('succesfully asserted exporting.error'); }, @@ -987,7 +987,7 @@ function test_Exporting() { chartOptions: { subtitle: null } - } + } as Highcharts.ExportingOptions }); } @@ -1113,12 +1113,12 @@ function test_AreaOptions() { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, plotOptions: { - series: { + series: { fillColor: { linearGradient: [0, 0, 0, 300], stops: [ [0, Highcharts.getOptions().colors[0]], - [1, ( Highcharts.Color(Highcharts.getOptions().colors[0])).setOpacity(0).get('rgba')] + [1, ((Highcharts.Color(Highcharts.getOptions().colors[0])) as Highcharts.Gradient).setOpacity(0).get('rgba')] ] }, fillOpacity: 0.1, @@ -1129,7 +1129,7 @@ function test_AreaOptions() { threshold: 100, trackByArea: true, stickyTracking: false // to show the difference in tracking - } + } as Highcharts.AreaChartSeriesOptions }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] @@ -1146,7 +1146,7 @@ function test_AreaRange() { type: "arearange", zoomType: 'x' }, - series: [ { + series: [{ data: (((arr: number[], len: number) => { for (let i = 0; i < len; i = i + 1) { arr.push(i); @@ -1191,7 +1191,7 @@ function test_AreaRange() { legend: { enabled: false }, - series: [ { + series: [{ name: 'Temperatures', data, dataLabels: { @@ -1199,7 +1199,7 @@ function test_AreaRange() { yHigh: 20, yLow: -20 } - }] + } as Highcharts.AreaRangeChartSeriesOptions] }); }); } @@ -1215,7 +1215,7 @@ function test_Bar() { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, plotOptions: { - series: { + series: { borderColor: '#303030', borderRadius: 5, borderWidth: 2, @@ -1240,7 +1240,7 @@ function test_Bar() { } } } - } + } as Highcharts.BarChartSeriesOptions }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] @@ -1274,7 +1274,7 @@ function test_Bar() { // grouping example Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, (color: string) => { - return ( Highcharts.Color(color)) + return (Highcharts.Color(color) as Highcharts.Gradient) .setOpacity(0.5) .get('rgba'); }); @@ -1309,19 +1309,19 @@ function test_Bar() { shadow: false } }, - series: [ { + series: [{ name: 'Tokyo', data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], pointPadding: 0 - }, { + } as Highcharts.BarChartSeriesOptions, { name: 'New York', data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3], pointPadding: 0.1 - }, { + }, { name: 'London', data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2], pointPadding: 0.2 - }, { + }, { name: 'Berlin', data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1], pointPadding: 0.3 @@ -1407,7 +1407,7 @@ function test_Bubble() { maxSize: 50 } }, - series: [ { + series: [{ data: [ [9, 81, 13], [98, 5, 39], @@ -1430,7 +1430,7 @@ function test_Bubble() { zMin: 0, zMax: 100, zThreshold: 0 - }] + } as Highcharts.BubbleChartSeriesOptions] }); // size by absolute value example @@ -1444,7 +1444,7 @@ function test_Bubble() { subtitle: { text: 'Size is computed by absolute value on negative bubbles' }, - series: [ { + series: [{ data: [ [-5, 0, -5], [-4, 0, -4], @@ -1460,7 +1460,7 @@ function test_Bubble() { ], sizeByAbsoluteValues: true, negativeColor: '#FF0000' - }] + } as Highcharts.BubbleChartSeriesOptions] }); } @@ -1479,7 +1479,7 @@ function test_ColumnCrispFalse() { } return arr; }; - const chart = new Highcharts.Chart( { + const chart = new Highcharts.Chart({ title: { text: 'Crisp columns are disabled' }, @@ -1527,7 +1527,7 @@ function test_ErrorBar() { tooltip: { shared: true }, - series: [ { + series: [{ name: 'Temperature', type: 'spline', data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6], @@ -1537,7 +1537,7 @@ function test_ErrorBar() { tooltip: { pointFormat: ' {series.name} : {point.y:.1f}°C
' } - }, { + } as Highcharts.SplineChartSeriesOptions, { color: '#FF0000', name: 'Temperature error', type: 'errorbar', @@ -1549,7 +1549,7 @@ function test_ErrorBar() { stemDashStyle: "Solid", stemWidth: 3, whiskerLength: 0 - }] + } as Highcharts.ErrorBarChartSeriesOptions] }); } @@ -1568,7 +1568,7 @@ function test_FindNearestPointBy() { } }, - series: [ { + series: [{ findNearestPointBy: 'x', // Hover at [3.5, 6] to demo x-dimension search // Compare to Series 2 behavior at [5.5, 3] @@ -1584,7 +1584,7 @@ function test_FindNearestPointBy() { [6, 6], [7, 6] ] - }, { + } as Highcharts.IndividualSeriesOptions, { findNearestPointBy: 'xy', // Hover at [1, 4] to demo xy-dimension search. // Useful when having multiple points on the same x-value. @@ -1600,7 +1600,7 @@ function test_FindNearestPointBy() { [6, 3], [7, 3] ] - }] + } as Highcharts.IndividualSeriesOptions] }); } @@ -1618,7 +1618,7 @@ function test_Funnel() { x: -50 }, plotOptions: { - series: { + series: { dataLabels: { enabled: true, format: ' {point.name} ({point.y:,.0f})', @@ -1630,7 +1630,7 @@ function test_Funnel() { reversed: false, height: "10%", width: 100 - } + } as Highcharts.FunnelChartSeriesOptions }, legend: { enabled: false @@ -1701,10 +1701,10 @@ function test_Gauge() { } } }, - series: [ { + series: [{ data: [80], overshoot: 5 - }] + } as Highcharts.GaugeChartSeriesOptions] }); } @@ -1757,14 +1757,14 @@ function test_HeatMap() { ], min: -5 }, - series: [ { + series: [{ borderWidth: 0, colsize: 24 * 36e5, // one day tooltip: { headerFormat: 'Temperature
', pointFormat: '{point.x:%e %b, %Y} {point.y}:00: {point.value} ℃ ' } - }] + } as Highcharts.HeatMapSeriesOptions] }); } @@ -1779,17 +1779,17 @@ function test_Line() { xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, - series: [ { + series: [{ data: [1, 2, 3, 4, null, 6, 7, null, 9], step: 'right', name: 'Right', linecap: 'round' - }, { + } as Highcharts.LineChartSeriesOptions, { data: [5, 6, 7, 8, null, 10, 11, null, 13], step: 'center', name: 'Center', linecap: 'round' - }, { + }, { data: [9, 10, 11, 12, null, 14, 15, null, 17], step: 'left', name: 'Left', @@ -1829,7 +1829,7 @@ function test_Pie() { } } }, - series: [ { + series: [{ name: "Brands", colorByPoint: true, data: [{ @@ -1853,7 +1853,7 @@ function test_Pie() { name: "Proprietary or Undetectable", y: 0.2 }] - }] + } as Highcharts.PieChartSeriesOptions] }); // semi circle @@ -1888,7 +1888,7 @@ function test_Pie() { center: ['50%', '75%'] } }, - series: [ { + series: [{ type: 'pie', name: 'Browser share', innerSize: '50%', @@ -2161,10 +2161,10 @@ function test_Waterfall() { } function test_AccessibilityOptions() { - const accessibilityOptions: Highcharts.AccessibilityOptions = { + const accessibilityOptions: Highcharts.AccessibilityOptions = { describeSingleSeries: true, enabled: true, - keyboardNavigation: { + keyboardNavigation: { enabled: true, skipNullPoints: true }, @@ -2177,7 +2177,7 @@ function test_AccessibilityOptions() { seriesDescriptionFormatter: () => { } }; - const chart = new Highcharts.Chart( { + const chart = new Highcharts.Chart({ accessibility: accessibilityOptions }); } @@ -2435,31 +2435,31 @@ function test_AxisObject() { axis.toPixels(10, true); axis.toValue(10); axis.toValue(10, true); - axis.update( {}); - axis.update( {}, true); + axis.update({}); + axis.update({}, true); } function test_ChartObject() { const chart = $("#container").highcharts(); - chart.addAxis( {}); - chart.addAxis( {}, true); - chart.addAxis( {}, true, false); - chart.addAxis( {}, true, true, false); - chart.addAxis( {}, true, true, { duration: 50 }); - chart.addSeries( {}); - chart.addSeries( {}, false); - chart.addSeries( {}, false, false); - chart.addSeries( {}, false, { duration: 50 }); - chart.addSeriesAsDrilldown( {}, {}); + chart.addAxis({}); + chart.addAxis({}, true); + chart.addAxis({}, true, false); + chart.addAxis({}, true, true, false); + chart.addAxis({}, true, true, { duration: 50 }); + chart.addSeries({}); + chart.addSeries({}, false); + chart.addSeries({}, false, false); + chart.addSeries({}, false, { duration: 50 }); + chart.addSeriesAsDrilldown({}, {}); const container = chart.container; console.log(container.id); chart.destroy(); chart.drillUp(); - chart.exportChart( {}, {}); - chart.exportChartLocal( {}, {}); + chart.exportChart({}, {}); + chart.exportChartLocal({}, {}); const object = chart.get('axisIdOrSeriesIdOrPointId'); const svg1 = chart.getSVG(); - const svg2 = chart.getSVG( {}); + const svg2 = chart.getSVG({}); const selectedPoints = chart.getSelectedPoints(); const selectedSeries = chart.getSelectedSeries(); chart.hideLoading(); @@ -2480,11 +2480,11 @@ function test_ChartObject() { const firstXAxis = chart.xAxis[0]; const firstYAxis = chart.yAxis[0]; const legend = chart.legend; - chart.update( {}); - chart.update( {}, true); - chart.update( {}, true, true); - chart.update( {}, true, true, true); - chart.update( {}, true, true, { + chart.update({}); + chart.update({}, true); + chart.update({}, true, true); + chart.update({}, true, true, true); + chart.update({}, true, true, { duration: 3000, }); } @@ -2564,7 +2564,7 @@ function test_NumericSymbolMagnitude() { } function test_PaneBackground() { - const pane = { + const pane = { backgroundColor: 'blue', borderColor: 'white', borderWidth: 5, @@ -2576,7 +2576,7 @@ function test_PaneBackground() { } function test_PointObject() { - const point = $('#container').highcharts().get('point1'); + const point = $('#container').highcharts().get('point1') as Highcharts.PointObject; const category = point.category; const percentage = point.percentage; point.index; @@ -2608,7 +2608,7 @@ function test_RendererObject() { const renderer = $('#container').highcharts().renderer; renderer.arc(0, 0, 20, 10, 0, Math.PI); renderer.circle(0, 0, 100); - renderer.definition( {}); + renderer.definition({}); renderer.g('groupName'); renderer.image('http://source', 20, 20, 100, 100); renderer.label('Label', 200, 100, 'rect', 0, 0, false, false, 'class'); @@ -2618,15 +2618,15 @@ function test_RendererObject() { } function test_ResponsiveOptions() { - const responsiveOptions: Highcharts.ResponsiveOptions = { + const responsiveOptions: Highcharts.ResponsiveOptions = { rules: [ - { - chartOptions: { + { + chartOptions: { chart: { description: 'just a test' } }, - condition: { + condition: { callback: () => { }, maxHeight: 420, maxWidth: 420, @@ -2643,7 +2643,7 @@ function test_ResponsiveOptions() { } function test_SeriesObject() { - const series = $('#container').highcharts().get('series1'); + const series = $('#container').highcharts().get('series1') as Highcharts.SeriesObject; series.addPoint(0); series.addPoint([0, 0]); series.addPoint({}); From 5b7fc62ce75b058b26c601a0021bb0a89d30d411 Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 26 Nov 2018 10:12:10 -0800 Subject: [PATCH 131/174] Small fixes from more issues. --- types/highcharts/test/highstock.ts | 2 +- types/highcharts/test/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/highcharts/test/highstock.ts b/types/highcharts/test/highstock.ts index e80e0cb7a3..af9de8d1f9 100644 --- a/types/highcharts/test/highstock.ts +++ b/types/highcharts/test/highstock.ts @@ -70,6 +70,6 @@ $(() => { name: 'USD to EUR', data: someData, lineColor: "blue" - }] + } as Highcharts.AreaRangeChartSeriesOptions] }); }); diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index 2bb429ec7a..e5c891b5ef 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -2450,7 +2450,7 @@ function test_ChartObject() { chart.addSeries({}, false); chart.addSeries({}, false, false); chart.addSeries({}, false, { duration: 50 }); - chart.addSeriesAsDrilldown({}, {}); + chart.addSeriesAsDrilldown({} as Highcharts.PointObject, {}); const container = chart.container; console.log(container.id); chart.destroy(); From 1fef27e8affcb1a8eb34fb7a1f9889d980f65baa Mon Sep 17 00:00:00 2001 From: juwar Date: Mon, 26 Nov 2018 10:20:33 -0800 Subject: [PATCH 132/174] Another one. --- types/highcharts/test/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index e5c891b5ef..1474ee7e9c 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -2637,7 +2637,7 @@ function test_ResponsiveOptions() { ] }; - const chart = new Highcharts.Chart( { + const chart = new Highcharts.Chart({ responsive: responsiveOptions }); } From d73f3efdcfadea4fb6100686286b53bf92be8275 Mon Sep 17 00:00:00 2001 From: dyniper Date: Tue, 20 Nov 2018 11:56:00 -0800 Subject: [PATCH 133/174] Add new partialBundledLanguages InitOptions --- types/i18next/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/i18next/index.d.ts b/types/i18next/index.d.ts index 84433c26ec..d2e0b4ee6b 100644 --- a/types/i18next/index.d.ts +++ b/types/i18next/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for i18next 11.9 +// Type definitions for i18next 12.1 // Project: http://i18next.com // Definitions by: Michael Ledin // Budi Irawan @@ -160,6 +160,12 @@ declare namespace i18next { */ resources?: Resource; + /** + * Allow initializing with bundled resources while using a backend to load non bundled ones. + * @default false + */ + partialBundledLanguages?: boolean; + /** * language to use (overrides language detection) * @default undefined From e3c335e16e88c7869c90ec2e4b942e3a176f6682 Mon Sep 17 00:00:00 2001 From: John Plusje Date: Mon, 26 Nov 2018 19:48:57 +0100 Subject: [PATCH 134/174] Add call to server.close() in order to show that http.Server is properly extended. Added a StoppableServer type for typing the created server instance. --- types/stoppable/index.d.ts | 8 +++++--- types/stoppable/stoppable-tests.ts | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/types/stoppable/index.d.ts b/types/stoppable/index.d.ts index b15444c7ba..1b30c5a995 100644 --- a/types/stoppable/index.d.ts +++ b/types/stoppable/index.d.ts @@ -7,10 +7,12 @@ /// import { Server } from 'http'; -interface StoppableServer extends Server { - stop(callback?: (e: Error, gracefully: boolean) => void): void; +declare namespace stoppable { + interface StoppableServer extends Server { + stop(callback?: (e: Error, gracefully: boolean) => void): void; + } } -declare function stoppable(server: Server, grace?: number): StoppableServer; +declare function stoppable(server: Server, grace?: number): stoppable.StoppableServer; export = stoppable; diff --git a/types/stoppable/stoppable-tests.ts b/types/stoppable/stoppable-tests.ts index 89ebf64f6d..930a2340bd 100644 --- a/types/stoppable/stoppable-tests.ts +++ b/types/stoppable/stoppable-tests.ts @@ -1,11 +1,12 @@ import * as http from 'http'; import stoppable = require('stoppable'); -const server = stoppable(http.createServer()); +const server: stoppable.StoppableServer = stoppable(http.createServer()); server.stop(); -const server2 = stoppable(http.createServer(), 10000); +const server2: stoppable.StoppableServer = stoppable(http.createServer(), 10000); server2.stop(); -const server3 = stoppable(http.createServer()); +const server3: stoppable.StoppableServer = stoppable(http.createServer()); server.stop((err, gracefully) => {}); +server.close(); From dac19ea9e5d43d976abce50f6302cd7df32ddbb7 Mon Sep 17 00:00:00 2001 From: Cameron Martin Date: Mon, 26 Nov 2018 21:40:06 +0000 Subject: [PATCH 135/174] [@babel/core]: Fixed typo in method name. Renamed one overload of `transformFromAstSync` to `transformFromAstAsync`. See https://github.com/babel/babel/blob/61f2aed5b0d3ef869dca2f8e2673e46079df7d09/packages/babel-core/src/transform-ast.js#L75 and https://github.com/babel/babel/blob/61f2aed5b0d3ef869dca2f8e2673e46079df7d09/packages/babel-core/src/index.js#L29 --- types/babel__core/babel__core-tests.ts | 4 ++++ types/babel__core/index.d.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/babel__core/babel__core-tests.ts b/types/babel__core/babel__core-tests.ts index a873c3392f..623d4121fe 100644 --- a/types/babel__core/babel__core-tests.ts +++ b/types/babel__core/babel__core-tests.ts @@ -29,3 +29,7 @@ babel.transformFromAst(parsedAst!, sourceCode, options, (err, result) => { const transformFromAstSyncResult = babel.transformFromAstSync(parsedAst!, sourceCode, options); const { code, map, ast } = transformFromAstSyncResult!; + +babel.transformFromAstAsync(parsedAst!, sourceCode, options).then(transformFromAstAsyncResult => { + const { code, map, ast } = transformFromAstAsyncResult!; +}); diff --git a/types/babel__core/index.d.ts b/types/babel__core/index.d.ts index 85a89392af..ad061fba80 100644 --- a/types/babel__core/index.d.ts +++ b/types/babel__core/index.d.ts @@ -349,7 +349,7 @@ export function transformFromAstSync(ast: Node, code?: string, opts?: TransformO /** * Given an AST, transform it. */ -export function transformFromAstSync(ast: Node, code?: string, opts?: TransformOptions): Promise; +export function transformFromAstAsync(ast: Node, code?: string, opts?: TransformOptions): Promise; // A babel plugin is a simple function which must return an object matching // the following interface. Babel will throw if it finds unknown properties. From 9f4587cc6731cf6e733de34f6a09c71415a373f8 Mon Sep 17 00:00:00 2001 From: Cameron Martin Date: Mon, 26 Nov 2018 23:52:05 +0000 Subject: [PATCH 136/174] [@babel/traverse]: Added types to argument of Scope#push. Copied from the flow types (https://github.com/babel/babel/blob/61f2aed5b0d3ef869dca2f8e2673e46079df7d09/packages/babel-traverse/src/scope/index.js#L778) with one exception - kind was made optional, since this is assigned a default value (https://github.com/babel/babel/blob/61f2aed5b0d3ef869dca2f8e2673e46079df7d09/packages/babel-traverse/src/scope/index.js#L801) and is most likely a mistake in the flow types. --- types/babel__traverse/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/babel__traverse/index.d.ts b/types/babel__traverse/index.d.ts index 465a60464f..4825dc5303 100644 --- a/types/babel__traverse/index.d.ts +++ b/types/babel__traverse/index.d.ts @@ -90,7 +90,13 @@ export class Scope { removeData(key: string): void; - push(opts: any): void; + push(opts: { + id: object, + init?: object, + unique?: boolean, + _blockHoist?: number, + kind?: "var" | "let", + }): void; getProgramParent(): Scope; From aa086a84c1eb3b2499f77d0d075f91a672f11573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Aguilar=20Hern=C3=A1ndez?= Date: Mon, 26 Nov 2018 19:16:28 -0500 Subject: [PATCH 137/174] * Applied better practices --- types/better-sqlite3/better-sqlite3-tests.ts | 22 +++-- types/better-sqlite3/index.d.ts | 86 +++++++++++++++++++- types/better-sqlite3/tsconfig.json | 1 - types/better-sqlite3/types.d.ts | 80 ------------------ 4 files changed, 99 insertions(+), 90 deletions(-) delete mode 100644 types/better-sqlite3/types.d.ts diff --git a/types/better-sqlite3/better-sqlite3-tests.ts b/types/better-sqlite3/better-sqlite3-tests.ts index 5d8b95ecf7..7272d88f7e 100644 --- a/types/better-sqlite3/better-sqlite3-tests.ts +++ b/types/better-sqlite3/better-sqlite3-tests.ts @@ -1,27 +1,33 @@ import Database = require('better-sqlite3'); -import { RunResult } from 'better-sqlite3/types'; const integer = Database.Integer(1); const err = new Database.SqliteError('ok', 'ok'); -const result: RunResult = { changes: 1, lastInsertRowid: 1 }; +const result: Database.RunResult = { changes: 1, lastInsertRowid: 1 }; +const options: Database.Options = { fileMustExist: true, memory: true, readonly: true }; +const registrationOptions: Database.RegistrationOptions = { + deterministic: true, + name: '', + safeIntegers: true, + varargs: true +}; let db = Database('.'); -db = new Database('.', {memory: true}); +db = new Database('.', { memory: true }); db.exec('CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL);'); db.exec('INSERT INTO test(name) VALUES("name");'); db.pragma('data_version', true); db.checkpoint(); db.checkpoint('main'); -db.register(() => {}); -db.register({name: 'noop', deterministic: true, varargs: true}, () => {}); +db.register(() => { }); +db.register({ name: 'noop', deterministic: true, varargs: true }, () => { }); db.defaultSafeIntegers(); db.defaultSafeIntegers(true); const stmt = db.prepare('SELECT * FROM test WHERE name == ?;'); stmt.get(['name']); -stmt.all({name: 'name'}); -stmt.each('name', (row: {name: string}) => {}); -stmt.each((row: {name: string}) => {}); +stmt.all({ name: 'name' }); +stmt.each('name', (row: { name: string }) => { }); +stmt.each((row: { name: string }) => { }); stmt.pluck(); stmt.pluck(true); stmt.bind('name'); diff --git a/types/better-sqlite3/index.d.ts b/types/better-sqlite3/index.d.ts index d120209765..5a4859e21f 100644 --- a/types/better-sqlite3/index.d.ts +++ b/types/better-sqlite3/index.d.ts @@ -5,7 +5,91 @@ // Santiago Aguilar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { DatabaseConstructor } from "./types"; +import Integer = require("integer"); + +declare class Statement { + database: Database; + source: string; + returnsData: boolean; + constructor(db: Database, sources: string[]); + + run(...params: any[]): Database.RunResult; + get(...params: any[]): any; + all(...params: any[]): any[]; + each(params: any, cb: (row: any) => void): void; + each(cb: (row: any) => void): void; + each(...params: any[]): void; + pluck(toggleState?: boolean): this; + bind(...params: any[]): this; + safeIntegers(toggleState?: boolean): this; +} + +declare class Transaction { + database: Database; + source: string; + constructor(db: Database, sources: string[]); + + run(...params: any[]): Database.RunResult; + bind(...params: any[]): this; + safeIntegers(toggleState?: boolean): this; +} + +interface Database { + memory: boolean; + readonly: boolean; + name: string; + open: boolean; + inTransaction: boolean; + + prepare(source: string): Statement; + transaction(sources: string[]): Transaction; + exec(source: string): this; + pragma(source: string, simplify?: boolean): any; + checkpoint(databaseName?: string): this; + register(cb: (...params: any[]) => any): this; + register( + options: Database.RegistrationOptions, + cb: (...params: any[]) => any + ): this; + close(): this; + defaultSafeIntegers(toggleState?: boolean): this; +} + +declare class SqliteError implements Error { + name: string; + message: string; + code: string; + constructor(message: string, code: string); +} + +interface DatabaseConstructor { + new (filename: string, options?: Database.Options): Database; + (filename: string, options?: Database.Options): Database; + prototype: Database; + + Integer: typeof Integer; + SqliteError: typeof SqliteError; +} + +declare namespace Database { + interface RunResult { + changes: number; + lastInsertRowid: Integer.IntLike; + } + + interface Options { + memory?: boolean; + readonly?: boolean; + fileMustExist?: boolean; + } + + interface RegistrationOptions { + name?: string; + varargs?: boolean; + deterministic?: boolean; + safeIntegers?: boolean; + } +} declare const Database: DatabaseConstructor; export = Database; diff --git a/types/better-sqlite3/tsconfig.json b/types/better-sqlite3/tsconfig.json index 891afa0aad..30a480355b 100644 --- a/types/better-sqlite3/tsconfig.json +++ b/types/better-sqlite3/tsconfig.json @@ -18,7 +18,6 @@ }, "files": [ "index.d.ts", - "types.d.ts", "better-sqlite3-tests.ts" ] } \ No newline at end of file diff --git a/types/better-sqlite3/types.d.ts b/types/better-sqlite3/types.d.ts deleted file mode 100644 index 61f376b0bf..0000000000 --- a/types/better-sqlite3/types.d.ts +++ /dev/null @@ -1,80 +0,0 @@ -import Integer = require("integer"); - -export interface RunResult { - changes: number; - lastInsertRowid: Integer.IntLike; -} - -export class Statement { - database: Database; - source: string; - returnsData: boolean; - constructor(db: Database, sources: string[]); - - run(...params: any[]): RunResult; - get(...params: any[]): any; - all(...params: any[]): any[]; - each(params: any, cb: (row: any) => void): void; - each(cb: (row: any) => void): void; - each(...params: any[]): void; - pluck(toggleState?: boolean): this; - bind(...params: any[]): this; - safeIntegers(toggleState?: boolean): this; -} - -export class Transaction { - database: Database; - source: string; - constructor(db: Database, sources: string[]); - - run(...params: any[]): RunResult; - bind(...params: any[]): this; - safeIntegers(toggleState?: boolean): this; -} - -export interface DatabaseOptions { - memory?: boolean; - readonly?: boolean; - fileMustExist?: boolean; -} - -export interface RegistrationOptions { - name?: string; - varargs?: boolean; - deterministic?: boolean; - safeIntegers?: boolean; -} - -export interface Database { - memory: boolean; - readonly: boolean; - name: string; - open: boolean; - inTransaction: boolean; - - prepare(source: string): Statement; - transaction(sources: string[]): Transaction; - exec(source: string): this; - pragma(source: string, simplify?: boolean): any; - checkpoint(databaseName?: string): this; - register(cb: (...params: any[]) => any): this; - register(options: RegistrationOptions, cb: (...params: any[]) => any): this; - close(): this; - defaultSafeIntegers(toggleState?: boolean): this; -} - -export class SqliteError implements Error { - name: string; - message: string; - code: string; - constructor(message: string, code: string); -} - -export interface DatabaseConstructor { - new (filename: string, options?: DatabaseOptions): Database; - (filename: string, options?: DatabaseOptions): Database; - prototype: Database; - - Integer: typeof Integer; - SqliteError: typeof SqliteError; -} From 838a295269bc8f0674c902db18d87b95e3cc406e Mon Sep 17 00:00:00 2001 From: ksaryan Date: Mon, 26 Nov 2018 16:20:05 -0800 Subject: [PATCH 138/174] Add ios_backgroundColor prop to Switch --- types/react-native/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2386fc71c2..9e68e283a9 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -8177,6 +8177,13 @@ export interface SwitchProps extends SwitchPropsIOS { * Default value is false. */ value?: boolean; + + /** + * On iOS, custom color for the background. + * Can be seen when the switch value is false or when the switch is disabled. + */ + ios_backgroundColor?: string; + style?: StyleProp; } From 389b8185f9630eb48b27b95c40f5c39b8c15137a Mon Sep 17 00:00:00 2001 From: obedm503 Date: Mon, 26 Nov 2018 20:31:12 -0600 Subject: [PATCH 139/174] Revert typescript version change --- types/react-intl/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 2c25a55b1f..aaba74820b 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -11,7 +11,7 @@ // Kanitkorn Sujautra // obedm503 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.9 +// TypeScript Version: 2.8 declare namespace ReactIntl { type DateSource = Date | string | number; From 5934128c87ea053d8443a14b5fa1b692f1db2730 Mon Sep 17 00:00:00 2001 From: obedm503 Date: Mon, 26 Nov 2018 20:39:22 -0600 Subject: [PATCH 140/174] fix trailing whitespace --- types/react-intl/react-intl-tests.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index 74da23a12a..63af762e61 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -401,13 +401,13 @@ class TestApp extends React.Component { hello: "Hello, {name}!" }; return ( - console.error(error)} > From 2df4d594006f2a9070e2359ac791768c14430623 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 27 Nov 2018 14:40:20 +0900 Subject: [PATCH 141/174] Set data unknown --- types/vfile/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vfile/index.d.ts b/types/vfile/index.d.ts index ce8f1dce38..7329e8e9ec 100644 --- a/types/vfile/index.d.ts +++ b/types/vfile/index.d.ts @@ -117,7 +117,7 @@ declare namespace vfile { * Place to store custom information. * It's OK to store custom data directly on the `vfile`, moving it to `data` gives a little more privacy. */ - data: any; + data: unknown; /** * List of messages associated with the file. */ From 1da614b33511ba1968a40a86df80dede10895967 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 27 Nov 2018 14:40:34 +0900 Subject: [PATCH 142/174] Clean up type tests --- types/vfile/vfile-tests.ts | 116 ++++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/types/vfile/vfile-tests.ts b/types/vfile/vfile-tests.ts index 4d146237b1..5c14c8502b 100644 --- a/types/vfile/vfile-tests.ts +++ b/types/vfile/vfile-tests.ts @@ -2,56 +2,38 @@ import vfile = require('vfile'); import * as Unist from 'unist'; // Instantiation -vfile(); +const file: vfile.VFile = vfile(); vfile('string'); vfile(Buffer.from('string')); vfile(vfile()); vfile({ stem: 'readme', extname: '.md' }); -try { - vfile({ extname: '.md' }); -} catch (e) { - console.log('Error: set extname without path'); -} -interface CustomVFile extends vfile.VFile { - custom: string; - data: { - custom: number; - }; -} - -const file = vfile({ - path: '~/example.txt', - contents: 'Alpha *braavo* charlie.', - custom: 'Custom tango', - data: { - custom: 12345 - } -}); -const customIsString: string = file.custom; -const dataCustomIsNumber: number = file.data.custom; -const copiedFile: CustomVFile = vfile(file); - -file.path; // => '~/example.txt' -file.dirname; // => '~' +vfile({ path: 1234 }); // $ExpectError +file.path = '~/test.txt'; +file.dirname = '~'; file.extname = '.md'; +file.basename = 'test.text'; +file.history = ['~/test.txt']; // => ['~/example.txt', '~/example.md', '~/index.text'] +file.messages = [{ + file: '~/test.txt', + ruleId: '', + reason: '', + line: 1, + column: 1, + location: { + start: { + line: 1, + column: 1, + }, + end: { + line: 1, + column: 1, + } + }, + source: '' +}]; -file.basename; // => 'example.md' - -file.basename = 'index.text'; - -file.history; // => ['~/example.txt', '~/example.md', '~/index.text'] - -file.message('`braavo` is misspelt; did you mean `bravo`?', {line: 1, column: 8}); - -console.log(file.messages); - -// Typings of the custom data can be resolved from the parameters above -const custom: string = file.custom; // 'Custom tango' -const dataCustom: number = file.data.custom; // 12345 - -// message method accept any Stringifiable Position(e.g. point, position, node with position) const startPoint: Unist.Point = { line: 1, column: 1, @@ -63,18 +45,56 @@ const position: Unist.Position = { column: 2, }, }; -// Accept Point + file.message('test', startPoint); -// Accept Position file.message('test', position); -// Accept Node with extra value file.message('test', { type: 'ramdom node', position, extraValue: 'extra tango', }); -// But, it must reject any malformed position + file.message('test', { start: 'invalid point' }); // $ExpectError -// Typings of original properties must be kept -const fileWithWrongParams = vfile({ path: 1234 }); // $ExpectError +// Using `data` prop +interface CustomData { + message: string; +} +function isCustomData(data: any): data is CustomData { + return data != null && typeof data.message === 'string'; +} +function doSomethingWithCustomData(data: CustomData) { +} +const customData: CustomData = { + message: 'tango' +}; +const fileWithData = vfile({ + data: customData +}); + +if (isCustomData(fileWithData.data)) { + doSomethingWithCustomData(fileWithData.data); +} +doSomethingWithCustomData(fileWithData.data); // $ExpectError + +// Extending vfile +interface CustomVFile extends vfile.VFile { + custom: string; + data: { + custom: number; + }; +} + +const customVFile = vfile({ + path: '~/example.txt', + contents: 'Alpha *braavo* charlie.', + custom: 'Custom tango', + data: { + custom: 12345 + } +}); + +customVFile.custom = 'test'; +customVFile.data.custom = 1234; + +const copiedFile: CustomVFile = vfile(customVFile); From dcf5a0dbd497d343a92b6084440c7ffb12cc220f Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 27 Nov 2018 14:47:42 +0900 Subject: [PATCH 143/174] Add decription for `data` prop --- types/vfile/readme.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/types/vfile/readme.md b/types/vfile/readme.md index 349503cef8..21525242cb 100644 --- a/types/vfile/readme.md +++ b/types/vfile/readme.md @@ -3,6 +3,34 @@ Below are some examples of how to use these Definitions.
Scenarios where the Typescript code is identical to plain Javascript code are omitted. +### Using `data` property + +Because `data` property type is set `unknown`, you have to make your own type guard. + +```ts +interface CustomData { + message: string; +} +// This is the type guard +function isCustomData(data: any): data is CustomData { + return data != null && typeof data.message === 'string'; +} +function doSomethingWithCustomData(data: CustomData) { +} +const customData: CustomData = { + message: 'tango' +}; +const fileWithData = vfile({ + data: customData +}); + +if (isCustomData(fileWithData.data)) { + doSomethingWithCustomData(fileWithData.data); +} +// The below code will throw a compiler error +doSomethingWithCustomData(fileWithData.data); // $ExpectError +``` + ### Extending VFile ```ts From dcc3948836f0a3683aeb8cb9b6395742760757a8 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 27 Nov 2018 14:49:51 +0900 Subject: [PATCH 144/174] Upgrade typescript version because it is using `unknown` --- types/vfile/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vfile/index.d.ts b/types/vfile/index.d.ts index 7329e8e9ec..df729e0a49 100644 --- a/types/vfile/index.d.ts +++ b/types/vfile/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: bizen241 // Junyoung Choi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 3.0 /// From ebb397fb9eab1217421bd2f80d301a157ec15bb2 Mon Sep 17 00:00:00 2001 From: Cameron Martin Date: Tue, 27 Nov 2018 09:12:09 +0000 Subject: [PATCH 145/174] Implemented suggested changes. --- types/babel__traverse/babel__traverse-tests.ts | 3 ++- types/babel__traverse/index.d.ts | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/babel__traverse/babel__traverse-tests.ts b/types/babel__traverse/babel__traverse-tests.ts index 5b4fbbef5f..2f5b5ca74d 100644 --- a/types/babel__traverse/babel__traverse-tests.ts +++ b/types/babel__traverse/babel__traverse-tests.ts @@ -89,7 +89,8 @@ const v1: Visitor = { const id = path.scope.generateUidIdentifierBasedOnNode(path.node.id!); path.remove(); - path.scope.parent.push({ id, init: path.node }); + path.scope.parent.push({ id }); + path.scope.parent.push({ id, init: t.stringLiteral('foo'), kind: "const" }); path.scope.rename("n", "x"); path.scope.rename("n"); diff --git a/types/babel__traverse/index.d.ts b/types/babel__traverse/index.d.ts index 4825dc5303..93c768a913 100644 --- a/types/babel__traverse/index.d.ts +++ b/types/babel__traverse/index.d.ts @@ -91,11 +91,10 @@ export class Scope { removeData(key: string): void; push(opts: { - id: object, - init?: object, + id: t.LVal, + init?: t.Expression, unique?: boolean, - _blockHoist?: number, - kind?: "var" | "let", + kind?: "var" | "let" | "const", }): void; getProgramParent(): Scope; From 9b183dbac86e46d7ffd08bcb6c5ee6385c3cc081 Mon Sep 17 00:00:00 2001 From: Cameron Martin Date: Tue, 27 Nov 2018 09:13:03 +0000 Subject: [PATCH 146/174] Introduced $ExpectError. See https://github.com/Microsoft/dtslint#write-tests --- types/babel__traverse/babel__traverse-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/babel__traverse/babel__traverse-tests.ts b/types/babel__traverse/babel__traverse-tests.ts index 2f5b5ca74d..1a1bf712d7 100644 --- a/types/babel__traverse/babel__traverse-tests.ts +++ b/types/babel__traverse/babel__traverse-tests.ts @@ -105,7 +105,7 @@ const BindingKindTest: Visitor = { kind === 'const'; kind === 'let'; kind === 'var'; - // The following should fail when uncommented - // kind === 'anythingElse'; + // $ExpectError + kind === 'anythingElse'; }, }; From 0d5716d5f08c94062e7ac396587ed956f168ea6d Mon Sep 17 00:00:00 2001 From: Stefano Bourscheid Date: Tue, 27 Nov 2018 11:33:48 +0100 Subject: [PATCH 147/174] Remove 2.x support from react-native-video --- types/react-native-video/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/react-native-video/index.d.ts b/types/react-native-video/index.d.ts index 726169caca..63d0ff6c89 100644 --- a/types/react-native-video/index.d.ts +++ b/types/react-native-video/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native-video 2.0 and 3.1 +// Type definitions for react-native-video 3.1 // Project: https://github.com/react-native-community/react-native-video // Definitions by: HuHuanming // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -95,8 +95,6 @@ export interface VideoProperties extends ViewProps { onPlaybackRateChange?(): void; onAudioFocusChanged?(): void; onAudioBecomingNoisy?(): void; - - /* 3.0 onwards */ selectedTextTrack?: { type: 'system' | 'disabled' | 'title' | 'language' | 'index'; value?: string | number; From b91830f72f5a229b7376fcfa238ef38c077b2122 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 27 Nov 2018 23:35:27 +0900 Subject: [PATCH 148/174] Fix typescript version of vfile-location --- types/vfile-location/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vfile-location/index.d.ts b/types/vfile-location/index.d.ts index b991528c7e..fbea17630e 100644 --- a/types/vfile-location/index.d.ts +++ b/types/vfile-location/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Ika // Junyoung Choi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 3.0 import * as VFile from "vfile"; From 83a419ec7bd69ba15089a669a0aab466189d2b42 Mon Sep 17 00:00:00 2001 From: Chris O'Toole Date: Tue, 27 Nov 2018 10:38:11 -0500 Subject: [PATCH 149/174] Don't update main package version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2bd57a4c7c..09fe064d48 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "definitely-typed", - "version": "0.0.4", + "version": "0.0.3", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped", "repository": { "type": "git", From 37d0e8c735d8573f238b51461fb3489190274def Mon Sep 17 00:00:00 2001 From: Nicolas Biehler Date: Fri, 23 Nov 2018 15:35:35 +0100 Subject: [PATCH 150/174] fix: extend elasticsearch alias params As shown in elasticsearch documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#filtered), an alias can have a routing value and a filter specified. --- types/elasticsearch/elasticsearch-tests.ts | 43 ++++++++++++++++------ types/elasticsearch/index.d.ts | 2 - 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index ee57f847fa..0d12a931ed 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -209,7 +209,7 @@ client.get({ id: '1', routing: '1' }, (error, response) => { - const routing = response._routing; + const routing = response._routing; }); client.mget({ @@ -338,22 +338,43 @@ client.indices.updateAliases({ // ... }); -client.reindex({ - body: { - source: { - index: "twitter" - }, - dest: { - index: "new_twitter" +client.indices.updateAliases({ + body: { + actions: [ + { + add: { + index: 'logstash-2018.11', alias: 'logstash-filtered', filter: { + query: { + exists: { field: 'id' } + } + }, + routing: 'id' } } + ] + } +}).then((response) => { + // ... +}, (error) => { + // ... +}); + +client.reindex({ + body: { + source: { + index: "twitter" + }, + dest: { + index: "new_twitter" + } + } }) -.then(response => { + .then(response => { const { took, timed_out } = response; // ... -}); + }); // Errors function testErrors() { - throw new elasticsearch.errors.AuthenticationException(); + throw new elasticsearch.errors.AuthenticationException(); } diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index 62202dbc90..401627d2c1 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -1407,8 +1407,6 @@ export interface IndicesUpdateAliasesParamsAction { index?: string; indices?: string[]; alias: string; - routing?: string; - filter?: object; }; remove_index?: { index: string; From 2bd511da769254c4dc31a651b7ff05c1e3dd571f Mon Sep 17 00:00:00 2001 From: timhwang21 Date: Tue, 27 Nov 2018 12:47:24 -0500 Subject: [PATCH 151/174] [node-forge] add types for missing modules; fix incorrect types Add typedefs for: * `jsbn` (bare minimum); API isn't public so should be fine * `random` Improve typedefs for: * `pki` public and private keys * Add types for `pki.rsa` keys Add stubs for: (I didn't fix as these types aren't currently relevant to my work) * `pss` * `pki.ed25519` Also fixed some incorrect types, e.g. `createBuffer` was mistyped. Added test case for RSA signing. Also fixed some incorrect tests, and commented out ones that seemed entirely broken. The two removed lines don't trigger type errors on master, but if you actually run the file they will error: `ts-node types/node-forge/node-forge-tests.ts` --- types/node-forge/index.d.ts | 132 ++++++++++++++++++--------- types/node-forge/node-forge-tests.ts | 20 +++- 2 files changed, 104 insertions(+), 48 deletions(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index d362eb1c27..40badbbcf4 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for node-forge 0.7.6 +// Type definitions for node-forge 0.7.7 // Project: https://github.com/digitalbazaar/forge // Definitions by: Seth Westphal // Kay Schecker @@ -7,6 +7,7 @@ // Beeno Tung // Joe Flateau // Nikita Koryabkin +// timhwang21 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -20,6 +21,15 @@ declare module "node-forge" { type Utf8 = string; type OID = string; + namespace jsbn { + class BigInteger { + data: number[]; + t: number; + s: number; + toString(): string; + } + } + namespace pem { interface EncodeOptions { @@ -40,28 +50,18 @@ declare module "node-forge" { } namespace pki { - type PEM = string; - type Key = any; + type PublicKey = rsa.PublicKey | ed25519.Key; + type PrivateKey = rsa.PrivateKey | ed25519.Key; interface KeyPair { publicKey: PublicKey; privateKey: PrivateKey; } - interface PublicKey { - encrypt(data: string, scheme?: string, schemeOptions?: number): Bytes - verify(digest: string, signature: string, scheme?: string): boolean - } - - interface PrivateKey { - decrypt(data: string, scheme?: string, schemeOptions?: number): string - sign(md: string, scheme?: string): Bytes - } - function pemToDer(pem: PEM): util.ByteStringBuffer; function privateKeyToPem(key: PrivateKey, maxline?: number): PEM; - function privateKeyInfoToPem(key: PrivateKey, maxline?: number): PEM; + function privateKeyInfoToPem(key: Bytes, maxline?: number): PEM; function publicKeyToPem(key: PublicKey, maxline?: number): PEM; function publicKeyFromPem(pem: PEM): PublicKey; function privateKeyFromPem(pem: PEM): PrivateKey; @@ -73,7 +73,38 @@ declare module "node-forge" { } var oids: oids; + namespace ed25519 { + type Key = ArrayBuffer; + } + namespace rsa { + type EncryptionScheme = 'RSAES-PKCS1-V1_5' | 'RSA-OAEP' | 'RAW' | 'NONE' | null; + type SignatureScheme = 'RSASSA-PKCS1-V1_5' | pss.PSS | 'NONE' | null; + + interface PublicKey { + n: jsbn.BigInteger; + e: jsbn.BigInteger; + encrypt(data: Bytes, scheme?: EncryptionScheme, schemeOptions?: any): Bytes; + verify(digest: Bytes, signature: Bytes, scheme?: SignatureScheme): boolean; + } + + interface PrivateKey { + n: jsbn.BigInteger; + e: jsbn.BigInteger; + d: jsbn.BigInteger; + p: jsbn.BigInteger; + q: jsbn.BigInteger; + dP: jsbn.BigInteger; + dQ: jsbn.BigInteger; + qInv: jsbn.BigInteger; + decrypt(data: Bytes, scheme?: EncryptionScheme, schemeOptions?: any): Bytes; + sign(md: md.MessageDigest, scheme?: SignatureScheme): Bytes; + } + + interface KeyPair { + publicKey: PublicKey; + privateKey: PrivateKey; + } interface GenerateKeyPairOptions { bits?: number; @@ -84,9 +115,9 @@ declare module "node-forge" { prng?: any; algorithm?: string; } - + function setPublicKey(n: any, e: any): any; - + function generateKeyPair(bits?: number, e?: number, callback?: (err: Error, keypair: KeyPair) => void): KeyPair; function generateKeyPair(options?: GenerateKeyPairOptions, callback?: (err: Error, keypair: KeyPair) => void): KeyPair; } @@ -160,8 +191,8 @@ declare module "node-forge" { hash: any; }; extensions: any[]; - privateKey: Key; - publicKey: Key; + privateKey: PrivateKey; + publicKey: PublicKey; md: any; /** * Sets the subject of this certificate. @@ -200,7 +231,7 @@ declare module "node-forge" { * @param key the private key to sign with. * @param md the message digest object to use (defaults to forge.md.sha1). */ - sign(key: pki.Key, md: md.MessageDigest): void; + sign(key: pki.PrivateKey, md?: md.MessageDigest): void; /** * Attempts verify the signature on the passed certificate using this * certificate's public key. @@ -215,19 +246,30 @@ declare module "node-forge" { function certificateFromAsn1(obj: asn1.Asn1, computeHash?: boolean): Certificate; - function decryptRsaPrivateKey(pem: PEM, passphrase?: string): Key; + function decryptRsaPrivateKey(pem: PEM, passphrase?: string): PrivateKey; function createCertificate(): Certificate; - + function certificationRequestToPem(cert: Certificate, maxline?: number): PEM; - + function certificationRequestFromPem(pem: PEM, computeHash?: boolean, strict?: boolean): Certificate; - + function createCertificationRequest(): Certificate; - - function publicKeyToAsn1(publicKey: Key): any; - - function publicKeyToRSAPublicKey(publicKey: Key): any; + + function publicKeyToAsn1(publicKey: PublicKey): any; + + function publicKeyToRSAPublicKey(publicKey: PublicKey): any; + } + + namespace random { + function getBytes(count: number, callback?: (bytes: Bytes) => any): Bytes; + function getBytesSync(count: number): Bytes; + type CB = (_: any, seed: string) => void; + interface Random { + seedFileSync: (needed: number) => string; + seedFile: (needed: number, cb: CB) => void; + } + function createInstance(): Random; } namespace ssh { @@ -249,22 +291,22 @@ declare module "node-forge" { /** * @description Encodes a private RSA key as an OpenSSH file */ - function privateKeyToOpenSSH(privateKey: pki.Key, passphrase?: string): string; + function privateKeyToOpenSSH(privateKey: pki.PrivateKey, passphrase?: string): string; /** * @description Encodes (and optionally encrypts) a private RSA key as a Putty PPK file */ - function privateKeyToPutty(privateKey: pki.Key, passphrase?: string, comment?: string): string; + function privateKeyToPutty(privateKey: pki.PrivateKey, passphrase?: string, comment?: string): string; /** * @description Encodes a public RSA key as an OpenSSH file */ - function publicKeyToOpenSSH(publicKey: pki.Key, comment?: string): string | pki.PEM; + function publicKeyToOpenSSH(publicKey: pki.PublicKey, comment?: string): string | pki.PEM; /** * @description Gets the SSH fingerprint for the given public key */ - function getPublicKeyFingerprint(publicKey: pki.Key, options?: FingerprintOptions): util.ByteStringBuffer | Hex | string; + function getPublicKeyFingerprint(publicKey: pki.PublicKey, options?: FingerprintOptions): util.ByteStringBuffer | Hex | string; } namespace asn1 { @@ -377,7 +419,7 @@ declare module "node-forge" { function decodeUtf8(encoded: Utf8): string; function createBuffer(): ByteBuffer; - function createBuffer(input: string, encode: string): ByteBuffer; + function createBuffer(input: Bytes | ArrayBuffer | ArrayBufferView | ByteStringBuffer, encode: string): ByteBuffer; namespace binary { namespace raw { @@ -418,7 +460,7 @@ declare module "node-forge" { interface Bag { type: string; attributes: any; - key?: pki.Key; + key?: pki.PrivateKey; cert?: pki.Certificate; asn1: asn1.Asn1 } @@ -441,12 +483,12 @@ declare module "node-forge" { function pkcs12FromAsn1(obj: any, strict?: boolean, password?: string): Pkcs12Pfx; function pkcs12FromAsn1(obj: any, password?: string): Pkcs12Pfx; } - + namespace pkcs7 { interface PkcsSignedData { content?: string | util.ByteBuffer; contentInfo?: { value: any[] }; - + addCertificate(certificate: pki.Certificate): void; addSigner(options: { key: string; @@ -459,14 +501,16 @@ declare module "node-forge" { }): void; toAsn1(): asn1.Asn1; } - + function createSignedData(): PkcsSignedData; } namespace md { + type Encoding = "raw" | "utf8" + interface MessageDigest { - update(msg: string, encoding?: string): MessageDigest; + update(msg: string, encoding?: Encoding): MessageDigest; digest(): util.ByteStringBuffer; } @@ -477,7 +521,7 @@ declare module "node-forge" { namespace sha256 { function create(): MessageDigest; } - + namespace sha512 { function create(): MessageDigest; } @@ -513,18 +557,16 @@ declare module "node-forge" { tag: util.ByteStringBuffer; } } - + namespace pss { - function create(any: any): any; + type PSS = any; + + function create(any: any): PSS; } - + namespace mgf { namespace mgf1 { function create(any: any): any; } } - - namespace random { - function getBytesSync(length: number): Bytes; - } } diff --git a/types/node-forge/node-forge-tests.ts b/types/node-forge/node-forge-tests.ts index abc863f7ff..a8d352ad1a 100644 --- a/types/node-forge/node-forge-tests.ts +++ b/types/node-forge/node-forge-tests.ts @@ -8,9 +8,7 @@ let x: string = forge.ssh.privateKeyToOpenSSH(key); let pemKey: forge.pki.PEM = publicKeyPem; let publicKeyRsa = forge.pki.publicKeyFromPem(pemKey); let privateKeyRsa = forge.pki.privateKeyFromPem(privateKeyPem); -let privateKeyRsa2 = forge.pki.privateKeyInfoToPem(privateKeyRsa); let byteBufferString = forge.pki.pemToDer(privateKeyPem); -let certPem = forge.pki.certificateFromPem(pemKey); let cert = forge.pki.createCertificate(); { @@ -118,6 +116,7 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin } { + let key = forge.random.getBytesSync(24) let payload = { asd: 'asd' }; let cipher = forge.cipher.createCipher('3DES-ECB', forge.util.createBuffer(key, 'raw')); cipher.start(); @@ -133,7 +132,7 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin let decrypted = decipher.output as forge.util.ByteStringBuffer; let content = JSON.parse(forge.util.encodeUtf8(decrypted.getBytes())); - if (content.asd == payload.asd) throw Error('forge.cipher.createCipher failed'); + if (content.asd !== payload.asd) throw Error('forge.cipher.createCipher failed'); } { @@ -189,3 +188,18 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin // self-sign certificate cert.sign(keypair.privateKey, forge.md.sha256.create()); } + +{ + let md: forge.md.MessageDigest; + let hex: string; + let signature: forge.Bytes + + md = forge.md.sha256.create(); + md = md.update('Test'); + hex = md.digest().toHex(); + + signature = keypair.privateKey.sign(md) + if (!keypair.publicKey.verify(md.digest().bytes(), signature)) { + throw Error("rsa signature verification fail"); + } +} From 075dc4a1ce3f16807dfe3e4aa13893a814958fde Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Tue, 27 Nov 2018 10:48:49 -0800 Subject: [PATCH 152/174] Delete Vega typings since Vega comes with its own types. --- types/vega/index.d.ts | 562 ----------- types/vega/tsconfig.json | 24 - types/vega/tslint.json | 79 -- types/vega/vega-tests.ts | 2035 -------------------------------------- 4 files changed, 2700 deletions(-) delete mode 100644 types/vega/index.d.ts delete mode 100644 types/vega/tsconfig.json delete mode 100644 types/vega/tslint.json delete mode 100644 types/vega/vega-tests.ts diff --git a/types/vega/index.d.ts b/types/vega/index.d.ts deleted file mode 100644 index da7b0fee32..0000000000 --- a/types/vega/index.d.ts +++ /dev/null @@ -1,562 +0,0 @@ -// Type definitions for Vega -// Project: http://trifacta.github.io/vega/ -// Definitions by: Tom Crockett -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace vg { - - export type ChartViewConstructor = { - (args: {renderer: 'svg'} & ViewArgs): SvgView; - (args: {renderer: 'canvas'} & ViewArgs): CanvasView; - (args: ViewArgs): View; - }; - - export interface Parse { - spec(url: string, callback: (chart: ChartViewConstructor) => void): void; - spec(spec: Spec, callback: (chart: ChartViewConstructor) => void): void; - data(dataSet: Data[], callback: () => void): void; - // TODO all the other stuff - } - - export interface ViewArgs { - // TODO docs - el?: any; - data?: any; - hover?: boolean; - renderer?: string; - } - - export interface View { - // TODO docs - width(): number; - width(w: number): this; - - height(): number; - height(h: number): this; - - padding(): Padding; - padding(p: Padding): this; - - viewport(): number[]; - viewport(v: number[]): this; - - renderer(r: string): this; - - data(): Runtime.DataSets; - data(d: any/*TODO*/): this; - - initialize(selector: string): this; - initialize(node: Element): this; - - render(r?: any[]): this; - - update(options?: UpdateOptions): this; - - model(): Vega.Model; - - defs(): Defs; - defs(defs: Defs): this; - } - - export interface SvgView extends View { - svg(): string; - } - - export interface CanvasView extends View { - canvas(): any; // Returns a node-canvas instance - } - - export interface Padding { - // TODO docs - top: number; - right: number; - bottom: number; - left: number; - } - - export interface UpdateOptions { - // TODO docs - props?: string; - items?: any; - duration?: number; - ease?: string; - } - - export interface Bounds { - x1: number; - y1: number; - x2: number; - y2: number; - clear(): Bounds; - set(x1: number, y1: number, x2: number, y2: number): Bounds; - add(x: number, y: number): Bounds; - expand(d: number): Bounds; - round(): Bounds; - translate(dx: number, dy: number): Bounds; - rotate(angle: number, x: number, y: number): Bounds; - union(b: Bounds): Bounds; - encloses(b: Bounds): boolean; - intersects(b: Bounds): boolean; - contains(x: number, y: number): boolean; - width(): number; - height(): number; - } - - export interface Model { - defs(): Defs; - defs(defs: Defs): Model; - - data(): Runtime.DataSets; - data(data: Runtime.DataSets): Model; - - ingest(name: string, tx: any/*TODO*/, input: any/*TODO*/): void; - - dependencies(name: string, tx: any/*TODO*/): void; - - width(w: number): Model; - - height(h: number): Model; - - scene(): Node; - scene(node: Node): Model; - - build(): Model; - - encode(trans?: any/*TODO*/, request?: string, item?: any): Model; - - reset(): Model; - } - - export namespace Runtime { - export interface DataSets { - [name: string]: Datum[]; - } - - export interface Datum { - [key: string]: any - } - - export interface Marks { - type: string; - width: number; - height: number; - scales: Scale[]; - axes: Axis[]; - legends: Legend[]; - marks: Mark[]; - } - - export interface PropertySets { - enter?: Properties; - exit?: Properties; - update?: Properties; - hover?: Properties; - } - - export interface Properties { - (item: Node, group: Node, trans: any/*TODO*/): void; - } - } - - export interface Node { - def: Vega.Mark; - marktype: string; - interactive: boolean; - items: Node[]; - bounds: Bounds; - - // mark item members - hasPropertySet(name: string): boolean; - cousin(offset: number, index: number): Node; - sibling(offset: number): Node; - remove(): Node; - touch(): void; - - // group members - scales?: {[name: string]: any}; - axisItems?: Node[]; - } - - export interface Defs { - width: number; - height: number; - viewport?: number[]; - padding: any; - marks: Runtime.Marks; - data: Data[]; - } - - export interface Spec { - /** - * A unique name for the visualization specification. - */ - name?: string; - /** - * The total width, in pixels, of the data rectangle. Default is 500 if - * undefined. - */ - width?: number; - /** - * The total height, in pixels, of the data rectangle. Default is 500 if - * undefined. - */ - height?: number; - /** - * The width and height of the on-screen viewport, in pixels. If necessary, - * clipping and scrolling will be applied. - */ - viewport?: number[]; - /** - * [Number | Object | String] - * The internal padding, in pixels, from the edge of the visualization - * canvas to the data rectangle. If an object is provided, it must include - * {top, left, right, bottom} properties. Two string values are also - * acceptable: "auto" (the default) and "strict". Auto-padding computes the - * padding dynamically based on the contents of the visualization. All - * marks, including axes and legends, are used to compute the necessary - * padding. "Strict" auto-padding attempts to adjust the padding such that - * the overall width and height of the visualization is unchanged. This mode - * can cause the visualization's width and height parameters to be adjusted - * such that the total size, including padding, remains constant. Note that - * in some cases strict padding is not possible; for example, if the axis - * labels are much larger than the data rectangle. - */ - padding?: number | string | { - top: number; left: number; right: number; bottom: number - }; // string is "auto" or "strict" - /** - * Definitions of data to visualize. - */ - data: Data[]; - /** - * Scale transform definitions. - */ - scales?: Scale[]; - /** - * Axis definitions. - */ - axes?: Axis[]; - /** - * Legend definitions. - */ - legends?: Legend[]; - /** - * Graphical mark definitions. - */ - marks: (Mark | GroupMark)[]; - } - - export interface Data { - /** - * A unique name for the data set. - */ - name: string; - /** - * An object that specifies the format for the data file, if loaded from a - * URL. - */ - format?: Data.Format; - /** - * The actual data set to use. The values property allows data to be inlined - * directly within the specification itself. - */ - values?: any; - /** - * The name of another data set to use as the source for this data set. The - * source property is particularly useful in combination with a transform - * pipeline to derive new data. - */ - source?: string; - /** - * A URL from which to load the data set. Use the format property to ensure - * the loaded data is correctly parsed. If the format property is not specified, - * the data is assumed to be in a row-oriented JSON format. - */ - url?: string; - /** - * An array of transforms to perform on the data. Transform operators will be - * run on the default data, as provided by late-binding or as specified by the - * source, values, or url properties. - */ - transform?: Data.Transform[]; - } - - export namespace Data { - export interface FormatBase { - /** - * The currently supported format types are json (JavaScript Object - * Notation), csv (comma-separated values), tsv (tab-separated values), - * topojson, and treejson. - */ - type: string; - // TODO: fields for specific formats - } - - /** - * The JSON property containing the desired data. - * This parameter can be used when the loaded JSON file may have surrounding structure or meta-data. - * For example "property": "values.features" is equivalent to retrieving json.values.features from the - * loaded JSON object. - */ - export interface JsonFormat extends FormatBase { - type: string; // "json" - property?: string; - } - - export interface CsvOrTsvFormat extends FormatBase { - type: string; // "csv" | "tsv" - parse?: { - [propertyName: string]: string; // "number" | "boolean" | "date" - } - } - - export interface TopoJsonFormat extends FormatBase { - type: string; // "topojson" - feature?: string; - mesh?: string; - } - - export interface TreeJson extends FormatBase { - type: string; // "treejson" - children?: string; - parse?: { - [propertyName: string]: string; // "number" | "boolean" | "date" - } - } - - export type Format = JsonFormat | CsvOrTsvFormat | TopoJsonFormat | TreeJson; - - export interface Transform { - // TODO - } - } - - export interface Scale { - // TODO docs - - // -- Common scale properties - name?: string; - type?: string; - domain?: any; - domainMin?: any; - domainMax?: any; - range?: any; - rangeMin?: any; - rangeMax?: any; - reverse?: boolean; - round?: boolean; - - // -- Ordinal scale properties - points?: boolean; - padding?: number; - sort?: boolean; - - // -- Time/Quantitative scale properties - clamp?: boolean; - /** boolean for quantitative scales, string for time scales */ - nice?: boolean | string; - - // -- Quantitative scale properties - exponent?: number; - zero?: boolean; - } - - export interface Axis { - // TODO docs - type: string; - scale: string; - orient?: string; - title?: string; - titleOffset?: number; - format?: string; - ticks?: number; - values?: any[]; - subdivide?: number; - tickPadding?: number; - tickSize?: number; - tickSizeMajor?: number; - tickSizeMinor?: number; - tickSizeEnd?: number; - offset?: any; - layer?: string; - grid?: boolean; - properties?: Axis.Properties - } - - export namespace Axis { - export interface Properties { - ticks?: PropertySet; - minorTicks?: PropertySet; - grid?: PropertySet; - labels?: PropertySet; - title?: PropertySet; - axis?: PropertySet; - } - } - - export interface Legend { - // TODO - } - - export interface Mark { - // TODO docs - // Stuff from Spec.Mark - type: string; // "rect" | "symbol" | "path" | "arc" | "area" | "line" | "rule" | "image" | "text" | "group" - name?: string; - description?: string; - from?: Mark.From; - key?: string; - delay?: ValueRefs; - /** - * "linear-in" | "linear-out" | "linear-in-out" | "linear-out-in" | "quad-in" | "quad-out" | "quad-in-out" | - * "quad-out-in" | "cubic-in" | "cubic-out" | "cubic-in-out" | "cubic-out-in" | "sin-in" | "sin-out" | "sin-in-out" | - * "sin-out-in" | "exp-in" | "exp-out" | "exp-in-out" | "exp-out-in" | "circle-in" | "circle-out" | "circle-in-out" | - * "circle-out-in" | "bounce-in" | "bounce-out" | "bounce-in-out" | "bounce-out-in" - */ - ease?: string; - - interactive?: boolean; - - // Runtime PropertySets - properties?: PropertySets; - } - - export module Mark { - export interface From { - // TODO docs - data?: string; - mark?: string; - transform?: Data.Transform[]; - } - } - - export interface GroupMark extends Mark { - type: string; // "group" - /** - * Scale transform definitions. - */ - scales?: Scale[]; - /** - * Axis definitions. - */ - axes?: Axis[]; - /** - * Legend definitions. - */ - legends?: Legend[]; - /** - * Groups differ from other mark types in their ability to contain children marks. - * Marks defined within a group mark can inherit data from their parent group. - * For inheritance to work each data element for a group must contain data elements of its own. - * This arrangement of nested data is typically achieved by facetting the data, such that each group-level data element includes its own array of sub-elements - */ - marks?: (Mark | GroupMark)[]; - } - - export interface PropertySets { - // TODO docs - enter?: PropertySet; - exit?: PropertySet; - update?: PropertySet; - hover?: PropertySet; - } - - export interface PropertySet { - // TODO docs - - // -- Shared visual properties - x?: ValueRefs; - x2?: ValueRefs; - width?: ValueRefs; - y?: ValueRefs; - y2?: ValueRefs; - height?: ValueRefs; - opacity?: ValueRefs; - fill?: ValueRefs; - fillOpacity?: ValueRefs; - stroke?: ValueRefs; - strokeWidth?: ValueRefs; - strokeOpacity?: ValueRefs; - strokeDash?: ValueRefs; - strokeDashOffset?: ValueRefs; - - // -- symbol - size?: ValueRefs; - shape?: ValueRefs; - - // -- path - path?: ValueRefs; - - // -- arc - innerRadius?: ValueRefs; - outerRadius?: ValueRefs; - startAngle?: ValueRefs; - endAngle?: ValueRefs; - - // -- area / line - interpolate?: ValueRefs; - tension?: ValueRefs; - - // -- image / text - align?: ValueRefs; - baseline?: ValueRefs; - - // -- image - url?: ValueRefs; - - // -- text - text?: ValueRefs; - dx?: ValueRefs; - dy?: ValueRefs; - angle?: ValueRefs; - font?: ValueRefs; - fontSize?: ValueRefs; - fontWeight?: ValueRefs; - fontStyle?: ValueRefs; - } - - export interface ValueRef { - // TODO docs - value?: any; - field?: any; - group?: any; - scale?: any; - mult?: number; - offset?: number; - band?: boolean; - test?: string; - } - - export type ValueRefs = ValueRef | ValueRef[]; - - export var parse: Parse; - export namespace scene { - export function item(mark: Node): Node; - } - - export class Bounds implements Bounds { - x1: number; - y1: number; - x2: number; - y2: number; - clear(): Bounds; - set(x1: number, y1: number, x2: number, y2: number): Bounds; - add(x: number, y: number): Bounds; - expand(d: number): Bounds; - round(): Bounds; - translate(dx: number, dy: number): Bounds; - rotate(angle: number, x: number, y: number): Bounds; - union(b: Bounds): Bounds; - encloses(b: Bounds): boolean; - intersects(b: Bounds): boolean; - contains(x: number, y: number): boolean; - width(): number; - height(): number; - } - - // TODO: classes for View, Model, etc. -} - -export = vg; -export as namespace vg; -export as namespace Vega; diff --git a/types/vega/tsconfig.json b/types/vega/tsconfig.json deleted file mode 100644 index f49e5e811b..0000000000 --- a/types/vega/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "vega-tests.ts" - ] -} \ No newline at end of file diff --git a/types/vega/tslint.json b/types/vega/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/vega/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} diff --git a/types/vega/vega-tests.ts b/types/vega/vega-tests.ts deleted file mode 100644 index 5baeaee024..0000000000 --- a/types/vega/vega-tests.ts +++ /dev/null @@ -1,2035 +0,0 @@ - - -// examples from http://trifacta.github.io/vega/editor/ -var specs: Vega.Spec[]; - -specs[0] = { - "name": "arc", - "width": 400, - "height": 400, - "data": [ - { - "name": "table", - "values": [12, 23, 47, 6, 52, 19], - "transform": [ - { "type": "pie", "value": "data" } - ] - } - ], - "scales": [ - { - "name": "r", - "type": "sqrt", - "domain": { "data": "table", "field": "data" }, - "range": [20, 100] - } - ], - "marks": [ - { - "type": "arc", - "from": { "data": "table" }, - "properties": { - "enter": { - "x": { "group": "width", "mult": 0.5 }, - "y": { "group": "height", "mult": 0.5 }, - "startAngle": { "field": "startAngle" }, - "endAngle": { "field": "endAngle" }, - "innerRadius": { "value": 20 }, - "outerRadius": { "scale": "r" }, - "stroke": { "value": "#fff" } - }, - "update": { - "fill": { "value": "#ccc" } - }, - "hover": { - "fill": { "value": "pink" } - } - } - } - ] -} - -specs[1] = { - "width": 500, - "height": 200, - "padding": { "top": 10, "left": 30, "bottom": 30, "right": 10 }, - "data": [ - { - "name": "table", - "values": [ - { "x": 1, "y": 28 }, { "x": 2, "y": 55 }, - { "x": 3, "y": 43 }, { "x": 4, "y": 91 }, - { "x": 5, "y": 81 }, { "x": 6, "y": 53 }, - { "x": 7, "y": 19 }, { "x": 8, "y": 87 }, - { "x": 9, "y": 52 }, { "x": 10, "y": 48 }, - { "x": 11, "y": 24 }, { "x": 12, "y": 49 }, - { "x": 13, "y": 87 }, { "x": 14, "y": 66 }, - { "x": 15, "y": 17 }, { "x": 16, "y": 27 }, - { "x": 17, "y": 68 }, { "x": 18, "y": 16 }, - { "x": 19, "y": 49 }, { "x": 20, "y": 15 } - ] - } - ], - "scales": [ - { - "name": "x", - "type": "linear", - "range": "width", - "zero": false, - "domain": { "data": "table", "field": "data.x" } - }, - { - "name": "y", - "type": "linear", - "range": "height", - "nice": true, - "domain": { "data": "table", "field": "data.y" } - } - ], - "axes": [ - { "type": "x", "scale": "x", "ticks": 20 }, - { "type": "y", "scale": "y" } - ], - "marks": [ - { - "type": "area", - "from": { "data": "table" }, - "properties": { - "enter": { - "interpolate": { "value": "monotone" }, - "x": { "scale": "x", "field": "data.x" }, - "y": { "scale": "y", "field": "data.y" }, - "y2": { "scale": "y", "value": 0 }, - "fill": { "value": "steelblue" } - }, - "update": { - "fillOpacity": { "value": 1 } - }, - "hover": { - "fillOpacity": { "value": 0.5 } - } - } - } - ] -} - -specs[2] = { - "width": 200, - "height": 720, - "data": [ - { - "name": "barley", - "url": "data/barley.json" - }, - { - "name": "variety", - "source": "barley", - "transform": [ - { "type": "facet", "keys": ["data.variety"] }, - { "type": "stats", "value": "data.yield", "median": true }, - { "type": "sort", "by": "-median" } - ] - }, - { - "name": "site", - "source": "barley", - "transform": [ - { "type": "facet", "keys": ["data.site"] }, - { "type": "stats", "value": "data.yield", "median": true }, - { "type": "sort", "by": "-median" } - ] - } - ], - "scales": [ - { - "name": "g", - "type": "ordinal", - "range": "height", - "padding": 0.15, - "domain": { "data": "site", "field": "key" } - }, - { - "name": "x", - "type": "linear", - "nice": true, - "range": "width", - "domain": { "data": "barley", "field": "data.yield" } - }, - { - "name": "c", - "type": "ordinal", - "range": "category10" - } - ], - "axes": [ - { "type": "x", "scale": "x", "offset": -12 } - ], - "marks": [ - { - "type": "text", - "from": { "data": "site" }, - "properties": { - "enter": { - "x": { "group": "width", "mult": 0.5 }, - "y": { "scale": "g", "field": "key", "offset": -2 }, - "fontWeight": { "value": "bold" }, - "text": { "field": "key" }, - "align": { "value": "center" }, - "baseline": { "value": "bottom" }, - "fill": { "value": "#000" } - } - } - }, - { - "type": "group", - "from": { "data": "site" }, - "scales": [ - { - "name": "y", - "type": "ordinal", - "range": "height", - "points": true, - "padding": 1.2, - "domain": { "data": "variety", "field": "key" } - } - ], - "axes": [ - { - "type": "y", - "scale": "y", - "tickSize": 0, - "properties": { "axis": { "stroke": { "value": "transparent" } } } - } - ], - "properties": { - "enter": { - "x": { "value": 0.5 }, - "y": { "scale": "g", "field": "key" }, - "height": { "scale": "g", "band": true }, - "width": { "group": "width" }, - "stroke": { "value": "#ccc" } - } - }, - "marks": [ - { - "type": "symbol", - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.yield" }, - "y": { "scale": "y", "field": "data.variety" }, - "size": { "value": 50 }, - "stroke": { "scale": "c", "field": "data.year" }, - "strokeWidth": { "value": 2 } - } - } - } - ] - } - ] -} - -specs[3] = { - "width": 960, - "height": 500, - "data": [ - { - "name": "unemp", - "url": "data/unemployment.tsv", - "format": { "type": "tsv", "parse": { "rate": "number" } } - }, - { - "name": "counties", - "url": "data/us-10m.json", - "format": { "type": "topojson", "feature": "counties" }, - "transform": [ - { "type": "geopath", "value": "data", "projection": "albersUsa" }, - { - "type": "zip", - "key": "data.id", - "with": "unemp", - "withKey": "data.id", - "as": "value", - "default": null - }, - { "type": "filter", "test": "d.path!=null && d.value!=null" } - ] - } - ], - "scales": [ - { - "name": "color", - "type": "quantize", - "domain": [0, 0.15], - "range": ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", - "#4292c6", "#2171b5", "#08519c", "#08306b"] - } - ], - "marks": [ - { - "type": "path", - "from": { "data": "counties" }, - "properties": { - "enter": { "path": { "field": "path" } }, - "update": { "fill": { "scale": "color", "field": "value.data.rate" } }, - "hover": { "fill": { "value": "red" } } - } - } - ] -} - -specs[4] = { - "width": 300, - "height": 240, - "data": [ - { - "name": "table", - "url": "data/groups.json" - } - ], - "scales": [ - { - "name": "cat", - "type": "ordinal", - "range": "height", - "padding": 0.2, - "domain": { "data": "table", "field": "data.category" } - }, - { - "name": "val", - "range": "width", - "round": true, - "nice": true, - "domain": { "data": "table", "field": "data.value" } - }, - { - "name": "color", - "type": "ordinal", - "range": "category20" - } - ], - "axes": [ - { "type": "y", "scale": "cat", "tickSize": 0, "tickPadding": 8 }, - { "type": "x", "scale": "val" } - ], - "marks": [ - { - "type": "group", - "from": { - "data": "table", - "transform": [{ "type": "facet", "keys": ["data.category"] }] - }, - "properties": { - "enter": { - "y": { "scale": "cat", "field": "key" }, - "height": { "scale": "cat", "band": true } - } - }, - "scales": [ - { - "name": "pos", - "type": "ordinal", - "range": "height", - "domain": { "field": "data.position" } - } - ], - "marks": [ - { - "type": "rect", - "properties": { - "enter": { - "y": { "scale": "pos", "field": "data.position" }, - "height": { "scale": "pos", "band": true }, - "x": { "scale": "val", "field": "data.value" }, - "x2": { "scale": "val", "value": 0 }, - "fill": { "scale": "color", "field": "data.position" } - } - } - }, - { - "type": "text", - "properties": { - "enter": { - "y": { "scale": "pos", "field": "data.position" }, - "dy": { "scale": "pos", "band": true, "mult": 0.5 }, - "x": { "scale": "val", "field": "data.value", "offset": -4 }, - "fill": { "value": "white" }, - "align": { "value": "right" }, - "baseline": { "value": "middle" }, - "text": { "field": "data.value" } - } - } - } - ] - } - ] -} - -specs[5] = { - "width": 400, - "height": 100, - "padding": { "top": 30, "left": 30, "bottom": 30, "right": 10 }, - "data": [ - { - "name": "stats", - "values": [ - { "label": "Category A", "mean": 1, "lo": 0, "hi": 2 }, - { "label": "Category B", "mean": 2, "lo": 1.5, "hi": 2.5 }, - { "label": "Category C", "mean": 3, "lo": 1.7, "hi": 4.3 }, - { "label": "Category D", "mean": 4, "lo": 3, "hi": 5 }, - { "label": "Category E", "mean": 5, "lo": 4.1, "hi": 5.9 } - ] - } - ], - "scales": [ - { - "name": "y", - "type": "ordinal", - "range": "height", - "domain": { "data": "stats", "field": "index" } - }, - { - "name": "x", - "range": [100, 400], - "nice": true, - "zero": true, - "domain": { "data": "stats", "field": "data.hi" } - } - ], - "axes": [ - { "type": "x", "scale": "x", "ticks": 6 } - ], - "marks": [ - { - "type": "text", - "from": { "data": "stats" }, - "properties": { - "enter": { - "x": { "value": 0 }, - "y": { "scale": "y", "field": "index" }, - "baseline": { "value": "middle" }, - "fill": { "value": "#000" }, - "text": { "field": "data.label" }, - "font": { "value": "Helvetica Neue" }, - "fontSize": { "value": 13 } - } - } - }, - { - "type": "rect", - "from": { "data": "stats" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.lo" }, - "x2": { "scale": "x", "field": "data.hi" }, - "y": { "scale": "y", "field": "index", "offset": -1 }, - "height": { "value": 1 }, - "fill": { "value": "#888" } - } - } - }, - { - "type": "symbol", - "from": { "data": "stats" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.mean" }, - "y": { "scale": "y", "field": "index" }, - "size": { "value": 40 }, - "fill": { "value": "#000" } - } - } - } - ] -} - -specs[6] = { - "name": "force", - "width": 500, - "height": 500, - "padding": { "top": 0, "bottom": 0, "left": 0, "right": 0 }, - "data": [ - { - "name": "edges", - "url": "data/miserables.json", - "format": { "type": "json", "property": "links" }, - "transform": [ - { "type": "copy", "from": "data", "fields": ["source", "target"] } - ] - }, - { - "name": "nodes", - "url": "data/miserables.json", - "format": { "type": "json", "property": "nodes" }, - "transform": [ - { - "type": "force", - "links": "edges", - "linkDistance": 70, - "charge": -100, - "iterations": 1000 - } - ] - } - ], - "marks": [ - { - "type": "path", - "from": { - "data": "edges", - "transform": [ - { "type": "link", "shape": "line" } - ] - }, - "properties": { - "update": { - "path": { "field": "path" }, - "stroke": { "value": "#ccc" }, - "strokeWidth": { "value": 0.5 } - } - } - }, - { - "type": "symbol", - "from": { "data": "nodes" }, - "properties": { - "enter": { - "fillOpacity": { "value": 0.3 }, - "stroke": { "value": "steelblue" } - }, - "update": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "fill": { "value": "steelblue" } - }, - "hover": { - "fill": { "value": "#f00" } - } - } - } - ] -}; - -specs[7] = { - "name": "image", - "width": 200, - "height": 200, - "padding": { "left": 30, "top": 10, "bottom": 30, "right": 10 }, - "data": [ - { - "name": "data", - "values": [ - { "x": 0.5, "y": 0.5, "img": "data/ffox.png" }, - { "x": 1.5, "y": 1.5, "img": "data/gimp.png" }, - { "x": 2.5, "y": 2.5, "img": "data/7zip.png" } - ] - } - ], - "scales": [ - { "name": "x", "domain": [0, 3], "range": "width" }, - { "name": "y", "domain": [0, 3], "range": "height" } - ], - "axes": [ - { "type": "x", "scale": "x" }, - { "type": "y", "scale": "y" } - ], - "marks": [ - { - "type": "image", - "from": { "data": "data" }, - "properties": { - "enter": { - "url": { "field": "data.img" }, - "width": { "value": 50 }, - "height": { "value": 50 }, - "x": { "scale": "x", "field": "data.x" }, - "y": { "scale": "y", "field": "data.y" }, - "align": { "value": "center" }, - "baseline": { "value": "middle" } - }, - "update": { - "opacity": { "value": 1.0 } - }, - "hover": { - "opacity": { "value": 0.5 } - } - } - } - ] -} - -specs[8] = { - "width": 800, - "height": 500, - "padding": { "left": 15, "right": 65, "top": 10, "bottom": 20 }, - "data": [ - { - "name": "jobs", - "url": "data/jobs.json" - }, - { - "name": "series", - "source": "jobs", - "transform": [ - { "type": "facet", "keys": ["data.job", "data.sex"] }, - { "type": "stats", "value": "data.perc" }, - { "type": "stack", "point": "data.year", "height": "data.perc", "order": "reverse" } - ] - }, - { - "name": "stats", - "source": "jobs", - "transform": [ - { "type": "facet", "keys": ["data.year"] }, - { "type": "stats", "value": "data.perc" } - ] - } - ], - "scales": [ - { - "name": "x", - "type": "linear", - "range": "width", - "zero": false, "round": true, - "domain": { "data": "jobs", "field": "data.year" } - }, - { - "name": "y", - "type": "linear", - "range": "height", "round": true, - "domain": { "data": "stats", "field": "sum" } - }, - { - "name": "color", - "type": "ordinal", - "domain": ["men", "women"], - "range": ["#33f", "#f33"] - }, - { - "name": "alpha", - "type": "linear", - "domain": { "data": "series", "field": "sum" }, - "range": [0.4, 0.8] - }, - { - "name": "font", - "type": "sqrt", - "range": [0, 24], "round": true, - "domain": { "data": "stats", "field": "sum" } - }, - { - "name": "align", - "type": "quantize", - "range": ["left", "center", "right"], "zero": false, - "domain": [1730, 2130] - }, - { - "name": "offset", - "type": "quantize", - "range": [6, 0, -6], "zero": false, - "domain": [1730, 2130] - } - ], - "axes": [ - { "type": "x", "scale": "x", "format": "d", "ticks": 15, "tickSizeEnd": 0 }, - { - "type": "y", "scale": "y", "format": "n", "orient": "right", - "grid": true, "layer": "back", "tickSize": 12, - "properties": { - "axis": { "stroke": { "value": "transparent" } }, - "grid": { "stroke": { "value": "#ccc" } }, - "ticks": { "stroke": { "value": "#ccc" } } - } - } - ], - "marks": [ - { - "type": "group", - "from": { "data": "series" }, - "marks": [ - { - "type": "area", - "properties": { - "update": { - "x": { "scale": "x", "field": "data.year" }, - "y": { "scale": "y", "field": "y" }, - "y2": { "scale": "y", "field": "y2" }, - "fill": { "scale": "color", "field": "data.sex" }, - "fillOpacity": { "scale": "alpha", "group": "sum" } - }, - "hover": { - "fillOpacity": { "value": 0.2 } - } - } - } - ] - }, - { - "type": "group", - "from": { "data": "series" }, - "marks": [ - { - "type": "text", - "from": { - "transform": [ - { "type": "slice", "by": "max", "field": "data.perc" } - ] - }, - "interactive": false, - "properties": { - "update": { - "x": { "scale": "x", "field": "data.year" }, - "dx": { "scale": "offset", "field": "data.year" }, - "y": { "scale": "y", "field": "cy" }, - "fill": { "value": "#000" }, - "fillOpacity": { "scale": "font", "field": "data.perc", "mult": 0.15 }, - "fontSize": { "scale": "font", "field": "data.perc", "offset": 5 }, - "text": { "field": "data.job" }, - "align": { "scale": "align", "field": "data.year" }, - "baseline": { "value": "middle" } - } - } - } - ] - } - ] -}; - -specs[9] = { - "name": "lifelines", - "width": 400, - "height": 100, - "data": [ - { - "name": "people", - "values": [ - { - "label": "Washington", "born": -7506057600000, "died": -5366196000000, - "enter": -5701424400000, "leave": -5453884800000 - }, - { - "label": "Adams", "born": -7389766800000, "died": -4528285200000, - "enter": -5453884800000, "leave": -5327740800000 - }, - { - "label": "Jefferson", "born": -7154586000000, "died": -4528285200000, - "enter": -5327740800000, "leave": -5075280000000 - }, - { - "label": "Madison", "born": -6904544400000, "died": -4213184400000, - "enter": -5075280000000, "leave": -4822819200000 - }, - { - "label": "Monroe", "born": -6679904400000, "died": -4370518800000, - "enter": -4822819200000, "leave": -4570358400000 - } - ] - }, - { - "name": "events", - "format": { "type": "json", "parse": { "when": "date" } }, - "values": [ - { "name": "Decl. of Independence", "when": "July 4, 1776" }, - { "name": "U.S. Constitution", "when": "3/4/1789" }, - { "name": "Louisiana Purchase", "when": "April 30, 1803" }, - { "name": "Monroe Doctrine", "when": "Dec 2, 1823" } - ] - } - - ], - "scales": [ - { - "name": "y", - "type": "ordinal", - "range": "height", - "domain": { "data": "people", "field": "data.label" } - }, - { - "name": "x", - "type": "time", - "range": "width", - "round": true, - "nice": "year", - "domain": { "data": "people", "field": ["data.born", "data.died"] } - } - ], - "axes": [ - { "type": "x", "scale": "x" } - ], - "marks": [ - { - "type": "text", - "from": { "data": "events" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.when" }, - "y": { "value": -10 }, - "angle": { "value": -25 }, - "fill": { "value": "#000" }, - "text": { "field": "data.name" }, - "font": { "value": "Helvetica Neue" }, - "fontSize": { "value": 10 } - } - } - }, - { - "type": "rect", - "from": { "data": "events" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.when" }, - "y": { "value": -8 }, - "width": { "value": 1 }, - "height": { "group": "height", "offset": 8 }, - "fill": { "value": "#888" } - } - } - }, - { - "type": "text", - "from": { "data": "people" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.born" }, - "y": { "scale": "y", "field": "data.label", "offset": -3 }, - "fill": { "value": "#000" }, - "text": { "field": "data.label" }, - "font": { "value": "Helvetica Neue" }, - "fontSize": { "value": 10 } - } - } - }, - { - "type": "rect", - "from": { "data": "people" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.born" }, - "x2": { "scale": "x", "field": "data.died" }, - "y": { "scale": "y", "field": "data.label" }, - "height": { "value": 2 }, - "fill": { "value": "#557" } - } - } - }, - { - "type": "rect", - "from": { "data": "people" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.enter" }, - "x2": { "scale": "x", "field": "data.leave" }, - "y": { "scale": "y", "field": "data.label", "offset": -1 }, - "height": { "value": 4 }, - "fill": { "value": "#e44" } - } - } - } - ] -} - -specs[10] = { - "width": 1920, - "height": 1000, - "viewport": [960, 500], - "data": [ - { - "name": "world", - "url": "data/world-110m.json", - "format": { "type": "topojson", "feature": "countries" } - } - ], - "marks": [ - { - "type": "path", - "from": { - "data": "world", - "transform": [{ - "type": "geopath", - "value": "data", - "projection": "winkel3", - "scale": 300, - "translate": [960, 500] - }] - }, - "properties": { - "enter": { - "stroke": { "value": "#fff" }, - "path": { "field": "path" } - }, - "update": { "fill": { "value": "#ccc" } }, - "hover": { "fill": { "value": "pink" } } - } - } - ] -} - -specs[11] = { - "width": 760, - "height": 260, - "data": [ - { - "name": "temp", - "url": "data/napoleon.json", - "format": { "type": "json", "property": "temp" }, - "transform": [ - { "type": "formula", "field": "lat", "expr": "55" }, - { - "type": "geo", - "lat": "lat", - "lon": "data.lon", - "center": [32.52, 53.3], - "scale": 3000 - } - ] - }, - { - "name": "army", - "url": "data/napoleon.json", - "format": { "type": "json", "property": "army" }, - "transform": [ - { - "type": "geo", - "lat": "data.lat", - "lon": "data.lon", - "center": [32.52, 53.3], - "scale": 3000 - } - ] - }, - { - "name": "cities", - "url": "data/napoleon.json", - "format": { "type": "json", "property": "cities" }, - "transform": [ - { - "type": "geo", - "lat": "data.lat", - "lon": "data.lon", - "center": [32.52, 53.3], - "scale": 3000 - } - ] - } - ], - "scales": [ - { - "name": "color", - "type": "ordinal", - "domain": { "data": "army", "field": "data.dir" }, - "range": ["brown", "black"] - }, - { - "name": "lw", - "type": "linear", "zero": false, - "domain": { "data": "army", "field": "data.size" }, - "range": [1, 50] - } - ], - "marks": [ - { - "type": "group", - "properties": { - "enter": { - "x": { "value": 0 }, - "y": { "value": 200 }, - "width": { "group": "width" }, - "height": { "value": 60 } - } - }, - "scales": [ - { - "name": "y", - "type": "linear", "zero": false, "round": true, - "domain": { "data": "temp", "field": "data.temp" }, - "range": "height" - } - ], - "axes": [ - { - "type": "y", "scale": "y", "ticks": 4, "orient": "right", - "grid": true, "layer": "back" - } - ], - "marks": [ - { - "type": "rule", - "from": { "data": "temp" }, - "properties": { - "enter": { - "x": { "field": "x" }, - "y1": 0, - "y2": { "scale": "y", "field": "data.temp" }, - "stroke": { "value": "#ccc" } - } - } - }, - { - "type": "line", - "from": { "data": "temp" }, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "scale": "y", "field": "data.temp" }, - "stroke": { "value": "#000" }, - "strokeWidth": { "value": 2 } - } - } - }, - { - "type": "text", - "from": { "data": "temp" }, - "properties": { - "enter": { - "x": { "field": "x", "offset": -2 }, - "y": { "scale": "y", "field": "data.temp", "offset": 6 }, - "fill": { "value": "#000" }, - "text": { "field": "data.date" }, - "font": { "value": "Georgia" }, - "fontSize": { "value": 10 }, - "align": { "value": "center" }, - "baseline": { "value": "top" } - } - } - } - ] - }, - { - "type": "group", - "from": { - "data": "army", - "transform": [ - { "type": "facet", "keys": ["data.group", "data.dir"] } - ] - }, - "marks": [ - { - "type": "group", - "from": { - "transform": [ - { "type": "window", "size": 2, "step": 1 } - ] - }, - "marks": [ - { - "type": "line", - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "stroke": { "scale": "color", "field": "data.dir" }, - "strokeWidth": { "scale": "lw", "field": "data.size" }, - "strokeCap": { "value": "round" } - } - } - } - ] - } - ] - }, - { - "type": "symbol", - "from": { "data": "cities" }, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "size": { "value": 25 }, - "fill": { "value": "brown" }, - "stroke": { "value": "#000" } - } - } - }, - { - "type": "text", - "from": { "data": "cities" }, - "properties": { - "enter": { - "x": { "field": "x", "offset": 1 }, - "y": { "field": "y", "offset": -4 }, - "fill": { "value": "#fff" }, - "fillOpacity": { "value": 0.8 }, - "text": { "field": "data.city" }, - "align": { "value": "center" }, - "baseline": { "value": "bottom" }, - "font": { "value": "Georgia" }, - "fontSize": { "value": 9 }, - "fontStyle": { "value": "italic" } - } - } - }, - { - "type": "text", - "from": { "data": "cities" }, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y", "offset": -5 }, - "fill": { "value": "#000" }, - "text": { "field": "data.city" }, - "align": { "value": "center" }, - "baseline": { "value": "bottom" }, - "font": { "value": "Georgia" }, - "fontSize": { "value": 9 }, - "fontStyle": { "value": "italic" } - } - } - } - ] -} - -specs[12] = { - "width": 700, - "height": 400, - "data": [ - { - "name": "cars", - "url": "data/cars.json" - }, - { - "name": "fields", - "values": ["cyl", "dsp", "lbs", "hp", "acc", "mpg", "year"] - } - ], - "scales": [ - { - "name": "ord", - "type": "ordinal", - "range": "width", "points": true, - "domain": { "data": "fields", "field": "data" } - }, - { - "name": "cyl", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.cyl" } - }, - { - "name": "dsp", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.dsp" } - }, - { - "name": "lbs", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.lbs" } - }, - { - "name": "hp", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.hp" } - }, - { - "name": "acc", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.acc" } - }, - { - "name": "mpg", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.mpg" } - }, - { - "name": "year", - "range": "height", "zero": false, "nice": true, - "domain": { "data": "cars", "field": "data.year" } - } - ], - "axes": [ - { "type": "y", "scale": "cyl", "offset": { "scale": "ord", "value": "cyl" } }, - { "type": "y", "scale": "dsp", "offset": { "scale": "ord", "value": "dsp" } }, - { "type": "y", "scale": "lbs", "offset": { "scale": "ord", "value": "lbs" } }, - { "type": "y", "scale": "hp", "offset": { "scale": "ord", "value": "hp" } }, - { "type": "y", "scale": "acc", "offset": { "scale": "ord", "value": "acc" } }, - { "type": "y", "scale": "mpg", "offset": { "scale": "ord", "value": "mpg" } }, - { "type": "y", "scale": "year", "offset": { "scale": "ord", "value": "year" } } - ], - "marks": [ - { - "type": "group", - "from": { "data": "cars" }, - "marks": [ - { - "type": "line", - "from": { "data": "fields" }, - "properties": { - "enter": { - "x": { "scale": "ord", "field": "data" }, - "y": { "scale": { "field": "data" }, "group": "data", "field": "data" }, - "stroke": { "value": "steelblue" }, - "strokeWidth": { "value": 1 }, - "strokeOpacity": { "value": 0.3 } - } - } - } - ] - }, - { - "type": "text", - "from": { "data": "fields" }, - "properties": { - "enter": { - "x": { "scale": "ord", "field": "data", "offset": -8 }, - "y": { "group": "height", "offset": 6 }, - "fontWeight": { "value": "bold" }, - "fill": { "value": "black" }, - "text": { "field": "data" }, - "align": { "value": "right" }, - "baseline": { "value": "top" } - } - } - } - ] -} - -specs[13] = { - "width": 700, - "height": 400, - "padding": { "top": 0, "left": 0, "bottom": 20, "right": 0 }, - "data": [ - { - "name": "pop2000", - "url": "data/population.json", - "transform": [ - { "type": "filter", "test": "d.data.year == 2000" } - ] - } - ], - "scales": [ - { - "name": "g", - "domain": [0, 1], - "range": [340, 10] - }, - { - "name": "y", - "type": "ordinal", - "range": "height", - "reverse": true, - "domain": { "data": "pop2000", "field": "data.age" } - }, - { - "name": "c", - "type": "ordinal", - "domain": [1, 2], - "range": ["#1f77b4", "#e377c2"] - } - ], - "marks": [ - { - "type": "text", - "interactive": false, - "from": { - "data": "pop2000", - "transform": [{ "type": "unique", "field": "data.age", "as": "age" }] - }, - "properties": { - "enter": { - "x": { "value": 325 }, - "y": { "scale": "y", "field": "age", "offset": 11 }, - "text": { "field": "age" }, - "baseline": { "value": "middle" }, - "align": { "value": "center" }, - "fill": { "value": "#000" } - } - } - }, - { - "type": "group", - "from": { - "data": "pop2000", - "transform": [ - { "type": "facet", "keys": ["data.sex"] } - ] - }, - "properties": { - "update": { - "x": { "scale": "g", "field": "index" }, - "y": { "value": 0 }, - "width": { "value": 300 }, - "height": { "group": "height" } - } - }, - "scales": [ - { - "name": "x", - "type": "linear", - "range": "width", - "reverse": true, - "nice": true, - "domain": { "data": "pop2000", "field": "data.people" } - } - ], - "axes": [ - { "type": "x", "scale": "x", "format": "s" } - ], - "marks": [ - { - "type": "rect", - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.people" }, - "x2": { "scale": "x", "value": 0 }, - "y": { "scale": "y", "field": "data.age" }, - "height": { "scale": "y", "band": true, "offset": -1 }, - "fillOpacity": { "value": 0.6 }, - "fill": { "scale": "c", "field": "data.sex" } - } - } - } - ] - } - ] -} - -specs[14] = { - "width": 200, - "height": 200, - "data": [ - { - "name": "iris", - "url": "data/iris.json" - } - ], - "scales": [ - { - "name": "x", - "nice": true, - "range": "width", - "domain": { "data": "iris", "field": "data.sepalWidth" } - }, - { - "name": "y", - "nice": true, - "range": "height", - "domain": { "data": "iris", "field": "data.petalLength" } - }, - { - "name": "c", - "type": "ordinal", - "domain": { "data": "iris", "field": "data.species" }, - "range": ["#800", "#080", "#008"] - } - ], - "axes": [ - { "type": "x", "scale": "x", "offset": 5, "ticks": 5, "title": "Sepal Width" }, - { "type": "y", "scale": "y", "offset": 5, "ticks": 5, "title": "Petal Length" } - ], - "legends": [ - { - "fill": "c", - "title": "Species", - "offset": 0, - "properties": { - "symbols": { - "fillOpacity": { "value": 0.5 }, - "stroke": { "value": "transparent" } - } - } - } - ], - "marks": [ - { - "type": "symbol", - "from": { "data": "iris" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.sepalWidth" }, - "y": { "scale": "y", "field": "data.petalLength" }, - "fill": { "scale": "c", "field": "data.species" }, - "fillOpacity": { "value": 0.5 } - }, - "update": { - "size": { "value": 100 }, - "stroke": { "value": "transparent" } - }, - "hover": { - "size": { "value": 300 }, - "stroke": { "value": "white" } - } - } - } - ] -} - -specs[15] = { - "width": 600, - "height": 600, - "data": [ - { - "name": "iris", - "url": "data/iris.json" - }, - { - "name": "fields", - "values": ["petalLength", "petalWidth", "sepalWidth", "sepalLength"] - } - ], - "scales": [ - { - "name": "gx", - "type": "ordinal", - "range": "width", - "round": true, - "domain": { "data": "fields", "field": "data" } - }, - { - "name": "gy", - "type": "ordinal", - "range": "height", - "round": true, - "domain": { "data": "fields", "field": "data" } - }, - { - "name": "c", - "type": "ordinal", - "domain": { "data": "iris", "field": "data.species" }, - "range": ["#800", "#080", "#008"] - } - ], - "legends": [ - { - "fill": "c", - "title": "Species", - "offset": 10, - "properties": { - "symbols": { - "fillOpacity": { "value": 0.5 }, - "stroke": { "value": "transparent" } - } - } - } - ], - "marks": [ - { - "type": "group", - "from": { - "data": "fields", - "transform": [{ "type": "cross" }] - }, - "properties": { - "enter": { - "x": { "scale": "gx", "field": "a.data" }, - "y": { "scale": "gy", "field": "b.data" }, - "width": { "scale": "gx", "band": true, "offset": -35 }, - "height": { "scale": "gy", "band": true, "offset": -35 }, - "stroke": { "value": "#ddd" } - } - }, - "scales": [ - { - "name": "x", - "range": "width", - "zero": false, - "round": true, - "domain": { "data": "iris", "field": { "group": "a.data" } } - }, - { - "name": "y", - "range": "height", - "zero": false, - "round": true, - "domain": { "data": "iris", "field": { "group": "b.data" } } - } - ], - "axes": [ - { "type": "x", "scale": "x", "ticks": 5 }, - { "type": "y", "scale": "y", "ticks": 5 } - ], - "marks": [ - { - "type": "symbol", - "from": { "data": "iris" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": { "group": "a.data" } }, - "y": { "scale": "y", "field": { "group": "b.data" } }, - "fill": { "scale": "c", "field": "data.spec[0]ies" }, - "fillOpacity": { "value": 0.5 } - }, - "update": { - "size": { "value": 36 }, - "stroke": { "value": "transparent" } - }, - "hover": { - "size": { "value": 100 }, - "stroke": { "value": "white" } - } - } - } - ] - } - ] -} - -specs[16] = { - "width": 500, - "height": 200, - "padding": { "top": 10, "left": 30, "bottom": 30, "right": 10 }, - "data": [ - { - "name": "table", - "values": [ - { "x": 0, "y": 28, "c": 0 }, { "x": 0, "y": 55, "c": 1 }, - { "x": 1, "y": 43, "c": 0 }, { "x": 1, "y": 91, "c": 1 }, - { "x": 2, "y": 81, "c": 0 }, { "x": 2, "y": 53, "c": 1 }, - { "x": 3, "y": 19, "c": 0 }, { "x": 3, "y": 87, "c": 1 }, - { "x": 4, "y": 52, "c": 0 }, { "x": 4, "y": 48, "c": 1 }, - { "x": 5, "y": 24, "c": 0 }, { "x": 5, "y": 49, "c": 1 }, - { "x": 6, "y": 87, "c": 0 }, { "x": 6, "y": 66, "c": 1 }, - { "x": 7, "y": 17, "c": 0 }, { "x": 7, "y": 27, "c": 1 }, - { "x": 8, "y": 68, "c": 0 }, { "x": 8, "y": 16, "c": 1 }, - { "x": 9, "y": 49, "c": 0 }, { "x": 9, "y": 15, "c": 1 } - ] - }, - { - "name": "stats", - "source": "table", - "transform": [ - { "type": "facet", "keys": ["data.x"] }, - { "type": "stats", "value": "data.y" } - ] - } - ], - "scales": [ - { - "name": "x", - "type": "linear", - "range": "width", - "zero": false, - "domain": { "data": "table", "field": "data.x" } - }, - { - "name": "y", - "type": "linear", - "range": "height", - "nice": true, - "domain": { "data": "stats", "field": "sum" } - }, - { - "name": "color", - "type": "ordinal", - "range": "category10" - } - ], - "axes": [ - { "type": "x", "scale": "x" }, - { "type": "y", "scale": "y" } - ], - "marks": [ - { - "type": "group", - "from": { - "data": "table", - "transform": [ - { "type": "facet", "keys": ["data.c"] }, - { "type": "stack", "point": "data.x", "height": "data.y" } - ] - }, - "marks": [ - { - "type": "area", - "properties": { - "enter": { - "interpolate": { "value": "monotone" }, - "x": { "scale": "x", "field": "data.x" }, - "y": { "scale": "y", "field": "y" }, - "y2": { "scale": "y", "field": "y2" }, - "fill": { "scale": "color", "field": "data.c" } - }, - "update": { - "fillOpacity": { "value": 1 } - }, - "hover": { - "fillOpacity": { "value": 0.5 } - } - } - } - ] - } - ] -} - -specs[17] = { - "width": 500, - "height": 200, - "padding": { "top": 10, "left": 30, "bottom": 30, "right": 10 }, - "data": [ - { - "name": "table", - "values": [ - { "x": 0, "y": 28, "c": 0 }, { "x": 0, "y": 55, "c": 1 }, - { "x": 1, "y": 43, "c": 0 }, { "x": 1, "y": 91, "c": 1 }, - { "x": 2, "y": 81, "c": 0 }, { "x": 2, "y": 53, "c": 1 }, - { "x": 3, "y": 19, "c": 0 }, { "x": 3, "y": 87, "c": 1 }, - { "x": 4, "y": 52, "c": 0 }, { "x": 4, "y": 48, "c": 1 }, - { "x": 5, "y": 24, "c": 0 }, { "x": 5, "y": 49, "c": 1 }, - { "x": 6, "y": 87, "c": 0 }, { "x": 6, "y": 66, "c": 1 }, - { "x": 7, "y": 17, "c": 0 }, { "x": 7, "y": 27, "c": 1 }, - { "x": 8, "y": 68, "c": 0 }, { "x": 8, "y": 16, "c": 1 }, - { "x": 9, "y": 49, "c": 0 }, { "x": 9, "y": 15, "c": 1 } - ] - }, - { - "name": "stats", - "source": "table", - "transform": [ - { "type": "facet", "keys": ["data.x"] }, - { "type": "stats", "value": "data.y" } - ] - } - ], - "scales": [ - { - "name": "x", - "type": "ordinal", - "range": "width", - "domain": { "data": "table", "field": "data.x" } - }, - { - "name": "y", - "type": "linear", - "range": "height", - "nice": true, - "domain": { "data": "stats", "field": "sum" } - }, - { - "name": "color", - "type": "ordinal", - "range": "category10" - } - ], - "axes": [ - { "type": "x", "scale": "x" }, - { "type": "y", "scale": "y" } - ], - "marks": [ - { - "type": "group", - "from": { - "data": "table", - "transform": [ - { "type": "facet", "keys": ["data.c"] }, - { "type": "stack", "point": "data.x", "height": "data.y" } - ] - }, - "marks": [ - { - "type": "rect", - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.x" }, - "width": { "scale": "x", "band": true, "offset": -1 }, - "y": { "scale": "y", "field": "y" }, - "y2": { "scale": "y", "field": "y2" }, - "fill": { "scale": "color", "field": "data.c" } - }, - "update": { - "fillOpacity": { "value": 1 } - }, - "hover": { - "fillOpacity": { "value": 0.5 } - } - } - } - ] - } - ] -} - -specs[18] = { - "width": 500, - "height": 200, - "data": [ - { - "name": "stocks", - "url": "data/stocks.csv", - "format": { "type": "csv", "parse": { "price": "number", "date": "date" } } - } - ], - "scales": [ - { - "name": "x", - "type": "time", - "range": "width", - "domain": { "data": "stocks", "field": "data.date" } - }, - { - "name": "y", - "type": "linear", - "range": "height", - "nice": true, - "domain": { "data": "stocks", "field": "data.price" } - }, - { - "name": "color", "type": "ordinal", "range": "category10" - } - ], - "axes": [ - { "type": "x", "scale": "x", "tickSizeEnd": 0 }, - { "type": "y", "scale": "y" } - ], - "marks": [ - { - "type": "group", - "from": { - "data": "stocks", - "transform": [{ "type": "facet", "keys": ["data.symbol"] }] - }, - "marks": [ - { - "type": "line", - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.date" }, - "y": { "scale": "y", "field": "data.price" }, - "stroke": { "scale": "color", "field": "data.symbol" }, - "strokeWidth": { "value": 2 } - } - } - }, - { - "type": "text", - "from": { - "transform": [{ "type": "filter", "test": "index==data.length-1" }] - }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "data.date", "offset": 2 }, - "y": { "scale": "y", "field": "data.price" }, - "fill": { "scale": "color", "field": "data.symbol" }, - "text": { "field": "data.symbol" }, - "baseline": { "value": "middle" } - } - } - } - ] - } - ] -} - -specs[19] = { - "name": "treemap", - "width": 960, - "height": 500, - "padding": 2.5, - "data": [ - { - "name": "tree", - "url": "data/flare.json", - "format": { "type": "treejson" }, - "transform": [ - { "type": "treemap", "value": "data.size" } - ] - } - ], - "scales": [ - { - "name": "color", - "type": "ordinal", - "range": [ - "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", - "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", - "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", - "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9" - ] - }, - { - "name": "size", - "type": "ordinal", - "domain": [0, 1, 2, 3], - "range": [256, 28, 20, 14] - }, - { - "name": "opacity", - "type": "ordinal", - "domain": [0, 1, 2, 3], - "range": [0.15, 0.5, 0.8, 1.0] - } - ], - "marks": [ - { - "type": "rect", - "from": { - "data": "tree", - "transform": [{ "type": "filter", "test": "d.values" }] - }, - "interactive": false, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "width": { "field": "width" }, - "height": { "field": "height" }, - "fill": { "scale": "color", "field": "data.name" } - } - } - }, - { - "type": "rect", - "from": { - "data": "tree", - "transform": [{ "type": "filter", "test": "!d.values" }] - }, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "width": { "field": "width" }, - "height": { "field": "height" }, - "stroke": { "value": "#fff" } - }, - "update": { - "fill": { "value": "rgba(0,0,0,0)" } - }, - "hover": { - "fill": { "value": "red" } - } - } - }, - { - "type": "text", - "from": { - "data": "tree", - "transform": [{ "type": "filter", "test": "d.values" }] - }, - "interactive": false, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "dx": { "field": "width", "mult": 0.5 }, - "dy": { "field": "height", "mult": 0.5 }, - "font": { "value": "Helvetica Neue" }, - "fontSize": { "scale": "size", "field": "depth" }, - "align": { "value": "center" }, - "baseline": { "value": "middle" }, - "fill": { "value": "#000" }, - "fillOpacity": { "scale": "opacity", "field": "depth" }, - "text": { "field": "data.name" } - } - } - } - ] -} - -specs[20] = { - "width": 250, - "height": 200, - "data": [ - { - "name": "weather", - "url": "data/weather.json" - } - ], - "scales": [ - { - "name": "x", - "type": "ordinal", - "range": "width", - "padding": 0.1, "round": true, - "domain": { "data": "weather", "field": "index" } - }, - { - "name": "y", - "range": "height", - "nice": true, "zero": false, "round": true, - "domain": { - "data": "weather", - "field": ["data.record.low", "data.record.high"] - } - } - ], - "axes": [ - { - "type": "y", "scale": "y", "ticks": 3, "tickSize": 0, - "orient": "right", "grid": true, - "properties": { - "grid": { "stroke": { "value": "white" }, "strokeWidth": { "value": 2 } }, - "axis": { "stroke": { "value": "transparent" } } - } - } - ], - "marks": [ - { - "type": "text", - "from": { "data": "weather" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index" }, - "dx": { "scale": "x", "band": true, "mult": 0.5 }, - "y": { "value": 0 }, - "fill": { "value": "#000" }, - "text": { "field": "data.day" }, - "align": { "value": "center" }, - "baseline": { "value": "bottom" } - } - } - }, - { - "type": "rect", - "from": { "data": "weather" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index" }, - "width": { "scale": "x", "band": true, "offset": -1 }, - "y": { "scale": "y", "field": "data.record.low" }, - "y2": { "scale": "y", "field": "data.record.high" }, - "fill": { "value": "#ccc" } - } - } - }, - { - "type": "rect", - "from": { "data": "weather" }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index" }, - "width": { "scale": "x", "band": true, "offset": -1 }, - "y": { "scale": "y", "field": "data.normal.low" }, - "y2": { "scale": "y", "field": "data.normal.high" }, - "fill": { "value": "#999" } - } - } - }, - { - "type": "rect", - "from": { - "data": "weather", - "transform": [{ "type": "filter", "test": "d.data.actual" }] - }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index", "offset": 4 }, - "width": { "scale": "x", "band": true, "offset": -8 }, - "y": { "scale": "y", "field": "data.actual.low" }, - "y2": { "scale": "y", "field": "data.actual.high" }, - "fill": { "value": "#000" } - } - } - }, - { - "type": "rect", - "from": { - "data": "weather", - "transform": [{ "type": "filter", "test": "d.data.forecast" }] - }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index", "offset": 9 }, - "width": { "scale": "x", "band": true, "offset": -18 }, - "y": { "scale": "y", "field": "data.forecast.low.low" }, - "y2": { "scale": "y", "field": "data.forecast.high.high" }, - "fill": { "value": "#000" } - } - } - }, - { - "type": "rect", - "from": { - "data": "weather", - "transform": [{ "type": "filter", "test": "d.data.forecast" }] - }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index", "offset": 4 }, - "width": { "scale": "x", "band": true, "offset": -8 }, - "y": { "scale": "y", "field": "data.forecast.low.low" }, - "y2": { "scale": "y", "field": "data.forecast.low.high" }, - "fill": { "value": "#000" } - } - } - }, - { - "type": "rect", - "from": { - "data": "weather", - "transform": [{ "type": "filter", "test": "d.data.forecast" }] - }, - "properties": { - "enter": { - "x": { "scale": "x", "field": "index", "offset": 4 }, - "width": { "scale": "x", "band": true, "offset": -8 }, - "y": { "scale": "y", "field": "data.forecast.high.low" }, - "y2": { "scale": "y", "field": "data.forecast.high.high" }, - "fill": { "value": "#000" } - } - } - } - ] -} - -const hoverFill21: Vega.ValueRefs = [{ - "test": "datum.value < 30", - "value": "#f00" -}, { - "value": "#f55" -}]; - -specs[21] = { - "name": "wordcloud", - "width": 400, - "height": 400, - "padding": { "top": 0, "bottom": 0, "left": 0, "right": 0 }, - "data": [ - { - "name": "table", - "values": [ - { "text": "poem", "value": 80 }, - { "text": "peom", "value": 44 }, - { "text": "moep", "value": 40 }, - { "text": "meop", "value": 36 }, - { "text": "emop", "value": 32 }, - { "text": "epom", "value": 28 }, - { "text": "opem", "value": 24 }, - { "text": "omep", "value": 20 }, - { "text": "mope", "value": 56 }, - { "text": "mepo", "value": 12 }, - { "text": "pemo", "value": 10 }, - { "text": "pome", "value": 10 } - ], - "transform": [ - { - "type": "wordcloud", - "text": "data.text", - "font": "Helvetica Neue", - "fontSize": "data.value", - "rotate": { "random": [-60, -30, 0, 30, 60] } - } - ] - } - ], - "marks": [ - { - "type": "text", - "from": { "data": "table" }, - "properties": { - "enter": { - "x": { "field": "x" }, - "y": { "field": "y" }, - "angle": { "field": "angle" }, - "align": { "value": "center" }, - "baseline": { "value": "alphabetic" }, - "font": { "field": "font" }, - "fontSize": { "field": "fontSize" }, - "text": { "field": "data.text" } - }, - "update": { - "fill": [{ - "test": "datum.value < 30", - "value": "steelblue" - }, { - "value": "blue" - }] - }, - "hover": { - "fill": hoverFill21 - } - } - } - ] -} - -specs.forEach(spec => { - vg.parse.spec(spec, chart => { - chart({el:"#vis"}).update(); - }); -}); From 994038d60cacf827c189629a44abf00b3e07ace2 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 15 Nov 2018 15:21:20 -0800 Subject: [PATCH 153/174] Remove node dependencies from react --- types/react-dom/server/index.d.ts | 8 +++++++- types/react/test/index.ts | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/types/react-dom/server/index.d.ts b/types/react-dom/server/index.d.ts index 53bbca7250..ef42606717 100644 --- a/types/react-dom/server/index.d.ts +++ b/types/react-dom/server/index.d.ts @@ -1,4 +1,10 @@ -/// +// forward declarations +declare global { + namespace NodeJS { + // tslint:disable-next-line:no-empty-interface + interface ReadableStream {} + } +} import { ReactElement } from 'react'; diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 97d61118b9..0b747edd66 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -14,6 +14,23 @@ import update = require("react-addons-update"); import createReactClass = require("create-react-class"); import * as DOM from "react-dom-factories"; +// forward declarations (avoids an unnecessary dependency on NodeJS) +declare global { + interface Console { + log(message?: any, ...optionalParams: any[]): void; + } + var console: Console; + + function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout; + function clearInterval(intervalId: NodeJS.Timeout): void; + + namespace NodeJS { + // tslint:disable-next-line:no-empty-interface + interface Timer {} + interface Timeout extends Timer {} + } +} + interface Props extends React.Attributes { hello: string; world?: string | null; From f961f35307f3c2e2d085dde65fc46484efd2150d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 16 Nov 2018 12:48:36 -0800 Subject: [PATCH 154/174] Remove node dependencies from react --- types/react/test/index.ts | 46 ++++++++++++----------------------- types/react/v15/test/index.ts | 29 ++++++++++++---------- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 0b747edd66..672de32b37 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -14,23 +14,6 @@ import update = require("react-addons-update"); import createReactClass = require("create-react-class"); import * as DOM from "react-dom-factories"; -// forward declarations (avoids an unnecessary dependency on NodeJS) -declare global { - interface Console { - log(message?: any, ...optionalParams: any[]): void; - } - var console: Console; - - function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout; - function clearInterval(intervalId: NodeJS.Timeout): void; - - namespace NodeJS { - // tslint:disable-next-line:no-empty-interface - interface Timer {} - interface Timeout extends Timer {} - } -} - interface Props extends React.Attributes { hello: string; world?: string | null; @@ -103,7 +86,7 @@ declare const container: Element; render() { return null; } componentDidMount() { // $ExpectError -> this will be true in next BC release where state is gonna be `null | Readonly` - console.log(this.state.inputValue); + this.state.inputValue; } mutateState() { // $ExpectError @@ -184,7 +167,7 @@ class ModernComponent extends React.Component value: this.state.inputValue ? this.state.inputValue : undefined }), DOM.input({ - onChange: event => console.log(event.target) + onChange: event => event.target })); } @@ -518,17 +501,20 @@ class Timer extends React.Component<{}, TimerState> { state = { secondsElapsed: 0 }; - private _interval: NodeJS.Timer; + // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes + // private _interval: NodeJS.Timer; tick() { this.setState((prevState, props) => ({ secondsElapsed: prevState.secondsElapsed + 1 })); } componentDidMount() { - this._interval = setInterval(() => this.tick(), 1000); + // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes + // this._interval = setInterval(() => this.tick(), 1000); } componentWillUnmount() { - clearInterval(this._interval); + // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes + // clearInterval(this._interval); } render() { return DOM.div( @@ -615,14 +601,14 @@ Perf.printExclusive(); Perf.printWasted(); Perf.printOperations(); -console.log(Perf.getExclusive()); -console.log(Perf.getInclusive()); -console.log(Perf.getWasted()); -console.log(Perf.getOperations()); -console.log(Perf.getExclusive(measurements)); -console.log(Perf.getInclusive(measurements)); -console.log(Perf.getWasted(measurements)); -console.log(Perf.getOperations(measurements)); +Perf.getExclusive(); +Perf.getInclusive(); +Perf.getWasted(); +Perf.getOperations(); +Perf.getExclusive(measurements); +Perf.getInclusive(measurements); +Perf.getWasted(measurements); +Perf.getOperations(measurements); // Renamed to printOperations(). Please use it instead. Perf.printDOM(measurements); diff --git a/types/react/v15/test/index.ts b/types/react/v15/test/index.ts index 30dd3bd75d..42ca5999a8 100644 --- a/types/react/v15/test/index.ts +++ b/types/react/v15/test/index.ts @@ -120,7 +120,7 @@ class ModernComponent extends React.Component value: this.state.inputValue }), React.DOM.input({ - onChange: event => console.log(event.target) + onChange: event => event.target })); } @@ -342,7 +342,7 @@ const htmlAttr: React.HTMLProps = { event.stopPropagation(); }, onAnimationStart: event => { - console.log(event.currentTarget.className); + event.currentTarget.className; }, dangerouslySetInnerHTML: { __html: "STRONG" @@ -505,17 +505,20 @@ class Timer extends React.Component<{}, TimerState> { state = { secondsElapsed: 0 }; - private _interval: NodeJS.Timer; + // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes + // private _interval: NodeJS.Timer; tick() { this.setState((prevState, props) => ({ secondsElapsed: prevState.secondsElapsed + 1 })); } componentDidMount() { - this._interval = setInterval(() => this.tick(), 1000); + // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes + // this._interval = setInterval(() => this.tick(), 1000); } componentWillUnmount() { - clearInterval(this._interval); + // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes + // clearInterval(this._interval); } render() { return React.DOM.div( @@ -602,14 +605,14 @@ Perf.printExclusive(); Perf.printWasted(); Perf.printOperations(); -console.log(Perf.getExclusive()); -console.log(Perf.getInclusive()); -console.log(Perf.getWasted()); -console.log(Perf.getOperations()); -console.log(Perf.getExclusive(measurements)); -console.log(Perf.getInclusive(measurements)); -console.log(Perf.getWasted(measurements)); -console.log(Perf.getOperations(measurements)); +Perf.getExclusive(); +Perf.getInclusive(); +Perf.getWasted(); +Perf.getOperations(); +Perf.getExclusive(measurements); +Perf.getInclusive(measurements); +Perf.getWasted(measurements); +Perf.getOperations(measurements); // Renamed to printOperations(). Please use it instead. Perf.printDOM(measurements); From 48eba801e2af7ea945f8f4cd06d247b2890889ac Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 16 Nov 2018 14:17:11 -0800 Subject: [PATCH 155/174] Fix lint errors due to new lint rules --- types/meteor/test/globals/meteor-tests.ts | 16 ++++++++-------- types/meteor/test/meteor-tests.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/types/meteor/test/globals/meteor-tests.ts b/types/meteor/test/globals/meteor-tests.ts index 782701086f..e3a3e750bb 100644 --- a/types/meteor/test/globals/meteor-tests.ts +++ b/types/meteor/test/globals/meteor-tests.ts @@ -371,19 +371,19 @@ Comments.find({ viewNumber: { $gt: 100 } }); Comments.find({ viewNumber: { $not: { $lt: 100, $gt: 1000 } } }); Comments.find({ tags: { $in: [ "tag-1", "tag-2", "tag-3" ] } }); Comments.find({ $or: [ { text: "hello" }, { text: "world" } ] }); -Comments.find({ $or: [ - { text: "hello" }, - { text: "world", viewNumber: { $gt: 0 } } +Comments.find({ $or: [ + { text: "hello" }, + { text: "world", viewNumber: { $gt: 0 } } ], authorId: "test-author-id" }); -Comments.find({ $and: [ - { $or: [{ authorId: "author-id-1" }, { authorId: "author-id-2" }] }, +Comments.find({ $and: [ + { $or: [{ authorId: "author-id-1" }, { authorId: "author-id-2" }] }, { $or: [{ tags: "tag-1" }, { tags: "tag-2" }] } ]}); Comments.find({ $query: {inlineLinks: { $exists: true, $type: "array" } } }); -Comments.find({ inlineLinks: { $elemMatch: { - objectType: InlineObjectType.Image, - objectUrl: { $regex: "https://(www\.?)youtube\.com" } +Comments.find({ inlineLinks: { $elemMatch: { + objectType: InlineObjectType.Image, + objectUrl: { $regex: "https://(www\.?)youtube\.com" } } } }); Comments.find({ "inlineLinks.objectType": InlineObjectType.Person }); Comments.find({ tags: "tag-1" }); diff --git a/types/meteor/test/meteor-tests.ts b/types/meteor/test/meteor-tests.ts index b45284df52..63f83ef79d 100644 --- a/types/meteor/test/meteor-tests.ts +++ b/types/meteor/test/meteor-tests.ts @@ -383,19 +383,19 @@ Comments.find({ viewNumber: { $gt: 100 } }); Comments.find({ viewNumber: { $not: { $lt: 100, $gt: 1000 } } }); Comments.find({ tags: { $in: [ "tag-1", "tag-2", "tag-3" ] } }); Comments.find({ $or: [ { text: "hello" }, { text: "world" } ] }); -Comments.find({ $or: [ - { text: "hello" }, - { text: "world", viewNumber: { $gt: 0 } } +Comments.find({ $or: [ + { text: "hello" }, + { text: "world", viewNumber: { $gt: 0 } } ], authorId: "test-author-id" }); -Comments.find({ $and: [ - { $or: [{ authorId: "author-id-1" }, { authorId: "author-id-2" }] }, +Comments.find({ $and: [ + { $or: [{ authorId: "author-id-1" }, { authorId: "author-id-2" }] }, { $or: [{ tags: "tag-1" }, { tags: "tag-2" }] } ]}); Comments.find({ $query: { inlineLinks: { $exists: true, $type: "array" } } }); -Comments.find({ inlineLinks: { $elemMatch: { - objectType: InlineObjectType.Image, - objectUrl: { $regex: "https://(www\.?)youtube\.com" } +Comments.find({ inlineLinks: { $elemMatch: { + objectType: InlineObjectType.Image, + objectUrl: { $regex: "https://(www\.?)youtube\.com" } } } }); Comments.find({ "inlineLinks.objectType": InlineObjectType.Person }); Comments.find({ tags: "tag-1" }); From f8a87d07b3253029c217f25002f3ff4e8f05a1a8 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 27 Nov 2018 11:24:21 -0800 Subject: [PATCH 156/174] Address PR feedback --- types/react/test/index.ts | 37 ++++++++++++++++++++--------------- types/react/v15/test/index.ts | 37 ++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 672de32b37..8a4a2bd89b 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -14,6 +14,14 @@ import update = require("react-addons-update"); import createReactClass = require("create-react-class"); import * as DOM from "react-dom-factories"; +// NOTE: forward declarations for tests +declare function setInterval(...args: any[]): any; +declare function clearInterval(...args: any[]): any; +declare var console: Console; +interface Console { + log(...args: any[]): void; +} + interface Props extends React.Attributes { hello: string; world?: string | null; @@ -86,7 +94,7 @@ declare const container: Element; render() { return null; } componentDidMount() { // $ExpectError -> this will be true in next BC release where state is gonna be `null | Readonly` - this.state.inputValue; + console.log(this.state.inputValue); } mutateState() { // $ExpectError @@ -167,7 +175,7 @@ class ModernComponent extends React.Component value: this.state.inputValue ? this.state.inputValue : undefined }), DOM.input({ - onChange: event => event.target + onChange: event => console.log(event.target) })); } @@ -501,20 +509,17 @@ class Timer extends React.Component<{}, TimerState> { state = { secondsElapsed: 0 }; - // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes - // private _interval: NodeJS.Timer; + private _interval: number; tick() { this.setState((prevState, props) => ({ secondsElapsed: prevState.secondsElapsed + 1 })); } componentDidMount() { - // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes - // this._interval = setInterval(() => this.tick(), 1000); + this._interval = setInterval(() => this.tick(), 1000); } componentWillUnmount() { - // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes - // clearInterval(this._interval); + clearInterval(this._interval); } render() { return DOM.div( @@ -601,14 +606,14 @@ Perf.printExclusive(); Perf.printWasted(); Perf.printOperations(); -Perf.getExclusive(); -Perf.getInclusive(); -Perf.getWasted(); -Perf.getOperations(); -Perf.getExclusive(measurements); -Perf.getInclusive(measurements); -Perf.getWasted(measurements); -Perf.getOperations(measurements); +console.log(Perf.getExclusive()); +console.log(Perf.getInclusive()); +console.log(Perf.getWasted()); +console.log(Perf.getOperations()); +console.log(Perf.getExclusive(measurements)); +console.log(Perf.getInclusive(measurements)); +console.log(Perf.getWasted(measurements)); +console.log(Perf.getOperations(measurements)); // Renamed to printOperations(). Please use it instead. Perf.printDOM(measurements); diff --git a/types/react/v15/test/index.ts b/types/react/v15/test/index.ts index 42ca5999a8..79d05ac8d0 100644 --- a/types/react/v15/test/index.ts +++ b/types/react/v15/test/index.ts @@ -11,6 +11,14 @@ import * as TestUtils from "react-addons-test-utils"; import TransitionGroup = require("react-addons-transition-group"); import update = require("react-addons-update"); +// NOTE: forward declarations for tests +declare function setInterval(...args: any[]): any; +declare function clearInterval(...args: any[]): any; +declare var console: Console; +interface Console { + log(...args: any[]): void; +} + interface Props extends React.Attributes { hello: string; world?: string; @@ -120,7 +128,7 @@ class ModernComponent extends React.Component value: this.state.inputValue }), React.DOM.input({ - onChange: event => event.target + onChange: event => console.log(event.target) })); } @@ -342,7 +350,7 @@ const htmlAttr: React.HTMLProps = { event.stopPropagation(); }, onAnimationStart: event => { - event.currentTarget.className; + console.log(event.currentTarget.className); }, dangerouslySetInnerHTML: { __html: "STRONG" @@ -505,20 +513,17 @@ class Timer extends React.Component<{}, TimerState> { state = { secondsElapsed: 0 }; - // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes - // private _interval: NodeJS.Timer; + private _interval: number; tick() { this.setState((prevState, props) => ({ secondsElapsed: prevState.secondsElapsed + 1 })); } componentDidMount() { - // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes - // this._interval = setInterval(() => this.tick(), 1000); + this._interval = setInterval(() => this.tick(), 1000); } componentWillUnmount() { - // NOTE: creates unnecessary dependency on 'node'. leaving for reference purposes - // clearInterval(this._interval); + clearInterval(this._interval); } render() { return React.DOM.div( @@ -605,14 +610,14 @@ Perf.printExclusive(); Perf.printWasted(); Perf.printOperations(); -Perf.getExclusive(); -Perf.getInclusive(); -Perf.getWasted(); -Perf.getOperations(); -Perf.getExclusive(measurements); -Perf.getInclusive(measurements); -Perf.getWasted(measurements); -Perf.getOperations(measurements); +console.log(Perf.getExclusive()); +console.log(Perf.getInclusive()); +console.log(Perf.getWasted()); +console.log(Perf.getOperations()); +console.log(Perf.getExclusive(measurements)); +console.log(Perf.getInclusive(measurements)); +console.log(Perf.getWasted(measurements)); +console.log(Perf.getOperations(measurements)); // Renamed to printOperations(). Please use it instead. Perf.printDOM(measurements); From 6edec833a26d69eb5982014628fbd7cec28d1188 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 27 Nov 2018 22:41:31 +0100 Subject: [PATCH 157/174] Add new Expo type definitions from official docs --- types/expo/expo-tests.tsx | 3 ++- types/expo/index.d.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index 5bb6b5abc4..75dee784de 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -145,7 +145,8 @@ Audio.setAudioModeAsync({ playsInSilentModeIOS: true, interruptionModeIOS: 2, interruptionModeAndroid: 1, - allowsRecordingIOS: true + allowsRecordingIOS: true, + playThroughEarpieceAndroid: false }); Audio.setIsEnabledAsync(true); diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index b406b4e8ec..ad94eb38ed 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -12,6 +12,7 @@ // Nathan Phillip Brink // Martin Olsson // Levan Basharuli +// Pavel Ihm // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -405,6 +406,9 @@ export namespace Audio { /** an enum selecting how your experience’s audio should interact with the audio from other apps on Android: */ interruptionModeAndroid: InterruptionModeAndroid; + + /** Boolean selecting if audio should go to earpiece (only on Android).*/ + playThroughEarpieceAndroid: boolean; } function setIsEnabledAsync(value: boolean): Promise; @@ -566,7 +570,7 @@ export interface PlaybackStatusToSet { volume?: number; } -export type PlaybackSource = RequireSource | { uri: string } | Asset; +export type PlaybackSource = RequireSource | { uri: string, headers?: { [string]: string }, overrideFileExtensionAndroid?: string } | Asset; export class PlaybackObject { /** @@ -2355,7 +2359,7 @@ export namespace Calendar { /** Name for the account that owns this calendar */ ownerAccount?: string; // Android - /** Time zone for the calendar */ + /** Time zone for the calendar */ timeZone?: string; // Android /** Alarm methods that this calendar supports */ @@ -2398,7 +2402,7 @@ export namespace Calendar { /** Visible name of the event */ title?: string; - /** Location field of the event */ + /** Location field of the event */ location?: string; /** Date when the event record was created */ From 675bc38625d0e0767639d7423ffcada9f3d67574 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 27 Nov 2018 23:03:24 +0100 Subject: [PATCH 158/174] Fix build errors --- types/expo/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index ad94eb38ed..9e48e391d8 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -407,7 +407,7 @@ export namespace Audio { /** an enum selecting how your experience’s audio should interact with the audio from other apps on Android: */ interruptionModeAndroid: InterruptionModeAndroid; - /** Boolean selecting if audio should go to earpiece (only on Android).*/ + /** Boolean selecting if audio should go to earpiece (only on Android). */ playThroughEarpieceAndroid: boolean; } @@ -570,7 +570,7 @@ export interface PlaybackStatusToSet { volume?: number; } -export type PlaybackSource = RequireSource | { uri: string, headers?: { [string]: string }, overrideFileExtensionAndroid?: string } | Asset; +export type PlaybackSource = RequireSource | { uri: string, headers?: { [header: string]: string }, overrideFileExtensionAndroid?: string } | Asset; export class PlaybackObject { /** From 797f19a5eb36bdf78d82e52ff5651a020b192e48 Mon Sep 17 00:00:00 2001 From: James Ide Date: Tue, 27 Nov 2018 14:50:09 -0800 Subject: [PATCH 159/174] [react-native] Update type definition for requireNativeComponent for 0.57.x requireNativeComponent now only takes a string and returns a string. See the definition here: https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/Libraries/ReactNative/requireNativeComponent.js#L24-L27. The return type here is specified as `React.ReactType`, which is a union type that includes strings. We can't use `string` because TypeScript treats it as an intrinsic element like `div` and thinks it has no props. Updated the corresponding test code too. --- types/react-native/index.d.ts | 29 +++++------------------------ types/react-native/test/index.tsx | 7 +------ 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 9e68e283a9..6e54b6d7c9 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -9030,34 +9030,15 @@ export const Platform: PlatformStatic; export const PlatformIOS: PlatformIOSStatic; export const PixelRatio: PixelRatioStatic; -export interface ComponentInterface

{ - name?: string; - displayName?: string; - propTypes: PropTypes.ValidationMap

; -} - /** - * Used to create React components that directly wrap native component - * implementations. Config information is extracted from data exported from the - * UIManager module. You should also wrap the native component in a - * hand-written component with full propTypes definitions and other - * documentation - pass the hand-written component in as `componentInterface` to - * verify all the native props are documented via `propTypes`. + * Creates values that can be used like React components which represent native + * view managers. You should create JavaScript modules that wrap these values so + * that the results are memoized. Example: * - * If some native props shouldn't be exposed in the wrapper interface, you can - * pass null for `componentInterface` and call `verifyPropTypes` directly - * with `nativePropsToIgnore`; + * const View = requireNativeComponent('RCTView'); * - * Common types are lined up with the appropriate prop differs with - * `TypeToDifferMap`. Non-scalar types not in the map default to `deepDiffer`. */ -export function requireNativeComponent( - viewName: string, - componentInterface?: ComponentInterface

, - extraConfig?: { nativeOnly?: NP } -): React.ComponentClass< - Partial>> & { [K in keyof NP]?: any} ->; +export function requireNativeComponent(viewName: string): React.ReactType; export function findNodeHandle( componentOrHandle: null | number | React.Component | React.ComponentClass diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 56d6b7035b..b5d7a5faeb 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -822,12 +822,7 @@ class BridgedComponentTest extends React.Component { } } -const NativeBridgedComponent = requireNativeComponent("NativeBridgedComponent", BridgedComponentTest, { - nativeOnly: { - nativeProp: true, - } -}); - +const NativeBridgedComponent = requireNativeComponent("NativeBridgedComponent"); const SwitchColorTest = () => ( From 83ac5c88348de8b402427c18997d321a0aa2f1f2 Mon Sep 17 00:00:00 2001 From: Glen Date: Wed, 28 Nov 2018 09:36:59 +0200 Subject: [PATCH 160/174] Make sitekey optional in Parameters --- types/grecaptcha/grecaptcha-tests.ts | 6 +++++- types/grecaptcha/index.d.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/grecaptcha/grecaptcha-tests.ts b/types/grecaptcha/grecaptcha-tests.ts index 288836d6b3..970660cc6c 100644 --- a/types/grecaptcha/grecaptcha-tests.ts +++ b/types/grecaptcha/grecaptcha-tests.ts @@ -18,11 +18,15 @@ const badge1: ReCaptchaV2.Badge = "bottomleft"; const badge2: ReCaptchaV2.Badge = "bottomright"; const badge3: ReCaptchaV2.Badge = "inline"; -const invisibleParams: ReCaptchaV2.Parameters = { +const invisibleParams1: ReCaptchaV2.Parameters = { sitekey: "siteKey", badge: badge1, }; +const invisibleParams2: ReCaptchaV2.Parameters = { + badge: badge2, +}; + const id1: number = grecaptcha.render("foo"); const id2: number = grecaptcha.render("foo", params); const id3: number = grecaptcha.render(document.getElementById("foo")); diff --git a/types/grecaptcha/index.d.ts b/types/grecaptcha/index.d.ts index c9dedbfb74..4430aa90e9 100644 --- a/types/grecaptcha/index.d.ts +++ b/types/grecaptcha/index.d.ts @@ -46,7 +46,7 @@ declare namespace ReCaptchaV2 { /** * Your sitekey. */ - sitekey: string; + sitekey?: string; /** * Optional. The color theme of the widget. * Accepted values: "light", "dark" From 6b8b4cb0b3461847d8b3dc5fa15e7d31ea1a575d Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Wed, 28 Nov 2018 12:58:49 +0100 Subject: [PATCH 161/174] [redux-first-router] Update definitions for Options for 2.1 --- types/redux-first-router/index.d.ts | 101 ++++++++++++++++-- .../redux-first-router-tests.ts | 82 ++++++++------ 2 files changed, 140 insertions(+), 43 deletions(-) diff --git a/types/redux-first-router/index.d.ts b/types/redux-first-router/index.d.ts index 2184deed0b..1cf954b69f 100644 --- a/types/redux-first-router/index.d.ts +++ b/types/redux-first-router/index.d.ts @@ -6,6 +6,7 @@ // corydeppen // jscinoz // surgeboris +// geirsagberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -194,25 +195,107 @@ export interface NavigatorsConfig { }; } +export interface Bag { + action: ReceivedAction | Action; + extra: any; +} + export interface Options { - title?: string | SelectTitleState; + /** + * A prefix that will be prepended to the URL. For example, using a basename of '/playground', + * a route with the path '/home' would correspond to the URL path '/playground/home'. + */ + basename?: string; + /** + * Whether or not a trailing delimiter is allowed when matching path. + */ + strict?: boolean; + /** + * The name of the state key or a selector function to specify where in your Redux state tree + * Redux First Router should expect your page location reducer to be attached to. + */ location?: string | SelectLocationState; - notFoundPath?: string; - scrollTop?: boolean; - onBeforeChange?(dispatch: Dispatch, getState: StateGetter): void; - onAfterChange?(dispatch: Dispatch, getState: StateGetter): void; - onBackNext?(dispatch: Dispatch, getState: StateGetter): void; - restoreScroll?(history: History): ScrollBehavior; + /** + * The name of the state key or a selector function to specify where in your Redux state tree + * Redux First Router should expect your page title reducer to be attached to. + * This can be omitted if you attach the reducer at state.title. + */ + title?: string | SelectTitleState; + /** + * Can be set to false to bypass the initial dispatch, so you can do it manually, perhaps after running sagas. + */ initialDispatch?: boolean; - querySerializer?: QuerySerializer; - navigators?: NavigatorsConfig; + /** + * An array of entries to initialise history object. Useful for server side rendering and tests. + */ initialEntries?: HistoryEntries; + /** + * An object with parse and stringify methods, such as the `query-string` or `qs` libraries (or anything handmade). + * This will be used to handle querystrings. Without this option, query strings are ignored silently. + */ + querySerializer?: QuerySerializer; + /** + * The path where users may be redirected in 2 situations: when you dispatch an action with no matching path, + * or if you manually call dispatch(redirect({ type: NOT_FOUND })), where NOT_FOUND is an export from this package. + * The type in actions and state will be NOT_FOUND, which you can use to show a 404 page. + */ + notFoundPath?: string; + /** + * Whether or not window.scrollTo(0, 0) should be run on route changes so the user starts each page at the top. + */ + scrollTop?: boolean; + /** + * A function to update window/elements scroll position. + */ + restoreScroll?(history: History): ScrollBehavior; + /** + * A simple function that will be called before the routes change. + * It's passed your standard `dispatch` and `getState` arguments like a thunk, + * as well as the `bag` object as a third parameter, which contains the dispatched `action` and the configured `extra` value. + */ + onBeforeChange?(dispatch: Dispatch, getState: StateGetter, bag: Bag): void; + /** + * A simple function that will be called after the routes change. + * It's passed your standard `dispatch` and `getState` arguments like a thunk, + * as well as the `bag` object as a third parameter, which contains the dispatched `action` and the configured `extra` value. + */ + onAfterChange?(dispatch: Dispatch, getState: StateGetter, bag: Bag): void; + /** + * A simple function that will be called whenever the user uses the browser back/next buttons. + * It's passed your standard `dispatch` and `getState` arguments like a thunk, + * as well as the `bag` object as a third parameter, which contains the dispatched `action` + * and the configured `extra` value. Actions with kinds `back`, `next`, and `pop` trigger this. + */ + onBackNext?(dispatch: Dispatch, getState: StateGetter, bag: Bag): void; + /** + * A function receiving `message` and `callback` when navigation is blocked with `confirmLeave`. + * The message is the return value from `confirmLeave`. + * The callback can be called with `true` to unblock the navigation, or with `false` to cancel the navigation. + */ + displayConfirmLeave?: DisplayConfirmLeave; + /** + * A function returning a history object compatible with the popular `history` package. + */ createHistory?(): History; + /** + * A map of of your Redux state keys to _React Navigation_ navigators. + */ + navigators?: NavigatorsConfig; + /** + * An optional value that will be passed as part of the third `bag` argument to all options callbacks and routes thunk. + * It works much like the `withExtraArgument` feature of `redux-thunk` or the `context` argument of GraphQL resolvers. + * You can use it to pass any required context to your thunks without having to tightly couple them to it. + * For example, you could pass an instance of an API client initialised with authentication cookies, + * or a function `addReducer` to inject new code split reducers into the store. + */ + extra?: any; } export type Params = object; export type Payload = object; +export type DisplayConfirmLeave = (message: string, callback: (unblock: boolean) => void) => void; + export type ScrollUpdater = (performedByUser: boolean) => void; export const NOT_FOUND: '@@redux-first-router/NOT_FOUND'; diff --git a/types/redux-first-router/redux-first-router-tests.ts b/types/redux-first-router/redux-first-router-tests.ts index 5297be4175..0439f551c7 100644 --- a/types/redux-first-router/redux-first-router-tests.ts +++ b/types/redux-first-router/redux-first-router-tests.ts @@ -7,21 +7,24 @@ import { redirect, Action as ReduxFirstRouterAction, QuerySerializer, - pathToAction + pathToAction, + StateGetter, + Bag, + Navigators, + NavigationAction, + Nullable, + Route } from 'redux-first-router'; import { - AnyAction, createStore, applyMiddleware, Middleware, - MiddlewareAPI, - Store, Dispatch, compose, - Action, - StoreEnhancer, StoreEnhancerStoreCreator, - combineReducers + combineReducers, + AnyAction, + Store } from 'redux'; import { History } from 'history'; @@ -52,28 +55,40 @@ const routesMap: RoutesMap = { } }; -const { - reducer, - middleware, - enhancer, - initialDispatch, - thunk, -} = connectRoutes(routesMap, { - initialDispatch: false, - onBeforeChange: (dispatch, getState) => { - dispatch; // $ExpectType Dispatch - getState; // $ExpectType StateGetter +const { reducer, middleware, enhancer, initialDispatch, thunk } = connectRoutes(routesMap, { + basename: '/base', + strict: false, + location: state => { + const locationState = state.location; // $ExpectType LocationState + return locationState; + }, + title: state => { + const title = state.location.pathname; // $ExpectType string + return title; + }, + initialDispatch: false, + initialEntries: [], + querySerializer: { + stringify: queryString => { + queryString; // $ExpectType object + return ''; }, - location: state => { - const locationState = state.location; // $ExpectType LocationState - return locationState; - }, - title: state => { - const title = state.location.pathname; // $ExpectType string - return title; - }, - createHistory: () => history, - }); + parse: params => { + params; // $ExpectType string + return {}; + } + }, + notFoundPath: 'not-found', + scrollTop: true, + restoreScroll: (history: History) => { + return {}; + }, + onBeforeChange: (dispatch: Dispatch, getState: StateGetter, bag: Bag) => { }, + onAfterChange: (dispatch: Dispatch, getState: StateGetter, bag: Bag) => { }, + onBackNext: (dispatch: Dispatch, getState: StateGetter, bag: Bag) => { }, + displayConfirmLeave: (message: string, callback: (unblock: boolean) => void) => { }, + createHistory: (options?: any) => history +}); const dumbMiddleware: Middleware = store => next => action => next(action); @@ -89,10 +104,9 @@ const combined = combineReducers({ location: reducer }); const store = createStore(combined, storeEnhancer); // Test that `thunk()` has correct state types now that `store` is defined -thunk(store) - .then((t) => { - t = t!; // $ExpectType RouteThunk - }); +thunk(store).then(t => { + t = t!; // $ExpectType RouteThunk +}); const receivedAction: ReceivedAction = { type: 'HOME', @@ -102,8 +116,8 @@ actionToPath(receivedAction, routesMap); // $ExpectType string pathToAction('/', routesMap); // $ExpectType ReceivedAction const querySerializer: QuerySerializer = { - stringify: (params) => '', - parse: (queryString) => ({}) + stringify: params => '', + parse: queryString => ({}) }; actionToPath(receivedAction, routesMap, querySerializer); // $ExpectType string pathToAction('/', routesMap, querySerializer); // $ExpectType ReceivedAction From 843aa82f3d1921ee5a6fbd52196efb3307bc0349 Mon Sep 17 00:00:00 2001 From: Alexander Sidko Date: Wed, 28 Nov 2018 14:01:24 +0200 Subject: [PATCH 162/174] Use pino-pretty options as PrettyOptions --- types/pino/index.d.ts | 31 ++++++++++++++++++++++++------- types/pino/pino-tests.ts | 13 +++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index bea9987832..8efaa85d33 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -5,6 +5,7 @@ // Christian Rackerseder // GP // Alex Ferrando +// Oleksandr Sidko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -243,13 +244,12 @@ declare namespace P { interface PrettyOptions { /** - * If set to true, it will only covert the unix timestamp to ISO 8601 date format, and reserialize the JSON (equivalent to pino -t). + * Translate the epoch time value into a human readable date and time string. + * This flag also can set the format string to apply when translating the date to human readable format. + * The default format is yyyy-mm-dd HH:MM:ss.l o in UTC. + * For a list of available pattern letters see the {@link https://www.npmjs.com/package/dateformat|dateformat documentation}. */ - timeTransOnly?: boolean; - /** - * A custom function to format the line, is passed the JSON object as an argument and should return a string value. - */ - formatter?(log: LogDescriptor): string; + translateTime?: boolean | string; /** * If set to true, it will print the name of the log level as the first field in the log line. Default: `false`. */ @@ -261,7 +261,24 @@ declare namespace P { /** * If set to true, will add color information to the formatted output message. Default: `false`. */ - forceColor?: boolean; + colorize?: boolean; + /** + * Appends carriage return and line feed, instead of just a line feed, to the formatted log line. + */ + crlf?: boolean; + /** + * Define the log keys that are associated with error like objects. Default: ["err", "error"] + */ + errorLikeObjectKeys?: string[]; + /** + * When formatting an error object, display this list of properties. + * The list should be a comma separated list of properties. Default: '' + */ + errorProps?: string; + /** + * Specify a search pattern according to {@link http://jmespath.org|jmespath} + */ + search?: string; } type Level = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace'; diff --git a/types/pino/pino-tests.ts b/types/pino/pino-tests.ts index d3203b5dd4..56b28d284c 100644 --- a/types/pino/pino-tests.ts +++ b/types/pino/pino-tests.ts @@ -123,3 +123,16 @@ anotherRedacted.info({ msg: 'another logged with redacted properties', anotherPath: 'Not shown' }); + +const pretty = pino({ + prettyPrint: { + colorize: true, + crlf: false, + errorLikeObjectKeys: ['err', 'error'], + errorProps: '', + levelFirst: false, + messageKey: 'msg', + translateTime: 'UTC:h:MM:ss TT Z', + search: 'foo == `bar`' + } +}) From a821fb106f90a104a262a335b67718554a636ced Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Wed, 28 Nov 2018 13:25:07 +0100 Subject: [PATCH 163/174] [redux-first-router] Update RouteObject --- types/redux-first-router/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/redux-first-router/index.d.ts b/types/redux-first-router/index.d.ts index 1cf954b69f..13b4578322 100644 --- a/types/redux-first-router/index.d.ts +++ b/types/redux-first-router/index.d.ts @@ -25,6 +25,8 @@ export type StateGetter = () => TState; export type RouteString = string; +export type ConfirmLeave = (state: object, action: object) => Nullable; + export type RouteThunk = ( dispatch: Dispatch, getState: StateGetter, @@ -37,6 +39,9 @@ export type RouteObject = TKeys & { thunk?: RouteThunk; fromPath?(path: string, key?: string): string; toPath?(param: string, key?: string): string; + coerceNumbers?: boolean; + confirmLeave?: ConfirmLeave; + meta?: Meta; }; export type Route = RouteString | RouteObject; From 0bdba525bac419a9a946a0f4753742a73a0d828d Mon Sep 17 00:00:00 2001 From: Alexander Sidko Date: Wed, 28 Nov 2018 14:42:24 +0200 Subject: [PATCH 164/174] Fix pino tests --- types/pino/pino-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/pino/pino-tests.ts b/types/pino/pino-tests.ts index 56b28d284c..3a6283c3e4 100644 --- a/types/pino/pino-tests.ts +++ b/types/pino/pino-tests.ts @@ -135,4 +135,4 @@ const pretty = pino({ translateTime: 'UTC:h:MM:ss TT Z', search: 'foo == `bar`' } -}) +}); From 1748c8d191505ad7a17165f5078dd45ee8575e9b Mon Sep 17 00:00:00 2001 From: Joe Flateau Date: Wed, 28 Nov 2018 12:14:34 -0500 Subject: [PATCH 165/174] Update types/node-forge/index.d.ts Co-Authored-By: timhwang21 --- types/node-forge/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index 40badbbcf4..1a2b028a90 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for node-forge 0.7.7 +// Type definitions for node-forge 0.7.6 // Project: https://github.com/digitalbazaar/forge // Definitions by: Seth Westphal // Kay Schecker From 99db723f07aec0b37f34137ea71b4c6fc7dd7d01 Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Wed, 28 Nov 2018 12:34:36 -0500 Subject: [PATCH 166/174] Fix error type in backoffStrategies interface change `typeof Error` (resolves to `ErrorConstructor`) to just `Error`. This allows accessing actual error instance properties (message, etc.) --- types/bull/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index 6096d98145..dd5723f2d2 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -92,7 +92,7 @@ declare namespace Bull { * Define a custom backoff strategy */ backoffStrategies?: { - [key: string]: (attemptsMade: number, err: typeof Error) => number; + [key: string]: (attemptsMade: number, err: Error) => number; }; /** From be8aa4618958d2c663438aab7fbc28fc1160e8c3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 28 Nov 2018 10:11:58 -0800 Subject: [PATCH 167/174] Add status badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9a31d73da1..0f8ba84c27 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ [![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Are packages being published to npm in less than 10,000 seconds on average? +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Has typescript-bot been active on DefinitelyTyped in the last two hours? + > The repository for *high quality* TypeScript type definitions. Also see the [definitelytyped.org](http://definitelytyped.org) website, although information in this README is more up-to-date. From 2b17e0bbf1d0c973856be1911ca89615230f163a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 28 Nov 2018 10:13:52 -0800 Subject: [PATCH 168/174] Move badges to bottom --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f8ba84c27..129762bd9b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ [![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Are packages being published to npm in less than 10,000 seconds on average? -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Has typescript-bot been active on DefinitelyTyped in the last two hours? - > The repository for *high quality* TypeScript type definitions. Also see the [definitelytyped.org](http://definitelytyped.org) website, although information in this README is more up-to-date. @@ -339,3 +336,6 @@ This project is licensed under the MIT license. Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file. [![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon) + +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Are packages being published to npm in less than 10,000 seconds on average? +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Has typescript-bot been active on DefinitelyTyped in the last two hours? From a6cc14597d068d6312f7434fcf93cdb6b2cd8282 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 28 Nov 2018 11:09:56 -0800 Subject: [PATCH 169/174] Swap types-publisher/typescript-bot status badge links The links were backward, but not the images. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 129762bd9b..9062f4ea00 100644 --- a/README.md +++ b/README.md @@ -337,5 +337,5 @@ Copyrights on the definition files are respective of each contributor listed at [![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon) -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Are packages being published to npm in less than 10,000 seconds on average? -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Has typescript-bot been active on DefinitelyTyped in the last two hours? +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average? +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours? From 154a76cccee50c2b789fbff0a60b124d84668f9f Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 28 Nov 2018 11:30:48 -0800 Subject: [PATCH 170/174] Add Vega entry to notNeededPackages.json --- notNeededPackages.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notNeededPackages.json b/notNeededPackages.json index cf5c9449d7..53ff6a7124 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1656,6 +1656,12 @@ "sourceRepoURL": "https://github.com/ansman/validate.js", "asOfVersion": "0.11.0" }, + { + "libraryName": "vega", + "typingsPackageName": "vega", + "sourceRepoURL": "https://github.com/vega/vega", + "asOfVersion": "3.2.0" + }, { "libraryName": "vso-node-api", "typingsPackageName": "vso-node-api", From ebb848491a767717f82c852b21af81df56ad8b80 Mon Sep 17 00:00:00 2001 From: Bradley Hill Date: Wed, 28 Nov 2018 13:37:09 -0600 Subject: [PATCH 171/174] fabric - update the TextBox.getSelectionStyles signature to latest fabricjs --- types/fabric/fabric-impl.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 485a603966..39b3e45757 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -3467,7 +3467,7 @@ export class IText extends Object { * @param [endIndex] End index to get styles at * @return styles Style object at a specified (or current) index */ - getSelectionStyles(startIndex: number, endIndex: number): any; + getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any; /** * Sets style of a current selection * @param [styles] Styles object From 75cbccb548c1778e72b848ae6c818aabbb145129 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 28 Nov 2018 14:02:28 -0800 Subject: [PATCH 172/174] Nope, the images were backward too --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9062f4ea00..eba170c493 100644 --- a/README.md +++ b/README.md @@ -337,5 +337,5 @@ Copyrights on the definition files are respective of each contributor listed at [![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon) -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average? -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours? +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average? +[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours? From e228d2d09b79adfcdb8992735644e6d447bc2914 Mon Sep 17 00:00:00 2001 From: Alex Jerabek Date: Wed, 28 Nov 2018 14:38:39 -0800 Subject: [PATCH 173/174] Remove redundant text --- types/office-js/index.d.ts | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index ceb6f2263b..1390c616cc 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -50829,7 +50829,7 @@ declare namespace Word { getRange(rangeLocation?: "Whole" | "Start" | "End" | "Before" | "After" | "Content"): Word.Range; /** * - * Inserts a break at the specified location in the main document. The insertLocation value can be 'Before' or 'After'. + * Inserts a break at the specified location in the main document. * * [Api set: WordApi 1.2] * @@ -50839,7 +50839,7 @@ declare namespace Word { insertBreak(breakType: Word.BreakType, insertLocation: Word.InsertLocation): void; /** * - * Inserts a break at the specified location in the main document. The insertLocation value can be 'Before' or 'After'. + * Inserts a break at the specified location in the main document. * * [Api set: WordApi 1.2] * @@ -50856,7 +50856,7 @@ declare namespace Word { insertContentControl(): Word.ContentControl; /** * - * Inserts a document at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a document at the specified location. * * [Api set: WordApi 1.2] * @@ -50866,7 +50866,7 @@ declare namespace Word { insertFileFromBase64(base64File: string, insertLocation: Word.InsertLocation): Word.Range; /** * - * Inserts a document at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a document at the specified location. * * [Api set: WordApi 1.2] * @@ -50876,7 +50876,7 @@ declare namespace Word { insertFileFromBase64(base64File: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Range; /** * - * Inserts HTML at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts HTML at the specified location. * * [Api set: WordApi 1.2] * @@ -50886,7 +50886,7 @@ declare namespace Word { insertHtml(html: string, insertLocation: Word.InsertLocation): Word.Range; /** * - * Inserts HTML at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts HTML at the specified location. * * [Api set: WordApi 1.2] * @@ -50916,7 +50916,7 @@ declare namespace Word { insertInlinePictureFromBase64(base64EncodedImage: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.InlinePicture; /** * - * Inserts OOXML at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts OOXML at the specified location. * * [Api set: WordApi 1.2] * @@ -50926,7 +50926,7 @@ declare namespace Word { insertOoxml(ooxml: string, insertLocation: Word.InsertLocation): Word.Range; /** * - * Inserts OOXML at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts OOXML at the specified location. * * [Api set: WordApi 1.2] * @@ -50936,7 +50936,7 @@ declare namespace Word { insertOoxml(ooxml: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Range; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.2] * @@ -50946,7 +50946,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.2] * @@ -50956,7 +50956,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Paragraph; /** * - * Inserts text at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts text at the specified location. * * [Api set: WordApi 1.2] * @@ -50966,7 +50966,7 @@ declare namespace Word { insertText(text: string, insertLocation: Word.InsertLocation): Word.Range; /** * - * Inserts text at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts text at the specified location. * * [Api set: WordApi 1.2] * @@ -51777,7 +51777,7 @@ declare namespace Word { getTextRanges(endingMarks: string[], trimSpacing?: boolean): Word.RangeCollection; /** * - * Inserts a break at the specified location in the main document. The insertLocation value can be 'Before' or 'After'. + * Inserts a break at the specified location in the main document. * * [Api set: WordApi 1.1] * @@ -51787,7 +51787,7 @@ declare namespace Word { insertBreak(breakType: Word.BreakType, insertLocation: Word.InsertLocation): void; /** * - * Inserts a break at the specified location in the main document. The insertLocation value can be 'Before' or 'After'. + * Inserts a break at the specified location in the main document. * * [Api set: WordApi 1.1] * @@ -51884,7 +51884,7 @@ declare namespace Word { insertOoxml(ooxml: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Range; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.1] * @@ -51894,7 +51894,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.1] * @@ -51904,7 +51904,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Paragraph; /** * - * Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'. + * Inserts a table with the specified number of rows and columns. * * [Api set: WordApi 1.3] * @@ -51916,7 +51916,7 @@ declare namespace Word { insertTable(rowCount: number, columnCount: number, insertLocation: Word.InsertLocation, values?: string[][]): Word.Table; /** * - * Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'. + * Inserts a table with the specified number of rows and columns. * * [Api set: WordApi 1.3] * @@ -52355,7 +52355,7 @@ declare namespace Word { getTextRanges(endingMarks: string[], trimSpacing?: boolean): Word.RangeCollection; /** * - * Inserts a break at the specified location in the main document. The insertLocation value can be 'Before' or 'After'. + * Inserts a break at the specified location in the main document. * * [Api set: WordApi 1.1] * @@ -52365,7 +52365,7 @@ declare namespace Word { insertBreak(breakType: Word.BreakType, insertLocation: Word.InsertLocation): void; /** * - * Inserts a break at the specified location in the main document. The insertLocation value can be 'Before' or 'After'. + * Inserts a break at the specified location in the main document. * * [Api set: WordApi 1.1] * @@ -52462,7 +52462,7 @@ declare namespace Word { insertOoxml(ooxml: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Range; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.1] * @@ -52472,7 +52472,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.1] * @@ -52482,7 +52482,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Paragraph; /** * - * Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'. + * Inserts a table with the specified number of rows and columns. * * [Api set: WordApi 1.3] * @@ -52494,7 +52494,7 @@ declare namespace Word { insertTable(rowCount: number, columnCount: number, insertLocation: Word.InsertLocation, values?: string[][]): Word.Table; /** * - * Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'. + * Inserts a table with the specified number of rows and columns. * * [Api set: WordApi 1.3] * @@ -53357,7 +53357,7 @@ declare namespace Word { insertContentControl(): Word.ContentControl; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.3] * @@ -53367,7 +53367,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph; /** * - * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * Inserts a paragraph at the specified location. * * [Api set: WordApi 1.3] * @@ -53377,7 +53377,7 @@ declare namespace Word { insertParagraph(paragraphText: string, insertLocation: "Before" | "After" | "Start" | "End" | "Replace"): Word.Paragraph; /** * - * Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'. + * Inserts a table with the specified number of rows and columns. * * [Api set: WordApi 1.3] * @@ -53389,7 +53389,7 @@ declare namespace Word { insertTable(rowCount: number, columnCount: number, insertLocation: Word.InsertLocation, values?: string[][]): Word.Table; /** * - * Inserts a table with the specified number of rows and columns. The insertLocation value can be 'Before' or 'After'. + * Inserts a table with the specified number of rows and columns. * * [Api set: WordApi 1.3] * From c0f3e556bb8b958a337c691d6fb9962b130b93dd Mon Sep 17 00:00:00 2001 From: Alex Jerabek Date: Wed, 28 Nov 2018 15:10:50 -0800 Subject: [PATCH 174/174] Clarify formula behavior for data validation rules --- types/office-js/index.d.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index ceb6f2263b..7dd1437b13 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -21758,18 +21758,19 @@ declare namespace Excel { interface BasicDataValidation { /** * - * Gets or sets the Formula1, i.e. minimum value or value depending of the operator. - When setting the value, it can be passed in as a number, a range object, or a string formula (where the string is either a stringified number, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). - When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. + * Specifies the right-hand operand when the operator property is set to a binary operator such as GreaterThan (the left-hand operand is the value the user tries to enter in the cell). With the ternary operators Between and NotBetween, specifies the lower bound operand. + * For example, setting formula1 to 10 and operator to GreaterThan means that valid data for the range must be greater than 10. + * When setting the value, it can be passed in as a number, a range object, or a string formula (where the string is either a stringified number, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). + * When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * * [Api set: ExcelApi 1.8] */ formula1: string | number | Range; /** * - * Gets or sets the Formula2, i.e. maximum value or value depending of the operator. - When setting the value, it can be passed in as a number, a range object, or a string formula (where the string is either a stringified number, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). - When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. + * With the ternary operators Between and NotBetween, specifies the upper bound operand. Is not used with the binary operators, such as GreaterThan. + * When setting the value, it can be passed in as a number, a range object, or a string formula (where the string is either a stringified number, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). + * When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * * [Api set: ExcelApi 1.8] */ @@ -21791,18 +21792,18 @@ declare namespace Excel { interface DateTimeDataValidation { /** * - * Gets or sets the Formula1, i.e. minimum value or value depending of the operator. - When setting the value, it can be passed in as a Date, a Range object, or a string formula (where the string is either a stringified date/time in ISO8601 format, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). - When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. + * Specifies the right-hand operand when the operator property is set to a binary operator such as GreaterThan (the left-hand operand is the value the user tries to enter in the cell). With the ternary operators Between and NotBetween, specifies the lower bound operand. + * When setting the value, it can be passed in as a Date, a Range object, or a string formula (where the string is either a stringified date/time in ISO8601 format, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). + * When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * * [Api set: ExcelApi 1.8] */ formula1: string | Date | Range; /** * - * Gets or sets the Formula2, i.e. maximum value or value depending of the operator. - When setting the value, it can be passed in as a Date, a Range object, or a string (where the string is either a stringified date/time in ISO8601 format, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). - When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. + * With the ternary operators Between and NotBetween, specifies the upper bound operand. Is not used with the binary operators, such as GreaterThan. + * When setting the value, it can be passed in as a Date, a Range object, or a string (where the string is either a stringified date/time in ISO8601 format, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). + * When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * * [Api set: ExcelApi 1.8] */