From 6d3b4850459d1498b7d2d2552572611131b79ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20H=C3=A9tu=20Rivard?= Date: Thu, 3 Jan 2019 17:23:51 -0500 Subject: [PATCH 001/222] [parse] Update cloud code definitions for Parse server 3.X --- types/parse/index.d.ts | 41 +++++++++++--------------------------- types/parse/parse-tests.ts | 32 +++++++++++++++++++---------- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index bf89204b04..fbf5894964 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -7,6 +7,7 @@ // Wes Grimes // Otherwise SAS // Andrew Goldis +// Alexandre Hétu Rivard // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -490,7 +491,7 @@ declare namespace Parse { /** * Represents a LiveQuery Subscription. - * + * * @see https://docs.parseplatform.org/js/guide/#live-queries * @see NodeJS.EventEmitter * @@ -556,7 +557,7 @@ subscription.on('close', () => {}); class LiveQuerySubscription extends NodeJS.EventEmitter { /** * Creates an instance of LiveQuerySubscription. - * + * * @param {string} id * @param {string} query * @param {string} [sessionToken] @@ -692,12 +693,7 @@ subscription.on('close', () => {}); interface JobRequest { params: any; - } - - interface JobStatus { - error?: (response: any) => void; message?: (response: any) => void; - success?: (response: any) => void; } interface FunctionRequest { @@ -707,12 +703,6 @@ subscription.on('close', () => {}); user?: User; } - interface FunctionResponse { - success: (response: any) => void; - error (code: number, response: any): void; - error (response: any): void; - } - interface Cookie { name?: string; options?: CookieOptions; @@ -734,11 +724,7 @@ subscription.on('close', () => {}); interface AfterSaveRequest extends TriggerRequest { } interface AfterDeleteRequest extends TriggerRequest { } interface BeforeDeleteRequest extends TriggerRequest { } - interface BeforeDeleteResponse extends FunctionResponse { } interface BeforeSaveRequest extends TriggerRequest { } - interface BeforeSaveResponse extends FunctionResponse { - success: () => void; - } // Read preference describes how MongoDB driver route read operations to the members of a replica set. enum ReadPreferenceOption { @@ -760,19 +746,16 @@ subscription.on('close', () => {}); objects: Object[] } - interface AfterFindResponse extends FunctionResponse { - success: (objects: Object[]) => void; - } - - function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void; - function afterSave(arg1: any, func?: (request: AfterSaveRequest) => void): void; - function beforeDelete(arg1: any, func?: (request: BeforeDeleteRequest, response: BeforeDeleteResponse) => void): void; - function beforeSave(arg1: any, func?: (request: BeforeSaveRequest, response: BeforeSaveResponse) => void): void; - function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => void): void; - function afterFind(arg1: any, func?: (request: AfterFindRequest, response: AfterFindResponse) => void): void; - function define(name: string, func?: (request: FunctionRequest, response: FunctionResponse) => void): void; + function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => Promise | void): void; + function afterSave(arg1: any, func?: (request: AfterSaveRequest) => Promise | void): void; + function beforeDelete(arg1: any, func?: (request: BeforeDeleteRequest) => Promise | void): void; + function beforeSave(arg1: any, func?: (request: BeforeSaveRequest) => Promise | void): void; + function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => Promise | void): void; + function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => Promise | Query): void; + function afterFind(arg1: any, func?: (request: AfterFindRequest) => Promise | any): void; + function define(name: string, func?: (request: FunctionRequest) => Promise | any): void; function httpRequest(options: HTTPOptions): Promise; - function job(name: string, func?: (request: JobRequest, status: JobStatus) => void): HttpResponse; + function job(name: string, func?: (request: JobRequest) => Promise | void): HttpResponse; function run(name: string, data?: any, options?: RunOptions): Promise; function useMasterKey(): void; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 8a2064e968..034002ed96 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -126,7 +126,7 @@ function test_query() { // Find objects with distinct key query.distinct('name'); - const testQuery = Parse.Query.or(query, query); + const testQuery = Parse.Query.or(query, query); } async function test_query_promise() { @@ -348,30 +348,30 @@ function test_cloud_functions() { // result }); - Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest, - response: Parse.Cloud.BeforeDeleteResponse) => { + Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest) => { + // result + }); + + Parse.Cloud.beforeDelete('MyCustomClass', async (request: Parse.Cloud.BeforeDeleteRequest) => { // result }); const CUSTOM_ERROR_INVALID_CONDITION = 1001 const CUSTOM_ERROR_IMMUTABLE_FIELD = 1002 - Parse.Cloud.beforeSave('MyCustomClass', (request: Parse.Cloud.BeforeSaveRequest, - response: Parse.Cloud.BeforeSaveResponse) => { - + Parse.Cloud.beforeSave('MyCustomClass', async (request: Parse.Cloud.BeforeSaveRequest) => { if (request.object.isNew()) { - if (!request.object.has('immutable')) return response.error('Field immutable is required') + if (!request.object.has('immutable')) throw new Error('Field immutable is required') } else { const original = request.original; if (original == null) { // When the object is not new, request.original must be defined - return response.error(CUSTOM_ERROR_INVALID_CONDITION, 'Original must me defined for an existing object') + throw new Parse.Error(CUSTOM_ERROR_INVALID_CONDITION, 'Original must me defined for an existing object') } if (original.get('immutable') !== request.object.get('immutable')) { - return response.error(CUSTOM_ERROR_IMMUTABLE_FIELD, 'This field cannot be changed') + throw new Parse.Error(CUSTOM_ERROR_IMMUTABLE_FIELD, 'This field cannot be changed') } } - response.success() }); Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { @@ -388,6 +388,18 @@ function test_cloud_functions() { request.readPreference = Parse.Cloud.ReadPreferenceOption.SecondaryPreferred request.readPreference = Parse.Cloud.ReadPreferenceOption.Nearest }); + + Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { + let query = request.query; // the Parse.Query + + return new Parse.Query("QueryMe!"); + }); + + Parse.Cloud.beforeFind('MyCustomClass', async (request: Parse.Cloud.BeforeFindRequest) => { + let query = request.query; // the Parse.Query + + return new Parse.Query("QueryMe, IN THE FUTURE!"); + }); } class PlaceObject extends Parse.Object { } From 1b2cef852ba589bb6fe766b5a6fe3b6a085cccfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20H=C3=A9tu=20Rivard?= Date: Thu, 10 Jan 2019 09:46:04 -0500 Subject: [PATCH 002/222] Added tests for missing cloud functions + fixed job request --- types/parse/index.d.ts | 4 ++-- types/parse/parse-tests.ts | 28 ++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index fbf5894964..0fd309782c 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for parse 2.1.0 +// Type definitions for parse 2.1.0 and parse-server 3.1.3 // Project: https://parseplatform.org/ // Definitions by: Ullisen Media Group // David Poetzsch-Heffter @@ -693,7 +693,7 @@ subscription.on('close', () => {}); interface JobRequest { params: any; - message?: (response: any) => void; + message: (response: any) => void; } interface FunctionRequest { diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 034002ed96..cb80764cd4 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -389,17 +389,29 @@ function test_cloud_functions() { request.readPreference = Parse.Cloud.ReadPreferenceOption.Nearest }); - Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { - let query = request.query; // the Parse.Query + Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { + let query = request.query; // the Parse.Query - return new Parse.Query("QueryMe!"); - }); + return new Parse.Query("QueryMe!"); + }); - Parse.Cloud.beforeFind('MyCustomClass', async (request: Parse.Cloud.BeforeFindRequest) => { - let query = request.query; // the Parse.Query + Parse.Cloud.beforeFind('MyCustomClass', async (request: Parse.Cloud.BeforeFindRequest) => { + let query = request.query; // the Parse.Query - return new Parse.Query("QueryMe, IN THE FUTURE!"); - }); + return new Parse.Query("QueryMe, IN THE FUTURE!"); + }); + + Parse.Cloud.afterFind('MyCustomClass', async (request: Parse.Cloud.AfterFindRequest) => { + return new Parse.Object('MyCustomClass'); + }); + + Parse.Cloud.define('AFunc', (request: Parse.Cloud.FunctionRequest) => { + return 'Some result'; + }); + + Parse.Cloud.job('AJob', (request: Parse.Cloud.JobRequest) => { + request.message('Message to associate with this job run'); + }); } class PlaceObject extends Parse.Object { } From 9a7ddff8cf0887b613a7023a2940eeb3c26be75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20H=C3=A9tu=20Rivard?= Date: Wed, 23 Jan 2019 15:57:30 -0500 Subject: [PATCH 003/222] Removed parse-server version from header --- types/parse/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 0fd309782c..b87a9f5f56 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for parse 2.1.0 and parse-server 3.1.3 +// Type definitions for parse 2.1.0 // Project: https://parseplatform.org/ // Definitions by: Ullisen Media Group // David Poetzsch-Heffter From aa2b7b7034d58ccee3946e654b477421f1e0b578 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Mon, 4 Feb 2019 23:05:15 -0800 Subject: [PATCH 004/222] Update several base types, add react-leaflet specific types and methods including: * AddLayerHandler * RemoveLayerHandler * LayerContainer * LeafletContext * LatLng * LatLngBounds * Point * Viewport * DivOverlayProps Update a few components and controls too: * MapControl * AttributionControl * From LayersControl.js: * ControlledLayerProps * ControlledLayer * BaseLayer * Overlay * LayersControlProps * LayersControl * ScaleControlProps * ScaleControl * ZoomControlProps * ZoomControl --- types/react-leaflet/index.d.ts | 110 ++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 28 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index c362a1f23c..7e25e8d301 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-leaflet 1.1 +// Type definitions for react-leaflet 2.2 // Project: https://github.com/PaulLeCam/react-leaflet // Definitions by: Dave Leaver , David Schneider , Yui T. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -118,6 +118,14 @@ export type LeafletEvents = MapEvents // These type parameters aren't needed for instantiating a component, but they are useful for // extending react-leaflet classes. +export type MapComponentProps = { + leaflet: LeafletContext, + pane?: string +} + +export type DivOverlayProps = MapComponentProps & Leaflet.DivOverlayOptions; + + export class MapComponent extends React.Component

{ _leafletEvents: LeafletEvents; leafletElement: E; @@ -177,10 +185,36 @@ export class Pane

void; + +export type RemoveLayerHandler = (layer: Leaflet.Layer) => void; + export interface LayerContainer { - addLayer(layer: Leaflet.Layer): this; - removeLayer(layer: number | Leaflet.Layer): this; + addLayer: AddLayerHandler, + removeLayer: RemoveLayerHandler } + +export interface LeafletContext { + map?: Leaflet.Map, + pane?: string | null | undefined, + layerContainer?: LayerContainer | null | undefined, + popupContainer?: Leaflet.Layer | null | undefined +} + +export type LatLng = Leaflet.LatLng | Array | object; + +export type LatLngBounds = Leaflet.LatLngBounds | Array; + +export type Point = [number, number] | Leaflet.Point; + +export interface Viewport { + center: [number, number] | null | undefined, + zoom: number | null | undefined +} + export class MapLayer

extends MapComponent { createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; @@ -305,38 +339,54 @@ export class Tooltip

extends React.Component

{ leafletElement: E; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; } -export type AttributionControlProps = Leaflet.Control.AttributionOptions; -export class AttributionControl

extends MapControl { } +export type AttributionControlProps = Leaflet.Control.AttributionOptions & MapControlProps; +export class AttributionControl

extends MapControl { + createLeafletElement(props: P): E; +} -export interface LayersControlProps extends LayersControlEvents, Leaflet.Control.LayersOptions { - baseLayers?: Leaflet.Control.LayersObject; - children?: Children; - overlays?: Leaflet.Control.LayersObject; +export interface LayersControlProps extends MapControlProps, LayersControlEvents, Leaflet.Control.LayersOptions { + children: Children; + collapsed?: boolean; +} +export class LayersControl

extends MapControl { + controlProps: { + addBaseLayer: AddLayerHandler, + addOverlay: AddLayerHandler, + removeLayer: RemoveLayerHandler, + removeLayerControl: RemoveLayerHandler + } + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + addBaseLayer(layer: Leaflet.Layer, name: string, checked: boolean): void; + addOverlay(layer: Leaflet.Layer, name: string, checked: boolean): void; + removeLayer(layer: Leaflet.Layer): void; + removeLayerControl(layer: Leaflet.Layer): void; } -export class LayersControl

extends MapControl { } export namespace LayersControl { - interface BaseControlledLayerProps { - checked?: boolean; - children?: Children; - removeLayer?(layer: Leaflet.Layer): void; - removeLayerControl?(layer: Leaflet.Layer): void; + interface ControlledLayerProps { + addBaseLayer: AddLayerHandler; + addOverlay: AddLayerHandler, + checked?: boolean, + children: Children, + leaflet: LeafletContext, + name: string, + removeLayer: RemoveLayerHandler, + removeLayerControl: RemoveLayerHandler } - interface ControlledLayerProps extends BaseControlledLayerProps { - addBaseLayer?(layer: Leaflet.Layer, name: string, checked: boolean): void; - addOverlay?(layer: Leaflet.Layer, name: string, checked: boolean): void; - name: string; - } - class ControlledLayer

extends React.Component

{ - layer?: Leaflet.Layer; - getChildContext(): { layerContainer: LayerContainer }; + class ControlledLayer

extends React.Component

{ + contextValue: LeafletContext; + layer: Leaflet.Layer | null | undefined; addLayer(): void; removeLayer(layer: Leaflet.Layer): void; } @@ -344,8 +394,12 @@ export namespace LayersControl { class Overlay

extends ControlledLayer

{ } } -export type ScaleControlProps = Leaflet.Control.ScaleOptions; -export class ScaleControl

extends MapControl { } +export type ScaleControlProps = Leaflet.Control.ScaleOptions & MapControlProps; +export class ScaleControl

extends MapControl { + createLeafletElement(props: P): E; +} -export type ZoomControlProps = Leaflet.Control.ZoomOptions; -export class ZoomControl

extends MapControl { } +export type ZoomControlProps = Leaflet.Control.ZoomOptions & MapControlProps; +export class ZoomControl

extends MapControl { + createLeafletElement(props: P): E; +} From 6fa80b498e015c49844d99abc92cd15e738474a8 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Tue, 5 Feb 2019 23:25:24 -0800 Subject: [PATCH 005/222] Add context and remove stray semi-colons * LeafletConsumer * LeafletProvider * withLeaflet --- types/react-leaflet/index.d.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 7e25e8d301..1a9936b31a 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -109,7 +109,7 @@ export type LeafletEvents = MapEvents & TileLayerEvents & PathEvents & FeatureGroupEvents - & LayersControlEvents; + & LayersControlEvents // Most react-leaflet components take two type parameters: // - P : the component's props object @@ -123,7 +123,7 @@ export type MapComponentProps = { pane?: string } -export type DivOverlayProps = MapComponentProps & Leaflet.DivOverlayOptions; +export type DivOverlayProps = MapComponentProps & Leaflet.DivOverlayOptions export class MapComponent extends React.Component

{ @@ -403,3 +403,14 @@ export type ZoomControlProps = Leaflet.Control.ZoomOptions & MapControlProps; export class ZoomControl

extends MapControl { createLeafletElement(props: P): E; } + +// context.js +export class LeafletConsumer extends React.Component> {} +export class LeafletProvider extends React.Component> {} + +type ContextProps = { + leaflet: LeafletContext; +} +type Omit = Pick> + +export function withLeaflet(WrappedComponent: React.Component): React.Component> \ No newline at end of file From 8759d616ca5ea2a06f9977867d0885e8c1f03d2b Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Tue, 5 Feb 2019 23:44:28 -0800 Subject: [PATCH 006/222] Update WMSTileLayerProps and WMSTileLayer --- types/react-leaflet/index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 1a9936b31a..b7edb68d2d 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -232,11 +232,15 @@ export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOption } export class TileLayer

extends GridLayer { } -export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { +export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions, GridLayerProps { children?: Children; url: string; } -export class WMSTileLayer

extends GridLayer { } +export class WMSTileLayer

extends GridLayer { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + getOptions(params: P): P; +} export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { bounds: Leaflet.LatLngBoundsExpression; From 440f35fd0f84d94730d11d27126e39ea3c901be5 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Wed, 6 Feb 2019 23:31:32 -0800 Subject: [PATCH 007/222] Update MapLayerProps, add back some semi-colons, update several props * GridLayerProps * TileLayerProps * ImageOverlayProps * LayerGroupProps * MarkerProps * CircleProps * CircleMarkerProps * FeatureGroupProps * GeoJSONProps * PolylineProps * PolygonProps * RectangleProps --- types/react-leaflet/index.d.ts | 81 +++++++++++++--------------------- 1 file changed, 31 insertions(+), 50 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index b7edb68d2d..6ead4ec6e3 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -182,26 +182,25 @@ export class Pane

void; export type RemoveLayerHandler = (layer: Leaflet.Layer) => void; export interface LayerContainer { - addLayer: AddLayerHandler, - removeLayer: RemoveLayerHandler + addLayer: AddLayerHandler; + removeLayer: RemoveLayerHandler; } export interface LeafletContext { - map?: Leaflet.Map, - pane?: string | null | undefined, - layerContainer?: LayerContainer | null | undefined, - popupContainer?: Leaflet.Layer | null | undefined + map?: Leaflet.Map; + pane?: string | null | undefined; + layerContainer?: LayerContainer | null | undefined; + popupContainer?: Leaflet.Layer | null | undefined; } export type LatLng = Leaflet.LatLng | Array | object; @@ -211,8 +210,8 @@ export type LatLngBounds = Leaflet.LatLngBounds | Array; export type Point = [number, number] | Leaflet.Point; export interface Viewport { - center: [number, number] | null | undefined, - zoom: number | null | undefined + center: [number, number] | null | undefined; + zoom: number | null | undefined; } export class MapLayer

extends MapComponent { @@ -221,13 +220,10 @@ export class MapLayer

extends MapLayer {} -export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOptions { - children?: Children; +export interface TileLayerProps extends GridLayerProps, TileLayerEvents, Leaflet.TileLayerOptions { url: string; } export class TileLayer

extends GridLayer { } @@ -242,24 +238,20 @@ export class WMSTileLayer

extends MapLayer { getChildContext(): { popupContainer: E }; } -export interface LayerGroupProps { - children?: Children; -} +export interface LayerGroupProps extends MapLayerProps { } export class LayerGroup

extends MapLayer { getChildContext(): { layerContainer: E }; } -export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions { - children?: Children; +export interface MarkerProps extends MapLayerProps, MarkerEvents, Leaflet.MarkerOptions { position: Leaflet.LatLngExpression; } export class Marker

extends MapLayer { @@ -274,51 +266,40 @@ export abstract class Path

extends MapLayer { setStyleIfChanged(fromProps: P, toProps: P): void; } -export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions { +export interface CircleProps extends MapLayerProps, PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; - children?: Children; radius: number; } export class Circle

extends Path { } -export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions { +export interface CircleMarkerProps extends PathProps, PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; - children?: Children; radius: number; } export class CircleMarker

extends Path { } -export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions { - children?: Children; -} +export interface FeatureGroupProps extends MapLayerProps, FeatureGroupEvents, Leaflet.PathOptions { } export class FeatureGroup

extends Path { getChildContext(): { layerContainer: E, popupContainer: E }; } -export interface GeoJSONProps extends FeatureGroupEvents, Leaflet.GeoJSONOptions { - children?: Children; +export interface GeoJSONProps extends PathProps, FeatureGroupEvents, Leaflet.GeoJSONOptions { data: GeoJSON.GeoJsonObject; - style?: Leaflet.StyleFunction; } export class GeoJSON

extends Path { } -export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { - children?: Children; +export interface PolylineProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; } export class Polyline

extends Path { } -export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions { - children?: Children; - popupContainer?: Leaflet.FeatureGroup; +export interface PolygonProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; } export class Polygon

extends Path { } -export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { - children?: Children; +export interface RectangleProps extends PathProps, PathEvents, Leaflet.PolylineOptions { bounds: Leaflet.LatLngBoundsExpression; - popupContainer?: Leaflet.FeatureGroup; } export class Rectangle

extends Path { } @@ -380,13 +361,13 @@ export class LayersControl

extends React.Component

{ contextValue: LeafletContext; From dd2fd322a86d952b103df88dd08175ece6e97853 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Fri, 8 Feb 2019 23:52:09 -0800 Subject: [PATCH 008/222] Update base props and classes along with some child components: * MapEvented * MapComponent * MapProps * Map * DivOverlayProps * DivOverlayTypes * DivOverlay * MapLayer * Path * Circle * CircleMarker * FeatureGroup * GeoJSON * PopupProps * Popup * TooltipProps * Tooltip --- types/react-leaflet/index.d.ts | 81 ++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 6ead4ec6e3..6bcfa81569 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -118,20 +118,21 @@ export type LeafletEvents = MapEvents // These type parameters aren't needed for instantiating a component, but they are useful for // extending react-leaflet classes. + export type MapComponentProps = { leaflet: LeafletContext, pane?: string } -export type DivOverlayProps = MapComponentProps & Leaflet.DivOverlayOptions - - -export class MapComponent extends React.Component

{ +export class MapEvented extends React.Component

{ _leafletEvents: LeafletEvents; leafletElement: E; extractLeafletEvents(props: P): LeafletEvents; bindLeafletEvents(next: LeafletEvents, prev: LeafletEvents): LeafletEvents; fireLeafletEvent(type: string, data: any): void; +} + +export class MapComponent

extends MapEvented { getOptions(props: P): P; } @@ -139,29 +140,48 @@ export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateO animate?: boolean; bounds?: Leaflet.LatLngBoundsExpression; boundsOptions?: Leaflet.FitBoundsOptions; - center?: Leaflet.LatLngExpression; - children?: Children; + children: Children; className?: string; id?: string; - maxBounds?: Leaflet.LatLngBoundsExpression; - maxZoom?: number; - minZoom?: number; style?: React.CSSProperties; useFlyTo?: boolean; - zoom?: number; + viewport?: Viewport + whenReady?: () => void; } -export class Map

extends MapComponent { - className?: string; - container: HTMLDivElement; - getChildContext(): { layerContainer: E, map: E }; +export class Map

extends MapEvented { + className: string | null | undefined; + contextValue: LeafletContext | null | undefined; + container: HTMLDivElement | null | undefined; + viewport: Viewport; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; - bindContainer(container: HTMLDivElement): void; + onViewportChange: () => void; + onViewportChanged: () => void; + bindContainer(container: HTMLDivElement | null | undefined): void; shouldUpdateCenter(next: Leaflet.LatLngExpression, prev: Leaflet.LatLngExpression): boolean; shouldUpdateBounds(next: Leaflet.LatLngBoundsExpression, prev: Leaflet.LatLngBoundsExpression): boolean; } +export interface DivOverlayProps extends MapComponentProps, Leaflet.DivOverlayOptions { + children: Children; + onClose?: () => void; + onOpen?: () => void; +} + +export interface DivOverlayTypes extends Leaflet.Evented { + isOpen: () => boolean; + update: () => void; +} + +export class DivOverlay

extends MapComponent { + createLeafletElement(_props: P): Error; + updateLeafletElement(_prevProps: P, _props: P): void; + onClose(): void; + onOpen(): void; + onRender(): void; +} + export interface PaneProps { name?: string; children?: Children; @@ -214,7 +234,7 @@ export interface Viewport { zoom: number | null | undefined; } -export class MapLayer

extends MapComponent { +export class MapLayer

extends MapComponent { createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; readonly layerContainer: LayerContainer | Leaflet.Map; @@ -259,7 +279,7 @@ export class Marker

extends MapLayer { +export abstract class Path

extends MapLayer { getChildContext(): { popupContainer: E }; getPathOptions(props: P): Leaflet.PathOptions; setStyle(options: Leaflet.PathOptions): void; @@ -270,23 +290,29 @@ export interface CircleProps extends MapLayerProps, PathEvents, Leaflet.CircleMa center: Leaflet.LatLngExpression; radius: number; } -export class Circle

extends Path { } +export class Circle

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface CircleMarkerProps extends PathProps, PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; radius: number; } -export class CircleMarker

extends Path { } +export class CircleMarker

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface FeatureGroupProps extends MapLayerProps, FeatureGroupEvents, Leaflet.PathOptions { } -export class FeatureGroup

extends Path { - getChildContext(): { layerContainer: E, popupContainer: E }; +export class FeatureGroup

extends LayerGroup { + createLeafletElement(props: P): E; } export interface GeoJSONProps extends PathProps, FeatureGroupEvents, Leaflet.GeoJSONOptions { data: GeoJSON.GeoJsonObject; } -export class GeoJSON

extends Path { } +export class GeoJSON

extends FeatureGroup { } export interface PolylineProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; @@ -303,21 +329,18 @@ export interface RectangleProps extends PathProps, PathEvents, Leaflet.PolylineO } export class Rectangle

extends Path { } -export interface PopupProps extends Leaflet.PopupOptions { - children?: Children; +export interface PopupProps extends Leaflet.PopupOptions, DivOverlayProps { position?: Leaflet.LatLngExpression; } -export class Popup

extends MapComponent { +export class Popup

extends DivOverlay { onPopupOpen(arg: { popup: E }): void; onPopupClose(arg: { popup: E }): void; renderPopupContent(): void; removePopupContent(): void; } -export interface TooltipProps extends Leaflet.TooltipOptions { - children?: Children; -} -export class Tooltip

extends MapComponent { +export interface TooltipProps extends Leaflet.TooltipOptions, DivOverlayProps { } +export class Tooltip

extends DivOverlay { onTooltipOpen(arg: { tooltip: E }): void; onTooltipClose(arg: { tooltip: E }): void; renderTooltipContent(): void; From 6d9df7cea064573694b41219537e145c78a82b2c Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 00:32:31 -0800 Subject: [PATCH 009/222] Update methods on GridLayer and GeoJSON --- types/react-leaflet/index.d.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 6bcfa81569..cf0ac1c60d 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -241,7 +241,11 @@ export class MapLayer

extends MapLayer {} +export class GridLayer

extends MapLayer { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + getOptions(props: P): P; +} export interface TileLayerProps extends GridLayerProps, TileLayerEvents, Leaflet.TileLayerOptions { url: string; @@ -312,7 +316,10 @@ export class FeatureGroup

extends FeatureGroup { } +export class GeoJSON

extends FeatureGroup { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface PolylineProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; From 008ed31b28a655cfc84b4fbca4fee0c0b006ac60 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 00:46:36 -0800 Subject: [PATCH 010/222] Update Tooltip methods --- types/react-leaflet/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index cf0ac1c60d..81d48e7d86 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -350,8 +350,6 @@ export interface TooltipProps extends Leaflet.TooltipOptions, DivOverlayProps { export class Tooltip

extends DivOverlay { onTooltipOpen(arg: { tooltip: E }): void; onTooltipClose(arg: { tooltip: E }): void; - renderTooltipContent(): void; - removeTooltipContent(): void; } export type MapControlProps = { From 74a4627af3e08e28430760d05ac7ea25d9dfbe3e Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 00:59:24 -0800 Subject: [PATCH 011/222] Update ImageOverlayProps and ImageOverlay --- types/react-leaflet/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 81d48e7d86..8234f36c78 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -265,9 +265,11 @@ export class WMSTileLayer

extends MapLayer { - getChildContext(): { popupContainer: E }; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; } export interface LayerGroupProps extends MapLayerProps { } From c3ec7d74124139e9828bf5893565a6823671d205 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 12:10:56 -0800 Subject: [PATCH 012/222] Update methods on TileLayer, Polyline, Polygon, and Rectangle --- types/react-leaflet/index.d.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 8234f36c78..c4eb701e0e 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -250,7 +250,10 @@ export class GridLayer

extends GridLayer { } +export class TileLayer

extends GridLayer { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions, GridLayerProps { children?: Children; @@ -326,17 +329,26 @@ export class GeoJSON

extends Path { } +export class Polyline

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface PolygonProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; } -export class Polygon

extends Path { } +export class Polygon

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface RectangleProps extends PathProps, PathEvents, Leaflet.PolylineOptions { bounds: Leaflet.LatLngBoundsExpression; } -export class Rectangle

extends Path { } +export class Rectangle

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} export interface PopupProps extends Leaflet.PopupOptions, DivOverlayProps { position?: Leaflet.LatLngExpression; From ac01d02987eeb17b6d885b8823f5da161b1069ca Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 12:39:13 -0800 Subject: [PATCH 013/222] Return void from createLeafletElement on DivOverlay, update LayerGroup and Popup methods --- types/react-leaflet/index.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index c4eb701e0e..563cb65e90 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -175,7 +175,7 @@ export interface DivOverlayTypes extends Leaflet.Evented { } export class DivOverlay

extends MapComponent { - createLeafletElement(_props: P): Error; + createLeafletElement(_props: P): void; updateLeafletElement(_prevProps: P, _props: P): void; onClose(): void; onOpen(): void; @@ -277,7 +277,7 @@ export class ImageOverlay

extends MapLayer { - getChildContext(): { layerContainer: E }; + createLeafletElement(props: P): E; } export interface MarkerProps extends MapLayerProps, MarkerEvents, Leaflet.MarkerOptions { @@ -354,10 +354,12 @@ export interface PopupProps extends Leaflet.PopupOptions, DivOverlayProps { position?: Leaflet.LatLngExpression; } export class Popup

extends DivOverlay { + getOptions(props: P): P; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; onPopupOpen(arg: { popup: E }): void; onPopupClose(arg: { popup: E }): void; - renderPopupContent(): void; - removePopupContent(): void; + onRender: () => void; } export interface TooltipProps extends Leaflet.TooltipOptions, DivOverlayProps { } From c2f4917796b3fdbd2efb1c1d3bd703f74b0f22cd Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 12:57:21 -0800 Subject: [PATCH 014/222] Update PaneProps, PaneState, and Pane --- types/react-leaflet/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 563cb65e90..0a165caa38 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -183,23 +183,23 @@ export class DivOverlay

ex } export interface PaneProps { - name?: string; children?: Children; - map?: Leaflet.Map; className?: string; + leaflet: LeafletContext; + name?: string; style?: React.CSSProperties; pane?: string; } export interface PaneState { - name?: string; + name: string | null | undefined; + context: LeafletContext | null | undefined; } export class Pane

extends React.Component { - getChildContext(): { pane: string }; createPane(props: P): void; removePane(): void; setStyle(arg: { style?: string, className?: string }): void; - getParentPane(): HTMLElement | undefined; - getPane(name: string): HTMLElement | undefined; + getParentPane(): HTMLElement | null | undefined; + getPane(name: string | null | undefined): HTMLElement | null | undefined; } export interface MapLayerProps extends MapComponentProps { From 4bf9a579e28643452c52a50e67fe5491298ee0b8 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sat, 9 Feb 2019 16:59:46 -0800 Subject: [PATCH 015/222] Update Marker methods --- types/react-leaflet/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 0a165caa38..cfcd69a72f 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -284,7 +284,8 @@ export interface MarkerProps extends MapLayerProps, MarkerEvents, Leaflet.Marker position: Leaflet.LatLngExpression; } export class Marker

extends MapLayer { - getChildContext(): { popupContainer: E }; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; } export interface PathProps extends PathEvents, Leaflet.PathOptions, MapLayerProps { } From b0ae2234be794632c5a626fdad7b96e4b199bdf0 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sun, 10 Feb 2019 01:17:29 -0800 Subject: [PATCH 016/222] Fix linting errors, mark leafletContext optional in many places, add methods to BaseLayer and Overlay --- types/react-leaflet/index.d.ts | 61 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index cfcd69a72f..75851472aa 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/PaulLeCam/react-leaflet // Definitions by: Dave Leaver , David Schneider , Yui T. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 3.2 import * as Leaflet from 'leaflet'; import * as React from 'react'; @@ -109,7 +109,7 @@ export type LeafletEvents = MapEvents & TileLayerEvents & PathEvents & FeatureGroupEvents - & LayersControlEvents + & LayersControlEvents; // Most react-leaflet components take two type parameters: // - P : the component's props object @@ -118,10 +118,9 @@ export type LeafletEvents = MapEvents // These type parameters aren't needed for instantiating a component, but they are useful for // extending react-leaflet classes. - -export type MapComponentProps = { - leaflet: LeafletContext, - pane?: string +export interface MapComponentProps { + leaflet?: LeafletContext; + pane?: string; } export class MapEvented extends React.Component

{ @@ -145,7 +144,7 @@ export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateO id?: string; style?: React.CSSProperties; useFlyTo?: boolean; - viewport?: Viewport + viewport?: Viewport; whenReady?: () => void; } @@ -185,7 +184,7 @@ export class DivOverlay

ex export interface PaneProps { children?: Children; className?: string; - leaflet: LeafletContext; + leaflet?: LeafletContext; name?: string; style?: React.CSSProperties; pane?: string; @@ -218,14 +217,14 @@ export interface LayerContainer { export interface LeafletContext { map?: Leaflet.Map; - pane?: string | null | undefined; - layerContainer?: LayerContainer | null | undefined; - popupContainer?: Leaflet.Layer | null | undefined; + pane?: string; + layerContainer?: LayerContainer; + popupContainer?: Leaflet.Layer; } -export type LatLng = Leaflet.LatLng | Array | object; +export type LatLng = Leaflet.LatLng | number[] | object; -export type LatLngBounds = Leaflet.LatLngBounds | Array; +export type LatLngBounds = Leaflet.LatLngBounds | LatLng[]; export type Point = [number, number] | Leaflet.Point; @@ -235,6 +234,8 @@ export interface Viewport { } export class MapLayer

extends MapComponent { + contextValue: LeafletContext | null | undefined; + leafletElement: E; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; readonly layerContainer: LayerContainer | Leaflet.Map; @@ -275,8 +276,7 @@ export class ImageOverlay

extends MapLayer { +export class LayerGroup

extends MapLayer { createLeafletElement(props: P): E; } @@ -370,7 +370,7 @@ export class Tooltip

extends React.Component

{ @@ -394,7 +394,7 @@ export class LayersControl

extends React.Component

{ contextValue: LeafletContext; layer: Leaflet.Layer | null | undefined; - addLayer(): void; removeLayer(layer: Leaflet.Layer): void; } - class BaseLayer

extends ControlledLayer

{ } - class Overlay

extends ControlledLayer

{ } + class BaseLayer

extends ControlledLayer

{ + constructor(props: ControlledLayerProps); + addLayer: (layer: Leaflet.Layer) => void; + } + class Overlay

extends ControlledLayer

{ + constructor(props: ControlledLayerProps); + addLayer: (layer: Leaflet.Layer) => void; + } } export type ScaleControlProps = Leaflet.Control.ScaleOptions & MapControlProps; @@ -438,9 +443,9 @@ export class ZoomControl

> {} export class LeafletProvider extends React.Component> {} -type ContextProps = { +export interface ContextProps { leaflet: LeafletContext; } -type Omit = Pick> +export type Omit = Pick>; -export function withLeaflet(WrappedComponent: React.Component): React.Component> \ No newline at end of file +export function withLeaflet(WrappedComponent: React.Component): React.Component>; From 3b11b16d95cfa12060c83020a056b707eb2043f3 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Sun, 10 Feb 2019 09:40:55 -0800 Subject: [PATCH 017/222] Revert to older version of TS for compatibility with react-leaflet-markercluster --- types/react-leaflet/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 75851472aa..e174eff001 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/PaulLeCam/react-leaflet // Definitions by: Dave Leaver , David Schneider , Yui T. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.2 +// TypeScript Version: 2.8 import * as Leaflet from 'leaflet'; import * as React from 'react'; @@ -176,9 +176,9 @@ export interface DivOverlayTypes extends Leaflet.Evented { export class DivOverlay

extends MapComponent { createLeafletElement(_props: P): void; updateLeafletElement(_prevProps: P, _props: P): void; - onClose(): void; - onOpen(): void; - onRender(): void; + onClose: () => void; + onOpen: () => void; + onRender: () => void; } export interface PaneProps { From a74b997f94e904731edf7514b7b7eeb2858fed4a Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Mon, 11 Feb 2019 00:00:27 -0800 Subject: [PATCH 018/222] Update withLeaflet and add tests for viewport example, withLeaflet, createLeafletElement, and updateLeafletElement --- types/react-leaflet/index.d.ts | 4 +- types/react-leaflet/react-leaflet-tests.tsx | 72 ++++++++++++++++++++- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index e174eff001..99f86a0078 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -444,8 +444,8 @@ export class LeafletConsumer extends React.Component> {} export interface ContextProps { - leaflet: LeafletContext; + leaflet?: LeafletContext; } export type Omit = Pick>; -export function withLeaflet(WrappedComponent: React.Component): React.Component>; +export function withLeaflet(WrappedComponent: React.ComponentType): React.Component>; diff --git a/types/react-leaflet/react-leaflet-tests.tsx b/types/react-leaflet/react-leaflet-tests.tsx index fe9825c465..2b6d9f49c1 100644 --- a/types/react-leaflet/react-leaflet-tests.tsx +++ b/types/react-leaflet/react-leaflet-tests.tsx @@ -16,8 +16,10 @@ import { MapProps, Marker, MarkerProps, + Path, Pane, Polygon, + PolygonProps, Polyline, Popup, PopupProps, @@ -25,7 +27,10 @@ import { TileLayer, Tooltip, WMSTileLayer, - ZoomControl + ZoomControl, + LeafletProvider, + withLeaflet, + Viewport } from 'react-leaflet'; const { BaseLayer, Overlay } = LayersControl; @@ -207,7 +212,7 @@ export class CustomComponent extends Component } } -// SOURCE ??? +// Similar to custom-icons.js export class MarkerWithDivIconExample extends Component { render() { return ( @@ -628,6 +633,44 @@ export class VectorLayersExample extends Component { } } +// viewport.js + +const DEFAULT_VIEWPORT = { + center: [51.505, -0.09] as [number, number], + zoom: 13 +}; + +export class ViewportExample extends Component { + state = { + viewport: { + center: [51.505, -0.09] as [number, number], + zoom: 13 + } + }; + + onClickReset = () => { + this.setState({ viewport: DEFAULT_VIEWPORT }); + } + + onViewportChanged = (viewport: Viewport) => { + this.setState({ viewport }); + } + + render() { + return ( + + + + ); + } +} + // wms-tile-layer.js interface WMSTileLayerExampleState { lat: number; @@ -729,6 +772,8 @@ class LegendControl extends MapControl } } +const legendControlComponent = withLeaflet(LegendControl); + const LegendControlExample = () => ( ( ); + +class CustomPolygon extends Path { + createLeafletElement(props: PolygonProps) { + const el = new L.Polygon(props.positions, this.getOptions(props)); + this.contextValue = { ...props.leaflet, popupContainer: el }; + return el; + } + + updateLeafletElement(fromProps: PolygonProps, toProps: PolygonProps) { + if (toProps.positions !== fromProps.positions) { + this.leafletElement.setLatLngs(toProps.positions); + } + this.setStyleIfChanged(fromProps, toProps); + } + + render() { + const { children } = this.props; + return children == null || this.contextValue == null ? null : ( + {children} + ); + } +} +const leafletComponent = withLeaflet(CustomPolygon); From 11ef1793cf05d67072afd284565c9c1a77fbeec4 Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Tue, 12 Feb 2019 00:42:00 -0800 Subject: [PATCH 019/222] Return ComponentType from withLeaflet --- types/react-leaflet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index 99f86a0078..b805aba70f 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -448,4 +448,4 @@ export interface ContextProps { } export type Omit = Pick>; -export function withLeaflet(WrappedComponent: React.ComponentType): React.Component>; +export function withLeaflet(WrappedComponent: React.ComponentType): React.ComponentType>; From e8fe30221655bc53c7761ce60ee8775317d35946 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Thu, 14 Feb 2019 12:20:14 +0100 Subject: [PATCH 020/222] [styled-components] Add test for union props --- types/styled-components/test/index.tsx | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx index a37c33f315..067cdc7d89 100644 --- a/types/styled-components/test/index.tsx +++ b/types/styled-components/test/index.tsx @@ -1030,3 +1030,32 @@ const WrapperFunc = (props: WrapperProps) =>

; const StyledWrapperFunc = styled(WrapperFunc)``; // No `children` in props, so this should generate an error const wrapperFunc = Text; // $ExpectError + +function unionTest() { + interface Book { + kind: 'book'; + author: string; + } + + interface Magazine { + kind: 'magazine'; + issue: number; + } + + type SomethingToRead = (Book | Magazine); + + const Readable: React.FunctionComponent = props => { + if (props.kind === 'magazine') { + return
magazine #{props.issue}
; + } + + return
magazine #{props.author}
; + }; + + const StyledReadable = styled(Readable)` + font-size: ${props => props.kind === 'book' ? 16 : 14} + `; + + ; + ; // $ExpectError +} From 39d881e4343a5d20046c2e57e33aebc7783883f2 Mon Sep 17 00:00:00 2001 From: ltlombardi Date: Thu, 14 Feb 2019 09:22:55 -0200 Subject: [PATCH 021/222] - new jsdocs, improvements in text and small fixes --- types/knockout/index.d.ts | 159 ++++++++++++++++++++++++-------------- 1 file changed, 99 insertions(+), 60 deletions(-) diff --git a/types/knockout/index.d.ts b/types/knockout/index.d.ts index 8bf99b79db..bf571c621e 100644 --- a/types/knockout/index.d.ts +++ b/types/knockout/index.d.ts @@ -12,7 +12,18 @@ // TypeScript Version: 2.3 interface KnockoutSubscribableFunctions { - notifySubscribers(valueToWrite?: T, event?: string): void; + /** + * Notify subscribers of knockout "change" event. This doesn't acctually change the observable value. + * @param eventValue A value to be sent with the event. + * @param event The knockout event. + */ + notifySubscribers(eventValue?: T, event?: "change"): void; + /** + * Notify subscribers of a knockout or user defined event. + * @param eventValue A value to be sent with the event. + * @param event The knockout or user defined event name. + */ + notifySubscribers(eventValue: U, event: string): void; } interface KnockoutComputedFunctions { @@ -57,7 +68,7 @@ interface KnockoutObservableArrayFunctions extends KnockoutReadonlyObservable pop(): T; /** * Adds a new item to the end of array. - * @param items Items to be added + * @param items Items to be added. */ push(...items: T[]): void; /** @@ -66,7 +77,7 @@ interface KnockoutObservableArrayFunctions extends KnockoutReadonlyObservable shift(): T; /** * Inserts a new item at the beginning of the array. - * @param items Items to be added + * @param items Items to be added. */ unshift(...items: T[]): number; /** @@ -85,24 +96,24 @@ interface KnockoutObservableArrayFunctions extends KnockoutReadonlyObservable // Ko specific /** - * Replaces the first value that equals oldItem with newItem - * @param oldItem Item to be replaced - * @param newItem Replacing item + * Replaces the first value that equals oldItem with newItem. + * @param oldItem Item to be replaced. + * @param newItem Replacing item. */ replace(oldItem: T, newItem: T): void; /** * Removes all values that equal item and returns them as an array. - * @param item The item to be removed + * @param item The item to be removed. */ remove(item: T): T[]; /** * Removes all values and returns them as an array. - * @param removeFunction A function used to determine true if item should be removed and fasle otherwise + * @param removeFunction A function used to determine true if item should be removed and fasle otherwise. */ remove(removeFunction: (item: T) => boolean): T[]; /** - * Removes all values that equal any of the supplied items - * @param items Items to be removed + * Removes all values that equal any of the supplied items. + * @param items Items to be removed. */ removeAll(items: T[]): T[]; /** @@ -140,45 +151,45 @@ interface KnockoutSubscribableStatic { interface KnockoutSubscription { /** - * Terminates a subscription + * Terminates a subscription. */ dispose(): void; } interface KnockoutSubscribable extends KnockoutSubscribableFunctions { /** - * Registers to be notified after the observable's value changes - * @param callback Function that is called whenever the notification happens - * @param target Defines the value of 'this' in the callback function - * @param event The name of the event to receive notification for + * Registers to be notified after the observable's value changes. + * @param callback Function that is called whenever the notification happens. + * @param target Defines the value of 'this' in the callback function. + * @param event The knockout event name. */ subscribe(callback: (newValue: T) => void, target?: any, event?: "change"): KnockoutSubscription; /** - * Registers to be notified before the observable's value changes - * @param callback Function that is called whenever the notification happens - * @param target Defines the value of 'this' in the callback function - * @param event The name of the event to receive notification for + * Registers to be notified before the observable's value changes. + * @param callback Function that is called whenever the notification happens. + * @param target Defines the value of 'this' in the callback function. + * @param event The knockout event name. */ subscribe(callback: (newValue: T) => void, target: any, event: "beforeChange"): KnockoutSubscription; /** - * Registers to be notified when the observable's value changes - * @param callback Function that is called whenever the notification happens - * @param target Defines the value of 'this' in the callback function - * @param event The name of the event to receive notification for + * Registers to be notified when a knockout or user defined event happens. + * @param callback Function that is called whenever the notification happens. eventValue can be anything. No relation to underlying observable. + * @param target Defines the value of 'this' in the callback function. + * @param event The knockout or user defined event name. */ - subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + subscribe(callback: (eventValue: U) => void, target: any, event: string): KnockoutSubscription; /** - * Customizes observables basic functionality + * Customizes observables basic functionality. * @param requestedExtenders Name of the extender feature and its value, e.g. { notify: 'always' }, { rateLimit: 50 } */ extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable; /** - * Gets total number of subscribers + * Gets total number of subscribers. */ getSubscriptionsCount(): number; /** - * Gets number of subscribers of a particular event - * @param event Event name + * Gets number of subscribers of a particular event. + * @param event Event name. */ getSubscriptionsCount(event: string): number; } @@ -187,20 +198,20 @@ interface KnockoutComputedStatic { fn: KnockoutComputedFunctions; /** - * Creates computed observable + * Creates computed observable. */ (): KnockoutComputed; /** - * Creates computed observable - * @param evaluatorFunction Function that computes the observable value - * @param context Defines the value of 'this' when evaluating the computed observable - * @param options An object with further properties for the computed observable + * Creates computed observable. + * @param evaluatorFunction Function that computes the observable value. + * @param context Defines the value of 'this' when evaluating the computed observable. + * @param options An object with further properties for the computed observable. */ (evaluatorFunction: () => T, context?: any, options?: KnockoutComputedOptions): KnockoutComputed; /** - * Creates computed observable - * @param options An object that defines the computed observable options and behavior - * @param context Defines the value of 'this' when evaluating the computed observable + * Creates computed observable. + * @param options An object that defines the computed observable options and behavior. + * @param context Defines the value of 'this' when evaluating the computed observable. */ (options: KnockoutComputedDefine, context?: any): KnockoutComputed; } @@ -228,7 +239,7 @@ interface KnockoutComputed extends KnockoutReadonlyComputed, KnockoutObser */ getDependenciesCount(): number; /** - * Customizes observables basic functionality + * Customizes observables basic functionality. * @param requestedExtenders Name of the extender feature and it's value, e.g. { notify: 'always' }, { rateLimit: 50 } */ extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed; @@ -283,7 +294,7 @@ interface KnockoutReadonlyObservable extends KnockoutSubscribable, Knockou /** - * Returns the current value of the computed observable without creating a dependency + * Returns the current value of the computed observable without creating a dependency. */ peek(): T; valueHasMutated?: { (): void; }; @@ -301,7 +312,7 @@ interface KnockoutComputedOptions { /** * Makes the computed observable writable. This is a function that receives values that other code is trying to write to your computed observable. * It’s up to you to supply custom logic to handle the incoming values, typically by writing the values to some underlying observable(s). - * @param value + * @param value Value being written to the computer observable. */ write?(value: T): void; /** @@ -640,15 +651,15 @@ interface KnockoutStatic { computed: KnockoutComputedStatic; /** - * Creates a pure computed observable - * @param evaluatorFunction Function that computes the observable value - * @param context Defines the value of 'this' when evaluating the computed observable + * Creates a pure computed observable. + * @param evaluatorFunction Function that computes the observable value. + * @param context Defines the value of 'this' when evaluating the computed observable. */ pureComputed(evaluatorFunction: () => T, context?: any): KnockoutComputed; /** - * Creates a pure computed observable - * @param options An object that defines the computed observable options and behavior - * @param context Defines the value of 'this' when evaluating the computed observable + * Creates a pure computed observable. + * @param options An object that defines the computed observable options and behavior. + * @param context Defines the value of 'this' when evaluating the computed observable. */ pureComputed(options: KnockoutComputedDefine, context?: any): KnockoutComputed; @@ -661,32 +672,32 @@ interface KnockoutStatic { toJS(viewModel: any): any; /** * Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isObservable(instance: any): instance is KnockoutObservable; /** * Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isObservable(instance: KnockoutObservable | T): instance is KnockoutObservable; /** * Determine if argument is a writable observable. Returns true for observables, observable arrays, and writable computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isWriteableObservable(instance: any): instance is KnockoutObservable; /** * Determine if argument is a writable observable. Returns true for observables, observable arrays, and writable computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isWriteableObservable(instance: KnockoutObservable | T): instance is KnockoutObservable; /** - * Determine if argument is a computed observable - * @param instance Object to be checked + * Determine if argument is a computed observable. + * @param instance Object to be checked. */ isComputed(instance: any): instance is KnockoutComputed; /** - * Determine if argument is a computed observable - * @param instance Object to be checked + * Determine if argument is a computed observable. + * @param instance Object to be checked. */ isComputed(instance: KnockoutObservable | T): instance is KnockoutComputed; @@ -695,8 +706,16 @@ interface KnockoutStatic { cleanNode(node: Node): Node; renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; - unwrap(value: KnockoutObservable | T): T; - unwrap(value: KnockoutObservableArray | T[]): T[]; + /** + * Returns the underlying value of the Knockout Observable or in case of plain js object, return the object. Use this to easily accept both observable and plain values. + * @param instance observable to be unwraped if it's an Observable. + */ + unwrap(instance: KnockoutObservable | T): T; + /** + * Gets the array inside the KnockoutObservableArray. + * @param instance observable to be unwraped. + */ + unwrap(instance: KnockoutObservableArray | T[]): T[]; /** * Get information about the current computed property during the execution of a computed observable’s evaluator function. @@ -783,10 +802,10 @@ interface KnockoutStatic { renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; /** - * Executes a callback function inside a computed observable, without creating a dependecy between it and the observables inside the function + * Executes a callback function inside a computed observable, without creating a dependecy between it and the observables inside the function. * @param callback Function to be called. - * @param callbackTarget Defines the value of 'this' in the callback function - * @param callbackArgs Arguments for the callback Function + * @param callbackTarget Defines the value of 'this' in the callback function. + * @param callbackArgs Arguments for the callback Function. */ ignoreDependencies(callback: () => T, callbackTarget?: any, callbackArgs?: any): T; @@ -924,9 +943,25 @@ declare namespace KnockoutComponentTypes { } interface Loader { + /** + * Define this if: you want to supply configurations programmatically based on names, e.g., to implement a naming convention. + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ getConfig?(componentName: string, callback: (result: ComponentConfig | null) => void): void; + /** + * Define this if: you want to take control over how component configurations are interpreted, e.g., if you do not want to use the standard 'viewModel/template' pair format. + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ loadComponent?(componentName: string, config: ComponentConfig, callback: (result: Definition | null) => void): void; + /** + * Define this if: you want to use custom logic to supply DOM nodes for a given template configuration (e.g., using an ajax request to fetch a template by URL). + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ loadTemplate?(componentName: string, templateConfig: any, callback: (result: Node[] | null) => void): void; + /** + * Define this if: you want to use custom logic to supply a viewmodel factory for a given viewmodel configuration (e.g., integrating with a third-party module loader or dependency injection system). + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ loadViewModel?(componentName: string, viewModelConfig: any, callback: (result: any) => void): void; suppressLoaderExceptions?: boolean; } @@ -941,7 +976,7 @@ interface KnockoutComponents { /** * Registers a component, in the default component loader, to be used by name in the component binding. - * @param componentName Component name. + * @param componentName Component name. Will be used for your custom HTML tag name * @param config Component configuration. */ register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void; @@ -956,7 +991,7 @@ interface KnockoutComponents { */ unregister(componentName: string): void; /** - * Searchs each registered component loader by component name, and returns the viewmodel/template declaration via callback parameter + * Searchs each registered component loader by component name, and returns the viewmodel/template declaration via callback parameter. * @param componentName Component name. * @param callback Function to be called with the viewmodel/template declaration parameter. */ @@ -968,6 +1003,10 @@ interface KnockoutComponents { clearCachedDefinition(componentName: string): void defaultLoader: KnockoutComponentTypes.Loader; loaders: KnockoutComponentTypes.Loader[]; + /** + * Returns the registered component name for a HTML element. Can be overwriten to to control dynamically which HTML element map to which component name. + * @param node html element that corresponds to a custom component. + */ getComponentNameForNode(node: Node): string; } From 6605356eb7ca1b9ef54c3f3ad00bfd4479188a1e Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Thu, 14 Feb 2019 12:20:20 +0100 Subject: [PATCH 022/222] [styled-components] Fix union type of props being lost --- types/styled-components/index.d.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/types/styled-components/index.d.ts b/types/styled-components/index.d.ts index a7dea63e06..c89b50c86d 100644 --- a/types/styled-components/index.d.ts +++ b/types/styled-components/index.d.ts @@ -5,6 +5,7 @@ // Adam Lavin // Jessica Franco // Jason Killian +// Sebastian Silbermann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 @@ -45,9 +46,9 @@ export type StyledProps

= ThemedStyledProps>; // Wrap in an outer-level conditional type to allow distribution over props that are unions type Defaultize = P extends any ? string extends keyof P ? P : - & Pick> - & Partial>> - & Partial>> + & PickU> + & Partial>> + & Partial>> : never; type ReactDefaultizedProps = C extends { defaultProps: infer D; } @@ -64,13 +65,13 @@ export type StyledComponentProps< // The props that are made optional by .attrs A extends keyof any > = WithOptionalTheme< - Omit< + OmitU< ReactDefaultizedProps< C, React.ComponentPropsWithRef > & O, A - > & Partial & O, A>>, + > & Partial & O, A>>, T > & WithChildrenIfReactComponentClass; @@ -345,8 +346,10 @@ export type ThemedCssFunction = BaseThemedCssFunction< >; // Helper type operators -type Omit = Pick>; -type WithOptionalTheme

= Omit & { +// Pick that distributes over union types +export type PickU = T extends any ? {[P in K]: T[P]} : never; +export type OmitU = T extends any ? PickU> : never; +type WithOptionalTheme

= OmitU & { theme?: T; }; type AnyIfEmpty = keyof T extends never ? any : T; From 4eb791cf5439a889766b77c8d8f4683f26785e61 Mon Sep 17 00:00:00 2001 From: Gordon Date: Wed, 23 Jan 2019 09:46:02 -0600 Subject: [PATCH 023/222] Add connectHighlight definitions --- types/react-instantsearch-core/index.d.ts | 50 +++++++++++++++- .../react-instantsearch-core-tests.tsx | 60 ++++++++++++++++++- 2 files changed, 107 insertions(+), 3 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index bceb91ca85..746eb0bd00 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -208,7 +208,52 @@ export function connectGeoSearch(stateless: React.StatelessComponent>, THit>(ctor: React.ComponentType): ConnectedComponentClass, GeoSearchExposed>; export function connectHierarchicalMenu(Composed: React.ComponentType): React.ComponentClass; -export function connectHighlight(Composed: React.ComponentType): React.ComponentClass; + + +export interface HighlightProvided { + /** + * function to retrieve and parse an attribute from a hit. It takes a configuration object with 3 attributes: + * * highlightProperty which is the property that contains the highlight structure from the records, + * * attribute which is the name of the attribute (it can be either a string or an array of strings) to look for, + * * hit which is the hit from Algolia. + * It returns an array of objects {value: string, isHighlighted: boolean}. + * If the element that corresponds to the attribute is an array of strings, it will return a nested array of objects. + * In this case you should cast the result: + * ```ts + * highlight({ + * attribute: 'my_string_array', + * hit, + * highlightProperty: '_highlightResult' + * }) as Array> + * ``` + */ + highlight(configuration: { + attribute: string, + hit: Hit, + highlightProperty: string, + preTag?: string, + postTag?: string, + }): Array<{value: string, isHighlighted: boolean}> +} + +interface HighlightPassedThru { + hit: Hit + attribute: string + highlightProperty?: string +} + +export type HighlightProps = HighlightProvided & HighlightPassedThru + +/** + * connectHighlight connector provides the logic to create an highlighter component that will retrieve, parse and render an highlighted attribute from an Algolia hit. + */ +export function connectHighlight(stateless: React.StatelessComponent>): React.ComponentClass>; +export function connectHighlight>, TDoc>(ctor: React.ComponentType): ConnectedComponentClass>; + +interface HitsProvided { + /** the records that matched the search state */ + hits: Hit[] +} /** * connectHits connector provides the logic to create connected components that will render the results retrieved from Algolia. @@ -217,7 +262,8 @@ export function connectHighlight(Composed: React.ComponentType): React.Comp * * https://community.algolia.com/react-instantsearch/connectors/connectHits.html */ -export function connectHits(ctor: React.ComponentType): ConnectedComponentClass; +export function connectHits(stateless: React.StatelessComponent>): React.ComponentClass; +export function connectHits, THit>(ctor: React.ComponentType): ConnectedComponentClass>; export function connectHitsPerPage(Composed: React.ComponentType): React.ComponentClass; diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index e39a9f53e6..051e02c3b3 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -11,7 +11,11 @@ import { CurrentRefinementsProvided, connectCurrentRefinements, RefinementListProvided, - Refinement + Refinement, + connectHighlight, + connectHits, + HighlightProvided, + HighlightProps } from 'react-instantsearch-core'; () => { @@ -219,3 +223,57 @@ import { ; }; + +() => { + interface MyDoc { + a: 1; + b: { + c: '2' + }; + } + + const CustomHighlight = connectHighlight( + ({ highlight, attribute, hit }) => { + const highlights = highlight({ + highlightProperty: '_highlightResult', + attribute, + hit + }); + + return <> + {highlights.map(part => part.isHighlighted ? ( + {part.value} + ) : ( + {part.value} + )) + }; + } + ); + + class CustomHighlight2 extends React.Component { + render() { + const {highlight, attribute, hit, limit} = this.props; + const highlights = highlight({ + highlightProperty: '_highlightResult', + attribute, + hit + }); + + return <> + {highlights.slice(0, limit).map(part => part.isHighlighted ? ( + {part.value} + ) : ( + {part.value} + )) + }; + } + } + const ConnectedCustomHighlight2 = connectHighlight(CustomHighlight2); + + connectHits(({ hits }) => ( +

+ + +

+ )); +} From defc473ae9f893bfb655c7841409de8470074d00 Mon Sep 17 00:00:00 2001 From: Gordon Date: Mon, 28 Jan 2019 10:59:00 -0600 Subject: [PATCH 024/222] Improve definitions for translatable, createConnector, autocomplete --- types/react-instantsearch-core/index.d.ts | 76 ++++- .../react-instantsearch-core-tests.tsx | 269 +++++++++++++++++- 2 files changed, 330 insertions(+), 15 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index 746eb0bd00..b38db4c718 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -7,6 +7,7 @@ // TypeScript Version: 2.9 import * as React from 'react'; +import { SearchParameters } from 'algoliasearch-helper' // Core /** @@ -29,7 +30,7 @@ export function createInstantSearch( */ export function createIndex(defaultRoot: object): React.ComponentClass; -export interface ConnectorDescription { +export interface ConnectorDescription { displayName: string; propTypes?: any; defaultProps?: any; @@ -43,14 +44,26 @@ export interface ConnectorDescription { * meta is the list of metadata from all widgets whose connector defines a getMetadata method. * searchForFacetValuesResults holds the search for facet values results. */ - getProvidedProps?(...args: any[]): any; + getProvidedProps( + this: React.Component, + props: TExposed, + searchState: SearchState, + searchResults: SearchResults, + metadata: any, + resultsFacetValues: any, + ): TProvided; /** * This method defines exactly how the refine prop of widgets affects the search state. * It takes in the current props of the higher-order component, the search state of all widgets, as well as all arguments passed * to the refine and createURL props of stateful widgets, and returns a new state. */ - refine?(...args: any[]): any; + refine?( + this: React.Component, + props: TExposed, + searchState: SearchState, + ...args: any[], + ): any; /** * This method applies the current props and state to the provided SearchParameters, and returns a new SearchParameters. The SearchParameters @@ -59,7 +72,12 @@ export interface ConnectorDescription { * to produce a new SearchParameters. Then, if the output SearchParameters differs from the previous one, a new search is triggered. * As such, the getSearchParameters method allows you to describe how the state and props of a widget should affect the search parameters. */ - getSearchParameters?(...args: any[]): any; + getSearchParameters?( + this: React.Component, + searchParameters: SearchParameters, + props: TExposed, + searchState: SearchState, + ): any; /** * This method allows the widget to register a custom metadata object for any props and state combination. @@ -70,7 +88,11 @@ export interface ConnectorDescription { * The CurrentRefinements widget leverages this mechanism in order to allow any widget to declare the filters it has applied. If you want to add * your own filter, declare a filters property on your widget’s metadata */ - getMetadata?(...args: any[]): any; + getMetadata?( + this: React.Component, + props: TExposed, + searchState: SearchState, + ...args: any[]): any; /** * This method needs to be implemented if you want to have the ability to perform a search for facet values inside your widget. @@ -78,7 +100,11 @@ export interface ConnectorDescription { * props of stateful widgets, and returns an object of the shape: {facetName: string, query: string, maxFacetHits?: number}. The default value for the * maxFacetHits is the one set by the API which is 10. */ - searchForFacetValues?(...args: any[]): any; + searchForFacetValues?( + this: React.Component, + searchState: SearchState, + nextRefinement?: any, + ): any; /** * This method is called when a widget is about to unmount in order to clean the searchState. @@ -87,7 +113,7 @@ export interface ConnectorDescription { * searchState holds the searchState of all widgets, with the shape {[widgetId]: widgetState}. Stateful widgets describe the format of their searchState * in their respective documentation entry. */ - cleanUp?(...args: any[]): any; + cleanUp?(this: React.Component, props: TExposed, searchState: SearchState): SearchState; } /** @@ -100,7 +126,10 @@ export interface ConnectorDescription { * @return a function that wraps a component into * an instantsearch connected one. */ -export function createConnector(connectorDesc: ConnectorDescription): (Composed: React.ComponentType) => React.ComponentClass; +export function createConnector( + connectorDesc: ConnectorDescription, +): >(Composed: React.ComponentType) => + ConnectedComponentClass; // Utils export const HIGHLIGHT_TAGS: { @@ -108,7 +137,18 @@ export const HIGHLIGHT_TAGS: { highlightPostTag: string, }; export const version: string; -export function translatable(defaultTranslations: any): (Composed: React.ComponentType) => React.ComponentClass; + + +export interface TranslatableProvided { + translate(key: string, ...params: any[]): string +} +export interface TranslatableExposed { + translations?: { [key: string]: string | ((...args: any[]) => string) } +} + +export function translatable(defaultTranslations: { [key: string]: string | ((...args: any[]) => string) }): + (ctor: React.ComponentType) => + ConnectedComponentClass // Widgets /** @@ -125,7 +165,19 @@ export function translatable(defaultTranslations: any): (Composed: React.Compone export class Configure extends React.Component {} // Connectors -export function connectAutoComplete(Composed: React.ComponentType): React.ComponentClass; +export interface AutocompleteProvided { + hits: Array>; + currentRefinement: string; + refine(value?: string): void; +} + +export interface AutocompleteExposed { + defaultRefinement?: string; +} + +export function connectAutoComplete(stateless: React.StatelessComponent>,): React.ComponentClass; +export function connectAutoComplete, TDoc>(Composed: React.ComponentType): ConnectedComponentClass, AutocompleteExposed>; + export function connectBreadcrumb(Composed: React.ComponentType): React.ComponentClass; export function connectConfigure(Composed: React.ComponentType): React.ComponentClass; @@ -474,6 +526,8 @@ export type ConnectedComponentClass * https://community.algolia.com/react-instantsearch/guide/Search_state.html */ export interface SearchState { + [widgetId: string]: any + range?: { [key: string]: { min: number; @@ -533,7 +587,7 @@ export interface SearchResults { nbPages: number; page: number; processingTimeMS: number; - exhaustiveNbHits: true; + exhaustiveNbHits: boolean; disjunctiveFacets: any[]; hierarchicalFacets: any[]; facets: any[]; diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index 051e02c3b3..25bb9ac0df 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -15,7 +15,12 @@ import { connectHighlight, connectHits, HighlightProvided, - HighlightProps + HighlightProps, + AutocompleteProvided, + connectAutoComplete, + Hit, + TranslatableProvided, + translatable } from 'react-instantsearch-core'; () => { @@ -36,7 +41,13 @@ import { // https://community.algolia.com/react-instantsearch/guide/Custom_connectors.html () => { - const CoolWidget = createConnector({ + interface Provided { + query: string; + page: string; + refine: (newQuery: string, newPage: number) => void; + } + + const CoolWidget = createConnector({ displayName: 'CoolWidget', getProvidedProps(props, searchState) { @@ -62,7 +73,7 @@ import { queryAndPage: [newQuery, newPage], }; }, - })(props => + })((props: Provided) =>
The query is {props.query}, the page is {props.page}. {/* @@ -276,4 +287,254 @@ import {

)); -} +}; + +// https://github.com/algolia/react-instantsearch/blob/master/examples/autocomplete/src/App-Mentions.js +() => { + const Mention: any = null; // import Mention from 'antd/lib/mention'; + + const AsyncMention = ({ hits, refine }: AutocompleteProvided) => ( + hit.name)} + onSearchChange={refine} + /> + ); + + const ConnectedAsyncMention = connectAutoComplete(AsyncMention); + + ; +}; + +// https://github.com/algolia/react-instantsearch/blob/master/examples/autocomplete/src/App-Multi-Index.js +import * as Autosuggest from 'react-autosuggest'; +() => { + class Example extends React.Component { + state = { + value: this.props.currentRefinement, + }; + + onChange = (_event: any, { newValue }: { newValue: string }) => { + this.setState({ + value: newValue, + }); + } + + onSuggestionsFetchRequested = ({ value }: { value: string }) => { + this.props.refine(value); + } + + onSuggestionsClearRequested = () => { + this.props.refine(); + } + + getSuggestionValue(hit: Hit) { + return hit.name; + } + + renderSuggestion(hit: Hit) { + const Highlight: any = null; // import {Highlight} from 'react-instantsearch-dom' + return ; + } + + renderSectionTitle(section: any) { + return section.index; + } + + getSectionSuggestions(section: any) { + return section.hits; + } + + render() { + const { hits } = this.props; + const { value } = this.state; + + const inputProps = { + placeholder: 'Search for a product...', + onChange: this.onChange, + value, + }; + + return ( + + ); + } + } + + const AutoComplete = connectAutoComplete(Example); + + ; +}; + +() => { + type Props = SearchBoxProvided & TranslatableProvided & { + className?: string + showLoadingIndicator?: boolean + + submit?: JSX.Element; + reset?: JSX.Element; + loadingIndicator?: JSX.Element; + + onSubmit?: (event: React.SyntheticEvent) => any; + onReset?: (event: React.SyntheticEvent) => any; + onChange?: (event: React.SyntheticEvent) => any; + }; + interface State { + query: string | null; + } + + class SearchBox extends React.Component { + static defaultProps = { + currentRefinement: '', + className: 'ais-SearchBox', + focusShortcuts: ['s', '/'], + autoFocus: false, + searchAsYouType: true, + showLoadingIndicator: false, + isSearchStalled: false, + reset: clear, + submit: search, + }; + + constructor(props: SearchBox['props']) { + super(props); + + this.state = { + query: null, + }; + } + + getQuery = () => this.props.currentRefinement; + + onSubmit = (e: React.SyntheticEvent) => { + e.preventDefault(); + e.stopPropagation(); + + const { refine, onSubmit } = this.props; + + if (onSubmit) { + onSubmit(e); + } + return false; + } + + onChange = (event: React.ChangeEvent) => { + const { onChange } = this.props; + const value = event.target.value; + + this.setState({ query: value }); + + if (onChange) { + onChange(event); + } + } + + onReset = (event: React.FormEvent) => { + const { refine, onReset } = this.props; + + refine(''); + + this.setState({ query: '' }); + + if (onReset) { + onReset(event); + } + } + + render() { + const { + className, + translate, + loadingIndicator, + submit, + reset, + } = this.props; + const query = this.getQuery(); + + const isSearchStalled = + this.props.showLoadingIndicator && this.props.isSearchStalled; + + const isCurrentQuerySubmitted = + query && query === this.props.currentRefinement; + + const button = + isSearchStalled ? 'loading' : + isCurrentQuerySubmitted ? 'reset' : 'submit'; + + return ( +
+
+ + + + +
+
+ ); + } + } + + const TranslatableSearchBox = translatable({ + resetTitle: 'Clear the search query.', + submitTitle: 'Submit your search query.', + placeholder: 'Search here…', + })(SearchBox); + + const ConnectedSearchBox = connectSearchBox(TranslatableSearchBox); + + search} + onSubmit={(evt) => { console.log('submitted', evt); }} + />; +}; From 3de6b3d9060a60cd428429429d1dc1c4464b8bef Mon Sep 17 00:00:00 2001 From: Gordon Date: Mon, 28 Jan 2019 11:18:29 -0600 Subject: [PATCH 025/222] Improve createConnector definition --- types/react-instantsearch-core/index.d.ts | 12 +- .../react-instantsearch-core-tests.tsx | 121 ++++++++++++++++-- 2 files changed, 122 insertions(+), 11 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index b38db4c718..68f977b538 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -116,6 +116,10 @@ export interface ConnectorDescription { cleanUp?(this: React.Component, props: TExposed, searchState: SearchState): SearchState; } +export type ConnectorProvided = TProvided & + { refine: (...args: any[]) => any, createURL: (...args: any[]) => string } & + { searchForItems: (...args: any[]) => any } + /** * Connectors are the HOC used to transform React components * into InstantSearch widgets. @@ -128,8 +132,12 @@ export interface ConnectorDescription { */ export function createConnector( connectorDesc: ConnectorDescription, -): >(Composed: React.ComponentType) => - ConnectedComponentClass; +): ( + (stateless: React.StatelessComponent>) => React.ComponentClass + ) & ( + >>(Composed: React.ComponentType) => + ConnectedComponentClass, TExposed> + ); // Utils export const HIGHLIGHT_TAGS: { diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index 25bb9ac0df..aa8f3e88ec 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -20,7 +20,8 @@ import { connectAutoComplete, Hit, TranslatableProvided, - translatable + translatable, + ConnectorProvided } from 'react-instantsearch-core'; () => { @@ -41,13 +42,7 @@ import { // https://community.algolia.com/react-instantsearch/guide/Custom_connectors.html () => { - interface Provided { - query: string; - page: string; - refine: (newQuery: string, newPage: number) => void; - } - - const CoolWidget = createConnector({ + const CoolWidget = createConnector({ displayName: 'CoolWidget', getProvidedProps(props, searchState) { @@ -73,9 +68,10 @@ import { queryAndPage: [newQuery, newPage], }; }, - })((props: Provided) => + })((props) =>
The query is {props.query}, the page is {props.page}. + This is an error: {props.somethingElse} { /* $ExpectError */} {/* Clicking on this button will update the searchState to: { @@ -102,6 +98,113 @@ import { ; }; +() => { + interface Provided { + query: string; + page: number; + } + + interface Exposed { + defaultRefinement: string; + startAtPage: number; + } + + const typedCoolConnector = createConnector({ + displayName: 'CoolWidget', + + getProvidedProps(props, searchState) { + // Since the `queryAndPage` searchState entry isn't necessarily defined, we need + // to default its value. + const [query, page] = searchState.queryAndPage || + [props.defaultRefinement, props.startAtPage]; + + // Connect the underlying component to the `queryAndPage` searchState entry. + return { + query, + page, + }; + }, + + refine(props, searchState, newQuery, newPage) { + // When the underlying component calls its `refine` prop, update the searchState + // with the new query and page. + return { + // `searchState` represents the search state of *all* widgets. We need to extend it + // instead of replacing it, otherwise other widgets will lose their + // respective state. + ...searchState, + queryAndPage: [newQuery, newPage], + }; + }, + }); + + const TypedCoolWidgetStateless = typedCoolConnector((props) => +
+ The query is {props.query}, the page is {props.page}. + This is an error: {props.somethingElse} { /* $ExpectError */} + {/* + Clicking on this button will update the searchState to: + { + ...otherSearchState, + query: 'algolia', + page: 20, + } + */} +
+ ); + + ; + + const TypedCoolWidget = typedCoolConnector( + class extends React.Component & { passThruName: string }> { + render() { + const props = this.props; + return
+ The query is {props.query}, the page is {props.page}. + The name is {props.passThruName} + {/* + Clicking on this button will update the searchState to: + { + ...otherSearchState, + query: 'algolia', + page: 20, + } + */} +
; + } + } + ); + + ; + +}; + () => { interface StateResultsProps { searchResults: SearchResults<{ From b242c7844898dfe7a415358758fbc9f1d6e0efaf Mon Sep 17 00:00:00 2001 From: Gordon Date: Mon, 28 Jan 2019 11:25:22 -0600 Subject: [PATCH 026/222] Fix linter issues --- types/react-instantsearch-core/index.d.ts | 43 ++++++++++--------- .../react-instantsearch-core-tests.tsx | 9 ++-- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index 68f977b538..f33c690254 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -7,7 +7,7 @@ // TypeScript Version: 2.9 import * as React from 'react'; -import { SearchParameters } from 'algoliasearch-helper' +import { SearchParameters } from 'algoliasearch-helper'; // Core /** @@ -118,7 +118,7 @@ export interface ConnectorDescription { export type ConnectorProvided = TProvided & { refine: (...args: any[]) => any, createURL: (...args: any[]) => string } & - { searchForItems: (...args: any[]) => any } + { searchForItems: (...args: any[]) => any }; /** * Connectors are the HOC used to transform React components @@ -146,17 +146,16 @@ export const HIGHLIGHT_TAGS: { }; export const version: string; - export interface TranslatableProvided { - translate(key: string, ...params: any[]): string + translate(key: string, ...params: any[]): string; } export interface TranslatableExposed { - translations?: { [key: string]: string | ((...args: any[]) => string) } + translations?: { [key: string]: string | ((...args: any[]) => string) }; } export function translatable(defaultTranslations: { [key: string]: string | ((...args: any[]) => string) }): (ctor: React.ComponentType) => - ConnectedComponentClass + ConnectedComponentClass; // Widgets /** @@ -183,8 +182,10 @@ export interface AutocompleteExposed { defaultRefinement?: string; } -export function connectAutoComplete(stateless: React.StatelessComponent>,): React.ComponentClass; -export function connectAutoComplete, TDoc>(Composed: React.ComponentType): ConnectedComponentClass, AutocompleteExposed>; +// tslint:disable-next-line:no-unnecessary-generics +export function connectAutoComplete(stateless: React.StatelessComponent>): React.ComponentClass; +export function connectAutoComplete, TDoc>(Composed: React.ComponentType): + ConnectedComponentClass, AutocompleteExposed>; export function connectBreadcrumb(Composed: React.ComponentType): React.ComponentClass; export function connectConfigure(Composed: React.ComponentType): React.ComponentClass; @@ -269,7 +270,6 @@ export function connectGeoSearch> export function connectHierarchicalMenu(Composed: React.ComponentType): React.ComponentClass; - export interface HighlightProvided { /** * function to retrieve and parse an attribute from a hit. It takes a configuration object with 3 attributes: @@ -288,21 +288,21 @@ export interface HighlightProvided { * ``` */ highlight(configuration: { - attribute: string, - hit: Hit, - highlightProperty: string, - preTag?: string, - postTag?: string, - }): Array<{value: string, isHighlighted: boolean}> + attribute: string; + hit: Hit; + highlightProperty: string; + preTag?: string; + postTag?: string; + }): Array<{value: string, isHighlighted: boolean}>; } interface HighlightPassedThru { - hit: Hit - attribute: string - highlightProperty?: string + hit: Hit; + attribute: string; + highlightProperty?: string; } -export type HighlightProps = HighlightProvided & HighlightPassedThru +export type HighlightProps = HighlightProvided & HighlightPassedThru; /** * connectHighlight connector provides the logic to create an highlighter component that will retrieve, parse and render an highlighted attribute from an Algolia hit. @@ -312,7 +312,7 @@ export function connectHighlight>, T interface HitsProvided { /** the records that matched the search state */ - hits: Hit[] + hits: Array>; } /** @@ -322,6 +322,7 @@ interface HitsProvided { * * https://community.algolia.com/react-instantsearch/connectors/connectHits.html */ +// tslint:disable-next-line:no-unnecessary-generics export function connectHits(stateless: React.StatelessComponent>): React.ComponentClass; export function connectHits, THit>(ctor: React.ComponentType): ConnectedComponentClass>; @@ -534,7 +535,7 @@ export type ConnectedComponentClass * https://community.algolia.com/react-instantsearch/guide/Search_state.html */ export interface SearchState { - [widgetId: string]: any + [widgetId: string]: any; range?: { [key: string]: { diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index aa8f3e88ec..09bab5af15 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -71,7 +71,9 @@ import { })((props) =>
The query is {props.query}, the page is {props.page}. - This is an error: {props.somethingElse} { /* $ExpectError */} + This is an error: { + props.somethingElse // $ExpectError + } {/* Clicking on this button will update the searchState to: { @@ -141,7 +143,9 @@ import { const TypedCoolWidgetStateless = typedCoolConnector((props) =>
The query is {props.query}, the page is {props.page}. - This is an error: {props.somethingElse} { /* $ExpectError */} + This is an error: { + props.somethingElse // $ExpectError + } {/* Clicking on this button will update the searchState to: { @@ -202,7 +206,6 @@ import { defaultRefinement={'asdf'} startAtPage={10} passThruName={'test'} />; - }; () => { From d40d1983b3a2559e0cfee6c93da50a9add1a054b Mon Sep 17 00:00:00 2001 From: Gordon Date: Fri, 15 Feb 2019 14:57:10 -0600 Subject: [PATCH 027/222] Import SearchParameters from helper --- types/react-instantsearch-core/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index f33c690254..27bd779f3d 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -77,7 +77,7 @@ export interface ConnectorDescription { searchParameters: SearchParameters, props: TExposed, searchState: SearchState, - ): any; + ): SearchParameters; /** * This method allows the widget to register a custom metadata object for any props and state combination. From 2a793b0dcd7be70a1391330d5cc883d05486b544 Mon Sep 17 00:00:00 2001 From: Gordon Date: Fri, 15 Feb 2019 14:57:44 -0600 Subject: [PATCH 028/222] Add connectStats --- types/react-instantsearch-core/index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index 27bd779f3d..f2623cbcdb 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -512,7 +512,15 @@ export interface StateResultsProvided { export function connectStateResults(stateless: React.StatelessComponent): React.ComponentClass; export function connectStateResults>, TDoc>(ctor: React.ComponentType): ConnectedComponentClass>; -export function connectStats(Composed: React.ComponentType): React.ComponentClass; +interface StatsProvided { + nbHits: number, + processingTimeMS: number +} + +export function connectStats(stateless: React.StatelessComponent): React.ComponentClass +export function connectStats, TDoc>(ctor: React.ComponentType): + ConnectedComponentClass + export function connectToggleRefinement(Composed: React.ComponentType): React.ComponentClass; export interface AlgoliaError { From fda1393189c39fce4762e0f7ec93af3d4c29c497 Mon Sep 17 00:00:00 2001 From: Gordon Date: Fri, 15 Feb 2019 14:59:29 -0600 Subject: [PATCH 029/222] Add haroen and samuel as maintainers --- types/react-instantsearch-core/index.d.ts | 2 ++ types/react-instantsearch-dom/index.d.ts | 2 ++ types/react-instantsearch-native/index.d.ts | 2 ++ types/react-instantsearch/index.d.ts | 2 ++ 4 files changed, 8 insertions(+) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index f2623cbcdb..d3a4baa0dc 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Gordon Burgett // Justin Powell // David Furlong +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 diff --git a/types/react-instantsearch-dom/index.d.ts b/types/react-instantsearch-dom/index.d.ts index 6ecb03c981..6f270485b3 100644 --- a/types/react-instantsearch-dom/index.d.ts +++ b/types/react-instantsearch-dom/index.d.ts @@ -2,6 +2,8 @@ // Project: https://community.algolia.com/react-instantsearch/ // Definitions by: Gordon Burgett // Justin Powell +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 diff --git a/types/react-instantsearch-native/index.d.ts b/types/react-instantsearch-native/index.d.ts index 6b328de132..74933ebabf 100644 --- a/types/react-instantsearch-native/index.d.ts +++ b/types/react-instantsearch-native/index.d.ts @@ -2,6 +2,8 @@ // Project: https://community.algolia.com/react-instantsearch // Definitions by: Gordon Burgett // Justin Powell +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 diff --git a/types/react-instantsearch/index.d.ts b/types/react-instantsearch/index.d.ts index 3f80cf4aa3..64a415e6ba 100644 --- a/types/react-instantsearch/index.d.ts +++ b/types/react-instantsearch/index.d.ts @@ -2,6 +2,8 @@ // Project: https://community.algolia.com/react-instantsearch/ // Definitions by: Gordon Burgett // Justin Powell +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 From 7880ff88bbc5da1974f32b9273c5f08a47b47c90 Mon Sep 17 00:00:00 2001 From: Gordon Date: Fri, 15 Feb 2019 16:53:32 -0600 Subject: [PATCH 030/222] Fix linter errors --- types/react-instantsearch-core/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index d3a4baa0dc..68bebdee9f 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -515,13 +515,13 @@ export function connectStateResults(stateless: React.StatelessComponent>, TDoc>(ctor: React.ComponentType): ConnectedComponentClass>; interface StatsProvided { - nbHits: number, - processingTimeMS: number + nbHits: number; + processingTimeMS: number; } -export function connectStats(stateless: React.StatelessComponent): React.ComponentClass -export function connectStats, TDoc>(ctor: React.ComponentType): - ConnectedComponentClass +export function connectStats(stateless: React.StatelessComponent): React.ComponentClass; +export function connectStats>(ctor: React.ComponentType): + ConnectedComponentClass; export function connectToggleRefinement(Composed: React.ComponentType): React.ComponentClass; From 531ab265ca3d76bee3e601627caa01b27ec7f67b Mon Sep 17 00:00:00 2001 From: Mick Dekkers Date: Sat, 16 Feb 2019 11:16:01 +0100 Subject: [PATCH 031/222] Add types for progress-stream 2.0 --- types/progress-stream/index.d.ts | 51 +++++++++++++ .../progress-stream/progress-stream-tests.ts | 71 +++++++++++++++++++ types/progress-stream/tsconfig.json | 16 +++++ types/progress-stream/tslint.json | 1 + 4 files changed, 139 insertions(+) create mode 100644 types/progress-stream/index.d.ts create mode 100644 types/progress-stream/progress-stream-tests.ts create mode 100644 types/progress-stream/tsconfig.json create mode 100644 types/progress-stream/tslint.json diff --git a/types/progress-stream/index.d.ts b/types/progress-stream/index.d.ts new file mode 100644 index 0000000000..0b20223b3e --- /dev/null +++ b/types/progress-stream/index.d.ts @@ -0,0 +1,51 @@ +// Type definitions for progress-stream 2.0 +// Project: https://github.com/freeall/progress-stream +// Definitions by: Mick Dekkers +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// + +import stream = require("stream"); +export = progress_stream; + +declare function progress_stream( + options: progress_stream.Options, + progressListener: progress_stream.ProgressListener, +): progress_stream.ProgressStream; + +declare function progress_stream( + optionsOrProgressListener?: + | progress_stream.Options + | progress_stream.ProgressListener, +): progress_stream.ProgressStream; + +declare namespace progress_stream { + interface Options { + time?: number; + speed?: number; + length?: number; + drain?: boolean; + transferred?: number; + } + + type ProgressListener = (progress: Progress) => void; + + type ProgressStream = stream.Transform & { + on(event: "progress", listener: ProgressListener): ProgressStream; + on(event: "length", listener: (length: number) => void): ProgressStream; + setLength(length: number): void; + progress(): Progress; + }; + + interface Progress { + percentage: number; + transferred: number; + length: number; + remaining: number; + eta: number; + runtime: number; + delta: number; + speed: number; + } +} diff --git a/types/progress-stream/progress-stream-tests.ts b/types/progress-stream/progress-stream-tests.ts new file mode 100644 index 0000000000..e10ab0f925 --- /dev/null +++ b/types/progress-stream/progress-stream-tests.ts @@ -0,0 +1,71 @@ +import progress = require("progress-stream"); +import stream = require("stream"); + +const options: progress.Options = { + time: 100, + speed: 100, + length: 100, + drain: true, + transferred: 0, +}; + +const progressListener = (progress: progress.Progress) => { + // $ExpectType number + progress.percentage; + // $ExpectType number + progress.transferred; + // $ExpectType number + progress.length; + // $ExpectType number + progress.remaining; + // $ExpectType number + progress.eta; + // $ExpectType number + progress.runtime; + // $ExpectType number + progress.delta; + // $ExpectType number + progress.speed; +}; + +// $ExpectType ProgressStream +const p = progress(); + +// $ExpectType ProgressStream +progress(options); + +// $ExpectType ProgressStream +progress(options, progressListener); + +// $ExpectType ProgressStream +progress(progressListener); + +// $ExpectType ProgressStream +p.on("progress", progressListener); + +// $ExpectType ProgressStream +p.on("length", (length: number) => {}); + +p.setLength(200); // $ExpectType void + +p.progress(); // $ExpectType Progress + +// Check if ProgressStream extends stream.Transform correctly + +// $ExpectType ProgressStream +p.on("close", () => {}); +// $ExpectType ProgressStream +p.on("data", (chunk: any) => {}); +// $ExpectType ProgressStream +p.on("end", () => {}); +// $ExpectType ProgressStream +p.on("error", (err: Error) => {}); +// $ExpectType ProgressStream +p.on("readable", () => {}); +// $ExpectType ProgressStream +p.pause(); + +const writable = new stream.Writable(); + +// $ExpectType Writable +p.pipe(writable); diff --git a/types/progress-stream/tsconfig.json b/types/progress-stream/tsconfig.json new file mode 100644 index 0000000000..0dfc8b25fc --- /dev/null +++ b/types/progress-stream/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "progress-stream-tests.ts"] +} diff --git a/types/progress-stream/tslint.json b/types/progress-stream/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/progress-stream/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 08ba15aab8a7847c7ad830f3fe50de7fb010d4d2 Mon Sep 17 00:00:00 2001 From: Ian Craig Date: Sun, 17 Feb 2019 17:12:46 -0800 Subject: [PATCH 032/222] is* and assert* checks accept null and undefined --- types/babel-types/babel-types-tests.ts | 6 + types/babel-types/index.d.ts | 928 ++++++++++++------------- types/babel-types/tsconfig.json | 2 +- 3 files changed, 471 insertions(+), 465 deletions(-) diff --git a/types/babel-types/babel-types-tests.ts b/types/babel-types/babel-types-tests.ts index 8ffb1b32de..921608924c 100644 --- a/types/babel-types/babel-types-tests.ts +++ b/types/babel-types/babel-types-tests.ts @@ -53,6 +53,12 @@ traverse(ast, { } }); +// Node type checks +t.isIdentifier(t.identifier("id")); +t.isIdentifier(exp); +t.isIdentifier(null); +t.isIdentifier(undefined); + // TypeScript Types // TODO: Test all variants of these functions' signatures diff --git a/types/babel-types/index.d.ts b/types/babel-types/index.d.ts index d37cdf0a76..d164fba1d5 100644 --- a/types/babel-types/index.d.ts +++ b/types/babel-types/index.d.ts @@ -1514,246 +1514,246 @@ export function TSUndefinedKeyword(): TSUndefinedKeyword; export function TSUnionType(types: TSType[]): TSUnionType; export function TSVoidKeyword(): TSVoidKeyword; -export function isArrayExpression(node: object, opts?: object): node is ArrayExpression; -export function isAssignmentExpression(node: object, opts?: object): node is AssignmentExpression; -export function isBinaryExpression(node: object, opts?: object): node is BinaryExpression; -export function isDirective(node: object, opts?: object): node is Directive; -export function isDirectiveLiteral(node: object, opts?: object): node is DirectiveLiteral; -export function isBlockStatement(node: object, opts?: object): node is BlockStatement; -export function isBreakStatement(node: object, opts?: object): node is BreakStatement; -export function isCallExpression(node: object, opts?: object): node is CallExpression; -export function isCatchClause(node: object, opts?: object): node is CatchClause; -export function isConditionalExpression(node: object, opts?: object): node is ConditionalExpression; -export function isContinueStatement(node: object, opts?: object): node is ContinueStatement; -export function isDebuggerStatement(node: object, opts?: object): node is DebuggerStatement; -export function isDoWhileStatement(node: object, opts?: object): node is DoWhileStatement; -export function isEmptyStatement(node: object, opts?: object): node is EmptyStatement; -export function isExpressionStatement(node: object, opts?: object): node is ExpressionStatement; -export function isFile(node: object, opts?: object): node is File; -export function isForInStatement(node: object, opts?: object): node is ForInStatement; -export function isForStatement(node: object, opts?: object): node is ForStatement; -export function isFunctionDeclaration(node: object, opts?: object): node is FunctionDeclaration; -export function isFunctionExpression(node: object, opts?: object): node is FunctionExpression; -export function isIdentifier(node: object, opts?: object): node is Identifier; -export function isIfStatement(node: object, opts?: object): node is IfStatement; -export function isLabeledStatement(node: object, opts?: object): node is LabeledStatement; -export function isStringLiteral(node: object, opts?: object): node is StringLiteral; -export function isNumericLiteral(node: object, opts?: object): node is NumericLiteral; -export function isNullLiteral(node: object, opts?: object): node is NullLiteral; -export function isBooleanLiteral(node: object, opts?: object): node is BooleanLiteral; -export function isRegExpLiteral(node: object, opts?: object): node is RegExpLiteral; -export function isLogicalExpression(node: object, opts?: object): node is LogicalExpression; -export function isMemberExpression(node: object, opts?: object): node is MemberExpression; -export function isNewExpression(node: object, opts?: object): node is NewExpression; -export function isProgram(node: object, opts?: object): node is Program; -export function isObjectExpression(node: object, opts?: object): node is ObjectExpression; -export function isObjectMethod(node: object, opts?: object): node is ObjectMethod; -export function isObjectProperty(node: object, opts?: object): node is ObjectProperty; -export function isRestElement(node: object, opts?: object): node is RestElement; -export function isReturnStatement(node: object, opts?: object): node is ReturnStatement; -export function isSequenceExpression(node: object, opts?: object): node is SequenceExpression; -export function isSwitchCase(node: object, opts?: object): node is SwitchCase; -export function isSwitchStatement(node: object, opts?: object): node is SwitchStatement; -export function isThisExpression(node: object, opts?: object): node is ThisExpression; -export function isThrowStatement(node: object, opts?: object): node is ThrowStatement; -export function isTryStatement(node: object, opts?: object): node is TryStatement; -export function isUnaryExpression(node: object, opts?: object): node is UnaryExpression; -export function isUpdateExpression(node: object, opts?: object): node is UpdateExpression; -export function isVariableDeclaration(node: object, opts?: object): node is VariableDeclaration; -export function isVariableDeclarator(node: object, opts?: object): node is VariableDeclarator; -export function isWhileStatement(node: object, opts?: object): node is WhileStatement; -export function isWithStatement(node: object, opts?: object): node is WithStatement; -export function isAssignmentPattern(node: object, opts?: object): node is AssignmentPattern; -export function isArrayPattern(node: object, opts?: object): node is ArrayPattern; -export function isArrowFunctionExpression(node: object, opts?: object): node is ArrowFunctionExpression; -export function isClassBody(node: object, opts?: object): node is ClassBody; -export function isClassDeclaration(node: object, opts?: object): node is ClassDeclaration; -export function isClassExpression(node: object, opts?: object): node is ClassExpression; -export function isExportAllDeclaration(node: object, opts?: object): node is ExportAllDeclaration; -export function isExportDefaultDeclaration(node: object, opts?: object): node is ExportDefaultDeclaration; -export function isExportNamedDeclaration(node: object, opts?: object): node is ExportNamedDeclaration; -export function isExportSpecifier(node: object, opts?: object): node is ExportSpecifier; -export function isForOfStatement(node: object, opts?: object): node is ForOfStatement; -export function isImportDeclaration(node: object, opts?: object): node is ImportDeclaration; -export function isImportDefaultSpecifier(node: object, opts?: object): node is ImportDefaultSpecifier; -export function isImportNamespaceSpecifier(node: object, opts?: object): node is ImportNamespaceSpecifier; -export function isImportSpecifier(node: object, opts?: object): node is ImportSpecifier; -export function isMetaProperty(node: object, opts?: object): node is MetaProperty; -export function isClassMethod(node: object, opts?: object): node is ClassMethod; -export function isObjectPattern(node: object, opts?: object): node is ObjectPattern; -export function isSpreadElement(node: object, opts?: object): node is SpreadElement; -export function isSuper(node: object, opts?: object): node is Super; -export function isTaggedTemplateExpression(node: object, opts?: object): node is TaggedTemplateExpression; -export function isTemplateElement(node: object, opts?: object): node is TemplateElement; -export function isTemplateLiteral(node: object, opts?: object): node is TemplateLiteral; -export function isYieldExpression(node: object, opts?: object): node is YieldExpression; -export function isAnyTypeAnnotation(node: object, opts?: object): node is AnyTypeAnnotation; -export function isArrayTypeAnnotation(node: object, opts?: object): node is ArrayTypeAnnotation; -export function isBooleanTypeAnnotation(node: object, opts?: object): node is BooleanTypeAnnotation; -export function isBooleanLiteralTypeAnnotation(node: object, opts?: object): node is BooleanLiteralTypeAnnotation; -export function isNullLiteralTypeAnnotation(node: object, opts?: object): node is NullLiteralTypeAnnotation; -export function isClassImplements(node: object, opts?: object): node is ClassImplements; -export function isClassProperty(node: object, opts?: object): node is ClassProperty; -export function isDeclareClass(node: object, opts?: object): node is DeclareClass; -export function isDeclareFunction(node: object, opts?: object): node is DeclareFunction; -export function isDeclareInterface(node: object, opts?: object): node is DeclareInterface; -export function isDeclareModule(node: object, opts?: object): node is DeclareModule; -export function isDeclareTypeAlias(node: object, opts?: object): node is DeclareTypeAlias; -export function isDeclareVariable(node: object, opts?: object): node is DeclareVariable; -export function isExistentialTypeParam(node: object, opts?: object): node is ExistentialTypeParam; -export function isFunctionTypeAnnotation(node: object, opts?: object): node is FunctionTypeAnnotation; -export function isFunctionTypeParam(node: object, opts?: object): node is FunctionTypeParam; -export function isGenericTypeAnnotation(node: object, opts?: object): node is GenericTypeAnnotation; -export function isInterfaceExtends(node: object, opts?: object): node is InterfaceExtends; -export function isInterfaceDeclaration(node: object, opts?: object): node is InterfaceDeclaration; -export function isIntersectionTypeAnnotation(node: object, opts?: object): node is IntersectionTypeAnnotation; -export function isMixedTypeAnnotation(node: object, opts?: object): node is MixedTypeAnnotation; -export function isNullableTypeAnnotation(node: object, opts?: object): node is NullableTypeAnnotation; -export function isNumericLiteralTypeAnnotation(node: object, opts?: object): node is NumericLiteralTypeAnnotation; -export function isNumberTypeAnnotation(node: object, opts?: object): node is NumberTypeAnnotation; -export function isStringLiteralTypeAnnotation(node: object, opts?: object): node is StringLiteralTypeAnnotation; -export function isStringTypeAnnotation(node: object, opts?: object): node is StringTypeAnnotation; -export function isThisTypeAnnotation(node: object, opts?: object): node is ThisTypeAnnotation; -export function isTupleTypeAnnotation(node: object, opts?: object): node is TupleTypeAnnotation; -export function isTypeofTypeAnnotation(node: object, opts?: object): node is TypeofTypeAnnotation; -export function isTypeAlias(node: object, opts?: object): node is TypeAlias; -export function isTypeAnnotation(node: object, opts?: object): node is TypeAnnotation; -export function isTypeCastExpression(node: object, opts?: object): node is TypeCastExpression; -export function isTypeParameter(node: object, opts?: object): node is TypeParameter; -export function isTypeParameterDeclaration(node: object, opts?: object): node is TypeParameterDeclaration; -export function isTypeParameterInstantiation(node: object, opts?: object): node is TypeParameterInstantiation; -export function isObjectTypeAnnotation(node: object, opts?: object): node is ObjectTypeAnnotation; -export function isObjectTypeCallProperty(node: object, opts?: object): node is ObjectTypeCallProperty; -export function isObjectTypeIndexer(node: object, opts?: object): node is ObjectTypeIndexer; -export function isObjectTypeProperty(node: object, opts?: object): node is ObjectTypeProperty; -export function isQualifiedTypeIdentifier(node: object, opts?: object): node is QualifiedTypeIdentifier; -export function isUnionTypeAnnotation(node: object, opts?: object): node is UnionTypeAnnotation; -export function isVoidTypeAnnotation(node: object, opts?: object): node is VoidTypeAnnotation; -export function isJSXAttribute(node: object, opts?: object): node is JSXAttribute; -export function isJSXClosingElement(node: object, opts?: object): node is JSXClosingElement; -export function isJSXElement(node: object, opts?: object): node is JSXElement; -export function isJSXEmptyExpression(node: object, opts?: object): node is JSXEmptyExpression; -export function isJSXExpressionContainer(node: object, opts?: object): node is JSXExpressionContainer; -export function isJSXIdentifier(node: object, opts?: object): node is JSXIdentifier; -export function isJSXMemberExpression(node: object, opts?: object): node is JSXMemberExpression; -export function isJSXNamespacedName(node: object, opts?: object): node is JSXNamespacedName; -export function isJSXOpeningElement(node: object, opts?: object): node is JSXOpeningElement; -export function isJSXSpreadAttribute(node: object, opts?: object): node is JSXSpreadAttribute; -export function isJSXText(node: object, opts?: object): node is JSXText; -export function isNoop(node: object, opts?: object): node is Noop; -export function isParenthesizedExpression(node: object, opts?: object): node is ParenthesizedExpression; -export function isAwaitExpression(node: object, opts?: object): node is AwaitExpression; -export function isBindExpression(node: object, opts?: object): node is BindExpression; -export function isDecorator(node: object, opts?: object): node is Decorator; -export function isDoExpression(node: object, opts?: object): node is DoExpression; -export function isExportDefaultSpecifier(node: object, opts?: object): node is ExportDefaultSpecifier; -export function isExportNamespaceSpecifier(node: object, opts?: object): node is ExportNamespaceSpecifier; -export function isRestProperty(node: object, opts?: object): node is RestProperty; -export function isSpreadProperty(node: object, opts?: object): node is SpreadProperty; -export function isExpression(node: object, opts?: object): node is Expression; -export function isBinary(node: object, opts?: object): node is Binary; -export function isScopable(node: object, opts?: object): node is Scopable; -export function isBlockParent(node: object, opts?: object): node is BlockParent; -export function isBlock(node: object, opts?: object): node is Block; -export function isStatement(node: object, opts?: object): node is Statement; -export function isTerminatorless(node: object, opts?: object): node is Terminatorless; -export function isCompletionStatement(node: object, opts?: object): node is CompletionStatement; -export function isConditional(node: object, opts?: object): node is Conditional; -export function isLoop(node: object, opts?: object): node is Loop; -export function isWhile(node: object, opts?: object): node is While; -export function isExpressionWrapper(node: object, opts?: object): node is ExpressionWrapper; -export function isFor(node: object, opts?: object): node is For; -export function isForXStatement(node: object, opts?: object): node is ForXStatement; +export function isArrayExpression(node: any, opts?: object): node is ArrayExpression; +export function isAssignmentExpression(node: any, opts?: object): node is AssignmentExpression; +export function isBinaryExpression(node: any, opts?: object): node is BinaryExpression; +export function isDirective(node: any, opts?: object): node is Directive; +export function isDirectiveLiteral(node: any, opts?: object): node is DirectiveLiteral; +export function isBlockStatement(node: any, opts?: object): node is BlockStatement; +export function isBreakStatement(node: any, opts?: object): node is BreakStatement; +export function isCallExpression(node: any, opts?: object): node is CallExpression; +export function isCatchClause(node: any, opts?: object): node is CatchClause; +export function isConditionalExpression(node: any, opts?: object): node is ConditionalExpression; +export function isContinueStatement(node: any, opts?: object): node is ContinueStatement; +export function isDebuggerStatement(node: any, opts?: object): node is DebuggerStatement; +export function isDoWhileStatement(node: any, opts?: object): node is DoWhileStatement; +export function isEmptyStatement(node: any, opts?: object): node is EmptyStatement; +export function isExpressionStatement(node: any, opts?: object): node is ExpressionStatement; +export function isFile(node: any, opts?: object): node is File; +export function isForInStatement(node: any, opts?: object): node is ForInStatement; +export function isForStatement(node: any, opts?: object): node is ForStatement; +export function isFunctionDeclaration(node: any, opts?: object): node is FunctionDeclaration; +export function isFunctionExpression(node: any, opts?: object): node is FunctionExpression; +export function isIdentifier(node: any, opts?: object): node is Identifier; +export function isIfStatement(node: any, opts?: object): node is IfStatement; +export function isLabeledStatement(node: any, opts?: object): node is LabeledStatement; +export function isStringLiteral(node: any, opts?: object): node is StringLiteral; +export function isNumericLiteral(node: any, opts?: object): node is NumericLiteral; +export function isNullLiteral(node: any, opts?: object): node is NullLiteral; +export function isBooleanLiteral(node: any, opts?: object): node is BooleanLiteral; +export function isRegExpLiteral(node: any, opts?: object): node is RegExpLiteral; +export function isLogicalExpression(node: any, opts?: object): node is LogicalExpression; +export function isMemberExpression(node: any, opts?: object): node is MemberExpression; +export function isNewExpression(node: any, opts?: object): node is NewExpression; +export function isProgram(node: any, opts?: object): node is Program; +export function isObjectExpression(node: any, opts?: object): node is ObjectExpression; +export function isObjectMethod(node: any, opts?: object): node is ObjectMethod; +export function isObjectProperty(node: any, opts?: object): node is ObjectProperty; +export function isRestElement(node: any, opts?: object): node is RestElement; +export function isReturnStatement(node: any, opts?: object): node is ReturnStatement; +export function isSequenceExpression(node: any, opts?: object): node is SequenceExpression; +export function isSwitchCase(node: any, opts?: object): node is SwitchCase; +export function isSwitchStatement(node: any, opts?: object): node is SwitchStatement; +export function isThisExpression(node: any, opts?: object): node is ThisExpression; +export function isThrowStatement(node: any, opts?: object): node is ThrowStatement; +export function isTryStatement(node: any, opts?: object): node is TryStatement; +export function isUnaryExpression(node: any, opts?: object): node is UnaryExpression; +export function isUpdateExpression(node: any, opts?: object): node is UpdateExpression; +export function isVariableDeclaration(node: any, opts?: object): node is VariableDeclaration; +export function isVariableDeclarator(node: any, opts?: object): node is VariableDeclarator; +export function isWhileStatement(node: any, opts?: object): node is WhileStatement; +export function isWithStatement(node: any, opts?: object): node is WithStatement; +export function isAssignmentPattern(node: any, opts?: object): node is AssignmentPattern; +export function isArrayPattern(node: any, opts?: object): node is ArrayPattern; +export function isArrowFunctionExpression(node: any, opts?: object): node is ArrowFunctionExpression; +export function isClassBody(node: any, opts?: object): node is ClassBody; +export function isClassDeclaration(node: any, opts?: object): node is ClassDeclaration; +export function isClassExpression(node: any, opts?: object): node is ClassExpression; +export function isExportAllDeclaration(node: any, opts?: object): node is ExportAllDeclaration; +export function isExportDefaultDeclaration(node: any, opts?: object): node is ExportDefaultDeclaration; +export function isExportNamedDeclaration(node: any, opts?: object): node is ExportNamedDeclaration; +export function isExportSpecifier(node: any, opts?: object): node is ExportSpecifier; +export function isForOfStatement(node: any, opts?: object): node is ForOfStatement; +export function isImportDeclaration(node: any, opts?: object): node is ImportDeclaration; +export function isImportDefaultSpecifier(node: any, opts?: object): node is ImportDefaultSpecifier; +export function isImportNamespaceSpecifier(node: any, opts?: object): node is ImportNamespaceSpecifier; +export function isImportSpecifier(node: any, opts?: object): node is ImportSpecifier; +export function isMetaProperty(node: any, opts?: object): node is MetaProperty; +export function isClassMethod(node: any, opts?: object): node is ClassMethod; +export function isObjectPattern(node: any, opts?: object): node is ObjectPattern; +export function isSpreadElement(node: any, opts?: object): node is SpreadElement; +export function isSuper(node: any, opts?: object): node is Super; +export function isTaggedTemplateExpression(node: any, opts?: object): node is TaggedTemplateExpression; +export function isTemplateElement(node: any, opts?: object): node is TemplateElement; +export function isTemplateLiteral(node: any, opts?: object): node is TemplateLiteral; +export function isYieldExpression(node: any, opts?: object): node is YieldExpression; +export function isAnyTypeAnnotation(node: any, opts?: object): node is AnyTypeAnnotation; +export function isArrayTypeAnnotation(node: any, opts?: object): node is ArrayTypeAnnotation; +export function isBooleanTypeAnnotation(node: any, opts?: object): node is BooleanTypeAnnotation; +export function isBooleanLiteralTypeAnnotation(node: any, opts?: object): node is BooleanLiteralTypeAnnotation; +export function isNullLiteralTypeAnnotation(node: any, opts?: object): node is NullLiteralTypeAnnotation; +export function isClassImplements(node: any, opts?: object): node is ClassImplements; +export function isClassProperty(node: any, opts?: object): node is ClassProperty; +export function isDeclareClass(node: any, opts?: object): node is DeclareClass; +export function isDeclareFunction(node: any, opts?: object): node is DeclareFunction; +export function isDeclareInterface(node: any, opts?: object): node is DeclareInterface; +export function isDeclareModule(node: any, opts?: object): node is DeclareModule; +export function isDeclareTypeAlias(node: any, opts?: object): node is DeclareTypeAlias; +export function isDeclareVariable(node: any, opts?: object): node is DeclareVariable; +export function isExistentialTypeParam(node: any, opts?: object): node is ExistentialTypeParam; +export function isFunctionTypeAnnotation(node: any, opts?: object): node is FunctionTypeAnnotation; +export function isFunctionTypeParam(node: any, opts?: object): node is FunctionTypeParam; +export function isGenericTypeAnnotation(node: any, opts?: object): node is GenericTypeAnnotation; +export function isInterfaceExtends(node: any, opts?: object): node is InterfaceExtends; +export function isInterfaceDeclaration(node: any, opts?: object): node is InterfaceDeclaration; +export function isIntersectionTypeAnnotation(node: any, opts?: object): node is IntersectionTypeAnnotation; +export function isMixedTypeAnnotation(node: any, opts?: object): node is MixedTypeAnnotation; +export function isNullableTypeAnnotation(node: any, opts?: object): node is NullableTypeAnnotation; +export function isNumericLiteralTypeAnnotation(node: any, opts?: object): node is NumericLiteralTypeAnnotation; +export function isNumberTypeAnnotation(node: any, opts?: object): node is NumberTypeAnnotation; +export function isStringLiteralTypeAnnotation(node: any, opts?: object): node is StringLiteralTypeAnnotation; +export function isStringTypeAnnotation(node: any, opts?: object): node is StringTypeAnnotation; +export function isThisTypeAnnotation(node: any, opts?: object): node is ThisTypeAnnotation; +export function isTupleTypeAnnotation(node: any, opts?: object): node is TupleTypeAnnotation; +export function isTypeofTypeAnnotation(node: any, opts?: object): node is TypeofTypeAnnotation; +export function isTypeAlias(node: any, opts?: object): node is TypeAlias; +export function isTypeAnnotation(node: any, opts?: object): node is TypeAnnotation; +export function isTypeCastExpression(node: any, opts?: object): node is TypeCastExpression; +export function isTypeParameter(node: any, opts?: object): node is TypeParameter; +export function isTypeParameterDeclaration(node: any, opts?: object): node is TypeParameterDeclaration; +export function isTypeParameterInstantiation(node: any, opts?: object): node is TypeParameterInstantiation; +export function isObjectTypeAnnotation(node: any, opts?: object): node is ObjectTypeAnnotation; +export function isObjectTypeCallProperty(node: any, opts?: object): node is ObjectTypeCallProperty; +export function isObjectTypeIndexer(node: any, opts?: object): node is ObjectTypeIndexer; +export function isObjectTypeProperty(node: any, opts?: object): node is ObjectTypeProperty; +export function isQualifiedTypeIdentifier(node: any, opts?: object): node is QualifiedTypeIdentifier; +export function isUnionTypeAnnotation(node: any, opts?: object): node is UnionTypeAnnotation; +export function isVoidTypeAnnotation(node: any, opts?: object): node is VoidTypeAnnotation; +export function isJSXAttribute(node: any, opts?: object): node is JSXAttribute; +export function isJSXClosingElement(node: any, opts?: object): node is JSXClosingElement; +export function isJSXElement(node: any, opts?: object): node is JSXElement; +export function isJSXEmptyExpression(node: any, opts?: object): node is JSXEmptyExpression; +export function isJSXExpressionContainer(node: any, opts?: object): node is JSXExpressionContainer; +export function isJSXIdentifier(node: any, opts?: object): node is JSXIdentifier; +export function isJSXMemberExpression(node: any, opts?: object): node is JSXMemberExpression; +export function isJSXNamespacedName(node: any, opts?: object): node is JSXNamespacedName; +export function isJSXOpeningElement(node: any, opts?: object): node is JSXOpeningElement; +export function isJSXSpreadAttribute(node: any, opts?: object): node is JSXSpreadAttribute; +export function isJSXText(node: any, opts?: object): node is JSXText; +export function isNoop(node: any, opts?: object): node is Noop; +export function isParenthesizedExpression(node: any, opts?: object): node is ParenthesizedExpression; +export function isAwaitExpression(node: any, opts?: object): node is AwaitExpression; +export function isBindExpression(node: any, opts?: object): node is BindExpression; +export function isDecorator(node: any, opts?: object): node is Decorator; +export function isDoExpression(node: any, opts?: object): node is DoExpression; +export function isExportDefaultSpecifier(node: any, opts?: object): node is ExportDefaultSpecifier; +export function isExportNamespaceSpecifier(node: any, opts?: object): node is ExportNamespaceSpecifier; +export function isRestProperty(node: any, opts?: object): node is RestProperty; +export function isSpreadProperty(node: any, opts?: object): node is SpreadProperty; +export function isExpression(node: any, opts?: object): node is Expression; +export function isBinary(node: any, opts?: object): node is Binary; +export function isScopable(node: any, opts?: object): node is Scopable; +export function isBlockParent(node: any, opts?: object): node is BlockParent; +export function isBlock(node: any, opts?: object): node is Block; +export function isStatement(node: any, opts?: object): node is Statement; +export function isTerminatorless(node: any, opts?: object): node is Terminatorless; +export function isCompletionStatement(node: any, opts?: object): node is CompletionStatement; +export function isConditional(node: any, opts?: object): node is Conditional; +export function isLoop(node: any, opts?: object): node is Loop; +export function isWhile(node: any, opts?: object): node is While; +export function isExpressionWrapper(node: any, opts?: object): node is ExpressionWrapper; +export function isFor(node: any, opts?: object): node is For; +export function isForXStatement(node: any, opts?: object): node is ForXStatement; // tslint:disable-next-line ban-types -export function isFunction(node: object, opts?: object): node is Function; -export function isFunctionParent(node: object, opts?: object): node is FunctionParent; -export function isPureish(node: object, opts?: object): node is Pureish; -export function isDeclaration(node: object, opts?: object): node is Declaration; -export function isLVal(node: object, opts?: object): node is LVal; -export function isLiteral(node: object, opts?: object): node is Literal; -export function isImmutable(node: object, opts?: object): node is Immutable; -export function isUserWhitespacable(node: object, opts?: object): node is UserWhitespacable; -export function isMethod(node: object, opts?: object): node is Method; -export function isObjectMember(node: object, opts?: object): node is ObjectMember; -export function isProperty(node: object, opts?: object): node is Property; -export function isUnaryLike(node: object, opts?: object): node is UnaryLike; -export function isPattern(node: object, opts?: object): node is Pattern; -export function isClass(node: object, opts?: object): node is Class; -export function isModuleDeclaration(node: object, opts?: object): node is ModuleDeclaration; -export function isExportDeclaration(node: object, opts?: object): node is ExportDeclaration; -export function isModuleSpecifier(node: object, opts?: object): node is ModuleSpecifier; -export function isFlow(node: object, opts?: object): node is Flow; -export function isFlowBaseAnnotation(node: object, opts?: object): node is FlowBaseAnnotation; -export function isFlowDeclaration(node: object, opts?: object): node is FlowDeclaration; -export function isJSX(node: object, opts?: object): node is JSX; -export function isNumberLiteral(node: object, opts?: object): node is NumericLiteral; -export function isRegexLiteral(node: object, opts?: object): node is RegExpLiteral; +export function isFunction(node: any, opts?: object): node is Function; +export function isFunctionParent(node: any, opts?: object): node is FunctionParent; +export function isPureish(node: any, opts?: object): node is Pureish; +export function isDeclaration(node: any, opts?: object): node is Declaration; +export function isLVal(node: any, opts?: object): node is LVal; +export function isLiteral(node: any, opts?: object): node is Literal; +export function isImmutable(node: any, opts?: object): node is Immutable; +export function isUserWhitespacable(node: any, opts?: object): node is UserWhitespacable; +export function isMethod(node: any, opts?: object): node is Method; +export function isObjectMember(node: any, opts?: object): node is ObjectMember; +export function isProperty(node: any, opts?: object): node is Property; +export function isUnaryLike(node: any, opts?: object): node is UnaryLike; +export function isPattern(node: any, opts?: object): node is Pattern; +export function isClass(node: any, opts?: object): node is Class; +export function isModuleDeclaration(node: any, opts?: object): node is ModuleDeclaration; +export function isExportDeclaration(node: any, opts?: object): node is ExportDeclaration; +export function isModuleSpecifier(node: any, opts?: object): node is ModuleSpecifier; +export function isFlow(node: any, opts?: object): node is Flow; +export function isFlowBaseAnnotation(node: any, opts?: object): node is FlowBaseAnnotation; +export function isFlowDeclaration(node: any, opts?: object): node is FlowDeclaration; +export function isJSX(node: any, opts?: object): node is JSX; +export function isNumberLiteral(node: any, opts?: object): node is NumericLiteral; +export function isRegexLiteral(node: any, opts?: object): node is RegExpLiteral; -export function isReferencedIdentifier(node: object, opts?: object): node is Identifier | JSXIdentifier; -export function isReferencedMemberExpression(node: object, opts?: object): node is MemberExpression; -export function isBindingIdentifier(node: object, opts?: object): node is Identifier; -export function isScope(node: object, opts?: object): node is Scopable; -export function isReferenced(node: object, opts?: object): boolean; -export function isBlockScoped(node: object, opts?: object): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration; -export function isVar(node: object, opts?: object): node is VariableDeclaration; -export function isUser(node: object, opts?: object): boolean; -export function isGenerated(node: object, opts?: object): boolean; -export function isPure(node: object, opts?: object): boolean; +export function isReferencedIdentifier(node: any, opts?: object): node is Identifier | JSXIdentifier; +export function isReferencedMemberExpression(node: any, opts?: object): node is MemberExpression; +export function isBindingIdentifier(node: any, opts?: object): node is Identifier; +export function isScope(node: any, opts?: object): node is Scopable; +export function isReferenced(node: any, opts?: object): boolean; +export function isBlockScoped(node: any, opts?: object): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration; +export function isVar(node: any, opts?: object): node is VariableDeclaration; +export function isUser(node: any, opts?: object): boolean; +export function isGenerated(node: any, opts?: object): boolean; +export function isPure(node: any, opts?: object): boolean; -export function isTSAnyKeyword(node: object, opts?: object): node is TSAnyKeyword; -export function isTSArrayType(node: object, opts?: object): node is TSArrayType; -export function isTSAsExpression(node: object, opts?: object): node is TSAsExpression; -export function isTSBooleanKeyword(node: object, opts?: object): node is TSBooleanKeyword; -export function isTSCallSignatureDeclaration(node: object, opts?: object): node is TSCallSignatureDeclaration; -export function isTSConstructSignatureDeclaration(node: object, opts?: object): node is TSTypeElement; -export function isTSConstructorType(node: object, opts?: object): node is TSConstructorType; -export function isTSDeclareFunction(node: object, opts?: object): node is TSDeclareFunction; -export function isTSDeclareMethod(node: object, opts?: object): node is TSDeclareMethod; -export function isTSEnumDeclaration(node: object, opts?: object): node is TSEnumDeclaration; -export function isTSEnumMember(node: object, opts?: object): node is TSEnumMember; -export function isTSExportAssignment(node: object, opts?: object): node is TSExportAssignment; -export function isTSExpressionWithTypeArguments(node: object, opts?: object): node is TSExpressionWithTypeArguments; -export function isTSExternalModuleReference(node: object, opts?: object): node is TSExternalModuleReference; -export function isTSFunctionType(node: object, opts?: object): node is TSFunctionType; -export function isTSImportEqualsDeclaration(node: object, opts?: object): node is TSImportEqualsDeclaration; -export function isTSIndexSignature(node: object, opts?: object): node is TSIndexSignature; -export function isTSIndexedAccessType(node: object, opts?: object): node is TSIndexedAccessType; -export function isTSInterfaceBody(node: object, opts?: object): node is TSInterfaceBody; -export function isTSInterfaceDeclaration(node: object, opts?: object): node is TSInterfaceDeclaration; -export function isTSIntersectionType(node: object, opts?: object): node is TSIntersectionType; -export function isTSLiteralType(node: object, opts?: object): node is TSLiteralType; -export function isTSMappedType(node: object, opts?: object): node is TSMappedType; -export function isTSMethodSignature(node: object, opts?: object): node is TSMethodSignature; -export function isTSModuleBlock(node: object, opts?: object): node is TSModuleBlock; -export function isTSModuleDeclaration(node: object, opts?: object): node is TSModuleDeclaration; -export function isTSNamespaceExportDeclaration(node: object, opts?: object): node is TSNamespaceExportDeclaration; -export function isTSNeverKeyword(node: object, opts?: object): node is TSNeverKeyword; -export function isTSNonNullExpression(node: object, opts?: object): node is TSNonNullExpression; -export function isTSNullKeyword(node: object, opts?: object): node is TSNullKeyword; -export function isTSNumberKeyword(node: object, opts?: object): node is TSNumberKeyword; -export function isTSObjectKeyword(node: object, opts?: object): node is TSObjectKeyword; -export function isTSParameterProperty(node: object, opts?: object): node is TSParameterProperty; -export function isTSParenthesizedType(node: object, opts?: object): node is TSParenthesizedType; -export function isTSPropertySignature(node: object, opts?: object): node is TSPropertySignature; -export function isTSQualifiedName(node: object, opts?: object): node is TSQualifiedName; -export function isTSStringKeyword(node: object, opts?: object): node is TSStringKeyword; -export function isTSSymbolKeyword(node: object, opts?: object): node is TSSymbolKeyword; -export function isTSThisType(node: object, opts?: object): node is TSThisType; -export function isTSTupleType(node: object, opts?: object): node is TSTupleType; -export function isTSTypeAliasDeclaration(node: object, opts?: object): node is TSTypeAliasDeclaration; -export function isTSTypeAnnotation(node: object, opts?: object): node is TSTypeAnnotation; -export function isTSTypeAssertion(node: object, opts?: object): node is TSTypeAssertion; -export function isTSTypeLiteral(node: object, opts?: object): node is TSTypeLiteral; -export function isTSTypeOperator(node: object, opts?: object): node is TSTypeOperator; -export function isTSTypeParameter(node: object, opts?: object): node is TSTypeParameter; -export function isTSTypeParameterDeclaration(node: object, opts?: object): node is TSTypeParameterDeclaration; -export function isTSTypeParameterInstantiation(node: object, opts?: object): node is TSTypeParameterInstantiation; -export function isTSTypePredicate(node: object, opts?: object): node is TSTypePredicate; -export function isTSTypeQuery(node: object, opts?: object): node is TSTypeQuery; -export function isTSTypeReference(node: object, opts?: object): node is TSTypeReference; -export function isTSUndefinedKeyword(node: object, opts?: object): node is TSUndefinedKeyword; -export function isTSUnionType(node: object, opts?: object): node is TSUnionType; -export function isTSVoidKeyword(node: object, opts?: object): node is TSVoidKeyword; +export function isTSAnyKeyword(node: any, opts?: object): node is TSAnyKeyword; +export function isTSArrayType(node: any, opts?: object): node is TSArrayType; +export function isTSAsExpression(node: any, opts?: object): node is TSAsExpression; +export function isTSBooleanKeyword(node: any, opts?: object): node is TSBooleanKeyword; +export function isTSCallSignatureDeclaration(node: any, opts?: object): node is TSCallSignatureDeclaration; +export function isTSConstructSignatureDeclaration(node: any, opts?: object): node is TSTypeElement; +export function isTSConstructorType(node: any, opts?: object): node is TSConstructorType; +export function isTSDeclareFunction(node: any, opts?: object): node is TSDeclareFunction; +export function isTSDeclareMethod(node: any, opts?: object): node is TSDeclareMethod; +export function isTSEnumDeclaration(node: any, opts?: object): node is TSEnumDeclaration; +export function isTSEnumMember(node: any, opts?: object): node is TSEnumMember; +export function isTSExportAssignment(node: any, opts?: object): node is TSExportAssignment; +export function isTSExpressionWithTypeArguments(node: any, opts?: object): node is TSExpressionWithTypeArguments; +export function isTSExternalModuleReference(node: any, opts?: object): node is TSExternalModuleReference; +export function isTSFunctionType(node: any, opts?: object): node is TSFunctionType; +export function isTSImportEqualsDeclaration(node: any, opts?: object): node is TSImportEqualsDeclaration; +export function isTSIndexSignature(node: any, opts?: object): node is TSIndexSignature; +export function isTSIndexedAccessType(node: any, opts?: object): node is TSIndexedAccessType; +export function isTSInterfaceBody(node: any, opts?: object): node is TSInterfaceBody; +export function isTSInterfaceDeclaration(node: any, opts?: object): node is TSInterfaceDeclaration; +export function isTSIntersectionType(node: any, opts?: object): node is TSIntersectionType; +export function isTSLiteralType(node: any, opts?: object): node is TSLiteralType; +export function isTSMappedType(node: any, opts?: object): node is TSMappedType; +export function isTSMethodSignature(node: any, opts?: object): node is TSMethodSignature; +export function isTSModuleBlock(node: any, opts?: object): node is TSModuleBlock; +export function isTSModuleDeclaration(node: any, opts?: object): node is TSModuleDeclaration; +export function isTSNamespaceExportDeclaration(node: any, opts?: object): node is TSNamespaceExportDeclaration; +export function isTSNeverKeyword(node: any, opts?: object): node is TSNeverKeyword; +export function isTSNonNullExpression(node: any, opts?: object): node is TSNonNullExpression; +export function isTSNullKeyword(node: any, opts?: object): node is TSNullKeyword; +export function isTSNumberKeyword(node: any, opts?: object): node is TSNumberKeyword; +export function isTSObjectKeyword(node: any, opts?: object): node is TSObjectKeyword; +export function isTSParameterProperty(node: any, opts?: object): node is TSParameterProperty; +export function isTSParenthesizedType(node: any, opts?: object): node is TSParenthesizedType; +export function isTSPropertySignature(node: any, opts?: object): node is TSPropertySignature; +export function isTSQualifiedName(node: any, opts?: object): node is TSQualifiedName; +export function isTSStringKeyword(node: any, opts?: object): node is TSStringKeyword; +export function isTSSymbolKeyword(node: any, opts?: object): node is TSSymbolKeyword; +export function isTSThisType(node: any, opts?: object): node is TSThisType; +export function isTSTupleType(node: any, opts?: object): node is TSTupleType; +export function isTSTypeAliasDeclaration(node: any, opts?: object): node is TSTypeAliasDeclaration; +export function isTSTypeAnnotation(node: any, opts?: object): node is TSTypeAnnotation; +export function isTSTypeAssertion(node: any, opts?: object): node is TSTypeAssertion; +export function isTSTypeLiteral(node: any, opts?: object): node is TSTypeLiteral; +export function isTSTypeOperator(node: any, opts?: object): node is TSTypeOperator; +export function isTSTypeParameter(node: any, opts?: object): node is TSTypeParameter; +export function isTSTypeParameterDeclaration(node: any, opts?: object): node is TSTypeParameterDeclaration; +export function isTSTypeParameterInstantiation(node: any, opts?: object): node is TSTypeParameterInstantiation; +export function isTSTypePredicate(node: any, opts?: object): node is TSTypePredicate; +export function isTSTypeQuery(node: any, opts?: object): node is TSTypeQuery; +export function isTSTypeReference(node: any, opts?: object): node is TSTypeReference; +export function isTSUndefinedKeyword(node: any, opts?: object): node is TSUndefinedKeyword; +export function isTSUnionType(node: any, opts?: object): node is TSUnionType; +export function isTSVoidKeyword(node: any, opts?: object): node is TSVoidKeyword; // React specific export interface ReactHelpers { @@ -1762,231 +1762,231 @@ export interface ReactHelpers { } export const react: ReactHelpers; -export function assertArrayExpression(node: object, opts?: object): void; -export function assertAssignmentExpression(node: object, opts?: object): void; -export function assertBinaryExpression(node: object, opts?: object): void; -export function assertDirective(node: object, opts?: object): void; -export function assertDirectiveLiteral(node: object, opts?: object): void; -export function assertBlockStatement(node: object, opts?: object): void; -export function assertBreakStatement(node: object, opts?: object): void; -export function assertCallExpression(node: object, opts?: object): void; -export function assertCatchClause(node: object, opts?: object): void; -export function assertConditionalExpression(node: object, opts?: object): void; -export function assertContinueStatement(node: object, opts?: object): void; -export function assertDebuggerStatement(node: object, opts?: object): void; -export function assertDoWhileStatement(node: object, opts?: object): void; -export function assertEmptyStatement(node: object, opts?: object): void; -export function assertExpressionStatement(node: object, opts?: object): void; -export function assertFile(node: object, opts?: object): void; -export function assertForInStatement(node: object, opts?: object): void; -export function assertForStatement(node: object, opts?: object): void; -export function assertFunctionDeclaration(node: object, opts?: object): void; -export function assertFunctionExpression(node: object, opts?: object): void; -export function assertIdentifier(node: object, opts?: object): void; -export function assertIfStatement(node: object, opts?: object): void; -export function assertLabeledStatement(node: object, opts?: object): void; -export function assertStringLiteral(node: object, opts?: object): void; -export function assertNumericLiteral(node: object, opts?: object): void; -export function assertNullLiteral(node: object, opts?: object): void; -export function assertBooleanLiteral(node: object, opts?: object): void; -export function assertRegExpLiteral(node: object, opts?: object): void; -export function assertLogicalExpression(node: object, opts?: object): void; -export function assertMemberExpression(node: object, opts?: object): void; -export function assertNewExpression(node: object, opts?: object): void; -export function assertProgram(node: object, opts?: object): void; -export function assertObjectExpression(node: object, opts?: object): void; -export function assertObjectMethod(node: object, opts?: object): void; -export function assertObjectProperty(node: object, opts?: object): void; -export function assertRestElement(node: object, opts?: object): void; -export function assertReturnStatement(node: object, opts?: object): void; -export function assertSequenceExpression(node: object, opts?: object): void; -export function assertSwitchCase(node: object, opts?: object): void; -export function assertSwitchStatement(node: object, opts?: object): void; -export function assertThisExpression(node: object, opts?: object): void; -export function assertThrowStatement(node: object, opts?: object): void; -export function assertTryStatement(node: object, opts?: object): void; -export function assertUnaryExpression(node: object, opts?: object): void; -export function assertUpdateExpression(node: object, opts?: object): void; -export function assertVariableDeclaration(node: object, opts?: object): void; -export function assertVariableDeclarator(node: object, opts?: object): void; -export function assertWhileStatement(node: object, opts?: object): void; -export function assertWithStatement(node: object, opts?: object): void; -export function assertAssignmentPattern(node: object, opts?: object): void; -export function assertArrayPattern(node: object, opts?: object): void; -export function assertArrowFunctionExpression(node: object, opts?: object): void; -export function assertClassBody(node: object, opts?: object): void; -export function assertClassDeclaration(node: object, opts?: object): void; -export function assertClassExpression(node: object, opts?: object): void; -export function assertExportAllDeclaration(node: object, opts?: object): void; -export function assertExportDefaultDeclaration(node: object, opts?: object): void; -export function assertExportNamedDeclaration(node: object, opts?: object): void; -export function assertExportSpecifier(node: object, opts?: object): void; -export function assertForOfStatement(node: object, opts?: object): void; -export function assertImportDeclaration(node: object, opts?: object): void; -export function assertImportDefaultSpecifier(node: object, opts?: object): void; -export function assertImportNamespaceSpecifier(node: object, opts?: object): void; -export function assertImportSpecifier(node: object, opts?: object): void; -export function assertMetaProperty(node: object, opts?: object): void; -export function assertClassMethod(node: object, opts?: object): void; -export function assertObjectPattern(node: object, opts?: object): void; -export function assertSpreadElement(node: object, opts?: object): void; -export function assertSuper(node: object, opts?: object): void; -export function assertTaggedTemplateExpression(node: object, opts?: object): void; -export function assertTemplateElement(node: object, opts?: object): void; -export function assertTemplateLiteral(node: object, opts?: object): void; -export function assertYieldExpression(node: object, opts?: object): void; -export function assertAnyTypeAnnotation(node: object, opts?: object): void; -export function assertArrayTypeAnnotation(node: object, opts?: object): void; -export function assertBooleanTypeAnnotation(node: object, opts?: object): void; -export function assertBooleanLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertNullLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertClassImplements(node: object, opts?: object): void; -export function assertClassProperty(node: object, opts?: object): void; -export function assertDeclareClass(node: object, opts?: object): void; -export function assertDeclareFunction(node: object, opts?: object): void; -export function assertDeclareInterface(node: object, opts?: object): void; -export function assertDeclareModule(node: object, opts?: object): void; -export function assertDeclareTypeAlias(node: object, opts?: object): void; -export function assertDeclareVariable(node: object, opts?: object): void; -export function assertExistentialTypeParam(node: object, opts?: object): void; -export function assertFunctionTypeAnnotation(node: object, opts?: object): void; -export function assertFunctionTypeParam(node: object, opts?: object): void; -export function assertGenericTypeAnnotation(node: object, opts?: object): void; -export function assertInterfaceExtends(node: object, opts?: object): void; -export function assertInterfaceDeclaration(node: object, opts?: object): void; -export function assertIntersectionTypeAnnotation(node: object, opts?: object): void; -export function assertMixedTypeAnnotation(node: object, opts?: object): void; -export function assertNullableTypeAnnotation(node: object, opts?: object): void; -export function assertNumericLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertNumberTypeAnnotation(node: object, opts?: object): void; -export function assertStringLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertStringTypeAnnotation(node: object, opts?: object): void; -export function assertThisTypeAnnotation(node: object, opts?: object): void; -export function assertTupleTypeAnnotation(node: object, opts?: object): void; -export function assertTypeofTypeAnnotation(node: object, opts?: object): void; -export function assertTypeAlias(node: object, opts?: object): void; -export function assertTypeAnnotation(node: object, opts?: object): void; -export function assertTypeCastExpression(node: object, opts?: object): void; -export function assertTypeParameter(node: object, opts?: object): void; -export function assertTypeParameterDeclaration(node: object, opts?: object): void; -export function assertTypeParameterInstantiation(node: object, opts?: object): void; -export function assertObjectTypeAnnotation(node: object, opts?: object): void; -export function assertObjectTypeCallProperty(node: object, opts?: object): void; -export function assertObjectTypeIndexer(node: object, opts?: object): void; -export function assertObjectTypeProperty(node: object, opts?: object): void; -export function assertQualifiedTypeIdentifier(node: object, opts?: object): void; -export function assertUnionTypeAnnotation(node: object, opts?: object): void; -export function assertVoidTypeAnnotation(node: object, opts?: object): void; -export function assertJSXAttribute(node: object, opts?: object): void; -export function assertJSXClosingElement(node: object, opts?: object): void; -export function assertJSXElement(node: object, opts?: object): void; -export function assertJSXEmptyExpression(node: object, opts?: object): void; -export function assertJSXExpressionContainer(node: object, opts?: object): void; -export function assertJSXIdentifier(node: object, opts?: object): void; -export function assertJSXMemberExpression(node: object, opts?: object): void; -export function assertJSXNamespacedName(node: object, opts?: object): void; -export function assertJSXOpeningElement(node: object, opts?: object): void; -export function assertJSXSpreadAttribute(node: object, opts?: object): void; -export function assertJSXText(node: object, opts?: object): void; -export function assertNoop(node: object, opts?: object): void; -export function assertParenthesizedExpression(node: object, opts?: object): void; -export function assertAwaitExpression(node: object, opts?: object): void; -export function assertBindExpression(node: object, opts?: object): void; -export function assertDecorator(node: object, opts?: object): void; -export function assertDoExpression(node: object, opts?: object): void; -export function assertExportDefaultSpecifier(node: object, opts?: object): void; -export function assertExportNamespaceSpecifier(node: object, opts?: object): void; -export function assertRestProperty(node: object, opts?: object): void; -export function assertSpreadProperty(node: object, opts?: object): void; -export function assertExpression(node: object, opts?: object): void; -export function assertBinary(node: object, opts?: object): void; -export function assertScopable(node: object, opts?: object): void; -export function assertBlockParent(node: object, opts?: object): void; -export function assertBlock(node: object, opts?: object): void; -export function assertStatement(node: object, opts?: object): void; -export function assertTerminatorless(node: object, opts?: object): void; -export function assertCompletionStatement(node: object, opts?: object): void; -export function assertConditional(node: object, opts?: object): void; -export function assertLoop(node: object, opts?: object): void; -export function assertWhile(node: object, opts?: object): void; -export function assertExpressionWrapper(node: object, opts?: object): void; -export function assertFor(node: object, opts?: object): void; -export function assertForXStatement(node: object, opts?: object): void; -export function assertFunction(node: object, opts?: object): void; -export function assertFunctionParent(node: object, opts?: object): void; -export function assertPureish(node: object, opts?: object): void; -export function assertDeclaration(node: object, opts?: object): void; -export function assertLVal(node: object, opts?: object): void; -export function assertLiteral(node: object, opts?: object): void; -export function assertImmutable(node: object, opts?: object): void; -export function assertUserWhitespacable(node: object, opts?: object): void; -export function assertMethod(node: object, opts?: object): void; -export function assertObjectMember(node: object, opts?: object): void; -export function assertProperty(node: object, opts?: object): void; -export function assertUnaryLike(node: object, opts?: object): void; -export function assertPattern(node: object, opts?: object): void; -export function assertClass(node: object, opts?: object): void; -export function assertModuleDeclaration(node: object, opts?: object): void; -export function assertExportDeclaration(node: object, opts?: object): void; -export function assertModuleSpecifier(node: object, opts?: object): void; -export function assertFlow(node: object, opts?: object): void; -export function assertFlowBaseAnnotation(node: object, opts?: object): void; -export function assertFlowDeclaration(node: object, opts?: object): void; -export function assertJSX(node: object, opts?: object): void; -export function assertNumberLiteral(node: object, opts?: object): void; -export function assertRegexLiteral(node: object, opts?: object): void; +export function assertArrayExpression(node: any, opts?: object): void; +export function assertAssignmentExpression(node: any, opts?: object): void; +export function assertBinaryExpression(node: any, opts?: object): void; +export function assertDirective(node: any, opts?: object): void; +export function assertDirectiveLiteral(node: any, opts?: object): void; +export function assertBlockStatement(node: any, opts?: object): void; +export function assertBreakStatement(node: any, opts?: object): void; +export function assertCallExpression(node: any, opts?: object): void; +export function assertCatchClause(node: any, opts?: object): void; +export function assertConditionalExpression(node: any, opts?: object): void; +export function assertContinueStatement(node: any, opts?: object): void; +export function assertDebuggerStatement(node: any, opts?: object): void; +export function assertDoWhileStatement(node: any, opts?: object): void; +export function assertEmptyStatement(node: any, opts?: object): void; +export function assertExpressionStatement(node: any, opts?: object): void; +export function assertFile(node: any, opts?: object): void; +export function assertForInStatement(node: any, opts?: object): void; +export function assertForStatement(node: any, opts?: object): void; +export function assertFunctionDeclaration(node: any, opts?: object): void; +export function assertFunctionExpression(node: any, opts?: object): void; +export function assertIdentifier(node: any, opts?: object): void; +export function assertIfStatement(node: any, opts?: object): void; +export function assertLabeledStatement(node: any, opts?: object): void; +export function assertStringLiteral(node: any, opts?: object): void; +export function assertNumericLiteral(node: any, opts?: object): void; +export function assertNullLiteral(node: any, opts?: object): void; +export function assertBooleanLiteral(node: any, opts?: object): void; +export function assertRegExpLiteral(node: any, opts?: object): void; +export function assertLogicalExpression(node: any, opts?: object): void; +export function assertMemberExpression(node: any, opts?: object): void; +export function assertNewExpression(node: any, opts?: object): void; +export function assertProgram(node: any, opts?: object): void; +export function assertObjectExpression(node: any, opts?: object): void; +export function assertObjectMethod(node: any, opts?: object): void; +export function assertObjectProperty(node: any, opts?: object): void; +export function assertRestElement(node: any, opts?: object): void; +export function assertReturnStatement(node: any, opts?: object): void; +export function assertSequenceExpression(node: any, opts?: object): void; +export function assertSwitchCase(node: any, opts?: object): void; +export function assertSwitchStatement(node: any, opts?: object): void; +export function assertThisExpression(node: any, opts?: object): void; +export function assertThrowStatement(node: any, opts?: object): void; +export function assertTryStatement(node: any, opts?: object): void; +export function assertUnaryExpression(node: any, opts?: object): void; +export function assertUpdateExpression(node: any, opts?: object): void; +export function assertVariableDeclaration(node: any, opts?: object): void; +export function assertVariableDeclarator(node: any, opts?: object): void; +export function assertWhileStatement(node: any, opts?: object): void; +export function assertWithStatement(node: any, opts?: object): void; +export function assertAssignmentPattern(node: any, opts?: object): void; +export function assertArrayPattern(node: any, opts?: object): void; +export function assertArrowFunctionExpression(node: any, opts?: object): void; +export function assertClassBody(node: any, opts?: object): void; +export function assertClassDeclaration(node: any, opts?: object): void; +export function assertClassExpression(node: any, opts?: object): void; +export function assertExportAllDeclaration(node: any, opts?: object): void; +export function assertExportDefaultDeclaration(node: any, opts?: object): void; +export function assertExportNamedDeclaration(node: any, opts?: object): void; +export function assertExportSpecifier(node: any, opts?: object): void; +export function assertForOfStatement(node: any, opts?: object): void; +export function assertImportDeclaration(node: any, opts?: object): void; +export function assertImportDefaultSpecifier(node: any, opts?: object): void; +export function assertImportNamespaceSpecifier(node: any, opts?: object): void; +export function assertImportSpecifier(node: any, opts?: object): void; +export function assertMetaProperty(node: any, opts?: object): void; +export function assertClassMethod(node: any, opts?: object): void; +export function assertObjectPattern(node: any, opts?: object): void; +export function assertSpreadElement(node: any, opts?: object): void; +export function assertSuper(node: any, opts?: object): void; +export function assertTaggedTemplateExpression(node: any, opts?: object): void; +export function assertTemplateElement(node: any, opts?: object): void; +export function assertTemplateLiteral(node: any, opts?: object): void; +export function assertYieldExpression(node: any, opts?: object): void; +export function assertAnyTypeAnnotation(node: any, opts?: object): void; +export function assertArrayTypeAnnotation(node: any, opts?: object): void; +export function assertBooleanTypeAnnotation(node: any, opts?: object): void; +export function assertBooleanLiteralTypeAnnotation(node: any, opts?: object): void; +export function assertNullLiteralTypeAnnotation(node: any, opts?: object): void; +export function assertClassImplements(node: any, opts?: object): void; +export function assertClassProperty(node: any, opts?: object): void; +export function assertDeclareClass(node: any, opts?: object): void; +export function assertDeclareFunction(node: any, opts?: object): void; +export function assertDeclareInterface(node: any, opts?: object): void; +export function assertDeclareModule(node: any, opts?: object): void; +export function assertDeclareTypeAlias(node: any, opts?: object): void; +export function assertDeclareVariable(node: any, opts?: object): void; +export function assertExistentialTypeParam(node: any, opts?: object): void; +export function assertFunctionTypeAnnotation(node: any, opts?: object): void; +export function assertFunctionTypeParam(node: any, opts?: object): void; +export function assertGenericTypeAnnotation(node: any, opts?: object): void; +export function assertInterfaceExtends(node: any, opts?: object): void; +export function assertInterfaceDeclaration(node: any, opts?: object): void; +export function assertIntersectionTypeAnnotation(node: any, opts?: object): void; +export function assertMixedTypeAnnotation(node: any, opts?: object): void; +export function assertNullableTypeAnnotation(node: any, opts?: object): void; +export function assertNumericLiteralTypeAnnotation(node: any, opts?: object): void; +export function assertNumberTypeAnnotation(node: any, opts?: object): void; +export function assertStringLiteralTypeAnnotation(node: any, opts?: object): void; +export function assertStringTypeAnnotation(node: any, opts?: object): void; +export function assertThisTypeAnnotation(node: any, opts?: object): void; +export function assertTupleTypeAnnotation(node: any, opts?: object): void; +export function assertTypeofTypeAnnotation(node: any, opts?: object): void; +export function assertTypeAlias(node: any, opts?: object): void; +export function assertTypeAnnotation(node: any, opts?: object): void; +export function assertTypeCastExpression(node: any, opts?: object): void; +export function assertTypeParameter(node: any, opts?: object): void; +export function assertTypeParameterDeclaration(node: any, opts?: object): void; +export function assertTypeParameterInstantiation(node: any, opts?: object): void; +export function assertObjectTypeAnnotation(node: any, opts?: object): void; +export function assertObjectTypeCallProperty(node: any, opts?: object): void; +export function assertObjectTypeIndexer(node: any, opts?: object): void; +export function assertObjectTypeProperty(node: any, opts?: object): void; +export function assertQualifiedTypeIdentifier(node: any, opts?: object): void; +export function assertUnionTypeAnnotation(node: any, opts?: object): void; +export function assertVoidTypeAnnotation(node: any, opts?: object): void; +export function assertJSXAttribute(node: any, opts?: object): void; +export function assertJSXClosingElement(node: any, opts?: object): void; +export function assertJSXElement(node: any, opts?: object): void; +export function assertJSXEmptyExpression(node: any, opts?: object): void; +export function assertJSXExpressionContainer(node: any, opts?: object): void; +export function assertJSXIdentifier(node: any, opts?: object): void; +export function assertJSXMemberExpression(node: any, opts?: object): void; +export function assertJSXNamespacedName(node: any, opts?: object): void; +export function assertJSXOpeningElement(node: any, opts?: object): void; +export function assertJSXSpreadAttribute(node: any, opts?: object): void; +export function assertJSXText(node: any, opts?: object): void; +export function assertNoop(node: any, opts?: object): void; +export function assertParenthesizedExpression(node: any, opts?: object): void; +export function assertAwaitExpression(node: any, opts?: object): void; +export function assertBindExpression(node: any, opts?: object): void; +export function assertDecorator(node: any, opts?: object): void; +export function assertDoExpression(node: any, opts?: object): void; +export function assertExportDefaultSpecifier(node: any, opts?: object): void; +export function assertExportNamespaceSpecifier(node: any, opts?: object): void; +export function assertRestProperty(node: any, opts?: object): void; +export function assertSpreadProperty(node: any, opts?: object): void; +export function assertExpression(node: any, opts?: object): void; +export function assertBinary(node: any, opts?: object): void; +export function assertScopable(node: any, opts?: object): void; +export function assertBlockParent(node: any, opts?: object): void; +export function assertBlock(node: any, opts?: object): void; +export function assertStatement(node: any, opts?: object): void; +export function assertTerminatorless(node: any, opts?: object): void; +export function assertCompletionStatement(node: any, opts?: object): void; +export function assertConditional(node: any, opts?: object): void; +export function assertLoop(node: any, opts?: object): void; +export function assertWhile(node: any, opts?: object): void; +export function assertExpressionWrapper(node: any, opts?: object): void; +export function assertFor(node: any, opts?: object): void; +export function assertForXStatement(node: any, opts?: object): void; +export function assertFunction(node: any, opts?: object): void; +export function assertFunctionParent(node: any, opts?: object): void; +export function assertPureish(node: any, opts?: object): void; +export function assertDeclaration(node: any, opts?: object): void; +export function assertLVal(node: any, opts?: object): void; +export function assertLiteral(node: any, opts?: object): void; +export function assertImmutable(node: any, opts?: object): void; +export function assertUserWhitespacable(node: any, opts?: object): void; +export function assertMethod(node: any, opts?: object): void; +export function assertObjectMember(node: any, opts?: object): void; +export function assertProperty(node: any, opts?: object): void; +export function assertUnaryLike(node: any, opts?: object): void; +export function assertPattern(node: any, opts?: object): void; +export function assertClass(node: any, opts?: object): void; +export function assertModuleDeclaration(node: any, opts?: object): void; +export function assertExportDeclaration(node: any, opts?: object): void; +export function assertModuleSpecifier(node: any, opts?: object): void; +export function assertFlow(node: any, opts?: object): void; +export function assertFlowBaseAnnotation(node: any, opts?: object): void; +export function assertFlowDeclaration(node: any, opts?: object): void; +export function assertJSX(node: any, opts?: object): void; +export function assertNumberLiteral(node: any, opts?: object): void; +export function assertRegexLiteral(node: any, opts?: object): void; -export function assertTSAnyKeyword(node: object, opts?: object): void; -export function assertTSArrayType(node: object, opts?: object): void; -export function assertTSAsExpression(node: object, opts?: object): void; -export function assertTSBooleanKeyword(node: object, opts?: object): void; -export function assertTSCallSignatureDeclaration(node: object, opts?: object): void; -export function assertTSConstructSignatureDeclaration(node: object, opts?: object): void; -export function assertTSConstructorType(node: object, opts?: object): void; -export function assertTSDeclareFunction(node: object, opts?: object): void; -export function assertTSDeclareMethod(node: object, opts?: object): void; -export function assertTSEnumDeclaration(node: object, opts?: object): void; -export function assertTSEnumMember(node: object, opts?: object): void; -export function assertTSExportAssignment(node: object, opts?: object): void; -export function assertTSExpressionWithTypeArguments(node: object, opts?: object): void; -export function assertTSExternalModuleReference(node: object, opts?: object): void; -export function assertTSFunctionType(node: object, opts?: object): void; -export function assertTSImportEqualsDeclaration(node: object, opts?: object): void; -export function assertTSIndexSignature(node: object, opts?: object): void; -export function assertTSIndexedAccessType(node: object, opts?: object): void; -export function assertTSInterfaceBody(node: object, opts?: object): void; -export function assertTSInterfaceDeclaration(node: object, opts?: object): void; -export function assertTSIntersectionType(node: object, opts?: object): void; -export function assertTSLiteralType(node: object, opts?: object): void; -export function assertTSMappedType(node: object, opts?: object): void; -export function assertTSMethodSignature(node: object, opts?: object): void; -export function assertTSModuleBlock(node: object, opts?: object): void; -export function assertTSModuleDeclaration(node: object, opts?: object): void; -export function assertTSNamespaceExportDeclaration(node: object, opts?: object): void; -export function assertTSNeverKeyword(node: object, opts?: object): void; -export function assertTSNonNullExpression(node: object, opts?: object): void; -export function assertTSNullKeyword(node: object, opts?: object): void; -export function assertTSNumberKeyword(node: object, opts?: object): void; -export function assertTSObjectKeyword(node: object, opts?: object): void; -export function assertTSParameterProperty(node: object, opts?: object): void; -export function assertTSParenthesizedType(node: object, opts?: object): void; -export function assertTSPropertySignature(node: object, opts?: object): void; -export function assertTSQualifiedName(node: object, opts?: object): void; -export function assertTSStringKeyword(node: object, opts?: object): void; -export function assertTSSymbolKeyword(node: object, opts?: object): void; -export function assertTSThisType(node: object, opts?: object): void; -export function assertTSTupleType(node: object, opts?: object): void; -export function assertTSTypeAliasDeclaration(node: object, opts?: object): void; -export function assertTSTypeAnnotation(node: object, opts?: object): void; -export function assertTSTypeAssertion(node: object, opts?: object): void; -export function assertTSTypeLiteral(node: object, opts?: object): void; -export function assertTSTypeOperator(node: object, opts?: object): void; -export function assertTSTypeParameter(node: object, opts?: object): void; -export function assertTSTypeParameterDeclaration(node: object, opts?: object): void; -export function assertTSTypeParameterInstantiation(node: object, opts?: object): void; -export function assertTSTypePredicate(node: object, opts?: object): void; -export function assertTSTypeQuery(node: object, opts?: object): void; -export function assertTSTypeReference(node: object, opts?: object): void; -export function assertTSUndefinedKeyword(node: object, opts?: object): void; -export function assertTSUnionType(node: object, opts?: object): void; -export function assertTSVoidKeyword(node: object, opts?: object): void; +export function assertTSAnyKeyword(node: any, opts?: object): void; +export function assertTSArrayType(node: any, opts?: object): void; +export function assertTSAsExpression(node: any, opts?: object): void; +export function assertTSBooleanKeyword(node: any, opts?: object): void; +export function assertTSCallSignatureDeclaration(node: any, opts?: object): void; +export function assertTSConstructSignatureDeclaration(node: any, opts?: object): void; +export function assertTSConstructorType(node: any, opts?: object): void; +export function assertTSDeclareFunction(node: any, opts?: object): void; +export function assertTSDeclareMethod(node: any, opts?: object): void; +export function assertTSEnumDeclaration(node: any, opts?: object): void; +export function assertTSEnumMember(node: any, opts?: object): void; +export function assertTSExportAssignment(node: any, opts?: object): void; +export function assertTSExpressionWithTypeArguments(node: any, opts?: object): void; +export function assertTSExternalModuleReference(node: any, opts?: object): void; +export function assertTSFunctionType(node: any, opts?: object): void; +export function assertTSImportEqualsDeclaration(node: any, opts?: object): void; +export function assertTSIndexSignature(node: any, opts?: object): void; +export function assertTSIndexedAccessType(node: any, opts?: object): void; +export function assertTSInterfaceBody(node: any, opts?: object): void; +export function assertTSInterfaceDeclaration(node: any, opts?: object): void; +export function assertTSIntersectionType(node: any, opts?: object): void; +export function assertTSLiteralType(node: any, opts?: object): void; +export function assertTSMappedType(node: any, opts?: object): void; +export function assertTSMethodSignature(node: any, opts?: object): void; +export function assertTSModuleBlock(node: any, opts?: object): void; +export function assertTSModuleDeclaration(node: any, opts?: object): void; +export function assertTSNamespaceExportDeclaration(node: any, opts?: object): void; +export function assertTSNeverKeyword(node: any, opts?: object): void; +export function assertTSNonNullExpression(node: any, opts?: object): void; +export function assertTSNullKeyword(node: any, opts?: object): void; +export function assertTSNumberKeyword(node: any, opts?: object): void; +export function assertTSObjectKeyword(node: any, opts?: object): void; +export function assertTSParameterProperty(node: any, opts?: object): void; +export function assertTSParenthesizedType(node: any, opts?: object): void; +export function assertTSPropertySignature(node: any, opts?: object): void; +export function assertTSQualifiedName(node: any, opts?: object): void; +export function assertTSStringKeyword(node: any, opts?: object): void; +export function assertTSSymbolKeyword(node: any, opts?: object): void; +export function assertTSThisType(node: any, opts?: object): void; +export function assertTSTupleType(node: any, opts?: object): void; +export function assertTSTypeAliasDeclaration(node: any, opts?: object): void; +export function assertTSTypeAnnotation(node: any, opts?: object): void; +export function assertTSTypeAssertion(node: any, opts?: object): void; +export function assertTSTypeLiteral(node: any, opts?: object): void; +export function assertTSTypeOperator(node: any, opts?: object): void; +export function assertTSTypeParameter(node: any, opts?: object): void; +export function assertTSTypeParameterDeclaration(node: any, opts?: object): void; +export function assertTSTypeParameterInstantiation(node: any, opts?: object): void; +export function assertTSTypePredicate(node: any, opts?: object): void; +export function assertTSTypeQuery(node: any, opts?: object): void; +export function assertTSTypeReference(node: any, opts?: object): void; +export function assertTSUndefinedKeyword(node: any, opts?: object): void; +export function assertTSUnionType(node: any, opts?: object): void; +export function assertTSVoidKeyword(node: any, opts?: object): void; diff --git a/types/babel-types/tsconfig.json b/types/babel-types/tsconfig.json index 92d7d6442e..f4a6179f99 100644 --- a/types/babel-types/tsconfig.json +++ b/types/babel-types/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From 2555a5aa51bece8d823cc362439263a61af65d45 Mon Sep 17 00:00:00 2001 From: Dalius Dobravolskas Date: Mon, 18 Feb 2019 11:09:23 +0200 Subject: [PATCH 033/222] redux 4.x support. --- types/reduce-reducers/index.d.ts | 3 ++- types/reduce-reducers/package.json | 2 +- .../reduce-reducers/reduce-reducers-tests.ts | 20 +++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/types/reduce-reducers/index.d.ts b/types/reduce-reducers/index.d.ts index 9f787df032..89f98aa2b3 100644 --- a/types/reduce-reducers/index.d.ts +++ b/types/reduce-reducers/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for reduce-reducers 0.2 +// Type definitions for reduce-reducers 0.3 // Project: https://github.com/redux-utilities/reduce-reducers // Definitions by: Huy Nguyen // Dalius Dobravolskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import { Reducer } from 'redux'; export default function reduceReducer(r0: Reducer, s: S | null): Reducer; diff --git a/types/reduce-reducers/package.json b/types/reduce-reducers/package.json index 6d68bf2f9b..7f5b19d45b 100644 --- a/types/reduce-reducers/package.json +++ b/types/reduce-reducers/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "redux": "^3.6.0" + "redux": "^4.0.0" } } diff --git a/types/reduce-reducers/reduce-reducers-tests.ts b/types/reduce-reducers/reduce-reducers-tests.ts index f4fdd8fff3..6d14449814 100644 --- a/types/reduce-reducers/reduce-reducers-tests.ts +++ b/types/reduce-reducers/reduce-reducers-tests.ts @@ -8,8 +8,8 @@ interface TestStore { a: number; b: string; } -const firstReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const secondReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a; +const firstReducer: Reducer = (store, action) => ({a: 0, b: ''}); +const secondReducer: Reducer = (store, action) => ({a: 0, b: ''}); const finalReducer: (state: TestStore, action: Action) => TestStore = reduceReducers(firstReducer, secondReducer); const finalReducerWithState: (state: TestStore, action: Action) => TestStore = reduceReducers(firstReducer, secondReducer, null); @@ -23,14 +23,14 @@ const finalReducerWithInitialState: (state: TestStore, action: Action) => TestSt secondReducer, initialState); -const reducer02: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer03: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer04: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer05: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer06: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer07: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer08: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer09: (state: TestStore, action: Action) => TestStore = (a, b) => a; +const reducer02: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer03: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer04: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer05: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer06: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer07: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer08: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer09: Reducer = (store, action) => ({a: 0, b: ''}); const finalReducerWithInitialState02: (state: TestStore, action: Action) => TestStore = reduceReducers( firstReducer, From bfaa66209a8e6813bb8665f0df2f6ab77872a0b9 Mon Sep 17 00:00:00 2001 From: ltlombardi Date: Mon, 18 Feb 2019 10:00:45 -0300 Subject: [PATCH 034/222] more typings --- types/knockout/index.d.ts | 87 ++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 20 deletions(-) diff --git a/types/knockout/index.d.ts b/types/knockout/index.d.ts index bf571c621e..12320d5d16 100644 --- a/types/knockout/index.d.ts +++ b/types/knockout/index.d.ts @@ -30,6 +30,12 @@ interface KnockoutComputedFunctions { } interface KnockoutObservableFunctions { + /** + * Used by knockout to decide if value of observable has changed and should notify subscribers. Returns true if instances are primitives, and false if are objects. + * If your observable holds an object, this can be overwritten to return equality based on your needs. + * @param a previous value. + * @param b next value. + */ equalityComparer(a: T, b: T): boolean; } @@ -217,7 +223,13 @@ interface KnockoutComputedStatic { } interface KnockoutReadonlyComputed extends KnockoutReadonlyObservable { + /** + * Returns whether the computed observable may be updated in the future. A computed observable is inactive if it has no dependencies. + */ isActive(): boolean; + /** + * Returns the current number of dependencies of the computed observable. + */ getDependenciesCount(): number; } @@ -230,14 +242,6 @@ interface KnockoutComputed extends KnockoutReadonlyComputed, KnockoutObser * computed observable that has dependencies on observables that won’t be cleaned. */ dispose(): void; - /** - * Returns whether the computed observable may be updated in the future. A computed observable is inactive if it has no dependencies. - */ - isActive(): boolean; - /** - * Returns the current number of dependencies of the computed observable. - */ - getDependenciesCount(): number; /** * Customizes observables basic functionality. * @param requestedExtenders Name of the extender feature and it's value, e.g. { notify: 'always' }, { rateLimit: 50 } @@ -260,19 +264,19 @@ interface KnockoutReadonlyObservableArray extends KnockoutReadonlyObservable< subscribe(callback: (newValue: KnockoutArrayChange[]) => void, target: any, event: "arrayChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target: any, event: "beforeChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target?: any, event?: "change"): KnockoutSubscription; - subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + subscribe(callback: (newValue: U) => void, target: any, event: string): KnockoutSubscription; } /* - NOTE: In theory this should extend both Observable and ReadonlyObservableArray, + NOTE: In theory this should extend both KnockoutObservable and KnockoutReadonlyObservableArray, but can't since they both provide conflicting typings of .subscribe. - So it extends Observable and duplicates the subscribe definitions, which should be kept in sync + So it extends KnockoutObservable and duplicates the subscribe definitions, which should be kept in sync */ interface KnockoutObservableArray extends KnockoutObservable, KnockoutObservableArrayFunctions { subscribe(callback: (newValue: KnockoutArrayChange[]) => void, target: any, event: "arrayChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target: any, event: "beforeChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target?: any, event?: "change"): KnockoutSubscription; - subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + subscribe(callback: (newValue: U) => void, target: any, event: string): KnockoutSubscription; extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray; } @@ -292,7 +296,6 @@ interface KnockoutObservableStatic { interface KnockoutReadonlyObservable extends KnockoutSubscribable, KnockoutObservableFunctions { (): T; - /** * Returns the current value of the computed observable without creating a dependency. */ @@ -305,6 +308,10 @@ interface KnockoutObservable extends KnockoutReadonlyObservable { (value: T): void; // Since .extend does arbitrary thing to an observable, it's not safe to do on a readonly observable + /** + * Customizes observables basic functionality. + * @param requestedExtenders Name of the extender feature and it's value, e.g. { notify: 'always' }, { rateLimit: 50 } + */ extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable; } @@ -358,8 +365,19 @@ interface KnockoutBindingContext { $component: any; $componentTemplateNodes: Node[]; - extend(properties: any): any; - createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; + /** + * Clones the current Binding Context, adding extra properties to it. + * @param properties object with properties to be added in the binding context. + */ + extend(properties: { [key: string]: any; } | (() => { [key: string]: any; })): KnockoutBindingContext; + /** + * This returns a new binding context whose viewmodel is the first parameter and whose $parentContext is the current bindingContext. + * @param dataItemOrAccessor The binding context of the children. + * @param dataItemAlias An alias for the data item in descendant contexts. + * @param extendCallback Function to be called. + * @param options Further options. + */ + createChildContext(dataItemOrAccessor: any, dataItemAlias?: string, extendCallback?: Function, options?: { "exportDependencies": boolean }): any; } interface KnockoutAllBindingsAccessor { @@ -416,7 +434,7 @@ interface KnockoutBindingHandlers { } interface KnockoutMemoization { - memoize(callback: () => string): string; + memoize(callback: Function): string; unmemoize(memoId: string, callbackParams: any[]): boolean; unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: any[]): boolean; parseMemoText(memoText: string): string; @@ -665,10 +683,22 @@ interface KnockoutStatic { observableArray: KnockoutObservableArrayStatic; - contextFor(node: any): any; + /** + * Evaluates if instance is a KnockoutSubscribable. + * @param instance Instance to be evaluated. + */ isSubscribable(instance: any): instance is KnockoutSubscribable; - toJSON(viewModel: any, replacer?: Function, space?: any): string; - + /** + * Clones object substituting each observable for it's underlying value. Uses browser JSON.stringify internally to stringify the result. + * @param viewModel Object with observables to be converted. + * @param replacer A Function or array of names that alters the behavior of the stringification process. + * @param space Used to insert white space into the output JSON string for readability purposes. + */ + toJSON(viewModel: any, replacer?: Function | [string | number], space?: string | number): string; + /** + * Clones object substituting for each observable the current value of that observable. + * @param viewModel Object with observables to be converted. + */ toJS(viewModel: any): any; /** * Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables. @@ -701,8 +731,25 @@ interface KnockoutStatic { */ isComputed(instance: KnockoutObservable | T): instance is KnockoutComputed; - dataFor(node: any): any; + /** + * Returns the data that was available for binding against the element. + * @param node Html node that contains the binding context. + */ + dataFor(node: Node): any; + /** + * Returns the entire binding context that was available to the DOM element. + * @param node Html node that contains the binding context. + */ + contextFor(node: Node): any; + /** + * Removes a node from the DOM. + * @param node Node to be removed. + */ removeNode(node: Node): void; + /** + * Used internally by Knockout to clean up data/computeds that it created related to the element. It does not remove any event handlers added by bindings. + * @param node Node to be cleaned. + */ cleanNode(node: Node): Node; renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; From 1c3c4209430c3adb5c98268df14d95626e8fef53 Mon Sep 17 00:00:00 2001 From: ltlombardi Date: Mon, 18 Feb 2019 10:26:07 -0300 Subject: [PATCH 035/222] really small fix --- types/knockout/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/knockout/index.d.ts b/types/knockout/index.d.ts index 12320d5d16..39eb527c2e 100644 --- a/types/knockout/index.d.ts +++ b/types/knockout/index.d.ts @@ -1023,7 +1023,7 @@ interface KnockoutComponents { /** * Registers a component, in the default component loader, to be used by name in the component binding. - * @param componentName Component name. Will be used for your custom HTML tag name + * @param componentName Component name. Will be used for your custom HTML tag name. * @param config Component configuration. */ register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void; From 5448e1b03c2f135252d7f5b3f5f0c7fc0e1023a8 Mon Sep 17 00:00:00 2001 From: arichter83 Date: Mon, 18 Feb 2019 16:44:26 +0100 Subject: [PATCH 036/222] [meteor-universe-i18n] add offChangeLocale https://github.com/vazco/meteor-universe-i18n#listener-on-language-change --- types/meteor-universe-i18n/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/meteor-universe-i18n/index.d.ts b/types/meteor-universe-i18n/index.d.ts index a577b0185e..1596ceef81 100644 --- a/types/meteor-universe-i18n/index.d.ts +++ b/types/meteor-universe-i18n/index.d.ts @@ -65,6 +65,7 @@ declare module "meteor/universe:i18n" { // events function onChangeLocale(callback: (locale: string) => void): void; + function offChangeLocale(callback: (locale: string) => void): void; } interface ReactComponentProps { From aa79821823725e994a19b636a25736cf6fd1c8a1 Mon Sep 17 00:00:00 2001 From: Ian Craig Date: Mon, 18 Feb 2019 12:35:11 -0800 Subject: [PATCH 037/222] Switch to | null | undefined to match babel --- types/babel-types/index.d.ts | 928 +++++++++++++++++------------------ 1 file changed, 464 insertions(+), 464 deletions(-) diff --git a/types/babel-types/index.d.ts b/types/babel-types/index.d.ts index d164fba1d5..f0d781a7ed 100644 --- a/types/babel-types/index.d.ts +++ b/types/babel-types/index.d.ts @@ -1514,246 +1514,246 @@ export function TSUndefinedKeyword(): TSUndefinedKeyword; export function TSUnionType(types: TSType[]): TSUnionType; export function TSVoidKeyword(): TSVoidKeyword; -export function isArrayExpression(node: any, opts?: object): node is ArrayExpression; -export function isAssignmentExpression(node: any, opts?: object): node is AssignmentExpression; -export function isBinaryExpression(node: any, opts?: object): node is BinaryExpression; -export function isDirective(node: any, opts?: object): node is Directive; -export function isDirectiveLiteral(node: any, opts?: object): node is DirectiveLiteral; -export function isBlockStatement(node: any, opts?: object): node is BlockStatement; -export function isBreakStatement(node: any, opts?: object): node is BreakStatement; -export function isCallExpression(node: any, opts?: object): node is CallExpression; -export function isCatchClause(node: any, opts?: object): node is CatchClause; -export function isConditionalExpression(node: any, opts?: object): node is ConditionalExpression; -export function isContinueStatement(node: any, opts?: object): node is ContinueStatement; -export function isDebuggerStatement(node: any, opts?: object): node is DebuggerStatement; -export function isDoWhileStatement(node: any, opts?: object): node is DoWhileStatement; -export function isEmptyStatement(node: any, opts?: object): node is EmptyStatement; -export function isExpressionStatement(node: any, opts?: object): node is ExpressionStatement; -export function isFile(node: any, opts?: object): node is File; -export function isForInStatement(node: any, opts?: object): node is ForInStatement; -export function isForStatement(node: any, opts?: object): node is ForStatement; -export function isFunctionDeclaration(node: any, opts?: object): node is FunctionDeclaration; -export function isFunctionExpression(node: any, opts?: object): node is FunctionExpression; -export function isIdentifier(node: any, opts?: object): node is Identifier; -export function isIfStatement(node: any, opts?: object): node is IfStatement; -export function isLabeledStatement(node: any, opts?: object): node is LabeledStatement; -export function isStringLiteral(node: any, opts?: object): node is StringLiteral; -export function isNumericLiteral(node: any, opts?: object): node is NumericLiteral; -export function isNullLiteral(node: any, opts?: object): node is NullLiteral; -export function isBooleanLiteral(node: any, opts?: object): node is BooleanLiteral; -export function isRegExpLiteral(node: any, opts?: object): node is RegExpLiteral; -export function isLogicalExpression(node: any, opts?: object): node is LogicalExpression; -export function isMemberExpression(node: any, opts?: object): node is MemberExpression; -export function isNewExpression(node: any, opts?: object): node is NewExpression; -export function isProgram(node: any, opts?: object): node is Program; -export function isObjectExpression(node: any, opts?: object): node is ObjectExpression; -export function isObjectMethod(node: any, opts?: object): node is ObjectMethod; -export function isObjectProperty(node: any, opts?: object): node is ObjectProperty; -export function isRestElement(node: any, opts?: object): node is RestElement; -export function isReturnStatement(node: any, opts?: object): node is ReturnStatement; -export function isSequenceExpression(node: any, opts?: object): node is SequenceExpression; -export function isSwitchCase(node: any, opts?: object): node is SwitchCase; -export function isSwitchStatement(node: any, opts?: object): node is SwitchStatement; -export function isThisExpression(node: any, opts?: object): node is ThisExpression; -export function isThrowStatement(node: any, opts?: object): node is ThrowStatement; -export function isTryStatement(node: any, opts?: object): node is TryStatement; -export function isUnaryExpression(node: any, opts?: object): node is UnaryExpression; -export function isUpdateExpression(node: any, opts?: object): node is UpdateExpression; -export function isVariableDeclaration(node: any, opts?: object): node is VariableDeclaration; -export function isVariableDeclarator(node: any, opts?: object): node is VariableDeclarator; -export function isWhileStatement(node: any, opts?: object): node is WhileStatement; -export function isWithStatement(node: any, opts?: object): node is WithStatement; -export function isAssignmentPattern(node: any, opts?: object): node is AssignmentPattern; -export function isArrayPattern(node: any, opts?: object): node is ArrayPattern; -export function isArrowFunctionExpression(node: any, opts?: object): node is ArrowFunctionExpression; -export function isClassBody(node: any, opts?: object): node is ClassBody; -export function isClassDeclaration(node: any, opts?: object): node is ClassDeclaration; -export function isClassExpression(node: any, opts?: object): node is ClassExpression; -export function isExportAllDeclaration(node: any, opts?: object): node is ExportAllDeclaration; -export function isExportDefaultDeclaration(node: any, opts?: object): node is ExportDefaultDeclaration; -export function isExportNamedDeclaration(node: any, opts?: object): node is ExportNamedDeclaration; -export function isExportSpecifier(node: any, opts?: object): node is ExportSpecifier; -export function isForOfStatement(node: any, opts?: object): node is ForOfStatement; -export function isImportDeclaration(node: any, opts?: object): node is ImportDeclaration; -export function isImportDefaultSpecifier(node: any, opts?: object): node is ImportDefaultSpecifier; -export function isImportNamespaceSpecifier(node: any, opts?: object): node is ImportNamespaceSpecifier; -export function isImportSpecifier(node: any, opts?: object): node is ImportSpecifier; -export function isMetaProperty(node: any, opts?: object): node is MetaProperty; -export function isClassMethod(node: any, opts?: object): node is ClassMethod; -export function isObjectPattern(node: any, opts?: object): node is ObjectPattern; -export function isSpreadElement(node: any, opts?: object): node is SpreadElement; -export function isSuper(node: any, opts?: object): node is Super; -export function isTaggedTemplateExpression(node: any, opts?: object): node is TaggedTemplateExpression; -export function isTemplateElement(node: any, opts?: object): node is TemplateElement; -export function isTemplateLiteral(node: any, opts?: object): node is TemplateLiteral; -export function isYieldExpression(node: any, opts?: object): node is YieldExpression; -export function isAnyTypeAnnotation(node: any, opts?: object): node is AnyTypeAnnotation; -export function isArrayTypeAnnotation(node: any, opts?: object): node is ArrayTypeAnnotation; -export function isBooleanTypeAnnotation(node: any, opts?: object): node is BooleanTypeAnnotation; -export function isBooleanLiteralTypeAnnotation(node: any, opts?: object): node is BooleanLiteralTypeAnnotation; -export function isNullLiteralTypeAnnotation(node: any, opts?: object): node is NullLiteralTypeAnnotation; -export function isClassImplements(node: any, opts?: object): node is ClassImplements; -export function isClassProperty(node: any, opts?: object): node is ClassProperty; -export function isDeclareClass(node: any, opts?: object): node is DeclareClass; -export function isDeclareFunction(node: any, opts?: object): node is DeclareFunction; -export function isDeclareInterface(node: any, opts?: object): node is DeclareInterface; -export function isDeclareModule(node: any, opts?: object): node is DeclareModule; -export function isDeclareTypeAlias(node: any, opts?: object): node is DeclareTypeAlias; -export function isDeclareVariable(node: any, opts?: object): node is DeclareVariable; -export function isExistentialTypeParam(node: any, opts?: object): node is ExistentialTypeParam; -export function isFunctionTypeAnnotation(node: any, opts?: object): node is FunctionTypeAnnotation; -export function isFunctionTypeParam(node: any, opts?: object): node is FunctionTypeParam; -export function isGenericTypeAnnotation(node: any, opts?: object): node is GenericTypeAnnotation; -export function isInterfaceExtends(node: any, opts?: object): node is InterfaceExtends; -export function isInterfaceDeclaration(node: any, opts?: object): node is InterfaceDeclaration; -export function isIntersectionTypeAnnotation(node: any, opts?: object): node is IntersectionTypeAnnotation; -export function isMixedTypeAnnotation(node: any, opts?: object): node is MixedTypeAnnotation; -export function isNullableTypeAnnotation(node: any, opts?: object): node is NullableTypeAnnotation; -export function isNumericLiteralTypeAnnotation(node: any, opts?: object): node is NumericLiteralTypeAnnotation; -export function isNumberTypeAnnotation(node: any, opts?: object): node is NumberTypeAnnotation; -export function isStringLiteralTypeAnnotation(node: any, opts?: object): node is StringLiteralTypeAnnotation; -export function isStringTypeAnnotation(node: any, opts?: object): node is StringTypeAnnotation; -export function isThisTypeAnnotation(node: any, opts?: object): node is ThisTypeAnnotation; -export function isTupleTypeAnnotation(node: any, opts?: object): node is TupleTypeAnnotation; -export function isTypeofTypeAnnotation(node: any, opts?: object): node is TypeofTypeAnnotation; -export function isTypeAlias(node: any, opts?: object): node is TypeAlias; -export function isTypeAnnotation(node: any, opts?: object): node is TypeAnnotation; -export function isTypeCastExpression(node: any, opts?: object): node is TypeCastExpression; -export function isTypeParameter(node: any, opts?: object): node is TypeParameter; -export function isTypeParameterDeclaration(node: any, opts?: object): node is TypeParameterDeclaration; -export function isTypeParameterInstantiation(node: any, opts?: object): node is TypeParameterInstantiation; -export function isObjectTypeAnnotation(node: any, opts?: object): node is ObjectTypeAnnotation; -export function isObjectTypeCallProperty(node: any, opts?: object): node is ObjectTypeCallProperty; -export function isObjectTypeIndexer(node: any, opts?: object): node is ObjectTypeIndexer; -export function isObjectTypeProperty(node: any, opts?: object): node is ObjectTypeProperty; -export function isQualifiedTypeIdentifier(node: any, opts?: object): node is QualifiedTypeIdentifier; -export function isUnionTypeAnnotation(node: any, opts?: object): node is UnionTypeAnnotation; -export function isVoidTypeAnnotation(node: any, opts?: object): node is VoidTypeAnnotation; -export function isJSXAttribute(node: any, opts?: object): node is JSXAttribute; -export function isJSXClosingElement(node: any, opts?: object): node is JSXClosingElement; -export function isJSXElement(node: any, opts?: object): node is JSXElement; -export function isJSXEmptyExpression(node: any, opts?: object): node is JSXEmptyExpression; -export function isJSXExpressionContainer(node: any, opts?: object): node is JSXExpressionContainer; -export function isJSXIdentifier(node: any, opts?: object): node is JSXIdentifier; -export function isJSXMemberExpression(node: any, opts?: object): node is JSXMemberExpression; -export function isJSXNamespacedName(node: any, opts?: object): node is JSXNamespacedName; -export function isJSXOpeningElement(node: any, opts?: object): node is JSXOpeningElement; -export function isJSXSpreadAttribute(node: any, opts?: object): node is JSXSpreadAttribute; -export function isJSXText(node: any, opts?: object): node is JSXText; -export function isNoop(node: any, opts?: object): node is Noop; -export function isParenthesizedExpression(node: any, opts?: object): node is ParenthesizedExpression; -export function isAwaitExpression(node: any, opts?: object): node is AwaitExpression; -export function isBindExpression(node: any, opts?: object): node is BindExpression; -export function isDecorator(node: any, opts?: object): node is Decorator; -export function isDoExpression(node: any, opts?: object): node is DoExpression; -export function isExportDefaultSpecifier(node: any, opts?: object): node is ExportDefaultSpecifier; -export function isExportNamespaceSpecifier(node: any, opts?: object): node is ExportNamespaceSpecifier; -export function isRestProperty(node: any, opts?: object): node is RestProperty; -export function isSpreadProperty(node: any, opts?: object): node is SpreadProperty; -export function isExpression(node: any, opts?: object): node is Expression; -export function isBinary(node: any, opts?: object): node is Binary; -export function isScopable(node: any, opts?: object): node is Scopable; -export function isBlockParent(node: any, opts?: object): node is BlockParent; -export function isBlock(node: any, opts?: object): node is Block; -export function isStatement(node: any, opts?: object): node is Statement; -export function isTerminatorless(node: any, opts?: object): node is Terminatorless; -export function isCompletionStatement(node: any, opts?: object): node is CompletionStatement; -export function isConditional(node: any, opts?: object): node is Conditional; -export function isLoop(node: any, opts?: object): node is Loop; -export function isWhile(node: any, opts?: object): node is While; -export function isExpressionWrapper(node: any, opts?: object): node is ExpressionWrapper; -export function isFor(node: any, opts?: object): node is For; -export function isForXStatement(node: any, opts?: object): node is ForXStatement; +export function isArrayExpression(node: object | null | undefined, opts?: object): node is ArrayExpression; +export function isAssignmentExpression(node: object | null | undefined, opts?: object): node is AssignmentExpression; +export function isBinaryExpression(node: object | null | undefined, opts?: object): node is BinaryExpression; +export function isDirective(node: object | null | undefined, opts?: object): node is Directive; +export function isDirectiveLiteral(node: object | null | undefined, opts?: object): node is DirectiveLiteral; +export function isBlockStatement(node: object | null | undefined, opts?: object): node is BlockStatement; +export function isBreakStatement(node: object | null | undefined, opts?: object): node is BreakStatement; +export function isCallExpression(node: object | null | undefined, opts?: object): node is CallExpression; +export function isCatchClause(node: object | null | undefined, opts?: object): node is CatchClause; +export function isConditionalExpression(node: object | null | undefined, opts?: object): node is ConditionalExpression; +export function isContinueStatement(node: object | null | undefined, opts?: object): node is ContinueStatement; +export function isDebuggerStatement(node: object | null | undefined, opts?: object): node is DebuggerStatement; +export function isDoWhileStatement(node: object | null | undefined, opts?: object): node is DoWhileStatement; +export function isEmptyStatement(node: object | null | undefined, opts?: object): node is EmptyStatement; +export function isExpressionStatement(node: object | null | undefined, opts?: object): node is ExpressionStatement; +export function isFile(node: object | null | undefined, opts?: object): node is File; +export function isForInStatement(node: object | null | undefined, opts?: object): node is ForInStatement; +export function isForStatement(node: object | null | undefined, opts?: object): node is ForStatement; +export function isFunctionDeclaration(node: object | null | undefined, opts?: object): node is FunctionDeclaration; +export function isFunctionExpression(node: object | null | undefined, opts?: object): node is FunctionExpression; +export function isIdentifier(node: object | null | undefined, opts?: object): node is Identifier; +export function isIfStatement(node: object | null | undefined, opts?: object): node is IfStatement; +export function isLabeledStatement(node: object | null | undefined, opts?: object): node is LabeledStatement; +export function isStringLiteral(node: object | null | undefined, opts?: object): node is StringLiteral; +export function isNumericLiteral(node: object | null | undefined, opts?: object): node is NumericLiteral; +export function isNullLiteral(node: object | null | undefined, opts?: object): node is NullLiteral; +export function isBooleanLiteral(node: object | null | undefined, opts?: object): node is BooleanLiteral; +export function isRegExpLiteral(node: object | null | undefined, opts?: object): node is RegExpLiteral; +export function isLogicalExpression(node: object | null | undefined, opts?: object): node is LogicalExpression; +export function isMemberExpression(node: object | null | undefined, opts?: object): node is MemberExpression; +export function isNewExpression(node: object | null | undefined, opts?: object): node is NewExpression; +export function isProgram(node: object | null | undefined, opts?: object): node is Program; +export function isObjectExpression(node: object | null | undefined, opts?: object): node is ObjectExpression; +export function isObjectMethod(node: object | null | undefined, opts?: object): node is ObjectMethod; +export function isObjectProperty(node: object | null | undefined, opts?: object): node is ObjectProperty; +export function isRestElement(node: object | null | undefined, opts?: object): node is RestElement; +export function isReturnStatement(node: object | null | undefined, opts?: object): node is ReturnStatement; +export function isSequenceExpression(node: object | null | undefined, opts?: object): node is SequenceExpression; +export function isSwitchCase(node: object | null | undefined, opts?: object): node is SwitchCase; +export function isSwitchStatement(node: object | null | undefined, opts?: object): node is SwitchStatement; +export function isThisExpression(node: object | null | undefined, opts?: object): node is ThisExpression; +export function isThrowStatement(node: object | null | undefined, opts?: object): node is ThrowStatement; +export function isTryStatement(node: object | null | undefined, opts?: object): node is TryStatement; +export function isUnaryExpression(node: object | null | undefined, opts?: object): node is UnaryExpression; +export function isUpdateExpression(node: object | null | undefined, opts?: object): node is UpdateExpression; +export function isVariableDeclaration(node: object | null | undefined, opts?: object): node is VariableDeclaration; +export function isVariableDeclarator(node: object | null | undefined, opts?: object): node is VariableDeclarator; +export function isWhileStatement(node: object | null | undefined, opts?: object): node is WhileStatement; +export function isWithStatement(node: object | null | undefined, opts?: object): node is WithStatement; +export function isAssignmentPattern(node: object | null | undefined, opts?: object): node is AssignmentPattern; +export function isArrayPattern(node: object | null | undefined, opts?: object): node is ArrayPattern; +export function isArrowFunctionExpression(node: object | null | undefined, opts?: object): node is ArrowFunctionExpression; +export function isClassBody(node: object | null | undefined, opts?: object): node is ClassBody; +export function isClassDeclaration(node: object | null | undefined, opts?: object): node is ClassDeclaration; +export function isClassExpression(node: object | null | undefined, opts?: object): node is ClassExpression; +export function isExportAllDeclaration(node: object | null | undefined, opts?: object): node is ExportAllDeclaration; +export function isExportDefaultDeclaration(node: object | null | undefined, opts?: object): node is ExportDefaultDeclaration; +export function isExportNamedDeclaration(node: object | null | undefined, opts?: object): node is ExportNamedDeclaration; +export function isExportSpecifier(node: object | null | undefined, opts?: object): node is ExportSpecifier; +export function isForOfStatement(node: object | null | undefined, opts?: object): node is ForOfStatement; +export function isImportDeclaration(node: object | null | undefined, opts?: object): node is ImportDeclaration; +export function isImportDefaultSpecifier(node: object | null | undefined, opts?: object): node is ImportDefaultSpecifier; +export function isImportNamespaceSpecifier(node: object | null | undefined, opts?: object): node is ImportNamespaceSpecifier; +export function isImportSpecifier(node: object | null | undefined, opts?: object): node is ImportSpecifier; +export function isMetaProperty(node: object | null | undefined, opts?: object): node is MetaProperty; +export function isClassMethod(node: object | null | undefined, opts?: object): node is ClassMethod; +export function isObjectPattern(node: object | null | undefined, opts?: object): node is ObjectPattern; +export function isSpreadElement(node: object | null | undefined, opts?: object): node is SpreadElement; +export function isSuper(node: object | null | undefined, opts?: object): node is Super; +export function isTaggedTemplateExpression(node: object | null | undefined, opts?: object): node is TaggedTemplateExpression; +export function isTemplateElement(node: object | null | undefined, opts?: object): node is TemplateElement; +export function isTemplateLiteral(node: object | null | undefined, opts?: object): node is TemplateLiteral; +export function isYieldExpression(node: object | null | undefined, opts?: object): node is YieldExpression; +export function isAnyTypeAnnotation(node: object | null | undefined, opts?: object): node is AnyTypeAnnotation; +export function isArrayTypeAnnotation(node: object | null | undefined, opts?: object): node is ArrayTypeAnnotation; +export function isBooleanTypeAnnotation(node: object | null | undefined, opts?: object): node is BooleanTypeAnnotation; +export function isBooleanLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is BooleanLiteralTypeAnnotation; +export function isNullLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is NullLiteralTypeAnnotation; +export function isClassImplements(node: object | null | undefined, opts?: object): node is ClassImplements; +export function isClassProperty(node: object | null | undefined, opts?: object): node is ClassProperty; +export function isDeclareClass(node: object | null | undefined, opts?: object): node is DeclareClass; +export function isDeclareFunction(node: object | null | undefined, opts?: object): node is DeclareFunction; +export function isDeclareInterface(node: object | null | undefined, opts?: object): node is DeclareInterface; +export function isDeclareModule(node: object | null | undefined, opts?: object): node is DeclareModule; +export function isDeclareTypeAlias(node: object | null | undefined, opts?: object): node is DeclareTypeAlias; +export function isDeclareVariable(node: object | null | undefined, opts?: object): node is DeclareVariable; +export function isExistentialTypeParam(node: object | null | undefined, opts?: object): node is ExistentialTypeParam; +export function isFunctionTypeAnnotation(node: object | null | undefined, opts?: object): node is FunctionTypeAnnotation; +export function isFunctionTypeParam(node: object | null | undefined, opts?: object): node is FunctionTypeParam; +export function isGenericTypeAnnotation(node: object | null | undefined, opts?: object): node is GenericTypeAnnotation; +export function isInterfaceExtends(node: object | null | undefined, opts?: object): node is InterfaceExtends; +export function isInterfaceDeclaration(node: object | null | undefined, opts?: object): node is InterfaceDeclaration; +export function isIntersectionTypeAnnotation(node: object | null | undefined, opts?: object): node is IntersectionTypeAnnotation; +export function isMixedTypeAnnotation(node: object | null | undefined, opts?: object): node is MixedTypeAnnotation; +export function isNullableTypeAnnotation(node: object | null | undefined, opts?: object): node is NullableTypeAnnotation; +export function isNumericLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is NumericLiteralTypeAnnotation; +export function isNumberTypeAnnotation(node: object | null | undefined, opts?: object): node is NumberTypeAnnotation; +export function isStringLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is StringLiteralTypeAnnotation; +export function isStringTypeAnnotation(node: object | null | undefined, opts?: object): node is StringTypeAnnotation; +export function isThisTypeAnnotation(node: object | null | undefined, opts?: object): node is ThisTypeAnnotation; +export function isTupleTypeAnnotation(node: object | null | undefined, opts?: object): node is TupleTypeAnnotation; +export function isTypeofTypeAnnotation(node: object | null | undefined, opts?: object): node is TypeofTypeAnnotation; +export function isTypeAlias(node: object | null | undefined, opts?: object): node is TypeAlias; +export function isTypeAnnotation(node: object | null | undefined, opts?: object): node is TypeAnnotation; +export function isTypeCastExpression(node: object | null | undefined, opts?: object): node is TypeCastExpression; +export function isTypeParameter(node: object | null | undefined, opts?: object): node is TypeParameter; +export function isTypeParameterDeclaration(node: object | null | undefined, opts?: object): node is TypeParameterDeclaration; +export function isTypeParameterInstantiation(node: object | null | undefined, opts?: object): node is TypeParameterInstantiation; +export function isObjectTypeAnnotation(node: object | null | undefined, opts?: object): node is ObjectTypeAnnotation; +export function isObjectTypeCallProperty(node: object | null | undefined, opts?: object): node is ObjectTypeCallProperty; +export function isObjectTypeIndexer(node: object | null | undefined, opts?: object): node is ObjectTypeIndexer; +export function isObjectTypeProperty(node: object | null | undefined, opts?: object): node is ObjectTypeProperty; +export function isQualifiedTypeIdentifier(node: object | null | undefined, opts?: object): node is QualifiedTypeIdentifier; +export function isUnionTypeAnnotation(node: object | null | undefined, opts?: object): node is UnionTypeAnnotation; +export function isVoidTypeAnnotation(node: object | null | undefined, opts?: object): node is VoidTypeAnnotation; +export function isJSXAttribute(node: object | null | undefined, opts?: object): node is JSXAttribute; +export function isJSXClosingElement(node: object | null | undefined, opts?: object): node is JSXClosingElement; +export function isJSXElement(node: object | null | undefined, opts?: object): node is JSXElement; +export function isJSXEmptyExpression(node: object | null | undefined, opts?: object): node is JSXEmptyExpression; +export function isJSXExpressionContainer(node: object | null | undefined, opts?: object): node is JSXExpressionContainer; +export function isJSXIdentifier(node: object | null | undefined, opts?: object): node is JSXIdentifier; +export function isJSXMemberExpression(node: object | null | undefined, opts?: object): node is JSXMemberExpression; +export function isJSXNamespacedName(node: object | null | undefined, opts?: object): node is JSXNamespacedName; +export function isJSXOpeningElement(node: object | null | undefined, opts?: object): node is JSXOpeningElement; +export function isJSXSpreadAttribute(node: object | null | undefined, opts?: object): node is JSXSpreadAttribute; +export function isJSXText(node: object | null | undefined, opts?: object): node is JSXText; +export function isNoop(node: object | null | undefined, opts?: object): node is Noop; +export function isParenthesizedExpression(node: object | null | undefined, opts?: object): node is ParenthesizedExpression; +export function isAwaitExpression(node: object | null | undefined, opts?: object): node is AwaitExpression; +export function isBindExpression(node: object | null | undefined, opts?: object): node is BindExpression; +export function isDecorator(node: object | null | undefined, opts?: object): node is Decorator; +export function isDoExpression(node: object | null | undefined, opts?: object): node is DoExpression; +export function isExportDefaultSpecifier(node: object | null | undefined, opts?: object): node is ExportDefaultSpecifier; +export function isExportNamespaceSpecifier(node: object | null | undefined, opts?: object): node is ExportNamespaceSpecifier; +export function isRestProperty(node: object | null | undefined, opts?: object): node is RestProperty; +export function isSpreadProperty(node: object | null | undefined, opts?: object): node is SpreadProperty; +export function isExpression(node: object | null | undefined, opts?: object): node is Expression; +export function isBinary(node: object | null | undefined, opts?: object): node is Binary; +export function isScopable(node: object | null | undefined, opts?: object): node is Scopable; +export function isBlockParent(node: object | null | undefined, opts?: object): node is BlockParent; +export function isBlock(node: object | null | undefined, opts?: object): node is Block; +export function isStatement(node: object | null | undefined, opts?: object): node is Statement; +export function isTerminatorless(node: object | null | undefined, opts?: object): node is Terminatorless; +export function isCompletionStatement(node: object | null | undefined, opts?: object): node is CompletionStatement; +export function isConditional(node: object | null | undefined, opts?: object): node is Conditional; +export function isLoop(node: object | null | undefined, opts?: object): node is Loop; +export function isWhile(node: object | null | undefined, opts?: object): node is While; +export function isExpressionWrapper(node: object | null | undefined, opts?: object): node is ExpressionWrapper; +export function isFor(node: object | null | undefined, opts?: object): node is For; +export function isForXStatement(node: object | null | undefined, opts?: object): node is ForXStatement; // tslint:disable-next-line ban-types -export function isFunction(node: any, opts?: object): node is Function; -export function isFunctionParent(node: any, opts?: object): node is FunctionParent; -export function isPureish(node: any, opts?: object): node is Pureish; -export function isDeclaration(node: any, opts?: object): node is Declaration; -export function isLVal(node: any, opts?: object): node is LVal; -export function isLiteral(node: any, opts?: object): node is Literal; -export function isImmutable(node: any, opts?: object): node is Immutable; -export function isUserWhitespacable(node: any, opts?: object): node is UserWhitespacable; -export function isMethod(node: any, opts?: object): node is Method; -export function isObjectMember(node: any, opts?: object): node is ObjectMember; -export function isProperty(node: any, opts?: object): node is Property; -export function isUnaryLike(node: any, opts?: object): node is UnaryLike; -export function isPattern(node: any, opts?: object): node is Pattern; -export function isClass(node: any, opts?: object): node is Class; -export function isModuleDeclaration(node: any, opts?: object): node is ModuleDeclaration; -export function isExportDeclaration(node: any, opts?: object): node is ExportDeclaration; -export function isModuleSpecifier(node: any, opts?: object): node is ModuleSpecifier; -export function isFlow(node: any, opts?: object): node is Flow; -export function isFlowBaseAnnotation(node: any, opts?: object): node is FlowBaseAnnotation; -export function isFlowDeclaration(node: any, opts?: object): node is FlowDeclaration; -export function isJSX(node: any, opts?: object): node is JSX; -export function isNumberLiteral(node: any, opts?: object): node is NumericLiteral; -export function isRegexLiteral(node: any, opts?: object): node is RegExpLiteral; +export function isFunction(node: object | null | undefined, opts?: object): node is Function; +export function isFunctionParent(node: object | null | undefined, opts?: object): node is FunctionParent; +export function isPureish(node: object | null | undefined, opts?: object): node is Pureish; +export function isDeclaration(node: object | null | undefined, opts?: object): node is Declaration; +export function isLVal(node: object | null | undefined, opts?: object): node is LVal; +export function isLiteral(node: object | null | undefined, opts?: object): node is Literal; +export function isImmutable(node: object | null | undefined, opts?: object): node is Immutable; +export function isUserWhitespacable(node: object | null | undefined, opts?: object): node is UserWhitespacable; +export function isMethod(node: object | null | undefined, opts?: object): node is Method; +export function isObjectMember(node: object | null | undefined, opts?: object): node is ObjectMember; +export function isProperty(node: object | null | undefined, opts?: object): node is Property; +export function isUnaryLike(node: object | null | undefined, opts?: object): node is UnaryLike; +export function isPattern(node: object | null | undefined, opts?: object): node is Pattern; +export function isClass(node: object | null | undefined, opts?: object): node is Class; +export function isModuleDeclaration(node: object | null | undefined, opts?: object): node is ModuleDeclaration; +export function isExportDeclaration(node: object | null | undefined, opts?: object): node is ExportDeclaration; +export function isModuleSpecifier(node: object | null | undefined, opts?: object): node is ModuleSpecifier; +export function isFlow(node: object | null | undefined, opts?: object): node is Flow; +export function isFlowBaseAnnotation(node: object | null | undefined, opts?: object): node is FlowBaseAnnotation; +export function isFlowDeclaration(node: object | null | undefined, opts?: object): node is FlowDeclaration; +export function isJSX(node: object | null | undefined, opts?: object): node is JSX; +export function isNumberLiteral(node: object | null | undefined, opts?: object): node is NumericLiteral; +export function isRegexLiteral(node: object | null | undefined, opts?: object): node is RegExpLiteral; -export function isReferencedIdentifier(node: any, opts?: object): node is Identifier | JSXIdentifier; -export function isReferencedMemberExpression(node: any, opts?: object): node is MemberExpression; -export function isBindingIdentifier(node: any, opts?: object): node is Identifier; -export function isScope(node: any, opts?: object): node is Scopable; -export function isReferenced(node: any, opts?: object): boolean; -export function isBlockScoped(node: any, opts?: object): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration; -export function isVar(node: any, opts?: object): node is VariableDeclaration; -export function isUser(node: any, opts?: object): boolean; -export function isGenerated(node: any, opts?: object): boolean; -export function isPure(node: any, opts?: object): boolean; +export function isReferencedIdentifier(node: object | null | undefined, opts?: object): node is Identifier | JSXIdentifier; +export function isReferencedMemberExpression(node: object | null | undefined, opts?: object): node is MemberExpression; +export function isBindingIdentifier(node: object | null | undefined, opts?: object): node is Identifier; +export function isScope(node: object | null | undefined, opts?: object): node is Scopable; +export function isReferenced(node: object | null | undefined, opts?: object): boolean; +export function isBlockScoped(node: object | null | undefined, opts?: object): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration; +export function isVar(node: object | null | undefined, opts?: object): node is VariableDeclaration; +export function isUser(node: object | null | undefined, opts?: object): boolean; +export function isGenerated(node: object | null | undefined, opts?: object): boolean; +export function isPure(node: object | null | undefined, opts?: object): boolean; -export function isTSAnyKeyword(node: any, opts?: object): node is TSAnyKeyword; -export function isTSArrayType(node: any, opts?: object): node is TSArrayType; -export function isTSAsExpression(node: any, opts?: object): node is TSAsExpression; -export function isTSBooleanKeyword(node: any, opts?: object): node is TSBooleanKeyword; -export function isTSCallSignatureDeclaration(node: any, opts?: object): node is TSCallSignatureDeclaration; -export function isTSConstructSignatureDeclaration(node: any, opts?: object): node is TSTypeElement; -export function isTSConstructorType(node: any, opts?: object): node is TSConstructorType; -export function isTSDeclareFunction(node: any, opts?: object): node is TSDeclareFunction; -export function isTSDeclareMethod(node: any, opts?: object): node is TSDeclareMethod; -export function isTSEnumDeclaration(node: any, opts?: object): node is TSEnumDeclaration; -export function isTSEnumMember(node: any, opts?: object): node is TSEnumMember; -export function isTSExportAssignment(node: any, opts?: object): node is TSExportAssignment; -export function isTSExpressionWithTypeArguments(node: any, opts?: object): node is TSExpressionWithTypeArguments; -export function isTSExternalModuleReference(node: any, opts?: object): node is TSExternalModuleReference; -export function isTSFunctionType(node: any, opts?: object): node is TSFunctionType; -export function isTSImportEqualsDeclaration(node: any, opts?: object): node is TSImportEqualsDeclaration; -export function isTSIndexSignature(node: any, opts?: object): node is TSIndexSignature; -export function isTSIndexedAccessType(node: any, opts?: object): node is TSIndexedAccessType; -export function isTSInterfaceBody(node: any, opts?: object): node is TSInterfaceBody; -export function isTSInterfaceDeclaration(node: any, opts?: object): node is TSInterfaceDeclaration; -export function isTSIntersectionType(node: any, opts?: object): node is TSIntersectionType; -export function isTSLiteralType(node: any, opts?: object): node is TSLiteralType; -export function isTSMappedType(node: any, opts?: object): node is TSMappedType; -export function isTSMethodSignature(node: any, opts?: object): node is TSMethodSignature; -export function isTSModuleBlock(node: any, opts?: object): node is TSModuleBlock; -export function isTSModuleDeclaration(node: any, opts?: object): node is TSModuleDeclaration; -export function isTSNamespaceExportDeclaration(node: any, opts?: object): node is TSNamespaceExportDeclaration; -export function isTSNeverKeyword(node: any, opts?: object): node is TSNeverKeyword; -export function isTSNonNullExpression(node: any, opts?: object): node is TSNonNullExpression; -export function isTSNullKeyword(node: any, opts?: object): node is TSNullKeyword; -export function isTSNumberKeyword(node: any, opts?: object): node is TSNumberKeyword; -export function isTSObjectKeyword(node: any, opts?: object): node is TSObjectKeyword; -export function isTSParameterProperty(node: any, opts?: object): node is TSParameterProperty; -export function isTSParenthesizedType(node: any, opts?: object): node is TSParenthesizedType; -export function isTSPropertySignature(node: any, opts?: object): node is TSPropertySignature; -export function isTSQualifiedName(node: any, opts?: object): node is TSQualifiedName; -export function isTSStringKeyword(node: any, opts?: object): node is TSStringKeyword; -export function isTSSymbolKeyword(node: any, opts?: object): node is TSSymbolKeyword; -export function isTSThisType(node: any, opts?: object): node is TSThisType; -export function isTSTupleType(node: any, opts?: object): node is TSTupleType; -export function isTSTypeAliasDeclaration(node: any, opts?: object): node is TSTypeAliasDeclaration; -export function isTSTypeAnnotation(node: any, opts?: object): node is TSTypeAnnotation; -export function isTSTypeAssertion(node: any, opts?: object): node is TSTypeAssertion; -export function isTSTypeLiteral(node: any, opts?: object): node is TSTypeLiteral; -export function isTSTypeOperator(node: any, opts?: object): node is TSTypeOperator; -export function isTSTypeParameter(node: any, opts?: object): node is TSTypeParameter; -export function isTSTypeParameterDeclaration(node: any, opts?: object): node is TSTypeParameterDeclaration; -export function isTSTypeParameterInstantiation(node: any, opts?: object): node is TSTypeParameterInstantiation; -export function isTSTypePredicate(node: any, opts?: object): node is TSTypePredicate; -export function isTSTypeQuery(node: any, opts?: object): node is TSTypeQuery; -export function isTSTypeReference(node: any, opts?: object): node is TSTypeReference; -export function isTSUndefinedKeyword(node: any, opts?: object): node is TSUndefinedKeyword; -export function isTSUnionType(node: any, opts?: object): node is TSUnionType; -export function isTSVoidKeyword(node: any, opts?: object): node is TSVoidKeyword; +export function isTSAnyKeyword(node: object | null | undefined, opts?: object): node is TSAnyKeyword; +export function isTSArrayType(node: object | null | undefined, opts?: object): node is TSArrayType; +export function isTSAsExpression(node: object | null | undefined, opts?: object): node is TSAsExpression; +export function isTSBooleanKeyword(node: object | null | undefined, opts?: object): node is TSBooleanKeyword; +export function isTSCallSignatureDeclaration(node: object | null | undefined, opts?: object): node is TSCallSignatureDeclaration; +export function isTSConstructSignatureDeclaration(node: object | null | undefined, opts?: object): node is TSTypeElement; +export function isTSConstructorType(node: object | null | undefined, opts?: object): node is TSConstructorType; +export function isTSDeclareFunction(node: object | null | undefined, opts?: object): node is TSDeclareFunction; +export function isTSDeclareMethod(node: object | null | undefined, opts?: object): node is TSDeclareMethod; +export function isTSEnumDeclaration(node: object | null | undefined, opts?: object): node is TSEnumDeclaration; +export function isTSEnumMember(node: object | null | undefined, opts?: object): node is TSEnumMember; +export function isTSExportAssignment(node: object | null | undefined, opts?: object): node is TSExportAssignment; +export function isTSExpressionWithTypeArguments(node: object | null | undefined, opts?: object): node is TSExpressionWithTypeArguments; +export function isTSExternalModuleReference(node: object | null | undefined, opts?: object): node is TSExternalModuleReference; +export function isTSFunctionType(node: object | null | undefined, opts?: object): node is TSFunctionType; +export function isTSImportEqualsDeclaration(node: object | null | undefined, opts?: object): node is TSImportEqualsDeclaration; +export function isTSIndexSignature(node: object | null | undefined, opts?: object): node is TSIndexSignature; +export function isTSIndexedAccessType(node: object | null | undefined, opts?: object): node is TSIndexedAccessType; +export function isTSInterfaceBody(node: object | null | undefined, opts?: object): node is TSInterfaceBody; +export function isTSInterfaceDeclaration(node: object | null | undefined, opts?: object): node is TSInterfaceDeclaration; +export function isTSIntersectionType(node: object | null | undefined, opts?: object): node is TSIntersectionType; +export function isTSLiteralType(node: object | null | undefined, opts?: object): node is TSLiteralType; +export function isTSMappedType(node: object | null | undefined, opts?: object): node is TSMappedType; +export function isTSMethodSignature(node: object | null | undefined, opts?: object): node is TSMethodSignature; +export function isTSModuleBlock(node: object | null | undefined, opts?: object): node is TSModuleBlock; +export function isTSModuleDeclaration(node: object | null | undefined, opts?: object): node is TSModuleDeclaration; +export function isTSNamespaceExportDeclaration(node: object | null | undefined, opts?: object): node is TSNamespaceExportDeclaration; +export function isTSNeverKeyword(node: object | null | undefined, opts?: object): node is TSNeverKeyword; +export function isTSNonNullExpression(node: object | null | undefined, opts?: object): node is TSNonNullExpression; +export function isTSNullKeyword(node: object | null | undefined, opts?: object): node is TSNullKeyword; +export function isTSNumberKeyword(node: object | null | undefined, opts?: object): node is TSNumberKeyword; +export function isTSObjectKeyword(node: object | null | undefined, opts?: object): node is TSObjectKeyword; +export function isTSParameterProperty(node: object | null | undefined, opts?: object): node is TSParameterProperty; +export function isTSParenthesizedType(node: object | null | undefined, opts?: object): node is TSParenthesizedType; +export function isTSPropertySignature(node: object | null | undefined, opts?: object): node is TSPropertySignature; +export function isTSQualifiedName(node: object | null | undefined, opts?: object): node is TSQualifiedName; +export function isTSStringKeyword(node: object | null | undefined, opts?: object): node is TSStringKeyword; +export function isTSSymbolKeyword(node: object | null | undefined, opts?: object): node is TSSymbolKeyword; +export function isTSThisType(node: object | null | undefined, opts?: object): node is TSThisType; +export function isTSTupleType(node: object | null | undefined, opts?: object): node is TSTupleType; +export function isTSTypeAliasDeclaration(node: object | null | undefined, opts?: object): node is TSTypeAliasDeclaration; +export function isTSTypeAnnotation(node: object | null | undefined, opts?: object): node is TSTypeAnnotation; +export function isTSTypeAssertion(node: object | null | undefined, opts?: object): node is TSTypeAssertion; +export function isTSTypeLiteral(node: object | null | undefined, opts?: object): node is TSTypeLiteral; +export function isTSTypeOperator(node: object | null | undefined, opts?: object): node is TSTypeOperator; +export function isTSTypeParameter(node: object | null | undefined, opts?: object): node is TSTypeParameter; +export function isTSTypeParameterDeclaration(node: object | null | undefined, opts?: object): node is TSTypeParameterDeclaration; +export function isTSTypeParameterInstantiation(node: object | null | undefined, opts?: object): node is TSTypeParameterInstantiation; +export function isTSTypePredicate(node: object | null | undefined, opts?: object): node is TSTypePredicate; +export function isTSTypeQuery(node: object | null | undefined, opts?: object): node is TSTypeQuery; +export function isTSTypeReference(node: object | null | undefined, opts?: object): node is TSTypeReference; +export function isTSUndefinedKeyword(node: object | null | undefined, opts?: object): node is TSUndefinedKeyword; +export function isTSUnionType(node: object | null | undefined, opts?: object): node is TSUnionType; +export function isTSVoidKeyword(node: object | null | undefined, opts?: object): node is TSVoidKeyword; // React specific export interface ReactHelpers { @@ -1762,231 +1762,231 @@ export interface ReactHelpers { } export const react: ReactHelpers; -export function assertArrayExpression(node: any, opts?: object): void; -export function assertAssignmentExpression(node: any, opts?: object): void; -export function assertBinaryExpression(node: any, opts?: object): void; -export function assertDirective(node: any, opts?: object): void; -export function assertDirectiveLiteral(node: any, opts?: object): void; -export function assertBlockStatement(node: any, opts?: object): void; -export function assertBreakStatement(node: any, opts?: object): void; -export function assertCallExpression(node: any, opts?: object): void; -export function assertCatchClause(node: any, opts?: object): void; -export function assertConditionalExpression(node: any, opts?: object): void; -export function assertContinueStatement(node: any, opts?: object): void; -export function assertDebuggerStatement(node: any, opts?: object): void; -export function assertDoWhileStatement(node: any, opts?: object): void; -export function assertEmptyStatement(node: any, opts?: object): void; -export function assertExpressionStatement(node: any, opts?: object): void; -export function assertFile(node: any, opts?: object): void; -export function assertForInStatement(node: any, opts?: object): void; -export function assertForStatement(node: any, opts?: object): void; -export function assertFunctionDeclaration(node: any, opts?: object): void; -export function assertFunctionExpression(node: any, opts?: object): void; -export function assertIdentifier(node: any, opts?: object): void; -export function assertIfStatement(node: any, opts?: object): void; -export function assertLabeledStatement(node: any, opts?: object): void; -export function assertStringLiteral(node: any, opts?: object): void; -export function assertNumericLiteral(node: any, opts?: object): void; -export function assertNullLiteral(node: any, opts?: object): void; -export function assertBooleanLiteral(node: any, opts?: object): void; -export function assertRegExpLiteral(node: any, opts?: object): void; -export function assertLogicalExpression(node: any, opts?: object): void; -export function assertMemberExpression(node: any, opts?: object): void; -export function assertNewExpression(node: any, opts?: object): void; -export function assertProgram(node: any, opts?: object): void; -export function assertObjectExpression(node: any, opts?: object): void; -export function assertObjectMethod(node: any, opts?: object): void; -export function assertObjectProperty(node: any, opts?: object): void; -export function assertRestElement(node: any, opts?: object): void; -export function assertReturnStatement(node: any, opts?: object): void; -export function assertSequenceExpression(node: any, opts?: object): void; -export function assertSwitchCase(node: any, opts?: object): void; -export function assertSwitchStatement(node: any, opts?: object): void; -export function assertThisExpression(node: any, opts?: object): void; -export function assertThrowStatement(node: any, opts?: object): void; -export function assertTryStatement(node: any, opts?: object): void; -export function assertUnaryExpression(node: any, opts?: object): void; -export function assertUpdateExpression(node: any, opts?: object): void; -export function assertVariableDeclaration(node: any, opts?: object): void; -export function assertVariableDeclarator(node: any, opts?: object): void; -export function assertWhileStatement(node: any, opts?: object): void; -export function assertWithStatement(node: any, opts?: object): void; -export function assertAssignmentPattern(node: any, opts?: object): void; -export function assertArrayPattern(node: any, opts?: object): void; -export function assertArrowFunctionExpression(node: any, opts?: object): void; -export function assertClassBody(node: any, opts?: object): void; -export function assertClassDeclaration(node: any, opts?: object): void; -export function assertClassExpression(node: any, opts?: object): void; -export function assertExportAllDeclaration(node: any, opts?: object): void; -export function assertExportDefaultDeclaration(node: any, opts?: object): void; -export function assertExportNamedDeclaration(node: any, opts?: object): void; -export function assertExportSpecifier(node: any, opts?: object): void; -export function assertForOfStatement(node: any, opts?: object): void; -export function assertImportDeclaration(node: any, opts?: object): void; -export function assertImportDefaultSpecifier(node: any, opts?: object): void; -export function assertImportNamespaceSpecifier(node: any, opts?: object): void; -export function assertImportSpecifier(node: any, opts?: object): void; -export function assertMetaProperty(node: any, opts?: object): void; -export function assertClassMethod(node: any, opts?: object): void; -export function assertObjectPattern(node: any, opts?: object): void; -export function assertSpreadElement(node: any, opts?: object): void; -export function assertSuper(node: any, opts?: object): void; -export function assertTaggedTemplateExpression(node: any, opts?: object): void; -export function assertTemplateElement(node: any, opts?: object): void; -export function assertTemplateLiteral(node: any, opts?: object): void; -export function assertYieldExpression(node: any, opts?: object): void; -export function assertAnyTypeAnnotation(node: any, opts?: object): void; -export function assertArrayTypeAnnotation(node: any, opts?: object): void; -export function assertBooleanTypeAnnotation(node: any, opts?: object): void; -export function assertBooleanLiteralTypeAnnotation(node: any, opts?: object): void; -export function assertNullLiteralTypeAnnotation(node: any, opts?: object): void; -export function assertClassImplements(node: any, opts?: object): void; -export function assertClassProperty(node: any, opts?: object): void; -export function assertDeclareClass(node: any, opts?: object): void; -export function assertDeclareFunction(node: any, opts?: object): void; -export function assertDeclareInterface(node: any, opts?: object): void; -export function assertDeclareModule(node: any, opts?: object): void; -export function assertDeclareTypeAlias(node: any, opts?: object): void; -export function assertDeclareVariable(node: any, opts?: object): void; -export function assertExistentialTypeParam(node: any, opts?: object): void; -export function assertFunctionTypeAnnotation(node: any, opts?: object): void; -export function assertFunctionTypeParam(node: any, opts?: object): void; -export function assertGenericTypeAnnotation(node: any, opts?: object): void; -export function assertInterfaceExtends(node: any, opts?: object): void; -export function assertInterfaceDeclaration(node: any, opts?: object): void; -export function assertIntersectionTypeAnnotation(node: any, opts?: object): void; -export function assertMixedTypeAnnotation(node: any, opts?: object): void; -export function assertNullableTypeAnnotation(node: any, opts?: object): void; -export function assertNumericLiteralTypeAnnotation(node: any, opts?: object): void; -export function assertNumberTypeAnnotation(node: any, opts?: object): void; -export function assertStringLiteralTypeAnnotation(node: any, opts?: object): void; -export function assertStringTypeAnnotation(node: any, opts?: object): void; -export function assertThisTypeAnnotation(node: any, opts?: object): void; -export function assertTupleTypeAnnotation(node: any, opts?: object): void; -export function assertTypeofTypeAnnotation(node: any, opts?: object): void; -export function assertTypeAlias(node: any, opts?: object): void; -export function assertTypeAnnotation(node: any, opts?: object): void; -export function assertTypeCastExpression(node: any, opts?: object): void; -export function assertTypeParameter(node: any, opts?: object): void; -export function assertTypeParameterDeclaration(node: any, opts?: object): void; -export function assertTypeParameterInstantiation(node: any, opts?: object): void; -export function assertObjectTypeAnnotation(node: any, opts?: object): void; -export function assertObjectTypeCallProperty(node: any, opts?: object): void; -export function assertObjectTypeIndexer(node: any, opts?: object): void; -export function assertObjectTypeProperty(node: any, opts?: object): void; -export function assertQualifiedTypeIdentifier(node: any, opts?: object): void; -export function assertUnionTypeAnnotation(node: any, opts?: object): void; -export function assertVoidTypeAnnotation(node: any, opts?: object): void; -export function assertJSXAttribute(node: any, opts?: object): void; -export function assertJSXClosingElement(node: any, opts?: object): void; -export function assertJSXElement(node: any, opts?: object): void; -export function assertJSXEmptyExpression(node: any, opts?: object): void; -export function assertJSXExpressionContainer(node: any, opts?: object): void; -export function assertJSXIdentifier(node: any, opts?: object): void; -export function assertJSXMemberExpression(node: any, opts?: object): void; -export function assertJSXNamespacedName(node: any, opts?: object): void; -export function assertJSXOpeningElement(node: any, opts?: object): void; -export function assertJSXSpreadAttribute(node: any, opts?: object): void; -export function assertJSXText(node: any, opts?: object): void; -export function assertNoop(node: any, opts?: object): void; -export function assertParenthesizedExpression(node: any, opts?: object): void; -export function assertAwaitExpression(node: any, opts?: object): void; -export function assertBindExpression(node: any, opts?: object): void; -export function assertDecorator(node: any, opts?: object): void; -export function assertDoExpression(node: any, opts?: object): void; -export function assertExportDefaultSpecifier(node: any, opts?: object): void; -export function assertExportNamespaceSpecifier(node: any, opts?: object): void; -export function assertRestProperty(node: any, opts?: object): void; -export function assertSpreadProperty(node: any, opts?: object): void; -export function assertExpression(node: any, opts?: object): void; -export function assertBinary(node: any, opts?: object): void; -export function assertScopable(node: any, opts?: object): void; -export function assertBlockParent(node: any, opts?: object): void; -export function assertBlock(node: any, opts?: object): void; -export function assertStatement(node: any, opts?: object): void; -export function assertTerminatorless(node: any, opts?: object): void; -export function assertCompletionStatement(node: any, opts?: object): void; -export function assertConditional(node: any, opts?: object): void; -export function assertLoop(node: any, opts?: object): void; -export function assertWhile(node: any, opts?: object): void; -export function assertExpressionWrapper(node: any, opts?: object): void; -export function assertFor(node: any, opts?: object): void; -export function assertForXStatement(node: any, opts?: object): void; -export function assertFunction(node: any, opts?: object): void; -export function assertFunctionParent(node: any, opts?: object): void; -export function assertPureish(node: any, opts?: object): void; -export function assertDeclaration(node: any, opts?: object): void; -export function assertLVal(node: any, opts?: object): void; -export function assertLiteral(node: any, opts?: object): void; -export function assertImmutable(node: any, opts?: object): void; -export function assertUserWhitespacable(node: any, opts?: object): void; -export function assertMethod(node: any, opts?: object): void; -export function assertObjectMember(node: any, opts?: object): void; -export function assertProperty(node: any, opts?: object): void; -export function assertUnaryLike(node: any, opts?: object): void; -export function assertPattern(node: any, opts?: object): void; -export function assertClass(node: any, opts?: object): void; -export function assertModuleDeclaration(node: any, opts?: object): void; -export function assertExportDeclaration(node: any, opts?: object): void; -export function assertModuleSpecifier(node: any, opts?: object): void; -export function assertFlow(node: any, opts?: object): void; -export function assertFlowBaseAnnotation(node: any, opts?: object): void; -export function assertFlowDeclaration(node: any, opts?: object): void; -export function assertJSX(node: any, opts?: object): void; -export function assertNumberLiteral(node: any, opts?: object): void; -export function assertRegexLiteral(node: any, opts?: object): void; +export function assertArrayExpression(node: object | null | undefined, opts?: object): void; +export function assertAssignmentExpression(node: object | null | undefined, opts?: object): void; +export function assertBinaryExpression(node: object | null | undefined, opts?: object): void; +export function assertDirective(node: object | null | undefined, opts?: object): void; +export function assertDirectiveLiteral(node: object | null | undefined, opts?: object): void; +export function assertBlockStatement(node: object | null | undefined, opts?: object): void; +export function assertBreakStatement(node: object | null | undefined, opts?: object): void; +export function assertCallExpression(node: object | null | undefined, opts?: object): void; +export function assertCatchClause(node: object | null | undefined, opts?: object): void; +export function assertConditionalExpression(node: object | null | undefined, opts?: object): void; +export function assertContinueStatement(node: object | null | undefined, opts?: object): void; +export function assertDebuggerStatement(node: object | null | undefined, opts?: object): void; +export function assertDoWhileStatement(node: object | null | undefined, opts?: object): void; +export function assertEmptyStatement(node: object | null | undefined, opts?: object): void; +export function assertExpressionStatement(node: object | null | undefined, opts?: object): void; +export function assertFile(node: object | null | undefined, opts?: object): void; +export function assertForInStatement(node: object | null | undefined, opts?: object): void; +export function assertForStatement(node: object | null | undefined, opts?: object): void; +export function assertFunctionDeclaration(node: object | null | undefined, opts?: object): void; +export function assertFunctionExpression(node: object | null | undefined, opts?: object): void; +export function assertIdentifier(node: object | null | undefined, opts?: object): void; +export function assertIfStatement(node: object | null | undefined, opts?: object): void; +export function assertLabeledStatement(node: object | null | undefined, opts?: object): void; +export function assertStringLiteral(node: object | null | undefined, opts?: object): void; +export function assertNumericLiteral(node: object | null | undefined, opts?: object): void; +export function assertNullLiteral(node: object | null | undefined, opts?: object): void; +export function assertBooleanLiteral(node: object | null | undefined, opts?: object): void; +export function assertRegExpLiteral(node: object | null | undefined, opts?: object): void; +export function assertLogicalExpression(node: object | null | undefined, opts?: object): void; +export function assertMemberExpression(node: object | null | undefined, opts?: object): void; +export function assertNewExpression(node: object | null | undefined, opts?: object): void; +export function assertProgram(node: object | null | undefined, opts?: object): void; +export function assertObjectExpression(node: object | null | undefined, opts?: object): void; +export function assertObjectMethod(node: object | null | undefined, opts?: object): void; +export function assertObjectProperty(node: object | null | undefined, opts?: object): void; +export function assertRestElement(node: object | null | undefined, opts?: object): void; +export function assertReturnStatement(node: object | null | undefined, opts?: object): void; +export function assertSequenceExpression(node: object | null | undefined, opts?: object): void; +export function assertSwitchCase(node: object | null | undefined, opts?: object): void; +export function assertSwitchStatement(node: object | null | undefined, opts?: object): void; +export function assertThisExpression(node: object | null | undefined, opts?: object): void; +export function assertThrowStatement(node: object | null | undefined, opts?: object): void; +export function assertTryStatement(node: object | null | undefined, opts?: object): void; +export function assertUnaryExpression(node: object | null | undefined, opts?: object): void; +export function assertUpdateExpression(node: object | null | undefined, opts?: object): void; +export function assertVariableDeclaration(node: object | null | undefined, opts?: object): void; +export function assertVariableDeclarator(node: object | null | undefined, opts?: object): void; +export function assertWhileStatement(node: object | null | undefined, opts?: object): void; +export function assertWithStatement(node: object | null | undefined, opts?: object): void; +export function assertAssignmentPattern(node: object | null | undefined, opts?: object): void; +export function assertArrayPattern(node: object | null | undefined, opts?: object): void; +export function assertArrowFunctionExpression(node: object | null | undefined, opts?: object): void; +export function assertClassBody(node: object | null | undefined, opts?: object): void; +export function assertClassDeclaration(node: object | null | undefined, opts?: object): void; +export function assertClassExpression(node: object | null | undefined, opts?: object): void; +export function assertExportAllDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportDefaultDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportNamedDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportSpecifier(node: object | null | undefined, opts?: object): void; +export function assertForOfStatement(node: object | null | undefined, opts?: object): void; +export function assertImportDeclaration(node: object | null | undefined, opts?: object): void; +export function assertImportDefaultSpecifier(node: object | null | undefined, opts?: object): void; +export function assertImportNamespaceSpecifier(node: object | null | undefined, opts?: object): void; +export function assertImportSpecifier(node: object | null | undefined, opts?: object): void; +export function assertMetaProperty(node: object | null | undefined, opts?: object): void; +export function assertClassMethod(node: object | null | undefined, opts?: object): void; +export function assertObjectPattern(node: object | null | undefined, opts?: object): void; +export function assertSpreadElement(node: object | null | undefined, opts?: object): void; +export function assertSuper(node: object | null | undefined, opts?: object): void; +export function assertTaggedTemplateExpression(node: object | null | undefined, opts?: object): void; +export function assertTemplateElement(node: object | null | undefined, opts?: object): void; +export function assertTemplateLiteral(node: object | null | undefined, opts?: object): void; +export function assertYieldExpression(node: object | null | undefined, opts?: object): void; +export function assertAnyTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertArrayTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertBooleanTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertBooleanLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNullLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertClassImplements(node: object | null | undefined, opts?: object): void; +export function assertClassProperty(node: object | null | undefined, opts?: object): void; +export function assertDeclareClass(node: object | null | undefined, opts?: object): void; +export function assertDeclareFunction(node: object | null | undefined, opts?: object): void; +export function assertDeclareInterface(node: object | null | undefined, opts?: object): void; +export function assertDeclareModule(node: object | null | undefined, opts?: object): void; +export function assertDeclareTypeAlias(node: object | null | undefined, opts?: object): void; +export function assertDeclareVariable(node: object | null | undefined, opts?: object): void; +export function assertExistentialTypeParam(node: object | null | undefined, opts?: object): void; +export function assertFunctionTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertFunctionTypeParam(node: object | null | undefined, opts?: object): void; +export function assertGenericTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertInterfaceExtends(node: object | null | undefined, opts?: object): void; +export function assertInterfaceDeclaration(node: object | null | undefined, opts?: object): void; +export function assertIntersectionTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertMixedTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNullableTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNumericLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNumberTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertStringLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertStringTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertThisTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTupleTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTypeofTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTypeAlias(node: object | null | undefined, opts?: object): void; +export function assertTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTypeCastExpression(node: object | null | undefined, opts?: object): void; +export function assertTypeParameter(node: object | null | undefined, opts?: object): void; +export function assertTypeParameterDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTypeParameterInstantiation(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeCallProperty(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeIndexer(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeProperty(node: object | null | undefined, opts?: object): void; +export function assertQualifiedTypeIdentifier(node: object | null | undefined, opts?: object): void; +export function assertUnionTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertVoidTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertJSXAttribute(node: object | null | undefined, opts?: object): void; +export function assertJSXClosingElement(node: object | null | undefined, opts?: object): void; +export function assertJSXElement(node: object | null | undefined, opts?: object): void; +export function assertJSXEmptyExpression(node: object | null | undefined, opts?: object): void; +export function assertJSXExpressionContainer(node: object | null | undefined, opts?: object): void; +export function assertJSXIdentifier(node: object | null | undefined, opts?: object): void; +export function assertJSXMemberExpression(node: object | null | undefined, opts?: object): void; +export function assertJSXNamespacedName(node: object | null | undefined, opts?: object): void; +export function assertJSXOpeningElement(node: object | null | undefined, opts?: object): void; +export function assertJSXSpreadAttribute(node: object | null | undefined, opts?: object): void; +export function assertJSXText(node: object | null | undefined, opts?: object): void; +export function assertNoop(node: object | null | undefined, opts?: object): void; +export function assertParenthesizedExpression(node: object | null | undefined, opts?: object): void; +export function assertAwaitExpression(node: object | null | undefined, opts?: object): void; +export function assertBindExpression(node: object | null | undefined, opts?: object): void; +export function assertDecorator(node: object | null | undefined, opts?: object): void; +export function assertDoExpression(node: object | null | undefined, opts?: object): void; +export function assertExportDefaultSpecifier(node: object | null | undefined, opts?: object): void; +export function assertExportNamespaceSpecifier(node: object | null | undefined, opts?: object): void; +export function assertRestProperty(node: object | null | undefined, opts?: object): void; +export function assertSpreadProperty(node: object | null | undefined, opts?: object): void; +export function assertExpression(node: object | null | undefined, opts?: object): void; +export function assertBinary(node: object | null | undefined, opts?: object): void; +export function assertScopable(node: object | null | undefined, opts?: object): void; +export function assertBlockParent(node: object | null | undefined, opts?: object): void; +export function assertBlock(node: object | null | undefined, opts?: object): void; +export function assertStatement(node: object | null | undefined, opts?: object): void; +export function assertTerminatorless(node: object | null | undefined, opts?: object): void; +export function assertCompletionStatement(node: object | null | undefined, opts?: object): void; +export function assertConditional(node: object | null | undefined, opts?: object): void; +export function assertLoop(node: object | null | undefined, opts?: object): void; +export function assertWhile(node: object | null | undefined, opts?: object): void; +export function assertExpressionWrapper(node: object | null | undefined, opts?: object): void; +export function assertFor(node: object | null | undefined, opts?: object): void; +export function assertForXStatement(node: object | null | undefined, opts?: object): void; +export function assertFunction(node: object | null | undefined, opts?: object): void; +export function assertFunctionParent(node: object | null | undefined, opts?: object): void; +export function assertPureish(node: object | null | undefined, opts?: object): void; +export function assertDeclaration(node: object | null | undefined, opts?: object): void; +export function assertLVal(node: object | null | undefined, opts?: object): void; +export function assertLiteral(node: object | null | undefined, opts?: object): void; +export function assertImmutable(node: object | null | undefined, opts?: object): void; +export function assertUserWhitespacable(node: object | null | undefined, opts?: object): void; +export function assertMethod(node: object | null | undefined, opts?: object): void; +export function assertObjectMember(node: object | null | undefined, opts?: object): void; +export function assertProperty(node: object | null | undefined, opts?: object): void; +export function assertUnaryLike(node: object | null | undefined, opts?: object): void; +export function assertPattern(node: object | null | undefined, opts?: object): void; +export function assertClass(node: object | null | undefined, opts?: object): void; +export function assertModuleDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportDeclaration(node: object | null | undefined, opts?: object): void; +export function assertModuleSpecifier(node: object | null | undefined, opts?: object): void; +export function assertFlow(node: object | null | undefined, opts?: object): void; +export function assertFlowBaseAnnotation(node: object | null | undefined, opts?: object): void; +export function assertFlowDeclaration(node: object | null | undefined, opts?: object): void; +export function assertJSX(node: object | null | undefined, opts?: object): void; +export function assertNumberLiteral(node: object | null | undefined, opts?: object): void; +export function assertRegexLiteral(node: object | null | undefined, opts?: object): void; -export function assertTSAnyKeyword(node: any, opts?: object): void; -export function assertTSArrayType(node: any, opts?: object): void; -export function assertTSAsExpression(node: any, opts?: object): void; -export function assertTSBooleanKeyword(node: any, opts?: object): void; -export function assertTSCallSignatureDeclaration(node: any, opts?: object): void; -export function assertTSConstructSignatureDeclaration(node: any, opts?: object): void; -export function assertTSConstructorType(node: any, opts?: object): void; -export function assertTSDeclareFunction(node: any, opts?: object): void; -export function assertTSDeclareMethod(node: any, opts?: object): void; -export function assertTSEnumDeclaration(node: any, opts?: object): void; -export function assertTSEnumMember(node: any, opts?: object): void; -export function assertTSExportAssignment(node: any, opts?: object): void; -export function assertTSExpressionWithTypeArguments(node: any, opts?: object): void; -export function assertTSExternalModuleReference(node: any, opts?: object): void; -export function assertTSFunctionType(node: any, opts?: object): void; -export function assertTSImportEqualsDeclaration(node: any, opts?: object): void; -export function assertTSIndexSignature(node: any, opts?: object): void; -export function assertTSIndexedAccessType(node: any, opts?: object): void; -export function assertTSInterfaceBody(node: any, opts?: object): void; -export function assertTSInterfaceDeclaration(node: any, opts?: object): void; -export function assertTSIntersectionType(node: any, opts?: object): void; -export function assertTSLiteralType(node: any, opts?: object): void; -export function assertTSMappedType(node: any, opts?: object): void; -export function assertTSMethodSignature(node: any, opts?: object): void; -export function assertTSModuleBlock(node: any, opts?: object): void; -export function assertTSModuleDeclaration(node: any, opts?: object): void; -export function assertTSNamespaceExportDeclaration(node: any, opts?: object): void; -export function assertTSNeverKeyword(node: any, opts?: object): void; -export function assertTSNonNullExpression(node: any, opts?: object): void; -export function assertTSNullKeyword(node: any, opts?: object): void; -export function assertTSNumberKeyword(node: any, opts?: object): void; -export function assertTSObjectKeyword(node: any, opts?: object): void; -export function assertTSParameterProperty(node: any, opts?: object): void; -export function assertTSParenthesizedType(node: any, opts?: object): void; -export function assertTSPropertySignature(node: any, opts?: object): void; -export function assertTSQualifiedName(node: any, opts?: object): void; -export function assertTSStringKeyword(node: any, opts?: object): void; -export function assertTSSymbolKeyword(node: any, opts?: object): void; -export function assertTSThisType(node: any, opts?: object): void; -export function assertTSTupleType(node: any, opts?: object): void; -export function assertTSTypeAliasDeclaration(node: any, opts?: object): void; -export function assertTSTypeAnnotation(node: any, opts?: object): void; -export function assertTSTypeAssertion(node: any, opts?: object): void; -export function assertTSTypeLiteral(node: any, opts?: object): void; -export function assertTSTypeOperator(node: any, opts?: object): void; -export function assertTSTypeParameter(node: any, opts?: object): void; -export function assertTSTypeParameterDeclaration(node: any, opts?: object): void; -export function assertTSTypeParameterInstantiation(node: any, opts?: object): void; -export function assertTSTypePredicate(node: any, opts?: object): void; -export function assertTSTypeQuery(node: any, opts?: object): void; -export function assertTSTypeReference(node: any, opts?: object): void; -export function assertTSUndefinedKeyword(node: any, opts?: object): void; -export function assertTSUnionType(node: any, opts?: object): void; -export function assertTSVoidKeyword(node: any, opts?: object): void; +export function assertTSAnyKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSArrayType(node: object | null | undefined, opts?: object): void; +export function assertTSAsExpression(node: object | null | undefined, opts?: object): void; +export function assertTSBooleanKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSCallSignatureDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSConstructSignatureDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSConstructorType(node: object | null | undefined, opts?: object): void; +export function assertTSDeclareFunction(node: object | null | undefined, opts?: object): void; +export function assertTSDeclareMethod(node: object | null | undefined, opts?: object): void; +export function assertTSEnumDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSEnumMember(node: object | null | undefined, opts?: object): void; +export function assertTSExportAssignment(node: object | null | undefined, opts?: object): void; +export function assertTSExpressionWithTypeArguments(node: object | null | undefined, opts?: object): void; +export function assertTSExternalModuleReference(node: object | null | undefined, opts?: object): void; +export function assertTSFunctionType(node: object | null | undefined, opts?: object): void; +export function assertTSImportEqualsDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSIndexSignature(node: object | null | undefined, opts?: object): void; +export function assertTSIndexedAccessType(node: object | null | undefined, opts?: object): void; +export function assertTSInterfaceBody(node: object | null | undefined, opts?: object): void; +export function assertTSInterfaceDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSIntersectionType(node: object | null | undefined, opts?: object): void; +export function assertTSLiteralType(node: object | null | undefined, opts?: object): void; +export function assertTSMappedType(node: object | null | undefined, opts?: object): void; +export function assertTSMethodSignature(node: object | null | undefined, opts?: object): void; +export function assertTSModuleBlock(node: object | null | undefined, opts?: object): void; +export function assertTSModuleDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSNamespaceExportDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSNeverKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSNonNullExpression(node: object | null | undefined, opts?: object): void; +export function assertTSNullKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSNumberKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSObjectKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSParameterProperty(node: object | null | undefined, opts?: object): void; +export function assertTSParenthesizedType(node: object | null | undefined, opts?: object): void; +export function assertTSPropertySignature(node: object | null | undefined, opts?: object): void; +export function assertTSQualifiedName(node: object | null | undefined, opts?: object): void; +export function assertTSStringKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSSymbolKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSThisType(node: object | null | undefined, opts?: object): void; +export function assertTSTupleType(node: object | null | undefined, opts?: object): void; +export function assertTSTypeAliasDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTSTypeAssertion(node: object | null | undefined, opts?: object): void; +export function assertTSTypeLiteral(node: object | null | undefined, opts?: object): void; +export function assertTSTypeOperator(node: object | null | undefined, opts?: object): void; +export function assertTSTypeParameter(node: object | null | undefined, opts?: object): void; +export function assertTSTypeParameterDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSTypeParameterInstantiation(node: object | null | undefined, opts?: object): void; +export function assertTSTypePredicate(node: object | null | undefined, opts?: object): void; +export function assertTSTypeQuery(node: object | null | undefined, opts?: object): void; +export function assertTSTypeReference(node: object | null | undefined, opts?: object): void; +export function assertTSUndefinedKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSUnionType(node: object | null | undefined, opts?: object): void; +export function assertTSVoidKeyword(node: object | null | undefined, opts?: object): void; From 4b83beec687241113a92de87ef38aec80f1be50e Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Mon, 18 Feb 2019 18:09:07 -0500 Subject: [PATCH 038/222] Started updating type defs. Currently up to Path --- types/fabric/fabric-impl.d.ts | 1714 +++++++++++++++++++++++---------- 1 file changed, 1194 insertions(+), 520 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 5cc59d0941..10b487180f 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -103,7 +103,7 @@ export function log(...values: any[]): void; export function warn(...values: any[]): void; /////////////////////////////////////////////////////////////////////////////// -// Data Object Interfaces - These intrface are not specific part of fabric, +// Data Object Interfaces - These interface are not specific part of fabric, // They are just helpful for for defining function parameters ////////////////////////////////////////////////////////////////////////////// interface IDataURLOptions { @@ -135,6 +135,9 @@ interface IDataURLOptions { * Cropping height. Introduced in v1.2.14 */ height?: number; + enableRetinaScaling?: boolean; + withoutTransform?: boolean; + withoutShadow?: boolean; } interface IEvent { @@ -175,6 +178,14 @@ interface IToSVGOptions { * Encoding of SVG output */ encoding: string; + /** + * desired width of svg with or without units + */ + width: number; + /** + * desired height of svg with or without units + */ + height: number; } interface IViewBox { @@ -611,32 +622,44 @@ interface IPatternOptions { */ offsetY: number; /** - * The source for the pattern + * crossOrigin value (one of "", "anonymous", "use-credentials") + * @see https://developer.mozilla.org/en-US/docs/HTML/CORS_settings_attributes + * @type String + * @default */ - source: string | HTMLImageElement; - /** - * Transform matrix to change the pattern, imported from svgs - */ - patternTransform?: number[]; + crossOrigin: '' | 'anonymous' | 'use-credentials'; + /** + * Transform matrix to change the pattern, imported from svgs + */ + patternTransform?: number[]; } export interface Pattern extends IPatternOptions { } export class Pattern { constructor(options?: IPatternOptions); initialise(options?: IPatternOptions): Pattern; - /** - * Returns an instance of CanvasPattern - */ - toLive(ctx: CanvasRenderingContext2D): Pattern; /** * Returns object representation of a pattern + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of a pattern instance */ - toObject(): any; + toObject: any; + /** * Returns SVG representation of a pattern + * @param {fabric.Object} object + * @return {String} SVG representation of a pattern */ toSVG(object: Object): string; + + /** + * Returns an instance of CanvasPattern + * @param {CanvasRenderingContext2D} ctx Context to create pattern + * @return {CanvasPattern} + */ + toLive(ctx: CanvasRenderingContext2D): CanvasPattern; + } export class Point { @@ -647,152 +670,222 @@ export class Point { /** * Adds another point to this one and returns another one + * @param {fabric.Point} that + * @return {fabric.Point} new Point instance with added values */ add(that: Point): Point; /** * Adds another point to this one + * @param {fabric.Point} that + * @return {fabric.Point} thisArg + * @chainable */ addEquals(that: Point): Point; /** * Adds value to this point and returns a new one + * @param {Number} scalar + * @return {fabric.Point} new Point with added value */ scalarAdd(scalar: number): Point; /** * Adds value to this point + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ scalarAddEquals(scalar: number): Point; /** * Subtracts another point from this point and returns a new one + * @param {fabric.Point} that + * @return {fabric.Point} new Point object with subtracted values */ subtract(that: Point): Point; /** * Subtracts another point from this point + * @param {fabric.Point} that + * @return {fabric.Point} thisArg + * @chainable */ subtractEquals(that: Point): Point; /** * Subtracts value from this point and returns a new one + * @param {Number} scalar + * @return {fabric.Point} */ scalarSubtract(scalar: number): Point; /** * Subtracts value from this point + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ scalarSubtractEquals(scalar: number): Point; /** - * Miltiplies this point by a value and returns a new one + * Multiplies this point by a value and returns a new one + * @param {Number} scalar + * @return {fabric.Point} */ multiply(scalar: number): Point; /** - * Miltiplies this point by a value + * Multiplies this point by a value + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ multiplyEquals(scalar: number): Point; /** * Divides this point by a value and returns a new one + * @param {Number} scalar + * @return {fabric.Point} */ divide(scalar: number): Point; /** * Divides this point by a value + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ divideEquals(scalar: number): Point; /** * Returns true if this point is equal to another one + * @param {fabric.Point} that + * @return {Boolean} */ eq(that: Point): Point; /** * Returns true if this point is less than another one + * @param {fabric.Point} that + * @return {Boolean} */ lt(that: Point): Point; /** * Returns true if this point is less than or equal to another one + * @param {fabric.Point} that + * @return {Boolean} */ lte(that: Point): Point; /** * Returns true if this point is greater another one + * @param {fabric.Point} that + * @return {Boolean} */ gt(that: Point): Point; /** * Returns true if this point is greater than or equal to another one + * @param {fabric.Point} that + * @return {Boolean} */ gte(that: Point): Point; /** * Returns new point which is the result of linear interpolation with this one and another one + * @param {fabric.Point} that + * @param {Number} t , position of interpolation, between 0 and 1 default 0.5 + * @return {fabric.Point} */ lerp(that: Point, t: number): Point; /** * Returns distance from this point and another one + * @param {fabric.Point} that + * @return {Number} */ distanceFrom(that: Point): number; /** * Returns the point between this point and another one + * @param {fabric.Point} that + * @return {fabric.Point} */ midPointFrom(that: Point): Point; /** * Returns a new point which is the min of this and another one + * @param {fabric.Point} that + * @return {fabric.Point} */ min(that: Point): Point; /** * Returns a new point which is the max of this and another one + * @param {fabric.Point} that + * @return {fabric.Point} */ max(that: Point): Point; /** * Returns string representation of this point + * @return {String} */ toString(): string; /** * Sets x/y of this point + * @param {Number} x + * @param {Number} y + * @chainable */ setXY(x: number, y: number): Point; + /** + * Sets x of this point + * @param {Number} x + * @chainable + */ + setX(x: number): Point; + + /** + * Sets y of this point + * @param {Number} y + * @chainable + */ + setY(y: number): Point; + /** * Sets x/y of this point from another point + * @param {fabric.Point} that + * @chainable */ setFromPoint(that: Point): Point; /** * Swaps x/y of this point and another point + * @param {fabric.Point} that */ swap(that: Point): Point; + + /** + * return a cloned instance of the point + * @return {fabric.Point} + */ + clone(): Point; } interface IShadowOptions { - /** - * Whether the shadow should affect stroke operations - */ - affectStrike: boolean; - /** - * Shadow blur - */ - blur: number; /** * Shadow color */ color: string; /** - * Indicates whether toObject should include default values + * Shadow blur */ - includeDefaultValues: boolean; + blur: number; /** * Shadow horizontal offset */ @@ -801,29 +894,42 @@ interface IShadowOptions { * Shadow vertical offset */ offsetY: number; + /** + * Whether the shadow should affect stroke operations + */ + affectStrike: boolean; + /** + * Indicates whether toObject should include default values + */ + includeDefaultValues: boolean; } export interface Shadow extends IShadowOptions { } export class Shadow { - constructor(options?: IShadowOptions); + constructor(options?: IShadowOptions| string); initialize(options?: IShadowOptions | string): Shadow; /** * Returns object representation of a shadow + * @return {Object} Object representation of a shadow instance */ toObject(): any; /** - * Returns a string representation of an instance, CSS3 text-shadow declaration + * Returns a string representation of an instance + * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow + * @return {String} Returns CSS3 text-shadow declaration */ toString(): string; /** * Returns SVG representation of a shadow + * @param {fabric.Object} object + * @return {String} SVG representation of a shadow */ toSVG(object: Object): string; - /** - * Regex matching shadow offsetX, offsetY and blur, Static + * Regex matching shadow offsetX, offsetY and blur (ex: "2px 2px 10px rgba(0,0,0,0.2)", "rgb(0,255,0) 2px 2px") + * @static + * @field + * @memberOf fabric.Shadow */ - reOffsetsAndBlur: RegExp; - static reOffsetsAndBlur: RegExp; } @@ -852,162 +958,238 @@ interface ICanvasDimensionsOptions { } interface IStaticCanvasOptions { - /** - * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas - */ - allowTouchScrolling?: boolean; - - /** - * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens - */ - enableRetinaScaling?: boolean; - - /** - * Indicates whether this canvas will use image smoothing, this is on by default in browsers - */ - imageSmoothingEnabled?: boolean; - - /** - * Indicates whether objects should remain in current stack position when selected. - * When false objects are brought to top and rendered as part of the selection group - */ - preserveObjectStacking?: boolean; - - /** - * The transformation (in the format of Canvas transform) which focuses the viewport - */ - viewportTransform?: number[]; - - freeDrawingColor?: string; - freeDrawingLineWidth?: number; - /** * Background color of canvas instance. - * Should be set via setBackgroundColor + * Should be set via {@link fabric.StaticCanvas#setBackgroundColor}. + * @type {(String|fabric.Pattern)} */ backgroundColor?: string | Pattern; /** * Background image of canvas instance. - * Should be set via setBackgroundImage - * Backwards incompatibility note: The "backgroundImageOpacity" and "backgroundImageStretch" properties are deprecated since 1.3.9. + * Should be set via {@link fabric.StaticCanvas#setBackgroundImage}. + * Backwards incompatibility note: The "backgroundImageOpacity" + * and "backgroundImageStretch" properties are deprecated since 1.3.9. + * Use {@link fabric.Image#opacity}, {@link fabric.Image#width} and {@link fabric.Image#height}. + * since 2.4.0 image caching is active, please when putting an image as background, add to the + * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom + * vale. As an alternative you can disable image objectCaching + * @type fabric.Image */ - backgroundImage?: Image | string; - backgroundImageOpacity?: number; - backgroundImageStretch?: number; - /** - * Function that determines clipping of entire canvas area - * Being passed context as first argument. See clipping canvas area - */ - clipTo?(context: CanvasRenderingContext2D): void; - - /** - * Indicates whether object controls (borders/controls) are rendered above overlay image - */ - controlsAboveOverlay?: boolean; - - /** - * Indicates whether toObject/toDatalessObject should include default values - */ - includeDefaultValues?: boolean; + backgroundImage?: Image; /** * Overlay color of canvas instance. - * Should be set via setOverlayColor + * Should be set via {@link fabric.StaticCanvas#setOverlayColor} + * @since 1.3.9 + * @type {(String|fabric.Pattern)} */ overlayColor?: string | Pattern; /** * Overlay image of canvas instance. - * Should be set via setOverlayImage - * Backwards incompatibility note: The "overlayImageLeft" and "overlayImageTop" properties are deprecated since 1.3.9. + * Should be set via {@link fabric.StaticCanvas#setOverlayImage}. + * Backwards incompatibility note: The "overlayImageLeft" + * and "overlayImageTop" properties are deprecated since 1.3.9. + * Use {@link fabric.Image#left} and {@link fabric.Image#top}. + * since 2.4.0 image caching is active, please when putting an image as overlay, add to the + * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom + * vale. As an alternative you can disable image objectCaching + * @type fabric.Image */ overlayImage?: Image; - overlayImageLeft?: number; - overlayImageTop?: number; /** - * Indicates whether add, insertAt and remove should also re-render canvas. - * Disabling this option could give a great performance boost when adding/removing a lot of objects to/from canvas at once - * (followed by a manual rendering after addition/deletion) + * Indicates whether toObject/toDatalessObject should include default values + * if set to false, takes precedence over the object value. + * @type Boolean + */ + includeDefaultValues?: boolean; + /** + * Indicates whether objects' state should be saved + * @type Boolean + */ + stateful?: boolean; + /** + * Indicates whether {@link fabric.Collection.add}, {@link fabric.Collection.insertAt} and {@link fabric.Collection.remove}, + * {@link fabric.StaticCanvas.moveTo}, {@link fabric.StaticCanvas.clear} and many more, should also re-render canvas. + * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once + * since the renders are quequed and executed one per frame. + * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() ) + * Left default to true to do not break documentation and old app, fiddles. + * @type Boolean */ renderOnAddRemove?: boolean; /** - * Indicates whether objects' state should be saved + * Function that determines clipping of entire canvas area + * Being passed context as first argument. + * If you are using code minification, ctx argument can be minified/manglied you should use + * as a workaround `var ctx = arguments[0];` in the function; + * See clipping canvas area in {@link https://github.com/kangax/fabric.js/wiki/FAQ} + * @deprecated since 2.0.0 + * @type Function */ - stateful?: boolean; + clipTo?(context: CanvasRenderingContext2D): void; + /** + * Indicates whether object controls (borders/controls) are rendered above overlay image + * @type Boolean + */ + controlsAboveOverlay?: boolean; + /** + * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas + * @type Boolean + */ + allowTouchScrolling?: boolean; + /** + * Indicates whether this canvas will use image smoothing, this is on by default in browsers + */ + imageSmoothingEnabled?: boolean; + /** + * The transformation (in the format of Canvas transform) which focuses the viewport + */ + viewportTransform?: number[]; + /** + * if set to false background image is not affected by viewport transform + * @since 1.6.3 + * @type Boolean + */ + backgroundVpt?: boolean; + /** + * if set to false overlay image is not affected by viewport transform + * @since 1.6.3 + * @type Boolean + */ + overlayVpt?: boolean; + /** + * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens + * @type Boolean + */ + enableRetinaScaling?: boolean; + /** + * Describe canvas element extension over design + * properties are tl,tr,bl,br. + * if canvas is not zoomed/panned those points are the four corner of canvas + * if canvas is viewportTransformed you those points indicate the extension + * of canvas element in plain untrasformed coordinates + * The coordinates get updated with @method calcViewportBoundaries. + * @memberOf fabric.StaticCanvas.prototype + */ + vptCoords?: {tl: number, tr: number, bl: number, br: number} + /** + * Based on vptCoords and object.aCoords, skip rendering of objects that + * are not included in current viewport. + * May greatly help in applications with crowded canvas and use of zoom/pan + * If One of the corner of the bounding box of the object is on the canvas + * the objects get rendered. + * @memberOf fabric.StaticCanvas.prototype + * @type Boolean + */ + skipOffscreen?: boolean; + /** + * a fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the canvas has rendered, and the context is placed in the + * top left corner of the canvas. + * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true + * @type fabric.Object + */ + clipPath?: Object; + /** + * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, + * a zoomed canvas will then produce zoomed SVG output. + * @type Boolean + */ + svgViewportTransformation: boolean; } export interface StaticCanvas extends IObservable, IStaticCanvasOptions, ICollection, ICanvasAnimation { } export class StaticCanvas { /** * Constructor - * @param element element to initialize instance on - * @param [options] Options object + * @param {HTMLElement | String} el element to initialize instance on + * @param {Object} [options] Options object + * @return {Object} thisArg */ constructor(element: HTMLCanvasElement | string, options?: ICanvasOptions); /** * Calculates canvas element offset relative to the document * This method is also attached as "resize" event handler of window + * @return {fabric.Canvas} instance + * @chainable */ - calcOffset(): this; + calcOffset(): StaticCanvas; /** * Sets {@link fabric.StaticCanvas#overlayImage|overlay image} for this canvas - * @param image fabric.Image instance or URL of an image to set overlay to - * @param callback callback to invoke when image is loaded and set as an overlay - * @param [options] Optional options to set for the {@link fabric.Image|overlay image}. + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set overlay to + * @param {Function} callback callback to invoke when image is loaded and set as an overlay + * @param {Object} [options] Optional options to set for the {@link fabric.Image|overlay image}. + * @return {fabric.Canvas} thisArg + * @chainable */ - setOverlayImage(image: Image | string, callback: (img: HTMLImageElement) => void, options?: IImageOptions): this; + setOverlayImage(image: Image | string, callback: (img: HTMLImageElement | undefined) => void, options?: IImageOptions): StaticCanvas; /** * Sets {@link fabric.StaticCanvas#backgroundImage|background image} for this canvas - * @param image fabric.Image instance or URL of an image to set background to - * @param callback Callback to invoke when image is loaded and set as background - * @param [options] Optional options to set for the {@link fabric.Image|background image}. + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set background to + * @param {Function} callback Callback to invoke when image is loaded and set as background + * @param {Object} [options] Optional options to set for the {@link fabric.Image|background image}. + * @return {fabric.Canvas} thisArg + * @chainable */ - setBackgroundImage(image: Image | string, callback?: (img: HTMLImageElement) => void, options?: IImageOptions): this; + setBackgroundImage(image: Image | string, callback?: Function, options?: IImageOptions): StaticCanvas; /** - * Sets {@link fabric.StaticCanvas#overlayColor|background color} for this canvas - * @param overlayColor Color or pattern to set background color to - * @param callback Callback to invoke when background color is set + * Sets {@link fabric.StaticCanvas#overlayColor|foreground color} for this canvas + * @param {(String|fabric.Pattern)} overlayColor Color or pattern to set foreground color to + * @param {Function} callback Callback to invoke when foreground color is set + * @return {fabric.Canvas} thisArg + * @chainable */ - setOverlayColor(overlayColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): this; + setOverlayColor(overlayColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): StaticCanvas; /** * Sets {@link fabric.StaticCanvas#backgroundColor|background color} for this canvas - * @param backgroundColor Color or pattern to set background color to - * @param callback Callback to invoke when background color is set + * @param {(String|fabric.Pattern)} backgroundColor Color or pattern to set background color to + * @param {Function} callback Callback to invoke when background color is set + * @return {fabric.Canvas} thisArg + * @chainable */ setBackgroundColor(backgroundColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): StaticCanvas; /** * Returns canvas width (in px) + * @return {Number} */ getWidth(): number; /** * Returns canvas height (in px) + * @return {Number} */ getHeight(): number; /** * Sets width of this canvas instance - * @param value Value to set width to - * @param [options] Options object + * @param {Number|String} value Value to set width to + * @param {Object} [options] Options object + * @return {fabric.Canvas} instance + * @chainable true */ - setWidth(value: number | string, options?: ICanvasDimensionsOptions): this; + setWidth(value: number | string, options?: ICanvasDimensionsOptions): StaticCanvas; /** * Sets height of this canvas instance * @param value Value to set height to * @param [options] Options object + * @return {fabric.Canvas} instance + * @chainable true */ - setHeight(value: number | string, options?: ICanvasDimensionsOptions): this; + setHeight(value: number | string, options?: ICanvasDimensionsOptions): StaticCanvas; /** * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em) * @param dimensions Object with width/height properties * @param [options] Options object + * @return {fabric.Canvas} thisArg + * @chainable */ - setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): this; + setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): StaticCanvas; /** * Returns canvas zoom level @@ -1016,191 +1198,297 @@ export class StaticCanvas { /** * Sets viewport transform of this canvas instance - * @param vpt the transform in the form of context.transform + * @param {Array} vpt the transform in the form of context.transform + * @return {fabric.Canvas} instance + * @chainable */ - setViewportTransform(vpt: number[]): this; + setViewportTransform(vpt: number[]): StaticCanvas; /** * Sets zoom level of this canvas instance, zoom centered around point - * @param point to zoom with respect to - * @param value to set zoom to, less than 1 zooms out + * @param {fabric.Point} point to zoom with respect to + * @param {Number} value to set zoom to, less than 1 zooms out + * @return {fabric.Canvas} instance + * @chainable true */ - zoomToPoint(point: Point, value: number): this; + zoomToPoint(point: Point, value: number): StaticCanvas; /** * Sets zoom level of this canvas instance - * @param value to set zoom to, less than 1 zooms out + * @param {Number} value to set zoom to, less than 1 zooms out + * @return {fabric.Canvas} instance + * @chainable */ - setZoom(value: number): this; + setZoom(value: number): StaticCanvas; /** * Pan viewport so as to place point at top left corner of canvas - * @param point to move to + * @param {fabric.Point} point to move to + * @return {fabric.Canvas} instance + * @chainable */ - absolutePan(point: Point): this; + absolutePan(point: Point): StaticCanvas; /** * Pans viewpoint relatively - * @param point (position vector) to move by + * @param {fabric.Point} point (position vector) to move by + * @return {fabric.Canvas} instance + * @chainable */ - relativePan(point: Point): this; + relativePan(point: Point): StaticCanvas; /** * Returns element corresponding to this instance + * @return {HTMLCanvasElement} */ getElement(): HTMLCanvasElement; - /** - * Returns currently selected object, if any - */ - getActiveObject(): Object; - - /** - * Returns currently selected group of object, if any - */ - getActiveGroup(): Group; - /** * Clears specified context of canvas element * @param ctx Context to clear * @chainable */ - clearContext(ctx: CanvasRenderingContext2D): this; + clearContext(ctx: CanvasRenderingContext2D): StaticCanvas; /** * Returns context of canvas where objects are drawn + * @return {CanvasRenderingContext2D} */ getContext(): CanvasRenderingContext2D; /** * Clears all contexts (background, main, top) of an instance - */ - clear(): this; - - /** - * Renders both the top canvas and the secondary container canvas. - * @param [allOnTop] Whether we want to force all images to be rendered on the top canvas + * @return {fabric.Canvas} thisArg * @chainable */ - renderAll(allOnTop?: boolean): this; + clear(): StaticCanvas; /** - * Append a renderAll request to next animation frame. a boolean flag will avoid appending more. + * Renders the canvas + * @return {fabric.Canvas} instance * @chainable */ - requestRenderAll(): this; + renderAll(): StaticCanvas; /** - * Method to render only the top canvas. - * Also used to render the group selection box. + * Function created to be instance bound at initialization + * used in requestAnimationFrame rendering + * Let the fabricJS call it. If you call it manually you could have more + * animationFrame stacking on to of each other + * for an imperative rendering, use canvas.renderAll + * @private + * @return {fabric.Canvas} instance * @chainable */ - renderTop(): StaticCanvas; + renderAndReset(): StaticCanvas; + + /** + * Append a renderAll request to next animation frame. + * unless one is already in progress, in that case nothing is done + * a boolean flag will avoid appending more. + * @return {fabric.Canvas} instance + * @chainable + */ + requestRenderAll(): StaticCanvas; + + /** + * Calculate the position of the 4 corner of canvas with current viewportTransform. + * helps to determinate when an object is in the current rendering viewport using + * object absolute coordinates ( aCoords ) + * @return {Object} points.tl + * @chainable + */ + calcViewportBoundaries(): StaticCanvas; + + cancelRequestedRender(): void; + + /** + * Renders background, objects, overlay and controls. + * @param {CanvasRenderingContext2D} ctx + * @param {Array} objects to render + * @return {fabric.Canvas} instance + * @chainable + */ + renderCanvas(ctx: CanvasRenderingContext2D, objects: Object[] ): StaticCanvas; + + /** + * Paint the cached clipPath on the lowerCanvasEl + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawClipPathOnCanvas(ctx: CanvasRenderingContext2D): void; /** * Returns coordinates of a center of canvas. * Returned value is an object with top and left properties + * @return {Object} object with "top" and "left" number values */ getCenter(): { top: number; left: number; }; - /** - * Centers object horizontally. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param object Object to center horizontally - */ - centerObjectH(object: Object): this; /** - * Centers object vertically. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param object Object to center vertically + * Centers object horizontally in the canvas + * @param {fabric.Object} object Object to center horizontally + * @return {fabric.Canvas} thisArg */ - centerObjectV(object: Object): this; + centerObjectH(object: Object): StaticCanvas; /** - * Centers object vertically and horizontally. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param object Object to center vertically and horizontally + * Centers object vertically in the canvas + * @param {fabric.Object} object Object to center vertically + * @return {fabric.Canvas} thisArg + * @chainable */ - centerObject(object: Object): this; + centerObjectV(object: Object): StaticCanvas; + + /** + * Centers object vertically and horizontally in the canvas + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + centerObject(object: Object): StaticCanvas; + + /** + * Centers object vertically and horizontally in the viewport + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObject(object: Object): StaticCanvas; + + /** + * Centers object horizontally in the viewport, object.top is unchanged + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObjectH(object: Object): StaticCanvas; + + /** + * Centers object Vertically in the viewport, object.top is unchanged + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObjectV(object: Object): StaticCanvas; + + /** + * Calculate the point in canvas that correspond to the center of actual viewport. + * @return {fabric.Point} vpCenter, viewport center + */ + getVpCenter(): Point; /** * Returs dataless JSON representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {String} json string */ toDatalessJSON(propertiesToInclude?: string[]): string; /** * Returns object representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance */ toObject(propertiesToInclude?: string[]): any; /** * Returns dataless object representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance */ toDatalessObject(propertiesToInclude?: string[]): any; - /** - * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, - * a zoomed canvas will then produce zoomed SVG output. - */ - svgViewportTransformation: boolean; - /** * Returns SVG representation of canvas * @param [options] Options object for SVG output * @param [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation. + * @return {String} SVG string */ toSVG(options: IToSVGOptions, reviver?: Function): string; /** - * Moves an object to the bottom of the stack of drawn objects - * @param object Object to send to back + * Moves an object or the objects of a multiple selection + * to the bottom of the stack of drawn objects + * @param {fabric.Object} object Object to send to back + * @return {fabric.Canvas} thisArg * @chainable */ - sendToBack(object: Object): this; + sendToBack(object: Object): StaticCanvas; /** - * Moves an object to the top of the stack of drawn objects - * @param object Object to send + * Moves an object or the objects of a multiple selection + * to the top of the stack of drawn objects + * @param {fabric.Object} object Object to send + * @return {fabric.Canvas} thisArg * @chainable */ - bringToFront(object: Object): this; + bringToFront(object: Object): StaticCanvas; /** - * Moves an object down in stack of drawn objects - * @param object Object to send - * @param [intersecting] If `true`, send object behind next lower intersecting object + * Moves an object or a selection down in stack of drawn objects + * An optional paramter, intersecting allowes to move the object in behind + * the first intersecting object. Where intersection is calculated with + * bounding box. If no intersection is found, there will not be change in the + * stack. + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object + * @return {fabric.Canvas} thisArg * @chainable */ - sendBackwards(object: Object): this; + sendBackwards(object: Object, intersecting?: boolean): StaticCanvas; /** - * Moves an object up in stack of drawn objects - * @param object Object to send - * @param [intersecting] If `true`, send object in front of next upper intersecting object + * Moves an object or a selection up in stack of drawn objects + * An optional paramter, intersecting allowes to move the object in front + * of the first intersecting object. Where intersection is calculated with + * bounding box. If no intersection is found, there will not be change in the + * stack. + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object + * @return {fabric.Canvas} thisArg * @chainable */ - bringForward(object: Object): this; + bringForward(object: Object, intersecting?: boolean): StaticCanvas; + /** * Moves an object to specified level in stack of drawn objects - * @param object Object to send - * @param index Position to move to + * @param {fabric.Object} object Object to send + * @param {Number} index Position to move to + * @return {fabric.Canvas} thisArg * @chainable */ - moveTo(object: Object, index: number): this; + moveTo(object: Object, index: number): StaticCanvas; /** - * Clears a canvas element and removes all event listeners - */ - dispose(): this; + * Clears a canvas element and dispose objects + * @return {fabric.Canvas} thisArg + * @chainable */ + dispose(): StaticCanvas; /** * Returns a string representation of an instance + * @return {String} string representation of an instance */ toString(): string; + /** + * @static + * @type String + * @default + */ + static EMPTY_JSON: string; + + /** + * Provides a way to check support of some of the canvas methods + * (either those of HTMLCanvasElement itself, or rendering context) + * + * @param {String} methodName Method to check support for; + * Could be one of "setLineDash" + * @return {Boolean | null} `true` if method is supported (or at least exists), + * `null` if canvas element or context can not be initialized + */ + supports(methodName: "getImageData" | "toDataURL" | "toDataURLWithQuality" | "setLineDash"): boolean; + /** * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately * @param [options] Options object @@ -1208,29 +1496,17 @@ export class StaticCanvas { toDataURL(options?: IDataURLOptions): string; /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - * @return `true` if method is supported (or at least exists), null` if canvas element or context can not be initialized + * Returns JSON representation of canvas + * @param [propertiesToInclude] Any properties that you might want to additionally include in the output */ - supports(methodName: "getImageData" | "toDataURL" | "toDataURLWithQuality" | "setLineDash"): boolean; + static toJSON(propertiesToInclude?: string[]): string; - /** - * Populates canvas with data from the specified JSON. - * JSON format must conform to the one of toJSON formats - * @param json JSON string or object - * @param callback Callback, invoked when json is parsed - * and corresponding objects (e.g: {@link fabric.Image}) - * are initialized - * @param [reviver] Method for further parsing of JSON elements, called after each fabric object created. - */ - loadFromJSON(json: string | any, callback: () => void, reviver?: Function): this; /** * Clones canvas instance * @param [callback] Receives cloned instance as a first argument * @param [properties] Array of properties to include in the cloned canvas and children */ - clone(callback: (canvas: StaticCanvas) => void, properties?: string[]): void; + clone(callback: Function, properties?: string[]): void; /** * Clones canvas instance without cloning existing data. @@ -1238,48 +1514,26 @@ export class StaticCanvas { * but leaves data empty (so that you can populate it with your own) * @param [callback] Receives cloned instance as a first argument */ - cloneWithoutData(callback: (canvas: StaticCanvas) => void): void; - - /** - * Callback; invoked right before object is about to be scaled/rotated - */ - onBeforeScaleRotate(target: Object): void; - - // Functions from object straighten mixin - // -------------------------------------------------------------------------------------------------------------------------------- - - /** - * Straightens object, then rerenders canvas - * @param object Object to straighten - */ - straightenObject(object: Object): this; - - /** - * Same as straightenObject, but animated - * @param object Object to straighten - */ - fxStraightenObject(object: Object): this; - - static EMPTY_JSON: string; - /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - */ - static supports(methodName: "getImageData" | "toDataURL" | "toDataURLWithQuality" | "setLineDash"): boolean; - /** - * Returns JSON representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - static toJSON(propertiesToInclude?: string[]): string; + cloneWithoutData(callback: Function): void; } interface ICanvasOptions extends IStaticCanvasOptions { /** * When true, objects can be transformed by one side (unproportionally) + * @type Boolean */ uniScaleTransform?: boolean; + /** + * Indicates which key enable unproportional scaling + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + */ + uniScaleKey?: string; + /** * When true, objects use center point as the origin of scale transformation. * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). @@ -1292,6 +1546,28 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ centeredRotation?: boolean; + /** + * Indicates which key enable centered Transform + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + * @default + */ + centeredKey?: string; + + /** + * Indicates which key enable alternate action on corner + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + * @default + */ + altActionKey?: string; + /** * Indicates that canvas is interactive. This property should not be changed. */ @@ -1302,6 +1578,32 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ selection?: boolean; + /** + * Indicates which key or keys enable multiple click selection + * Pass value as a string or array of strings + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or empty or containing any other string that is not a modifier key + * feature is disabled. + * @since 1.6.2 + * @type String|Array + * @default + */ + selectionKey?: string; + + /** + * Indicates which key enable alternative selection + * in case of target overlapping with active object + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * For a series of reason that come from the general expectations on how + * things should work, this feature works only for preserveObjectStacking true. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled. + * @since 1.6.5 + * @type null|String + * @default + */ + altSelectionKey?: string; + /** * Color of selection */ @@ -1311,7 +1613,7 @@ interface ICanvasOptions extends IStaticCanvasOptions { * Default dash array pattern * If not empty the selection border is dashed */ - selectionDashArray?: any[]; + selectionDashArray?: number[]; /** * Color of the border of selection (usually slightly darker than color of selection itself) @@ -1323,6 +1625,13 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ selectionLineWidth?: number; + /** + * Select only shapes that are fully contained in the dragged selection rectangle. + * @type Boolean + * @default + */ + selectionFullyContained?: boolean; + /** * Default cursor value used when hovering over an object on canvas */ @@ -1348,6 +1657,14 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ rotationCursor?: string; + /** + * Cursor value used for disabled elements ( corners with disabled action ) + * @type String + * @since 2.0.0 + * @default + */ + notAllowedCursor?: string; + /** * Default element class that's given to wrapper (div) element of canvas */ @@ -1374,6 +1691,54 @@ interface ICanvasOptions extends IStaticCanvasOptions { * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas. */ isDrawingMode?: boolean; + + /** + * Indicates whether objects should remain in current stack position when selected. + * When false objects are brought to top and rendered as part of the selection group + * @type Boolean + */ + preserveObjectStacking?: boolean; + + /** + * Indicates the angle that an object will lock to while rotating. + * @type Number + * @since 1.6.7 + */ + snapAngle?: number; + + /** + * Indicates the distance from the snapAngle the rotation will lock to the snapAngle. + * When `null`, the snapThreshold will default to the snapAngle. + * @type null|Number + * @since 1.6.7 + * @default + */ + snapThreshold?: null | number; + + /** + * Indicates if the right click on canvas can output the context menu or not + * @type Boolean + * @since 1.6.5 + * @default + */ + stopContextMenu?: boolean; + + /** + * Indicates if the canvas can fire right click events + * @type Boolean + * @since 1.6.5 + * @default + */ + fireRightClick?: boolean; + + /** + * Indicates if the canvas can fire middle click events + * @type Boolean + * @since 1.7.8 + * @default + */ + fireMiddleClick?: boolean; + } export interface Canvas extends StaticCanvas { } export interface Canvas extends ICanvasOptions { } @@ -1386,106 +1751,129 @@ export class Canvas { constructor(element: HTMLCanvasElement | string, options?: ICanvasOptions); _objects: Object[]; - /** - * Checks if point is contained within an area of given object - * @param e Event object - * @param target Object to test against - */ - containsPoint(e: Event, target: Object): boolean; - /** - * Deactivates all objects on canvas, removing any active group or object - * @return thisArg - */ - deactivateAll(): Canvas; - /** - * Deactivates all objects and dispatches appropriate events - * @param [e] Event (passed along when firing) - * @return thisArg - */ - deactivateAllWithDispatch(e?: Event): Canvas; - /** - * Discards currently active group - * @param [e] Event (passed along when firing) - * @return thisArg - */ - discardActiveGroup(e?: Event): Canvas; - /** - * Discards currently active object - * @param [e] Event (passed along when firing) - * @return thisArg + * Renders both the top canvas and the secondary container canvas. + * @return {fabric.Canvas} instance * @chainable */ - discardActiveObject(e?: Event): Canvas; + renderAll(): Canvas; /** - * Draws objects' controls (borders/controls) - * @param ctx Context to render controls on + * Method to render only the top canvas. + * Also used to render the group selection box. + * @return {fabric.Canvas} thisArg + * @chainable */ - drawControls(ctx: CanvasRenderingContext2D): void; + renderTop(): Canvas; + /** + * Checks if point is contained within an area of given object + * @param {Event} e Event object + * @param {fabric.Object} target Object to test against + * @param {Object} [point] x,y object of point coordinates we want to check. + * @return {Boolean} true if point is contained within an area of given object + */ + containsPoint(e: Event, target: Object, point?: {x: number, y: number}): boolean; + /** + * Returns true if object is transparent at a certain location + * @param {fabric.Object} target Object to check + * @param {Number} x Left coordinate + * @param {Number} y Top coordinate + * @return {Boolean} + */ + isTargetTransparent(target: Object, x: number, y: number): boolean; + /** + * Set the cursor type of the canvas element + * @param {String} value Cursor type of the canvas element. + * @see http://www.w3.org/TR/css3-ui/#cursor + */ + setCursor(value: string): void; /** * Method that determines what object we are clicking on - * @param e mouse event - * @param skipGroup when true, group is skipped and only objects are traversed through + * the skipGroup parameter is for internal use, is needed for shift+click action + * @param {Event} e mouse event + * @param {Boolean} skipGroup when true, activeGroup is skipped and only objects are traversed through + * @return {fabric.Object} the target found */ - findTarget(e: MouseEvent, skipGroup: boolean): Canvas; + findTarget(e: MouseEvent, skipGroup: boolean): Object; /** - * Returns currently active group - * @return Current group + * Returns pointer coordinates without the effect of the viewport + * @param {Object} pointer with "x" and "y" number values + * @return {Object} object with "x" and "y" number values */ - getActiveGroup(): Group; - /** - * Returns currently active object - * @return active object - */ - getActiveObject(): Object; - /** - * Returns an array with the current selected objects - * @return {Object[]} array of active objects - */ - getActiveObjects(): Object[]; + restorePointerVpt(pointer: Point): any; /** * Returns pointer coordinates relative to canvas. - * @return object with "x" and "y" number values + * Can return coordinates with or without viewportTransform. + * ignoreZoom false gives back coordinates that represent + * the point clicked on canvas element. + * ignoreZoom true gives back coordinates after being processed + * by the viewportTransform ( sort of coordinates of what is displayed + * on the canvas where you are clicking. + * ignoreZoom true = HTMLElement coordinates relative to top,left + * ignoreZoom false, default = fabric space coordinates, the same used for shape position + * To interact with your shapes top and left you want to use ignoreZoom true + * most of the time, while ignoreZoom false will give you coordinates + * compatible with the object.oCoords system. + * of the time. + * @param {Event} e + * @param {Boolean} ignoreZoom + * @return {Object} object with "x" and "y" number values */ - getPointer(e: Event, ignoreZoom?: boolean, upperCanvasEl?: CanvasRenderingContext2D): { x: number; y: number; }; + getPointer(e: Event, ignoreZoom: boolean): { x: number; y: number; }; /** * Returns context of canvas where object selection is drawn + * @return {CanvasRenderingContext2D} */ getSelectionContext(): CanvasRenderingContext2D; /** * Returns element on which object selection is drawn + * @return {HTMLCanvasElement} */ getSelectionElement(): HTMLCanvasElement; /** - * Returns true if object is transparent at a certain location - * @param target Object to check - * @param x Left coordinate - * @param y Top coordinate + * Returns currently active object + * @return {fabric.Object} active object */ - isTargetTransparent(target: Object, x: number, y: number): boolean; + getActiveObject(): Object; /** - * Sets active group to a speicified one - * @param group Group to set as a current one - * @param [e] Event (passed along when firing) + * Returns an array with the current selected objects + * @return {fabric.Object} active object */ - setActiveGroup(group: Group, e?: Event): Canvas; + getActiveObjects(): Object[]; /** * Sets given object as the only active object on canvas - * @param object Object to set as an active one - * @param [e] Event (passed along when firing "object:selected") + * @param {fabric.Object} object Object to set as an active one + * @param {Event} [e] Event (passed along when firing "object:selected") + * @return {fabric.Canvas} thisArg + * @chainable */ setActiveObject(object: Object, e?: Event): Canvas; /** - * Set the cursor type of the canvas element - * @param value Cursor type of the canvas element. - * @see http://www.w3.org/TR/css3-ui/#cursor + * Discards currently active object and fire events. If the function is called by fabric + * as a consequence of a mouse event, the event is passed as a parameter and + * sent to the fire function for the custom events. When used as a method the + * e param does not have any application. + * @param {event} e + * @return {fabric.Canvas} thisArg + * @chainable */ - setCursor(value: string): void; - + discardActiveObject(e?: Event): Canvas; /** - * Removes all event listeners + * Clears a canvas element and removes all event listeners + * @return {fabric.Canvas} thisArg + * @chainable */ - removeListeners(): void; + dispose(): Canvas; + /** + * Clears all contexts (background, main, top) of an instance + * @return {fabric.Canvas} thisArg + * @chainable + */ + clear(): Canvas; + /** + * Draws objects' controls (borders/controls) + * @param {CanvasRenderingContext2D} ctx Context to render controls on + */ + drawControls(ctx: CanvasRenderingContext2D): void; static EMPTY_JSON: string; /** @@ -1514,7 +1902,6 @@ interface ICircleOptions extends IObjectOptions { * Start angle of the circle, moving clockwise */ startAngle?: number; - /** * End angle of the circle */ @@ -1639,82 +2026,114 @@ export class Group { * @param objects Group objects * @param [options] Options object */ - constructor(items?: any[], options?: IObjectOptions); - - activateAllObjects(): Group; + constructor(objects?: Object[], options?: IObjectOptions, isAlreadyGrouped?: boolean); + /** + * Returns string representation of a group + */ + toString(): string; /** * Adds an object to a group; Then recalculates group's dimension, position. * @return thisArg * @chainable */ addWithUpdate(object: Object): Group; - containsPoint(point: Point): boolean; - /** - * Destroys a group (restoring state of its objects) - * @return thisArg - * @chainable - */ - destroy(): Group; - /** - * make a group an active selection, remove the group from canvas - * the group has to be on canvas for this to work. - * @return {fabric.ActiveSelection} thisArg - * @chainable - */ - toActiveSelection(): ActiveSelection; - /** - * Checks whether this group was moved (since `saveCoords` was called last) - * @return true if an object was moved (since fabric.Group#saveCoords was called) - */ - hasMoved(): boolean; /** * Removes an object from a group; Then recalculates group's dimension, position. * @return thisArg * @chainable */ removeWithUpdate(object: Object): Group; + /** + * Returns object representation of an instance + * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return object representation of an instance + */ + toObject(propertiesToInclude?: string[]): any; + /** + * Returns object representation of an instance, in dataless mode. + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toDatalessObject(propertiesToInclude?: string[]): any; /** * Renders instance on a given context * @param ctx context to render instance on */ render(ctx: CanvasRenderingContext2D): void; /** - * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * @param object Zero or more fabric instances - * @return thisArg - * @chainable + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * @return {Boolean} */ - remove(...object: Object[]): Group; + shouldCache(): boolean; /** - * Saves coordinates of this instance (to be used together with `hasMoved`) - * @saveCoords - * @return thisArg + * Check if this object or a child object will cast a shadow + * @return {Boolean} + */ + willDrawShadow(): boolean; + /** + * Check if this group or its parent group are caching, recursively up + * @return {Boolean} + */ + isOnACache(): boolean; + /** + * Execute the drawing operation for an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawObject(ctx: CanvasRenderingContext2D): void; + /** + * Check if cache is dirty + */ + isCacheDirty(skipCanvas?: boolean): boolean; + /** + * Realises the transform from this group onto the supplied object + * i.e. it tells you what would happen if the supplied object was in + * the group, and then the group was destroyed. It mutates the supplied + * object. + * @param {fabric.Object} object + * @return {fabric.Object} transformedObject + */ + realizeTransform(object: Object): Object; + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg * @chainable */ - saveCoords(): Group; + destroy(): Group; + /** + * make a group an active selection, remove the group from canvas + * the group has to be on canvas for this to work. + * @return {fabric.ActiveSelection} thisArg + * @chainable + */ + toActiveSelection(): ActiveSelection; + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg + * @chainable + */ + ungroupOnCanvas(): Group; /** * Sets coordinates of all group objects * @return thisArg * @chainable */ setObjectsCoords(): Group; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns string represenation of a group - */ - toString(): string; /** * Returns svg representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; - + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG(reviver?: Function): string; /** * Returns {@link fabric.Group} instance from an object representation * @param object Object to create a group from @@ -1726,14 +2145,14 @@ export class Group { /////////////////////////////////////////////////////////////////////////////// // ActiveSelection ////////////////////////////////////////////////////////////////////////////// -export interface ActiveSelection extends Object, ICollection { } +export interface ActiveSelection extends Group, ICollection { } export class ActiveSelection { /** * Constructor * @param objects ActiveSelection objects * @param [options] Options object */ - constructor(items?: Object[], options?: IObjectOptions); + constructor(objects?: Object[], options?: IObjectOptions); /** * Change te activeSelection to a normal group, @@ -1742,14 +2161,6 @@ export class ActiveSelection { */ toGroup(): Group; - /** - * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * @param object Zero or more fabric instances - * @return thisArg - * @chainable - */ - remove(...object: Object[]): Group; - /** * Returns string represenation of a group */ @@ -1770,6 +2181,36 @@ interface IImageOptions extends IObjectOptions { */ crossOrigin?: string; + /** + * When calling {@link fabric.Image.getSrc}, return value from element src with `element.getAttribute('src')`. + * This allows for relative urls as image src. + * @since 2.7.0 + * @type Boolean + */ + srcFromAttribute?: boolean; + + /** + * minimum scale factor under which any resizeFilter is triggered to resize the image + * 0 will disable the automatic resize. 1 will trigger automatically always. + * number bigger than 1 are not implemented yet. + * @type Number + */ + minimumScaleTrigger?: number; + + /** + * Image crop in pixels from original image size. + * @since 2.0.0 + * @type Number + */ + cropX?: number; + + /** + * Image crop in pixels from original image size. + * @since 2.0.0 + * @type Number + */ + cropY?: number; + /** * AlignX value, part of preserveAspectRatio (one of "none", "mid", "min", "max") * This parameter defines how the picture is aligned to its viewport when image element width differs from image width. @@ -1804,41 +2245,11 @@ export class Image { constructor(element: HTMLImageElement, objObjects: IObjectOptions); initialize(element?: string | HTMLImageElement, options?: IImageOptions): void; - /** - * Applies filters assigned to this image (from "filters" array) or from filter param - * @param {Array} filters to be applied - * @return {thisArg} return the fabric.Image object - * @chainable - */ - applyFilters(filters?: IBaseFilter[]): Image; - /** - * Returns a clone of an instance - * @param callback Callback is invoked with a clone as a first argument - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - clone(callback?: Function, propertiesToInclude?: string[]): void; - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; /** * Returns image element which this instance if based on * @return Image element */ getElement(): HTMLImageElement; - /** - * Returns original size of an image - * @return Object with "width" and "height" properties - */ - getOriginalSize(): { width: number; height: number; }; - /** - * Returns source of an image - * @return Source of an image - */ - getSrc(): string; - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** * Sets image element for this instance to a specified one. * If filters defined they are applied to new image. @@ -1847,10 +2258,23 @@ export class Image { * @param [options] Options object */ setElement(element: HTMLImageElement, callback: Function, options: IImageOptions): Image; + /** + * Delete a single texture if in webgl mode + */ + removeTexture(key: any): void; + /** + * Delete textures, reference to elements and eventually JSDOM cleanup + */ + dispose(): void; /** * Sets crossOrigin value (on an instance and corresponding image element) */ setCrossOrigin(value: string): Image; + /** + * Returns original size of an image + * @return Object with "width" and "height" properties + */ + getOriginalSize(): { width: number; height: number; }; /** * Returns object representation of an instance * @param [propertiesToInclude] Any properties that you might want to additionally include in the output @@ -1858,37 +2282,76 @@ export class Image { */ toObject(propertiesToInclude?: string[]): any; /** - * Returns string representation of an instance - * @return String representation of an instance + * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,hight. + * @return {Boolean} */ - toString(): string; + hasCrop(): boolean; /** * Returns SVG representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; + /** + * Returns source of an image + * @return Source of an image + */ + getSrc(): string; /** * Sets source of an image - * @param src Source string (URL) - * @param [callback] Callback is invoked when image has been loaded (and all filters have been applied) - * @param [options] Options object + * @param {String} src Source string (URL) + * @param {Function} [callback] Callback is invoked when image has been loaded (and all filters have been applied) + * @param {Object} [options] Options object + * @return {fabric.Image} thisArg + * @chainable */ setSrc(src: string, callback?: Function, options?: IImageOptions): Image; - /** - * Creates an instance of fabric.Image from an URL string - * @param url URL to create an image from - * @param [callback] Callback to invoke when image is created (newly created image is passed as a first argument) - * @param [imgOptions] Options object + * Returns string representation of an instance + * @return String representation of an instance */ - static fromURL(url: string, callback?: (image: Image) => void, imgOptions?: IImageOptions): Image; + toString(): string; + applyResizeFilters(): void; + /** + * Applies filters assigned to this image (from "filters" array) or from filter param + * @param {Array} filters to be applied + * @return {thisArg} return the fabric.Image object + * @chainable + */ + applyFilters(filters?: IBaseFilter[]): Image; + /** + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * This is the special image version where we would like to avoid caching where possible. + * Essentially images do not benefit from caching. They may require caching, and in that + * case we do it. Also caching an image usually ends in a loss of details. + * A full performance audit should be done. + * @return {Boolean} + */ + shouldCache(): void; + /** + * Calculate offset for center and scale factor for the image in order to respect + * the preserveAspectRatio attribute + * @private + * @return {Object} + */ + parsePreserveAspectRatioAttribute(): any; /** * Creates an instance of fabric.Image from its object representation * @param object Object to create an instance from * @param [callback] Callback to invoke when an image instance is created */ static fromObject(object: any, callback: (image: Image) => void): void; + /** + * Creates an instance of fabric.Image from an URL string + * @param url URL to create an image from + * @param [callback] Callback to invoke when image is created (newly created image is passed as a first argument) + * @param [imgOptions] Options object + */ + static fromURL(url: string, callback?: Function, imgOptions?: IImageOptions): Image; /** * Returns Image instance from an SVG element * @param element Element to parse @@ -1900,7 +2363,6 @@ export class Image { * Default CSS class name for canvas */ static CSS_CANVAS: string; - static filters: IAllFilters; } @@ -1930,11 +2392,6 @@ export class Line { * @param [options] Options object */ constructor(points?: number[], objObjects?: IObjectOptions); - /** - * Returns complexity of an instance - * @return complexity - */ - complexity(): number; initialize(points?: number[], options?: ILineOptions): Line; /** * Returns object representation of an instance @@ -1949,8 +2406,6 @@ export class Line { * @return svg representation of an instance */ toSVG(reviver?: Function): string; - - static ATTRIBUTE_NAMES: string[]; /** * Returns fabric.Line instance from an SVG element * @param element Element to parse @@ -1962,8 +2417,8 @@ export class Line { * @param object Object to create an instance from */ static fromObject(object: any): Line; + static ATTRIBUTE_NAMES: string[]; } - interface IObjectOptions { /** * Type of an object (rect, circle, path, etc.). @@ -2012,17 +2467,7 @@ interface IObjectOptions { */ scaleY?: number; - /** - * Object skew factor (horizontal) - */ - skewX?: number; - - /** - * Object skew factor (vertical) - */ - skewY?: number; - - /** + /** * When true, an object is rendered as flipped horizontally */ flipX?: boolean; @@ -2042,6 +2487,21 @@ interface IObjectOptions { */ angle?: number; + /** + * Object skew factor (horizontal) + */ + skewX?: number; + + /** + * Object skew factor (vertical) + */ + skewY?: number; + + /** + * Size of object's controlling corners (in pixels) + */ + cornerSize?: number; + /** * When true, object's controlling corners are rendered as transparent inside (i.e. stroke instead of fill) */ @@ -2052,6 +2512,11 @@ interface IObjectOptions { */ hoverCursor?: string; + /** + * Default cursor value used when moving an object on canvas + */ + moveCursor?: string; + /** * Padding between object and its controlling borders (in pixels) */ @@ -2072,16 +2537,6 @@ interface IObjectOptions { */ cornerColor?: string; - /** - * Array specifying dash pattern of an object's control (hasBorder must be true) - */ - cornerDashArray?: number[]; - - /** - * Size of object's controlling corners (in pixels) - */ - cornerSize?: number; - /** * Color of controlling corners of an object (when it's active and transparentCorners false) */ @@ -2092,6 +2547,11 @@ interface IObjectOptions { */ cornerStyle?: "rect" | "circle"; + /** + * Array specifying dash pattern of an object's control (hasBorder must be true) + */ + cornerDashArray?: number[]; + /** * When true, this object will use center point as the origin of transformation * when being scaled via the controls. @@ -2129,9 +2589,11 @@ interface IObjectOptions { backgroundColor?: string; /** - * When `true`, object is cached on an additional canvas. + * Selection Background color of an object. colored layer behind the object when it is active. + * does not mix good with globalCompositeOperation methods. + * @type String */ - objectCaching?: boolean; + selectionBackgroundColor?: string; /** * When defined, an object is rendered via stroke and this property specifies its color @@ -2146,7 +2608,14 @@ interface IObjectOptions { /** * Array specifying dash pattern of an object's stroke (stroke must be defined) */ - strokeDashArray?: any[]; + strokeDashArray?: number[]; + + /** + * Line offset of an object's stroke + * @type Number + * @default + */ + strokeDashOffset?: number; /** * Line endings style of an object's stroke (one of "butt", "round", "square") @@ -2240,20 +2709,7 @@ interface IObjectOptions { */ clipTo?: Function; - /** - * A fabricObject that, without stroke define a clipping area with their shape. filled in black - * the clipPath object gets used when the object has rendered, and the context is placed in the center - * of the object cacheCanvas. - * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' - */ - clipPath?: Object; - - /** - * When set to `true`, object's cache will be rerendered next render call. - */ - dirty?: boolean; - - /** + /** * When `true`, object horizontal movement is locked */ lockMovementX?: boolean; @@ -2283,11 +2739,126 @@ interface IObjectOptions { */ lockUniScaling?: boolean; + /** + * When `true`, object horizontal skewing is locked + * @type Boolean + */ + lockSkewingX?: boolean; + + /** + * When `true`, object vertical skewing is locked + * @type Boolean + */ + lockSkewingY?: boolean; + /** * When `true`, object cannot be flipped by scaling into negative values */ lockScalingFlip?: boolean; + /** + * When `true`, object is not exported in OBJECT/JSON + * since 1.6.3 + * @type Boolean + * @default + */ + excludeFromExport?: boolean; + + /** + * When `true`, object is cached on an additional canvas. + */ + objectCaching?: boolean; + + /** + * When `true`, object properties are checked for cache invalidation. In some particular + * situation you may want this to be disabled ( spray brush, very big, groups) + * or if your application does not allow you to modify properties for groups child you want + * to disable it for groups. + * default to false + * since 1.7.0 + * @type Boolean + * @default false + */ + statefullCache?: boolean; + + /** + * When `true`, cache does not get updated during scaling. The picture will get blocky if scaled + * too much and will be redrawn with correct details at the end of scaling. + * this setting is performance and application dependant. + * default to true + * since 1.7.0 + * @type Boolean + */ + noScaleCache?: boolean; + + /** + * When `false`, the stoke width will scale with the object. + * When `true`, the stroke will always match the exact pixel size entered for stroke width. + * default to false + * @since 2.6.0 + * @type Boolean + * @default false + * @type Boolean + */ + strokeUniform?: boolean; + + /** + * When set to `true`, object's cache will be rerendered next render call. + */ + dirty?: boolean; + + /** + * Determines if the fill or the stroke is drawn first (one of "fill" or "stroke") + * @type String + */ + paintFirst?: string; + + /** + * List of properties to consider when checking if state + * of an object is changed (fabric.Object#hasStateChanged) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties?: string[]; + + /** + * List of properties to consider when checking if cache needs refresh + * Those properties are checked by statefullCache ON ( or lazy mode if we want ) or from single + * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty + * and refreshed at the next render + * @type Array + */ + cacheProperties?: string[]; + + /** + * A fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the object has rendered, and the context is placed in the center + * of the object cacheCanvas. + * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' + */ + clipPath?: Object; + + /** + * Meaningful ONLY when the object is used as clipPath. + * if true, the clipPath will make the object clip to the outside of the clipPath + * since 2.4.0 + * @type boolean + * @default false + */ + inverted?: boolean; + + /** + * Meaningful ONLY when the object is used as clipPath. + * if true, the clipPath will have its top and left relative to canvas, and will + * not be influenced by the object transform. This will make the clipPath relative + * to the canvas, but clipping just a particular object. + * WARNING this is beta, this feature may change or be renamed. + * since 2.4.0 + * @type boolean + * @default false + */ + absolutePositioned?: boolean; + /** * Not used by fabric, just for convenience */ @@ -2366,17 +2937,16 @@ export class Object { getWidth(): number; setWidth(value: number): Object; - /* * Sets object's properties from options - * @param {Object} [options] Options object - */ + /* Sets object's properties from options + * @param {Object} [options] Options object + */ setOptions(options: IObjectOptions): void; /** * Transforms context when rendering an object - * @param ctx Context - * @param fromLeft When true, context is transformed to object's top/left corner. This is used when rendering text on Node + * @param {CanvasRenderingContext2D} ctx Context */ - transform(ctx: CanvasRenderingContext2D, fromLeft: boolean): void; + transform(ctx: CanvasRenderingContext2D): void; /** * Returns an object representation of an instance @@ -2396,63 +2966,107 @@ export class Object { toString(): string; /** - * Basic getter - * @param property Property name + * Return the object scale factor counting also the group scaling, zoom and retina + * @return {Object} object with scaleX and scaleY properties */ - get(property: K): this[K]; + getTotalObjectScaling(): {scaleX: number, scaleY: number}; /** - * Sets property to a given value. - * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. - * If you need to update those, call `setCoords()`. - * @param key Property name - * @param value Property value (if function, the value is passed into it and its return value is used as a new one) + * Return the object opacity counting also the group property + * @return {Number} */ - set(key: K, value: this[K] | ((value: this[K]) => this[K])): this; - /** - * Sets property to a given value. - * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. - * If you need to update those, call `setCoords()`. - * @param options Property object, iterate over the object properties - */ - set(options: Partial): this; - - /** - * Toggles specified property from `true` to `false` or from `false` to `true` - * @param property Property to toggle - */ - toggle(property: keyof this): this; - - /** - * Sets sourcePath of an object - * @param value Value to set sourcePath to - */ - setSourcePath(value: string): this; + getObjectOpacity(): number; /** * Retrieves viewportTransform from Object's canvas if possible */ - getViewportTransform(): boolean; + getViewportTransform(): any; /** * Renders an object on a specified context - * @param ctx Context to render on - * @param [noTransform] When true, context is not transformed + * @param {CanvasRenderingContext2D} ctx Context to render on */ - render(ctx: CanvasRenderingContext2D, noTransform?: boolean): void; + render(ctx: CanvasRenderingContext2D): void; + + /** + * When set to `true`, force the object to have its own cache, even if it is inside a group + * it may be needed when your object behave in a particular way on the cache and always needs + * its own isolated canvas to render correctly. + * Created to be overridden + * since 1.7.12 + * @returns false + */ + needsItsOwnCache(): boolean; + + /** + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * @return {Boolean} + */ + shouldCache(): boolean; + + /** + * Check if this object or a child object will cast a shadow + * used by Group.shouldCache to know if child has a shadow recursively + * @return {Boolean} + */ + willDrawShadow(): boolean; + + /** + * Execute the drawing operation for an object clipPath + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawClipPathOnCache(ctx: CanvasRenderingContext2D): void; + + /** + * Execute the drawing operation for an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawObject(ctx: CanvasRenderingContext2D): void; + + /** + * Paint the cached copy of the object on the target context. + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawCacheOnCanvas(ctx: CanvasRenderingContext2D): void; + + /** + * Check if cache is dirty + * @param {Boolean} skipCanvas skip canvas checks because this object is painted + * on parent canvas. + */ + isCacheDirty(): boolean; /** * Clones an instance, using a callback method will work for every object. * @param callback Callback is invoked with a clone as a first argument * @param [propertiesToInclude] Any properties that you might want to additionally include in the output */ - clone(callback: (clone: Object) => void, propertiesToInclude?: string[]): void; + clone(callback: Function, propertiesToInclude?: string[]): void; /** * Creates an instance of fabric.Image out of an object * @param callback callback, invoked with an instance as a first argument */ - cloneAsImage(callback: (image: Image) => void): this; + cloneAsImage(callback: Function, options?: IDataURLOptions): Object; + + /** + * Converts an object into a HTMLCanvas element + * @param {Object} options Options object + * @param {Number} [options.multiplier=1] Multiplier to scale by + * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14 + * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14 + * @param {Number} [options.width] Cropping width. Introduced in v1.2.14 + * @param {Number} [options.height] Cropping height. Introduced in v1.2.14 + * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4 + * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 + * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2 + * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format + */ + toCanvasElement(options?: IDataURLOptions): string; /** * Converts an object into a data-url-like string @@ -2483,59 +3097,73 @@ export class Object { * @param property Property name 'stroke' or 'fill' * @param [options] Options object */ - setGradient(property: "stroke" | "fill", options: IGradientOptions): this; + setGradient(property: "stroke" | "fill", options: IGradientOptions): Object; + /** * Sets pattern fill of an object * @param options Options object */ - setPatternFill(options: IFillOptions): this; + setPatternFill(options: IFillOptions): Object; /** * Sets shadow of an object * @param [options] Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)") */ - setShadow(options?: string | Shadow): this; + setShadow(options?: string | Shadow): Object; /** * Sets "color" of an instance (alias of `set('fill', …)`) * @param color Color value */ - setColor(color: string): this; + setColor(color: string): Object; /** * Sets "angle" of an instance * @param angle Angle value */ - setAngle(angle: number): this; - - /** - * Sets "angle" of an instance - * @param angle Angle value - */ - rotate(angle: number): this; + rotate(angle: number): Object; /** * Centers object horizontally on canvas to which it was added last. * You might need to call `setCoords` on an object after centering, to update controls area. */ - centerH(): this; + centerH(): Object; + + /** + * Centers object horizontally on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenterH(): Object; /** * Centers object vertically on canvas to which it was added last. * You might need to call `setCoords` on an object after centering, to update controls area. */ - centerV(): this; + centerV(): Object; + + /** + * Centers object vertically on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenterV(): Object; /** * Centers object vertically and horizontally on canvas to which is was added last * You might need to call `setCoords` on an object after centering, to update controls area. */ - center(): this; + center(): Object; /** - * Removes object from canvas to which it was added last + * Centers object on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable */ - remove(): Object; + viewportCenter(): Object; /** * Returns coordinates of a pointer relative to an object @@ -2544,6 +3172,52 @@ export class Object { */ getLocalPointer(e: Event, pointer?: { x: number, y: number }): { x: number, y: number }; + /** + * Basic getter + * @param property Property name + */ + get(property: K): this[K]; + + /** + * Sets property to a given value. + * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. + * If you need to update those, call `setCoords()`. + * @param key Property name + * @param value Property value (if function, the value is passed into it and its return value is used as a new one) + */ + set(key: K, value: this[K] | ((value: this[K]) => this[K])): Object; + + /** + * Sets property to a given value. + * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. + * If you need to update those, call `setCoords()`. + * @param options Property object, iterate over the object properties + */ + set(options: Partial): Object; + + /** + * Toggles specified property from `true` to `false` or from `false` to `true` + * @param property Property to toggle + */ + toggle(property: keyof this): Object; + + /** + * Sets sourcePath of an object + * @param value Value to set sourcePath to + */ + setSourcePath(value: string): Object; + + /** + * Sets "angle" of an instance + * @param angle Angle value + */ + setAngle(angle: number): Object; + + /** + * Removes object from canvas to which it was added last + */ + remove(): Object; + /** * Sets object's properties from options * @param [options] Options object @@ -2580,21 +3254,21 @@ export class Object { * @param [options] Object with additional `stateProperties` array to include when saving state * @return thisArg */ - saveState(options?: { stateProperties: any[] }): this; + saveState(options?: { stateProperties: any[] }): Object; /** * Setups state of an object */ - setupState(): this; + setupState(): Object; // functions from object straightening mixin // ----------------------------------------------------------------------------------------------------------------------------------- /** * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) */ - straighten(): this; + straighten(): Object; /** * Same as straighten but with animation */ - fxStraighten(callbacks: Callbacks): this; + fxStraighten(callbacks: Callbacks): Object; // functions from object stacking mixin // ----------------------------------------------------------------------------------------------------------------------------------- @@ -2602,25 +3276,25 @@ export class Object { * Moves an object up in stack of drawn objects * @param [intersecting] If `true`, send object in front of next upper intersecting object */ - bringForward(intersecting?: boolean): this; + bringForward(intersecting?: boolean): Object; /** * Moves an object to the top of the stack of drawn objects */ - bringToFront(): this; + bringToFront(): Object; /** * Moves an object down in stack of drawn objects * @param [intersecting] If `true`, send object behind next lower intersecting object */ - sendBackwards(intersecting?: boolean): this; + sendBackwards(intersecting?: boolean): Object; /** * Moves an object to the bottom of the stack of drawn objects */ - sendToBack(): this; + sendToBack(): Object; /** * Moves an object to specified level in stack of drawn objects * @param index New position of object */ - moveTo(index: number): this; + moveTo(index: number): Object; // functions from object origin mixin // ----------------------------------------------------------------------------------------------------------------------------------- @@ -2680,7 +3354,7 @@ export class Object { * Requires public options: padding, borderColor * @param ctx Context to draw on */ - drawBorders(context: CanvasRenderingContext2D): this; + drawBorders(context: CanvasRenderingContext2D): Object; /** * Draws corners of an object's bounding box. @@ -2700,7 +3374,7 @@ export class Object { * @param controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. * @param visible true to set the specified control visible, false otherwise */ - setControlVisible(controlName: string, visible: boolean): this; + setControlVisible(controlName: string, visible: boolean): Object; /** * Sets the visibility state of object controls. @@ -2724,7 +3398,7 @@ export class Object { * Sets corner position coordinates based on current angle, width and height * See https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords */ - setCoords(): this; + setCoords(): Object; /** * Returns coordinates of object's bounding rectangle (left, top, width, height) * @param absoluteopt use coordinates without viewportTransform @@ -2753,17 +3427,17 @@ export class Object { * @param value Scale factor * @return thisArg */ - scale(value: number): this; + scale(value: number): Object; /** * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) * @param value New height value */ - scaleToHeight(value: number): this; + scaleToHeight(value: number): Object; /** * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) * @param value New width value */ - scaleToWidth(value: number): this; + scaleToWidth(value: number): Object; /** * Checks if object intersects with another object * @param other Object to test From cf300431381ba6183464d59447e1fce2abecfc36 Mon Sep 17 00:00:00 2001 From: antoinebrault Date: Mon, 18 Feb 2019 20:39:22 -0500 Subject: [PATCH 039/222] [jest] support optional methods/properties from interfaces in spyOn --- types/jest/index.d.ts | 7 ++++--- types/jest/jest-tests.ts | 41 ++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index f0382d2cb5..437c524e94 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -220,9 +220,10 @@ declare namespace jest { * spy.mockRestore(); * }); */ - function spyOn>(object: T, method: M, accessType: 'get'): SpyInstance; - function spyOn>(object: T, method: M, accessType: 'set'): SpyInstance; - function spyOn>(object: T, method: M): T[M] extends (...args: any[]) => any ? SpyInstance, ArgsType> : never; + function spyOn>>(object: T, method: M, accessType: 'get'): SpyInstance[M], []>; + function spyOn>>(object: T, method: M, accessType: 'set'): SpyInstance[M]]>; + function spyOn>>(object: T, method: M): Required[M] extends (...args: any[]) => any ? + SpyInstance[M]>, ArgsType[M]>> : never; /** * Indicates that the module system should never return a mocked version of * the specified module from require() (e.g. that it should always return the real module). diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 41f011c2f2..93ba9980f6 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -349,21 +349,15 @@ const mockContextVoid = jest.fn().mock; const mockContextString = jest.fn(() => "").mock; jest.fn().mockClear(); - jest.fn().mockReset(); - jest.fn().mockRestore(); +jest.fn().mockImplementation((test: number) => test); +jest.fn().mockResolvedValue(1); -const spiedTarget = { - returnsVoid(): void { }, - setValue(value: string): void { - this.value = value; - }, - returnsString(): string { - return ""; - } -}; - +interface SpyInterface { + prop?: number; + method?: (arg1: boolean) => void; +} class SpiedTargetClass { private _value = 3; private _value2 = ''; @@ -380,6 +374,15 @@ class SpiedTargetClass { this._value2 = value2; } } +const spiedTarget = { + returnsVoid(): void { }, + setValue(value: string): void { + this.value = value; + }, + returnsString(): string { + return ""; + } +}; const spiedTarget2 = new SpiedTargetClass(); // $ExpectError @@ -425,11 +428,17 @@ const spy5 = jest.spyOn(spiedTarget2, "value", "get"); spy5.mockReturnValue('5'); // $ExpectType SpyInstance -const spy6 = jest.spyOn(spiedTarget2, "value", "set"); +jest.spyOn(spiedTarget2, "value", "set"); -// should compile -jest.fn().mockImplementation((test: number) => test); -jest.fn().mockResolvedValue(1); +let spyInterfaceImpl: SpyInterface = {}; +// $ExpectError +jest.spyOn(spyInterfaceImpl, "method", "get"); +// $ExpectError +jest.spyOn(spyInterfaceImpl, "prop"); +// $ExpectType SpyInstance +jest.spyOn(spyInterfaceImpl, "prop", "get"); +// $ExpectType SpyInstance +jest.spyOn(spyInterfaceImpl, "method"); interface Type1 { a: number; } interface Type2 { b: number; } From 160a16e3f2cd06ef61f1904b2439d42a291afcc3 Mon Sep 17 00:00:00 2001 From: Allan Guigou Date: Tue, 19 Feb 2019 11:53:41 -0500 Subject: [PATCH 040/222] Add optional vmapAdsRequest field to MediaInformation definition --- types/chromecast-caf-receiver/cast.framework.messages.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/chromecast-caf-receiver/cast.framework.messages.d.ts b/types/chromecast-caf-receiver/cast.framework.messages.d.ts index 1846fd4840..b6e66ff4db 100644 --- a/types/chromecast-caf-receiver/cast.framework.messages.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.messages.d.ts @@ -1441,6 +1441,12 @@ export interface MediaInformation { * The media tracks. */ tracks?: Track[]; + + /** + * VMAP ad request configuration. Used if breaks and breakClips are not + * provided. + */ + vmapAdsRequest?: VastAdsRequest; } /** From 207c59c3c323381ae4586d90bc2d91c732cc1f08 Mon Sep 17 00:00:00 2001 From: Gordon Date: Tue, 19 Feb 2019 11:16:20 -0600 Subject: [PATCH 041/222] Set default doc type --- types/react-instantsearch-core/index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index 68bebdee9f..b48c2a9689 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -186,7 +186,7 @@ export interface AutocompleteExposed { // tslint:disable-next-line:no-unnecessary-generics export function connectAutoComplete(stateless: React.StatelessComponent>): React.ComponentClass; -export function connectAutoComplete, TDoc>(Composed: React.ComponentType): +export function connectAutoComplete, TDoc = BasicDoc>(Composed: React.ComponentType): ConnectedComponentClass, AutocompleteExposed>; export function connectBreadcrumb(Composed: React.ComponentType): React.ComponentClass; @@ -511,8 +511,10 @@ export interface StateResultsProvided { * * https://community.algolia.com/react-instantsearch/connectors/connectStateResults.html */ -export function connectStateResults(stateless: React.StatelessComponent): React.ComponentClass; -export function connectStateResults>, TDoc>(ctor: React.ComponentType): ConnectedComponentClass>; +export function connectStateResults( + stateless: React.StatelessComponent>): React.ComponentClass; +export function connectStateResults>, TDoc = BasicDoc>( + ctor: React.ComponentType): ConnectedComponentClass>; interface StatsProvided { nbHits: number; From 85bde30b8678d3d050c7b3b79d95ea0e8de7bf61 Mon Sep 17 00:00:00 2001 From: Gordon Date: Tue, 19 Feb 2019 11:55:49 -0600 Subject: [PATCH 042/222] Fix type inference for connectStateResults --- types/react-instantsearch-core/index.d.ts | 8 ++-- .../react-instantsearch-core-tests.tsx | 38 ++++++++++++++----- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index b48c2a9689..0f2ec9ce61 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -511,10 +511,10 @@ export interface StateResultsProvided { * * https://community.algolia.com/react-instantsearch/connectors/connectStateResults.html */ -export function connectStateResults( - stateless: React.StatelessComponent>): React.ComponentClass; -export function connectStateResults>, TDoc = BasicDoc>( - ctor: React.ComponentType): ConnectedComponentClass>; +export function connectStateResults( + stateless: React.StatelessComponent): React.ComponentClass; +export function connectStateResults>>( + ctor: React.ComponentType): ConnectedComponentClass; interface StatsProvided { nbHits: number; diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index 09bab5af15..c115873470 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -21,7 +21,8 @@ import { Hit, TranslatableProvided, translatable, - ConnectorProvided + ConnectorProvided, + StateResultsProvided } from 'react-instantsearch-core'; () => { @@ -209,18 +210,35 @@ import { }; () => { + interface MyDoc { + field1: string; + field2: number; + field3: { compound: string }; + } + interface StateResultsProps { - searchResults: SearchResults<{ - field1: string - field2: number - field3: { compound: string } - }>; + searchResults: SearchResults; // partial of StateResultsProvided additionalProp: string; } - const Stateless = ({ additionalProp, searchResults }: StateResultsProps) => + const Stateless = connectStateResults( + ({ + searchResults, + additionalProp, // $ExpectError + }) => (
+

{additionalProp}

+ {searchResults.hits.map((h) => { + return {h._highlightResult.field1!.value}; + })} +
) + ); + + ; + ; // $ExpectError + + const StatelessWithType = ({ additionalProp, searchResults }: StateResultsProps) =>

{additionalProp}

{searchResults.hits.map((h) => { @@ -229,11 +247,11 @@ import { return {compound}; })}
; - const ComposedStateless = connectStateResults(Stateless); + const ComposedStatelessWithType = connectStateResults(StatelessWithType); - ; // $ExpectError + ; // $ExpectError - ; + ; class MyComponent extends React.Component { render() { From a6fd6b6257dfb88dc27bdddbfde8a9f85dd02c9a Mon Sep 17 00:00:00 2001 From: Elizabeth Samuel Date: Tue, 19 Feb 2019 11:02:31 -0800 Subject: [PATCH 043/222] [office-js] [office-js-preview] (Outlook preview) Add LocationChanged event --- types/office-js-preview/index.d.ts | 114 +++++++++++++++++++--------- types/office-js/index.d.ts | 116 ++++++++++++++++++++--------- 2 files changed, 157 insertions(+), 73 deletions(-) diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index 45e991646f..38d55380c4 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -2051,6 +2051,12 @@ declare namespace Office { * [Api set: Mailbox 1.5] */ ItemChanged, + /** + * Triggers when the appointment location is changed in Outlook. + * + * [Api set: Mailbox Preview] + */ + LocationChanged, /** * Triggers when a customXmlPart node is deleted. */ @@ -12400,7 +12406,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12424,7 +12431,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12446,7 +12454,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12874,7 +12883,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12896,7 +12906,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12916,7 +12927,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13459,7 +13471,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13483,7 +13496,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13505,7 +13519,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13960,7 +13975,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13982,7 +13998,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14002,7 +14019,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14103,7 +14121,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14128,7 +14147,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14151,7 +14171,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14418,7 +14439,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14441,7 +14463,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14462,7 +14485,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16104,7 +16128,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16128,7 +16153,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16150,7 +16176,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16588,7 +16615,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16610,7 +16638,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16630,7 +16659,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17190,7 +17220,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17214,7 +17245,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17236,7 +17268,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17697,7 +17730,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17719,7 +17753,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17739,7 +17774,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -18033,7 +18069,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18055,7 +18092,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18076,7 +18114,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18570,7 +18609,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18590,7 +18630,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18609,7 +18650,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index d6aef3d1c9..f72fea1656 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -2051,6 +2051,12 @@ declare namespace Office { * [Api set: Mailbox 1.5] */ ItemChanged, + /** + * Triggers when the appointment location is changed in Outlook. + * + * [Api set: Mailbox Preview] + */ + LocationChanged, /** * Triggers when a customXmlPart node is deleted. */ @@ -12399,8 +12405,9 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12424,7 +12431,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12446,7 +12454,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12874,7 +12883,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12896,7 +12906,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12916,7 +12927,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13459,7 +13471,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13483,7 +13496,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13505,7 +13519,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13960,7 +13975,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13982,7 +13998,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14002,7 +14019,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14103,7 +14121,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14128,7 +14147,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14151,7 +14171,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14418,7 +14439,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14441,7 +14463,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14462,7 +14485,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16104,7 +16128,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16128,7 +16153,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16150,7 +16176,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16588,7 +16615,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16610,7 +16638,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16630,7 +16659,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17190,7 +17220,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17214,7 +17245,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17236,7 +17268,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17697,7 +17730,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17719,7 +17753,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17739,7 +17774,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -18033,7 +18069,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18055,7 +18092,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18076,7 +18114,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18570,7 +18609,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18590,7 +18630,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -18609,7 +18650,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * From fdafa9747715b6feb07d960e0b1d499a9839b175 Mon Sep 17 00:00:00 2001 From: Elizabeth Samuel Date: Tue, 19 Feb 2019 12:26:18 -0800 Subject: [PATCH 044/222] Update event name --- types/office-js-preview/index.d.ts | 62 +++++++++++++++--------------- types/office-js/index.d.ts | 62 +++++++++++++++--------------- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index 38d55380c4..48756495bf 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -2056,7 +2056,7 @@ declare namespace Office { * * [Api set: Mailbox Preview] */ - LocationChanged, + EnhancedLocationsChanged, /** * Triggers when a customXmlPart node is deleted. */ @@ -12407,7 +12407,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12432,7 +12432,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12455,7 +12455,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12884,7 +12884,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12907,7 +12907,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12928,7 +12928,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13472,7 +13472,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13497,7 +13497,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13520,7 +13520,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13976,7 +13976,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13999,7 +13999,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14020,7 +14020,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14122,7 +14122,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14148,7 +14148,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14172,7 +14172,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14440,7 +14440,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14464,7 +14464,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14486,7 +14486,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16129,7 +16129,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16154,7 +16154,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16177,7 +16177,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16616,7 +16616,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16639,7 +16639,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16660,7 +16660,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17221,7 +17221,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17246,7 +17246,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17269,7 +17269,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17731,7 +17731,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17754,7 +17754,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17775,7 +17775,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index f72fea1656..7953bdd7c0 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -2056,7 +2056,7 @@ declare namespace Office { * * [Api set: Mailbox Preview] */ - LocationChanged, + EnhancedLocationsChanged, /** * Triggers when a customXmlPart node is deleted. */ @@ -12407,7 +12407,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12432,7 +12432,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12455,7 +12455,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12884,7 +12884,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12907,7 +12907,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12928,7 +12928,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13472,7 +13472,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13497,7 +13497,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13520,7 +13520,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13976,7 +13976,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13999,7 +13999,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14020,7 +14020,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14122,7 +14122,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14148,7 +14148,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14172,7 +14172,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14440,7 +14440,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14464,7 +14464,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14486,7 +14486,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16129,7 +16129,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16154,7 +16154,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16177,7 +16177,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16616,7 +16616,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16639,7 +16639,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16660,7 +16660,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17221,7 +17221,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17246,7 +17246,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17269,7 +17269,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17731,7 +17731,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17754,7 +17754,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -17775,7 +17775,7 @@ declare namespace Office { * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and * `Office.EventType.RecurrenceChanged`. - * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.LocationChanged` are also supported. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * From 57aff49fde01c44ba3423479213bef0ffa61b9dd Mon Sep 17 00:00:00 2001 From: Gordon Date: Tue, 19 Feb 2019 15:36:29 -0600 Subject: [PATCH 045/222] Fix createConnector getProvidedProps 3rd param --- types/react-instantsearch-core/index.d.ts | 20 +++++++- .../react-instantsearch-core-tests.tsx | 46 ++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index 0f2ec9ce61..a4bc0b194a 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -32,6 +32,14 @@ export function createInstantSearch( */ export function createIndex(defaultRoot: object): React.ComponentClass; +export interface ConnectorSearchResults { + results: AllSearchResults; + searching: boolean; + searchingForFacetValues: boolean; + isSearchStalled: boolean; + error: any; +} + export interface ConnectorDescription { displayName: string; propTypes?: any; @@ -50,7 +58,7 @@ export interface ConnectorDescription { this: React.Component, props: TExposed, searchState: SearchState, - searchResults: SearchResults, + searchResults: ConnectorSearchResults, metadata: any, resultsFacetValues: any, ): TProvided; @@ -495,7 +503,7 @@ export interface StateResultsProvided { */ searchResults: SearchResults; /** In case of multiple indices you can retrieve all the results */ - allSearchResults: { [index: string]: SearchResults }; + allSearchResults: AllSearchResults; /** If there is a search in progress. */ searching: boolean; /** Flag that indicates if React InstantSearch has detected that searches are stalled. */ @@ -616,6 +624,14 @@ export interface SearchResults { automaticRadius?: string; } +/** + * The shape of the searchResults object when used in a multi-index search + * https://community.algolia.com/react-instantsearch/connectors/connectStateResults.html#default-props-entry-connectStateResults-searchResults + */ +export type AllSearchResults = { + [index: string]: SearchResults; +} & SearchResults; + /** * All the records that match the search parameters. * Each record is augmented with a new attribute `_highlightResult` which is an diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index c115873470..76cc26f2a4 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -22,7 +22,10 @@ import { TranslatableProvided, translatable, ConnectorProvided, - StateResultsProvided + StateResultsProvided, + ConnectorSearchResults, + BasicDoc, + AllSearchResults } from 'react-instantsearch-core'; () => { @@ -662,3 +665,44 @@ import * as Autosuggest from 'react-autosuggest'; onSubmit={(evt) => { console.log('submitted', evt); }} />; }; + +// can we recreate connectStateResults from source using the createConnector typedef? +() => { + function getIndexId(context: any): string { + return context && context.multiIndexContext + ? context.multiIndexContext.targetedIndex + : context.ais.mainTargetedIndex; + } + + function getResults(searchResults: { results: AllSearchResults }, context: any): SearchResults | null | undefined { + const {results} = searchResults; + if (results && !results.hits) { + return results[getIndexId(context)] + ? results[getIndexId(context)] + : null; + } else { + return results ? results : null; + } + } + + const csr = createConnector({ + displayName: 'AlgoliaStateResults', + + getProvidedProps(props, searchState, searchResults) { + const results = getResults(searchResults, this.context); + + return { + searchState, + searchResults: results, + allSearchResults: searchResults.results, + searching: searchResults.searching, + isSearchStalled: searchResults.isSearchStalled, + error: searchResults.error, + searchingForFacetValues: searchResults.searchingForFacetValues, + props, + }; + }, + }); + + const asConnectStateResults: typeof connectStateResults = csr; +}; From 222855ab264e23c8e26b32af38bd245c1ef1e9b4 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Tue, 19 Feb 2019 17:17:43 -0500 Subject: [PATCH 046/222] Updated typedefs for shapes --- types/fabric/fabric-impl.d.ts | 1482 ++++++++++----------------------- 1 file changed, 453 insertions(+), 1029 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 10b487180f..f511e8f528 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -432,6 +432,12 @@ export class Color { */ toHex(): string; + /** + * Returns color representation in HEXA format + * @return {String} ex: FF5555CC + */ + toHexa(): string; + /** * Gets value of alpha channel for this color */ @@ -506,100 +512,87 @@ export class Color { interface IGradientOptions { /** - * @param [options.type] Type of gradient 'radial' or 'linear' + * Horizontal offset for aligning gradients coming from SVG when outside pathgroups + * @type Number */ + offsetX?: number; + /** + * Vertical offset for aligning gradients coming from SVG when outside pathgroups + * @type Number + */ + offsetY?: number; type?: string; - /** - * x-coordinate of start point - */ - x1?: number; - /** - * y-coordinate of start point - */ - y1?: number; - /** - * x-coordinate of end point - */ - x2?: number; - /** - * y-coordinate of end point - */ - y2?: number; - /** - * Radius of start point (only for radial gradients) - */ - r1?: number; - /** - * Radius of end point (only for radial gradients) - */ - r2?: number; + coords?: {x1: number, y1: number, x2: number, y2: number, r1: number, r2: number}; /** * Color stops object eg. {0:string; 1:string; */ colorStops?: any; + gradientTransform?: any; } -interface IGradient extends IGradientOptions { +export interface Gradient extends IGradientOptions { } +export class Gradient { /** * Adds another colorStop * @param colorStop Object with offset and color */ - addColorStop(colorStop: any): IGradient; + addColorStop(colorStop: any): Gradient; /** * Returns object representation of a gradient */ - toObject(): any; + toObject(propertiesToInclude?: any): any; /** * Returns SVG representation of an gradient - * @param object Object to create a gradient for - * @param normalize Whether coords should be normalized - * @return SVG representation of an gradient (linear/radial) + * @param {Object} object Object to create a gradient for + * @return {String} SVG representation of an gradient (linear/radial) */ - toSVG(object: Object, normalize?: boolean): string; - + toSVG(object: any): string; /** * Returns an instance of CanvasGradient * @param ctx Context to render on */ - toLive(ctx: CanvasRenderingContext2D, object?: PathGroup): CanvasGradient; -} -interface IGrandientStatic { - new(options?: IGradientOptions): IGradient; + toLive(ctx: CanvasRenderingContext2D): CanvasGradient; /** - * Returns instance from an SVG element - * @param el SVG gradient element + * Returns {@link fabric.Gradient} instance from an SVG element + * @static + * @memberOf fabric.Gradient + * @param {SVGGradientElement} el SVG gradient element + * @param {fabric.Object} instance + * @return {fabric.Gradient} Gradient instance + * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement + * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement */ - fromElement(el: SVGGradientElement, instance: Object): IGradient; + static fromElement(el: SVGGradientElement, instance: Object): Gradient; /** - * Returns instance from its object representation - * @param [options] Options object + * Returns {@link fabric.Gradient} instance from its object representation + * @static + * @memberOf fabric.Gradient + * @param {Object} obj + * @param {Object} [options] Options object */ - fromObject(obj: any, options: any[]): IGradient; + static forObject(obj: any, options?: IGradientOptions): Gradient; } - export class Intersection { constructor(status?: string); - /** * Appends a point to intersection */ - appendPoint(point: Point): void; + appendPoint(point: Point): Intersection; /** * Appends points to intersection */ - appendPoints(points: Point[]): void; - + appendPoints(points: Point[]): Intersection; /** - * Checks if polygon intersects another polygon + * Checks if one line intersects another */ - static intersectPolygonPolygon(points1: Point[], points2: Point[]): Intersection; + static intersectLineLine(a1: Point, a2: Point, b1: Point, b2: Point): Intersection; /** * Checks if line intersects polygon */ static intersectLinePolygon(a1: Point, a2: Point, points: Point[]): Intersection; /** - * Checks if one line intersects another + * Checks if polygon intersects another polygon */ - static intersectLineLine(a1: Point, a2: Point, b1: Point, b2: Point): Intersection; + static intersectPolygonPolygon(points1: Point[], points2: Point[]): Intersection; /** * Checks if polygon intersects rectangle */ @@ -610,24 +603,23 @@ interface IPatternOptions { /** * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) */ - repeat: string; + repeat?: string; /** * Pattern horizontal offset from object's left/top corner */ - offsetX: number; + offsetX?: number; /** * Pattern vertical offset from object's left/top corner */ - offsetY: number; + offsetY?: number; /** * crossOrigin value (one of "", "anonymous", "use-credentials") * @see https://developer.mozilla.org/en-US/docs/HTML/CORS_settings_attributes * @type String - * @default */ - crossOrigin: '' | 'anonymous' | 'use-credentials'; + crossOrigin?: '' | 'anonymous' | 'use-credentials'; /** * Transform matrix to change the pattern, imported from svgs */ @@ -636,45 +628,38 @@ interface IPatternOptions { export interface Pattern extends IPatternOptions { } export class Pattern { constructor(options?: IPatternOptions); - initialise(options?: IPatternOptions): Pattern; - /** * Returns object representation of a pattern * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output * @return {Object} Object representation of a pattern instance */ - toObject: any; - + toObject(propertiesToInclude: any): any; /** * Returns SVG representation of a pattern * @param {fabric.Object} object * @return {String} SVG representation of a pattern */ toSVG(object: Object): string; - + setOptions(options: IPatternOptions): void; /** * Returns an instance of CanvasPattern * @param {CanvasRenderingContext2D} ctx Context to create pattern * @return {CanvasPattern} */ toLive(ctx: CanvasRenderingContext2D): CanvasPattern; - } - export class Point { x: number; y: number; - + type: string; constructor(x: number, y: number); - /** * Adds another point to this one and returns another one * @param {fabric.Point} that * @return {fabric.Point} new Point instance with added values */ add(that: Point): Point; - /** * Adds another point to this one * @param {fabric.Point} that @@ -682,14 +667,12 @@ export class Point { * @chainable */ addEquals(that: Point): Point; - /** * Adds value to this point and returns a new one * @param {Number} scalar * @return {fabric.Point} new Point with added value */ scalarAdd(scalar: number): Point; - /** * Adds value to this point * @param {Number} scalar @@ -697,14 +680,12 @@ export class Point { * @chainable */ scalarAddEquals(scalar: number): Point; - /** * Subtracts another point from this point and returns a new one * @param {fabric.Point} that * @return {fabric.Point} new Point object with subtracted values */ subtract(that: Point): Point; - /** * Subtracts another point from this point * @param {fabric.Point} that @@ -712,14 +693,12 @@ export class Point { * @chainable */ subtractEquals(that: Point): Point; - /** * Subtracts value from this point and returns a new one * @param {Number} scalar * @return {fabric.Point} */ scalarSubtract(scalar: number): Point; - /** * Subtracts value from this point * @param {Number} scalar @@ -727,14 +706,12 @@ export class Point { * @chainable */ scalarSubtractEquals(scalar: number): Point; - /** * Multiplies this point by a value and returns a new one * @param {Number} scalar * @return {fabric.Point} */ multiply(scalar: number): Point; - /** * Multiplies this point by a value * @param {Number} scalar @@ -742,14 +719,12 @@ export class Point { * @chainable */ multiplyEquals(scalar: number): Point; - /** * Divides this point by a value and returns a new one * @param {Number} scalar * @return {fabric.Point} */ divide(scalar: number): Point; - /** * Divides this point by a value * @param {Number} scalar @@ -757,42 +732,36 @@ export class Point { * @chainable */ divideEquals(scalar: number): Point; - /** * Returns true if this point is equal to another one * @param {fabric.Point} that * @return {Boolean} */ eq(that: Point): Point; - /** * Returns true if this point is less than another one * @param {fabric.Point} that * @return {Boolean} */ lt(that: Point): Point; - /** * Returns true if this point is less than or equal to another one * @param {fabric.Point} that * @return {Boolean} */ lte(that: Point): Point; - /** * Returns true if this point is greater another one * @param {fabric.Point} that * @return {Boolean} */ gt(that: Point): Point; - /** * Returns true if this point is greater than or equal to another one * @param {fabric.Point} that * @return {Boolean} */ gte(that: Point): Point; - /** * Returns new point which is the result of linear interpolation with this one and another one * @param {fabric.Point} that @@ -800,41 +769,35 @@ export class Point { * @return {fabric.Point} */ lerp(that: Point, t: number): Point; - /** * Returns distance from this point and another one * @param {fabric.Point} that * @return {Number} */ distanceFrom(that: Point): number; - /** * Returns the point between this point and another one * @param {fabric.Point} that * @return {fabric.Point} */ midPointFrom(that: Point): Point; - /** * Returns a new point which is the min of this and another one * @param {fabric.Point} that * @return {fabric.Point} */ min(that: Point): Point; - /** * Returns a new point which is the max of this and another one * @param {fabric.Point} that * @return {fabric.Point} */ max(that: Point): Point; - /** * Returns string representation of this point * @return {String} */ toString(): string; - /** * Sets x/y of this point * @param {Number} x @@ -842,76 +805,65 @@ export class Point { * @chainable */ setXY(x: number, y: number): Point; - /** * Sets x of this point * @param {Number} x * @chainable */ setX(x: number): Point; - /** * Sets y of this point * @param {Number} y * @chainable */ setY(y: number): Point; - /** * Sets x/y of this point from another point * @param {fabric.Point} that * @chainable */ setFromPoint(that: Point): Point; - /** * Swaps x/y of this point and another point * @param {fabric.Point} that */ swap(that: Point): Point; - /** * return a cloned instance of the point * @return {fabric.Point} */ clone(): Point; } - interface IShadowOptions { /** * Shadow color */ - color: string; + color?: string; /** * Shadow blur */ - blur: number; + blur?: number; /** * Shadow horizontal offset */ - offsetX: number; + offsetX?: number; /** * Shadow vertical offset */ - offsetY: number; + offsetY?: number; /** * Whether the shadow should affect stroke operations */ - affectStrike: boolean; + affectStrike?: boolean; /** * Indicates whether toObject should include default values */ - includeDefaultValues: boolean; + includeDefaultValues?: boolean; } export interface Shadow extends IShadowOptions { } export class Shadow { constructor(options?: IShadowOptions| string); initialize(options?: IShadowOptions | string): Shadow; - /** - * Returns object representation of a shadow - * @return {Object} Object representation of a shadow instance - */ - toObject(): any; /** * Returns a string representation of an instance * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow @@ -924,6 +876,11 @@ export class Shadow { * @return {String} SVG representation of a shadow */ toSVG(object: Object): string; + /** + * Returns object representation of a shadow + * @return {Object} Object representation of a shadow instance + */ + toObject(): any; /** * Regex matching shadow offsetX, offsetY and blur (ex: "2px 2px 10px rgba(0,0,0,0.2)", "rgb(0,255,0) 2px 2px") * @static @@ -1910,12 +1867,6 @@ interface ICircleOptions extends IObjectOptions { export interface Circle extends Object, ICircleOptions { } export class Circle { constructor(options?: ICircleOptions); - - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; /** * Returns horizontal radius of an object (according to how an object is scaled) */ @@ -1928,20 +1879,12 @@ export class Circle { * Sets radius of an object (and updates width accordingly) */ setRadius(value: number): number; - - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; /** * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toSVG(reviver?: Function): string; - + _toSVG(): string; /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement}) */ @@ -1972,65 +1915,59 @@ interface IEllipseOptions extends IObjectOptions { export interface Ellipse extends Object, IEllipseOptions { } export class Ellipse { constructor(options?: IEllipseOptions); - /** * Returns horizontal radius of an object (according to how an object is scaled) */ getRx(): number; - /** * Returns Vertical radius of an object (according to how an object is scaled) */ getRy(): number; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; /** * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toSVG(reviver?: Function): string; - /** - * Returns complexity of an instance - * @return complexity - */ - complexity(): number; - + _toSVG(): string; /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement}) */ static ATTRIBUTE_NAMES: string[]; - /** * Returns Ellipse instance from an SVG element * @param element Element to parse * @param [options] Options object */ static fromElement(element: SVGElement, options?: IEllipseOptions): Ellipse; - /** * Returns Ellipse instance from an object representation * @param object Object to create an instance from */ static fromObject(object: any): Ellipse; } - -export interface Group extends Object, ICollection { } +interface IGroupOptions extends IObjectOptions { + /** + * Indicates if click events should also check for subtargets + * @type Boolean + */ + subTargetCheck?: boolean; + /** + * setOnGroup is a method used for TextBox that is no more used since 2.0.0 The behavior is still + * available setting this boolean to true. + * @type Boolean + * @since 2.0.0 + * @default + */ + useSetOnGroup?: boolean; +} +export interface Group extends Object, ICollection, IGroupOptions { } export class Group { /** * Constructor * @param objects Group objects * @param [options] Options object */ - constructor(objects?: Object[], options?: IObjectOptions, isAlreadyGrouped?: boolean); - /** - * Returns string representation of a group - */ - toString(): string; + constructor(objects?: Object[], options?: IGroupOptions, isAlreadyGrouped?: boolean); /** * Adds an object to a group; Then recalculates group's dimension, position. * @return thisArg @@ -2043,18 +1980,6 @@ export class Group { * @chainable */ removeWithUpdate(object: Object): Group; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns object representation of an instance, in dataless mode. - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toDatalessObject(propertiesToInclude?: string[]): any; /** * Renders instance on a given context * @param ctx context to render instance on @@ -2153,26 +2078,25 @@ export class ActiveSelection { * @param [options] Options object */ constructor(objects?: Object[], options?: IObjectOptions); - /** * Change te activeSelection to a normal group, * High level function that automatically adds it to canvas as * active object. no events fired. */ toGroup(): Group; - /** - * Returns string represenation of a group + * If returns true, deselection is cancelled. + * @since 2.0.0 + * @return {Boolean} [cancel] */ - toString(): string; - + onDeselect(): boolean; /** * Returns {@link fabric.ActiveSelection} instance from an object representation * @memberOf fabric.ActiveSelection * @param object Object to create a group from * @param [callback] Callback to invoke when an ActiveSelection instance is created */ - static fromObject(object: Group, callback: (activeSelection: ActiveSelection) => void): void; + static fromObject(object: any, callback: Function): void; } interface IImageOptions extends IObjectOptions { @@ -2180,7 +2104,6 @@ interface IImageOptions extends IObjectOptions { * crossOrigin value (one of "", "anonymous", "allow-credentials") */ crossOrigin?: string; - /** * When calling {@link fabric.Image.getSrc}, return value from element src with `element.getAttribute('src')`. * This allows for relative urls as image src. @@ -2188,7 +2111,6 @@ interface IImageOptions extends IObjectOptions { * @type Boolean */ srcFromAttribute?: boolean; - /** * minimum scale factor under which any resizeFilter is triggered to resize the image * 0 will disable the automatic resize. 1 will trigger automatically always. @@ -2196,40 +2118,24 @@ interface IImageOptions extends IObjectOptions { * @type Number */ minimumScaleTrigger?: number; - + /** + * key used to retrieve the texture representing this image + * @since 2.0.0 + * @type String + */ + cacheKey?: string; /** * Image crop in pixels from original image size. * @since 2.0.0 * @type Number */ cropX?: number; - /** * Image crop in pixels from original image size. * @since 2.0.0 * @type Number */ cropY?: number; - - /** - * AlignX value, part of preserveAspectRatio (one of "none", "mid", "min", "max") - * This parameter defines how the picture is aligned to its viewport when image element width differs from image width. - */ - alignX?: string; - - /** - * AlignY value, part of preserveAspectRatio (one of "none", "mid", "min", "max") - * This parameter defines how the picture is aligned to its viewport when image element height differs from image height. - */ - alignY?: string; - - /** - * meetOrSlice value, part of preserveAspectRatio (one of "meet", "slice"). - * if meet the image is always fully visibile, if slice the viewport is always filled with image. - * @see http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute - */ - meetOrSlice?: string; - /** * Image filter array */ @@ -2242,8 +2148,7 @@ export class Image { * @param element Image element * @param [options] Options object */ - constructor(element: HTMLImageElement, objObjects: IObjectOptions); - + constructor(element?: string | HTMLImageElement, options?: IImageOptions); initialize(element?: string | HTMLImageElement, options?: IImageOptions): void; /** * Returns image element which this instance if based on @@ -2275,23 +2180,17 @@ export class Image { * @return Object with "width" and "height" properties */ getOriginalSize(): { width: number; height: number; }; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return Object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; /** * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,hight. * @return {Boolean} */ hasCrop(): boolean; /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toSVG(reviver?: Function): string; + _toSVG(): string; /** * Returns source of an image * @return Source of an image @@ -2306,11 +2205,6 @@ export class Image { * @chainable */ setSrc(src: string, callback?: Function, options?: IImageOptions): Image; - /** - * Returns string representation of an instance - * @return String representation of an instance - */ - toString(): string; applyResizeFilters(): void; /** * Applies filters assigned to this image (from "filters" array) or from filter param @@ -2319,19 +2213,6 @@ export class Image { * @chainable */ applyFilters(filters?: IBaseFilter[]): Image; - /** - * Decide if the object should cache or not. Create its own cache level - * objectCaching is a global flag, wins over everything - * needsItsOwnCache should be used when the object drawing method requires - * a cache step. None of the fabric classes requires it. - * Generally you do not cache objects in groups because the group outside is cached. - * This is the special image version where we would like to avoid caching where possible. - * Essentially images do not benefit from caching. They may require caching, and in that - * case we do it. Also caching an image usually ends in a loss of details. - * A full performance audit should be done. - * @return {Boolean} - */ - shouldCache(): void; /** * Calculate offset for center and scale factor for the image in order to respect * the preserveAspectRatio attribute @@ -2339,12 +2220,6 @@ export class Image { * @return {Object} */ parsePreserveAspectRatioAttribute(): any; - /** - * Creates an instance of fabric.Image from its object representation - * @param object Object to create an instance from - * @param [callback] Callback to invoke when an image instance is created - */ - static fromObject(object: any, callback: (image: Image) => void): void; /** * Creates an instance of fabric.Image from an URL string * @param url URL to create an image from @@ -2358,12 +2233,13 @@ export class Image { * @param callback Callback to execute when fabric.Image object is created * @param [options] Options object */ - static fromElement(element: SVGElement, callback: (image: Image) => void, options?: IImageOptions): void; + static fromElement(element: SVGElement, callback: Function, options?: IImageOptions): Image; /** * Default CSS class name for canvas */ static CSS_CANVAS: string; static filters: IAllFilters; + static ATTRIBUTE_NAMES: string[]; } interface ILineOptions extends IObjectOptions { @@ -2391,33 +2267,33 @@ export class Line { * @param [points] Array of points * @param [options] Options object */ - constructor(points?: number[], objObjects?: IObjectOptions); + constructor(points?: number[], objObjects?: ILineOptions); initialize(points?: number[], options?: ILineOptions): Line; /** - * Returns object representation of an instance - * @methd toObject - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toObject(propertiesToInclude: string[]): any; - /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; + _toSVG(): string; /** * Returns fabric.Line instance from an SVG element - * @param element Element to parse - * @param [options] Options object + * @static + * @memberOf fabric.Line + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + * @param {Function} [callback] callback function invoked after parsing */ - static fromElement(element: SVGElement, options?: ILineOptions): Line; + static fromElement(element: SVGElement, callback?: Function, options?: ILineOptions): Line; /** * Returns fabric.Line instance from an object representation * @param object Object to create an instance from */ static fromObject(object: any): Line; static ATTRIBUTE_NAMES: string[]; + /** + * Produces a function that calculates distance from canvas edge to Line origin. + */ + makeEdgeToOriginGetter(propertyNames: {origin: number, axis1: any, axis2: any, dimension: any}, originValues: {nearest: any, center: any, farthest: any}): Function; } interface IObjectOptions { /** @@ -2635,7 +2511,7 @@ interface IObjectOptions { /** * Shadow object representing shadow of this shape */ - shadow?: Shadow | string; + shadow?: Shadow; /** * Opacity of object's controlling borders when object is active and moving @@ -2876,66 +2752,8 @@ interface IObjectOptions { } export interface Object extends IObservable, IObjectOptions, IObjectAnimation { } export class Object { - getCurrentWidth(): number; - getCurrentHeight(): number; - - getAngle(): number; - setAngle(value: number): Object; - - getBorderColor(): string; - setBorderColor(value: string): Object; - - getBorderScaleFactor(): number; - - getCornersize(): number; - setCornersize(value: number): Object; - - getFill(): string; - setFill(value: string): Object; - - getFillRule(): string; - setFillRule(value: string): Object; - - getFlipX(): boolean; - setFlipX(value: boolean): Object; - - getFlipY(): boolean; - setFlipY(value: boolean): Object; - - getHeight(): number; - setHeight(value: number): Object; - - getLeft(): number; - setLeft(value: number): Object; - - getOpacity(): number; - setOpacity(value: number): Object; - - overlayFill: string; - getOverlayFill(): string; - setOverlayFill(value: string): Object; - - getScaleX(): number; - setScaleX(value: number): Object; - - getScaleY(): number; - setScaleY(value: number): Object; - - getSkewX(): number; - setSkewX(value: number): Object; - - getSkewY(): number; - setSkewY(value: number): Object; - - setShadow(options: any): Object; - getShadow(): Object; - - stateProperties: any[]; - getTop(): number; - setTop(value: number): Object; - - getWidth(): number; - setWidth(value: number): Object; + constructor(options?: IObjectOptions); + initialize(options?: IObjectOptions): Object; /* Sets object's properties from options * @param {Object} [options] Options object @@ -2965,6 +2783,12 @@ export class Object { */ toString(): string; + /** + * Return the object scale factor counting also the group scaling + * @return {Object} object with scaleX and scaleY properties + */ + getObjectScaling(): {scaleX: number, scaleY: number}; + /** * Return the object scale factor counting also the group scaling, zoom and retina * @return {Object} object with scaleX and scaleY properties @@ -2977,6 +2801,14 @@ export class Object { */ getObjectOpacity(): number; + /** + * This callback function is called by the parent group of an object every + * time a non-delegated property changes on the group. It is passed the key + * and value as parameters. Not adding in this function's signature to avoid + * Travis build error about unused variables. + */ + setOnGroup(): void; + /** * Retrieves viewportTransform from Object's canvas if possible */ @@ -3103,7 +2935,7 @@ export class Object { * Sets pattern fill of an object * @param options Options object */ - setPatternFill(options: IFillOptions): Object; + setPatternFill(options: IFillOptions, callback: Function): Object; /** * Sets shadow of an object @@ -3455,17 +3287,7 @@ interface IPathOptions extends IObjectOptions { /** * Array of path points */ - path?: any[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; + path?: Point[]; } export interface Path extends Object, IPathOptions { } export class Path { @@ -3474,178 +3296,54 @@ export class Path { * @param path Path data (sequence of coordinates and corresponding "command" tokens) * @param [options] Options object */ - constructor(path?: string | any[], options?: IPathOptions); + constructor(path?: string | Point[], options?: IPathOptions); pathOffset: Point; - initialize(path?: any[], options?: IPathOptions): Path; - + initialize(path?: Point[], options?: IPathOptions): Path; /** - * Returns number representation of an instance complexity - * @return complexity of this instance + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance */ - complexity(): number; - - /** - * Renders path on a specified context - * @param ctx context to render path on - * @param [noTransform] When true, context is not transformed - */ - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns dataless object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toDatalessObject(propertiesToInclude?: string[]): any; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns string representation of an instance - * @return string representation of an instance - */ - toString(): string; + toClipPathSVG(reviver?: Function): string; /** * Returns svg representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; - /** * Creates an instance of fabric.Path from an SVG element * @param element to parse * @param callback Callback to invoke when an fabric.Path instance is created * @param [options] Options object */ - static fromElement(element: SVGElement, callback: (path: Path) => any, options?: IPathOptions): void; + static fromElement(element: SVGElement, callback: Function, options?: IPathOptions): Path; /** * Creates an instance of fabric.Path from an object * @param callback Callback to invoke when an fabric.Path instance is created */ - static fromObject(object: any, callback: (path: Path) => any): void; + static fromObject(object: any, callback: Function): Path; + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) + */ + static ATTRIBUTE_NAMES: string[]; } - -export class PathGroup extends Object { - /** - * Constructor - * @param [options] Options object - */ - constructor(paths: Path[], options?: IObjectOptions); - - initialize(paths: Path[], options?: IObjectOptions): void; - /** - * Returns number representation of object's complexity - * @return complexity - */ - complexity(): number; - /** - * Returns true if all paths in this group are of same color - * @return true if all paths are of the same color (`fill`) - */ - isSameColor(): boolean; - /** - * Renders this group on a specified context - * @param ctx Context to render this instance on - */ - render(ctx: CanvasRenderingContext2D): void; - /** - * Returns dataless object representation of this path group - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return dataless object representation of an instance - */ - toDatalessObject(propertiesToInclude?: string[]): any; - /** - * Returns object representation of this path group - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns a string representation of this path group - * @return string representation of an object - */ - toString(): string; - /** - * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** - * Returns all paths in this path group - * @return array of path objects included in this path group - */ - getObjects(): Path[]; - - static fromObject(object: any): PathGroup; - /** - * Creates fabric.PathGroup instance from an object representation - * @param object Object to create an instance from - * @param callback Callback to invoke when an fabric.PathGroup instance is created - */ - static fromObject(object: any, callback: (group: PathGroup) => any): void; -} - -interface IPolygonOptions extends IObjectOptions { - /** - * Points array - */ - points?: Point[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; -} -export interface Polygon extends IPolygonOptions { } -export class Polygon extends Object { +export interface Polygon extends IPolylineOptions { } +export class Polygon extends Polyline { /** * Constructor * @param points Array of points * @param [options] Options object */ - constructor(points: Array<{ x: number; y: number }>, options?: IObjectOptions, skipOffset?: boolean); - - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; - - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) - */ - static ATTRIBUTE_NAMES: string[]; - + constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions); /** * Returns Polygon instance from an SVG element * @param element Element to parse * @param [options] Options object */ - static fromElement(element: SVGElement, options?: IPolygonOptions): Polygon; + static fromElement(element: SVGElement, options?: IPolylineOptions): Polygon; /** * Returns fabric.Polygon instance from an object representation * @param object Object to create an instance from @@ -3658,16 +3356,6 @@ interface IPolylineOptions extends IObjectOptions { * Points array */ points?: Point[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; } export interface Polyline extends IPolylineOptions { } export class Polyline extends Object { @@ -3679,29 +3367,10 @@ export class Polyline extends Object { */ constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions); initialize(points: Point[], options?: IPolylineOptions): void; - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return Object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) */ static ATTRIBUTE_NAMES: string[]; - /** * Returns Polyline instance from an SVG element * @param element Element to parse @@ -3716,8 +3385,6 @@ export class Polyline extends Object { } interface IRectOptions extends IObjectOptions { - x?: number; - y?: number; /** * Horizontal border radius */ @@ -3736,25 +3403,7 @@ export class Rect extends Object { * @param [options] Options object */ constructor(options?: IRectOptions); - initialize(points?: number[], options?: any): Rect; - /** - * Returns complexity of an instance - * @return complexity - */ - complexity(): number; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude: any[]): any; - /** - * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - + initialize(options?: IRectOptions): Rect; /** * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) */ @@ -3771,607 +3420,389 @@ export class Rect extends Object { */ static fromObject(object: any): Rect; } - -interface ITextOptions extends IObjectOptions { +interface TextOptions extends IObjectOptions { /** * Font size (in pixels) + * @type Number */ fontSize?: number; /** * Font weight (e.g. bold, normal, 400, 600, 800) + * @type {(Number|String)} */ - fontWeight?: number | string; + fontWeight?: string | number; /** * Font family + * @type String */ fontFamily?: string; /** - * Text decoration Possible values?: "", "underline", "overline" or "line-through". - * Feels like this has been deprecated in favor of underline, overline, linethrough props + * Text decoration underline. + * @type Boolean */ - textDecoration?: string; - /** - * Text decoration underline. - * @type Boolean - * @default - */ - underline?: boolean; - /** - * Text decoration overline. - * @type Boolean - * @default - */ - overline?: boolean; - /** - * Text decoration linethrough. - * @type Boolean - * @default - */ - linethrough?: boolean; + underline?: boolean; /** - * Text alignment. Possible values?: "left", "center", or "right". + * Text decoration overline. + * @type Boolean */ - textAlign?: string; + overline?: boolean; /** - * Font style . Possible values?: "", "normal", "italic" or "oblique". + * Text decoration linethrough. + * @type Boolean */ - fontStyle?: string; + linethrough?: boolean; + /** + * Text alignment. Possible values: "left", "center", "right", "justify", + * "justify-left", "justify-center" or "justify-right". + * @type String + */ + textAlign?: 'left' | 'center' | 'right' | 'justify' | 'justify-left' | 'justify-center' | 'justify-right'; + /** + * Font style . Possible values: "", "normal", "italic" or "oblique". + * @type String + */ + fontStyle?: '' | 'normal' | 'italic' | 'oblique'; /** * Line height + * @type Number */ lineHeight?: number; - /** - * Character spacing - */ - charSpacing?: number; + /** + * Superscript schema object (minimum overlap) + * @type {Object} + */ + superscript?: {size: number, baseline: number}; + /** + * Subscript schema object (minimum overlap) + * @type {Object} + */ + subscript?: {size: number, baseline: number}; + /** + * Background color of text lines + * @type String + */ + textBackgroundColor?: string; /** * When defined, an object is rendered via stroke and this property specifies its color. - * Backwards incompatibility note?: This property was named "strokeStyle" until v1.1.6 + * Backwards incompatibility note: This property was named "strokeStyle" until v1.1.6 */ stroke?: string; /** * Shadow object representing shadow of this shape. - * Backwards incompatibility note?: This property was named "textShadow" (String) until v1.2.11 + * Backwards incompatibility note: This property was named "textShadow" (String) until v1.2.11 + * @type fabric.Shadow */ - shadow?: Shadow | string; + shadow?: Shadow; /** - * Background color of text lines + * additional space between characters + * expressed in thousands of em unit + * @type Number */ - textBackgroundColor?: string; - + charSpacing?: number; + /** + * Object containing character styles - top-level properties -> line numbers, + * 2nd-level properties - charater numbers + * @type Object + */ + styles?: any; + /** + * Baseline shift, stlyes only, keep at 0 for the main text object + * @type {Number} + */ + deltaY?: number; +} +export interface Text extends TextOptions { } +export class Text extends Object { + text?: string; + /** + * Constructor + * @param text Text string + * @param [options] Options object + */ + constructor(text: string, options?: TextOptions); + /** + * Return a context for measurement of text string. + * if created it gets stored for reuse + * @return {fabric.Text} thisArg + */ + getMeasuringContext(): CanvasRenderingContext2D; + /** + * Initialize or update text dimensions. + * Updates this.width and this.height with the proper values. + * Does not return dimensions. + */ + initDimensions(): void; + /** + * Enlarge space boxes and shift the others + */ + enlargeSpaces(): void; + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @return {Boolean} + */ + isEndOfWrapping(): boolean; + /** + * Returns string representation of an instance + */ + toString(): string; + /** + * Computes height of character at given position + * @param {Number} line the line number + * @param {Number} char the character number + * @return {Number} fontSize of the character + */ + getHeightOfChar(line: number, char: number): number; + /** + * measure a text line measuring all characters. + * @param {Number} lineIndex line number + * @return {Number} Line width + */ + measureLine(lineIndex: number): number; + /** + * Calculate height of line at 'lineIndex' + * @param {Number} lineIndex index of line to calculate + * @return {Number} + */ + getHeightOfLine(lineIndex: number): number; + /** + * Calculate text box height + */ + calcTextHeight(): number; + /** + * Turns the character into a 'superior figure' (i.e. 'superscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSuperscript(start: number, end: number): Text; + /** + * Turns the character into an 'inferior figure' (i.e. 'subscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSubscript(start: number, end: number): Text; + /** + * Retrieves the value of property at given character position + * @param {Number} lineIndex the line number + * @param {Number} charIndex the charater number + * @param {String} property the property name + * @returns the value of 'property' + */ + getValueOfPropertyAt(lineIndex: number, charIndex: number, property: string): any; + static DEFAULT_SVG_FONT_SIZE: number; + /** + * Returns fabric.Text instance from an SVG element (not yet implemented) + * @static + * @memberOf fabric.Text + * @param {SVGElement} element Element to parse + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, callback?: Function, options?: TextOptions): Text; + /** + * Returns fabric.Text instance from an object representation + * @static + * @memberOf fabric.Text + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created + */ + static fromObject(object: any, callback?: Function): Text; +} +interface ITextOptions extends TextOptions { + /** + * Index where text selection starts (or where cursor is when there is no selection) + * @type Number + */ + selectionStart?: number;/** + * Index where text selection ends + * @type Number + */ + selectionEnd?: number; + /** + * Color of text selection + * @type String + */ + selectionColor?: string; + /** + * Indicates whether text is in editing mode + * @type Boolean + */ + isEditing?: boolean; + /** + * Indicates whether a text can be edited + * @type Boolean + */ + editable?: boolean; + /** + * Border color of text object while it's in editing mode + * @type String + */ + editingBorderColor?: string; + /** + * Width of cursor (in px) + * @type Number + */ + cursorWidth?: number; + /** + * Color of default cursor (when not overwritten by character style) + * @type String + */ + cursorColor?: string; + /** + * Delay between cursor blink (in ms) + * @type Number + */ + cursorDelay?: number; + /** + * Duration of cursor fadein (in ms) + * @type Number + */ + cursorDuration?: number; + /** + * Indicates whether internal text char widths can be cached + * @type Boolean + */ + caching?: boolean; + /** + * Helps determining when the text is in composition, so that the cursor + * rendering is altered. + */ + inCompositionMode?: boolean; path?: string; useNative?: boolean; - text?: string; } -export interface Text extends ITextOptions { } -export class Text extends Object { +export interface IText extends ITextOptions, IObservable { } +export class IText extends Text { /** * Constructor * @param text Text string * @param [options] Options object */ constructor(text: string, options?: ITextOptions); + initialize(text: string, options?: ITextOptions): IText; /** - * Returns complexity of an instance + * Sets selection start (left boundary of a selection) + * @param {Number} index Index to set selection start to */ - complexity(): number; + setSelectionStart(index: number): void; /** - * Returns string representation of an instance + * Sets selection end (right boundary of a selection) + * @param {Number} index Index to set selection end to */ - toString(): string; + setSelectionEnd(index: number): void; /** - * Renders text instance on a specified context - * @param ctx Context to render on + * Prepare and clean the contextTop */ - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; + clearContextTop(skipRestor: boolean): void; /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * Renders cursor or selection (depending on what exists) */ - toObject(propertiesToInclude?: string[]): any; + renderCursorOrSelection(): void; /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. + * Renders cursor + * @param {Object} boundaries + * @param {CanvasRenderingContext2D} ctx transformed context to draw on */ - toSVG(reviver?: Function): string; + renderCursor(boundaries: any, ctx: CanvasRenderingContext2D): void; /** - * Retrieves object's fontSize + * Renders text selection + * @param {Object} boundaries Object with left/top/leftOffset/topOffset + * @param {CanvasRenderingContext2D} ctx transformed context to draw on */ - getFontSize(): number; + renderSelection(boundaries: any, ctx: CanvasRenderingContext2D): void; /** - * Sets object's fontSize - * @param fontSize Font size (in pixels) + * High level function to know the height of the cursor. + * the currentChar is the one that precedes the cursor + * Returns fontSize of char at the current cursor + * @return {Number} Character font size */ - setFontSize(fontSize: number): Text; + getCurrentCharFontSize(): number; /** - * Retrieves object's fontWeight + * High level function to know the color of the cursor. + * the currentChar is the one that precedes the cursor + * Returns color (fill) of char at the current cursor + * @return {String} Character color (fill) */ - getFontWeight(): number | string; + getCurrentCharColor(): string; /** - * Sets object's fontWeight - * @param fontWeight Font weight + * Returns fabric.IText instance from an object representation + * @static + * @memberOf fabric.IText + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as argument */ - setFontWeight(fontWeight: string | number): Text; - /** - * Retrieves object's fontFamily - */ - getFontFamily(): string; - /** - * Sets object's fontFamily - * @param fontFamily Font family - */ - setFontFamily(fontFamily: string): Text; - /** - * Retrieves object's text - */ - getText(): string; - /** - * Sets object's text - * @param text Text - */ - setText(text: string): Text; - /** - * Retrieves object's textDecoration - */ - getTextDecoration(): string; - /** - * Sets object's textDecoration - * @param textDecoration Text decoration - */ - setTextDecoration(textDecoration: string): Text; - /** - * Retrieves object's underline - */ - getUnderline(): boolean; - /** - * Sets object's underline - * @param underline Text underline - */ - setUnderline(underline: boolean): Text; - /** - * Retrieves object's overline - */ - getOverline(): boolean; - /** - * Sets object's overline - * @param overline Text overline - */ - setOverline(overline: boolean): Text; - /** - * Retrieves object's linethrough - */ - getLinethrough(): boolean; - /** - * Sets object's linethrough - * @param linethrough Text linethrough - */ - setLinethrough(linethrough: boolean): Text; - /** - * Retrieves object's fontStyle - */ - getFontStyle(): string; - /** - * Sets object's fontStyle - * @param fontStyle Font style - */ - setFontStyle(fontStyle: string): Text; - /** - * Retrieves object's lineHeight - */ - getLineHeight(): number; - /** - * Sets object's lineHeight - * @param lineHeight Line height - */ - setLineHeight(lineHeight: number): Text; - /** - * Retrieves object's charSpacing - */ - getCharSpacing(): number; - /** - * Sets object's charSpacing - * @param charSpacing Character spacing - */ - setCharSpacing(charSpacing: number): Text; - /** - * Retrieves object's textAlign - */ - getTextAlign(): string; - /** - * Sets object's textAlign - * @param textAlign Text alignment - */ - setTextAlign(textAlign: string): Text; - /** - * Retrieves object's textBackgroundColor - */ - getTextBackgroundColor(): string; - /** - * Sets object's textBackgroundColor - * @param textBackgroundColor Text background color - */ - setTextBackgroundColor(textBackgroundColor: string): Text; - - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Text.fromElement`) - */ - static ATTRIBUTE_NAMES: string[]; - /** - * Default SVG font size - */ - static DEFAULT_SVG_FONT_SIZE: number; - - /** - * Returns fabric.Text instance from an SVG element (not yet implemented) - * @param element Element to parse - * @param [options] Options object - */ - static fromElement(element: SVGElement, options?: ITextOptions): Text; - /** - * Returns fabric.Text instance from an object representation - * @param object Object to create an instance from - */ - static fromObject(object: any): Text; + static fromObject(object: any, callback?: Function): IText; } - -interface IITextOptions extends IObjectOptions, ITextOptions { +interface ITextboxOptions extends ITextOptions { /** - * Index where text selection starts (or where cursor is when there is no selection) + * Minimum width of textbox, in pixels. + * @type Number */ - selectionStart?: number; - + minWidth?: number; /** - * Index where text selection ends + * Minimum calculated width of a textbox, in pixels. + * fixed to 2 so that an empty textbox cannot go to 0 + * and is still selectable without text. + * @type Number */ - selectionEnd?: number; - + dynamicMinWidth?: number; /** - * Color of text selection + * Override standard Object class values */ - selectionColor?: string; - + lockScalingFlip?: boolean; /** - * Indicates whether text is in editing mode + * Override standard Object class values + * Textbox needs this on false */ - isEditing?: boolean; - + noScaleCache?: boolean; /** - * Indicates whether a text can be edited + * Use this boolean property in order to split strings that have no white space concept. + * this is a cheap way to help with chinese/japaense + * @type Boolean + * @since 2.6.0 */ - editable?: boolean; - - /** - * Border color of text object while it's in editing mode - */ - editingBorderColor?: string; - - /** - * Width of cursor (in px) - */ - cursorWidth?: number; - - /** - * Color of default cursor (when not overwritten by character style) - */ - cursorColor?: string; - - /** - * Delay between cursor blink (in ms) - */ - cursorDelay?: number; - - /** - * Duration of cursor fadein (in ms) - */ - cursorDuration?: number; - - /** - * Object containing character styles - * (where top-level properties corresponds to line number and 2nd-level properties -- to char number in a line) - */ - styles?: any; - - /** - * Indicates whether internal text char widths can be cached - */ - caching?: boolean; + splitByGrapheme?: boolean; } -export interface Textbox extends IText {} +export interface Textbox extends ITextboxOptions, IObservable{} export class Textbox extends IText { /** * Constructor * @param text Text string * @param [options] Options object */ - constructor(text: string, options?: IITextOptions); - /** - * Detect if the text line is ended with an hard break - * text and itext do not have wrapping, return false - * @param {Number} lineIndex text to split - * @return {Boolean} - */ - isEndOfWrapping(lineIndex: number): boolean; - /** - * Get minimum width of text box - * @return {Number} - */ - getMinWidth(): number; - /** - * Selects entire text - * @return {fabric.Text} thisArg - * @chainable - */ - selectAll(): Textbox; - /** - * Selects a line based on the index - * @param {Number} selectionStart Index of a character - * @return {fabric.IText} thisArg - * @chainable - */ - selectLine(selectionStart: number): Textbox; - /** - * Enters editing state - * @return {fabric.Textbox} thisArg - * @chainable - */ - enterEditing(): Textbox; - /** - * Exits from editing state - * @return {fabric.Textbox} thisArg - * @chainable - */ - exitEditing(): Textbox; -} -export interface IText extends Text, IITextOptions { } -export class IText extends Object { + constructor(text: string, options?: ITextboxOptions); /** - * Constructor - * @param text Text string - * @param [options] Options object + * Returns true if object has a style property or has it ina specified line + * @param {Number} lineIndex + * @return {Boolean} */ - constructor(text: string, options?: IITextOptions); + styleHas(property: string, lineIndex: number): boolean; /** - * Returns true if object has no styling or no styling in a line - * @param {Number} lineIndex , lineIndex is on wrapped lines. + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} */ isEmptyStyles(lineIndex: number): boolean; - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @param {Number} lineIndex text to split + * @return {Boolean} */ - toObject(propertiesToInclude?: string[]): any; - - setText(value: string): Text; + isEndOfWrapping(lineIndex: number): boolean; /** - * Sets selection start (left boundary of a selection) - * @param index Index to set selection start to + * Returns fabric.Textbox instance from an object representation + * @static + * @memberOf fabric.Textbox + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Textbox instance is created */ - setSelectionStart(index: number): void; - /** - * Sets selection end (right boundary of a selection) - * @param index Index to set selection end to - */ - setSelectionEnd(index: number): void; - /** - * Gets style of a current selection/cursor (at the start position) - * @param [startIndex] Start index to get styles at - * @param [endIndex] End index to get styles at - * @return styles Style object at a specified (or current) index - */ - getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any; - /** - * Sets style of a current selection - * @param [styles] Styles object - * @return thisArg - * @chainable - */ - setSelectionStyles(styles: any): Text; - - /** - * Renders cursor or selection (depending on what exists) - */ - renderCursorOrSelection(): void; - - /** - * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) - * @param [selectionStart] Optional index. When not given, current selectionStart is used. - */ - get2DCursorLocation(selectionStart?: number): void; - /** - * Returns complete style of char at the current cursor - * @param lineIndex Line index - * @param charIndex Char index - * @return Character style - */ - getCurrentCharStyle(lineIndex: number, charIndex: number): any; - - /** - * Returns fontSize of char at the current cursor - * @param lineIndex Line index - * @param charIndex Char index - * @return Character font size - */ - getCurrentCharFontSize(lineIndex: number, charIndex: number): number; - - /** - * Returns color (fill) of char at the current cursor - * @param lineIndex Line index - * @param charIndex Char index - * @return Character color (fill) - */ - getCurrentCharColor(lineIndex: number, charIndex: number): string; - /** - * Renders cursor - */ - renderCursor(boundaries: any): void; - - /** - * Renders text selection - * @param chars Array of characters - * @param boundaries Object with left/top/leftOffset/topOffset - */ - renderSelection(chars: string[], boundaries: any): void; - - // functions from itext behavior mixin - // ------------------------------------------------------------------------------------------------------------------------ - /** - * Initializes all the interactive behavior of IText - */ - initBehavior(): void; - - /** - * Initializes "selected" event handler - */ - initSelectedHandler(): void; - - /** - * Initializes "added" event handler - */ - initAddedHandler(): void; - - initRemovedHandler(): void; - - /** - * Initializes delayed cursor - */ - initDelayedCursor(restart: boolean): void; - - /** - * Aborts cursor animation and clears all timeouts - */ - abortCursorAnimation(): void; - - /** - * Selects entire text - */ - selectAll(): void; - - /** - * Returns selected text - */ - getSelectedText(): string; - - /** - * Find new selection index representing start of current word according to current selection index - * @param startFrom Surrent selection index - * @return New selection index - */ - findWordBoundaryLeft(startFrom: number): number; - - /** - * Find new selection index representing end of current word according to current selection index - * @param startFrom Current selection index - * @return New selection index - */ - findWordBoundaryRight(startFrom: number): number; - - /** - * Find new selection index representing start of current line according to current selection index - * @param startFrom Current selection index - */ - findLineBoundaryLeft(startFrom: number): number; - - /** - * Find new selection index representing end of current line according to current selection index - * @param startFrom Current selection index - */ - findLineBoundaryRight(startFrom: number): number; - - /** - * Returns number of newlines in selected text - */ - getNumNewLinesInSelectedText(): number; - - /** - * Finds index corresponding to beginning or end of a word - * @param selectionStart Index of a character - * @param direction: 1 or -1 - */ - searchWordBoundary(selectionStart: number, direction: number): number; - - /** - * Selects a word based on the index - * @param selectionStart Index of a character - */ - selectWord(selectionStart: number): void; - /** - * Selects a line based on the index - * @param selectionStart Index of a character - */ - selectLine(selectionStart: number): void; - - /** - * Enters editing state - */ - enterEditing(): IText; - - /** - * Initializes "mousemove" event handler - */ - initMouseMoveHandler(): void; - /** - * Exits from editing state - * @return thisArg - * @chainable - */ - exitEditing(): IText; - - /** - * Inserts a character where cursor is (replacing selection if one exists) - * @param _chars Characters to insert - */ - insertChars(_chars: string, useCopiedStyle?: boolean): void; - /** - * Inserts new style object - * @param lineIndex Index of a line - * @param charIndex Index of a char - * @param isEndOfLine True if it's end of line - */ - insertNewlineStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; - - /** - * Inserts style object for a given line/char index - * @param lineIndex Index of a line - * @param charIndex Index of a char - * @param [style] Style object to insert, if given - */ - insertCharStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; - - /** - * Inserts style object(s) - * @param _chars Characters at the location where style is inserted - * @param isEndOfLine True if it's end of line - * @param [useCopiedStyle] Style to insert - */ - insertStyleObjects(_chars: string, isEndOfLine: boolean, useCopiedStyle?: boolean): void; - - /** - * Shifts line styles up or down - * @param lineIndex Index of a line - * @param offset Can be -1 or +1 - */ - shiftLineStyles(lineIndex: number, offset: number): void; - - /** - * Removes style object - * @param isBeginningOfLine True if cursor is at the beginning of line - * @param [index] Optional index. When not given, current selectionStart is used. - */ - removeStyleObject(isBeginningOfLine: boolean, index?: number): void; - /** - * Inserts new line - */ - insertNewline(): void; - - /** - * Returns fabric.IText instance from an object representation - * @param object Object to create an instance from - */ - static fromObject(object: any): IText; + static fromObject(object: any, callback?: Function): Textbox; } - interface ITriangleOptions extends IObjectOptions { } export class Triangle extends Object { /** @@ -4379,19 +3810,12 @@ export class Triangle extends Object { * @param [options] Options object */ constructor(options?: ITriangleOptions); - - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; /** * Returns SVG representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; - /** * Returns Triangle instance from an object representation * @param object Object to create an instance from From 83bd66ec839d67aba99d0ef48b8f3eb53e0dd497 Mon Sep 17 00:00:00 2001 From: saranshkataria Date: Tue, 19 Feb 2019 16:27:08 -0800 Subject: [PATCH 047/222] updated stripe types, added unit_label in products --- types/stripe/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 2b46cbb3af..41e591c839 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -16,6 +16,7 @@ // Simon Schick // Slava Yultyyev // Corey Psoinos +// Saransh Kataria // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -3383,6 +3384,12 @@ declare namespace Stripe { * May only be set if type=service. */ statement_descriptor?: string; + + /** + * A label that represents units of this product, such as seat(s), in Stripe and on customers’ receipts and invoices. + * Only available on products of type=service. + */ + unit_label?: string; } interface IProductUpdateOptions extends IDataOptionsWithMetadata { From b983812c4dc891c0fc7e9794c454b28e43978d1d Mon Sep 17 00:00:00 2001 From: antoinebrault Date: Tue, 19 Feb 2019 19:46:29 -0500 Subject: [PATCH 048/222] cleanup --- types/jest/jest-tests.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 693c16d44f..578ce0132e 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -358,6 +358,15 @@ interface SpyInterface { prop?: number; method?: (arg1: boolean) => void; } +const spiedTarget = { + returnsVoid(): void { }, + setValue(value: string): void { + this.value = value; + }, + returnsString(): string { + return ""; + } +}; class SpiedTargetClass { private _value = 3; private _value2 = ''; @@ -374,15 +383,7 @@ class SpiedTargetClass { this._value2 = value2; } } -const spiedTarget = { - returnsVoid(): void { }, - setValue(value: string): void { - this.value = value; - }, - returnsString(): string { - return ""; - } -}; + const spiedTarget2 = new SpiedTargetClass(); // $ExpectError From acb6157ad35ff6113ae86a46a52c9785651fb795 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Tue, 19 Feb 2019 20:19:04 -0500 Subject: [PATCH 049/222] Updated some of the definitions --- types/fabric/fabric-impl.d.ts | 177 ++++++++++++++++++++++++++++++---- 1 file changed, 159 insertions(+), 18 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index f511e8f528..473c0aaf23 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -628,7 +628,6 @@ interface IPatternOptions { export interface Pattern extends IPatternOptions { } export class Pattern { constructor(options?: IPatternOptions); - initialise(options?: IPatternOptions): Pattern; /** * Returns object representation of a pattern * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output @@ -1472,6 +1471,32 @@ export class StaticCanvas { * @param [callback] Receives cloned instance as a first argument */ cloneWithoutData(callback: Function): void; + + /** + * Populates canvas with data from the specified dataless JSON. + * JSON format must conform to the one of {@link fabric.Canvas#toDatalessJSON} + * @deprecated since 1.2.2 + * @param {String|Object} json JSON string or object + * @param {Function} callback Callback, invoked when json is parsed + * and corresponding objects (e.g: {@link fabric.Image}) + * are initialized + * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. + * @return {fabric.Canvas} instance + * @chainable + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization} + */ + loadFromDatalessJSON(json: any, callback?: Function, reviver?: Function): Canvas; + /** + * Populates canvas with data from the specified JSON. + * JSON format must conform to the one of {@link fabric.Canvas#toJSON} + * @param {String|Object} json JSON string or object + * @param {Function} callback Callback, invoked when json is parsed + * and corresponding objects (e.g: {@link fabric.Image}) + * are initialized + * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. + * @return {fabric.Canvas} instance + */ + loadFromJSON(json: any, callback?: Function, reviver?: Function): Canvas; } interface ICanvasOptions extends IStaticCanvasOptions { @@ -1775,7 +1800,7 @@ export class Canvas { * @param {Boolean} ignoreZoom * @return {Object} object with "x" and "y" number values */ - getPointer(e: Event, ignoreZoom: boolean): { x: number; y: number; }; + getPointer(e: Event, ignoreZoom?: boolean): { x: number; y: number; }; /** * Returns context of canvas where object selection is drawn * @return {CanvasRenderingContext2D} @@ -2149,7 +2174,6 @@ export class Image { * @param [options] Options object */ constructor(element?: string | HTMLImageElement, options?: IImageOptions); - initialize(element?: string | HTMLImageElement, options?: IImageOptions): void; /** * Returns image element which this instance if based on * @return Image element @@ -2268,7 +2292,6 @@ export class Line { * @param [options] Options object */ constructor(points?: number[], objObjects?: ILineOptions); - initialize(points?: number[], options?: ILineOptions): Line; /** * Returns svg representation of an instance * @return {Array} an array of strings with the specific svg representation @@ -3045,11 +3068,6 @@ export class Object { */ setAngle(angle: number): Object; - /** - * Removes object from canvas to which it was added last - */ - remove(): Object; - /** * Sets object's properties from options * @param [options] Options object @@ -3300,7 +3318,6 @@ export class Path { pathOffset: Point; - initialize(path?: Point[], options?: IPathOptions): Path; /** * Returns svg clipPath representation of an instance * @param {Function} [reviver] Method for further parsing of svg representation. @@ -3366,7 +3383,6 @@ export class Polyline extends Object { * @param [skipOffset] Whether points offsetting should be skipped */ constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions); - initialize(points: Point[], options?: IPolylineOptions): void; /** * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) */ @@ -3403,7 +3419,6 @@ export class Rect extends Object { * @param [options] Options object */ constructor(options?: IRectOptions); - initialize(options?: IRectOptions): Rect; /** * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) */ @@ -3510,10 +3525,10 @@ interface TextOptions extends IObjectOptions { * @type {Number} */ deltaY?: number; + text?: string; } export interface Text extends TextOptions { } export class Text extends Object { - text?: string; /** * Constructor * @param text Text string @@ -3541,7 +3556,7 @@ export class Text extends Object { * text and itext do not have wrapping, return false * @return {Boolean} */ - isEndOfWrapping(): boolean; + isEndOfWrapping(lineIndex: number): boolean; /** * Returns string representation of an instance */ @@ -3675,7 +3690,7 @@ interface ITextOptions extends TextOptions { path?: string; useNative?: boolean; } -export interface IText extends ITextOptions, IObservable { } +export interface IText extends ITextOptions { } export class IText extends Text { /** * Constructor @@ -3683,7 +3698,6 @@ export class IText extends Text { * @param [options] Options object */ constructor(text: string, options?: ITextOptions); - initialize(text: string, options?: ITextOptions): IText; /** * Sets selection start (left boundary of a selection) * @param {Number} index Index to set selection start to @@ -3736,6 +3750,133 @@ export class IText extends Text { * @param {function} [callback] invoked with new instance as argument */ static fromObject(object: any, callback?: Function): IText; + /** + * Initializes all the interactive behavior of IText + */ + initBehavior(): void; + onDeselect(): void; + /** + * Initializes "added" event handler + */ + initAddedHandler(): void; + /** + * Initializes delayed cursor + */ + initDelayedCursor(): void; + /** + * Aborts cursor animation and clears all timeouts + */ + abortCursorAnimation(): void; + /** + * Selects entire text + * @return {fabric.IText} thisArg + * @chainable + */ + selectAll(): IText; + /** + * Returns selected text + * @return {String} + */ + getSelectedText(): string; + /** + * Find new selection index representing start of current word according to current selection index + * @param {Number} startFrom Surrent selection index + * @return {Number} New selection index + */ + findWordBoundaryLeft(startFrom: number): number; + /** + * Find new selection index representing end of current word according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findWordBoundaryRight(startFrom: number): number; + /** + * Find new selection index representing start of current line according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findLineBoundaryLeft(startFrom: number): number; + /** + * Find new selection index representing end of current line according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findLineBoundaryRight(startFrom: number): number; + /** + * Finds index corresponding to beginning or end of a word + * @param {Number} selectionStart Index of a character + * @param {Number} direction 1 or -1 + * @return {Number} Index of the beginning or end of a word + */ + searchWordBoundary(selectionStart: number, direction: number): number; + /** + * Selects a word based on the index + * @param {Number} selectionStart Index of a character + */ + selectWord(selectionStart: number): void; + /** + * Selects a line based on the index + * @param {Number} selectionStart Index of a character + * @return {fabric.IText} thisArg + * @chainable + */ + selectLine(selectionStart: number): IText; + /** + * Enters editing state + * @return {fabric.IText} thisArg + * @chainable + */ + enterEditing(): IText; + /** + * Initializes "mousemove" event handler + */ + initMouseMoveHandler(): void; + /** + * Exits from editing state + * @return {fabric.IText} thisArg + * @chainable + */ + exitEditing(): IText; + /** + * remove and reflow a style block from start to end. + * @param {Number} start linear start position for removal (included in removal) + * @param {Number} end linear end position for removal ( excluded from removal ) + */ + removeStyleFromTo(start: number, end: number): void; + /** + * Shifts line styles up or down + * @param {Number} lineIndex Index of a line + * @param {Number} offset Can any number? + */ + shiftLineStyles(lineIndex: number, offset: number): void; + /** + * Inserts new style object + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Number} qty number of lines to add + * @param {Array} copiedStyle Array of objects styles + */ + insertNewlineStyleObject(lineIndex: number, charIndex: number, qty: number, copiedStyle: any[]): void; + /** + * Inserts style object for a given line/char index + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Number} quantity number Style object to insert, if given + * @param {Array} copiedStyle array of style objecs + */ + insertCharStyleObject(lineIndex: number, charIndex: number, quantity: number, copiedStyle: any[]): void; + /** + * Inserts style object(s) + * @param {Array} insertedText Characters at the location where style is inserted + * @param {Number} start cursor index for inserting style + * @param {Array} [copiedStyle] array of style objects to insert. + */ + insertNewStyleBlock(insertedText: any[], start: number, copiedStyle: any[]): void; + /** + * Set the selectionStart and selectionEnd according to the ne postion of cursor + * mimic the key - mouse navigation when shift is pressed. + */ + setSelectionStartEndWithShift(start: number, end: number, newSelection: number): void; } interface ITextboxOptions extends ITextOptions { /** @@ -3767,7 +3908,7 @@ interface ITextboxOptions extends ITextOptions { */ splitByGrapheme?: boolean; } -export interface Textbox extends ITextboxOptions, IObservable{} +export interface Textbox extends ITextboxOptions{} export class Textbox extends IText { /** * Constructor @@ -4699,7 +4840,7 @@ interface IUtilMisc { * @param elements SVG elements to group * @param [options] Options object */ - groupSVGElements(elements: any[], options?: any, path?: any): PathGroup; + groupSVGElements(elements: any[], options?: any, path?: string): Object | Group; /** * Populates an object with properties of another object From 0e268d83a912b13ee31d5fe4aa270242946b12ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Alvergnat?= Date: Tue, 19 Feb 2019 11:13:42 +0100 Subject: [PATCH 050/222] Fix handlebars-helpers as handlebars types are now included in npm package --- types/handlebars-helpers/package.json | 6 ++++++ types/handlebars-helpers/tsconfig.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 types/handlebars-helpers/package.json diff --git a/types/handlebars-helpers/package.json b/types/handlebars-helpers/package.json new file mode 100644 index 0000000000..bd9f09c2c3 --- /dev/null +++ b/types/handlebars-helpers/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "handlebars": ">=4.1.0" + } +} diff --git a/types/handlebars-helpers/tsconfig.json b/types/handlebars-helpers/tsconfig.json index e822854459..6b03737014 100644 --- a/types/handlebars-helpers/tsconfig.json +++ b/types/handlebars-helpers/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es2015" ], "noImplicitAny": true, "noImplicitThis": false, From 11b660f12a0aa2ee34e76dfe757663e7a9720b99 Mon Sep 17 00:00:00 2001 From: David Mair Spiess Date: Wed, 20 Feb 2019 10:16:22 +0100 Subject: [PATCH 051/222] react-avatar-editor: add missing onPositionChange parameter --- types/react-avatar-editor/index.d.ts | 18 +++++++++--------- .../react-avatar-editor-tests.tsx | 14 +++++++++++--- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/types/react-avatar-editor/index.d.ts b/types/react-avatar-editor/index.d.ts index 3d4135120c..00603c898e 100644 --- a/types/react-avatar-editor/index.d.ts +++ b/types/react-avatar-editor/index.d.ts @@ -3,26 +3,26 @@ // Definitions by: Diogo Corrêa // Gabriel Prates // Laurent Senta +// David Spiess // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; -export interface ImageState { - height: number; - width: number; +export interface Position { x: number; y: number; - resource: ImageData; } -export interface CroppedRect { - x: number; - y: number; +export interface CroppedRect extends Position { width: number; height: number; } +export interface ImageState extends CroppedRect { + resource: ImageData; +} + export interface AvatarEditorProps { className?: string; image: string | File; @@ -33,7 +33,7 @@ export interface AvatarEditorProps { color?: number[]; style?: object; scale?: number; - position?: object; + position?: Position; rotate?: number; crossOrigin?: string; disableDrop?: boolean; @@ -44,7 +44,7 @@ export interface AvatarEditorProps { onMouseUp?(): void; onMouseMove?(event: Event): void; onImageChange?(): void; - onPositionChange?(): void; + onPositionChange?(position: Position): void; } export default class AvatarEditor extends React.Component { diff --git a/types/react-avatar-editor/react-avatar-editor-tests.tsx b/types/react-avatar-editor/react-avatar-editor-tests.tsx index bee4ff6a56..5942f55a7e 100644 --- a/types/react-avatar-editor/react-avatar-editor-tests.tsx +++ b/types/react-avatar-editor/react-avatar-editor-tests.tsx @@ -1,8 +1,16 @@ import * as React from "react"; -import AvatarEditor, { ImageState, CroppedRect } from "react-avatar-editor"; +import AvatarEditor, { + ImageState, + CroppedRect, + Position +} from "react-avatar-editor"; const file: File = new File(["str"], "image.jpg"); const image: ImageData = new ImageData(1, 2); +const position: Position = { + x: 1, + y: 1 +}; const imageState: ImageState = { height: 1, width: 1, @@ -34,7 +42,7 @@ class AvatarEditorTest extends React.Component { - + @@ -45,7 +53,7 @@ class AvatarEditorTest extends React.Component { {}} /> {}} /> {}} /> - {}} /> + {}} /> { From 41e641d8b346f7f4c3a19821d9f388d4195f754a Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Wed, 20 Feb 2019 18:54:28 +0800 Subject: [PATCH 052/222] sinon: add overrides parameter to createStubInstance --- types/sinon/index.d.ts | 7 ++++++- types/sinon/sinon-tests.ts | 3 +++ types/sinon/ts3.1/index.d.ts | 4 +++- types/sinon/ts3.1/sinon-tests.ts | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 7295119c66..321a6174fd 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -1618,10 +1618,15 @@ declare namespace Sinon { * * @template TType Type being stubbed. * @param constructor Object or class to stub. + * @param overrides An optional map overriding created stubs * @returns A stubbed version of the constructor. * @remarks The given constructor function is not invoked. See also the stub API. */ - createStubInstance(constructor: StubbableType): SinonStubbedInstance; + createStubInstance( + constructor: StubbableType, + overrides?: { [K in keyof TType]?: any } + ): SinonStubbedInstance; + } interface SinonApi { diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index aebe96ae25..9e76b20bbe 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -87,6 +87,9 @@ function testSandbox() { const privateFooFoo: sinon.SinonStub = privateFooStubbedInstance.foo; const clsBar: number = stubInstance.bar; const privateFooBar: number = privateFooStubbedInstance.bar; + sb.createStubInstance(cls, { + bar: 1 + }); } function testFakeServer() { diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index 7123e75d49..0ddf54a3b1 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -1707,11 +1707,13 @@ declare namespace Sinon { * * @template TType Type being stubbed. * @param constructor Object or class to stub. + * @param overrides An optional map overriding created stubs * @returns A stubbed version of the constructor. * @remarks The given constructor function is not invoked. See also the stub API. */ createStubInstance( - constructor: StubbableType + constructor: StubbableType, + overrides?: { [K in keyof TType]?: any } ): SinonStubbedInstance; } diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index 2db25348ae..d1f2e4c1bb 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -87,6 +87,9 @@ function testSandbox() { const privateFooFoo: sinon.SinonStub = privateFooStubbedInstance.foo; const clsBar: number = stubInstance.bar; const privateFooBar: number = privateFooStubbedInstance.bar; + sb.createStubInstance(cls, { + bar: 1 + }); } function testFakeServer() { From c067e0f906d5f0b4ba11d8d1415607c8311eb2dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 12:05:59 +0100 Subject: [PATCH 053/222] Type the drag and drop addon Closes #33224 which you can see for context. --- .../react-big-calendar/lib/addons/dragAndDrop.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 types/react-big-calendar/lib/addons/dragAndDrop.d.ts diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts new file mode 100644 index 0000000000..0ebdcf98f9 --- /dev/null +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -0,0 +1,14 @@ + import BigCalendar, { BigCalendarProps, Event } from 'react-big-calendar'; + + type withDragAndDropProps = { + onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; + onEventResize?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; + resizable?: boolean; + }; + + declare class DragAndDropCalendar + extends React.Component & withDragAndDropProps>, {} + + function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; + export = withDragAndDrop; + From 4d2fc7e27b21e9d74b43d8fd5bcff772079dbb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 12:07:17 +0100 Subject: [PATCH 054/222] Fix indentation --- .../lib/addons/dragAndDrop.d.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index 0ebdcf98f9..8c9c21fc98 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -1,14 +1,14 @@ - import BigCalendar, { BigCalendarProps, Event } from 'react-big-calendar'; +import BigCalendar, { BigCalendarProps, Event } from 'react-big-calendar'; - type withDragAndDropProps = { - onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; - onEventResize?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; - resizable?: boolean; - }; +type withDragAndDropProps = { + onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; + onEventResize?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; + resizable?: boolean; +}; - declare class DragAndDropCalendar - extends React.Component & withDragAndDropProps>, {} +declare class DragAndDropCalendar + extends React.Component & withDragAndDropProps>, {} + +function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; +export = withDragAndDrop; - function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; - export = withDragAndDrop; - From 5a233501941f9a4c9e3fedf5f81b0b05467d6f5e Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Wed, 20 Feb 2019 19:17:57 +0800 Subject: [PATCH 055/222] Fix a lint error --- types/sinon/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 321a6174fd..d05495078c 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -1626,7 +1626,6 @@ declare namespace Sinon { constructor: StubbableType, overrides?: { [K in keyof TType]?: any } ): SinonStubbedInstance; - } interface SinonApi { From 632ee1aa3a13a4a2e0ec7077a360f7231a242634 Mon Sep 17 00:00:00 2001 From: Igor Morozov Date: Wed, 20 Feb 2019 14:51:17 +0300 Subject: [PATCH 056/222] Add body to the HTTPError class According to this https://github.com/sindresorhus/got/blob/ada5861347cd59e59b537042f41f0572e13769d4/source/errors.ts#L96 HTTPError has response body in the body property --- types/got/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 0c847d6489..a9f289b831 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -36,6 +36,7 @@ declare class HTTPError extends StdError { statusCode: number; statusMessage: string; headers: http.IncomingHttpHeaders; + body: Buffer | string | object; } declare class MaxRedirectsError extends StdError { From 3318b6d29db08e4fd2bbb3af86678153886b014a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 13:00:42 +0100 Subject: [PATCH 057/222] Add the file to `tsconfig.json` to avoid test failure --- types/react-big-calendar/tsconfig.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/react-big-calendar/tsconfig.json b/types/react-big-calendar/tsconfig.json index eddf55cc13..8722501ef7 100644 --- a/types/react-big-calendar/tsconfig.json +++ b/types/react-big-calendar/tsconfig.json @@ -20,6 +20,7 @@ }, "files": [ "index.d.ts", - "react-big-calendar-tests.tsx" + "react-big-calendar-tests.tsx", + "lib/addons/dragAndDrop.d.ts" ] -} \ No newline at end of file +} From b5a5b6414882a0d3b433c90f53e13cb7b43cd3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 13:06:15 +0100 Subject: [PATCH 058/222] Use a relative import --- types/react-big-calendar/lib/addons/dragAndDrop.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index 8c9c21fc98..9b96bb7f7e 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -1,4 +1,4 @@ -import BigCalendar, { BigCalendarProps, Event } from 'react-big-calendar'; +import BigCalendar, { BigCalendarProps, Event } from '../../index.d.ts'; type withDragAndDropProps = { onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; From 6eb9c5a828c1a07f4047e698eb4741cb8d705ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 13:13:12 +0100 Subject: [PATCH 059/222] Address more test failures --- types/react-big-calendar/lib/addons/dragAndDrop.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index 9b96bb7f7e..0908373780 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -1,14 +1,14 @@ -import BigCalendar, { BigCalendarProps, Event } from '../../index.d.ts'; +import BigCalendar, { BigCalendarProps, Event, stringOrDate } from '../../index'; +import React from 'react'; -type withDragAndDropProps = { +interface withDragAndDropProps { onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; onEventResize?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; resizable?: boolean; }; declare class DragAndDropCalendar - extends React.Component & withDragAndDropProps>, {} + extends React.Component & withDragAndDropProps> {} -function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; +declare function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; export = withDragAndDrop; - From 84d49f513578f029f836fbc3f7019d67ffe0e95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 13:18:54 +0100 Subject: [PATCH 060/222] Address more build failures --- types/react-big-calendar/lib/addons/dragAndDrop.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index 0908373780..bee2f112c6 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -1,11 +1,11 @@ import BigCalendar, { BigCalendarProps, Event, stringOrDate } from '../../index'; -import React from 'react'; +import React = require('react'); interface withDragAndDropProps { onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; onEventResize?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; resizable?: boolean; -}; +} declare class DragAndDropCalendar extends React.Component & withDragAndDropProps> {} From 1cbd2cd12a2daf5ef4e828ad2b13e41f39ecf9f7 Mon Sep 17 00:00:00 2001 From: ntnyq Date: Wed, 20 Feb 2019 20:35:57 +0800 Subject: [PATCH 061/222] Added the lost options force --- types/gulp-gh-pages/gulp-gh-pages-tests.ts | 3 +++ types/gulp-gh-pages/index.d.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/types/gulp-gh-pages/gulp-gh-pages-tests.ts b/types/gulp-gh-pages/gulp-gh-pages-tests.ts index e541f18508..6fee2842e0 100644 --- a/types/gulp-gh-pages/gulp-gh-pages-tests.ts +++ b/types/gulp-gh-pages/gulp-gh-pages-tests.ts @@ -19,5 +19,8 @@ gulp.src("test.css") gulp.src("test.css") .pipe(ghPages({push: false})); +gulp.src("test.css") + .pipe(ghPages({ force: true })); + gulp.src("test.css") .pipe(ghPages({message: "master"})); diff --git a/types/gulp-gh-pages/index.d.ts b/types/gulp-gh-pages/index.d.ts index f01b9890f1..782f9e9b56 100644 --- a/types/gulp-gh-pages/index.d.ts +++ b/types/gulp-gh-pages/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for gulp-gh-pages // Project: https://github.com/rowoot/gulp-gh-pages // Definitions by: Asana +// Ntnyq // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -12,6 +13,7 @@ interface Options { branch?: string; cacheDir?: string; push?: boolean; + force?: boolean; message?: string; } From d7baa6af78084677e85663bfb6fd997cca735559 Mon Sep 17 00:00:00 2001 From: Gordon Date: Wed, 20 Feb 2019 08:20:31 -0600 Subject: [PATCH 062/222] 'Refine' returns a SearchState --- types/react-instantsearch-core/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index a4bc0b194a..0092feb370 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -73,7 +73,7 @@ export interface ConnectorDescription { props: TExposed, searchState: SearchState, ...args: any[], - ): any; + ): SearchState; /** * This method applies the current props and state to the provided SearchParameters, and returns a new SearchParameters. The SearchParameters From 0d413bd7372143b40dd463e8856b950b2f2e5af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 15:53:52 +0100 Subject: [PATCH 063/222] Use ES import to see if it works --- types/react-big-calendar/lib/addons/dragAndDrop.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index bee2f112c6..072bb2ebfa 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -1,5 +1,5 @@ import BigCalendar, { BigCalendarProps, Event, stringOrDate } from '../../index'; -import React = require('react'); +import React from 'react'; interface withDragAndDropProps { onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; From ea27c4bbd892cb29c7a1ecbabfb3874678d97479 Mon Sep 17 00:00:00 2001 From: AntoineDoubovetzky Date: Wed, 20 Feb 2019 16:18:51 +0100 Subject: [PATCH 064/222] improve types/mui-datatables --- types/mui-datatables/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/mui-datatables/index.d.ts b/types/mui-datatables/index.d.ts index 2dffabbc53..1bdf9fc07f 100644 --- a/types/mui-datatables/index.d.ts +++ b/types/mui-datatables/index.d.ts @@ -105,7 +105,7 @@ export interface MUIDataTableColumnOptions { hint?: string; customHeadRender?: (columnMeta: MUIDataTableCustomHeadRenderer, updateDirection: (params: any) => any) => string; customBodyRender?: (value: any, tableMeta: MUIDataTableMeta, updateValue: (s: any, c: any, p: any) => any) => string | React.ReactNode; - setCellProps?: (cellValue: string, rowIndex: number, columnIndex: number) => string; + setCellProps?: (cellValue: string, rowIndex: number, columnIndex: number) => object; } export interface MUIDataTableOptions { @@ -117,7 +117,7 @@ export interface MUIDataTableOptions { textLabels?: MUIDataTableTextLabels; pagination?: boolean; selectableRows?: boolean; - IsRowSelectable?: (dataIndex: any) => boolean; + IsRowSelectable?: (dataIndex: number) => boolean; resizableColumns?: boolean; expandableRows?: boolean; renderExpandableRow?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => React.ReactNode; @@ -143,7 +143,7 @@ export interface MUIDataTableOptions { onRowsSelect?: (currentRowsSelected: any[], rowsSelected: any[]) => void; onRowsDelete?: (rowsDeleted: any[]) => void; onRowClick?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => void; - onCellClick?: (colIndex: number, rowIndex: number) => void; + onCellClick?: (colData: any, cellMeta: { colIndex: number, rowIndex: number, dataIndex: number }) => void; onChangePage?: (currentPage: number) => void; onChangeRowsPerPage?: (numberOfRows: number) => void; onSearchChange?: (searchText: string) => void; @@ -151,7 +151,7 @@ export interface MUIDataTableOptions { onColumnSortChange?: (changedColumn: string, direction: string) => void; onColumnViewChange?: (changedColumn: string, action: string) => void; onTableChange?: (action: string, tableState: object) => void; - setRowProps?: (row: any[], rowIndex: number) => any; + setRowProps?: (row: any[], rowIndex: number) => object; } export type MUIDataTableColumnDef = string | MUIDataTableColumn; From e529abd8fa0dda3291bbfa08c6b7f33c7e3f27ba Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Wed, 20 Feb 2019 15:22:31 +0000 Subject: [PATCH 065/222] imap-simple: sync description format of search() The description of the `search()` method uses the phrase "in the previously opened mailbox", which is inconsistent with what's used in `onmail()`, `append()` and `moveMessage()`, i.e. "in the currently open mailbox". This change rewords the first passage to match the other ones. --- types/imap-simple/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/imap-simple/index.d.ts b/types/imap-simple/index.d.ts index 398bcb6a26..f346d51e52 100644 --- a/types/imap-simple/index.d.ts +++ b/types/imap-simple/index.d.ts @@ -55,7 +55,7 @@ export class ImapSimple extends NodeJS.EventEmitter { getBoxes(callback: (err: Error, boxes: Imap.MailBoxes) => void): void; getBoxes(): Promise; - /** Search for and retrieve mail in the previously opened mailbox. */ + /** Search for and retrieve mail in the currently open mailbox. */ search(searchCriteria: any[], fetchOptions: Imap.FetchOptions, callback: (err: Error, messages: Message[]) => void): void; search(searchCriteria: any[], fetchOptions: Imap.FetchOptions): Promise; From f0197615ef318a4ec74685e3991fa3d8d8010d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 17:26:12 +0100 Subject: [PATCH 066/222] Fix the ES import --- types/react-big-calendar/lib/addons/dragAndDrop.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index 072bb2ebfa..583e6d0e30 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -1,5 +1,5 @@ import BigCalendar, { BigCalendarProps, Event, stringOrDate } from '../../index'; -import React from 'react'; +import * as React from 'react'; interface withDragAndDropProps { onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; From 3ec4ae1d819f4d61ad4b6518d264c5f038894cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 17:26:58 +0100 Subject: [PATCH 067/222] Use default export --- types/react-big-calendar/lib/addons/dragAndDrop.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts index 583e6d0e30..a1b7d01dad 100644 --- a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -11,4 +11,4 @@ declare class DragAndDropCalendar & withDragAndDropProps> {} declare function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; -export = withDragAndDrop; +export default withDragAndDrop; From 40d20c7022cc9af3ccce2019ea6c06e0ddbc96a3 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Wed, 20 Feb 2019 11:32:10 -0500 Subject: [PATCH 068/222] Updated Canvas and StaticCanvas --- types/fabric/fabric-impl.d.ts | 147 ++++++++++++++++++++++++---------- 1 file changed, 106 insertions(+), 41 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 473c0aaf23..e00a180b6e 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -1051,6 +1051,12 @@ interface IStaticCanvasOptions { * @type Boolean */ svgViewportTransformation: boolean; + /** + * Animation duration (in ms) for fx* methods + * @type Number + */ + FX_DURATION?: number; + } export interface StaticCanvas extends IObservable, IStaticCanvasOptions, ICollection, ICanvasAnimation { } export class StaticCanvas { @@ -1068,7 +1074,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - calcOffset(): StaticCanvas; + calcOffset(): Canvas; /** * Sets {@link fabric.StaticCanvas#overlayImage|overlay image} for this canvas @@ -1078,7 +1084,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - setOverlayImage(image: Image | string, callback: (img: HTMLImageElement | undefined) => void, options?: IImageOptions): StaticCanvas; + setOverlayImage(image: Image | string, callback: Function, options?: IImageOptions): Canvas; /** * Sets {@link fabric.StaticCanvas#backgroundImage|background image} for this canvas @@ -1088,7 +1094,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - setBackgroundImage(image: Image | string, callback?: Function, options?: IImageOptions): StaticCanvas; + setBackgroundImage(image: Image | string, callback: Function, options?: IImageOptions): Canvas; /** * Sets {@link fabric.StaticCanvas#overlayColor|foreground color} for this canvas @@ -1097,7 +1103,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - setOverlayColor(overlayColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): StaticCanvas; + setOverlayColor(overlayColor: string | Pattern, callback: Function): Canvas; /** * Sets {@link fabric.StaticCanvas#backgroundColor|background color} for this canvas @@ -1106,7 +1112,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - setBackgroundColor(backgroundColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): StaticCanvas; + setBackgroundColor(backgroundColor: string | Pattern, callback: Function): Canvas; /** * Returns canvas width (in px) @@ -1127,7 +1133,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable true */ - setWidth(value: number | string, options?: ICanvasDimensionsOptions): StaticCanvas; + setWidth(value: number | string, options?: ICanvasDimensionsOptions): Canvas; /** * Sets height of this canvas instance @@ -1136,7 +1142,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable true */ - setHeight(value: number | string, options?: ICanvasDimensionsOptions): StaticCanvas; + setHeight(value: number | string, options?: ICanvasDimensionsOptions): Canvas; /** * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em) @@ -1145,7 +1151,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): StaticCanvas; + setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): Canvas; /** * Returns canvas zoom level @@ -1158,7 +1164,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - setViewportTransform(vpt: number[]): StaticCanvas; + setViewportTransform(vpt: number[]): Canvas; /** * Sets zoom level of this canvas instance, zoom centered around point @@ -1167,7 +1173,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable true */ - zoomToPoint(point: Point, value: number): StaticCanvas; + zoomToPoint(point: Point, value: number): Canvas; /** * Sets zoom level of this canvas instance @@ -1175,7 +1181,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - setZoom(value: number): StaticCanvas; + setZoom(value: number): Canvas; /** * Pan viewport so as to place point at top left corner of canvas @@ -1183,7 +1189,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - absolutePan(point: Point): StaticCanvas; + absolutePan(point: Point): Canvas; /** * Pans viewpoint relatively @@ -1191,7 +1197,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - relativePan(point: Point): StaticCanvas; + relativePan(point: Point): Canvas; /** * Returns element corresponding to this instance @@ -1204,7 +1210,7 @@ export class StaticCanvas { * @param ctx Context to clear * @chainable */ - clearContext(ctx: CanvasRenderingContext2D): StaticCanvas; + clearContext(ctx: CanvasRenderingContext2D): Canvas; /** * Returns context of canvas where objects are drawn @@ -1217,14 +1223,14 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - clear(): StaticCanvas; + clear(): Canvas; /** * Renders the canvas * @return {fabric.Canvas} instance * @chainable */ - renderAll(): StaticCanvas; + renderAll(): Canvas; /** * Function created to be instance bound at initialization @@ -1236,7 +1242,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - renderAndReset(): StaticCanvas; + renderAndReset(): Canvas; /** * Append a renderAll request to next animation frame. @@ -1245,7 +1251,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - requestRenderAll(): StaticCanvas; + requestRenderAll(): Canvas; /** * Calculate the position of the 4 corner of canvas with current viewportTransform. @@ -1254,9 +1260,7 @@ export class StaticCanvas { * @return {Object} points.tl * @chainable */ - calcViewportBoundaries(): StaticCanvas; - - cancelRequestedRender(): void; + calcViewportBoundaries(): {tl: Point, br: Point, tr: Point, bl: Point}; /** * Renders background, objects, overlay and controls. @@ -1265,7 +1269,7 @@ export class StaticCanvas { * @return {fabric.Canvas} instance * @chainable */ - renderCanvas(ctx: CanvasRenderingContext2D, objects: Object[] ): StaticCanvas; + renderCanvas(ctx: CanvasRenderingContext2D, objects: Object[] ): Canvas; /** * Paint the cached clipPath on the lowerCanvasEl @@ -1285,7 +1289,7 @@ export class StaticCanvas { * @param {fabric.Object} object Object to center horizontally * @return {fabric.Canvas} thisArg */ - centerObjectH(object: Object): StaticCanvas; + centerObjectH(object: Object): Canvas; /** * Centers object vertically in the canvas @@ -1293,7 +1297,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - centerObjectV(object: Object): StaticCanvas; + centerObjectV(object: Object): Canvas; /** * Centers object vertically and horizontally in the canvas @@ -1301,7 +1305,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - centerObject(object: Object): StaticCanvas; + centerObject(object: Object): Canvas; /** * Centers object vertically and horizontally in the viewport @@ -1309,7 +1313,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - viewportCenterObject(object: Object): StaticCanvas; + viewportCenterObject(object: Object): Canvas; /** * Centers object horizontally in the viewport, object.top is unchanged @@ -1317,7 +1321,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - viewportCenterObjectH(object: Object): StaticCanvas; + viewportCenterObjectH(object: Object): Canvas; /** * Centers object Vertically in the viewport, object.top is unchanged @@ -1325,7 +1329,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - viewportCenterObjectV(object: Object): StaticCanvas; + viewportCenterObjectV(object: Object): Canvas; /** * Calculate the point in canvas that correspond to the center of actual viewport. @@ -1360,7 +1364,7 @@ export class StaticCanvas { * @param [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation. * @return {String} SVG string */ - toSVG(options: IToSVGOptions, reviver?: Function): string; + toSVG(options?: IToSVGOptions, reviver?: Function): string; /** * Moves an object or the objects of a multiple selection @@ -1369,7 +1373,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - sendToBack(object: Object): StaticCanvas; + sendToBack(object: Object): Canvas; /** * Moves an object or the objects of a multiple selection @@ -1378,7 +1382,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - bringToFront(object: Object): StaticCanvas; + bringToFront(object: Object): Canvas; /** * Moves an object or a selection down in stack of drawn objects @@ -1391,7 +1395,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - sendBackwards(object: Object, intersecting?: boolean): StaticCanvas; + sendBackwards(object: Object, intersecting?: boolean): Canvas; /** * Moves an object or a selection up in stack of drawn objects @@ -1404,7 +1408,7 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - bringForward(object: Object, intersecting?: boolean): StaticCanvas; + bringForward(object: Object, intersecting?: boolean): Canvas; /** * Moves an object to specified level in stack of drawn objects @@ -1413,13 +1417,13 @@ export class StaticCanvas { * @return {fabric.Canvas} thisArg * @chainable */ - moveTo(object: Object, index: number): StaticCanvas; + moveTo(object: Object, index: number): Canvas; /** * Clears a canvas element and dispose objects * @return {fabric.Canvas} thisArg * @chainable */ - dispose(): StaticCanvas; + dispose(): Canvas; /** * Returns a string representation of an instance @@ -1462,7 +1466,7 @@ export class StaticCanvas { * @param [callback] Receives cloned instance as a first argument * @param [properties] Array of properties to include in the cloned canvas and children */ - clone(callback: Function, properties?: string[]): void; + clone(callback?: any, properties?: string[]): void; /** * Clones canvas instance without cloning existing data. @@ -1470,7 +1474,7 @@ export class StaticCanvas { * but leaves data empty (so that you can populate it with your own) * @param [callback] Receives cloned instance as a first argument */ - cloneWithoutData(callback: Function): void; + cloneWithoutData(callback?: any): void; /** * Populates canvas with data from the specified dataless JSON. @@ -1485,7 +1489,7 @@ export class StaticCanvas { * @chainable * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization} */ - loadFromDatalessJSON(json: any, callback?: Function, reviver?: Function): Canvas; + loadFromDatalessJSON(json: any, callback: Function, reviver?: Function): Canvas; /** * Populates canvas with data from the specified JSON. * JSON format must conform to the one of {@link fabric.Canvas#toJSON} @@ -1496,7 +1500,64 @@ export class StaticCanvas { * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. * @return {fabric.Canvas} instance */ - loadFromJSON(json: any, callback?: Function, reviver?: Function): Canvas; + loadFromJSON(json: any, callback: Function, reviver?: Function): Canvas; + /** + * Creates markup containing SVG font faces, + * font URLs for font faces must be collected by developers + * and are not extracted from the DOM by fabricjs + * @param {Array} objects Array of fabric objects + * @return {String} + */ + createSVGFontFacesMarkup(objects: any[]): string; + /** + * Creates markup containing SVG referenced elements like patterns, gradients etc. + * @return {String} + */ + createSVGRefElementsMarkup(): string; + /** + * Centers object horizontally with animation. + * @param {fabric.Object} object Object to center + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxCenterObjectH(object: Object, callbacks?: Callbacks): Canvas; + /** + * Centers object vertically with animation. + * @param {fabric.Object} object Object to center + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxCenterObjectV(object: Object, callbacks?: Callbacks): Canvas; + /** + * Same as `fabric.Canvas#remove` but animated + * @param {fabric.Object} object Object to remove + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxRemove(object: Object, callbacks?: Callbacks): Canvas; + /** + * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxStraightenObject(object: Object): Canvas; + /** + * Straightens object, then rerenders canvas + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + * @chainable + */ + straightenObject(object: Object): Canvas; } interface ICanvasOptions extends IStaticCanvasOptions { @@ -1570,7 +1631,7 @@ interface ICanvasOptions extends IStaticCanvasOptions { * @type String|Array * @default */ - selectionKey?: string; + selectionKey?: string | string[]; /** * Indicates which key enable alternative selection @@ -1584,7 +1645,7 @@ interface ICanvasOptions extends IStaticCanvasOptions { * @type null|String * @default */ - altSelectionKey?: string; + altSelectionKey?: string | null; /** * Color of selection @@ -1869,6 +1930,10 @@ export class Canvas { * @param [propertiesToInclude] Any properties that you might want to additionally include in the output */ static toJSON(propertiesToInclude?: string[]): string; + /** + * Removes all event listeners + */ + removeListeners(): void; } /////////////////////////////////////////////////////////////////////////////// From 9fbdc9019b060ce0cb209f5aaf0abce218a6a910 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Wed, 20 Feb 2019 12:13:45 -0500 Subject: [PATCH 069/222] Updated type defs based on findings in test that have been verified and updated tests to ensure they are up to date with the latest definitions based on fabricjs codebase --- types/fabric/fabric-impl.d.ts | 20 ++++++------ types/fabric/test/index.ts | 60 ++++++++++++----------------------- 2 files changed, 30 insertions(+), 50 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index e00a180b6e..69c226988b 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -522,7 +522,7 @@ interface IGradientOptions { */ offsetY?: number; type?: string; - coords?: {x1: number, y1: number, x2: number, y2: number, r1: number, r2: number}; + coords?: {x1?: number, y1?: number, x2?: number, y2?: number, r1?: number, r2?: number}; /** * Color stops object eg. {0:string; 1:string; */ @@ -931,7 +931,7 @@ interface IStaticCanvasOptions { * vale. As an alternative you can disable image objectCaching * @type fabric.Image */ - backgroundImage?: Image; + backgroundImage?: Image | string; /** * Overlay color of canvas instance. * Should be set via {@link fabric.StaticCanvas#setOverlayColor} @@ -1050,7 +1050,7 @@ interface IStaticCanvasOptions { * a zoomed canvas will then produce zoomed SVG output. * @type Boolean */ - svgViewportTransformation: boolean; + svgViewportTransformation?: boolean; /** * Animation duration (in ms) for fx* methods * @type Number @@ -2335,19 +2335,19 @@ interface ILineOptions extends IObjectOptions { /** * x value or first line edge */ - x1: number; + x1?: number; /** * x value or second line edge */ - x2: number; + x2?: number; /** * y value or first line edge */ - y1: number; + y1?: number; /** * y value or second line edge */ - y2: number; + y2?: number; } export interface Line extends Object, ILineOptions { } export class Line { @@ -2599,7 +2599,7 @@ interface IObjectOptions { /** * Shadow object representing shadow of this shape */ - shadow?: Shadow; + shadow?: Shadow | string; /** * Opacity of object's controlling borders when object is active and moving @@ -3536,7 +3536,7 @@ interface TextOptions extends IObjectOptions { * "justify-left", "justify-center" or "justify-right". * @type String */ - textAlign?: 'left' | 'center' | 'right' | 'justify' | 'justify-left' | 'justify-center' | 'justify-right'; + textAlign?: string; /** * Font style . Possible values: "", "normal", "italic" or "oblique". * @type String @@ -3572,7 +3572,7 @@ interface TextOptions extends IObjectOptions { * Backwards incompatibility note: This property was named "textShadow" (String) until v1.2.11 * @type fabric.Shadow */ - shadow?: Shadow; + shadow?: Shadow | string; /** * additional space between characters * expressed in thousands of em unit diff --git a/types/fabric/test/index.ts b/types/fabric/test/index.ts index 9a5c0b24d2..cd8884710a 100644 --- a/types/fabric/test/index.ts +++ b/types/fabric/test/index.ts @@ -236,21 +236,21 @@ function sample4() { const topControl = $('top-control'); topControl.onchange = function(this: HTMLInputElement) { - rect.setTop(+this.value).setCoords(); + rect.set('top',+this.value).setCoords(); canvas.renderAll(); }; const leftControl = $('left-control'); leftControl.onchange = function(this: HTMLInputElement) { - rect.setLeft(+this.value).setCoords(); + rect.set('left',+this.value).setCoords(); canvas.renderAll(); }; function updateControls() { - scaleControl.value = rect.getScaleX().toString(); - angleControl.value = rect.getAngle().toString(); - leftControl.value = rect.getLeft().toString(); - topControl.value = rect.getTop().toString(); + scaleControl.value = rect.scaleX.toString(); + angleControl.value = rect.angle.toString(); + leftControl.value = rect.left.toString(); + topControl.value = rect.top.toString(); } canvas.on({ 'object:moving': updateControls, @@ -343,7 +343,7 @@ function sample6() { const distX = Math.abs(p.x - obj.left); const distY = Math.abs(p.y - obj.top); const dist = Math.round(Math.sqrt(Math.pow(distX, 2) + Math.pow(distY, 2))); - obj.setOpacity(1 / (dist / 20)); + obj.set('opacity', (1 / (dist / 20))); }); }); }); @@ -373,7 +373,7 @@ function sample7() { if (img.left > 900 || img.top > 500) { canvas.remove(img); } else { - img.setAngle(img.getAngle() + 2); + img.setAngle(img.angle + 2); } }); canvas.renderAll(); @@ -554,15 +554,8 @@ function sample8() { const removeSelectedEl = document.getElementById('remove-selected'); removeSelectedEl.onclick = () => { const activeObject = canvas.getActiveObject(); - const activeGroup = canvas.getActiveGroup(); if (activeObject) { canvas.remove(activeObject); - } else if (activeGroup) { - const objectsInGroup = activeGroup.getObjects(); - canvas.discardActiveGroup(); - objectsInGroup.forEach(object => { - canvas.remove(object); - }); } }; @@ -601,10 +594,9 @@ function sample8() { slider.onchange = function() { const activeObject = canvas.getActiveObject(); - const activeGroup = canvas.getActiveGroup(); - if (activeObject || activeGroup) { - (activeObject || activeGroup).setOpacity(parseInt(( this).value, 10) / 100); + if (activeObject) { + activeObject.set('opacity', (parseInt(( this).value, 10) / 100)); canvas.renderAll(); } }; @@ -632,10 +624,9 @@ function sample8() { colorpicker.onchange = function() { const activeObject = canvas.getActiveObject(); - const activeGroup = canvas.getActiveGroup(); - if (activeObject || activeGroup) { - (activeObject || activeGroup).setFill(( this).value); + if (activeObject) { + activeObject.set('fill', ( this).value); canvas.renderAll(); } }; @@ -768,16 +759,6 @@ function sample8() { updateComplexity(); }); - drawingColorEl.onchange = () => { - canvas.freeDrawingColor = drawingColorEl.value; - }; - drawingLineWidthEl.onchange = () => { - canvas.freeDrawingLineWidth = parseInt(drawingLineWidthEl.value, 10) || 1; // disallow 0, NaN, etc. - }; - - canvas.freeDrawingColor = drawingColorEl.value; - canvas.freeDrawingLineWidth = parseInt(drawingLineWidthEl.value, 10) || 1; - const text = `Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt @@ -802,7 +783,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; }; document.onkeydown = e => { - const obj = canvas.getActiveObject() || canvas.getActiveGroup(); + const obj = canvas.getActiveObject(); if (obj && e.keyCode === 8) { // this is horrible. need to fix, so that unified interface can be used if (obj.type === 'group') { @@ -832,8 +813,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const obj = canvas.getActiveObject(); if (obj) { obj.setGradient("fill", { - x2: (getRandomInt(0, 1) ? 0 : obj.width), - y2: (getRandomInt(0, 1) ? 0 : obj.height), + coords: {x2: (getRandomInt(0, 1) ? 0 : obj.width), y2: (getRandomInt(0, 1) ? 0 : obj.height)}, colorStops: { 0: '#' + getRandomColor(), 1: '#' + getRandomColor() @@ -871,8 +851,8 @@ laboris nisi ut aliquip ex ea commodo consequat.`; cmdUnderlineBtn.onclick = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.textDecoration = (activeObject.textDecoration === 'underline' ? '' : 'underline'); - (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; + activeObject.underline = !activeObject.underline; + (this as HTMLElement).className = activeObject.underline ? 'selected' : ''; canvas.renderAll(); } }; @@ -884,8 +864,8 @@ laboris nisi ut aliquip ex ea commodo consequat.`; cmdLinethroughBtn.onclick = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.textDecoration = (activeObject.textDecoration === 'line-through' ? '' : 'line-through'); - (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; + activeObject.linethrough = !activeObject.linethrough; + (this as HTMLElement).className = activeObject.linethrough ? 'selected' : ''; canvas.renderAll(); } }; @@ -897,8 +877,8 @@ laboris nisi ut aliquip ex ea commodo consequat.`; cmdOverlineBtn.onclick = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.textDecoration = (activeObject.textDecoration === 'overline' ? '' : 'overline'); - (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; + activeObject.overline = !activeObject.overline; + (this as HTMLElement).className = activeObject.overline ? 'selected' : ''; canvas.renderAll(); } }; From e45bd0ef9f4d58ce7c87f2b828f696978b27bc3a Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Wed, 20 Feb 2019 12:19:18 -0500 Subject: [PATCH 070/222] Removed definitions that already existed and were creating conflicts --- types/fabric/fabric-impl.d.ts | 50 ++++++----------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 69c226988b..48f9e56483 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -340,6 +340,14 @@ interface ICanvasAnimation { * @chainable */ fxRemove(object: Object): T; + + /** + * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxStraightenObject(object: Object): T; } interface IObjectAnimation { /** @@ -1051,11 +1059,6 @@ interface IStaticCanvasOptions { * @type Boolean */ svgViewportTransformation?: boolean; - /** - * Animation duration (in ms) for fx* methods - * @type Number - */ - FX_DURATION?: number; } export interface StaticCanvas extends IObservable, IStaticCanvasOptions, ICollection, ICanvasAnimation { } @@ -1514,43 +1517,6 @@ export class StaticCanvas { * @return {String} */ createSVGRefElementsMarkup(): string; - /** - * Centers object horizontally with animation. - * @param {fabric.Object} object Object to center - * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - * @return {fabric.Canvas} thisArg - * @chainable - */ - fxCenterObjectH(object: Object, callbacks?: Callbacks): Canvas; - /** - * Centers object vertically with animation. - * @param {fabric.Object} object Object to center - * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - * @return {fabric.Canvas} thisArg - * @chainable - */ - fxCenterObjectV(object: Object, callbacks?: Callbacks): Canvas; - /** - * Same as `fabric.Canvas#remove` but animated - * @param {fabric.Object} object Object to remove - * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - * @return {fabric.Canvas} thisArg - * @chainable - */ - fxRemove(object: Object, callbacks?: Callbacks): Canvas; - /** - * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated - * @param {fabric.Object} object Object to straighten - * @return {fabric.Canvas} thisArg - * @chainable - */ - fxStraightenObject(object: Object): Canvas; /** * Straightens object, then rerenders canvas * @param {fabric.Object} object Object to straighten From 48c4b1fc133a232fa37a625c467cfd7d7e248035 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Wed, 20 Feb 2019 16:25:30 -0500 Subject: [PATCH 071/222] Updated definitions for Object and IObjectOptions --- types/fabric/fabric-impl.d.ts | 309 +++++++++++++++++++++++++++------- 1 file changed, 252 insertions(+), 57 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 48f9e56483..700e4eca97 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -2349,6 +2349,7 @@ export class Line { */ makeEdgeToOriginGetter(propertyNames: {origin: number, axis1: any, axis2: any, dimension: any}, originValues: {nearest: any, center: any, farthest: any}): Function; } + interface IObjectOptions { /** * Type of an object (rect, circle, path, etc.). @@ -2417,15 +2418,15 @@ interface IObjectOptions { */ angle?: number; - /** - * Object skew factor (horizontal) - */ - skewX?: number; + /** + * Object skew factor (horizontal) + */ + skewX?: number; - /** - * Object skew factor (vertical) - */ - skewY?: number; + /** + * Object skew factor (vertical) + */ + skewY?: number; /** * Size of object's controlling corners (in pixels) @@ -2457,10 +2458,10 @@ interface IObjectOptions { */ borderColor?: string; - /** - * Array specifying dash pattern of an object's border (hasBorder must be true) - */ - borderDashArray?: number[]; + /** + * Array specifying dash pattern of an object's border (hasBorder must be true) + */ + borderDashArray?: number[]; /** * Color of controlling corners of an object (when it's active) @@ -2761,12 +2762,12 @@ interface IObjectOptions { cacheProperties?: string[]; /** - * A fabricObject that, without stroke define a clipping area with their shape. filled in black - * the clipPath object gets used when the object has rendered, and the context is placed in the center - * of the object cacheCanvas. - * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' - */ - clipPath?: Object; + * A fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the object has rendered, and the context is placed in the center + * of the object cacheCanvas. + * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' + */ + clipPath?: Object; /** * Meaningful ONLY when the object is used as clipPath. @@ -2798,11 +2799,40 @@ interface IObjectOptions { * Not used by fabric, just for convenience */ data?: any; - - /** - * Describes the object's corner position in canvas object absolute properties. - */ - aCoords?: {bl: Point, br: Point, tl: Point, tr: Point}; + /** + * Describe object's corner position in canvas element coordinates. + * properties are tl,mt,tr,ml,mr,bl,mb,br,mtr for the main controls. + * each property is an object with x, y and corner. + * The `corner` property contains in a similar manner the 4 points of the + * interactive area of the corner. + * The coordinates depends from this properties: width, height, scaleX, scaleY + * skewX, skewY, angle, strokeWidth, viewportTransform, top, left, padding. + * The coordinates get updated with @method setCoords. + * You can calculate them without updating with @method calcCoords; + * @memberOf fabric.Object.prototype + */ + oCoords?: {tl: Point, mt: Point, tr: Point, ml: Point, mr: Point, bl: Point, mb: Point, br: Point, mtr: Point}; + /** + * Describe object's corner position in canvas object absolute coordinates + * properties are tl,tr,bl,br and describe the four main corner. + * each property is an object with x, y, instance of Fabric.Point. + * The coordinates depends from this properties: width, height, scaleX, scaleY + * skewX, skewY, angle, strokeWidth, top, left. + * Those coordinates are usefull to understand where an object is. They get updated + * with oCoords but they do not need to be updated when zoom or panning change. + * The coordinates get updated with @method setCoords. + * You can calculate them without updating with @method calcCoords(true); + * @memberOf fabric.Object.prototype + */ + aCoords?: {bl: Point, br: Point, tl: Point, tr: Point}; + /** + * storage for object full transform matrix + */ + matrixCache?: any; + /** + * storage for object transform matrix + */ + ownMatrixCache?: any; } export interface Object extends IObservable, IObjectOptions, IObjectAnimation { } export class Object { @@ -2810,8 +2840,8 @@ export class Object { initialize(options?: IObjectOptions): Object; /* Sets object's properties from options - * @param {Object} [options] Options object - */ + * @param {Object} [options] Options object + */ setOptions(options: IObjectOptions): void; /** @@ -2866,7 +2896,7 @@ export class Object { /** * Retrieves viewportTransform from Object's canvas if possible */ - getViewportTransform(): any; + getViewportTransform(): any[]; /** * Renders an object on a specified context @@ -2924,7 +2954,7 @@ export class Object { * @param {Boolean} skipCanvas skip canvas checks because this object is painted * on parent canvas. */ - isCacheDirty(): boolean; + isCacheDirty(skipCanvas?: boolean): boolean; /** * Clones an instance, using a callback method will work for every object. @@ -2983,7 +3013,7 @@ export class Object { * @param property Property name 'stroke' or 'fill' * @param [options] Options object */ - setGradient(property: "stroke" | "fill", options: IGradientOptions): Object; + setGradient(property: "stroke" | "fill", options?: IGradientOptions): Object; /** * Sets pattern fill of an object @@ -3103,7 +3133,7 @@ export class Object { * Sets object's properties from options * @param [options] Options object */ - setOptions(options: any): void; + setOptions(options?: any): void; /** * Sets sourcePath of an object * @param value Value to set sourcePath to @@ -3113,12 +3143,16 @@ export class Object { // ----------------------------------------------------------------------------------------------------------------------------------- /** * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} */ - getSvgStyles(): string; + getSvgStyles(skipShadow?: boolean): string; /** * Returns transform-string for svg-export + * @param {Boolean} use the full transform or the single object one. + * @return {String} */ - getSvgTransform(): string; + getSvgTransform(full?: boolean, additionalTransform?: string): string; /** * Returns transform-string for svg-export from the transform matrix of single elements */ @@ -3128,8 +3162,10 @@ export class Object { // ----------------------------------------------------------------------------------------------------------------------------------- /** * Returns true if object state (one of its state properties) was changed + * @param {String} [propertySet] optional name for the set of property we want to save + * @return {Boolean} true if instance' state has changed since `{@link fabric.Object#saveState}` was called */ - hasStateChanged(): boolean; + hasStateChanged(propertySet: string): boolean; /** * Saves state of an object * @param [options] Object with additional `stateProperties` array to include when saving state @@ -3138,8 +3174,10 @@ export class Object { saveState(options?: { stateProperties: any[] }): Object; /** * Setups state of an object + * @param {Object} [options] Object with additional `stateProperties` array to include when saving state + * @return {fabric.Object} thisArg */ - setupState(): Object; + setupState(options?: any): Object; // functions from object straightening mixin // ----------------------------------------------------------------------------------------------------------------------------------- /** @@ -3201,10 +3239,11 @@ export class Object { /** * Returns the coordinates of the object as if it has a different origin - * @param originX Horizontal origin: 'left', 'center' or 'right' - * @param originY Vertical origin: 'top', 'center' or 'bottom' + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} */ - getPointByOrigin(): Point; + getPointByOrigin(originX: string, originY: string) : Point; /** * Returns the point in local coordinates @@ -3233,9 +3272,46 @@ export class Object { * Draws borders of an object's bounding box. * Requires public properties: width, height * Requires public options: padding, borderColor - * @param ctx Context to draw on + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable */ - drawBorders(context: CanvasRenderingContext2D): Object; + drawBorders(ctx: CanvasRenderingContext2D, styleOverride?: any): Object; + + /** + * Draws borders of an object's bounding box when it is inside a group. + * Requires public properties: width, height + * Requires public options: padding, borderColor + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {object} options object representing current object parameters + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawBordersInGroup(ctx: CanvasRenderingContext2D, options?: any, styleOverride?: any): Object; + + /** + * Draws corners of an object's bounding box. + * Requires public properties: width, height + * Requires public options: cornerSize, padding + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawControls(ctx: CanvasRenderingContext2D, styleOverride?: any): Object; + + /** + * Draws a colored layer behind the object, inside its selection borders. + * Requires public options: padding, selectionBackgroundColor + * this function is called when the context is transformed + * has checks to be skipped when the object is on a staticCanvas + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @return {fabric.Object} thisArg + * @chainable + */ + drawSelectionBackground(ctx: CanvasRenderingContext2D): Object; /** * Draws corners of an object's bounding box. @@ -3276,33 +3352,45 @@ export class Object { // functions from geometry mixin // ------------------------------------------------------------------------------------------------------------------------------- /** - * Sets corner position coordinates based on current angle, width and height - * See https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords + * Sets corner position coordinates based on current angle, width and height. + * See {@link https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords|When-to-call-setCoords} + * @param {Boolean} [ignoreZoom] set oCoords with or without the viewport transform. + * @param {Boolean} [skipAbsolute] skip calculation of aCoords, usefull in setViewportTransform + * @return {fabric.Object} thisArg + * @chainable */ - setCoords(): Object; + setCoords(ignoreZoom?: boolean, skipAbsolute?: boolean): Object; /** * Returns coordinates of object's bounding rectangle (left, top, width, height) - * @param absoluteopt use coordinates without viewportTransform - * @param calculateopt use coordinates of current position instead of .oCoords / .aCoords - * @return Object with left, top, width, height properties + * the box is intented as aligned to axis of canvas. + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords / .aCoords + * @return {Object} Object with left, top, width, height properties */ - getBoundingRect(absoluteopt?: boolean, calculateopt?: boolean): { left: number; top: number; width: number; height: number }; + getBoundingRect(absolute?: boolean, calculate?: boolean): { left: number; top: number; width: number; height: number }; /** * Checks if object is fully contained within area of another object - * @param other Object to test + * @param {Object} other Object to test + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is fully contained within area of another object */ - isContainedWithinObject(other: Object): boolean; + isContainedWithinObject(other: Object, absolute?: boolean, calculate?: boolean): boolean; /** * Checks if object is fully contained within area formed by 2 points * @param pointTL top-left point of area * @param pointBR bottom-right point of area */ - isContainedWithinRect(pointTL: any, pointBR: any): boolean; + isContainedWithinRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean; /** * Checks if point is inside the object - * @param point Point to check against + * @param {fabric.Point} point Point to check against + * @param {Object} [lines] object returned from @method _getImageLines + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if point is inside the object */ - containsPoint(point: Point): boolean; + containsPoint(point: Point, lines?: any, absolute?: boolean, calculate?: boolean): boolean; /** * Scales an object (equally by x and y) * @param value Scale factor @@ -3313,23 +3401,130 @@ export class Object { * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) * @param value New height value */ - scaleToHeight(value: number): Object; + scaleToHeight(value: number, absolute?: boolean): Object; /** * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) * @param value New width value */ - scaleToWidth(value: number): Object; + scaleToWidth(value: number, absolute?: boolean): Object; /** * Checks if object intersects with another object - * @param other Object to test + * @param {Object} other Object to test + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object intersects with another object */ - intersectsWithObject(other: Object): boolean; + intersectsWithObject(other: Object, absolute?: boolean, calculate?: boolean): boolean; /** * Checks if object intersects with an area formed by 2 points - * @param pointTL top-left point of area - * @param pointBR bottom-right point of area + * @param {Object} pointTL top-left point of area + * @param {Object} pointBR bottom-right point of area + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object intersects with an area formed by 2 points */ - intersectsWithRect(pointTL: any, pointBR: any): boolean; + intersectsWithRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean; + /** + * Animates object's properties + */ + animate(): Object; + /** + * Calculate and returns the .coords of an object. + * @return {Object} Object with tl, tr, br, bl .... + * @chainable + */ + calcCoords(absolute?: boolean): any; + /** + * calculate trasform Matrix that represent current transformation from + * object properties. + * @param {Boolean} [skipGroup] return transformMatrix for object and not go upward with parents + * @return {Array} matrix Transform Matrix for the object + */ + calcTransformMatrix(skipGroup?: boolean): any[]; + /** + * return correct set of coordinates for intersection + */ + getCoords(absolute?: boolean, calculate?: boolean): any; + /** + * Returns height of an object bounding box counting transformations + * before 2.0 it was named getHeight(); + * @return {Number} height value + */ + getScaledHeight(): number; + /** + * Returns width of an object bounding box counting transformations + * before 2.0 it was named getWidth(); + * @return {Number} width value + */ + getScaledWidth(): number; + /** + * Returns id attribute for svg output + * @return {String} + */ + getSvgCommons(): string; + /** + * Returns filter for svg shadow + * @return {String} + */ + getSvgFilter(): string; + /** + * Returns styles-string for svg-export + * @param {Object} style the object from which to retrieve style properties + * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style. + * @return {String} + */ + getSvgSpanStyles(style: any, useWhiteSpace?: boolean): string; + /** + * Returns text-decoration property for svg-export + * @param {Object} style the object from which to retrieve style properties + * @return {String} + */ + getSvgTextDecoration(style: any): string; + /** + * Checks if object is contained within the canvas with current viewportTransform + * the check is done stopping at first point that appears on screen + * @param {Boolean} [calculate] use coordinates of current position instead of .aCoords + * @return {Boolean} true if object is fully or partially contained within canvas + */ + isOnScreen(calculate?: boolean): boolean; + /** + * Checks if object is partially contained within the canvas with current viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is partially contained within canvas + */ + isPartiallyOnScreen(calculate?: boolean): boolean; + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to deselect this object. If the function returns true, the process is cancelled + */ + onDeselect(): void; + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to select this object. If the function returns true, the process is cancelled + */ + onSelect(): void; + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG(reviver?: Function): string; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + /** + * Translates the coordinates from a set of origin to another (based on the object's dimensions) + * @param {fabric.Point} point The point which corresponds to the originX and originY params + * @param {String} fromOriginX Horizontal origin: 'left', 'center' or 'right' + * @param {String} fromOriginY Vertical origin: 'top', 'center' or 'bottom' + * @param {String} toOriginX Horizontal origin: 'left', 'center' or 'right' + * @param {String} toOriginY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + translateToGivenOrigin(pointL: Point, fromOriginX: string, fromOriginY: string, toOriginX: string, toOriginY: string): Point; } interface IPathOptions extends IObjectOptions { From aa799e79dd15070de573367c840ccc8ba68c5d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 22:57:13 +0100 Subject: [PATCH 072/222] Add a test for the drag and drop addon --- .../react-big-calendar-tests.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/types/react-big-calendar/react-big-calendar-tests.tsx b/types/react-big-calendar/react-big-calendar-tests.tsx index 4bb6f23943..7f13da096a 100644 --- a/types/react-big-calendar/react-big-calendar-tests.tsx +++ b/types/react-big-calendar/react-big-calendar-tests.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import BigCalendar, { BigCalendarProps, Navigate, View, DateRange, DateLocalizer, ToolbarProps, EventWrapperProps } from "react-big-calendar"; +import withDragAndDrop from "react-big-calendar/lib/addons/dragAndDrop"; // Don't want to add this as a dependency, because it is only used for tests. declare const globalize: any; @@ -59,6 +60,30 @@ class CalendarResource { ReactDOM.render(, document.body); } + +// Drag and Drop Example Test +{ + interface Props { + localizer: DateLocalizer; + } + const DragAndDropCalendar = withDragAndDrop(BigCalendar); + const DnD = ({ localizer }: Props) => ( + + ); + + const localizer = BigCalendar.momentLocalizer(moment); + + ReactDOM.render(, document.body); +} { class MyCalendar extends BigCalendar {} From 694dd29ab8eee3b477b3821ce6352a72180955a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Wed, 20 Feb 2019 23:13:10 +0100 Subject: [PATCH 073/222] Remove extra whitespace --- types/react-big-calendar/react-big-calendar-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-big-calendar/react-big-calendar-tests.tsx b/types/react-big-calendar/react-big-calendar-tests.tsx index 7f13da096a..6a4d874669 100644 --- a/types/react-big-calendar/react-big-calendar-tests.tsx +++ b/types/react-big-calendar/react-big-calendar-tests.tsx @@ -60,7 +60,7 @@ class CalendarResource { ReactDOM.render(, document.body); } - + // Drag and Drop Example Test { interface Props { From f3e3210e75a3b356cdeeee8553e91576598cb3fe Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Wed, 20 Feb 2019 17:17:48 -0500 Subject: [PATCH 074/222] Ran linter --- types/fabric/index.d.ts | 3 ++- types/fabric/test/index.ts | 27 ++++++++++----------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index e8d31aef56..1eacd9008d 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for FabricJS 1.5 +// Type definitions for FabricJS 2.6 // Project: http://fabricjs.com/ // Definitions by: Oliver Klemencic // Joseph Livecchi @@ -7,6 +7,7 @@ // Brian Martinson // Rogerio Teixeira // Bradley Hill +// Bryan Krol // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 export import fabric = require("./fabric-impl"); diff --git a/types/fabric/test/index.ts b/types/fabric/test/index.ts index cd8884710a..16c8f5c747 100644 --- a/types/fabric/test/index.ts +++ b/types/fabric/test/index.ts @@ -12,7 +12,7 @@ function sample1() { }); for (let i = 0; i < 15; i++) { - fabric.Image.fromURL('../assets/ladybug.png', img => { + fabric.Image.fromURL('../assets/ladybug.png', (img: fabric.Image) => { img.set({ left: fabric.util.getRandomInt(0, 600), top: fabric.util.getRandomInt(0, 500), @@ -122,7 +122,7 @@ function sample3() { } }); - const image = fabric.Image.fromURL('../assets/printio.png', img => { + const image = fabric.Image.fromURL('../assets/printio.png', (img: fabric.Image) => { const oImg = img.set({ left: 300, top: 300, angle: -15 }).scale(0.9); canvas.add(oImg).renderAll(); canvas.setActiveObject(oImg); @@ -331,10 +331,10 @@ function sample6() { canvas.centerObject(obj); canvas.add(obj); - obj.clone(clone => canvas.add(clone.set({ left: 100, top: 100, angle: -15 }))); - obj.clone(clone => canvas.add(clone.set({ left: 480, top: 100, angle: 15 }))); - obj.clone(clone => canvas.add(clone.set({ left: 100, top: 400, angle: -15 }))); - obj.clone(clone => canvas.add(clone.set({ left: 480, top: 400, angle: 15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 100, top: 100, angle: -15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 480, top: 100, angle: 15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 100, top: 400, angle: -15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 480, top: 400, angle: 15 }))); canvas.on('mouse:move', options => { const p = canvas.getPointer(options.e); @@ -357,7 +357,7 @@ function sample7() { const canvas = new fabric.Canvas('c', { selection: false }); setInterval(() => { - fabric.Image.fromURL('../assets/ladybug.png', obj => { + fabric.Image.fromURL('../assets/ladybug.png', (obj: fabric.Object) => { const img = obj; img.set('left', fabric.util.getRandomInt(200, 600)).set('top', -50); img.movingLeft = !!Math.round(Math.random()); @@ -475,7 +475,7 @@ function sample8() { break; case 'image1': - fabric.Image.fromURL('../assets/pug.jpg', image => { + fabric.Image.fromURL('../assets/pug.jpg', (image: fabric.Image) => { image.set({ left, top, @@ -489,7 +489,7 @@ function sample8() { break; case 'image2': - fabric.Image.fromURL('../assets/logo.png', image => { + fabric.Image.fromURL('../assets/logo.png', (image: fabric.Image) => { image.set({ left, top, @@ -510,14 +510,7 @@ function sample8() { fabric.loadSVGFromURL(`../assets/${match[0]}.svg`, (objects, options) => { const loadedObject = fabric.util.groupSVGElements(objects, options); - loadedObject.set({ - left, - top, - angle, - padding: 10, - cornerSize: 10 - }); - loadedObject/*.scaleToWidth(300)*/.setCoords(); + loadedObject.setCoords(); // loadedObject.hasRotatingPoint = true; From 6e696788b513bd760bba05db1755dcdf1a0bf4c5 Mon Sep 17 00:00:00 2001 From: Rusty Scrivens <34690530+rscrivens@users.noreply.github.com> Date: Wed, 20 Feb 2019 14:36:18 -0800 Subject: [PATCH 075/222] Update to latest sarif version 2.0.0-csd.2.beta-2019-01-24 --- types/sarif/index.d.ts | 907 ++++++++++++++++++++++------------------- 1 file changed, 493 insertions(+), 414 deletions(-) diff --git a/types/sarif/index.d.ts b/types/sarif/index.d.ts index cc5a9899b5..56bcf3e8da 100644 --- a/types/sarif/index.d.ts +++ b/types/sarif/index.d.ts @@ -5,7 +5,7 @@ // TypeScript Version: 2.4 /** - * Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2019-01-09 JSON Schema: a standard format for the + * Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2019-01-24 JSON Schema: a standard format for the * output of static analysis tools. */ export interface Log { @@ -32,23 +32,174 @@ export interface Log { export namespace Log { type version = - "2.0.0-csd.2.beta.2019-01-09"; + "2.0.0-csd.2.beta.2019-01-24"; } /** - * A file relevant to a tool invocation or to a result. + * A single artifact. In some cases, this artifact might be nested within another artifact. + */ +export interface Artifact { + /** + * The contents of the artifact. + */ + contents?: ArtifactContent; + + /** + * Specifies the encoding for an artifact object that refers to a text file. + */ + encoding?: string; + + /** + * A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value of + * the artifact produced by the specified hash function. + */ + hashes?: { [key: string]: string }; + + /** + * The Coordinated Universal Time (UTC) date and time at which the artifact was most recently modified. See + * "Date/time properties" in the SARIF spec for the required format. + */ + lastModifiedTimeUtc?: string; + + /** + * The length of the artifact in bytes. + */ + length?: number; + + /** + * The location of the artifact. + */ + location?: ArtifactLocation; + + /** + * The MIME type (RFC 2045) of the artifact. + */ + mimeType?: string; + + /** + * The offset in bytes of the artifact within its containing artifact. + */ + offset?: number; + + /** + * Identifies the index of the immediate parent of the artifact, if this artifact is nested. + */ + parentIndex?: number; + + /** + * The role or roles played by the artifact in the analysis. + */ + roles?: Artifact.roles[]; + + /** + * Specifies the source language for any artifact object that refers to a text file that contains source code. + */ + sourceLanguage?: string; + + /** + * Key/value pairs that provide additional information about the artifact. + */ + properties?: PropertyBag; +} + +export namespace Artifact { + type roles = + "analysisTarget" | + "toolComponent" | + "attachment" | + "responseFile" | + "resultFile" | + "standardStream" | + "traceFile" | + "unmodifiedFile" | + "modifiedFile" | + "addedFile" | + "deletedFile" | + "renamedFile" | + "uncontrolledFile"; +} + +/** + * A change to a single artifact. + */ +export interface ArtifactChange { + /** + * The location of the artifact to change. + */ + artifactLocation: ArtifactLocation; + + /** + * An array of replacement objects, each of which represents the replacement of a single region in a single + * artifact specified by 'artifactLocation'. + */ + replacements: Replacement[]; + + /** + * Key/value pairs that provide additional information about the change. + */ + properties?: PropertyBag; +} + +/** + * Represents the contents of an artifact. + */ +export interface ArtifactContent { + /** + * MIME Base64-encoded content from a binary artifact, or from a text artifact in its original encoding. + */ + binary?: string; + + /** + * UTF-8-encoded content from a text artifact. + */ + text?: string; + + /** + * Key/value pairs that provide additional information about the artifact content. + */ + properties?: PropertyBag; +} + +/** + * Specifies the location of an artifact. + */ +export interface ArtifactLocation { + /** + * The index within the run artifacts array of the artifact object associated with the artifact location. + */ + index?: number; + + /** + * A string containing a valid relative or absolute URI. + */ + uri: string; + + /** + * A string which indirectly specifies the absolute URI with respect to which a relative URI in the "uri" property + * is interpreted. + */ + uriBaseId?: string; + + /** + * Key/value pairs that provide additional information about the artifact location. + */ + properties?: PropertyBag; +} + +/** + * An artifact relevant to a tool invocation or to a result. */ export interface Attachment { + /** + * The location of the attachment. + */ + artifactLocation: ArtifactLocation; + /** * A message describing the role played by the attachment. */ description?: Message; - /** - * The location of the attachment. - */ - fileLocation: FileLocation; - /** * An array of rectangles specifying areas of interest within the image. */ @@ -75,8 +226,8 @@ export interface CodeFlow { message?: Message; /** - * An array of one or more unique threadFlow objects, each of which describes the progress of a program through - * a thread of execution. + * An array of one or more unique threadFlow objects, each of which describes the progress of a program through a + * thread of execution. */ threadFlows: ThreadFlow[]; @@ -94,7 +245,7 @@ export interface Conversion { /** * The locations of the analysis tool's per-run log files. */ - analysisToolLogFiles?: FileLocation[]; + analysisToolLogFiles?: ArtifactLocation[]; /** * An invocation object that describes the invocation of the converter. @@ -182,8 +333,8 @@ export interface Exception { innerExceptions?: Exception[]; /** - * A string that identifies the kind of exception, for example, the fully qualified type name of an object that - * was thrown, or the symbolic name of a signal. + * A string that identifies the kind of exception, for example, the fully qualified type name of an object that was + * thrown, or the symbolic name of a signal. */ kind?: string; @@ -210,7 +361,7 @@ export interface ExternalPropertyFile { /** * The location of the external property file. */ - fileLocation?: FileLocation; + artifactLocation?: ArtifactLocation; /** * A stable, unique identifer for the external property file in the form of a GUID. @@ -232,15 +383,20 @@ export interface ExternalPropertyFile { * References to external property files that should be inlined with the content of a root log file. */ export interface ExternalPropertyFiles { + /** + * An array of external property files containing run.artifacts arrays to be merged with the root log file. + */ + artifacts?: ExternalPropertyFile[]; + /** * An external property file containing a run.conversion object to be merged with the root log file. */ conversion?: ExternalPropertyFile; /** - * An array of external property files containing run.files arrays to be merged with the root log file. + * An external property file containing a run.properties object to be merged with the root log file. */ - files?: ExternalPropertyFile[]; + externalizedProperties?: ExternalPropertyFile; /** * An external property file containing a run.graphs object to be merged with the root log file. @@ -257,187 +413,32 @@ export interface ExternalPropertyFiles { */ logicalLocations?: ExternalPropertyFile[]; - /** - * An external property file containing a run.resources object to be merged with the root log file. - */ - resources?: ExternalPropertyFile; - /** * An array of external property files containing run.results arrays to be merged with the root log file. */ results?: ExternalPropertyFile[]; /** - * An external property file containing a run.properties object to be merged with the root log file. + * An external property file containing a run.tool object to be merged with the root log file. */ - properties?: ExternalPropertyFile; + tool?: ExternalPropertyFile; } /** - * A single file. In some cases, this file might be nested within another file. - */ -export interface File { - /** - * The contents of the file. - */ - contents?: FileContent; - - /** - * Specifies the encoding for a file object that refers to a text file. - */ - encoding?: string; - - /** - * The location of the file. - */ - fileLocation?: FileLocation; - - /** - * A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value - * of the file produced by the specified hash function. - */ - hashes?: { [key: string]: string }; - - /** - * The Coordinated Universal Time (UTC) date and time at which the file was most recently modified. See - * "Date/time properties" in the SARIF spec for the required format. - */ - lastModifiedTimeUtc?: string; - - /** - * The length of the file in bytes. - */ - length?: number; - - /** - * The MIME type (RFC 2045) of the file. - */ - mimeType?: string; - - /** - * The offset in bytes of the file within its containing file. - */ - offset?: number; - - /** - * Identifies the index of the immediate parent of the file, if this file is nested. - */ - parentIndex?: number; - - /** - * The role or roles played by the file in the analysis. - */ - roles?: File.roles[]; - - /** - * Specifies the source language for any file object that refers to a text file that contains source code. - */ - sourceLanguage?: string; - - /** - * Key/value pairs that provide additional information about the file. - */ - properties?: PropertyBag; -} - -export namespace File { - type roles = - "analysisTarget" | - "attachment" | - "responseFile" | - "resultFile" | - "standardStream" | - "traceFile" | - "unmodifiedFile" | - "modifiedFile" | - "addedFile" | - "deletedFile" | - "renamedFile" | - "uncontrolledFile"; -} - -/** - * A change to a single file. - */ -export interface FileChange { - /** - * The location of the file to change. - */ - fileLocation: FileLocation; - - /** - * An array of replacement objects, each of which represents the replacement of a single region in a single file - * specified by 'fileLocation'. - */ - replacements: Replacement[]; - - /** - * Key/value pairs that provide additional information about the file change. - */ - properties?: PropertyBag; -} - -/** - * Represents content from an external file. - */ -export interface FileContent { - /** - * MIME Base64-encoded content from a binary file, or from a text file in its original encoding. - */ - binary?: string; - - /** - * UTF-8-encoded content from a text file. - */ - text?: string; - - /** - * Key/value pairs that provide additional information about the external file. - */ - properties?: PropertyBag; -} - -/** - * Specifies the location of a file. - */ -export interface FileLocation { - /** - * The index within the run files array of the file object associated with the file location. - */ - fileIndex?: number; - - /** - * A string containing a valid relative or absolute URI. - */ - uri: string; - - /** - * A string which indirectly specifies the absolute URI with respect to which a relative URI in the "uri" - * property is interpreted. - */ - uriBaseId?: string; - - /** - * Key/value pairs that provide additional information about the file location. - */ - properties?: PropertyBag; -} - -/** - * A proposed fix for the problem represented by a result object. A fix specifies a set of file to modify. For each - * file, it specifies a set of bytes to remove, and provides a set of new bytes to replace them. + * A proposed fix for the problem represented by a result object. A fix specifies a set of artifacts to modify. For + * each artifact, it specifies a set of bytes to remove, and provides a set of new bytes to replace them. */ export interface Fix { + /** + * One or more artifact changes that comprise a fix for a result. + */ + changes: ArtifactChange[]; + /** * A message that describes the proposed fix, enabling viewers to present the proposed change to an end user. */ description?: Message; - /** - * One or more file changes that comprise a fix for a result. - */ - fileChanges: FileChange[]; - /** * Key/value pairs that provide additional information about the fix. */ @@ -445,8 +446,8 @@ export interface Fix { } /** - * A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a - * call graph). + * A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a call + * graph). */ export interface Graph { /** @@ -521,7 +522,7 @@ export interface Invocation { arguments?: string[]; /** - * A set of files relevant to the invocation of the tool. + * A set of artifacts relevant to the invocation of the tool. */ attachments?: Attachment[]; @@ -549,7 +550,7 @@ export interface Invocation { /** * An absolute URI specifying the location of the analysis tool's executable. */ - executableLocation?: FileLocation; + executableLocation?: ArtifactLocation; /** * The process exit code. @@ -587,36 +588,40 @@ export interface Invocation { processStartFailureMessage?: string; /** - * The locations of any response files specified on the tool's command line. + * An array of reportingConfigurationOverride objects that describe runtime reporting behavior. */ - responseFiles?: FileLocation[]; + reportingConfigurationOverrides?: ReportingConfigurationOverride[]; /** - * The Coordinated Universal Time (UTC) date and time at which the run started. See "Date/time properties" in - * the SARIF spec for the required format. + * The locations of any response files specified on the tool's command line. + */ + responseFiles?: ArtifactLocation[]; + + /** + * The Coordinated Universal Time (UTC) date and time at which the run started. See "Date/time properties" in the + * SARIF spec for the required format. */ startTimeUtc?: string; /** * A file containing the standard error stream from the process that was invoked. */ - stderr?: FileLocation; + stderr?: ArtifactLocation; /** * A file containing the standard input stream to the process that was invoked. */ - stdin?: FileLocation; + stdin?: ArtifactLocation; /** * A file containing the standard output stream from the process that was invoked. */ - stdout?: FileLocation; + stdout?: ArtifactLocation; /** - * A file containing the interleaved standard output and standard error stream from the process that was - * invoked. + * A file containing the interleaved standard output and standard error stream from the process that was invoked. */ - stdoutStderr?: FileLocation; + stdoutStderr?: ArtifactLocation; /** * A value indicating whether the tool's execution completed successfully. @@ -631,7 +636,7 @@ export interface Invocation { /** * The working directory for the analysis tool run. */ - workingDirectory?: FileLocation; + workingDirectory?: ArtifactLocation; /** * Key/value pairs that provide additional information about the invocation. @@ -649,9 +654,9 @@ export interface Location { annotations?: Region[]; /** - * The human-readable fully qualified name of the logical location. If run.logicalLocations is present, this - * value matches a property name within that object, from which further information about the logical location - * can be obtained. + * The human-readable fully qualified name of the logical location. If run.logicalLocations is present, this value + * matches a property name within that object, from which further information about the logical location can be + * obtained. */ fullyQualifiedLogicalName?: string; @@ -666,7 +671,7 @@ export interface Location { message?: Message; /** - * Identifies the file and region. + * Identifies the artifact and region. */ physicalLocation?: PhysicalLocation; @@ -681,8 +686,8 @@ export interface Location { */ export interface LogicalLocation { /** - * The machine-readable name for the logical location, such as a mangled function name provided by a C++ - * compiler that encodes calling convention, return type and other details along with the function name. + * The machine-readable name for the logical location, such as a mangled function name provided by a C++ compiler + * that encodes calling convention, return type and other details along with the function name. */ decoratedName?: string; @@ -693,8 +698,8 @@ export interface LogicalLocation { /** * The type of construct this logical location component refers to. Should be one of 'function', 'member', - * 'module', 'namespace', 'parameter', 'resource', 'returnType', 'type', or 'variable', if any of those - * accurately describe the construct. + * 'module', 'namespace', 'parameter', 'resource', 'returnType', 'type', or 'variable', if any of those accurately + * describe the construct. */ kind?: string; @@ -726,20 +731,15 @@ export interface Message { arguments?: string[]; /** - * The resource id for a plain text message string. + * A Markdown message string. + */ + markdown?: string; + + /** + * The resource id for a plain text or Markdown message string. */ messageId?: string; - /** - * The resource id for a rich text message string. - */ - richMessageId?: string; - - /** - * A rich text message string. - */ - richText?: string; - /** * A plain text message string. */ @@ -751,6 +751,26 @@ export interface Message { properties?: PropertyBag; } +/** + * A message string or message format string rendered in multiple formats. + */ +export interface MultiformatMessageString { + /** + * A Markdown message string or format string. + */ + markdown?: string; + + /** + * A plain text message string or format string. + */ + text?: string; + + /** + * Key/value pairs that provide additional information about the message. + */ + properties?: PropertyBag; +} + /** * Represents a node in a graph. */ @@ -807,7 +827,7 @@ export interface Notification { message: Message; /** - * The file and region relevant to this notification. + * The artifact and region relevant to this notification. */ physicalLocation?: PhysicalLocation; @@ -839,34 +859,35 @@ export interface Notification { export namespace Notification { type level = + "none" | "note" | "warning" | "error"; } /** - * A physical location relevant to a result. Specifies a reference to a programming artifact together with a range - * of bytes or characters within that artifact. + * A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of + * bytes or characters within that artifact. */ export interface PhysicalLocation { /** - * Specifies a portion of the file that encloses the region. Allows a viewer to display additional context + * The location of the artifact. + */ + artifactLocation: ArtifactLocation; + + /** + * Specifies a portion of the artifact that encloses the region. Allows a viewer to display additional context * around the region. */ contextRegion?: Region; - /** - * The location of the file. - */ - fileLocation: FileLocation; - /** * Value that distinguishes this physical location from all other physical locations in this run object. */ id?: number; /** - * Specifies a portion of the file. + * Specifies a portion of the artifact. */ region?: Region; @@ -927,7 +948,7 @@ export interface Rectangle { } /** - * A region within a file where a result was detected. + * A region within an artifact where a result was detected. */ export interface Region { /** @@ -936,7 +957,7 @@ export interface Region { byteLength?: number; /** - * The zero-based offset from the beginning of the file of the first byte in the region. + * The zero-based offset from the beginning of the artifact of the first byte in the region. */ byteOffset?: number; @@ -946,7 +967,7 @@ export interface Region { charLength?: number; /** - * The zero-based offset from the beginning of the file of the first character in the region. + * The zero-based offset from the beginning of the artifact of the first character in the region. */ charOffset?: number; @@ -966,12 +987,12 @@ export interface Region { message?: Message; /** - * The portion of the file contents within the specified region. + * The portion of the artifact contents within the specified region. */ - snippet?: FileContent; + snippet?: ArtifactContent; /** - * Specifies the source language, if any, of the portion of the file specified by the region object. + * Specifies the source language, if any, of the portion of the artifact specified by the region object. */ sourceLanguage?: string; @@ -992,18 +1013,18 @@ export interface Region { } /** - * The replacement of a single region of a file. + * The replacement of a single region of an artifact. */ export interface Replacement { /** - * The region of the file to delete. + * The region of the artifact to delete. */ deletedRegion: Region; /** * The content to insert at the location specified by the 'deletedRegion' property. */ - insertedContent?: FileContent; + insertedContent?: ArtifactContent; /** * Key/value pairs that provide additional information about the replacement. @@ -1012,21 +1033,133 @@ export interface Replacement { } /** - * Container for items that require localization. + * Information about a tool report that can be configured at runtime. */ -export interface Resources { +export interface ReportingConfiguration { /** - * A dictionary, each of whose keys is a resource identifier and each of whose values is a localized string. + * Specifies whether the report may be produced during the scan. */ - messageStrings?: { [key: string]: string }; + enabled?: boolean; /** - * An array of rule objects relevant to the run. + * Specifies the failure level for the report. */ - rules?: Rule[]; + level?: ReportingConfiguration.level; /** - * Key/value pairs that provide additional information about the resources. + * Contains configuration information specific to a report. + */ + parameters?: PropertyBag; + + /** + * Specifies the relative priority of the report. Used for analysis output only. + */ + rank?: number; + + /** + * Key/value pairs that provide additional information about the reporting configuration. + */ + properties?: PropertyBag; +} + +export namespace ReportingConfiguration { + type level = + "none" | + "note" | + "warning" | + "error"; +} + +/** + * Information about how a specific tool report was reconfigured at runtime. + */ +export interface ReportingConfigurationOverride { + /** + * Specifies how the report was configured during the scan. + */ + configuration?: ReportingConfiguration; + + /** + * The index within the run.tool.extensions array of the toolComponent object which describes the plug-in or tool + * extension that produced the report. + */ + extensionIndex?: number; + + /** + * The index within the toolComponent.notificationDescriptors array of the reportingDescriptor associated with this + * override. + */ + notificationIndex?: number; + + /** + * The index within the toolComponent.ruleDescriptors array of the reportingDescriptor associated with this + * override. + */ + ruleIndex?: number; + + /** + * Key/value pairs that provide additional information about the reporting configuration. + */ + properties?: PropertyBag; +} + +/** + * Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime + * reporting. + */ +export interface ReportingDescriptor { + /** + * Default reporting configuration information. + */ + defaultConfiguration?: ReportingConfiguration; + + /** + * An array of stable, opaque identifiers by which this report was known in some previous version of the analysis + * tool. + */ + deprecatedIds?: string[]; + + /** + * A description of the report. Should, as far as possible, provide details sufficient to enable resolution of any + * problem indicated by the result. + */ + fullDescription?: Message; + + /** + * Provides the primary documentation for the report, useful when there is no online documentation. + */ + help?: Message; + + /** + * A URI where the primary documentation for the report can be found. + */ + helpUri?: string; + + /** + * A stable, opaque identifier for the report. + */ + id?: string; + + /** + * A set of name/value pairs with arbitrary names. Each value is a multiformatMessageString object, which holds + * message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can + * be used to construct a message in combination with an arbitrary number of additional string arguments. + */ + messageStrings?: { [key: string]: MultiformatMessageString }; + + /** + * A report identifier that is understandable to an end user. + */ + name?: Message; + + /** + * A concise description of the report. Should be a single sentence that is understandable when visible space is + * limited to a single line of text. + */ + shortDescription?: Message; + + /** + * Key/value pairs that provide additional information about the report. */ properties?: PropertyBag; } @@ -1036,13 +1169,13 @@ export interface Resources { */ export interface Result { /** - * Identifies the file that the analysis tool was instructed to scan. This need not be the same as the file + * Identifies the artifact that the analysis tool was instructed to scan. This need not be the same as the artifact * where the result actually occurred. */ - analysisTarget?: FileLocation; + analysisTarget?: ArtifactLocation; /** - * A set of files relevant to the result. + * A set of artifacts relevant to the result. */ attachments?: Attachment[]; @@ -1073,8 +1206,7 @@ export interface Result { fixes?: Fix[]; /** - * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that - * id. + * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that id. */ graphs?: { [key: string]: Graph }; @@ -1093,6 +1225,11 @@ export interface Result { */ instanceGuid?: string; + /** + * A value that categorizes results by evaluation state. + */ + kind?: Result.kind; + /** * A value specifying the severity level of the result. */ @@ -1105,8 +1242,8 @@ export interface Result { locations?: Location[]; /** - * A message that describes the result. The first sentence of the message only will be displayed when visible - * space is limited. + * A message that describes the result. The first sentence of the message only will be displayed when visible space + * is limited. */ message: Message; @@ -1135,6 +1272,12 @@ export interface Result { */ relatedLocations?: Location[]; + /** + * The index within the run.tool.extensions array of the tool component object which describes the plug-in or tool + * extension that produced the result. + */ + ruleExtensionIndex?: number; + /** * The stable, unique identifier of the rule, if any, to which this notification is relevant. This member can be * used to retrieve rule metadata from the rules dictionary, if it exists. @@ -1168,13 +1311,19 @@ export interface Result { } export namespace Result { - type level = + type kind = + "none" | "notApplicable" | "pass" | + "fail" | + "review" | + "open"; + + type level = + "none" | "note" | "warning" | - "error" | - "open"; + "error"; type suppressionStates = "suppressedInSource" | @@ -1182,7 +1331,8 @@ export namespace Result { type baselineState = "new" | - "existing" | + "unchanged" | + "updated" | "absent"; } @@ -1191,14 +1341,13 @@ export namespace Result { */ export interface ResultProvenance { /** - * An array of physicalLocation objects which specify the portions of an analysis tool's output that a - * converter transformed into the result. + * An array of physicalLocation objects which specify the portions of an analysis tool's output that a converter + * transformed into the result. */ conversionSources?: PhysicalLocation[]; /** - * A GUID-valued string equal to the id.instanceGuid property of the run in which the result was first - * detected. + * A GUID-valued string equal to the id.instanceGuid property of the run in which the result was first detected. */ firstDetectionRunInstanceGuid?: string; @@ -1233,111 +1382,7 @@ export interface ResultProvenance { } /** - * Describes an analysis rule. - */ -export interface Rule { - /** - * Information about the rule that can be configured at runtime. - */ - configuration?: RuleConfiguration; - - /** - * An array of stable, opaque identifiers by which this rule was known in some previous version of the analysis - * tool. - */ - deprecatedIds?: string[]; - - /** - * A description of the rule. Should, as far as possible, provide details sufficient to enable resolution of any - * problem indicated by the result. - */ - fullDescription?: Message; - - /** - * Provides the primary documentation for the rule, useful when there is no online documentation. - */ - help?: Message; - - /** - * A URI where the primary documentation for the rule can be found. - */ - helpUri?: string; - - /** - * A stable, opaque identifier for the rule. - */ - id?: string; - - /** - * A set of name/value pairs with arbitrary names. The value within each name/value pair consists of plain text - * interspersed with placeholders, which can be used to construct a message in combination with an arbitrary - * number of additional string arguments. - */ - messageStrings?: { [key: string]: string }; - - /** - * A rule identifier that is understandable to an end user. - */ - name?: Message; - - /** - * A set of name/value pairs with arbitrary names. The value within each name/value pair consists of rich text - * interspersed with placeholders, which can be used to construct a message in combination with an arbitrary - * number of additional string arguments. - */ - richMessageStrings?: { [key: string]: string }; - - /** - * A concise description of the rule. Should be a single sentence that is understandable when visible space is - * limited to a single line of text. - */ - shortDescription?: Message; - - /** - * Key/value pairs that provide additional information about the rule. - */ - properties?: PropertyBag; -} - -/** - * Information about a rule that can be configured at runtime. - */ -export interface RuleConfiguration { - /** - * Specifies the default severity level for results generated by this rule. - */ - defaultLevel?: RuleConfiguration.defaultLevel; - - /** - * Specifies the default priority or importance for results generated by this rule. - */ - defaultRank?: number; - - /** - * Specifies whether the rule will be evaluated during the scan. - */ - enabled?: boolean; - - /** - * Contains configuration information specific to this rule. - */ - parameters?: PropertyBag; - - /** - * Key/value pairs that provide additional information about the rule configuration. - */ - properties?: PropertyBag; -} - -export namespace RuleConfiguration { - type defaultLevel = - "note" | - "warning" | - "error"; -} - -/** - * Describes a single run of an analysis tool, and contains the output of that run. + * Describes a single run of an analysis tool, and contains the reported output of that run. */ export interface Run { /** @@ -1345,6 +1390,11 @@ export interface Run { */ aggregateIds?: RunAutomationDetails[]; + /** + * An array of artifact objects relevant to the run. + */ + artifacts?: Artifact[]; + /** * The 'instanceGuid' property of a previous SARIF 'run' that comprises the baseline that was used to compute * result 'baselineState' properties for the run. @@ -1357,18 +1407,18 @@ export interface Run { columnKind?: Run.columnKind; /** - * A conversion object that describes how a converter transformed an analysis tool's native output format into + * A conversion object that describes how a converter transformed an analysis tool's native reporting format into * the SARIF format. */ conversion?: Conversion; /** - * Specifies the default encoding for any file object that refers to a text file. + * Specifies the default encoding for any artifact object that refers to a text file. */ defaultFileEncoding?: string; /** - * Specifies the default source language for any file object that refers to a text file that contains source + * Specifies the default source language for any artifact object that refers to a text file that contains source * code. */ defaultSourceLanguage?: string; @@ -1379,13 +1429,7 @@ export interface Run { externalPropertyFiles?: ExternalPropertyFiles; /** - * An array of file objects relevant to the run. - */ - files?: File[]; - - /** - * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that - * id. + * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that id. */ graphs?: { [key: string]: Graph }; @@ -1405,47 +1449,41 @@ export interface Run { logicalLocations?: LogicalLocation[]; /** - * An ordered list of character sequences that were treated as line breaks when computing region information - * for the run. + * The MIME type of all Markdown text message properties in the run. Default: "text/markdown;variant=GFM" + */ + markdownMessageMimeType?: string; + + /** + * An ordered list of character sequences that were treated as line breaks when computing region information for + * the run. */ newlineSequences?: string[]; /** - * The file location specified by each uriBaseId symbol on the machine where the tool originally ran. + * The artifact location specified by each uriBaseId symbol on the machine where the tool originally ran. */ - originalUriBaseIds?: { [key: string]: FileLocation }; + originalUriBaseIds?: { [key: string]: ArtifactLocation }; /** * The string used to replace sensitive information in a redaction-aware property. */ redactionToken?: string; - /** - * Items that can be localized, such as message strings and rule metadata. - */ - resources?: Resources; - /** * The set of results contained in an SARIF log. The results array can be omitted when a run is solely exporting * rules metadata. It must be present (but may be empty) if a log file represents an actual scan. */ results?: Result[]; - /** - * The MIME type of all rich text message properties in the run. Default: "text/markdown;variant=GFM" - */ - richMessageMimeType?: string; - /** * Information about the tool or tool pipeline that generated the results in this run. A run can only contain - * results produced by a single tool or tool pipeline. A run can aggregate results from multiple log files, as - * long as context around the tool run (tool command-line arguments and the like) is identical for all - * aggregated files. + * results produced by a single tool or tool pipeline. A run can aggregate results from multiple log files, as long + * as context around the tool run (tool command-line arguments and the like) is identical for all aggregated files. */ tool: Tool; /** - * Specifies the revision in version control of the files that were scanned. + * Specifies the revision in version control of the artifacts that were scanned. */ versionControlProvenance?: VersionControlDetails[]; @@ -1595,15 +1633,17 @@ export interface ThreadFlowLocation { executionTimeUtc?: string; /** - * Specifies the importance of this location in understanding the code flow in which it occurs. The order from - * most to least important is "essential", "important", "unimportant". Default: "important". + * Specifies the importance of this location in understanding the code flow in which it occurs. The order from most + * to least important is "essential", "important", "unimportant". Default: "important". */ importance?: ThreadFlowLocation.importance; /** - * A string describing the type of this location. + * A set of distinct strings that categorize the thread flow location. Well-known kinds include acquire, release, + * enter, exit, call, return, branch, implicit, false, true, caution, danger, unknown, unreachable, taint, + * function, handler, lock, memory, resource, and scope. */ - kind?: string; + kinds?: string[]; /** * The code location. @@ -1627,8 +1667,8 @@ export interface ThreadFlowLocation { /** * A dictionary, each of whose keys specifies a variable or expression, the associated value of which represents - * the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary - * might hold the current assumed values of a set of global variables. + * the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary might + * hold the current assumed values of a set of global variables. */ state?: { [key: string]: string }; @@ -1650,20 +1690,14 @@ export namespace ThreadFlowLocation { */ export interface Tool { /** - * The binary version of the tool's primary executable file expressed as four non-negative integers separated - * by a period (for operating systems that express file versions in this way). + * The analysis tool that was run. */ - dottedQuadFileVersion?: string; + driver: ToolComponent; /** - * The absolute URI from which the tool can be downloaded. + * Tool extensions that contributed to or reconfigured the analysis tool that was run. */ - downloadUri?: string; - - /** - * The name of the tool along with its version and any other useful identifying information, such as its locale. - */ - fullName?: string; + extensions?: ToolComponent[]; /** * The tool language (expressed as an ISO 649 two-letter lowercase culture code) and region (expressed as an ISO @@ -1672,28 +1706,73 @@ export interface Tool { language?: string; /** - * The name of the tool. + * Key/value pairs that provide additional information about the tool. + */ + properties?: PropertyBag; +} + +/** + * A component, such as a plug-in or the default driver, of the analysis tool that was run. + */ +export interface ToolComponent { + /** + * The index within the run artifacts array of the artifact object associated with the component. + */ + artifactIndex?: number; + + /** + * The binary version of the component's primary executable file expressed as four non-negative integers separated + * by a period (for operating systems that express file versions in this way). + */ + dottedQuadFileVersion?: string; + + /** + * The absolute URI from which the component can be downloaded. + */ + downloadUri?: string; + + /** + * The name of the component along with its version and any other useful identifying information, such as its + * locale. + */ + fullName?: string; + + /** + * A dictionary, each of whose keys is a resource identifier and each of whose values is a multiformatMessageString + * object, which holds message strings in plain text and (optionally) Markdown format. The strings can include + * placeholders, which can be used to construct a message in combination with an arbitrary number of additional + * string arguments. + */ + globalMessageStrings?: { [key: string]: MultiformatMessageString }; + + /** + * The name of the component. */ name: string; /** - * A version that uniquely identifies the SARIF logging component that generated this file, if it is versioned - * separately from the tool. + * An array of reportDescriptor objects relevant to the notifications related to the configuration and runtime + * execution of the component. */ - sarifLoggerVersion?: string; + notificationDescriptors?: ReportingDescriptor[]; /** - * The tool version in the format specified by Semantic Versioning 2.0. + * An array of reportDescriptor objects relevant to the analysis performed by the component. + */ + ruleDescriptors?: ReportingDescriptor[]; + + /** + * The component version in the format specified by Semantic Versioning 2.0. */ semanticVersion?: string; /** - * The tool version, in whatever format the tool natively provides. + * The component version, in whatever format the component natively provides. */ version?: string; /** - * Key/value pairs that provide additional information about the tool. + * Key/value pairs that provide additional information about the component. */ properties?: PropertyBag; } @@ -1703,8 +1782,8 @@ export interface Tool { */ export interface VersionControlDetails { /** - * A Coordinated Universal Time (UTC) date and time that can be used to synchronize an enlistment to the state - * of the repository at that time. + * A Coordinated Universal Time (UTC) date and time that can be used to synchronize an enlistment to the state of + * the repository at that time. */ asOfTimeUtc?: string; @@ -1717,7 +1796,7 @@ export interface VersionControlDetails { * The location in the local file system to which the root of the repository was mapped at the time of the * analysis. */ - mappedTo?: FileLocation; + mappedTo?: ArtifactLocation; /** * The absolute URI of the repository. From a3c324e8f741c4fd1d2a03cde5e145b70fd0c08a Mon Sep 17 00:00:00 2001 From: Rusty Scrivens <34690530+rscrivens@users.noreply.github.com> Date: Wed, 20 Feb 2019 15:30:16 -0800 Subject: [PATCH 076/222] Update the test --- types/sarif/sarif-tests.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/sarif/sarif-tests.ts b/types/sarif/sarif-tests.ts index 45b5bf922d..35d522b86b 100644 --- a/types/sarif/sarif-tests.ts +++ b/types/sarif/sarif-tests.ts @@ -4,8 +4,10 @@ const input = `{ "runs": [ { "tool": { - "name": "CodeScanner", - "semanticVersion": "2.1.0" + "driver": { + "name": "CodeScanner", + "semanticVersion": "2.1.0" + }, }, "results": [ ] @@ -13,6 +15,6 @@ const input = `{ ] }`; const log = JSON.parse("") as sarif.Log; -if (log.runs[0].tool.name !== "CodeScanner") { +if (log.runs[0].tool.driver.name !== "CodeScanner") { throw new Error("error: Tool name does not match"); } From ce71dddafde2e36cf92f431cba647cafc311f23c Mon Sep 17 00:00:00 2001 From: Leo Liang Date: Thu, 21 Feb 2019 13:35:40 +0800 Subject: [PATCH 077/222] Update according to review comment. --- types/sinon/ts3.1/index.d.ts | 3 ++- types/sinon/ts3.1/sinon-tests.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index 0ddf54a3b1..a27355e835 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -1713,7 +1713,8 @@ declare namespace Sinon { */ createStubInstance( constructor: StubbableType, - overrides?: { [K in keyof TType]?: any } + overrides?: { [K in keyof TType]?: + SinonStubbedMember | TType[K] extends (...args: any[]) => infer R ? R : TType[K] } ): SinonStubbedInstance; } diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index d1f2e4c1bb..a123f560fb 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -67,7 +67,7 @@ function testSandbox() { sb.replaceSetter(replaceMe, 'setter', (v) => { }); const cls = class { - foo(arg1: string, arg2: number) { return 1; } + foo(arg1: string, arg2: number): number { return 1; } bar: number; }; const PrivateFoo = class { @@ -88,6 +88,7 @@ function testSandbox() { const clsBar: number = stubInstance.bar; const privateFooBar: number = privateFooStubbedInstance.bar; sb.createStubInstance(cls, { + foo: (arg1: string, arg2: number) => 2, bar: 1 }); } From 92ec8feb5d00944d5c85039dd7144e06b00b77fd Mon Sep 17 00:00:00 2001 From: Robin Labat Date: Thu, 21 Feb 2019 09:23:58 +0100 Subject: [PATCH 078/222] add subset attribute to ResponderAdvertisement --- types/cote/cote-tests.ts | 4 +++- types/cote/index.d.ts | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/cote/cote-tests.ts b/types/cote/cote-tests.ts index 1851654625..d4af3ce95e 100644 --- a/types/cote/cote-tests.ts +++ b/types/cote/cote-tests.ts @@ -35,6 +35,7 @@ class Readme { }); const req = { + __subset: 'subset', type: 'randomRequest', payload: { val: Math.floor(Math.random() * 10) @@ -52,7 +53,8 @@ class Readme { name: 'Random Responder', namespace: 'rnd', key: 'a certain key', - respondsTo: ['randomRequest'] + respondsTo: ['randomRequest'], + subset: 'subset' }); interface RandomRequest { diff --git a/types/cote/index.d.ts b/types/cote/index.d.ts index 4c959af76b..a1aafe96b2 100644 --- a/types/cote/index.d.ts +++ b/types/cote/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cote 0.17 +// Type definitions for cote 0.19 // Project: https://github.com/dashersw/cote#readme // Definitions by: makepost // Labat Robin @@ -115,6 +115,11 @@ export interface ResponderAdvertisement extends Advertisement { * Request types that a Responder can listen to. */ respondsTo?: string[]; + + /** + * Subset attribut for directed requests. + */ + subset?: string; } export class Publisher extends Component { From 06ee3cb8bb10a3900b1b143b7591fb199776a8d7 Mon Sep 17 00:00:00 2001 From: dkirchhof Date: Thu, 21 Feb 2019 10:03:56 +0100 Subject: [PATCH 079/222] [Inquirer.js] Add number as standard prompt type --- types/inquirer/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 5d976e896d..0da68a13e8 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -81,6 +81,7 @@ declare namespace inquirer { * Possible values: *
    *
  • input
  • + *
  • number
  • *
  • confirm
  • *
  • list
  • *
  • rawlist
  • From 58e30dafa7f9d6c7a2bfe067c6eac4ce4c674ba6 Mon Sep 17 00:00:00 2001 From: dkirchhof Date: Thu, 21 Feb 2019 10:05:58 +0100 Subject: [PATCH 080/222] fixed indentation --- types/inquirer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 0da68a13e8..74aee08ed3 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -81,7 +81,7 @@ declare namespace inquirer { * Possible values: *
      *
    • input
    • - *
    • number
    • + *
    • number
    • *
    • confirm
    • *
    • list
    • *
    • rawlist
    • From 8f9cad9ad4ca502c00ce01540ec0bbe414ab9fbc Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Thu, 21 Feb 2019 11:53:19 +0000 Subject: [PATCH 081/222] update jest-environment-puppeteer --- types/jest-environment-puppeteer/index.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/types/jest-environment-puppeteer/index.d.ts b/types/jest-environment-puppeteer/index.d.ts index 79c25e32d8..8c71525938 100644 --- a/types/jest-environment-puppeteer/index.d.ts +++ b/types/jest-environment-puppeteer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jest-environment-puppeteer 2.2 +// Type definitions for jest-environment-puppeteer 4.0 // Project: https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer // Definitions by: Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,9 +6,15 @@ import { Browser, Page } from "puppeteer"; +interface JestPuppeteer { + resetPage(): Promise; + debug(): Promise; +} + declare global { const browser: Browser; - const page: Page; + const page: Page + const jestPuppeteer: JestPuppeteer; } export { }; From 35f4c6d0af4486bccfb0494caff2cb81deda70d1 Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Thu, 21 Feb 2019 12:07:16 +0000 Subject: [PATCH 082/222] fix: update types with latest information from docs --- types/jest-environment-puppeteer/index.d.ts | 29 +++++++++++++++++-- .../jest-environment-puppeteer-tests.ts | 4 +++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/types/jest-environment-puppeteer/index.d.ts b/types/jest-environment-puppeteer/index.d.ts index 8c71525938..bcc37c8f9e 100644 --- a/types/jest-environment-puppeteer/index.d.ts +++ b/types/jest-environment-puppeteer/index.d.ts @@ -1,20 +1,43 @@ // Type definitions for jest-environment-puppeteer 4.0 // Project: https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer // Definitions by: Josh Goldberg +// Ifiok Jr. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Browser, Page } from "puppeteer"; +import { Browser, Page, BrowserContext } from 'puppeteer'; interface JestPuppeteer { + /** + * Reset global.page + * + * ```ts + * beforeEach(async () => { + * await jestPuppeteer.resetPage() + * }) + * ``` + */ resetPage(): Promise; + + /** + * Suspends test execution and gives you opportunity to see what's going on in the browser + * - Jest is suspended (no timeout) + * - A debugger instruction to Chromium, if Puppeteer has been launched with { devtools: true } it will stop + * + * ```ts + * it('should put test in debug mode', async () => { + * await jestPuppeteer.debug() + * }) + * ``` + */ debug(): Promise; } declare global { const browser: Browser; - const page: Page + const context: BrowserContext; + const page: Page; const jestPuppeteer: JestPuppeteer; } -export { }; +export {}; diff --git a/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts b/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts index 3de8c3661a..fb424d580b 100644 --- a/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts +++ b/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts @@ -2,3 +2,7 @@ import * as puppeteer from "puppeteer"; const myBrowser: puppeteer.Browser = browser; const myPage: puppeteer.Page = page; +const myContext: puppeteer.BrowserContext = context; + +jestPuppeteer.debug(); +jestPuppeteer.resetPage(); From 61345c63d8e3e9c02c540062ac63fb3e00f970fa Mon Sep 17 00:00:00 2001 From: Takafumi Yamaguchi Date: Thu, 21 Feb 2019 22:16:41 +0900 Subject: [PATCH 083/222] Add detailed types to plotly.Layout.title According to the page below, specifying only string to Layout.title has been deprecated. https://plot.ly/javascript/reference/#layout-title --- types/plotly.js/index.d.ts | 15 +++++++++++++-- types/plotly.js/test/index-tests.ts | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index af90a6f6a0..8e5622bdef 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for plotly.js 1.43 +// Type definitions for plotly.js 1.44 // Project: https://plot.ly/javascript/, https://github.com/plotly/plotly.js // Definitions by: Chris Gervang // Martin Duparc @@ -10,6 +10,7 @@ // Sooraj Pudiyadath // Jon Freedman // Megan Riel-Mehan +// Takafumi Yamaguchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -205,7 +206,17 @@ export function deleteFrames(root: Root, frames: number[]): Promise; + xref: 'container' | 'paper'; + yref: 'container' | 'paper'; + x: number; + y: number; + xanchor: 'auto' | 'left' | 'center' | 'right'; + yanchor: 'auto' | 'top' | 'middle' | 'bottom'; + pad: Partial + }>; titlefont: Partial; autosize: boolean; showlegend: boolean; diff --git a/types/plotly.js/test/index-tests.ts b/types/plotly.js/test/index-tests.ts index 79343f43f7..828f2870a3 100644 --- a/types/plotly.js/test/index-tests.ts +++ b/types/plotly.js/test/index-tests.ts @@ -251,6 +251,24 @@ const graphDiv = '#test'; }; Plotly.update(graphDiv, data_update, layout_update); })(); + +(() => { + const update = { + title: { + text: 'some new title', + font: { + size: 1.2, + }, + x: 0.9, + pad: { + t: 20 + }, + }, // updates the title + 'xaxis.range': [0, 5], // updates the xaxis range + 'yaxis.range[1]': 15 // updates the end of the yaxis range + } as Layout; + Plotly.relayout(graphDiv, update); +})(); ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// From 6f665d9763a956507484777c5efe76bd5e0b881c Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Thu, 21 Feb 2019 23:28:14 +0800 Subject: [PATCH 084/222] solidity-parser-antlr: make the attribute "type" of ASTNode precise Back then, the `type` is just defined as `string` type. Now, it is very precisely defined for the interfaces extending `BaseASTNode`. --- types/solidity-parser-antlr/index.d.ts | 241 +++++++++++++++++-------- 1 file changed, 169 insertions(+), 72 deletions(-) diff --git a/types/solidity-parser-antlr/index.d.ts b/types/solidity-parser-antlr/index.d.ts index 7b92aefb22..a1b149ac8a 100644 --- a/types/solidity-parser-antlr/index.d.ts +++ b/types/solidity-parser-antlr/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/federicobond/solidity-parser-antlr // Definitions by: Leonid Logvinov // Alex Browne +// Xiao Liang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -13,114 +14,208 @@ export interface Location { start: LineColumn; end: LineColumn; } + +// Note: This should be consistent with the definition of type ASTNode +type TypeString = 'SourceUnit' +| 'PragmaDirective' +| 'PragmaName' +| 'PragmaValue' +| 'Version' +| 'VersionOperator' +| 'VersionConstraint' +| 'ImportDeclaration' +| 'ImportDirective' +| 'ContractDefinition' +| 'InheritanceSpecifier' +| 'ContractPart' +| 'StateVariableDeclaration' +| 'UsingForDeclaration' +| 'StructDefinition' +| 'ModifierDefinition' +| 'ModifierInvocation' +| 'FunctionDefinition' +| 'ReturnParameters' +| 'ModifierList' +| 'EventDefinition' +| 'EnumValue' +| 'EnumDefinition' +| 'ParameterList' +| 'Parameter' +| 'EventParameterList' +| 'EventParameter' +| 'FunctionTypeParameterList' +| 'FunctionTypeParameter' +| 'VariableDeclaration' +| 'TypeName' +| 'UserDefinedTypeName' +| 'Mapping' +| 'FunctionTypeName' +| 'StorageLocation' +| 'StateMutability' +| 'Block' +| 'Statement' +| 'ExpressionStatement' +| 'IfStatement' +| 'WhileStatement' +| 'SimpleStatement' +| 'ForStatement' +| 'InlineAssemblyStatement' +| 'DoWhileStatement' +| 'ContinueStatement' +| 'BreakStatement' +| 'ReturnStatement' +| 'ThrowStatement' +| 'VariableDeclarationStatement' +| 'IdentifierList' +| 'ElementaryTypeName' +| 'Expression' +| 'PrimaryExpression' +| 'ExpressionList' +| 'NameValueList' +| 'NameValue' +| 'FunctionCallArguments' +| 'AssemblyBlock' +| 'AssemblyItem' +| 'AssemblyExpression' +| 'AssemblyCall' +| 'AssemblyLocalDefinition' +| 'AssemblyAssignment' +| 'AssemblyIdentifierOrList' +| 'AssemblyIdentifierList' +| 'AssemblyStackAssignment' +| 'LabelDefinition' +| 'AssemblySwitch' +| 'AssemblyCase' +| 'AssemblyFunctionDefinition' +| 'AssemblyFunctionReturns' +| 'AssemblyFor' +| 'AssemblyIf' +| 'AssemblyLiteral' +| 'SubAssembly' +| 'TupleExpression' +| 'ElementaryTypeNameExpression' +| 'NumberLiteral' +| 'Identifier' +| 'BinaryOperation' +| 'Conditional'; + export interface BaseASTNode { - type: string; + type: TypeString; range?: [number, number]; loc?: Location; } export interface SourceUnit extends BaseASTNode { + type: 'SourceUnit'; children: ASTNode[]; // TODO: Can be more precise } // tslint:disable-line:no-empty-interface -export interface PragmaDirective extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface PragmaName extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface PragmaValue extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Version extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface VersionOperator extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface VersionConstraint extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ImportDeclaration extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ImportDirective extends BaseASTNode {} // tslint:disable-line:no-empty-interface +export interface PragmaDirective extends BaseASTNode { type: 'PragmaDirective'; } +export interface PragmaName extends BaseASTNode { type: 'PragmaName'; } +export interface PragmaValue extends BaseASTNode { type: 'PragmaValue'; } +export interface Version extends BaseASTNode { type: 'Version'; } +export interface VersionOperator extends BaseASTNode { type: 'VersionOperator'; } +export interface VersionConstraint extends BaseASTNode { type: 'VersionConstraint'; } +export interface ImportDeclaration extends BaseASTNode { type: 'ImportDeclaration'; } +export interface ImportDirective extends BaseASTNode { type: 'ImportDirective'; } export interface ContractDefinition extends BaseASTNode { + type: 'ContractDefinition'; name: string; subNodes: ASTNode[]; // TODO: Can be more precise } -export interface InheritanceSpecifier extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ContractPart extends BaseASTNode {} // tslint:disable-line:no-empty-interface +export interface InheritanceSpecifier extends BaseASTNode { type: 'InheritanceSpecifier'; } +export interface ContractPart extends BaseASTNode { type: 'ContractPart'; } export interface StateVariableDeclaration extends BaseASTNode { + type: 'StateVariableDeclaration'; variables: VariableDeclaration[]; } -export interface UsingForDeclaration extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface StructDefinition extends BaseASTNode {} // tslint:disable-line:no-empty-interface +export interface UsingForDeclaration extends BaseASTNode { type: 'UsingForDeclaration'; } +export interface StructDefinition extends BaseASTNode { type: 'StructDefinition'; } export interface ModifierDefinition extends BaseASTNode { + type: 'ModifierDefinition'; name: string; } export interface ModifierInvocation extends BaseASTNode { + type: 'ModifierInvocation'; name: string; } export interface FunctionDefinition extends BaseASTNode { + type: 'FunctionDefinition'; name: string; parameters: ParameterList; body: Block | null; } -export interface ReturnParameters extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ModifierList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface EventDefinition extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface EnumValue extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface EnumDefinition extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ParameterList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Parameter extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface EventParameterList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface EventParameter extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface FunctionTypeParameterList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface FunctionTypeParameter extends BaseASTNode {} // tslint:disable-line:no-empty-interface +export interface ReturnParameters extends BaseASTNode { type: 'ReturnParameters'; } +export interface ModifierList extends BaseASTNode { type: 'ModifierList'; } +export interface EventDefinition extends BaseASTNode { type: 'EventDefinition'; } +export interface EnumValue extends BaseASTNode { type: 'EnumValue'; } +export interface EnumDefinition extends BaseASTNode { type: 'EnumDefinition'; } +export interface ParameterList extends BaseASTNode { type: 'ParameterList'; } +export interface Parameter extends BaseASTNode { type: 'Parameter'; } +export interface EventParameterList extends BaseASTNode { type: 'EventParameterList'; } +export interface EventParameter extends BaseASTNode { type: 'EventParameter'; } +export interface FunctionTypeParameterList extends BaseASTNode { type: 'FunctionTypeParameterList'; } +export interface FunctionTypeParameter extends BaseASTNode { type: 'FunctionTypeParameter'; } export interface VariableDeclaration extends BaseASTNode { + type: 'VariableDeclaration'; visibility: "public" | "private"; isStateVar: boolean; } -export interface TypeName extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface UserDefinedTypeName extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Mapping extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface FunctionTypeName extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface StorageLocation extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface StateMutability extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Block extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Statement extends BaseASTNode {} // tslint:disable-line:no-empty-interface +export interface TypeName extends BaseASTNode { type: 'TypeName'; } +export interface UserDefinedTypeName extends BaseASTNode { type: 'UserDefinedTypeName'; } +export interface Mapping extends BaseASTNode { type: 'Mapping'; } +export interface FunctionTypeName extends BaseASTNode { type: 'FunctionTypeName'; } +export interface StorageLocation extends BaseASTNode { type: 'StorageLocation'; } +export interface StateMutability extends BaseASTNode { type: 'StateMutability'; } +export interface Block extends BaseASTNode { type: 'Block'; } +export interface Statement extends BaseASTNode { type: 'Statement'; } export interface ExpressionStatement extends BaseASTNode { + type: 'ExpressionStatement'; expression: ASTNode; } export interface IfStatement extends BaseASTNode { + type: 'IfStatement'; trueBody: ASTNode; falseBody: ASTNode; } -export interface WhileStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface SimpleStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ForStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface InlineAssemblyStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface DoWhileStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ContinueStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface BreakStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ReturnStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ThrowStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface VariableDeclarationStatement extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface IdentifierList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ElementaryTypeName extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Expression extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface PrimaryExpression extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ExpressionList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface NameValueList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface NameValue extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface FunctionCallArguments extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyBlock extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyItem extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyExpression extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyCall extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyLocalDefinition extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyAssignment extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyIdentifierOrList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyIdentifierList extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyStackAssignment extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface LabelDefinition extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblySwitch extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyCase extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyFunctionDefinition extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyFunctionReturns extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyFor extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyIf extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface AssemblyLiteral extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface SubAssembly extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface TupleExpression extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface ElementaryTypeNameExpression extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface NumberLiteral extends BaseASTNode {} // tslint:disable-line:no-empty-interface -export interface Identifier extends BaseASTNode {} // tslint:disable-line:no-empty-interface +export interface WhileStatement extends BaseASTNode { type: 'WhileStatement'; } +export interface SimpleStatement extends BaseASTNode { type: 'SimpleStatement'; } +export interface ForStatement extends BaseASTNode { type: 'ForStatement'; } +export interface InlineAssemblyStatement extends BaseASTNode { type: 'InlineAssemblyStatement'; } +export interface DoWhileStatement extends BaseASTNode { type: 'DoWhileStatement'; } +export interface ContinueStatement extends BaseASTNode { type: 'ContinueStatement'; } +export interface BreakStatement extends BaseASTNode { type: 'BreakStatement'; } +export interface ReturnStatement extends BaseASTNode { type: 'ReturnStatement'; } +export interface ThrowStatement extends BaseASTNode { type: 'ThrowStatement'; } +export interface VariableDeclarationStatement extends BaseASTNode { type: 'VariableDeclarationStatement'; } +export interface IdentifierList extends BaseASTNode { type: 'IdentifierList'; } +export interface ElementaryTypeName extends BaseASTNode { type: 'ElementaryTypeName'; } +export interface Expression extends BaseASTNode { type: 'Expression'; } +export interface PrimaryExpression extends BaseASTNode { type: 'PrimaryExpression'; } +export interface ExpressionList extends BaseASTNode { type: 'ExpressionList'; } +export interface NameValueList extends BaseASTNode { type: 'NameValueList'; } +export interface NameValue extends BaseASTNode { type: 'NameValue'; } +export interface FunctionCallArguments extends BaseASTNode { type: 'FunctionCallArguments'; } +export interface AssemblyBlock extends BaseASTNode { type: 'AssemblyBlock'; } +export interface AssemblyItem extends BaseASTNode { type: 'AssemblyItem'; } +export interface AssemblyExpression extends BaseASTNode { type: 'AssemblyExpression'; } +export interface AssemblyCall extends BaseASTNode { type: 'AssemblyCall'; } +export interface AssemblyLocalDefinition extends BaseASTNode { type: 'AssemblyLocalDefinition'; } +export interface AssemblyAssignment extends BaseASTNode { type: 'AssemblyAssignment'; } +export interface AssemblyIdentifierOrList extends BaseASTNode { type: 'AssemblyIdentifierOrList'; } +export interface AssemblyIdentifierList extends BaseASTNode { type: 'AssemblyIdentifierList'; } +export interface AssemblyStackAssignment extends BaseASTNode { type: 'AssemblyStackAssignment'; } +export interface LabelDefinition extends BaseASTNode { type: 'LabelDefinition'; } +export interface AssemblySwitch extends BaseASTNode { type: 'AssemblySwitch'; } +export interface AssemblyCase extends BaseASTNode { type: 'AssemblyCase'; } +export interface AssemblyFunctionDefinition extends BaseASTNode { type: 'AssemblyFunctionDefinition'; } +export interface AssemblyFunctionReturns extends BaseASTNode { type: 'AssemblyFunctionReturns'; } +export interface AssemblyFor extends BaseASTNode { type: 'AssemblyFor'; } +export interface AssemblyIf extends BaseASTNode { type: 'AssemblyIf'; } +export interface AssemblyLiteral extends BaseASTNode { type: 'AssemblyLiteral'; } +export interface SubAssembly extends BaseASTNode { type: 'SubAssembly'; } +export interface TupleExpression extends BaseASTNode { type: 'TupleExpression'; } +export interface ElementaryTypeNameExpression extends BaseASTNode { type: 'ElementaryTypeNameExpression'; } +export interface NumberLiteral extends BaseASTNode { type: 'NumberLiteral'; } +export interface Identifier extends BaseASTNode { type: 'Identifier'; } export type BinOp = | "+" | "-" @@ -153,11 +248,13 @@ export type BinOp = | "/=" | "%="; export interface BinaryOperation extends BaseASTNode { + type: 'BinaryOperation'; left: ASTNode; right: ASTNode; operator: BinOp; } export interface Conditional extends BaseASTNode { + type: 'Conditional'; trueExpression: ASTNode; falseExpression: ASTNode; } From 7c4d53a0e4e3e62a2ad42ca29624a5fc3849644f Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Thu, 21 Feb 2019 11:22:06 -0500 Subject: [PATCH 085/222] Updated Text members and methods --- types/fabric/fabric-impl.d.ts | 83 +++++++++++++++++ types/fabric/tmp.d.ts | 168 ++++++++++++++++++++++++++++++++++ 2 files changed, 251 insertions(+) create mode 100644 types/fabric/tmp.d.ts diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 700e4eca97..7c853a50c2 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -3661,7 +3661,9 @@ export class Rect extends Object { */ static fromObject(object: any): Rect; } + interface TextOptions extends IObjectOptions { + type?: string; /** * Font size (in pixels) * @type Number @@ -3752,6 +3754,18 @@ interface TextOptions extends IObjectOptions { */ deltaY?: number; text?: string; + /** + * List of properties to consider when checking if cache needs refresh + * @type Array + */ + cacheProperties?: string[]; + /** + * List of properties to consider when checking if + * state of an object is changed ({@link fabric.Object#hasStateChanged}) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties?: string[]; } export interface Text extends TextOptions { } export class Text extends Object { @@ -3852,6 +3866,75 @@ export class Text extends Object { * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created */ static fromObject(object: any, callback?: Function): Text; + /** + * Check if characters in a text have a value for a property + * whose value matches the textbox's value for that property. If so, + * the character-level property is deleted. If the character + * has no other properties, then it is also deleted. Finally, + * if the line containing that character has no other characters + * then it also is deleted. + * + * @param {string} property The property to compare between characters and text. + */ + cleanStyle(property: string): void; + /** + * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) + * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. + * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. usefull to manage styles. + */ + get2DCursorLocation(selectionStart: number, skipWrapping: boolean): {lineIndex: number, charIndex: number}; + /** + * return a new object that contains all the style property for a character + * the object returned is newly created + * @param {Number} lineIndex of the line where the character is + * @param {Number} charIndex position of the character on the line + * @return {Object} style object + */ + getCompleteStyleDeclaration(lineIndex: number, charIndex: number): any; + /** + * Gets style of a current selection/cursor (at the start position) + * if startIndex or endIndex are not provided, slectionStart or selectionEnd will be used. + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @param {Boolean} [complete] get full style or not + * @return {Array} styles an array with one, zero or more Style objects + */ + getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any[]; + /** + * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} + */ + getSvgStyles(skipShadow?: boolean): string; + /** + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} + */ + isEmptyStyles(lineIndex: number): boolean; + /** + * Remove a style property or properties from all individual character styles + * in a text object. Deletes the character style object if it contains no other style + * props. Deletes a line style object if it contains no other character styles. + * + * @param {String} props The property to remove from character styles. + */ + removeStyle(property: string): void; + /** + * Sets style of a current selection, if no selection exist, do not set anything. + * @param {Object} [styles] Styles object + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @return {fabric.IText} thisArg + * @chainable + */ + setSelectionStyles(styles: any, startIndex: number, endIndex: number): Text; + /** + * Returns true if object has a style property or has it ina specified line + * @param {Number} lineIndex + * @return {Boolean} + */ + styleHas(property: string, lineIndex?: number): boolean; } interface ITextOptions extends TextOptions { /** diff --git a/types/fabric/tmp.d.ts b/types/fabric/tmp.d.ts new file mode 100644 index 0000000000..7da1aa55ed --- /dev/null +++ b/types/fabric/tmp.d.ts @@ -0,0 +1,168 @@ +export class Text extends Object { + /** + * Constructor + * @param text Text string + * @param [options] Options object + */ + constructor(text: string, options?: TextOptions); + /** + * Return a context for measurement of text string. + * if created it gets stored for reuse + * @return {fabric.Text} thisArg + */ + getMeasuringContext(): CanvasRenderingContext2D; + /** + * Initialize or update text dimensions. + * Updates this.width and this.height with the proper values. + * Does not return dimensions. + */ + initDimensions(): void; + /** + * Enlarge space boxes and shift the others + */ + enlargeSpaces(): void; + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @return {Boolean} + */ + isEndOfWrapping(lineIndex: number): boolean; + /** + * Returns string representation of an instance + */ + toString(): string; + /** + * Computes height of character at given position + * @param {Number} line the line number + * @param {Number} char the character number + * @return {Number} fontSize of the character + */ + getHeightOfChar(line: number, char: number): number; + /** + * measure a text line measuring all characters. + * @param {Number} lineIndex line number + * @return {Number} Line width + */ + measureLine(lineIndex: number): number; + /** + * Calculate height of line at 'lineIndex' + * @param {Number} lineIndex index of line to calculate + * @return {Number} + */ + getHeightOfLine(lineIndex: number): number; + /** + * Calculate text box height + */ + calcTextHeight(): number; + /** + * Turns the character into a 'superior figure' (i.e. 'superscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSuperscript(start: number, end: number): Text; + /** + * Turns the character into an 'inferior figure' (i.e. 'subscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSubscript(start: number, end: number): Text; + /** + * Retrieves the value of property at given character position + * @param {Number} lineIndex the line number + * @param {Number} charIndex the charater number + * @param {String} property the property name + * @returns the value of 'property' + */ + getValueOfPropertyAt(lineIndex: number, charIndex: number, property: string): any; + static DEFAULT_SVG_FONT_SIZE: number; + /** + * Returns fabric.Text instance from an SVG element (not yet implemented) + * @static + * @memberOf fabric.Text + * @param {SVGElement} element Element to parse + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, callback?: Function, options?: TextOptions): Text; + /** + * Returns fabric.Text instance from an object representation + * @static + * @memberOf fabric.Text + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created + */ + static fromObject(object: any, callback?: Function): Text; + /** + * Check if characters in a text have a value for a property + * whose value matches the textbox's value for that property. If so, + * the character-level property is deleted. If the character + * has no other properties, then it is also deleted. Finally, + * if the line containing that character has no other characters + * then it also is deleted. + * + * @param {string} property The property to compare between characters and text. + */ + cleanStyle(property: string): void; + /** + * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) + * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. + * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. usefull to manage styles. + */ + get2DCursorLocation(selectionStart: number, skipWrapping: boolean): {lineIndex: number, charIndex: number}; + /** + * return a new object that contains all the style property for a character + * the object returned is newly created + * @param {Number} lineIndex of the line where the character is + * @param {Number} charIndex position of the character on the line + * @return {Object} style object + */ + getCompleteStyleDeclaration(lineIndex: number, charIndex: number): any; + /** + * Gets style of a current selection/cursor (at the start position) + * if startIndex or endIndex are not provided, slectionStart or selectionEnd will be used. + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @param {Boolean} [complete] get full style or not + * @return {Array} styles an array with one, zero or more Style objects + */ + getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any[]; + /** + * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} + */ + getSvgStyles(skipShadow?: boolean): string; + /** + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} + */ + isEmptyStyles(lineIndex: number): boolean; + /** + * Remove a style property or properties from all individual character styles + * in a text object. Deletes the character style object if it contains no other style + * props. Deletes a line style object if it contains no other character styles. + * + * @param {String} props The property to remove from character styles. + */ + removeStyle(property: string): void; + /** + * Sets style of a current selection, if no selection exist, do not set anything. + * @param {Object} [styles] Styles object + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @return {fabric.IText} thisArg + * @chainable + */ + setSelectionStyles(styles: any, startIndex: number, endIndex: number): Text; + /** + * Returns true if object has a style property or has it ina specified line + * @param {Number} lineIndex + * @return {Boolean} + */ + styleHas(property: string, lineIndex?: number): boolean; +} From 8e9d6c38b72ba4d76dbbca034d293760d709b75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Thu, 21 Feb 2019 14:30:25 +0000 Subject: [PATCH 086/222] [proper-lockfile] Add lockfilePath option --- types/proper-lockfile/index.d.ts | 4 ++++ types/proper-lockfile/proper-lockfile-tests.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/types/proper-lockfile/index.d.ts b/types/proper-lockfile/index.d.ts index 885e63808b..3e49e79fe3 100644 --- a/types/proper-lockfile/index.d.ts +++ b/types/proper-lockfile/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for proper-lockfile 3.0 // Project: https://github.com/moxystudio/node-proper-lockfile // Definitions by: Nikita Volodin +// Linus Unnebäck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface LockOptions { @@ -10,17 +11,20 @@ export interface LockOptions { realpath?: boolean; // default: true fs?: any; // default: graceful-fs onCompromised?: (err: Error) => any; // default: (err) => throw err + lockfilePath?: string; // default: `${file}.lock` } export interface UnlockOptions { realpath?: boolean; // default: true fs?: any; // default: graceful-fs + lockfilePath?: string; // default: `${file}.lock` } export interface CheckOptions { stale?: number; // default: 10000 realpath?: boolean; // default: true fs?: any; // default: graceful-fs + lockfilePath?: string; // default: `${file}.lock` } export function lock(file: string, options?: LockOptions): Promise<() => Promise>; diff --git a/types/proper-lockfile/proper-lockfile-tests.ts b/types/proper-lockfile/proper-lockfile-tests.ts index 7555fd5116..344e7be3f8 100644 --- a/types/proper-lockfile/proper-lockfile-tests.ts +++ b/types/proper-lockfile/proper-lockfile-tests.ts @@ -39,7 +39,12 @@ check('some/file') // isLocked will be true if 'some/file' is locked, false otherwise }); +lock('', { lockfilePath: 'some/file-lock' }) + .then((release) => release()); + const release = lockSync('some/file'); // $ExpectType () => void release(); // $ExpectType void unlockSync('some/file'); // $ExpectType void +unlockSync('', { lockfilePath: 'some/file-lock' }); // $ExpectType void checkSync('some/file'); // $ExpectType boolean +checkSync('', { lockfilePath: 'some/file-lock' }); // $ExpectType boolean From 90341dcc16f6e4f9fabd6be5ae86cb562c260371 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Thu, 21 Feb 2019 11:24:07 -0500 Subject: [PATCH 087/222] Removed tmp file that was accidentally included in last commit --- types/fabric/tmp.d.ts | 168 ------------------------------------------ 1 file changed, 168 deletions(-) delete mode 100644 types/fabric/tmp.d.ts diff --git a/types/fabric/tmp.d.ts b/types/fabric/tmp.d.ts deleted file mode 100644 index 7da1aa55ed..0000000000 --- a/types/fabric/tmp.d.ts +++ /dev/null @@ -1,168 +0,0 @@ -export class Text extends Object { - /** - * Constructor - * @param text Text string - * @param [options] Options object - */ - constructor(text: string, options?: TextOptions); - /** - * Return a context for measurement of text string. - * if created it gets stored for reuse - * @return {fabric.Text} thisArg - */ - getMeasuringContext(): CanvasRenderingContext2D; - /** - * Initialize or update text dimensions. - * Updates this.width and this.height with the proper values. - * Does not return dimensions. - */ - initDimensions(): void; - /** - * Enlarge space boxes and shift the others - */ - enlargeSpaces(): void; - /** - * Detect if the text line is ended with an hard break - * text and itext do not have wrapping, return false - * @return {Boolean} - */ - isEndOfWrapping(lineIndex: number): boolean; - /** - * Returns string representation of an instance - */ - toString(): string; - /** - * Computes height of character at given position - * @param {Number} line the line number - * @param {Number} char the character number - * @return {Number} fontSize of the character - */ - getHeightOfChar(line: number, char: number): number; - /** - * measure a text line measuring all characters. - * @param {Number} lineIndex line number - * @return {Number} Line width - */ - measureLine(lineIndex: number): number; - /** - * Calculate height of line at 'lineIndex' - * @param {Number} lineIndex index of line to calculate - * @return {Number} - */ - getHeightOfLine(lineIndex: number): number; - /** - * Calculate text box height - */ - calcTextHeight(): number; - /** - * Turns the character into a 'superior figure' (i.e. 'superscript') - * @param {Number} start selection start - * @param {Number} end selection end - * @returns {fabric.Text} thisArg - * @chainable - */ - setSuperscript(start: number, end: number): Text; - /** - * Turns the character into an 'inferior figure' (i.e. 'subscript') - * @param {Number} start selection start - * @param {Number} end selection end - * @returns {fabric.Text} thisArg - * @chainable - */ - setSubscript(start: number, end: number): Text; - /** - * Retrieves the value of property at given character position - * @param {Number} lineIndex the line number - * @param {Number} charIndex the charater number - * @param {String} property the property name - * @returns the value of 'property' - */ - getValueOfPropertyAt(lineIndex: number, charIndex: number, property: string): any; - static DEFAULT_SVG_FONT_SIZE: number; - /** - * Returns fabric.Text instance from an SVG element (not yet implemented) - * @static - * @memberOf fabric.Text - * @param {SVGElement} element Element to parse - * @param {Function} callback callback function invoked after parsing - * @param {Object} [options] Options object - */ - static fromElement(element: SVGElement, callback?: Function, options?: TextOptions): Text; - /** - * Returns fabric.Text instance from an object representation - * @static - * @memberOf fabric.Text - * @param {Object} object Object to create an instance from - * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created - */ - static fromObject(object: any, callback?: Function): Text; - /** - * Check if characters in a text have a value for a property - * whose value matches the textbox's value for that property. If so, - * the character-level property is deleted. If the character - * has no other properties, then it is also deleted. Finally, - * if the line containing that character has no other characters - * then it also is deleted. - * - * @param {string} property The property to compare between characters and text. - */ - cleanStyle(property: string): void; - /** - * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) - * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. - * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. usefull to manage styles. - */ - get2DCursorLocation(selectionStart: number, skipWrapping: boolean): {lineIndex: number, charIndex: number}; - /** - * return a new object that contains all the style property for a character - * the object returned is newly created - * @param {Number} lineIndex of the line where the character is - * @param {Number} charIndex position of the character on the line - * @return {Object} style object - */ - getCompleteStyleDeclaration(lineIndex: number, charIndex: number): any; - /** - * Gets style of a current selection/cursor (at the start position) - * if startIndex or endIndex are not provided, slectionStart or selectionEnd will be used. - * @param {Number} [startIndex] Start index to get styles at - * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 - * @param {Boolean} [complete] get full style or not - * @return {Array} styles an array with one, zero or more Style objects - */ - getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any[]; - /** - * Returns styles-string for svg-export - * @param {Boolean} skipShadow a boolean to skip shadow filter output - * @return {String} - */ - getSvgStyles(skipShadow?: boolean): string; - /** - * Returns true if object has no styling or no styling in a line - * @param {Number} lineIndex , lineIndex is on wrapped lines. - * @return {Boolean} - */ - isEmptyStyles(lineIndex: number): boolean; - /** - * Remove a style property or properties from all individual character styles - * in a text object. Deletes the character style object if it contains no other style - * props. Deletes a line style object if it contains no other character styles. - * - * @param {String} props The property to remove from character styles. - */ - removeStyle(property: string): void; - /** - * Sets style of a current selection, if no selection exist, do not set anything. - * @param {Object} [styles] Styles object - * @param {Number} [startIndex] Start index to get styles at - * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 - * @return {fabric.IText} thisArg - * @chainable - */ - setSelectionStyles(styles: any, startIndex: number, endIndex: number): Text; - /** - * Returns true if object has a style property or has it ina specified line - * @param {Number} lineIndex - * @return {Boolean} - */ - styleHas(property: string, lineIndex?: number): boolean; -} From 561a8bd9ac6b1c4b61b51db657cc62a41dba6411 Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Fri, 22 Feb 2019 00:49:41 +0800 Subject: [PATCH 088/222] solidity-parser-antlr: export the `TypeString` type --- types/solidity-parser-antlr/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/solidity-parser-antlr/index.d.ts b/types/solidity-parser-antlr/index.d.ts index a1b149ac8a..113d004fd7 100644 --- a/types/solidity-parser-antlr/index.d.ts +++ b/types/solidity-parser-antlr/index.d.ts @@ -16,7 +16,7 @@ export interface Location { } // Note: This should be consistent with the definition of type ASTNode -type TypeString = 'SourceUnit' +export type TypeString = 'SourceUnit' | 'PragmaDirective' | 'PragmaName' | 'PragmaValue' From a66262fee1df911499c3cbd04d1bf1e37e24e622 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Thu, 21 Feb 2019 12:24:43 -0500 Subject: [PATCH 089/222] Updated definitions for IText --- types/fabric/fabric-impl.d.ts | 187 +++++++++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 3 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 7c853a50c2..6c48f4b0e7 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -3941,7 +3941,8 @@ interface ITextOptions extends TextOptions { * Index where text selection starts (or where cursor is when there is no selection) * @type Number */ - selectionStart?: number;/** + selectionStart?: number; + /** * Index where text selection ends * @type Number */ @@ -3998,6 +3999,26 @@ interface ITextOptions extends TextOptions { inCompositionMode?: boolean; path?: string; useNative?: boolean; + /** + * For functionalities on keyDown + ctrl || cmd + */ + ctrlKeysMapDown?: any; + /** + * For functionalities on keyUp + ctrl || cmd + */ + ctrlKeysMapUp?: any; + /** + * For functionalities on keyDown + * Map a special key to a function of the instance/prototype + * If you need different behaviour for ESC or TAB or arrows, you have to change + * this map setting the name of a function that you build on the fabric.Itext or + * your prototype. + * the map change will affect all Instances unless you need for only some text Instances + * in that case you have to clone this object and assign your Instance. + * this.keysMap = fabric.util.object.clone(this.keysMap); + * The function must be in fabric.Itext.prototype.myFunction And will receive event as args[0] + */ + keysMap?: any; } export interface IText extends ITextOptions { } export class IText extends Text { @@ -4020,7 +4041,7 @@ export class IText extends Text { /** * Prepare and clean the contextTop */ - clearContextTop(skipRestor: boolean): void; + clearContextTop(skipRestore?: boolean): void; /** * Renders cursor or selection (depending on what exists) */ @@ -4180,12 +4201,172 @@ export class IText extends Text { * @param {Number} start cursor index for inserting style * @param {Array} [copiedStyle] array of style objects to insert. */ - insertNewStyleBlock(insertedText: any[], start: number, copiedStyle: any[]): void; + insertNewStyleBlock(insertedText: any[], start: number, copiedStyle?: any[]): void; /** * Set the selectionStart and selectionEnd according to the ne postion of cursor * mimic the key - mouse navigation when shift is pressed. */ setSelectionStartEndWithShift(start: number, end: number, newSelection: number): void; + /** + * Copies selected text + */ + copy(): void; + /** + * convert from fabric to textarea values + */ + fromGraphemeToStringSelection(start: number, end: number, _text: string): {selectionStart: string, selectionEnd: string}; + /** + * convert from textarea to grapheme indexes + */ + fromStringToGraphemeSelection(start: number, end: number, text: string): {selectionStart: string, selectionEnd: string}; + /** + * Gets start offset of a selection + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + getDownCursorOffset(e: Event, isRight?: boolean): number; + /** + * Returns index of a character corresponding to where an object was clicked + * @param {Event} e Event object + * @return {Number} Index of a character + */ + getSelectionStartFromPointer(e: Event): number; + /** + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + getUpCursorOffset(e: Event, isRight?: boolean): number; + /** + * Initializes double and triple click event handlers + */ + initClicks(): void; + /** + * Initializes event handlers related to cursor or selection + */ + initCursorSelectionHandlers(): void + /** + * Initializes "dbclick" event handler + */ + initDoubleClickSimulation(): void; + /** + * Initializes hidden textarea (needed to bring up keyboard in iOS) + */ + initHiddenTextarea(): void; + /** + * Initializes "mousedown" event handler + */ + initMousedownHandler(): void; + /** + * Initializes "mouseup" event handler + */ + initMouseupHandler(): void; + /** + * insert characters at start position, before start position. + * start equal 1 it means the text get inserted between actual grapheme 0 and 1 + * if style array is provided, it must be as the same length of text in graphemes + * if end is provided and is bigger than start, old text is replaced. + * start/end ar per grapheme position in _text array. + * + * @param {String} text text to insert + * @param {Array} style array of style objects + * @param {Number} start + * @param {Number} end default to start + 1 + */ + insertChars(text: string, style: any[], start: number, end: number): void; + /** + * Moves cursor down + * @param {Event} e Event object + */ + moveCursorDown(e: Event): void; + /** + * Moves cursor left + * @param {Event} e Event object + */ + moveCursorLeft(e: Event): void; + /** + * Moves cursor left without keeping selection + * @param {Event} e + */ + moveCursorLeftWithoutShift(e: Event): void; + /** + * Moves cursor left while keeping selection + * @param {Event} e + */ + moveCursorLeftWithShift(e: Event): void; + /** + * Moves cursor right + * @param {Event} e Event object + */ + moveCursorRight(e: Event): void; + /** + * Moves cursor right without keeping selection + * @param {Event} e Event object + */ + moveCursorRightWithoutShift(e: Event): void; + /** + * Moves cursor right while keeping selection + * @param {Event} e + */ + moveCursorRightWithShift(e: Event): void; + /** + * Moves cursor up + * @param {Event} e Event object + */ + moveCursorUp(e: Event): void; + /** + * Moves cursor up without shift + * @param {Number} offset + */ + moveCursorWithoutShift(offset: number): void; + /** + * Moves cursor with shift + * @param {Number} offset + */ + moveCursorWithShift(offset: number): void; + /** + * Composition end + */ + onCompositionEnd(): void; + /** + * Composition start + */ + onCompositionStart(): void; + /** + * Handles onInput event + * @param {Event} e Event object + */ + onInput(e: Event): void; + /** + * Handles keyup event + * @param {Event} e Event object + */ + onKeyDown(e: Event): void; + /** + * Handles keyup event + * We handle KeyUp because ie11 and edge have difficulties copy/pasting + * if a copy/cut event fired, keyup is dismissed + * @param {Event} e Event object + */ + onKeyUp(e: Event): void; + /** + * Pastes text + */ + paste(): void; + /** + * Removes characters from start/end + * start/end ar per grapheme position in _text array. + * + * @param {Number} start + * @param {Number} end default to start + 1 + */ + removeChars(start: number, end: number): void; + /** + * Changes cursor location in a text depending on passed pointer (x/y) object + * @param {Event} e Event object + */ + setCursorByClick(e: Event): void; } interface ITextboxOptions extends ITextOptions { /** From a7f1c533bdb6130eba1a5137ed3a8b3c19aa5289 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Thu, 21 Feb 2019 14:27:27 -0500 Subject: [PATCH 090/222] Updated getSelectionStyles for options start and end index --- 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 6c48f4b0e7..fb9a0d8a63 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -3899,7 +3899,7 @@ export class Text extends Object { * @param {Boolean} [complete] get full style or not * @return {Array} styles an array with one, zero or more Style objects */ - getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any[]; + getSelectionStyles(startIndex?: number, endIndex?: number, complete?: boolean): any[]; /** * Returns styles-string for svg-export * @param {Boolean} skipShadow a boolean to skip shadow filter output From 024af7684eb072790ee5918cca06462a57a5b2c7 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Thu, 21 Feb 2019 15:32:04 -0500 Subject: [PATCH 091/222] Updated definition for setSelectionStyles --- types/fabric/fabric-impl.d.ts | 66 +++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index fb9a0d8a63..5a31e9c8c0 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -143,7 +143,7 @@ interface IDataURLOptions { interface IEvent { e: Event; target?: Object; - transform?: { corner: string }; + transform?: { corner: string }; } interface IFillOptions { @@ -2135,10 +2135,10 @@ export class ActiveSelection { */ constructor(objects?: Object[], options?: IObjectOptions); /** - * Change te activeSelection to a normal group, - * High level function that automatically adds it to canvas as - * active object. no events fired. - */ + * Change te activeSelection to a normal group, + * High level function that automatically adds it to canvas as + * active object. no events fired. + */ toGroup(): Group; /** * If returns true, deselection is cancelled. @@ -3928,7 +3928,7 @@ export class Text extends Object { * @return {fabric.IText} thisArg * @chainable */ - setSelectionStyles(styles: any, startIndex: number, endIndex: number): Text; + setSelectionStyles(styles: any, startIndex?: number, endIndex?: number): Text; /** * Returns true if object has a style property or has it ina specified line * @param {Number} lineIndex @@ -4400,12 +4400,12 @@ interface ITextboxOptions extends ITextOptions { } export interface Textbox extends ITextboxOptions{} export class Textbox extends IText { - /** - * Constructor - * @param text Text string - * @param [options] Options object - */ - constructor(text: string, options?: ITextboxOptions); + /** + * Constructor + * @param text Text string + * @param [options] Options object + */ + constructor(text: string, options?: ITextboxOptions); /** * Returns true if object has a style property or has it ina specified line * @param {Number} lineIndex @@ -4503,18 +4503,18 @@ interface IAllFilters { */ fromObject(object: any): IBrightnessFilter }; - ColorMatrix: { - new(options?: { - /** Filter matrix */ - matrix?: number[] - }): IColorMatrix; - /** - * Returns filter instance from an object representation - * @param object Object to create an instance from - */ - fromObject(object: any): IColorMatrix - }; - Convolute: { + ColorMatrix: { + new(options?: { + /** Filter matrix */ + matrix?: number[] + }): IColorMatrix; + /** + * Returns filter instance from an object representation + * @param object Object to create an instance from + */ + fromObject(object: any): IColorMatrix + }; + Convolute: { new(options?: { opaque?: boolean, /** Filter matrix */ @@ -4703,11 +4703,11 @@ interface IBrightnessFilter extends IBaseFilter { applyTo(canvasEl: HTMLCanvasElement): void; } interface IColorMatrix extends IBaseFilter { - /** - * Applies filter to canvas element - * @param canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; + /** + * Applies filter to canvas element + * @param canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; } interface IConvoluteFilter extends IBaseFilter { /** @@ -5389,10 +5389,10 @@ interface IUtilMisc { */ qrDecompose(a: number[]): { angle: number, scaleX: number, scaleY: number, skewX: number, skewY: number, translateX: number, translateY: number }; - /** - * Creates a transform matrix with the specified scale and skew - */ - customTransformMatrix(scaleX: number, scaleY: number, skewX: number): number[]; + /** + * Creates a transform matrix with the specified scale and skew + */ + customTransformMatrix(scaleX: number, scaleY: number, skewX: number): number[]; /** * Returns string representation of function body From 307c2e4e4ee20715ecd534baac866094462a93b5 Mon Sep 17 00:00:00 2001 From: Steven Bell Date: Thu, 21 Feb 2019 13:02:13 -0800 Subject: [PATCH 092/222] Fix return values of rethrowResult and retryResult Bug: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33242 To make the type definition consistent with both the implementation and api docs as indicated in the bug, we are updating the return values of `rethrowResult` and `retryResult` to return a `DecisionInfo` object. Additionally the `DecisionInfo` object will have it's `consistency` field made optional and a new optional field of `useCurrentHost` is added. --- types/cassandra-driver/index.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types/cassandra-driver/index.d.ts b/types/cassandra-driver/index.d.ts index 86073ec888..21b6f9d8d1 100644 --- a/types/cassandra-driver/index.d.ts +++ b/types/cassandra-driver/index.d.ts @@ -87,7 +87,8 @@ export namespace policies { interface DecisionInfo { decision: number; - consistency: number; + consistency?: number; + useCurrentHost?: boolean; } interface RequestInfo { @@ -115,8 +116,8 @@ export namespace policies { onReadTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, isDataPresent: boolean): DecisionInfo; onUnavailable(requestInfo: RequestInfo, consistency: types.consistencies, required: number, alive: number): DecisionInfo; onWriteTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, writeType: string): DecisionInfo; - rethrowResult(): { decision: retryDecision }; - retryResult(consistency?: types.consistencies, useCurrentHost?: boolean): { decision: retryDecision, consistency: types.consistencies, useCurrentHost: boolean }; + rethrowResult(): DecisionInfo; + retryResult(consistency?: types.consistencies, useCurrentHost?: boolean): DecisionInfo; } } From 24766397d3a571f87d6ffa93e981e9de507f5456 Mon Sep 17 00:00:00 2001 From: Elizabeth Samuel Date: Thu, 21 Feb 2019 13:39:57 -0800 Subject: [PATCH 093/222] [office-js] [office-js-preview] (Outlook) Update setSelectedDataAsync --- types/office-js-preview/index.d.ts | 30 +++++++++++++++--------------- types/office-js/index.d.ts | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index 42544390d9..2aba542e41 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -12566,7 +12566,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -12575,10 +12575,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -12598,10 +12598,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** @@ -14251,7 +14251,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -14260,10 +14260,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -14283,10 +14283,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The read mode of {@link Office.Item | Office.context.mailbox.item}. @@ -15548,7 +15548,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -15556,10 +15556,10 @@ declare namespace Office { * applied in Outlook. If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -15579,10 +15579,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The message read mode of {@link Office.Item | Office.context.mailbox.item}. diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index c207b00668..3ae239539f 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -12566,7 +12566,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -12575,10 +12575,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -12598,10 +12598,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** @@ -14251,7 +14251,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -14260,10 +14260,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -14283,10 +14283,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The read mode of {@link Office.Item | Office.context.mailbox.item}. @@ -15548,7 +15548,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -15556,10 +15556,10 @@ declare namespace Office { * applied in Outlook. If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -15579,10 +15579,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The message read mode of {@link Office.Item | Office.context.mailbox.item}. From 5f2c115e58f3c8772dddab7320a3fb62fdf0f4b3 Mon Sep 17 00:00:00 2001 From: Michael Oakley Date: Thu, 21 Feb 2019 16:00:21 -0700 Subject: [PATCH 094/222] Update `containCrop()` definition Add `previousCrop` arg --- types/react-image-crop/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-image-crop/index.d.ts b/types/react-image-crop/index.d.ts index 9cb750dbd2..877966b00e 100644 --- a/types/react-image-crop/index.d.ts +++ b/types/react-image-crop/index.d.ts @@ -51,7 +51,7 @@ declare namespace ReactCrop { function getPixelCrop(image: HTMLImageElement, percentCrop: Crop): Crop; function makeAspectCrop(crop: Crop, imageAspect: number): Crop; - function containCrop(crop: Crop, imageAspect: number): Crop; + function containCrop(previousCrop: Crop, crop: Crop, imageAspect: number): Crop; } declare class ReactCrop extends Component { From a372e4f48e111baba5ef5e8311de19c9fe86d25b Mon Sep 17 00:00:00 2001 From: Alejandro Corredor Date: Thu, 21 Feb 2019 18:46:58 -0500 Subject: [PATCH 095/222] Update index.d.ts After this PR (https://github.com/sequelize/sequelize/pull/9914/files/e86ea72b2dc3c89525a42678bb268af338b40a9a) a uniqueKey option can be added to the `belongsToMany` association. --- types/sequelize/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index d89dac0d4a..107e01495a 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -1379,7 +1379,11 @@ declare namespace sequelize { * Should the join model have timestamps */ timestamps?: boolean; - + + /** + * Belongs-To-Many creates a unique key when primary key is not present on through model. This unique key name can be overridden using uniqueKey option. + */ + uniqueKey?: string; } /** From 21fa1faabf0a10cd61da32a2cf4aece9bd766ab6 Mon Sep 17 00:00:00 2001 From: Iago Melanias Date: Thu, 21 Feb 2019 20:57:13 -0300 Subject: [PATCH 096/222] nullable(): make argument isNullable optional Following the repository documentation, the argument isNullable is optional because it has the default value `true`. https://github.com/jquense/yup#mixednullableisnullable-boolean--true-schema --- types/yup/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index dc73ae6bd9..7e03517143 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -70,7 +70,7 @@ export interface Schema { withMutation(fn: (current: this) => void): void; default(value: any): this; default(): T; - nullable(isNullable: boolean): this; + nullable(isNullable?: boolean): this; required(message?: TestOptionsMessage): this; notRequired(): this; typeError(message?: TestOptionsMessage): this; From b5e530db8f96b6fc6a0f6dec59fbc33329873770 Mon Sep 17 00:00:00 2001 From: Iago Melanias Date: Thu, 21 Feb 2019 21:03:02 -0300 Subject: [PATCH 097/222] nullable(): add test to ensure isNullable argument is optional --- types/yup/yup-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index c6717e95ad..fdead13b2b 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -148,6 +148,7 @@ mixed.default({ number: 5 }); mixed.default(() => ({ number: 5 })); mixed.default(); mixed.nullable(true); +mixed.nullable(); mixed.required(); mixed.required("Foo"); mixed.required(() => "Foo"); From fd340e901186c6eeb2520b94242867d0e2debb18 Mon Sep 17 00:00:00 2001 From: Chives Date: Thu, 21 Feb 2019 16:33:55 -0800 Subject: [PATCH 098/222] Add typings for --- types/angular-material/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/angular-material/index.d.ts b/types/angular-material/index.d.ts index 6b012d5677..444e043210 100644 --- a/types/angular-material/index.d.ts +++ b/types/angular-material/index.d.ts @@ -512,5 +512,10 @@ declare module 'angular' { } type IStickyService = (scope: IScope, element: JQuery, elementClone?: JQuery) => void; + + interface IInteractionService { + getLastInteractionType(): string|null; + isUserInvoked(checkDelay?: number): boolean; + } } } From ccf14cc1ed8494f4fc761ec96f98c96bb2ed4e61 Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Fri, 22 Feb 2019 04:51:49 +0100 Subject: [PATCH 099/222] fix(node): add overloads for inherited methods on buffer --- types/node/globals.d.ts | 2 ++ types/node/test/buffer.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/types/node/globals.d.ts b/types/node/globals.d.ts index cd7d67bbdf..dd4198a00e 100644 --- a/types/node/globals.d.ts +++ b/types/node/globals.d.ts @@ -245,6 +245,7 @@ interface Buffer extends Uint8Array { compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): Buffer; + subarray(begin: number, end?: number): Buffer; writeUIntLE(value: number, offset: number, byteLength: number): number; writeUIntBE(value: number, offset: number, byteLength: number): number; writeIntLE(value: number, offset: number, byteLength: number): number; @@ -267,6 +268,7 @@ interface Buffer extends Uint8Array { readFloatBE(offset: number): number; readDoubleLE(offset: number): number; readDoubleBE(offset: number): number; + reverse(): this; swap16(): Buffer; swap32(): Buffer; swap64(): Buffer; diff --git a/types/node/test/buffer.ts b/types/node/test/buffer.ts index 37b02ef708..404b8b08c6 100644 --- a/types/node/test/buffer.ts +++ b/types/node/test/buffer.ts @@ -201,3 +201,10 @@ b.fill('a').fill('b'); const buffer = new Buffer('123'); const octets = new Uint8Array(buffer.buffer); } + +// Inherited from Uint8Array but return buffer +{ + const b = Buffer.from('asd'); + let res: Buffer = b.reverse(); + res = b.subarray(1); +} From 9087fc357ad880c958c0740866286d117b186bab Mon Sep 17 00:00:00 2001 From: ZSUU Date: Fri, 22 Feb 2019 12:45:34 +0800 Subject: [PATCH 100/222] @types/webpack Support SplitChunkOptions.automaticNameDelimiter --- types/webpack/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 1c423c428c..fe3dc638e1 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -610,6 +610,8 @@ declare namespace webpack { name?: boolean | string | ((...args: any[]) => any); /** Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) */ cacheGroups?: false | string | ((...args: any[]) => any) | RegExp | { [key: string]: CacheGroupsOptions | false }; + /** Override the default name separator (~) when generating names automatically (name: true) */ + automaticNameDelimiter?: string; } interface RuntimeChunkOptions { /** The name or name factory for the runtime chunks. */ From 1b5d9050705abcaba0d0131b6672de0b1384ec55 Mon Sep 17 00:00:00 2001 From: okampfer Date: Fri, 22 Feb 2019 17:38:33 +0800 Subject: [PATCH 101/222] Add middleware() method to ParcelBundler. --- types/parcel-bundler/index.d.ts | 2 ++ types/parcel-bundler/parcel-bundler-tests.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/types/parcel-bundler/index.d.ts b/types/parcel-bundler/index.d.ts index c661d105cd..735673967f 100644 --- a/types/parcel-bundler/index.d.ts +++ b/types/parcel-bundler/index.d.ts @@ -173,6 +173,8 @@ declare class ParcelBundler { addPackager(type: string, packager: string): void; bundle(): Promise; + + middleware(): (req: any, res: any, next: any) => any; } export = ParcelBundler; diff --git a/types/parcel-bundler/parcel-bundler-tests.ts b/types/parcel-bundler/parcel-bundler-tests.ts index 5833b8527b..0623056c89 100644 --- a/types/parcel-bundler/parcel-bundler-tests.ts +++ b/types/parcel-bundler/parcel-bundler-tests.ts @@ -10,4 +10,6 @@ bundler.addAssetType('md', 'markdown-asset'); bundler.addPackager('md', 'markdown-packager'); +bundler.middleware(); + bundler.bundle().then(bundle => bundle.name); From 6a6848a73b9601f8ef9f4a3179ea3245846cb77b Mon Sep 17 00:00:00 2001 From: Patrick Simmelbauer Date: Fri, 22 Feb 2019 14:18:25 +0100 Subject: [PATCH 102/222] Fix plugin typings --- types/prosemirror-state/index.d.ts | 36 +++++++++++++++--------------- types/prosemirror-view/index.d.ts | 1 + 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/types/prosemirror-state/index.d.ts b/types/prosemirror-state/index.d.ts index a0c2b6ae69..0fc8950838 100644 --- a/types/prosemirror-state/index.d.ts +++ b/types/prosemirror-state/index.d.ts @@ -22,7 +22,7 @@ import { EditorProps, EditorView } from 'prosemirror-view'; * This is the type passed to the [`Plugin`](#state.Plugin) * constructor. It provides a definition for a plugin. */ -export interface PluginSpec { +export interface PluginSpec { /** * The [view props](#view.EditorProps) added by this plugin. Props * that are functions will be bound to have the plugin instance as @@ -33,14 +33,14 @@ export interface PluginSpec { * Allows a plugin to define a [state field](#state.StateField), an * extra slot in the state object in which it can keep its own data. */ - state?: StateField | null; + state?: StateField | null; /** * Can be used to make this a keyed plugin. You can have only one * plugin with a given key in a given state, but it is possible to * access the plugin's configuration and state through the key, * without having access to the plugin instance object. */ - key?: PluginKey | null; + key?: PluginKey | null; /** * When the plugin needs to interact with the editor view, or * set something up in the DOM, use this field. The function @@ -82,11 +82,11 @@ export interface PluginSpec { * They are part of the [editor state](#state.EditorState) and * may influence that state and the view that contains it. */ -export class Plugin { +export class Plugin { /** * Create a plugin. */ - constructor(spec: PluginSpec); + constructor(spec: PluginSpec); /** * The [props](#view.EditorProps) exported by this plugin. */ @@ -94,11 +94,11 @@ export class Plugin { /** * The plugin's [spec object](#state.PluginSpec). */ - spec: { [key: string]: any }; + spec: PluginSpec; /** * Extract the plugin's state field from an editor state. */ - getState(state: EditorState): any; + getState(state: EditorState): T; } /** * A plugin spec may provide a state field (under its @@ -106,7 +106,7 @@ export class Plugin { * describes the state it wants to keep. Functions provided here are * always called with the plugin instance as their `this` binding. */ -export interface StateField { +export interface StateField { /** * Initialize the value of the field. `config` will be the object * passed to [`EditorState.create`](#state.EditorState^create). Note @@ -138,7 +138,7 @@ export interface StateField { * editor state. Assigning a key does mean only one plugin of that * type can be active in a state. */ -export class PluginKey { +export class PluginKey { /** * Create a plugin key. */ @@ -147,7 +147,7 @@ export class PluginKey { * Get the active plugin with this key, if any, from an editor * state. */ - get(state: EditorState): Plugin | null | undefined; + get(state: EditorState): Plugin | null | undefined; /** * Get the plugin's state from an editor state. */ @@ -440,7 +440,7 @@ export class EditorState { /** * The plugins that are active in this state. */ - plugins: Array>; + plugins: Array>; /** * Apply the given transaction to produce a new state. */ @@ -465,13 +465,13 @@ export class EditorState { * [`init`](#state.StateField.init) method, passing in the new * configuration object.. */ - reconfigure(config: { schema?: S | null; plugins?: Array> | null }): EditorState; + reconfigure(config: { schema?: S | null; plugins?: Array> | null }): EditorState; /** * Serialize this state to JSON. If you want to serialize the state * of plugins, pass an object mapping property names to use in the * resulting JSON object to plugin objects. */ - toJSON(pluginFields?: { [name: string]: Plugin } | string | number): { [key: string]: any }; + toJSON(pluginFields?: { [name: string]: Plugin } | string | number): { [key: string]: any }; /** * Create a new state. */ @@ -480,7 +480,7 @@ export class EditorState { doc?: ProsemirrorNode | null; selection?: Selection | null; storedMarks?: Mark[] | null; - plugins?: Array> | null; + plugins?: Array> | null; }): EditorState; /** * Deserialize a JSON representation of a state. `config` should @@ -490,9 +490,9 @@ export class EditorState { * instances with the property names they use in the JSON object. */ static fromJSON( - config: { schema: S; plugins?: Array> | null }, + config: { schema: S; plugins?: Array> | null }, json: { [key: string]: any }, - pluginFields?: { [name: string]: Plugin } + pluginFields?: { [name: string]: Plugin } ): EditorState; } /** @@ -589,11 +589,11 @@ export class Transaction extends Transform { * Store a metadata property in this transaction, keyed either by * name or by plugin. */ - setMeta(key: string | Plugin | PluginKey, value: any): Transaction; + setMeta(key: string | Plugin | PluginKey, value: any): Transaction; /** * Retrieve a metadata property for a given name or plugin. */ - getMeta(key: string | Plugin | PluginKey): any; + getMeta(key: string | Plugin | PluginKey): any; /** * Returns true if this transaction doesn't contain any metadata, * and can thus safely be extended. diff --git a/types/prosemirror-view/index.d.ts b/types/prosemirror-view/index.d.ts index a539be4593..da83390c40 100644 --- a/types/prosemirror-view/index.d.ts +++ b/types/prosemirror-view/index.d.ts @@ -79,6 +79,7 @@ export class Decoration { pos: number, toDOM: ((view: EditorView, getPos: () => number) => Node) | Node, spec?: { + [key: string]: any; side?: number | null; marks?: Mark[] | null; stopEvent?: ((event: Event) => boolean) | null; From a51e3b694f83205d8ddbb9fd8a67191a1b83580b Mon Sep 17 00:00:00 2001 From: Dmitry Filatov Date: Fri, 22 Feb 2019 11:58:47 +0300 Subject: [PATCH 103/222] Add optimizeSvgEncode option --- types/postcss-url/index.d.ts | 7 +++++++ types/postcss-url/postcss-url-tests.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/postcss-url/index.d.ts b/types/postcss-url/index.d.ts index 361b69f1c7..472fccc21b 100644 --- a/types/postcss-url/index.d.ts +++ b/types/postcss-url/index.d.ts @@ -84,6 +84,13 @@ declare namespace url { */ ignoreFragmentWarning?: boolean; + /** + * Reduce size of inlined svg (IE9+, Android 3+) + * + * @default false + */ + optimizeSvgEncode?: boolean; + /** * Determine wether a file should be inlined. */ diff --git a/types/postcss-url/postcss-url-tests.ts b/types/postcss-url/postcss-url-tests.ts index a258b49be4..70086036ab 100644 --- a/types/postcss-url/postcss-url-tests.ts +++ b/types/postcss-url/postcss-url-tests.ts @@ -7,7 +7,7 @@ const single: postcss.Transformer = url({ url: 'copy', assetsPath: 'img', useHas const multiple: postcss.Transformer = url([ { filter: '**/assets/copy/*.png', url: 'copy', assetsPath: 'img', useHash: true }, - { filter: '**/assets/inline/*.svg', url: 'inline' }, + { filter: '**/assets/inline/*.svg', url: 'inline', optimizeSvgEncode: true }, { filter: '**/assets/**/*.gif', url: 'rebase' }, { filter: 'cdn/**/*', url: (asset) => `https://cdn.url/${asset.url}` }, ]); From 454beec14042e174de5179af0c54bfe28cc094f5 Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Fri, 22 Feb 2019 10:31:41 -0500 Subject: [PATCH 104/222] Update ioredis cluster types --- types/ioredis/index.d.ts | 282 +++++++++++++++++++++++++++------ types/ioredis/ioredis-tests.ts | 143 ++++++++++------- 2 files changed, 321 insertions(+), 104 deletions(-) diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index cbe5b0f8e2..7158e9fb31 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -24,13 +24,13 @@ import tls = require('tls'); interface RedisStatic { - new(port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; - new(host?: string, options?: IORedis.RedisOptions): IORedis.Redis; - new(options?: IORedis.RedisOptions): IORedis.Redis; + new (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + new (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + new (options?: IORedis.RedisOptions): IORedis.Redis; (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (options?: IORedis.RedisOptions): IORedis.Redis; - Cluster: IORedis.Cluster; + Cluster: IORedis.ClusterStatic; Command: IORedis.Command; } @@ -40,10 +40,13 @@ export = IORedis; declare class Commander { getBuiltinCommands(): string[]; createBuiltinCommand(commandName: string): {}; - defineCommand(name: string, definition: { - numberOfKeys?: number; - lua?: string; - }): any; + defineCommand( + name: string, + definition: { + numberOfKeys?: number; + lua?: string; + } + ): any; sendCommand(): void; } @@ -75,19 +78,57 @@ declare namespace IORedis { getBuffer(key: KeyType, callback: (err: Error, res: Buffer) => void): void; getBuffer(key: KeyType): Promise; - set(key: KeyType, value: any, expiryMode?: string | any[], time?: number | string, setMode?: number | string): Promise; + set( + key: KeyType, + value: any, + expiryMode?: string | any[], + time?: number | string, + setMode?: number | string + ): Promise; set(key: KeyType, value: any, callback: (err: Error, res: string) => void): void; set(key: KeyType, value: any, setMode: string | any[], callback: (err: Error, res: string) => void): void; - set(key: KeyType, value: any, expiryMode: string, time: number | string, callback: (err: Error, res: string) => void): void; - set(key: KeyType, value: any, expiryMode: string, time: number | string, setMode: number | string, callback: (err: Error, res: string) => void): void; + set( + key: KeyType, + value: any, + expiryMode: string, + time: number | string, + callback: (err: Error, res: string) => void + ): void; + set( + key: KeyType, + value: any, + expiryMode: string, + time: number | string, + setMode: number | string, + callback: (err: Error, res: string) => void + ): void; - setBuffer(key: KeyType, value: any, expiryMode?: string | any[], time?: number | string, setMode?: number | string): Promise; + setBuffer( + key: KeyType, + value: any, + expiryMode?: string | any[], + time?: number | string, + setMode?: number | string + ): Promise; setBuffer(key: KeyType, value: any, callback: (err: Error, res: Buffer) => void): void; setBuffer(key: KeyType, value: any, setMode: string, callback: (err: Error, res: Buffer) => void): void; - setBuffer(key: KeyType, value: any, expiryMode: string, time: number, callback: (err: Error, res: Buffer) => void): void; - setBuffer(key: KeyType, value: any, expiryMode: string, time: number | string, setMode: number | string, callback: (err: Error, res: Buffer) => void): void; + setBuffer( + key: KeyType, + value: any, + expiryMode: string, + time: number, + callback: (err: Error, res: Buffer) => void + ): void; + setBuffer( + key: KeyType, + value: any, + expiryMode: string, + time: number | string, + setMode: number | string, + callback: (err: Error, res: Buffer) => void + ): void; setnx(key: KeyType, value: any, callback: (err: Error, res: any) => void): void; setnx(key: KeyType, value: any): Promise; @@ -142,8 +183,14 @@ declare namespace IORedis { lpushx(key: KeyType, value: any, callback: (err: Error, res: number) => void): void; lpushx(key: KeyType, value: any): Promise; - linsert(key: KeyType, direction: "BEFORE" | "AFTER", pivot: string, value: any, callback: (err: Error, res: number) => void): void; - linsert(key: KeyType, direction: "BEFORE" | "AFTER", pivot: string, value: any): Promise; + linsert( + key: KeyType, + direction: 'BEFORE' | 'AFTER', + pivot: string, + value: any, + callback: (err: Error, res: number) => void + ): void; + linsert(key: KeyType, direction: 'BEFORE' | 'AFTER', pivot: string, value: any): Promise; rpop(key: KeyType, callback: (err: Error, res: string) => void): void; rpop(key: KeyType): Promise; @@ -155,7 +202,12 @@ declare namespace IORedis { blpop(...keys: KeyType[]): any; - brpoplpush(source: string, destination: string, timeout: number, callback: (err: Error, res: any) => void): void; + brpoplpush( + source: string, + destination: string, + timeout: number, + callback: (err: Error, res: any) => void + ): void; brpoplpush(source: string, destination: string, timeout: number): Promise; llen(key: KeyType, callback: (err: Error, res: number) => void): void; @@ -222,7 +274,12 @@ declare namespace IORedis { zrem(key: KeyType, ...members: any[]): any; - zremrangebyscore(key: KeyType, min: number | string, max: number | string, callback: (err: Error, res: any) => void): void; + zremrangebyscore( + key: KeyType, + min: number | string, + max: number | string, + callback: (err: Error, res: any) => void + ): void; zremrangebyscore(key: KeyType, min: number | string, max: number | string): Promise; zremrangebyrank(key: KeyType, start: number, stop: number, callback: (err: Error, res: any) => void): void; @@ -233,18 +290,35 @@ declare namespace IORedis { zinterstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): any; zrange(key: KeyType, start: number, stop: number, callback: (err: Error, res: any) => void): void; - zrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; - zrange(key: KeyType, start: number, stop: number, withScores?: "WITHSCORES"): Promise; + zrange( + key: KeyType, + start: number, + stop: number, + withScores: 'WITHSCORES', + callback: (err: Error, res: any) => void + ): void; + zrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; zrevrange(key: KeyType, start: number, stop: number, callback: (err: Error, res: any) => void): void; - zrevrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; - zrevrange(key: KeyType, start: number, stop: number, withScores?: "WITHSCORES"): Promise; + zrevrange( + key: KeyType, + start: number, + stop: number, + withScores: 'WITHSCORES', + callback: (err: Error, res: any) => void + ): void; + zrevrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; zrangebyscore(key: KeyType, min: number | string, max: number | string, ...args: string[]): any; zrevrangebyscore(key: KeyType, max: number | string, min: number | string, ...args: string[]): any; - zcount(key: KeyType, min: number | string, max: number | string, callback: (err: Error, res: number) => void): void; + zcount( + key: KeyType, + min: number | string, + max: number | string, + callback: (err: Error, res: number) => void + ): void; zcount(key: KeyType, min: number | string, max: number | string): Promise; zcard(key: KeyType, callback: (err: Error, res: number) => void): void; @@ -373,8 +447,8 @@ declare namespace IORedis { bgrewriteaof(callback: (err: Error, res: string) => void): void; bgrewriteaof(): Promise; - shutdown(save: "SAVE" | "NOSAVE", callback: (err: Error, res: any) => void): void; - shutdown(save: "SAVE" | "NOSAVE"): Promise; + shutdown(save: 'SAVE' | 'NOSAVE', callback: (err: Error, res: any) => void): void; + shutdown(save: 'SAVE' | 'NOSAVE'): Promise; lastsave(callback: (err: Error, res: number) => void): void; lastsave(): Promise; @@ -468,8 +542,20 @@ declare namespace IORedis { scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string): Promise<[string, string[]]>; scan(cursor: number, countOption: 'count' | 'COUNT', count: number): Promise<[string, string[]]>; - scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number): Promise<[string, string[]]>; - scan(cursor: number, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string): Promise<[string, string[]]>; + scan( + cursor: number, + matchOption: 'match' | 'MATCH', + pattern: string, + countOption: 'count' | 'COUNT', + count: number + ): Promise<[string, string[]]>; + scan( + cursor: number, + countOption: 'count' | 'COUNT', + count: number, + matchOption: 'match' | 'MATCH', + pattern: string + ): Promise<[string, string[]]>; sscan(key: KeyType, cursor: number, ...args: any[]): any; @@ -512,7 +598,7 @@ declare namespace IORedis { xread(...args: any[]): any; - xreadgroup(groupOption: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): any; + xreadgroup(groupOption: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): any; xrevrange(key: KeyType, end: string, start: string, ...args: any[]): any; @@ -535,13 +621,39 @@ declare namespace IORedis { set(key: KeyType, value: any, callback?: (err: Error, res: string) => void): Pipeline; set(key: KeyType, value: any, setMode: string, callback?: (err: Error, res: string) => void): Pipeline; - set(key: KeyType, value: any, expiryMode: string, time: number, callback?: (err: Error, res: string) => void): Pipeline; - set(key: KeyType, value: any, expiryMode: string, time: number, setMode: string, callback?: (err: Error, res: string) => void): Pipeline; + set( + key: KeyType, + value: any, + expiryMode: string, + time: number, + callback?: (err: Error, res: string) => void + ): Pipeline; + set( + key: KeyType, + value: any, + expiryMode: string, + time: number, + setMode: string, + callback?: (err: Error, res: string) => void + ): Pipeline; setBuffer(key: KeyType, value: any, callback?: (err: Error, res: Buffer) => void): Pipeline; setBuffer(key: KeyType, value: any, setMode: string, callback?: (err: Error, res: Buffer) => void): Pipeline; - setBuffer(key: KeyType, value: any, expiryMode: string, time: number, callback?: (err: Error, res: Buffer) => void): Pipeline; - setBuffer(key: KeyType, value: any, expiryMode: string, time: number, setMode: string, callback?: (err: Error, res: Buffer) => void): Pipeline; + setBuffer( + key: KeyType, + value: any, + expiryMode: string, + time: number, + callback?: (err: Error, res: Buffer) => void + ): Pipeline; + setBuffer( + key: KeyType, + value: any, + expiryMode: string, + time: number, + setMode: string, + callback?: (err: Error, res: Buffer) => void + ): Pipeline; setnx(key: KeyType, value: any, callback?: (err: Error, res: any) => void): Pipeline; @@ -581,7 +693,13 @@ declare namespace IORedis { lpushx(key: KeyType, value: any, callback?: (err: Error, res: number) => void): Pipeline; - linsert(key: KeyType, direction: "BEFORE" | "AFTER", pivot: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; + linsert( + key: KeyType, + direction: 'BEFORE' | 'AFTER', + pivot: string, + value: any, + callback?: (err: Error, res: number) => void + ): Pipeline; rpop(key: KeyType, callback?: (err: Error, res: string) => void): Pipeline; @@ -591,7 +709,12 @@ declare namespace IORedis { blpop(...keys: KeyType[]): Pipeline; - brpoplpush(source: string, destination: string, timeout: number, callback?: (err: Error, res: any) => void): Pipeline; + brpoplpush( + source: string, + destination: string, + timeout: number, + callback?: (err: Error, res: any) => void + ): Pipeline; llen(key: KeyType, callback?: (err: Error, res: number) => void): Pipeline; @@ -611,7 +734,12 @@ declare namespace IORedis { srem(key: KeyType, ...members: any[]): Pipeline; - smove(source: string, destination: string, member: string, callback?: (err: Error, res: string) => void): Pipeline; + smove( + source: string, + destination: string, + member: string, + callback?: (err: Error, res: string) => void + ): Pipeline; sismember(key: KeyType, member: string, callback?: (err: Error, res: 1 | 0) => void): Pipeline; @@ -643,7 +771,12 @@ declare namespace IORedis { zrem(key: KeyType, ...members: any[]): Pipeline; - zremrangebyscore(key: KeyType, min: number | string, max: number | string, callback?: (err: Error, res: any) => void): Pipeline; + zremrangebyscore( + key: KeyType, + min: number | string, + max: number | string, + callback?: (err: Error, res: any) => void + ): Pipeline; zremrangebyrank(key: KeyType, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; @@ -652,16 +785,33 @@ declare namespace IORedis { zinterstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): Pipeline; zrange(key: KeyType, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; - zrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; + zrange( + key: KeyType, + start: number, + stop: number, + withScores: 'WITHSCORES', + callback?: (err: Error, res: any) => void + ): Pipeline; zrevrange(key: KeyType, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; - zrevrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; + zrevrange( + key: KeyType, + start: number, + stop: number, + withScores: 'WITHSCORES', + callback?: (err: Error, res: any) => void + ): Pipeline; zrangebyscore(key: KeyType, min: number | string, max: number | string, ...args: string[]): Pipeline; zrevrangebyscore(key: KeyType, max: number | string, min: number | string, ...args: string[]): Pipeline; - zcount(key: KeyType, min: number | string, max: number | string, callback?: (err: Error, res: number) => void): Pipeline; + zcount( + key: KeyType, + min: number | string, + max: number | string, + callback?: (err: Error, res: number) => void + ): Pipeline; zcard(key: KeyType, callback?: (err: Error, res: number) => void): Pipeline; @@ -686,7 +836,12 @@ declare namespace IORedis { hincrby(key: KeyType, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; - hincrbyfloat(key: KeyType, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; + hincrbyfloat( + key: KeyType, + field: string, + increment: number, + callback?: (err: Error, res: number) => void + ): Pipeline; hdel(key: KeyType, ...fields: string[]): Pipeline; @@ -749,7 +904,7 @@ declare namespace IORedis { bgrewriteaof(callback?: (err: Error, res: string) => void): Pipeline; - shutdown(save: "SAVE" | "NOSAVE", callback?: (err: Error, res: any) => void): Pipeline; + shutdown(save: 'SAVE' | 'NOSAVE', callback?: (err: Error, res: any) => void): Pipeline; lastsave(callback?: (err: Error, res: number) => void): Pipeline; @@ -825,8 +980,20 @@ declare namespace IORedis { scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string): Pipeline; scan(cursor: number, countOption: 'count' | 'COUNT', count: number): Pipeline; - scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number): Pipeline; - scan(cursor: number, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string): Pipeline; + scan( + cursor: number, + matchOption: 'match' | 'MATCH', + pattern: string, + countOption: 'count' | 'COUNT', + count: number + ): Pipeline; + scan( + cursor: number, + countOption: 'count' | 'COUNT', + count: number, + matchOption: 'match' | 'MATCH', + pattern: string + ): Pipeline; sscan(key: KeyType, cursor: number, ...args: any[]): Pipeline; hscan(key: KeyType, cursor: number, ...args: any[]): Pipeline; @@ -843,7 +1010,14 @@ declare namespace IORedis { xadd(key: KeyType, id: string, ...args: string[]): Pipeline; - xclaim(key: KeyType, group: string, consumer: string, minIdleTime: number, id: string, ...args: any[]): Pipeline; + xclaim( + key: KeyType, + group: string, + consumer: string, + minIdleTime: number, + id: string, + ...args: any[] + ): Pipeline; xdel(key: KeyType, ...ids: string[]): Pipeline; @@ -859,7 +1033,7 @@ declare namespace IORedis { xread(...args: any[]): Pipeline; - xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): Pipeline; + xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): Pipeline; xrevrange(key: KeyType, end: string, start: string, ...args: any[]): Pipeline; @@ -873,11 +1047,14 @@ declare namespace IORedis { type ClusterNode = string | number | NodeConfiguration; - interface Cluster extends NodeJS.EventEmitter, Commander { - new(nodes: ClusterNode[], options?: ClusterOptions): Redis; + interface Cluster { connect(callback: () => void): Promise; disconnect(): void; - nodes(role: string): Redis[]; + nodes: Redis[]; + } + + interface ClusterStatic extends NodeJS.EventEmitter, Commander { + new (nodes: ClusterNode[], options?: ClusterOptions): Cluster; } interface RedisOptions { @@ -958,7 +1135,7 @@ declare namespace IORedis { autoResendUnfulfilledCommands?: boolean; lazyConnect?: boolean; tls?: tls.ConnectionOptions; - sentinels?: Array<{ host: string; port: number; }>; + sentinels?: Array<{ host: string; port: number }>; name?: string; /** * Enable READONLY mode for the connection. Only available for cluster mode. @@ -981,9 +1158,12 @@ declare namespace IORedis { count?: number; } - type DNSLookupFunction = (hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void) => void; + type DNSLookupFunction = ( + hostname: string, + callback: (err: NodeJS.ErrnoException, address: string, family: number) => void + ) => void; interface NatMap { - [key: string]: {host: string, port: number}; + [key: string]: { host: string; port: number }; } interface ClusterOptions { diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index fdb1fafcc1..0428fe3086 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -1,4 +1,4 @@ -import Redis = require("ioredis"); +import Redis = require('ioredis'); const redis = new Redis(); @@ -38,23 +38,25 @@ redis.set('key', '100', ['EX', 10, 'NX'], (err, data) => {}); redis.setBuffer('key', '100', 'NX', 'EX', 10, (err, data) => {}); redis.exists('foo').then(result => result * 1); -redis.exists('foo', ((err, data) => data * 1)); +redis.exists('foo', (err, data) => data * 1); // Should support usage of Buffer redis.set(Buffer.from('key'), '100'); redis.setBuffer(Buffer.from('key'), '100', 'NX', 'EX', 10); -new Redis(); // Connect to 127.0.0.1:6379 -new Redis(6380); // 127.0.0.1:6380 -new Redis(6379, '192.168.1.1'); // 192.168.1.1:6379 +new Redis(); // Connect to 127.0.0.1:6379 +new Redis(6380); // 127.0.0.1:6380 +new Redis(6379, '192.168.1.1'); // 192.168.1.1:6379 new Redis('/tmp/redis.sock'); new Redis({ - port: 6379, // Redis port - host: '127.0.0.1', // Redis host - family: 4, // 4 (IPv4) or 6 (IPv6) + port: 6379, // Redis port + host: '127.0.0.1', // Redis host + family: 4, // 4 (IPv4) or 6 (IPv6) password: 'auth', db: 0, - retryStrategy() { return false; }, + retryStrategy() { + return false; + }, maxRetriesPerRequest: 20, showFriendlyErrorStack: true, tls: { @@ -97,25 +99,35 @@ pipeline.exec((err, results) => { }); // You can even chain the commands: -redis.pipeline().set('foo', 'bar').del('cc').exec((err, results) => { -}); +redis + .pipeline() + .set('foo', 'bar') + .del('cc') + .exec((err, results) => {}); // `exec` also returns a Promise: -const promise = redis.pipeline().set('foo', 'bar').get('foo').exec(); -promise.then((result) => { +const promise = redis + .pipeline() + .set('foo', 'bar') + .get('foo') + .exec(); +promise.then(result => { // result === [[null, 'OK'], [null, 'bar']] }); -redis.pipeline().set('foo', 'bar').get('foo', (err, result) => { - // result === 'bar' -}).exec((err, result) => { - // result[1][1] === 'bar' -}); +redis + .pipeline() + .set('foo', 'bar') + .get('foo', (err, result) => { + // result === 'bar' + }) + .exec((err, result) => { + // result[1][1] === 'bar' + }); -redis.pipeline([ - ['set', 'foo', 'bar'], - ['get', 'foo'] -]).exec(() => { /* ... */ }); +redis.pipeline([['set', 'foo', 'bar'], ['get', 'foo']]).exec(() => { + /* ... */ +}); Redis.Command.setArgumentTransformer('set', args => { return args; @@ -126,28 +138,33 @@ Redis.Command.setReplyTransformer('get', (result: any) => { }); redis.scan(0, 'match', '*foo*', 'count', 20).then(([nextCursor, keys]) => { - // nextCursor is always a string - if (nextCursor === '0') { - // keys is always an array of strings and it might be empty - return keys.map(key => key.trim()); - } + // nextCursor is always a string + if (nextCursor === '0') { + // keys is always an array of strings and it might be empty + return keys.map(key => key.trim()); + } }); -redis.pipeline().scan(0, 'count', 20, 'match', '*foo*').exec((err, result) => { - // result = [[null, [nextCursor, keys]]] -}); +redis + .pipeline() + .scan(0, 'count', 20, 'match', '*foo*') + .exec((err, result) => { + // result = [[null, [nextCursor, keys]]] + }); // multi -redis.multi().set('foo', 'bar').set('foo', 'baz').get('foo', (err, result) => { - // result === 'QUEUED' -}).exec((err, results) => { - // results = [[null, 'OK'], [null, 'OK'], [null, 'baz']] -}); +redis + .multi() + .set('foo', 'bar') + .set('foo', 'baz') + .get('foo', (err, result) => { + // result === 'QUEUED' + }) + .exec((err, results) => { + // results = [[null, 'OK'], [null, 'OK'], [null, 'baz']] + }); -redis.multi([ - ['set', 'foo', 'bar'], - ['get', 'foo'] -]).exec((err, results) => { +redis.multi([['set', 'foo', 'bar'], ['get', 'foo']]).exec((err, results) => { // results = [[null, 'OK'], [null, 'bar']] }); @@ -157,26 +174,28 @@ redis.mget(...keys); redis.mset(...['foo', 'bar']); redis.mset({ foo: 'bar' }); +new Redis.Cluster(['localhost']); + +new Redis.Cluster([6379]); + new Redis.Cluster([ - 'localhost' + { + host: 'localhost' + } ]); new Redis.Cluster([ - 6379 + { + port: 6379 + } ]); -new Redis.Cluster([{ - host: 'localhost' -}]); - -new Redis.Cluster([{ - port: 6379 -}]); - -new Redis.Cluster([{ - host: 'localhost', - port: 6379 -}]); +new Redis.Cluster([ + { + host: 'localhost', + port: 6379 + } +]); redis.xack('streamName', 'groupName', 'id'); redis.xadd('streamName', '*', 'field', 'name'); @@ -207,3 +226,21 @@ new Redis.Cluster([], { new Redis.Cluster([], { clusterRetryStrategy: (times: number, reason?: Error) => 1 }); + +// Cluster types +const clusterOptions: Redis.ClusterOptions = {}; +const cluster = new Redis.Cluster( + [ + { + host: 'localhost', + port: 6379 + } + ], + clusterOptions +); +cluster.nodes.map(node => { + node.pipeline() + .flushdb() + .exec() + .then(result => console.log(result)); +}); From 7e4e9a35c4204324727153166518acad125a9c5f Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Fri, 22 Feb 2019 12:49:00 -0500 Subject: [PATCH 105/222] Updated IPatternOptions to include additional source parameter that was previously missed. --- types/fabric/fabric-impl.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 5a31e9c8c0..2babdfe7e2 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -632,6 +632,10 @@ interface IPatternOptions { * Transform matrix to change the pattern, imported from svgs */ patternTransform?: number[]; + /** + * The source for the pattern + */ + source?: string | HTMLImageElement; } export interface Pattern extends IPatternOptions { } export class Pattern { From 340001752c806750a3ec849803e5b5670554a8bc Mon Sep 17 00:00:00 2001 From: Glenn Gartner Date: Fri, 22 Feb 2019 13:24:16 -0500 Subject: [PATCH 106/222] add oCoords to IObjectOptions, to match fabricjs API --- types/fabric/fabric-impl.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 5cc59d0941..e309af96a4 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -2302,6 +2302,15 @@ interface IObjectOptions { * Describes the object's corner position in canvas object absolute properties. */ aCoords?: {bl: Point, br: Point, tl: Point, tr: Point}; + + /** + * Describe object's corner position in canvas element coordinates. properties are tl,mt,tr,ml,mr,bl,mb,br,mtr for + * the main controls. each property is an object with x, y and corner. The `corner` property contains in a similar + * manner the 4 points of the interactive area of the corner. The coordinates depends from this properties: width, + * height, scaleX, scaleY skewX, skewY, angle, strokeWidth, viewportTransform, top, left, padding. The coordinates + * get updated with @method setCoords. You can calculate them without updating with @method calcCoords; + */ + oCoords?: { tl: Point, mt: Point, tr: Point, ml: Point, mr: Point, bl: Point, mb: Point, br: Point, mtr: Point } } export interface Object extends IObservable, IObjectOptions, IObjectAnimation { } export class Object { From 3ab9bc21912b5ec820f339db25e2027117ee6fe3 Mon Sep 17 00:00:00 2001 From: Glenn Gartner Date: Fri, 22 Feb 2019 13:31:42 -0500 Subject: [PATCH 107/222] update README with new contributor name --- types/fabric/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index e8d31aef56..435a8eb6d2 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -7,6 +7,7 @@ // Brian Martinson // Rogerio Teixeira // Bradley Hill +// Glenn Gartner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 export import fabric = require("./fabric-impl"); From e51a8b3ed53f464d9f193fb0538738df0978e3b8 Mon Sep 17 00:00:00 2001 From: Joe Chrisman Date: Fri, 22 Feb 2019 10:43:51 -0800 Subject: [PATCH 108/222] added isotope method with no paramters (arrange) --- types/isotope-layout/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/isotope-layout/index.d.ts b/types/isotope-layout/index.d.ts index 5662da48f7..e10c0ea7c7 100644 --- a/types/isotope-layout/index.d.ts +++ b/types/isotope-layout/index.d.ts @@ -284,6 +284,10 @@ declare global { * Get the Isotope instance from a jQuery object. Isotope instances are useful to access Isotope properties. */ data(methodName: 'isotope'): Isotope; + /** + * Filters, sorts, and lays out items. + */ + isotope(): JQuery; /** * Lays out specified items. * @param elements Array of Isotope.Items From 63996d2cbd279d8d1c9ccaef966f628d7fe69e10 Mon Sep 17 00:00:00 2001 From: Joe Chrisman Date: Fri, 22 Feb 2019 10:49:24 -0800 Subject: [PATCH 109/222] added tests --- types/isotope-layout/isotope-layout-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/isotope-layout/isotope-layout-tests.ts b/types/isotope-layout/isotope-layout-tests.ts index d37475cefa..c39b8851db 100644 --- a/types/isotope-layout/isotope-layout-tests.ts +++ b/types/isotope-layout/isotope-layout-tests.ts @@ -81,6 +81,7 @@ $grid = $('.grid').isotope({ }); // test methods using jquery +$grid.isotope(); $grid.isotope('addItems', $('.items')); $grid.isotope('appended', $('.items')[0]); $grid.isotope('hideItemElements', [ new HTMLElement() ]); From 85a2bcb512af99c87ffdb90c4fd75330f6c67518 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Fri, 22 Feb 2019 14:16:16 -0500 Subject: [PATCH 110/222] Updated Image.fromURL to make the callback strongly typed --- 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 2babdfe7e2..22f9d6d514 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -2285,7 +2285,7 @@ export class Image { * @param [callback] Callback to invoke when image is created (newly created image is passed as a first argument) * @param [imgOptions] Options object */ - static fromURL(url: string, callback?: Function, imgOptions?: IImageOptions): Image; + static fromURL(url: string, callback?: (image: Image) => void, imgOptions?: IImageOptions): Image; /** * Returns Image instance from an SVG element * @param element Element to parse From 226f7e41edbcbf13d6f2c8cfaa11cbb4d085aae4 Mon Sep 17 00:00:00 2001 From: Bryan Krol Date: Fri, 22 Feb 2019 15:54:33 -0500 Subject: [PATCH 111/222] Changed IPatternOptions.source to not be an optional parameter --- 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 22f9d6d514..b2a4c0066d 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -635,7 +635,7 @@ interface IPatternOptions { /** * The source for the pattern */ - source?: string | HTMLImageElement; + source: string | HTMLImageElement; } export interface Pattern extends IPatternOptions { } export class Pattern { From 3f84eddc066376aeffae04c16a1777dc79bb7a0b Mon Sep 17 00:00:00 2001 From: Alex Jerabek Date: Fri, 22 Feb 2019 13:49:30 -0800 Subject: [PATCH 112/222] [office-js-preview] Updating Excel APIs --- types/office-js-preview/index.d.ts | 627 +++++++++++++++++++++++++++-- 1 file changed, 587 insertions(+), 40 deletions(-) diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index 42544390d9..00ba027c06 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -19307,6 +19307,47 @@ declare namespace Excel { */ type: "WorkbookAutoSaveSettingChanged"; } + /** + * + * Provide information about the detail of WorksheetChangedEvent/TableChangedEvent + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface ChangedEventDetail { + /** + * + * Represents the value after changed. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueAfter: any; + /** + * + * Represents the value before changed. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueBefore: any; + /** + * + * Represents the type of value after changed + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueTypeAfter: Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue"; + /** + * + * Represents the type of value before changed + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueTypeBefore: Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue"; + } /** * * Provides information about the worksheet that raised the Changed event. @@ -19328,6 +19369,13 @@ declare namespace Excel { * [Api set: ExcelApi 1.7] */ changeType: Excel.DataChangeType | "Unknown" | "RangeEdited" | "RowInserted" | "RowDeleted" | "ColumnInserted" | "ColumnDeleted" | "CellInserted" | "CellDeleted"; + /** + * + * Represents the information about the change detail + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + */ + details: Excel.ChangedEventDetail; /** * * Gets the source of the event. See Excel.EventSource for details. @@ -19468,6 +19516,13 @@ declare namespace Excel { * [Api set: ExcelApi 1.7] */ worksheetId: string; + /** + * + * Represents the information about the change detail + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + */ + details: Excel.ChangedEventDetail; /** * * Gets the range that represents the changed area of a table on a specific worksheet. @@ -21878,7 +21933,28 @@ declare namespace Excel { set(properties: Interfaces.RangeUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ set(properties: Excel.Range): void; + /** + * + * Fills range from the current range to the destination range. + The destination range must extend the source either horizontally or vertically. Discontiguous ranges are not supported. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param destinationRange The destination range to autofill. + * @param autoFillType The type of autofill. Specifies how the destination range is to be filled, based on the contents of the current range. Default is "FillDefault". + */ autoFill(destinationRange: Range | string, autoFillType?: Excel.AutoFillType): void; + /** + * + * Fills range from the current range to the destination range. + The destination range must extend the source either horizontally or vertically. Discontiguous ranges are not supported. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * + * @param destinationRange The destination range to autofill. + * @param autoFillType The type of autofill. Specifies how the destination range is to be filled, based on the contents of the current range. Default is "FillDefault". + */ autoFill(destinationRange: Range | string, autoFillType?: "FillDefault" | "FillCopy" | "FillSeries" | "FillFormats" | "FillValues" | "FillDays" | "FillWeekdays" | "FillMonths" | "FillYears" | "LinearTrend" | "GrowthTrend" | "FlashFill"): void; /** * @@ -21996,6 +22072,14 @@ declare namespace Excel { * @returns The Range which matched the search criteria. */ findOrNullObject(text: string, criteria: Excel.SearchCriteria): Excel.Range; + /** + * + * Does FlashFill to current range.Flash Fill will automatically fills data when it senses a pattern, so the range must be single column range and have data around in order to find pattern. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + flashFill(): void; /** * * Gets a Range object with the same top-left cell as the current Range object, but with the specified numbers of rows and columns. @@ -22205,7 +22289,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Gets the RangeAreas object, comprising one or more ranges, that represents all the cells that match the specified type and value. @@ -22228,7 +22312,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Gets the range object containing the anchor cell for a cell getting spilled into. Fails if applied to a range with more than one cell. Read only. @@ -22743,7 +22827,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Returns a RangeAreas object that represents all the cells that match the specified type and value. Returns a null object if no special cells are found that match the criteria. @@ -22765,7 +22849,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Returns a scoped collection of tables that overlap with any range in this RangeAreas object. @@ -35177,7 +35261,7 @@ declare namespace Excel { * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta * - * @param index Index value of the object to be retrieved. Zero-indexed. + * @param index Index value of the style object to be retrieved. Zero-indexed. */ getItemAt(index: number): Excel.Style; /** @@ -36414,12 +36498,8 @@ declare namespace Excel { * @beta * * @param geometricShapeType Represents the geometric type of the shape. See Excel.GeometricShapeType for details. - * @param left The distance, in points, from the left side of the shape to the left side of the worksheet. - * @param top The distance, in points, from the top edge of the shape to the top of the worksheet. - * @param width The width, in points, of the shape. - * @param height The height, in points, of the shape. */ - addGeometricShape(geometricShapeType: Excel.GeometricShapeType, left: number, top: number, width: number, height: number): Excel.Shape; + addGeometricShape(geometricShapeType: Excel.GeometricShapeType): Excel.Shape; /** * * Adds a geometric shape to worksheet. Returns a Shape object that represents the new shape. @@ -36428,12 +36508,8 @@ declare namespace Excel { * @beta * * @param geometricShapeType Represents the geometric type of the shape. See Excel.GeometricShapeType for details. - * @param left The distance, in points, from the left side of the shape to the left side of the worksheet. - * @param top The distance, in points, from the top edge of the shape to the top of the worksheet. - * @param width The width, in points, of the shape. - * @param height The height, in points, of the shape. */ - addGeometricShape(geometricShapeType: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus", left: number, top: number, width: number, height: number): Excel.Shape; + addGeometricShape(geometricShapeType: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus"): Excel.Shape; /** * * Group a subset of shapes in a worksheet. Returns a Shape object that represents the new group of shapes. @@ -36644,6 +36720,14 @@ declare namespace Excel { * @beta */ altTextTitle: string; + /** + * + * Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly connectionSiteCount: number; /** * * Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -37201,6 +37285,22 @@ declare namespace Excel { class Line extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; + /** + * + * Represents the shape object that the beginning of the specified line is attached to. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly beginConnectedShape: Excel.Shape; + /** + * + * Represents the shape object that the end of the specified line is attached to. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly endConnectedShape: Excel.Shape; /** * * Returns the shape object for the line. Read-only. @@ -37209,6 +37309,70 @@ declare namespace Excel { * @beta */ readonly shape: Excel.Shape; + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the beginning of a connector is connected to. Read-only. Returns null when the beginning of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly beginConnectedSite: number; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the end of a connector is connected to. Read-only. Returns null when the end of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly endConnectedSite: number; /** * * Represents the shape identifier. Read-only. @@ -37217,6 +37381,22 @@ declare namespace Excel { * @beta */ readonly id: string; + /** + * + * Represents whether the beginning of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly isBeginConnected: boolean; + /** + * + * Represents whether the end of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly isEndConnected: boolean; /** * * Represents the connector type for the line. @@ -37239,6 +37419,44 @@ declare namespace Excel { set(properties: Interfaces.LineUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ set(properties: Excel.Line): void; + /** + * + * Attaches the beginning of the specified connector to a specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param shape The shape to attach the beginning of the connector to. + * @param connectionSite The connection site on the shape which the beginning of the connector attach to. Must be an integer between 0 and the connection site count(not included) of the specified shape. + */ + beginConnect(shape: Excel.Shape, connectionSite: number): void; + /** + * + * Detaches the beginning of the specified connector from the shape it's attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginDisconnect(): void; + /** + * + * Attaches the end of the specified connector to a specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param shape The shape to attach the end of the connector to. + * @param connectionSite The connection site on the shape which the end of the connector attach to. Must be an integer between 0 and the connection site count(not included) of the specified shape. + */ + endConnect(shape: Excel.Shape, connectionSite: number): void; + /** + * + * Detaches the end of the specified connector from the shape it's attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endDisconnect(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -37468,6 +37686,13 @@ declare namespace Excel { class TextFrame extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; + /** + * + * Represents the text range in the text frame. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ readonly textRange: Excel.TextRange; /** * @@ -37874,7 +38099,7 @@ declare namespace Excel { nameInFormula: string; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -37890,7 +38115,7 @@ declare namespace Excel { style: string; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37938,7 +38163,7 @@ declare namespace Excel { delete(): void; /** * - * Returns an array of selected items' names. Read-only. + * Returns an array of selected items' keys. Read-only. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -37946,8 +38171,8 @@ declare namespace Excel { getSelectedItems(): OfficeExtension.ClientResult; /** * - * Select slicer items based on their names. Previous selection will be cleared. - All items will be deselected if the array is empty. + * Select slicer items based on their keys. Previous selection will be cleared. + All items will be selected by default if the array is empty. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -38089,7 +38314,9 @@ declare namespace Excel { readonly hasData: boolean; /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -38934,6 +39161,36 @@ declare namespace Excel { systemDot = "SystemDot", systemDashDot = "SystemDashDot" } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ArrowHeadLength { + short = "Short", + medium = "Medium", + long = "Long" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ArrowHeadStyle { + none = "None", + triangle = "Triangle", + stealth = "Stealth", + diamond = "Diamond", + oval = "Oval", + open = "Open" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ArrowHeadWidth { + narrow = "Narrow", + medium = "Medium", + wide = "Wide" + } /** * [Api set: ExcelApi 1.1] */ @@ -39846,7 +40103,13 @@ declare namespace Excel { * */ worksheetFormatChanged = "WorksheetFormatChanged", - wacoperationEvent = "WACOperationEvent" + wacoperationEvent = "WACOperationEvent", + /** + * + * RibbonCommandExecuted represents the type of event registered on ribbon, and occurs when user click on ribbon + * + */ + ribbonCommandExecuted = "RibbonCommandExecuted" } /** * [Api set: ExcelApi 1.7] @@ -40456,12 +40719,6 @@ declare namespace Excel { * */ blanks = "Blanks", - /** - * - * Cells containing comments. - * - */ - comments = "Comments", /** * * Cells containing constants. @@ -40755,6 +41012,24 @@ declare namespace Excel { ascending = "Ascending", descending = "Descending" } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum RibbonTab { + others = "Others", + home = "Home", + insert = "Insert", + draw = "Draw", + pageLayout = "PageLayout", + formulas = "Formulas", + data = "Data", + review = "Review", + view = "View", + developer = "Developer", + addIns = "AddIns", + help = "Help" + } /** * * An object containing the result of a function-evaluation operation @@ -48918,6 +49193,54 @@ declare namespace Excel { } /** An interface for updating data on the Line object, for use in "line.set({ ... })". */ interface LineUpdateData { + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; /** * * Represents the connector type for the line. @@ -49212,7 +49535,7 @@ declare namespace Excel { nameInFormula?: string; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -49228,7 +49551,7 @@ declare namespace Excel { style?: string; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -49253,7 +49576,9 @@ declare namespace Excel { interface SlicerItemUpdateData { /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -54636,6 +54961,14 @@ declare namespace Excel { * @beta */ altTextTitle?: string; + /** + * + * Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: number; /** * * Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -54808,6 +55141,70 @@ declare namespace Excel { } /** An interface describing the data returned by calling "line.toJSON()". */ interface LineData { + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the beginning of a connector is connected to. Read-only. Returns null when the beginning of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginConnectedSite?: number; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the end of a connector is connected to. Read-only. Returns null when the end of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endConnectedSite?: number; /** * * Represents the shape identifier. Read-only. @@ -54816,6 +55213,22 @@ declare namespace Excel { * @beta */ id?: string; + /** + * + * Represents whether the beginning of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isBeginConnected?: boolean; + /** + * + * Represents whether the end of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isEndConnected?: boolean; /** * * Represents the connector type for the line. @@ -55150,7 +55563,7 @@ declare namespace Excel { nameInFormula?: string; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -55166,7 +55579,7 @@ declare namespace Excel { style?: string; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -55199,7 +55612,9 @@ declare namespace Excel { hasData?: boolean; /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -63416,6 +63831,14 @@ declare namespace Excel { * @beta */ altTextTitle?: boolean; + /** + * + * For EACH ITEM in the collection: Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: boolean; /** * * For EACH ITEM in the collection: Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -63622,6 +64045,14 @@ declare namespace Excel { * @beta */ altTextTitle?: boolean; + /** + * + * Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: boolean; /** * * Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -63914,6 +64345,14 @@ declare namespace Excel { * @beta */ altTextTitle?: boolean; + /** + * + * For EACH ITEM in the collection: Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: boolean; /** * * For EACH ITEM in the collection: Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -64042,12 +64481,92 @@ declare namespace Excel { $all?: boolean; /** * + * Represents the shape object that the beginning of the specified line is attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginConnectedShape?: Excel.Interfaces.ShapeLoadOptions; + /** + * + * Represents the shape object that the end of the specified line is attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endConnectedShape?: Excel.Interfaces.ShapeLoadOptions; + /** + * * Returns the shape object for the line. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta */ shape?: Excel.Interfaces.ShapeLoadOptions; + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength?: boolean; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle?: boolean; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth?: boolean; + /** + * + * Represents an integer that specifies the connection site that the beginning of a connector is connected to. Read-only. Returns null when the beginning of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginConnectedSite?: boolean; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength?: boolean; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle?: boolean; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth?: boolean; + /** + * + * Represents an integer that specifies the connection site that the end of a connector is connected to. Read-only. Returns null when the end of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endConnectedSite?: boolean; /** * * Represents the shape identifier. Read-only. @@ -64056,6 +64575,22 @@ declare namespace Excel { * @beta */ id?: boolean; + /** + * + * Represents whether the beginning of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isBeginConnected?: boolean; + /** + * + * Represents whether the end of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isEndConnected?: boolean; /** * * Represents the connector type for the line. @@ -64166,6 +64701,13 @@ declare namespace Excel { */ interface TextFrameLoadOptions { $all?: boolean; + /** + * + * Represents the text range in the text frame. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ textRange?: Excel.Interfaces.TextRangeLoadOptions; /** * @@ -64422,7 +64964,7 @@ declare namespace Excel { nameInFormula?: boolean; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64438,7 +64980,7 @@ declare namespace Excel { style?: boolean; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -64532,7 +65074,7 @@ declare namespace Excel { nameInFormula?: boolean; /** * - * For EACH ITEM in the collection: Represents the sort order of the items in the slicer. + * For EACH ITEM in the collection: Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64548,7 +65090,7 @@ declare namespace Excel { style?: boolean; /** * - * For EACH ITEM in the collection: Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * For EACH ITEM in the collection: Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -64584,7 +65126,9 @@ declare namespace Excel { hasData?: boolean; /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64626,7 +65170,9 @@ declare namespace Excel { hasData?: boolean; /** * - * For EACH ITEM in the collection: True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * For EACH ITEM in the collection: True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64675,6 +65221,7 @@ declare namespace Excel { } } + //////////////////////////////////////////////////////////////// //////////////////////// End Excel APIs //////////////////////// //////////////////////////////////////////////////////////////// From 1c7e445c08338b8dc9a9558eb1a58c8418b05c99 Mon Sep 17 00:00:00 2001 From: Benjamin Giesinger Date: Fri, 22 Feb 2019 23:08:43 +0100 Subject: [PATCH 113/222] Updated vexflow to the latest version and added a lot of missing, old and incorrect stuff --- types/vexflow/index.d.ts | 74 +++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/types/vexflow/index.d.ts b/types/vexflow/index.d.ts index c25ac00958..5bd7e0a05f 100644 --- a/types/vexflow/index.d.ts +++ b/types/vexflow/index.d.ts @@ -4,6 +4,7 @@ // Sebastian Haas // Basti Hoffmann // Simon Schmid +// Benjamin Giesinger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped //inconsistent namespace: this is a helper funtion from tables.js and should not pollute the global namespace! @@ -54,8 +55,8 @@ declare namespace Vex { beginPath() : IRenderContext; moveTo(x : number, y : number) : IRenderContext; lineTo(x : number, y : number) : IRenderContext; - bezierCurveToTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : IRenderContext; - quadraticCurveToTo(x1 : number, y1 : number, x2 : number, y2 : number) : IRenderContext; + bezierCurveTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : IRenderContext; + quadraticCurveTo(x1 : number, y1 : number, x2 : number, y2 : number) : IRenderContext; arc(x : number, y : number, radius : number, startAngle : number, endAngle : number, antiClockwise : boolean) : IRenderContext; glow() : IRenderContext; fill() : IRenderContext; @@ -103,6 +104,7 @@ declare namespace Vex { const STAVE_LINE_THICKNESS : number; const TIME4_4 : {num_beats : number, beat_value : number, resolution : number}; const unicode : {[name : string] : string}; //inconsistent API: this should be private and have a wrapper function like the other tables + const DEFAULT_NOTATION_FONT_SCALE: number; function clefProperties(clef : string) : {line_shift : number}; function keyProperties(key : string, clef : string, params : {octave_shift? : number}) : {key : string, octave : number, line : number, int_value : number, accidental : string, code : number, stroke : number, shift_right : number, displaced : boolean}; function integerToNote(integer : number) : string; @@ -211,8 +213,9 @@ declare namespace Vex { drawRepeatBar(stave : Stave, x : number, begin : boolean) : void; } - class Beam { + class Beam { constructor(notes : StemmableNote[], auto_stem? : boolean); + setStyle(style : {shadowColor? : string, shadowBlur? : string, fillStyle? : string, strokeStyle? : string}) : Beam; setContext(context : IRenderContext) : Beam; getNotes() : StemmableNote[]; getBeamCount() : number; @@ -275,8 +278,8 @@ declare namespace Vex { beginPath() : CanvasContext; moveTo(x : number, y : number) : CanvasContext; lineTo(x : number, y : number) : CanvasContext; - bezierCurveToTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : CanvasContext; - quadraticCurveToTo(x1 : number, y1 : number, x2 : number, y2 : number) : CanvasContext; + bezierCurveTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : CanvasContext; + quadraticCurveTo(x1 : number, y1 : number, x2 : number, y2 : number) : CanvasContext; arc(x : number, y : number, radius : number, startAngle : number, endAngle : number, antiClockwise : boolean) : CanvasContext; glow() : CanvasContext; fill() : CanvasContext; @@ -438,8 +441,9 @@ declare namespace Vex { } class FretHandFinger extends Modifier { - constructor(number : number); + constructor(number : number|string); static format(nums : FretHandFinger[], state : {left_shift : number, right_shift : number, text_line : number}) : void; + finger: number|string; getNote() : Note; setNote(note : Note) : FretHandFinger; getIndex() : number; @@ -488,11 +492,16 @@ declare namespace Vex { class GraceNote extends StaveNote { constructor(note_struct : {slash? : boolean, type? : string, dots? : number, duration : string, clef? : string, keys : string[], octave_shift? : number, auto_stem? : boolean, stem_direction? : number}); + static LEDGER_LINE_OFFSET : number; getStemExtension() : number; getCategory() : string; draw() : void; } + namespace GraceNote { + const SCALE : number; + } + class GraceNoteGroup extends Modifier { //TODO remove the following lines once TypeScript allows subclass overrides with type changes or type inconsistencies mentioned below are fixed setWidth(width : number) : Modifier; @@ -621,7 +630,8 @@ declare namespace Vex { getTickMultiplier() : Fraction; applyTickMultiplier(numerator : number, denominator : number) : void; setDuration(duration : Fraction) : void; - + preFormatted : boolean; + constructor(note_struct : {type? : string, dots? : number, duration : string}); getPlayNote() : any; setPlayNote(note : any) : Note; @@ -757,8 +767,8 @@ declare namespace Vex { beginPath() : RaphaelContext; moveTo(x : number, y : number) : RaphaelContext; lineTo(x : number, y : number) : RaphaelContext; - bezierCurveToTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : RaphaelContext; - quadraticCurveToTo(x1 : number, y1 : number, x : number, y : number) : RaphaelContext; //inconsistent name: x, y -> x2, y2 + bezierCurveTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : RaphaelContext; + quadraticCurveTo(x1 : number, y1 : number, x : number, y : number) : RaphaelContext; //inconsistent name: x, y -> x2, y2 arc(x : number, y : number, radius : number, startAngle : number, endAngle : number, antiClockwise : boolean) : RaphaelContext; glow() : {width : number, fill : boolean, opacity : number, offsetx : number, offsety : number, color : string}; //inconsistent type : Object -> RaphaelContext fill() : RaphaelContext; @@ -805,6 +815,7 @@ declare namespace Vex { class Stave { constructor(x : number, y : number, width : number, options? : {vertical_bar_width? : number, glyph_spacing_px? : number, num_lines? : number, fill_style? : string, spacing_between_lines_px? : number, space_above_staff_ln? : number, space_below_staff_ln? : number, top_text_position? : number}); + options: {vertical_bar_width? : number, glyph_spacing_px? : number, num_lines? : number, fill_style? : string, left_bar? : boolean, right_bar? : boolean, spacing_between_lines_px? : number, space_above_staff_ln? : number, space_below_staff_ln? : number, top_text_position? : number}; resetLines() : void; setNoteStartX(x : number) : Stave; getNoteStartX() : number; @@ -827,7 +838,7 @@ declare namespace Vex { setRepetitionTypeRight(type : Repetition.type, y : number) : Stave; setVoltaType(type : Volta.type, number_t : number, y : number) : Stave; setSection(section : string, y : number) : Stave; - setTempo(tempo : {name? : string, duration : string, dots : number, bpm : number}, y : number) : Stave; + setTempo(tempo : {name? : string, duration : string, dots : boolean, bpm : number}, y : number) : Stave; setText(text : string, position : Modifier.Position, options? : {shift_x? : number, shift_y? : number, justification? : TextNote.Justification}) : Stave; getHeight() : number; getSpacingBetweenLines() : number; @@ -858,10 +869,15 @@ declare namespace Vex { getConfigForLines() : {visible : boolean}[]; setConfigForLine(line_number : number, line_config : {visible : boolean}) : Stave; setConfigForLines(lines_configuration : {visible : boolean}[]) : Stave; + getModifiers(position? : number, category? : string) : StaveModifier[]; } class StaveConnector { constructor(top_stave : Stave, bottom_stave : Stave); + top_stave : Stave; + bottom_stave : Stave; + thickness : number; + x_shift : number; setContext(ctx : IRenderContext) : StaveConnector; setType(type : StaveConnector.type) : StaveConnector; setText(text : string, text_options? : {shift_x? : number, shift_y? : number}) : StaveConnector; @@ -918,6 +934,9 @@ declare namespace Vex { addToStaveEnd(stave : Stave, firstGlyph : boolean) : StaveModifier; addModifier() : void; addEndModifier() : void; + getPosition() : number; + getWidth() : number; + getPadding(index: number) : number; } namespace StaveModifier { @@ -929,10 +948,13 @@ declare namespace Vex { //TODO remove the following lines once TypeScript allows subclass overrides with type changes and/or inconsistencies mentioned below are fixed buildStem() : StemmableNote; setStave(stave : Stave) : Note; - addModifier(modifier : Modifier, index? : number) : Note; + //TODO: vexflow actualy managed to have Note use modifier, index and stavenote index,modifier. To use the function in + // Typescript we need to allow both. The name is the correct type :( + addModifier(index : any, modifier? : any) : Note; getModifierStartXY() : {x : number, y : number}; getDots() : number; - + x_shift: number; + constructor(note_struct : {type? : string, dots? : number, duration : string, clef? : string, keys : string[], octave_shift? : number, auto_stem? : boolean, stem_direction? : number}); static DEBUG : boolean; static format(notes : StaveNote[] , state : {left_shift : number, right_shift : number, text_line : number}) : boolean; @@ -959,11 +981,11 @@ declare namespace Vex { getLineForRest() : number; getModifierStartXY(position : Modifier.Position, index : number) : {x : number, y : number}; setStyle(style : {shadowColor? : string, shadowBlur? : string, fillStyle? : string, strokeStyle? : string}) : void; // inconsistent type: void -> StaveNote + setStemStyle(style : {shadowColor? : string, shadowBlur? : string, fillStyle? : string, strokeStyle? : string}) : void; setKeyStyle(index : number, style : {shadowColor? : string, shadowBlur? : string, fillStyle? : string, strokeStyle? : string}) : StaveNote; setKeyLine(index : number, line : number) : StaveNote; getKeyLine(index : number) : number; addToModifierContext(mContext : ModifierContext) : StaveNote; - addModifier(index : number, modifier : Modifier) : StaveNote; addAccidental(index : number, accidental : Accidental) : StaveNote; addArticulation(index : number, articulation : Articulation) : StaveNote; addAnnotation(index : number, annotation : Annotation) : StaveNote; @@ -1084,6 +1106,9 @@ declare namespace Vex { constructor(note_struct : {type? : string, dots? : number, duration : string}); static DEBUG : boolean; + flag: Glyph; + getAttribute(attr : string); + setFlagStyle(style_struct : {shadowColor? : string, shadowBlur? : string, fillStyle? : string, strokeStyle? : string}) : void; getStem() : Stem; setStem(stem : Stem) : StemmableNote; buildStem() : StemmableNote; @@ -1108,8 +1133,11 @@ declare namespace Vex { //TODO remove the following lines once TypeScript allows subclass overrides with type changes setNote(note : Note) : StringNumber; - constructor(number : number); + // actually this is not really consistent in the vexflow code "ctx.measureText(this.string_number).width" looks + // like it is a string. But from the use of it it might be a number ?! + constructor(number : number|string); static format(nums : StringNumber[], state : {left_shift : number, right_shift : number, text_line : number}) : boolean; + string_number : number|string; getNote() : Note; setNote(note : StemmableNote) : StringNumber; getIndex() : number; @@ -1130,7 +1158,7 @@ declare namespace Vex { } class Stroke extends Modifier { - constructor(type : Stroke.Type, options : {all_voices? : boolean}); + constructor(type : Stroke.Type, options? : {all_voices? : boolean}); static format(strokes : Stroke[], state : {left_shift : number, right_shift : number, text_line : number}) : boolean; getPosition() : Modifier.Position; addEndNote(note : Note) : Stroke; @@ -1138,14 +1166,18 @@ declare namespace Vex { } namespace Stroke { - const enum Type {BRUSH_DOWN = 1, BRUSH_UP, ROLL_DOWN, ROLL_UP, RASQUEDO_DOWN, RASQUEDO_UP} + const enum Type {BRUSH_DOWN = 1, BRUSH_UP, ROLL_DOWN, ROLL_UP, RASQUEDO_DOWN, RASQUEDO_UP, ARPEGGIO_DIRECTIONLESS} const CATEGORY : string; } class SVGContext implements IRenderContext { constructor(element : HTMLElement); + svg: SVGElement; + state: any; + attributes: any; + lineWidth: number; iePolyfill() : boolean; - setFont(family : string, size : number, weight? : number) : SVGContext; + setFont(family : string, size : number, weight? : number|string) : SVGContext; setRawFont(font : string) : SVGContext; setFillStyle(style : string) : SVGContext; setBackgroundFillStyle(style : string) : SVGContext; @@ -1165,8 +1197,8 @@ declare namespace Vex { beginPath() : SVGContext; moveTo(x : number, y : number) : SVGContext; lineTo(x : number, y : number) : SVGContext; - bezierCurveToTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : SVGContext; - quadraticCurveToTo(x1 : number, y1 : number, x : number, y : number) : SVGContext; //inconsistent: x, y -> x2, y2 + bezierCurveTo(x1 : number, y1 : number, x2 : number, y2 : number, x : number, y : number) : SVGContext; + quadraticCurveTo(x1 : number, y1 : number, x : number, y : number) : SVGContext; //inconsistent: x, y -> x2, y2 arc(x : number, y : number, radius : number, startAngle : number, endAngle : number, antiClockwise : boolean) : SVGContext; closePath() : SVGContext; glow() : SVGContext; @@ -1236,6 +1268,8 @@ declare namespace Vex { class TextBracket { constructor(bracket_data : {start : Note, stop : Note, text? : string, superscript? : string, position? : TextBracket.Positions}); static DEBUG : boolean; + start : Note; + stop : Note; applyStyle(context : IRenderContext) : TextBracket; setDashed(dashed : boolean, dash? : number[]) : TextBracket; setFont(font : {family : string, size : number, weight : string}) : TextBracket; @@ -1372,7 +1406,7 @@ declare namespace Vex { } class Tuplet { - constructor(notes : StaveNote[], options? : {num_notes? : number, beats_occupied? : number}); + constructor(notes : StaveNote[], options? : {location? : number, bracketed? : boolean, ratioed : boolean, num_notes? : number, notes_occupied? : number, y_offset? : number}); attach() : void; detach() : void; setContext(context : IRenderContext) : Tuplet; From 1ad76db859dc29ae7b3a9a8dc4506f62e12e87d7 Mon Sep 17 00:00:00 2001 From: Benjamin Giesinger Date: Fri, 22 Feb 2019 23:17:48 +0100 Subject: [PATCH 114/222] Updated to latest version number --- types/vexflow/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/vexflow/index.d.ts b/types/vexflow/index.d.ts index 5bd7e0a05f..784760b186 100644 --- a/types/vexflow/index.d.ts +++ b/types/vexflow/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for VexFlow v1.2.85 +// Type definitions for VexFlow v1.2.88 // Project: http://vexflow.com // Definitions by: Roman Quiring // Sebastian Haas @@ -1107,7 +1107,7 @@ declare namespace Vex { constructor(note_struct : {type? : string, dots? : number, duration : string}); static DEBUG : boolean; flag: Glyph; - getAttribute(attr : string); + getAttribute(attr : string) : any; setFlagStyle(style_struct : {shadowColor? : string, shadowBlur? : string, fillStyle? : string, strokeStyle? : string}) : void; getStem() : Stem; setStem(stem : Stem) : StemmableNote; From 9143994ad5f349e08e2ed533c703912c58dea8ea Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Fri, 22 Feb 2019 22:21:16 +0000 Subject: [PATCH 115/222] Add events for discord-rpc --- types/discord-rpc/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/discord-rpc/index.d.ts b/types/discord-rpc/index.d.ts index 2d63e363b7..dbb6beeb39 100644 --- a/types/discord-rpc/index.d.ts +++ b/types/discord-rpc/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for discord-rpc 3.0 // Project: https://github.com/discordjs/RPC#readme // Definitions by: Jason Bothell +// Jack Baron // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { EventEmitter } from 'events'; @@ -66,6 +67,10 @@ export class Client extends EventEmitter { subscribe(event: string, args: any, callback: (data: any) => void): Promise; destroy(): Promise; + + on(event: 'ready' | 'connected', listener: () => void): this; + once(event: 'ready' | 'connected', listener: () => void): this; + off(event: 'ready' | 'connected', listener: () => void): this; } export interface RPCClientOptions { From 7c691f029e39aa1ff1d4c624ca01cb536c353e47 Mon Sep 17 00:00:00 2001 From: Alex Jerabek Date: Fri, 22 Feb 2019 16:17:30 -0800 Subject: [PATCH 116/222] Remove space --- types/office-js-preview/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index 00ba027c06..a7079ea56f 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -22074,7 +22074,7 @@ declare namespace Excel { findOrNullObject(text: string, criteria: Excel.SearchCriteria): Excel.Range; /** * - * Does FlashFill to current range.Flash Fill will automatically fills data when it senses a pattern, so the range must be single column range and have data around in order to find pattern. + * Does FlashFill to current range. Flash Fill will automatically fills data when it senses a pattern, so the range must be single column range and have data around in order to find pattern. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta From 1ab5816356530184e9a7937989b1c34cec5b5e8f Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Fri, 22 Feb 2019 20:01:24 -0500 Subject: [PATCH 117/222] :art: Remove excess format changes --- types/ioredis/index.d.ts | 271 ++++++--------------------------- types/ioredis/ioredis-tests.ts | 125 +++++++-------- 2 files changed, 100 insertions(+), 296 deletions(-) diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index 7158e9fb31..b36cf485cf 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -24,9 +24,9 @@ import tls = require('tls'); interface RedisStatic { - new (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; - new (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; - new (options?: IORedis.RedisOptions): IORedis.Redis; + new(port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + new(host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + new(options?: IORedis.RedisOptions): IORedis.Redis; (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (options?: IORedis.RedisOptions): IORedis.Redis; @@ -40,13 +40,10 @@ export = IORedis; declare class Commander { getBuiltinCommands(): string[]; createBuiltinCommand(commandName: string): {}; - defineCommand( - name: string, - definition: { - numberOfKeys?: number; - lua?: string; - } - ): any; + defineCommand(name: string, definition: { + numberOfKeys?: number; + lua?: string; + }): any; sendCommand(): void; } @@ -78,57 +75,19 @@ declare namespace IORedis { getBuffer(key: KeyType, callback: (err: Error, res: Buffer) => void): void; getBuffer(key: KeyType): Promise; - set( - key: KeyType, - value: any, - expiryMode?: string | any[], - time?: number | string, - setMode?: number | string - ): Promise; + set(key: KeyType, value: any, expiryMode?: string | any[], time?: number | string, setMode?: number | string): Promise; set(key: KeyType, value: any, callback: (err: Error, res: string) => void): void; set(key: KeyType, value: any, setMode: string | any[], callback: (err: Error, res: string) => void): void; - set( - key: KeyType, - value: any, - expiryMode: string, - time: number | string, - callback: (err: Error, res: string) => void - ): void; - set( - key: KeyType, - value: any, - expiryMode: string, - time: number | string, - setMode: number | string, - callback: (err: Error, res: string) => void - ): void; + set(key: KeyType, value: any, expiryMode: string, time: number | string, callback: (err: Error, res: string) => void): void; + set(key: KeyType, value: any, expiryMode: string, time: number | string, setMode: number | string, callback: (err: Error, res: string) => void): void; - setBuffer( - key: KeyType, - value: any, - expiryMode?: string | any[], - time?: number | string, - setMode?: number | string - ): Promise; + setBuffer(key: KeyType, value: any, expiryMode?: string | any[], time?: number | string, setMode?: number | string): Promise; setBuffer(key: KeyType, value: any, callback: (err: Error, res: Buffer) => void): void; setBuffer(key: KeyType, value: any, setMode: string, callback: (err: Error, res: Buffer) => void): void; - setBuffer( - key: KeyType, - value: any, - expiryMode: string, - time: number, - callback: (err: Error, res: Buffer) => void - ): void; - setBuffer( - key: KeyType, - value: any, - expiryMode: string, - time: number | string, - setMode: number | string, - callback: (err: Error, res: Buffer) => void - ): void; + setBuffer(key: KeyType, value: any, expiryMode: string, time: number, callback: (err: Error, res: Buffer) => void): void; + setBuffer(key: KeyType, value: any, expiryMode: string, time: number | string, setMode: number | string, callback: (err: Error, res: Buffer) => void): void; setnx(key: KeyType, value: any, callback: (err: Error, res: any) => void): void; setnx(key: KeyType, value: any): Promise; @@ -183,14 +142,8 @@ declare namespace IORedis { lpushx(key: KeyType, value: any, callback: (err: Error, res: number) => void): void; lpushx(key: KeyType, value: any): Promise; - linsert( - key: KeyType, - direction: 'BEFORE' | 'AFTER', - pivot: string, - value: any, - callback: (err: Error, res: number) => void - ): void; - linsert(key: KeyType, direction: 'BEFORE' | 'AFTER', pivot: string, value: any): Promise; + linsert(key: KeyType, direction: "BEFORE" | "AFTER", pivot: string, value: any, callback: (err: Error, res: number) => void): void; + linsert(key: KeyType, direction: "BEFORE" | "AFTER", pivot: string, value: any): Promise; rpop(key: KeyType, callback: (err: Error, res: string) => void): void; rpop(key: KeyType): Promise; @@ -202,12 +155,7 @@ declare namespace IORedis { blpop(...keys: KeyType[]): any; - brpoplpush( - source: string, - destination: string, - timeout: number, - callback: (err: Error, res: any) => void - ): void; + brpoplpush(source: string, destination: string, timeout: number, callback: (err: Error, res: any) => void): void; brpoplpush(source: string, destination: string, timeout: number): Promise; llen(key: KeyType, callback: (err: Error, res: number) => void): void; @@ -274,12 +222,7 @@ declare namespace IORedis { zrem(key: KeyType, ...members: any[]): any; - zremrangebyscore( - key: KeyType, - min: number | string, - max: number | string, - callback: (err: Error, res: any) => void - ): void; + zremrangebyscore(key: KeyType, min: number | string, max: number | string, callback: (err: Error, res: any) => void): void; zremrangebyscore(key: KeyType, min: number | string, max: number | string): Promise; zremrangebyrank(key: KeyType, start: number, stop: number, callback: (err: Error, res: any) => void): void; @@ -290,35 +233,18 @@ declare namespace IORedis { zinterstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): any; zrange(key: KeyType, start: number, stop: number, callback: (err: Error, res: any) => void): void; - zrange( - key: KeyType, - start: number, - stop: number, - withScores: 'WITHSCORES', - callback: (err: Error, res: any) => void - ): void; - zrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; + zrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; + zrange(key: KeyType, start: number, stop: number, withScores?: "WITHSCORES"): Promise; zrevrange(key: KeyType, start: number, stop: number, callback: (err: Error, res: any) => void): void; - zrevrange( - key: KeyType, - start: number, - stop: number, - withScores: 'WITHSCORES', - callback: (err: Error, res: any) => void - ): void; - zrevrange(key: KeyType, start: number, stop: number, withScores?: 'WITHSCORES'): Promise; + zrevrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; + zrevrange(key: KeyType, start: number, stop: number, withScores?: "WITHSCORES"): Promise; zrangebyscore(key: KeyType, min: number | string, max: number | string, ...args: string[]): any; zrevrangebyscore(key: KeyType, max: number | string, min: number | string, ...args: string[]): any; - zcount( - key: KeyType, - min: number | string, - max: number | string, - callback: (err: Error, res: number) => void - ): void; + zcount(key: KeyType, min: number | string, max: number | string, callback: (err: Error, res: number) => void): void; zcount(key: KeyType, min: number | string, max: number | string): Promise; zcard(key: KeyType, callback: (err: Error, res: number) => void): void; @@ -447,8 +373,8 @@ declare namespace IORedis { bgrewriteaof(callback: (err: Error, res: string) => void): void; bgrewriteaof(): Promise; - shutdown(save: 'SAVE' | 'NOSAVE', callback: (err: Error, res: any) => void): void; - shutdown(save: 'SAVE' | 'NOSAVE'): Promise; + shutdown(save: "SAVE" | "NOSAVE", callback: (err: Error, res: any) => void): void; + shutdown(save: "SAVE" | "NOSAVE"): Promise; lastsave(callback: (err: Error, res: number) => void): void; lastsave(): Promise; @@ -542,20 +468,8 @@ declare namespace IORedis { scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string): Promise<[string, string[]]>; scan(cursor: number, countOption: 'count' | 'COUNT', count: number): Promise<[string, string[]]>; - scan( - cursor: number, - matchOption: 'match' | 'MATCH', - pattern: string, - countOption: 'count' | 'COUNT', - count: number - ): Promise<[string, string[]]>; - scan( - cursor: number, - countOption: 'count' | 'COUNT', - count: number, - matchOption: 'match' | 'MATCH', - pattern: string - ): Promise<[string, string[]]>; + scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number): Promise<[string, string[]]>; + scan(cursor: number, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string): Promise<[string, string[]]>; sscan(key: KeyType, cursor: number, ...args: any[]): any; @@ -598,7 +512,7 @@ declare namespace IORedis { xread(...args: any[]): any; - xreadgroup(groupOption: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): any; + xreadgroup(groupOption: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): any; xrevrange(key: KeyType, end: string, start: string, ...args: any[]): any; @@ -621,39 +535,13 @@ declare namespace IORedis { set(key: KeyType, value: any, callback?: (err: Error, res: string) => void): Pipeline; set(key: KeyType, value: any, setMode: string, callback?: (err: Error, res: string) => void): Pipeline; - set( - key: KeyType, - value: any, - expiryMode: string, - time: number, - callback?: (err: Error, res: string) => void - ): Pipeline; - set( - key: KeyType, - value: any, - expiryMode: string, - time: number, - setMode: string, - callback?: (err: Error, res: string) => void - ): Pipeline; + set(key: KeyType, value: any, expiryMode: string, time: number, callback?: (err: Error, res: string) => void): Pipeline; + set(key: KeyType, value: any, expiryMode: string, time: number, setMode: string, callback?: (err: Error, res: string) => void): Pipeline; setBuffer(key: KeyType, value: any, callback?: (err: Error, res: Buffer) => void): Pipeline; setBuffer(key: KeyType, value: any, setMode: string, callback?: (err: Error, res: Buffer) => void): Pipeline; - setBuffer( - key: KeyType, - value: any, - expiryMode: string, - time: number, - callback?: (err: Error, res: Buffer) => void - ): Pipeline; - setBuffer( - key: KeyType, - value: any, - expiryMode: string, - time: number, - setMode: string, - callback?: (err: Error, res: Buffer) => void - ): Pipeline; + setBuffer(key: KeyType, value: any, expiryMode: string, time: number, callback?: (err: Error, res: Buffer) => void): Pipeline; + setBuffer(key: KeyType, value: any, expiryMode: string, time: number, setMode: string, callback?: (err: Error, res: Buffer) => void): Pipeline; setnx(key: KeyType, value: any, callback?: (err: Error, res: any) => void): Pipeline; @@ -693,13 +581,7 @@ declare namespace IORedis { lpushx(key: KeyType, value: any, callback?: (err: Error, res: number) => void): Pipeline; - linsert( - key: KeyType, - direction: 'BEFORE' | 'AFTER', - pivot: string, - value: any, - callback?: (err: Error, res: number) => void - ): Pipeline; + linsert(key: KeyType, direction: "BEFORE" | "AFTER", pivot: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; rpop(key: KeyType, callback?: (err: Error, res: string) => void): Pipeline; @@ -709,12 +591,7 @@ declare namespace IORedis { blpop(...keys: KeyType[]): Pipeline; - brpoplpush( - source: string, - destination: string, - timeout: number, - callback?: (err: Error, res: any) => void - ): Pipeline; + brpoplpush(source: string, destination: string, timeout: number, callback?: (err: Error, res: any) => void): Pipeline; llen(key: KeyType, callback?: (err: Error, res: number) => void): Pipeline; @@ -734,12 +611,7 @@ declare namespace IORedis { srem(key: KeyType, ...members: any[]): Pipeline; - smove( - source: string, - destination: string, - member: string, - callback?: (err: Error, res: string) => void - ): Pipeline; + smove(source: string, destination: string, member: string, callback?: (err: Error, res: string) => void): Pipeline; sismember(key: KeyType, member: string, callback?: (err: Error, res: 1 | 0) => void): Pipeline; @@ -771,12 +643,7 @@ declare namespace IORedis { zrem(key: KeyType, ...members: any[]): Pipeline; - zremrangebyscore( - key: KeyType, - min: number | string, - max: number | string, - callback?: (err: Error, res: any) => void - ): Pipeline; + zremrangebyscore(key: KeyType, min: number | string, max: number | string, callback?: (err: Error, res: any) => void): Pipeline; zremrangebyrank(key: KeyType, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; @@ -785,33 +652,16 @@ declare namespace IORedis { zinterstore(destination: string, numkeys: number, key: KeyType, ...args: string[]): Pipeline; zrange(key: KeyType, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; - zrange( - key: KeyType, - start: number, - stop: number, - withScores: 'WITHSCORES', - callback?: (err: Error, res: any) => void - ): Pipeline; + zrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; zrevrange(key: KeyType, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; - zrevrange( - key: KeyType, - start: number, - stop: number, - withScores: 'WITHSCORES', - callback?: (err: Error, res: any) => void - ): Pipeline; + zrevrange(key: KeyType, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; zrangebyscore(key: KeyType, min: number | string, max: number | string, ...args: string[]): Pipeline; zrevrangebyscore(key: KeyType, max: number | string, min: number | string, ...args: string[]): Pipeline; - zcount( - key: KeyType, - min: number | string, - max: number | string, - callback?: (err: Error, res: number) => void - ): Pipeline; + zcount(key: KeyType, min: number | string, max: number | string, callback?: (err: Error, res: number) => void): Pipeline; zcard(key: KeyType, callback?: (err: Error, res: number) => void): Pipeline; @@ -836,12 +686,7 @@ declare namespace IORedis { hincrby(key: KeyType, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; - hincrbyfloat( - key: KeyType, - field: string, - increment: number, - callback?: (err: Error, res: number) => void - ): Pipeline; + hincrbyfloat(key: KeyType, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; hdel(key: KeyType, ...fields: string[]): Pipeline; @@ -904,7 +749,7 @@ declare namespace IORedis { bgrewriteaof(callback?: (err: Error, res: string) => void): Pipeline; - shutdown(save: 'SAVE' | 'NOSAVE', callback?: (err: Error, res: any) => void): Pipeline; + shutdown(save: "SAVE" | "NOSAVE", callback?: (err: Error, res: any) => void): Pipeline; lastsave(callback?: (err: Error, res: number) => void): Pipeline; @@ -980,20 +825,8 @@ declare namespace IORedis { scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string): Pipeline; scan(cursor: number, countOption: 'count' | 'COUNT', count: number): Pipeline; - scan( - cursor: number, - matchOption: 'match' | 'MATCH', - pattern: string, - countOption: 'count' | 'COUNT', - count: number - ): Pipeline; - scan( - cursor: number, - countOption: 'count' | 'COUNT', - count: number, - matchOption: 'match' | 'MATCH', - pattern: string - ): Pipeline; + scan(cursor: number, matchOption: 'match' | 'MATCH', pattern: string, countOption: 'count' | 'COUNT', count: number): Pipeline; + scan(cursor: number, countOption: 'count' | 'COUNT', count: number, matchOption: 'match' | 'MATCH', pattern: string): Pipeline; sscan(key: KeyType, cursor: number, ...args: any[]): Pipeline; hscan(key: KeyType, cursor: number, ...args: any[]): Pipeline; @@ -1010,14 +843,7 @@ declare namespace IORedis { xadd(key: KeyType, id: string, ...args: string[]): Pipeline; - xclaim( - key: KeyType, - group: string, - consumer: string, - minIdleTime: number, - id: string, - ...args: any[] - ): Pipeline; + xclaim(key: KeyType, group: string, consumer: string, minIdleTime: number, id: string, ...args: any[]): Pipeline; xdel(key: KeyType, ...ids: string[]): Pipeline; @@ -1033,7 +859,7 @@ declare namespace IORedis { xread(...args: any[]): Pipeline; - xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): Pipeline; + xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): Pipeline; xrevrange(key: KeyType, end: string, start: string, ...args: any[]): Pipeline; @@ -1135,7 +961,7 @@ declare namespace IORedis { autoResendUnfulfilledCommands?: boolean; lazyConnect?: boolean; tls?: tls.ConnectionOptions; - sentinels?: Array<{ host: string; port: number }>; + sentinels?: Array<{ host: string; port: number; }>; name?: string; /** * Enable READONLY mode for the connection. Only available for cluster mode. @@ -1158,12 +984,9 @@ declare namespace IORedis { count?: number; } - type DNSLookupFunction = ( - hostname: string, - callback: (err: NodeJS.ErrnoException, address: string, family: number) => void - ) => void; + type DNSLookupFunction = (hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void) => void; interface NatMap { - [key: string]: { host: string; port: number }; + [key: string]: {host: string, port: number}; } interface ClusterOptions { diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index 0428fe3086..284084cf93 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -1,4 +1,4 @@ -import Redis = require('ioredis'); +import Redis = require("ioredis"); const redis = new Redis(); @@ -38,25 +38,23 @@ redis.set('key', '100', ['EX', 10, 'NX'], (err, data) => {}); redis.setBuffer('key', '100', 'NX', 'EX', 10, (err, data) => {}); redis.exists('foo').then(result => result * 1); -redis.exists('foo', (err, data) => data * 1); +redis.exists('foo', ((err, data) => data * 1)); // Should support usage of Buffer redis.set(Buffer.from('key'), '100'); redis.setBuffer(Buffer.from('key'), '100', 'NX', 'EX', 10); -new Redis(); // Connect to 127.0.0.1:6379 -new Redis(6380); // 127.0.0.1:6380 -new Redis(6379, '192.168.1.1'); // 192.168.1.1:6379 +new Redis(); // Connect to 127.0.0.1:6379 +new Redis(6380); // 127.0.0.1:6380 +new Redis(6379, '192.168.1.1'); // 192.168.1.1:6379 new Redis('/tmp/redis.sock'); new Redis({ - port: 6379, // Redis port - host: '127.0.0.1', // Redis host - family: 4, // 4 (IPv4) or 6 (IPv6) + port: 6379, // Redis port + host: '127.0.0.1', // Redis host + family: 4, // 4 (IPv4) or 6 (IPv6) password: 'auth', db: 0, - retryStrategy() { - return false; - }, + retryStrategy() { return false; }, maxRetriesPerRequest: 20, showFriendlyErrorStack: true, tls: { @@ -99,36 +97,26 @@ pipeline.exec((err, results) => { }); // You can even chain the commands: -redis - .pipeline() - .set('foo', 'bar') - .del('cc') - .exec((err, results) => {}); +redis.pipeline().set('foo', 'bar').del('cc').exec((err, results) => { +}); // `exec` also returns a Promise: -const promise = redis - .pipeline() - .set('foo', 'bar') - .get('foo') - .exec(); -promise.then(result => { +const promise = redis.pipeline().set('foo', 'bar').get('foo').exec(); +promise.then((result) => { // result === [[null, 'OK'], [null, 'bar']] }); -redis - .pipeline() - .set('foo', 'bar') - .get('foo', (err, result) => { - // result === 'bar' - }) - .exec((err, result) => { - // result[1][1] === 'bar' - }); - -redis.pipeline([['set', 'foo', 'bar'], ['get', 'foo']]).exec(() => { - /* ... */ +redis.pipeline().set('foo', 'bar').get('foo', (err, result) => { + // result === 'bar' +}).exec((err, result) => { + // result[1][1] === 'bar' }); +redis.pipeline([ + ['set', 'foo', 'bar'], + ['get', 'foo'] +]).exec(() => { /* ... */ }); + Redis.Command.setArgumentTransformer('set', args => { return args; }); @@ -138,33 +126,28 @@ Redis.Command.setReplyTransformer('get', (result: any) => { }); redis.scan(0, 'match', '*foo*', 'count', 20).then(([nextCursor, keys]) => { - // nextCursor is always a string - if (nextCursor === '0') { - // keys is always an array of strings and it might be empty - return keys.map(key => key.trim()); - } + // nextCursor is always a string + if (nextCursor === '0') { + // keys is always an array of strings and it might be empty + return keys.map(key => key.trim()); + } }); -redis - .pipeline() - .scan(0, 'count', 20, 'match', '*foo*') - .exec((err, result) => { - // result = [[null, [nextCursor, keys]]] - }); +redis.pipeline().scan(0, 'count', 20, 'match', '*foo*').exec((err, result) => { + // result = [[null, [nextCursor, keys]]] +}); // multi -redis - .multi() - .set('foo', 'bar') - .set('foo', 'baz') - .get('foo', (err, result) => { - // result === 'QUEUED' - }) - .exec((err, results) => { - // results = [[null, 'OK'], [null, 'OK'], [null, 'baz']] - }); +redis.multi().set('foo', 'bar').set('foo', 'baz').get('foo', (err, result) => { + // result === 'QUEUED' +}).exec((err, results) => { + // results = [[null, 'OK'], [null, 'OK'], [null, 'baz']] +}); -redis.multi([['set', 'foo', 'bar'], ['get', 'foo']]).exec((err, results) => { +redis.multi([ + ['set', 'foo', 'bar'], + ['get', 'foo'] +]).exec((err, results) => { // results = [[null, 'OK'], [null, 'bar']] }); @@ -174,28 +157,26 @@ redis.mget(...keys); redis.mset(...['foo', 'bar']); redis.mset({ foo: 'bar' }); -new Redis.Cluster(['localhost']); - -new Redis.Cluster([6379]); - new Redis.Cluster([ - { - host: 'localhost' - } + 'localhost' ]); new Redis.Cluster([ - { - port: 6379 - } + 6379 ]); -new Redis.Cluster([ - { - host: 'localhost', - port: 6379 - } -]); +new Redis.Cluster([{ + host: 'localhost' +}]); + +new Redis.Cluster([{ + port: 6379 +}]); + +new Redis.Cluster([{ + host: 'localhost', + port: 6379 +}]); redis.xack('streamName', 'groupName', 'id'); redis.xadd('streamName', '*', 'field', 'name'); From 62c031fefa8b6af9be04e438209827f176812786 Mon Sep 17 00:00:00 2001 From: okampfer Date: Sat, 23 Feb 2019 10:23:33 +0800 Subject: [PATCH 118/222] Add additional dependency for parcel-bundler and correct middleware method definition. --- types/parcel-bundler/index.d.ts | 4 +++- types/parcel-bundler/package.json | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 types/parcel-bundler/package.json diff --git a/types/parcel-bundler/index.d.ts b/types/parcel-bundler/index.d.ts index 735673967f..d7ea9175ae 100644 --- a/types/parcel-bundler/index.d.ts +++ b/types/parcel-bundler/index.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 +import * as express from "express-serve-static-core"; + declare namespace ParcelBundler { interface ParcelOptions { /** @@ -174,7 +176,7 @@ declare class ParcelBundler { bundle(): Promise; - middleware(): (req: any, res: any, next: any) => any; + middleware(): (req: express.Request, res: express.Response, next: express.NextFunction) => any; } export = ParcelBundler; diff --git a/types/parcel-bundler/package.json b/types/parcel-bundler/package.json new file mode 100644 index 0000000000..4220709f3e --- /dev/null +++ b/types/parcel-bundler/package.json @@ -0,0 +1,13 @@ +{ + "name": "@types/parcel-bundler", + "version": "1.10.1", + "description": "TypeScript definitions for parcel-bundler", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" + }, + "dependencies": { + "@types/express-serve-static-core": "*" + } +} From 02cc1be2cc37dcc1bdbc78de8b5435fc192f03c0 Mon Sep 17 00:00:00 2001 From: okampfer Date: Sat, 23 Feb 2019 10:39:30 +0800 Subject: [PATCH 119/222] Remove license field from package.json --- types/parcel-bundler/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/parcel-bundler/package.json b/types/parcel-bundler/package.json index 4220709f3e..dd37507a8e 100644 --- a/types/parcel-bundler/package.json +++ b/types/parcel-bundler/package.json @@ -2,7 +2,6 @@ "name": "@types/parcel-bundler", "version": "1.10.1", "description": "TypeScript definitions for parcel-bundler", - "license": "MIT", "repository": { "type": "git", "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" From cb8c9e50d27f86b3fe1c1303a0600db581f3edef Mon Sep 17 00:00:00 2001 From: okampfer Date: Sat, 23 Feb 2019 10:50:16 +0800 Subject: [PATCH 120/222] Remove package.json for parcel-bundler --- types/parcel-bundler/package.json | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 types/parcel-bundler/package.json diff --git a/types/parcel-bundler/package.json b/types/parcel-bundler/package.json deleted file mode 100644 index dd37507a8e..0000000000 --- a/types/parcel-bundler/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@types/parcel-bundler", - "version": "1.10.1", - "description": "TypeScript definitions for parcel-bundler", - "repository": { - "type": "git", - "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" - }, - "dependencies": { - "@types/express-serve-static-core": "*" - } -} From 1c99f14c41cbd5391d26407d86d2b9138861c766 Mon Sep 17 00:00:00 2001 From: okampfer Date: Sat, 23 Feb 2019 11:09:53 +0800 Subject: [PATCH 121/222] Update required typescript version for parcel-bundler --- types/parcel-bundler/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/parcel-bundler/index.d.ts b/types/parcel-bundler/index.d.ts index d7ea9175ae..230d928db1 100644 --- a/types/parcel-bundler/index.d.ts +++ b/types/parcel-bundler/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/parcel-bundler/parcel#readme // Definitions by: pinage404 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 import * as express from "express-serve-static-core"; From 9669d70829404e6164d6e0313d62a659ce29a75a Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Sat, 23 Feb 2019 00:48:00 -0500 Subject: [PATCH 122/222] :zap: Have Cluster extend EventEmitter and Command --- types/ioredis/index.d.ts | 2 +- types/ioredis/ioredis-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index b36cf485cf..f8ddf5fd43 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -873,7 +873,7 @@ declare namespace IORedis { type ClusterNode = string | number | NodeConfiguration; - interface Cluster { + interface Cluster extends NodeJS.EventEmitter, Commander { connect(callback: () => void): Promise; disconnect(): void; nodes: Redis[]; diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index 284084cf93..cefb150109 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -219,6 +219,7 @@ const cluster = new Redis.Cluster( ], clusterOptions ); +cluster.on('end', () => console.log('on end')); cluster.nodes.map(node => { node.pipeline() .flushdb() From f99cf3aee23b63c3aef990e5301479c8da0a116b Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Sat, 23 Feb 2019 14:16:50 +0800 Subject: [PATCH 123/222] solidity-parser-antlr: rename `TypeString` to `ASTNodeTypeString` I think `ASTNodeTypeString` is a better name. --- types/solidity-parser-antlr/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/solidity-parser-antlr/index.d.ts b/types/solidity-parser-antlr/index.d.ts index 113d004fd7..7547fd282e 100644 --- a/types/solidity-parser-antlr/index.d.ts +++ b/types/solidity-parser-antlr/index.d.ts @@ -16,7 +16,7 @@ export interface Location { } // Note: This should be consistent with the definition of type ASTNode -export type TypeString = 'SourceUnit' +export type ASTNodeTypeString = 'SourceUnit' | 'PragmaDirective' | 'PragmaName' | 'PragmaValue' @@ -100,7 +100,7 @@ export type TypeString = 'SourceUnit' | 'Conditional'; export interface BaseASTNode { - type: TypeString; + type: ASTNodeTypeString; range?: [number, number]; loc?: Location; } From 52f566fbbc5eb07de1f48afa2a44662802165b2c Mon Sep 17 00:00:00 2001 From: Mick Dekkers Date: Sat, 23 Feb 2019 09:31:38 +0100 Subject: [PATCH 124/222] Fix progress-stream's ProgressStream by extending stream.Transform This works around the issue described in Microsoft/TypeScript#30031 Unfortunately, we have to redeclare all on/once overloads from stream.Transform in order to extend stream.Transform correctly. --- types/progress-stream/index.d.ts | 59 +++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/types/progress-stream/index.d.ts b/types/progress-stream/index.d.ts index 0b20223b3e..17410ea177 100644 --- a/types/progress-stream/index.d.ts +++ b/types/progress-stream/index.d.ts @@ -31,12 +31,63 @@ declare namespace progress_stream { type ProgressListener = (progress: Progress) => void; - type ProgressStream = stream.Transform & { - on(event: "progress", listener: ProgressListener): ProgressStream; - on(event: "length", listener: (length: number) => void): ProgressStream; + interface ProgressStream extends stream.Transform { + on(event: "progress", listener: ProgressListener): this; + on(event: "length", listener: (length: number) => void): this; + once(event: "progress", listener: ProgressListener): this; + once(event: "length", listener: (length: number) => void): this; setLength(length: number): void; progress(): Progress; - }; + + // We have to redeclare all on/once overloads from stream.Transform in + // order for this ProgressStream interface to extend stream.Transform + // correctly. Using an intersection type instead may be an option once + // https://github.com/Microsoft/TypeScript/issues/30031 is resolved. + + // stream.Readable events + + /* tslint:disable-next-line adjacent-overload-signatures */ + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: any) => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "end", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "readable", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + /* tslint:disable-next-line adjacent-overload-signatures */ + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: any) => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "end", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "readable", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + + // stream.Writable events + + /* tslint:disable-next-line adjacent-overload-signatures unified-signatures */ + on(event: "drain", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + /* tslint:disable-next-line adjacent-overload-signatures unified-signatures */ + once(event: "drain", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + + // events shared by stream.Readable and stream.Writable + + /* tslint:disable-next-line adjacent-overload-signatures */ + on(event: string | symbol, listener: (...args: any[]) => void): this; + /* tslint:disable-next-line adjacent-overload-signatures */ + once(event: string | symbol, listener: (...args: any[]) => void): this; + /* tslint:enable adjacent-overload-signatures unified-signatures */ + } interface Progress { percentage: number; From 78915c9333e50a71dc99a54dcc38f9123612adc2 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Sat, 23 Feb 2019 17:06:34 +0800 Subject: [PATCH 125/222] [weixin-app] add defs for observers --- types/weixin-app/index.d.ts | 210 +++++++++++++++------------ types/weixin-app/weixin-app-tests.ts | 84 +++++++---- 2 files changed, 175 insertions(+), 119 deletions(-) diff --git a/types/weixin-app/index.d.ts b/types/weixin-app/index.d.ts index 8c06b3de10..e2a9c7a5fb 100644 --- a/types/weixin-app/index.d.ts +++ b/types/weixin-app/index.d.ts @@ -87,16 +87,14 @@ declare namespace wx { * @version 1.4.0 */ onProgressUpdate( - callback?: ( - res: { - /** 上传进度百分比 */ - progress: number; - /** 已经上传的数据长度,单位 Bytes */ - totalBytesSent: number; - /** 预期需要上传的数据总长度,单位 Bytes */ - totalBytesExpectedToSend: number; - } - ) => void + callback?: (res: { + /** 上传进度百分比 */ + progress: number; + /** 已经上传的数据长度,单位 Bytes */ + totalBytesSent: number; + /** 预期需要上传的数据总长度,单位 Bytes */ + totalBytesExpectedToSend: number; + }) => void ): void; /** * 中断下载任务 @@ -135,16 +133,14 @@ declare namespace wx { * @version 1.4.0 */ onProgressUpdate( - callback?: ( - res: { - /** 下载进度百分比 */ - progress: number; - /** 已经下载的数据长度,单位 Bytes */ - totalBytesWritten: number; - /** 预期需要下载的数据总长度,单位 Bytes */ - totalBytesExpectedToWrite: number; - } - ) => void + callback?: (res: { + /** 下载进度百分比 */ + progress: number; + /** 已经下载的数据长度,单位 Bytes */ + totalBytesWritten: number; + /** 预期需要下载的数据总长度,单位 Bytes */ + totalBytesExpectedToWrite: number; + }) => void ): void; /** * 中断下载任务 @@ -1147,12 +1143,7 @@ declare namespace wx { * @version 1.1.0 */ function onNetworkStatusChange( - callback: ( - res: { - isConnected: boolean; - networkType: networkType; - } - ) => void + callback: (res: { isConnected: boolean; networkType: networkType }) => void ): void; // 设备-----加速度计 interface AccelerometerData { @@ -1391,11 +1382,7 @@ declare namespace wx { * @version 1.1.0 */ function onBluetoothDeviceFound( - callback: ( - res: { - devices: BluetoothDevice[]; - } - ) => void + callback: (res: { devices: BluetoothDevice[] }) => void ): void; interface GetConnectedBluetoothDevicesOptions extends BaseOptions { services: string[]; @@ -1604,43 +1591,39 @@ declare namespace wx { * 监听低功耗蓝牙连接的错误事件,包括设备丢失,连接异常断开等等。 */ function onBLEConnectionStateChanged( - callback: ( - res: { - /** - * 蓝牙设备 id,参考 device 对象 - */ - deviceId: string; - /** - * 连接目前的状态 - */ - connected: boolean; - } - ) => void + callback: (res: { + /** + * 蓝牙设备 id,参考 device 对象 + */ + deviceId: string; + /** + * 连接目前的状态 + */ + connected: boolean; + }) => void ): void; /** * 监听低功耗蓝牙设备的特征值变化。必须先启用notify接口才能接收到设备推送的notification。 */ function onBLECharacteristicValueChange( - callback: ( - res: { - /** - * 蓝牙设备 id,参考 device 对象 - */ - deviceId: string; - /** - * 特征值所属服务 uuid - */ - serviceId: string; - /** - * 特征值 uuid - */ - characteristicId: string; - /** - * 特征值最新的值 - */ - value: ArrayBuffer; - } - ) => void + callback: (res: { + /** + * 蓝牙设备 id,参考 device 对象 + */ + deviceId: string; + /** + * 特征值所属服务 uuid + */ + serviceId: string; + /** + * 特征值 uuid + */ + characteristicId: string; + /** + * 特征值最新的值 + */ + value: ArrayBuffer; + }) => void ): void; // #region iBeacon interface StartBeaconDiscoveryOptions extends BaseOptions { @@ -3729,9 +3712,9 @@ declare namespace wx { type DefaultProps = object | Record; - type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (( - k: infer I, - ) => void) + type UnionToIntersection = (U extends any + ? (k: U) => void + : never) extends ((k: infer I) => void) ? I : never; @@ -3743,20 +3726,26 @@ declare namespace wx { __DO_NOT_USE_INTERNAL_FIELD_METHODS: Methods; } - type UnboxBehaviorData = T extends Behavior<{}, {}, {}> ? T['__DO_NOT_USE_INTERNAL_FIELD_DATA'] : {}; - type UnboxBehaviorProps = T extends Behavior<{}, {}, {}> ? T['__DO_NOT_USE_INTERNAL_FIELD_PROPS'] : {}; - type UnboxBehaviorMethods = T extends Behavior<{}, {}, {}> ? T['__DO_NOT_USE_INTERNAL_FIELD_METHODS'] : {}; + type UnboxBehaviorData = T extends Behavior<{}, {}, {}> + ? T["__DO_NOT_USE_INTERNAL_FIELD_DATA"] + : {}; + type UnboxBehaviorProps = T extends Behavior<{}, {}, {}> + ? T["__DO_NOT_USE_INTERNAL_FIELD_PROPS"] + : {}; + type UnboxBehaviorMethods = T extends Behavior<{}, {}, {}> + ? T["__DO_NOT_USE_INTERNAL_FIELD_METHODS"] + : {}; - type UnboxBehaviorsMethods< - Behaviors extends Array | string> + type UnboxBehaviorsMethods< + Behaviors extends Array | string> > = UnboxBehaviorMethods>>; - type UnboxBehaviorsData< - Behaviors extends Array | string> + type UnboxBehaviorsData< + Behaviors extends Array | string> > = UnboxBehaviorData>>; - type UnboxBehaviorsProps< - Behaviors extends Array | string> + type UnboxBehaviorsProps< + Behaviors extends Array | string> > = UnboxBehaviorProps>>; // CombinedInstance models the `this`, i.e. instance type for (user defined) component @@ -3765,7 +3754,7 @@ declare namespace wx { Data, Methods, Props, - Behaviors extends Array | string> + Behaviors extends Array | string> > = Methods & Instance & UnboxBehaviorsMethods; type Prop = (() => T) | { new (...args: any[]): T & object }; @@ -3791,6 +3780,13 @@ declare namespace wx { type PropsDefinition = ArrayPropsDefinition | RecordPropsDefinition; + /** + * https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/observer.html + */ + interface ObserversDefs { + [expression: string]: (this: V, ...fields: any[]) => any; + } + interface ComponentRelation { /** 目标组件的相对关系,可选的值为 parent 、 child 、 ancestor 、 descendant */ type: "parent" | "child" | "ancestor" | "descendant"; @@ -3808,7 +3804,7 @@ declare namespace wx { Data, Methods, Props, - Behaviors extends Array | string> + Behaviors extends Array | string> > = object & ComponentOptions & ThisType, Behaviors>>; @@ -3872,7 +3868,7 @@ declare namespace wx { Data = DefaultData, Methods = DefaultMethods, Props = PropsDefinition, - Behaviors extends Array | string> = [] + Behaviors extends Array | string> = [] > extends Partial { /** * 组件的对外属性,是属性名到属性设置的映射表 @@ -3886,6 +3882,12 @@ declare namespace wx { */ data?: Data; + /** + * 数据监听器可以用于监听和响应任何属性和数据字段的变化。从小程序基础库版本 2.6.1 开始支持 + * @since 2.6.1 + */ + observers?: ObserversDefs; + /** * 组件的方法,包括事件响应函数和任意的自定义方法 * 关于事件响应函数的使用 @@ -3925,7 +3927,7 @@ declare namespace wx { * 类似于mixins和traits的组件间代码复用机制 * 参见 [behaviors](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/custom-component/behaviors.html) */ - behaviors?: Behaviors; + behaviors?: Behaviors; /** * 组件生命周期声明对象,组件的生命周期:created、attached、ready、moved、detached将收归到lifetimes字段内进行声明, @@ -3965,7 +3967,11 @@ declare namespace wx { /** * Component实例方法 */ - interface Component | string> = []> { + interface Component< + D, + P, + B extends Array | string> = [] + > { /** * 组件的文件路径 */ @@ -3981,20 +3987,24 @@ declare namespace wx { /** * 组件数据,包括内部数据和属性值 */ - data: D & UnboxBehaviorsData & { - [key in keyof (P & UnboxBehaviorsProps)]: PropValueType< - (P & UnboxBehaviorsProps)[key] - > - }; + data: D & + UnboxBehaviorsData & + { + [key in keyof (P & UnboxBehaviorsProps)]: PropValueType< + (P & UnboxBehaviorsProps)[key] + > + }; /** * 组件数据,包括内部数据和属性值(与 data 一致) */ - properties: D & UnboxBehaviorsData & { - [key in keyof (P & UnboxBehaviorsProps)]: PropValueType< - (P & UnboxBehaviorsProps)[key] - > - }; + properties: D & + UnboxBehaviorsData & + { + [key in keyof (P & UnboxBehaviorsProps)]: PropValueType< + (P & UnboxBehaviorsProps)[key] + > + }; /** * 将数据从逻辑层发送到视图层,同时改变对应的 this.data 的值 * 1. 直接修改 this.data 而不调用 this.setData 是无法改变页面的状态的,还会造成数据不一致。 @@ -4397,7 +4407,12 @@ declare function App( declare function getApp(): wx.App; // #endregion // #region Compontent组件 -declare function Component | string> = []>( +declare function Component< + D, + M, + P, + B extends Array | string> = [] +>( options?: wx.ThisTypedComponentOptionsWithRecordProps< wx.Component, D, @@ -4414,7 +4429,12 @@ declare function Component | st * 每个组件可以引用多个 behavior * behavior 也可以引用其他 behavior */ -declare function Behavior | string> = []>( +declare function Behavior< + D, + M, + P, + B extends Array | string> = [] +>( options?: wx.ThisTypedComponentOptionsWithRecordProps< wx.Component, D, @@ -4422,7 +4442,11 @@ declare function Behavior | str P, B > -): wx.Behavior, P & wx.UnboxBehaviorsProps, M & wx.UnboxBehaviorsMethods>; +): wx.Behavior< + D & wx.UnboxBehaviorsData, + P & wx.UnboxBehaviorsProps, + M & wx.UnboxBehaviorsMethods +>; // #endregion // #region Page /** diff --git a/types/weixin-app/weixin-app-tests.ts b/types/weixin-app/weixin-app-tests.ts index fb717d0c31..a824028862 100644 --- a/types/weixin-app/weixin-app-tests.ts +++ b/types/weixin-app/weixin-app-tests.ts @@ -16,7 +16,7 @@ const parentBehavior = Behavior({ } }, data: { - myParentBehaviorData: "", + myParentBehaviorData: "" }, methods: { myParentBehaviorMethod(input: number) { @@ -26,31 +26,40 @@ const parentBehavior = Behavior({ }); function createBehaviorWithUnionTypes(n: number) { - const properties = n % 2 < 1 ? { - unionPropA: { - type: String, - }, - } : { - unionPropB: { - type: Number, - }, - }; + const properties = + n % 2 < 1 + ? { + unionPropA: { + type: String + } + } + : { + unionPropB: { + type: Number + } + }; - const data = n % 4 < 2 ? { - unionDataA: 'a', - } : { - unionDataB: 1, - }; + const data = + n % 4 < 2 + ? { + unionDataA: "a" + } + : { + unionDataB: 1 + }; - const methods = n % 8 < 4 ? { - unionMethodA(a: number) { - return n + 1; - }, - } : { - unionMethodB(a: string) { - return {value: a}; - }, - }; + const methods = + n % 8 < 4 + ? { + unionMethodA(a: number) { + return n + 1; + } + } + : { + unionMethodB(a: string) { + return { value: a }; + } + }; return Behavior({ properties, @@ -63,7 +72,7 @@ const behavior = Behavior({ behaviors: [ createBehaviorWithUnionTypes(1), parentBehavior, - "wx://form-field", + "wx://form-field" ], properties: { myBehaviorProperty: { @@ -168,7 +177,7 @@ Component({ console.log(this.unionMethodA(5)); } if (this.unionMethodB) { - console.log(this.unionMethodB('test').value); + console.log(this.unionMethodB("test").value); } console.log(this.data.unionDataA); console.log(this.data.unionDataB); @@ -568,3 +577,26 @@ App({ }); } }); + +Component({ + observers: { + "name, age": function nameAgeObserver(name: string, age: number) { + this.setData({ + nameStr: `Dear ${name}`, + ageStr: `${age}` + }); + } + }, + properties: { + name: { + type: String + }, + age: { + type: Number + } + }, + data: { + nameStr: "", + ageStr: "" + } +}); From c337e699a84e204f7f13686f46c2abd85f11b4f9 Mon Sep 17 00:00:00 2001 From: Benjamin Giesinger Date: Sat, 23 Feb 2019 12:50:07 +0100 Subject: [PATCH 126/222] Added position to TextBracket which I missed the last commit --- types/vexflow/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/vexflow/index.d.ts b/types/vexflow/index.d.ts index 784760b186..2840f35872 100644 --- a/types/vexflow/index.d.ts +++ b/types/vexflow/index.d.ts @@ -1270,6 +1270,7 @@ declare namespace Vex { static DEBUG : boolean; start : Note; stop : Note; + position : TextBracket.Positions; applyStyle(context : IRenderContext) : TextBracket; setDashed(dashed : boolean, dash? : number[]) : TextBracket; setFont(font : {family : string, size : number, weight : string}) : TextBracket; From 05a76b557f7c945c7d44e4eb174dc7f9eb35d5a3 Mon Sep 17 00:00:00 2001 From: Haseeb Majid Date: Sat, 23 Feb 2019 12:55:12 +0000 Subject: [PATCH 127/222] Added screenProps Added screenProps to DrawerItemsProps. --- types/react-navigation/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 860d54523e..8e0b356f50 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -32,6 +32,7 @@ // Deniss Borisovs // Kenneth Skovhus // Aaron Rosen +// Haseeb Majid // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -922,6 +923,7 @@ export interface DrawerItemsProps { inactiveLabelStyle?: StyleProp; iconContainerStyle?: StyleProp; drawerPosition: 'left' | 'right'; + screenProps?: { [key: string]: any }; } export interface DrawerScene { route: NavigationRoute; From 7c723a81c595e4d3815b456a11f41e2f1f9cc285 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 23 Feb 2019 11:22:48 -0600 Subject: [PATCH 128/222] Update aws-iot-device-sdk for version 2.2.0 Lifted documentioned directly from the readme: https://github.com/aws/aws-iot-device-sdk-js#job Code change is here: https://github.com/aws/aws-iot-device-sdk-js/commit/234d170c865586f4e49e4b0946100d93f367ee8f --- .../aws-iot-device-sdk-tests.ts | 47 ++++++++ types/aws-iot-device-sdk/index.d.ts | 114 +++++++++++++++++- 2 files changed, 160 insertions(+), 1 deletion(-) diff --git a/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts b/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts index 66655f8dd3..89eff9a8c6 100644 --- a/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts +++ b/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts @@ -101,3 +101,50 @@ const thingShadows = new awsIot.thingShadow({ thingShadows.on("timeout", function(thingName: string, clientToken: string) { }); + +const jobs = new awsIot.jobs({ + keyPath: "", + certPath: "", + caPath: "", + clientId: "", + region: "", + baseReconnectTimeMs: 1000, + protocol: "wss", + port: 443, + host: "", + debug: false +}); + +jobs.subscribeToJobs("thingname", "operationname", (err, job) => { + console.error("Error", err); + if (err || !job) { + return; + } + console.log("job id", job.id); + console.log("job info", job.document); + console.log("job op", job.operation); + console.log("job status", job.status); + console.log("job status details", job.status.statusDetails); + console.log( + "job status details progress", + job.status.statusDetails.progress + ); + + job.inProgress({ progress: "1" }, err => + console.error("Job progress error", err) + ); + job.failed({ progress: "2" }, err => + console.error("Job failed error", err) + ); + job.succeeded({ progress: "3" }, err => + console.error("Job failed error", err) + ); +}); + +jobs.startJobNotifications("thingname", err => + console.error("Start job notification error", err) +); + +jobs.unsubscribeFromJobs("thingname", "operationame", err => + console.error("Unsubscribe from jobs error", err) +); diff --git a/types/aws-iot-device-sdk/index.d.ts b/types/aws-iot-device-sdk/index.d.ts index f2bcab818c..8b52a68bfc 100644 --- a/types/aws-iot-device-sdk/index.d.ts +++ b/types/aws-iot-device-sdk/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for aws-iot-device-sdk 2.1.0 +// Type definitions for aws-iot-device-sdk 2.2.0 // Project: https://github.com/aws/aws-iot-device-sdk-js // Definitions by: Markus Olsson // Margus Lamp @@ -391,3 +391,115 @@ export class thingShadow extends NodeJS.EventEmitter { /** Emitted when a different client"s update or delete operation is accepted on the shadow. */ on(event: "foreignStateChange", listener: (thingName: string, operation: "update" | "delete", stateObject: any) => void): this; } + +export interface statusDetails { + progress: string; +} + +export interface jobStatus { + status: string; + statusDetails: statusDetails; +} + +export interface jobDocument { + [key: string]: any +} + +export interface job { + /** Object that contains job execution information and functions for updating job execution status. */ + + /** Returns the job id. */ + id: string; + + /** + * The JSON document describing details of the job to be executed eg. + * { + * "operation": "install", + * "otherProperty": "value", + * ... + * } + */ + document: jobDocument; + + /** + * Returns the job operation from the job document. Eg. 'install', 'reboot', etc. + */ + operation: string; + + /** + * Returns the current job status according to AWS Orchestra. + */ + status: jobStatus; + + /** + * Update the status of the job execution to be IN_PROGRESS for the thing associated with the job. + * + * @param statusDetails - optional document describing the status details of the in progress job + * @param callback - function(err) optional callback for when the operation completes, err is null if no error occurred + */ + inProgress(statusDetails?: statusDetails, callback?: (err: Error) => void): void; + + /** + * Update the status of the job execution to be FAILED for the thing associated with the job. + * + * @param statusDetails - optional document describing the status details of the in progress job e.g. + * @param callback - function(err) optional callback for when the operation completes, err is null if no error occurred + */ + failed(statusDetails?: statusDetails, callback?: (err: Error) => void): void; + + /** + * Update the status of the job execution to be SUCCESS for the thing associated with the job. + * + * @param statusDetails - optional document describing the status details of the in progress job e.g. + * @param callback - function(err) optional callback for when the operation completes, err is null if no error occurred + */ + succeeded(statusDetails?: statusDetails, callback?: (err: Error) => void): void; +} + +export class jobs extends device { + /** + * The `jobs` class wraps an instance of the `device` class with additional functionality to + * handle job execution management through the AWS IoT Jobs platform. Arguments in `deviceOptions` + * are the same as those in the device class and the `jobs` class supports all of the + * same events and functions as the `device` class. + */ + constructor(options?: DeviceOptions); + + /** + * Subscribes to job execution notifications for the thing named `thingName`. If + * `operationName` is specified then the callback will only be called when a job + * ready for execution contains a property called `operation` in its job document with + * a value matching `operationName`. If `operationName` is omitted then the callback + * will be called for every job ready for execution that does not match another + * `subscribeToJobs` subscription. + * + * @param thingName - name of the Thing to receive job execution notifications + * @param operationName - optionally filter job execution notifications to jobs with a value + * for the `operation` property that matches `operationName + * @param callback - function (err, job) callback for when a job execution is ready for processing or an error occurs + * - `err` a subscription error or an error that occurs when client is disconnecting + * - `job` an object that contains job execution information and functions for updating job execution status. + */ + subscribeToJobs(thingName: string, operationName: string, callback?: (err: Error, job: job) => void): void; + + /** + * Causes any existing queued job executions for the given thing to be published + * to the appropriate subscribeToJobs handler. Only needs to be called once per thing. + * + * @param thingName - name of the Thing to cancel job execution notifications for + * @param callback - function (err) callback for when the startJobNotifications operation completes + */ + startJobNotifications(thingName: string, callback: (error: Error) => void): mqtt.Client; + + /** + * Unsubscribes from job execution notifications for the thing named `thingName` having + * operations with a value of the given `operationName`. If `operationName` is omitted then + * the default handler for the thing with the given name is unsubscribed. + * + * @param thingName - name of the Thing to cancel job execution notifications for + * @param operationName - optional name of previously subscribed operation names + * @param callback - function (err) callback for when the unsubscribe operation completes + */ + unsubscribeFromJobs(thingName: string, operationName: string, callback: (err: Error) => void): void; + +} From e59a8682539c76db01b64ec5083dd5a23ae2197f Mon Sep 17 00:00:00 2001 From: Roman Paradeev Date: Sat, 23 Feb 2019 23:50:35 +0500 Subject: [PATCH 129/222] Make sinon Bluebird-friendly --- types/sinon/ts3.1/index.d.ts | 2 +- types/sinon/ts3.1/sinon-tests.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index 7123e75d49..b378e2a30b 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -399,7 +399,7 @@ declare namespace Sinon { * The Promise library can be overwritten using the usingPromise method. * Since sinon@2.0.0 */ - resolves(value?: TReturnValue extends Promise ? TResolveValue : never): SinonStub; + resolves(value?: TReturnValue extends PromiseLike ? TResolveValue : never): SinonStub; /** * Causes the stub to return a Promise which resolves to the argument at the provided index. * stub.resolvesArg(0); causes the stub to return a Promise which resolves to the first argument. diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index 2db25348ae..560ad7c6ae 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -1,4 +1,5 @@ import sinon = require("sinon"); +import Bluebird = require("bluebird"); function testSandbox() { const obj = {}; @@ -422,6 +423,7 @@ function testStub() { const obj = class { foo() { } promiseFunc() { return Promise.resolve('foo'); } + promiseLikeFunc() { return {} as any as Bluebird; } }; const instance = new obj(); @@ -430,10 +432,12 @@ function testStub() { const spy: sinon.SinonSpy = stub; - function promiseFunc(n: number) { return Promise.resolve('foo'); } const promiseStub = sinon.stub(instance, 'promiseFunc'); promiseStub.resolves('test'); + const promiseLikeStub = sinon.stub(instance, 'promiseLikeFunc'); + promiseLikeStub.resolves('test'); + sinon.stub(instance); stub.reset(); From 1645790befc6a017db2101f6eb96f3488b0d4406 Mon Sep 17 00:00:00 2001 From: Anton Astashov Date: Fri, 22 Feb 2019 23:20:25 -0600 Subject: [PATCH 130/222] @types/koa-router: Typesafe middlewares prepending It's sometimes useful to prepend middlewares to the route handler, when we want to register some middlewares only for particular routes. Like: ```ts router.get("/foo", (ctx: Koa.Middleware, next) => { ctx.state.foo = "foo"; return next(); }, (ctx, next) => { // ctx here knows `ctx.state.foo` is `string` // ... } ); ``` Unfortunately, currently we can't infer that `ctx` there would have `state.foo`. All middlewares/route-handlers should have the same type currently. It seems to be impossible to do that in the general case (for any number of prepended middlewares), but we could have a special case for 2 middlewares, and if we have to prepend several middlewares - we could use `koa-compose` to combine them into one, and still do that in a typesafe way. Like: ```ts router.get("/foo", compose([ (ctx: Koa.Middleware, next) => { ctx.state.foo = "foo"; return next(); }, (ctx: Koa.Middleware, next) => { ctx.state.bar = "bar"; return next(); } ]), (ctx, next) => { // ctx here knows `ctx.state.foo` is `string` // and `ctx.state.bar` is `string`. } ); ``` Changes in this PR add that special case for one prepended middleware for all route methods (`get`, `post`, `head`, etc). It's not a breaking change - we keep old types here, we only add a special more type-correct way of prepending one middleware before a route handler. What do you think? --- types/koa-router/index.d.ts | 121 +++++++++++++++++++++++++++ types/koa-router/koa-router-tests.ts | 63 ++++++++++++++ 2 files changed, 184 insertions(+) diff --git a/types/koa-router/index.d.ts b/types/koa-router/index.d.ts index 4df53d0e8b..823cc48059 100644 --- a/types/koa-router/index.d.ts +++ b/types/koa-router/index.d.ts @@ -193,6 +193,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + get( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + get( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP post method @@ -206,6 +217,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + post( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + post( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP put method @@ -219,6 +241,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + put( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + put( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP link method @@ -232,6 +265,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + link( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + link( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP unlink method @@ -245,6 +289,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + unlink( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + unlink( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP delete method @@ -258,6 +313,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + delete( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + delete( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * Alias for `router.delete()` because delete is a reserved word @@ -271,6 +337,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + del( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + del( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP head method @@ -284,6 +361,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + head( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + head( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP options method @@ -297,6 +385,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + options( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + options( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP path method @@ -310,6 +409,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + patch( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + patch( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * Register route with all methods. @@ -323,6 +433,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + all( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + all( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * Set the path prefix for a Router instance that was already initialized. diff --git a/types/koa-router/koa-router-tests.ts b/types/koa-router/koa-router-tests.ts index 96fa0d1751..1759504f7b 100644 --- a/types/koa-router/koa-router-tests.ts +++ b/types/koa-router/koa-router-tests.ts @@ -125,3 +125,66 @@ app2.use((ctx: Context, next: any) => { }); app2.listen(8000); + +// Prepending middlewares tests + +type IBlah = { blah: string; } +type IWooh = { wooh: string; } + +const router4 = new Router({prefix: "/users"}); + +router4.get('/', + (ctx: Koa.ParameterizedContext, next) => { + ctx.state.blah = "blah"; + ctx.state.wooh = "wooh"; + return next(); + }, + (ctx, next) => { + console.log(ctx.state.blah); + console.log(ctx.state.wooh); + console.log(ctx.state.foo); + ctx.body = 'Hello World!'; + return next(); + }) + +const middleware1: Koa.Middleware = (ctx, next) => { + ctx.state.blah = "blah"; +} + +const middleware2: Koa.Middleware = (ctx, next) => { + ctx.state.wooh = "blah"; +} + +const emptyMiddleware: Koa.Middleware<{}> = (ctx, next) => { +} + +function routeHandler1(ctx: Koa.ParameterizedContext): void { + ctx.body = "234"; +} + +function routeHandler2(ctx: Koa.ParameterizedContext): void { + ctx.body = "234"; +} + +function routeHandler3(ctx: Koa.ParameterizedContext<{}>): void { + ctx.body = "234"; +} + +function routeHandler4(ctx: Router.RouterContext): void { + ctx.body = "234"; +} + +const middleware3 = compose([middleware1, middleware2]); + +router4.get('/foo', middleware3, routeHandler1); +router4.post('/foo', middleware1, routeHandler2); +router4.put('/foo', middleware2, routeHandler3); + +router4.patch("foo", '/foo', middleware3, routeHandler1); +router4.delete('/foo', middleware1, routeHandler2); +router4.head('/foo', middleware2, routeHandler3); + +router4.post('/foo', emptyMiddleware, emptyMiddleware, routeHandler4); +router4.post('/foo', emptyMiddleware, emptyMiddleware, emptyMiddleware, routeHandler4); +router4.get('name', '/foo', emptyMiddleware, emptyMiddleware, routeHandler4); +router4.get('name', '/foo', emptyMiddleware, emptyMiddleware, emptyMiddleware, routeHandler4); \ No newline at end of file From 828fb4392a592ef200655a16e1004c7a01b4bec3 Mon Sep 17 00:00:00 2001 From: Michael Heasell Date: Sun, 24 Feb 2019 00:50:34 +0000 Subject: [PATCH 131/222] pikaday: Enable strictNullChecks, noImplicitThis --- types/pikaday/index.d.ts | 14 +++++++------- types/pikaday/pikaday-tests.ts | 10 +++++++--- types/pikaday/tsconfig.json | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/types/pikaday/index.d.ts b/types/pikaday/index.d.ts index 2233fa9b4c..3061cd67e7 100644 --- a/types/pikaday/index.d.ts +++ b/types/pikaday/index.d.ts @@ -36,7 +36,7 @@ declare class Pikaday { * Returns a JavaScript Date object for the selected day, or null if * no date is selected. */ - getDate(): Date; + getDate(): Date | null; /** * Set the current selection. This will be restricted within the bounds @@ -50,7 +50,7 @@ declare class Pikaday { * Returns a Moment.js object for the selected date (Moment must be * loaded before Pikaday). */ - getMoment(): moment.Moment; + getMoment(): moment.Moment | null; /** * Set the current selection with a Moment.js object (see setDate). @@ -159,7 +159,7 @@ declare namespace Pikaday { /** * Bind the datepicker to a form field. */ - field?: HTMLElement; + field?: HTMLElement | null; /** * The default output format for toString() and field value. @@ -171,7 +171,7 @@ declare namespace Pikaday { * Use a different element to trigger opening the datepicker. * Default: field element. */ - trigger?: HTMLElement; + trigger?: HTMLElement | null; /** * Automatically show/hide the datepicker on field focus. @@ -201,7 +201,7 @@ declare namespace Pikaday { * DOM node to render calendar into, see container example. * Default: undefined. */ - container?: HTMLElement; + container?: HTMLElement | null; /** * The initial date to view when first opened. @@ -330,12 +330,12 @@ declare namespace Pikaday { * Function which will be used for parsing input string and getting a date object from it. * This function will take precedence over moment. */ - parse?(date: string, format: string): Date; + parse?(date: string, format: string): Date | null; /** * Callback function for when a date is selected. */ - onSelect?(date: Date): void; + onSelect?(this: Pikaday, date: Date): void; /** * Callback function for when the picker becomes visible. diff --git a/types/pikaday/pikaday-tests.ts b/types/pikaday/pikaday-tests.ts index 230104daf7..83790b70ec 100644 --- a/types/pikaday/pikaday-tests.ts +++ b/types/pikaday/pikaday-tests.ts @@ -14,15 +14,15 @@ new Pikaday({field: $('#datepicker')[0]}); console.log(date.toISOString()); } }); - field.parentNode.insertBefore(picker.el, field.nextSibling); + field.parentNode!.insertBefore(picker.el, field.nextSibling); })(); (() => { const picker = new Pikaday({ field: document.getElementById('datepicker'), format: 'D MMM YYYY', - onSelect: () => { - console.log(this.getMoment().format('Do MMMM YYYY')); + onSelect() { + console.log(this.getMoment()!.format('Do MMMM YYYY')); } }); @@ -116,3 +116,7 @@ new Pikaday({field: $('#datepicker')[0]}); toString: (date, format) => '2017-08-23' }); })(); + +new Pikaday({ + parse: (date) => null +}); diff --git a/types/pikaday/tsconfig.json b/types/pikaday/tsconfig.json index 3c936ab905..0c18391e53 100644 --- a/types/pikaday/tsconfig.json +++ b/types/pikaday/tsconfig.json @@ -6,8 +6,8 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -21,4 +21,4 @@ "index.d.ts", "pikaday-tests.ts" ] -} \ No newline at end of file +} From 709b506f4cfbb2e1a74c10d8ebbf64a95f5bb0a8 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sun, 24 Feb 2019 11:16:42 +0100 Subject: [PATCH 132/222] [internal-ip] Remove type definitions --- notNeededPackages.json | 6 +++++ types/internal-ip/index.d.ts | 12 ---------- types/internal-ip/internal-ip-tests.ts | 15 ------------ types/internal-ip/tsconfig.json | 23 ------------------- types/internal-ip/tslint.json | 1 - types/internal-ip/v2/index.d.ts | 7 ------ types/internal-ip/v2/internal-ip-tests.ts | 10 -------- types/internal-ip/v2/tsconfig.json | 28 ----------------------- types/internal-ip/v2/tslint.json | 1 - 9 files changed, 6 insertions(+), 97 deletions(-) delete mode 100644 types/internal-ip/index.d.ts delete mode 100644 types/internal-ip/internal-ip-tests.ts delete mode 100644 types/internal-ip/tsconfig.json delete mode 100644 types/internal-ip/tslint.json delete mode 100644 types/internal-ip/v2/index.d.ts delete mode 100644 types/internal-ip/v2/internal-ip-tests.ts delete mode 100644 types/internal-ip/v2/tsconfig.json delete mode 100644 types/internal-ip/v2/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index a7614a2e60..16555f66a7 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -774,6 +774,12 @@ "sourceRepoURL": "https://github.com/taye/interact.js", "asOfVersion": "1.3.0" }, + { + "libraryName": "internal-ip", + "typingsPackageName": "internal-ip", + "sourceRepoURL": "https://github.com/sindresorhus/internal-ip", + "asOfVersion": "4.1.0" + }, { "libraryName": "inversify", "typingsPackageName": "inversify", diff --git a/types/internal-ip/index.d.ts b/types/internal-ip/index.d.ts deleted file mode 100644 index 1bed7e9059..0000000000 --- a/types/internal-ip/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Type definitions for internal-ip 3.0 -// Project: https://github.com/sindresorhus/internal-ip#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export const v6: IPGetterFn; -export const v4: IPGetterFn; - -export interface IPGetterFn { // tslint:disable-line:interface-name - (): Promise; - sync(): string | null; -} diff --git a/types/internal-ip/internal-ip-tests.ts b/types/internal-ip/internal-ip-tests.ts deleted file mode 100644 index 1b383de2f3..0000000000 --- a/types/internal-ip/internal-ip-tests.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as internalIp from 'internal-ip'; - -internalIp.v6().then(ip => { - // $ExpectType string | null - ip; -}); -// $ExpectType string | null -internalIp.v6.sync(); - -internalIp.v4().then(ip => { - // $ExpectType string | null - ip; -}); -// $ExpectType string | null -internalIp.v4.sync(); diff --git a/types/internal-ip/tsconfig.json b/types/internal-ip/tsconfig.json deleted file mode 100644 index 99d54932e0..0000000000 --- a/types/internal-ip/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "internal-ip-tests.ts" - ] -} diff --git a/types/internal-ip/tslint.json b/types/internal-ip/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/internal-ip/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } diff --git a/types/internal-ip/v2/index.d.ts b/types/internal-ip/v2/index.d.ts deleted file mode 100644 index a82dd8c913..0000000000 --- a/types/internal-ip/v2/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Type definitions for internal-ip 2.0 -// Project: https://github.com/sindresorhus/internal-ip#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export function v6(): Promise; -export function v4(): Promise; diff --git a/types/internal-ip/v2/internal-ip-tests.ts b/types/internal-ip/v2/internal-ip-tests.ts deleted file mode 100644 index e94ec9f510..0000000000 --- a/types/internal-ip/v2/internal-ip-tests.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as internalIp from 'internal-ip'; - -let str: string; -internalIp.v6().then(ip => { - str = ip; -}); - -internalIp.v4().then(ip => { - str = ip; -}); diff --git a/types/internal-ip/v2/tsconfig.json b/types/internal-ip/v2/tsconfig.json deleted file mode 100644 index bae5b7feb8..0000000000 --- a/types/internal-ip/v2/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../../", - "typeRoots": [ - "../../" - ], - "paths": { - "internal-ip": [ - "internal-ip/v2" - ] - }, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "internal-ip-tests.ts" - ] -} diff --git a/types/internal-ip/v2/tslint.json b/types/internal-ip/v2/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/internal-ip/v2/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 2485f3301b37c16a17425ec15eae7b976004d9ac Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sun, 24 Feb 2019 11:24:16 +0100 Subject: [PATCH 133/222] [p-event] Move old types to sub-dir --- types/p-event/{ => v1}/index.d.ts | 0 types/p-event/{ => v1}/p-event-tests.ts | 0 types/p-event/{ => v1}/tsconfig.json | 11 ++++++++--- types/p-event/{ => v1}/tslint.json | 0 4 files changed, 8 insertions(+), 3 deletions(-) rename types/p-event/{ => v1}/index.d.ts (100%) rename types/p-event/{ => v1}/p-event-tests.ts (100%) rename types/p-event/{ => v1}/tsconfig.json (75%) rename types/p-event/{ => v1}/tslint.json (100%) diff --git a/types/p-event/index.d.ts b/types/p-event/v1/index.d.ts similarity index 100% rename from types/p-event/index.d.ts rename to types/p-event/v1/index.d.ts diff --git a/types/p-event/p-event-tests.ts b/types/p-event/v1/p-event-tests.ts similarity index 100% rename from types/p-event/p-event-tests.ts rename to types/p-event/v1/p-event-tests.ts diff --git a/types/p-event/tsconfig.json b/types/p-event/v1/tsconfig.json similarity index 75% rename from types/p-event/tsconfig.json rename to types/p-event/v1/tsconfig.json index 0e047aa84b..e8374c9b9e 100644 --- a/types/p-event/tsconfig.json +++ b/types/p-event/v1/tsconfig.json @@ -9,10 +9,15 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": false, - "baseUrl": "../", + "baseUrl": "../../", "typeRoots": [ - "../" + "../../" ], + "paths": { + "p-event": [ + "p-event/v1" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -21,4 +26,4 @@ "index.d.ts", "p-event-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/p-event/tslint.json b/types/p-event/v1/tslint.json similarity index 100% rename from types/p-event/tslint.json rename to types/p-event/v1/tslint.json From 84c1cc8e9b6c1d08e63924e9a7d37b30d839bdad Mon Sep 17 00:00:00 2001 From: Haseeb Majid Date: Sun, 24 Feb 2019 13:56:17 +0000 Subject: [PATCH 134/222] Updated Screen Props Definition Updated screen props to any, as per the react navigation documenation. https://reactnavigation.org/docs/en/stack-navigator.html#navigator-props --- types/react-navigation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 8e0b356f50..f2b0b968fb 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -923,7 +923,7 @@ export interface DrawerItemsProps { inactiveLabelStyle?: StyleProp; iconContainerStyle?: StyleProp; drawerPosition: 'left' | 'right'; - screenProps?: { [key: string]: any }; + screenProps?: any; } export interface DrawerScene { route: NavigationRoute; From b8bbaeb07b0f84d67c2323f3171a91477de76adf Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sun, 24 Feb 2019 17:19:49 +0100 Subject: [PATCH 135/222] feat(jest): add `timeout` parameter for `test.each()`. --- types/jest/index.d.ts | 5 +++-- types/jest/jest-tests.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index f0382d2cb5..343531025b 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -263,10 +263,11 @@ declare namespace jest { } interface Each { - (cases: any[]): (name: string, fn: (...args: any[]) => any) => void; + (cases: any[]): (name: string, fn: (...args: any[]) => any, timeout?: number) => void; (strings: TemplateStringsArray, ...placeholders: any[]): ( name: string, - fn: (arg: any) => any + fn: (arg: any) => any, + timeout?: number ) => void; } diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 69e68ab6f7..521b3c71f6 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -1360,6 +1360,14 @@ test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( } ); +test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( + ".add(%i, %i)", + (a, b, expected) => { + expect(a + b).toBe(expected); + }, + 5000 +); + test.each` a | b | expected ${1} | ${1} | ${2} @@ -1369,6 +1377,15 @@ test.each` expect(a + b).toBe(expected); }); +test.each` + a | b | expected + ${1} | ${1} | ${2} + ${1} | ${2} | ${3} + ${2} | ${1} | ${3} +`("returns $expected when $a is added $b", ({ a, b, expected }: Case) => { + expect(a + b).toBe(expected); +}, 5000); + test.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( ".add(%i, %i)", (a, b, expected) => { From 4278ade4c06e39d0002d2cac8b6dbf90d536c3f4 Mon Sep 17 00:00:00 2001 From: Olga Isakova Date: Mon, 25 Feb 2019 01:39:24 +0500 Subject: [PATCH 136/222] Add schema options: selectPopulatedPaths, storeSubdocValidationError --- types/mongoose/index.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 267163ac80..16e6d88715 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -18,6 +18,7 @@ // Emmanuel Gautier // Frontend Monster // Ming Chen +// Olga Isakova // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1060,12 +1061,25 @@ declare module "mongoose" { validateBeforeSave?: boolean; /** defaults to "__v" */ versionKey?: string | boolean; + /** + * By default, Mongoose will automatically + * select() any populated paths. + * To opt out, set selectPopulatedPaths to false. + */ + selectPopulatedPaths?: boolean; /** * skipVersioning allows excluding paths from * versioning (the internal revision will not be * incremented even if these paths are updated). */ skipVersioning?: any; + /** + * Validation errors in a single nested schema are reported + * both on the child and on the parent schema. + * Set storeSubdocValidationError to false on the child schema + * to make Mongoose only report the parent error. + */ + storeSubdocValidationError?: boolean; /** * If set timestamps, mongoose assigns createdAt * and updatedAt fields to your schema, the type From f8320d68ee2f018f0b44fc3d651d8b39186cfb8a Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sun, 24 Feb 2019 23:55:08 +0100 Subject: [PATCH 137/222] [p-event] Update types to v2.3 --- types/p-event/index.d.ts | 205 +++++++++++++++++++++++++++++++++ types/p-event/p-event-tests.ts | 110 ++++++++++++++++++ types/p-event/tsconfig.json | 24 ++++ types/p-event/tslint.json | 1 + 4 files changed, 340 insertions(+) create mode 100644 types/p-event/index.d.ts create mode 100644 types/p-event/p-event-tests.ts create mode 100644 types/p-event/tsconfig.json create mode 100644 types/p-event/tslint.json diff --git a/types/p-event/index.d.ts b/types/p-event/index.d.ts new file mode 100644 index 0000000000..6f76b75748 --- /dev/null +++ b/types/p-event/index.d.ts @@ -0,0 +1,205 @@ +// Type definitions for p-event 2.3 +// Project: https://github.com/sindresorhus/p-event#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { PCancelable } from 'p-cancelable'; + +export = pEvent; + +/** + * Promisify an event by waiting for it to be emitted. + * + * Returns a `Promise` that is fulfilled when emitter emits an event matching `event`, or rejects if emitter emits + * any of the events defined in the `rejectionEvents` option. + * + * **Note**: `event` is a string for a single event type, for example, `'data'`. To listen on multiple + * events, pass an array of strings, such as `['started', 'stopped']`. + * + * The returned promise has a `.cancel()` method, which when called, removes the event listeners and causes the promise to never be settled. + * + * @param emitter Event emitter object. Should have either a `.on()`/`.addListener()`/`.addEventListener()` and + * `.off()`/`.removeListener()`/`.removeEventListener()` method, like the [Node.js `EventEmitter`](https://nodejs.org/api/events.html) and + * [DOM events](https://developer.mozilla.org/en-US/docs/Web/Events). + * @param event Name of the event or events to listen to. If the same event is defined both here and in + * `rejectionEvents`, this one takes priority. + */ +declare function pEvent( + emitter: pEvent.Emitter, + event: string | symbol | Array, + options: pEvent.MultiArgsOptions +): PCancelable>; +declare function pEvent( + emitter: pEvent.Emitter, + event: string | symbol | Array, + filter: pEvent.FilterFn +): PCancelable; +declare function pEvent( + emitter: pEvent.Emitter, + event: string | symbol | Array, + options?: pEvent.Options +): PCancelable; + +declare namespace pEvent { + /** + * Wait for multiple event emissions. Returns an array. + */ + function multiple( + emitter: Emitter, + event: string | symbol | Array, + options: MultipleMultiArgsOptions + ): PCancelable>>; + function multiple( + emitter: Emitter, + event: string | symbol | Array, + options: MultipleOptions + ): PCancelable; + + /** + * Returns an [async iterator](http://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously + * iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching + * any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in + * the `rejectionEvents` option. + */ + function iterator( + emitter: Emitter, + event: string | symbol | Array, + options: IteratorMultiArgsOptions + ): AsyncIterableIterator>; + function iterator( + emitter: Emitter, + event: string | symbol | Array, + filter: FilterFn + ): AsyncIterableIterator; + function iterator( + emitter: Emitter, + event: string | symbol | Array, + options?: IteratorOptions + ): AsyncIterableIterator; + + interface Emitter { + on?: AddRmListenerFn; + addListener?: AddRmListenerFn; + addEventListener?: AddRmListenerFn; + off?: AddRmListenerFn; + removeListener?: AddRmListenerFn; + removeEventListener?: AddRmListenerFn; + } + + type FilterFn = (el: T) => boolean; + + interface Options { + /** + * Events that will reject the promise. + * @default ['error'] + */ + rejectionEvents?: Array; + /** + * By default, the promisified function will only return the first argument from the event callback, + * which works fine for most APIs. This option can be useful for APIs that return multiple arguments + * in the callback. Turning this on will make it return an array of all arguments from the callback, + * instead of just the first argument. This also applies to rejections. + * + * @example + * const pEvent = require('p-event'); + * const emitter = require('./some-event-emitter'); + * + * (async () => { + * const [foo, bar] = await pEvent(emitter, 'finish', {multiArgs: true}); + * })(); + * + * @default false + */ + multiArgs?: boolean; + /** + * Time in milliseconds before timing out. + * @default Infinity + */ + timeout?: number; + /** + * Filter function for accepting an event. + * + * @example + * const pEvent = require('p-event'); + * const emitter = require('./some-event-emitter'); + * + * (async () => { + * const result = await pEvent(emitter, '🦄', value => value > 3); + * // Do something with first 🦄 event with a value greater than 3 + * })(); + */ + filter?: FilterFn; + } + + interface MultiArgsOptions extends Options { + multiArgs: true; + } + + interface MultipleOptions extends Options { + /** + * The number of times the event needs to be emitted before the promise resolves. + */ + count: number; + /** + * Whether to resolve the promise immediately. Emitting one of the `rejectionEvents` won't throw an error. + * + * **Note**: The returned array will be mutated when an event is emitted. + * + * @example + * const emitter = new EventEmitter(); + * + * const promise = pEvent.multiple(emitter, 'hello', { + * resolveImmediately: true, + * count: Infinity + * }); + * + * const result = await promise; + * console.log(result); + * //=> [] + * + * emitter.emit('hello', 'Jack'); + * console.log(result); + * //=> ['Jack'] + * + * emitter.emit('hello', 'Mark'); + * console.log(result); + * //=> ['Jack', 'Mark'] + * + * // Stops listening + * emitter.emit('error', new Error('😿')); + * + * emitter.emit('hello', 'John'); + * console.log(result); + * //=> ['Jack', 'Mark'] + */ + resolveImmediately?: boolean; + } + + interface MultipleMultiArgsOptions extends MultipleOptions { + multiArgs: true; + } + + interface IteratorOptions extends Options { + /** + * Maximum number of events for the iterator before it ends. When the limit is reached, the iterator will be + * marked as `done`. This option is useful to paginate events, for example, fetching 10 events per page. + * @default Infinity + */ + limit?: number; + /** + * Events that will end the iterator. + * @default [] + */ + resolutionEvents?: Array; + } + + interface IteratorMultiArgsOptions extends IteratorOptions { + multiArgs: true; + } +} + +type AddRmListenerFn = ( + event: string | symbol, + listener: (arg1: T, ...args: TRest[]) => void +) => void; diff --git a/types/p-event/p-event-tests.ts b/types/p-event/p-event-tests.ts new file mode 100644 index 0000000000..dbbe50eee7 --- /dev/null +++ b/types/p-event/p-event-tests.ts @@ -0,0 +1,110 @@ +/// + +import pEvent = require('p-event'); +import { EventEmitter } from 'events'; +import * as fs from 'fs'; + +class NodeEmitter extends EventEmitter { + on(event: 'finish', listener: (num: number, str: string) => void) { + return this; + } + addListener(event: 'finish', listener: (num: number, str: string) => void) { + return this; + } + addEventListener(event: 'finish', listener: (num: number, str: string) => void) { + return this; + } + off(event: 'finish', listener: (num: number, str: string) => void) { + return this; + } + removeListener(event: 'finish', listener: (num: number, str: string) => void) { + return this; + } + removeEventListener(event: 'finish', listener: (num: number, str: string) => void) { + return this; + } +} + +class DomEmitter implements EventTarget { + addEventListener( + type: 'foo', + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions + ): void {} + + dispatchEvent(event: Event): boolean { + return false; + } + + removeEventListener( + type: 'foo', + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions + ): void {} +} + +pEvent(new NodeEmitter(), 'finish'); // $ExpectType PCancelable +pEvent(new NodeEmitter(), '🦄', value => value > 3); // $ExpectType PCancelable +pEvent(new DomEmitter(), 'finish'); // $ExpectType PCancelable +pEvent(document, 'DOMContentLoaded'); // $ExpectType PCancelable + +pEvent(new NodeEmitter(), 'finish', { rejectionEvents: ['error'] }); // $ExpectType PCancelable +pEvent(new NodeEmitter(), 'finish', { timeout: 1 }); // $ExpectType PCancelable +pEvent(new NodeEmitter(), 'finish', { filter: value => value > 3 }); // $ExpectType PCancelable +pEvent(new NodeEmitter(), 'finish', { multiArgs: true }); // $ExpectType PCancelable<(string | number)[]> + +pEvent(new NodeEmitter(), 'finish').cancel(); + +// $ExpectType PCancelable +pEvent.multiple(new NodeEmitter(), 'hello', { + count: Infinity, +}); +// $ExpectType PCancelable +pEvent.multiple(new NodeEmitter(), 'hello', { + resolveImmediately: true, + count: Infinity, +}); +// $ExpectType PCancelable<(string | number)[][]> +pEvent.multiple(new NodeEmitter(), 'hello', { + count: Infinity, + multiArgs: true, +}); +// $ExpectError +pEvent.multiple(new NodeEmitter(), 'hello', {}); +// $ExpectError +pEvent.multiple(new NodeEmitter(), 'hello'); + +pEvent.iterator(new NodeEmitter(), 'finish'); // $ExpectType AsyncIterableIterator +pEvent.iterator(new NodeEmitter(), '🦄', value => value > 3); // $ExpectType AsyncIterableIterator + +pEvent.iterator(new NodeEmitter(), 'finish', { limit: 1 }); // $ExpectType AsyncIterableIterator +pEvent.iterator(new NodeEmitter(), 'finish', { resolutionEvents: ['finish'] }); // $ExpectType AsyncIterableIterator +pEvent.iterator(new NodeEmitter(), 'finish', { multiArgs: true }); // $ExpectType AsyncIterableIterator<(string | number)[]> + +async function getOpenReadStream(file: string) { + const stream = fs.createReadStream(file); + await pEvent(stream, 'open'); + return stream; +} + +(async () => { + const stream = await getOpenReadStream('unicorn.txt'); + stream.pipe(process.stdout); +})().catch(console.error); + +(async () => { + try { + const result = await pEvent(new NodeEmitter(), 'finish'); + + if (result === 1) { + throw new Error('Emitter finished with an error'); + } + + // `emitter` emitted a `finish` event with an acceptable value + console.log(result); + } catch (error) { + // `emitter` emitted an `error` event or + // emitted a `finish` with 'unwanted result' + console.error(error); + } +})(); diff --git a/types/p-event/tsconfig.json b/types/p-event/tsconfig.json new file mode 100644 index 0000000000..dfde34c0e1 --- /dev/null +++ b/types/p-event/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es2016", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "p-event-tests.ts" + ] +} diff --git a/types/p-event/tslint.json b/types/p-event/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/p-event/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 64851f4edda640ad6a5025bde5c27b6b6a21b8e7 Mon Sep 17 00:00:00 2001 From: Noel Martin Llevares Date: Mon, 25 Feb 2019 11:55:28 +1100 Subject: [PATCH 138/222] Add numTodoTests to AggregatedResult. --- types/jest/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index f0382d2cb5..e8b9878040 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -1625,6 +1625,7 @@ declare namespace jest { numPendingTests: number; numPendingTestSuites: number; numRuntimeErrorTestSuites: number; + numTodoTests: number; numTotalTests: number; numTotalTestSuites: number; snapshot: SnapshotSummary; From 1293fcfe4cb007937934fec6ddb3df59c02588f2 Mon Sep 17 00:00:00 2001 From: "Adam A. Zerella" Date: Mon, 25 Feb 2019 16:29:22 +1100 Subject: [PATCH 139/222] Added type defs for complex.js --- types/complex.js/complex.js-tests.ts | 61 ++++++ types/complex.js/index.d.ts | 304 +++++++++++++++++++++++++++ types/complex.js/tsconfig.json | 25 +++ types/complex.js/tslint.json | 3 + 4 files changed, 393 insertions(+) create mode 100644 types/complex.js/complex.js-tests.ts create mode 100644 types/complex.js/index.d.ts create mode 100644 types/complex.js/tsconfig.json create mode 100644 types/complex.js/tslint.json diff --git a/types/complex.js/complex.js-tests.ts b/types/complex.js/complex.js-tests.ts new file mode 100644 index 0000000000..0edef20998 --- /dev/null +++ b/types/complex.js/complex.js-tests.ts @@ -0,0 +1,61 @@ +import Complex from "complex.js"; + +Complex.ZERO; +Complex.PI; +Complex.E; +Complex.I; +Complex.INFINITY; +Complex.EPSILON; +Complex.ONE; +Complex.NAN; + +new Complex(1, 0); +new Complex(1, 0).abs(); +new Complex(1, 0).acos(); +new Complex(1, 0).acot(); +new Complex(1, 0).acoth(); +new Complex(1, 0).acsc(); +new Complex(1, 0).acsch(); +new Complex(1, 0).add(1, 2); +new Complex(1, 0).arg(); +new Complex(1, 0).asec(); +new Complex(1, 0).asech(); +new Complex(1, 0).asin(); +new Complex(1, 0).asinh(); +new Complex(1, 0).atan(); +new Complex(1, 0).atanh(); +new Complex(1, 0).ceil(5); +new Complex(1, 0).clone(); +new Complex(1, 0).conjugate(); +new Complex(1, 0).cos(); +new Complex(1, 0).cosh(); +new Complex(1, 0).cot(); +new Complex(1, 0).coth(); +new Complex(1, 0).csc(); +new Complex(1, 0).csch(); +new Complex(1, 0).div(3, 1); +new Complex(1, 0).equals(5, 3); +new Complex(1, 0).exp(); +new Complex(1, 0).floor(6); +new Complex(1, 0).inverse(); +new Complex(1, 0).isFinite(); +new Complex(1, 0).isInfinite(); +new Complex(1, 0).isNaN(); +new Complex(1, 0).isZero(); +new Complex(1, 0).log(); +new Complex(1, 0).mul(3, 1); +new Complex(1, 0).neg(); +new Complex(1, 0).pow(1, 2); +new Complex(1, 0).round(3); +new Complex(1, 0).sec(); +new Complex(1, 0).sech(); +new Complex(1, 0).sign(); +new Complex(1, 0).sin(); +new Complex(1, 0).sinh(); +new Complex(1, 0).sqrt(); +new Complex(1, 0).sub(5, 1); +new Complex(1, 0).tan(); +new Complex(1, 0).tanh(); +new Complex(1, 0).toString(); +new Complex(1, 0).toVector(); +new Complex(1, 0).valueOf(); diff --git a/types/complex.js/index.d.ts b/types/complex.js/index.d.ts new file mode 100644 index 0000000000..487fc4e30d --- /dev/null +++ b/types/complex.js/index.d.ts @@ -0,0 +1,304 @@ +// Type definitions for complex.js 2.0 +// Project: https://github.com/infusion/Complex.js +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class Complex { + /** + * A complex zero value (south pole on the Riemann Sphere). + */ + static ZERO: Complex; + + /** + * A complex one instance. + */ + static ONE: Complex; + + /** + * A complex infinity value (north pole on the Riemann Sphere). + */ + static INFINITY: Complex; + + /** + * A complex NaN value (not on the Riemann Sphere). + */ + static NAN: Complex; + + /** + * An imaginary number i instance. + */ + static I: Complex; + + /** + * A complex PI instance. + */ + static PI: Complex; + + /** + * A complex euler number instance. + */ + static E: Complex; + + /** + * A small epsilon value used for equals() comparison in order to circumvent double inprecision. + */ + static EPSILON: number; + + constructor(x: number, y: number); + + /** + * Returns the complex sign, defined as the complex number + * normalized by it's absolute value. + */ + sign(): Complex; + + /** + * Adds another complex number. + */ + add(a: number, b: number): Complex; + + /** + * Subtracts another complex number. + */ + sub(a: number, b: number): Complex; + + /** + * Multiplies the number with another complex number. + */ + mul(a: number, b: number): Complex; + + /** + * Divides the number by another complex number. + */ + div(a: number, b: number): Complex; + + /** + * Returns the number raised to the complex exponent. + */ + pow(a: number, b: number): Complex; + + /** + * Returns the complex square root of the number. + */ + sqrt(): Complex; + + /** + * Returns e^n with complex exponent n + */ + exp(): Complex; + + /** + * Returns the natural logarithm (base E) of the actual complex number. + */ + log(): Complex; + + /** + * Calculates the magnitude of the complex number. + */ + abs(): number; + + /** + * Calculate the angle of the complex number. + */ + arg(): number; + + /** + * Calculates the multiplicative inverse of the complex number (1 / z). + */ + inverse(): Complex; + + /** + * Calculates the conjugate of the complex number (multiplies the imaginary part with -1). + */ + conjugate(): Complex; + + /** + * Negates the number (multiplies both the real and imaginary part with -1) in order to get the additive inverse. + */ + neg(): Complex; + + /** + * Floors the complex number parts towards zero. + */ + floor(places: number): Complex; + + /** + * Ceils the complex number parts off zero. + */ + ceil(places: number): Complex; + + /** + * Rounds the complex number parts. + */ + round(places: number): Complex; + + /** + * Checks if both numbers are exactly the same, + * if both numbers are infinite they are considered not equal. + */ + equals(a: number, b: number): boolean; + + /** + * Checks if the given number is not a number. + */ + isNaN(): boolean; + + /** + * Determines whether or not a complex number is at the zero pole of the + * Riemann sphere. + */ + isZero(): boolean; + + /** + * Checks if the given number is finite. + */ + isFinite(): boolean; + + /** + * Determines whether or not a complex number is at the infinity pole of the + * Riemann sphere. + */ + isInfinite(): boolean; + + /** + * Returns a new Complex instance with the same real and imaginary properties. + */ + clone(): Complex; + + /** + * Returns a Vector of the actual complex number with two components. + */ + toVector(): number[]; + + /** + * Returns a string representation of the actual number. As of v1.9.0 the output is a bit more human readable. + */ + toString(): string; + + /** + * Returns the real part of the number if imaginary part is zero. Otherwise null. + */ + valueOf(): number|undefined; + + /** + * Calculate the sine of the complex number. + */ + sin(): Complex; + + /** + * Calculate the complex arcus sinus. + */ + asin(): Complex; + + /** + * Calculate the complex sinh. + */ + sinh(): Complex; + + /** + * Calculate the complex asinh. + */ + asinh(): Complex; + + /** + * Calculate the cosine. + */ + cos(): Complex; + + /** + * Calculate the complex arcus cosinus. + */ + acos(): Complex; + + /** + * Calculate the complex cosh. + */ + cosh(): Complex; + + /** + * Calculate the complex asinh. + */ + acosh(): Complex; + + /** + * Calculate the tangent. + */ + tan(): Complex; + + /** + * Calculate the complex arcus tangent. + */ + atan(): Complex; + + /** + * Calculate the complex tanh. + */ + tanh(): Complex; + + /** + * Calculate the complex atanh. + */ + atanh(): Complex; + + /** + * Calculate the cotangent. + */ + cot(): Complex; + + /** + * Calculate the complex arcus cotangent. + */ + acot(): Complex; + + /** + * Calculate the complex coth. + */ + coth(): Complex; + + /** + * Calculate the complex acoth. + */ + acoth(): Complex; + + /** + * Calculate the secant. + */ + sec(): Complex; + + /** + * Calculate the complex arcus secant. + */ + asec(): Complex; + + /** + * Calculate the complex sech. + */ + sech(): Complex; + + /** + * Calculate the complex asech. + */ + asech(): Complex; + + /** + * Calculate the cosecans. + */ + csc(): Complex; + + /** + * Calculate the complex arcus cosecans. + */ + acsc(): Complex; + + /** + * Calculate the complex csch. + */ + csch(): Complex; + + /** + * Calculate the complex acsch. + */ + acsch(): Complex; +} + +export default Complex; diff --git a/types/complex.js/tsconfig.json b/types/complex.js/tsconfig.json new file mode 100644 index 0000000000..b4af58b032 --- /dev/null +++ b/types/complex.js/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "complex.js-tests.ts" + ] +} diff --git a/types/complex.js/tslint.json b/types/complex.js/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/complex.js/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From e1e28b2afcff810eb7edb48a92e2841de1637993 Mon Sep 17 00:00:00 2001 From: maruware Date: Mon, 25 Feb 2019 19:38:06 +0900 Subject: [PATCH 140/222] Fix gt, gte, lt, lte arg type. --- types/koa-bouncer/index.d.ts | 8 ++++---- types/koa-bouncer/koa-bouncer-tests.ts | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/types/koa-bouncer/index.d.ts b/types/koa-bouncer/index.d.ts index af3a8b6693..91b4973893 100644 --- a/types/koa-bouncer/index.d.ts +++ b/types/koa-bouncer/index.d.ts @@ -30,10 +30,10 @@ declare namespace KoaBouncer { isNotIn(arr: any[], tip?: string): Validator isArray(tip?: string): Validator eq(otherVal: string, tip?: string): Validator - gt(otherVal: string, tip?: string): Validator - gte(otherVal: string, tip?: string): Validator - lt(otherVal: string, tip?: string): Validator - lte(otherVal: string, tip?: string): Validator + gt(otherVal: number, tip?: string): Validator + gte(otherVal: number, tip?: string): Validator + lt(otherVal: number, tip?: string): Validator + lte(otherVal: number, tip?: string): Validator isLength(min: number, max: number, tip?: string): Validator defaultTo(valueOrFunction: any): Validator isString(tip?: string): Validator diff --git a/types/koa-bouncer/koa-bouncer-tests.ts b/types/koa-bouncer/koa-bouncer-tests.ts index 0f91658a85..05f84e1b21 100644 --- a/types/koa-bouncer/koa-bouncer-tests.ts +++ b/types/koa-bouncer/koa-bouncer-tests.ts @@ -29,6 +29,9 @@ router.post('/users', async (ctx) => { .isString() .eq(ctx.vals.password1, 'Passwords must match') + ctx.validateBody('age') + .gte(18, 'Must be 18 or older') + console.log(ctx.vals) }) From 918506e97b362ad8989abfa900f3d0558114e3e4 Mon Sep 17 00:00:00 2001 From: Sebastian Markgraf Date: Mon, 25 Feb 2019 13:40:08 +0100 Subject: [PATCH 141/222] Add typing for scrollparentjs 2.0 --- types/scrollparent/index.d.ts | 8 ++++++++ types/scrollparent/scrollparent-tests.tsx | 6 ++++++ types/scrollparent/tsconfig.json | 24 +++++++++++++++++++++++ types/scrollparent/tslint.json | 1 + 4 files changed, 39 insertions(+) create mode 100644 types/scrollparent/index.d.ts create mode 100644 types/scrollparent/scrollparent-tests.tsx create mode 100644 types/scrollparent/tsconfig.json create mode 100644 types/scrollparent/tslint.json diff --git a/types/scrollparent/index.d.ts b/types/scrollparent/index.d.ts new file mode 100644 index 0000000000..7a3ffd1e8b --- /dev/null +++ b/types/scrollparent/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for scrollparent 2.0 +// Project: https://github.com/olahol/scrollparent.js#readme +// Definitions by: Sintifo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function scrollparent(node: HTMLElement | SVGElement): HTMLElement | null; + +export = scrollparent; diff --git a/types/scrollparent/scrollparent-tests.tsx b/types/scrollparent/scrollparent-tests.tsx new file mode 100644 index 0000000000..8135f76369 --- /dev/null +++ b/types/scrollparent/scrollparent-tests.tsx @@ -0,0 +1,6 @@ +import scrollparent = require("scrollparent"); + +const elem = document.getElementById("content"); +if (elem) { + scrollparent(elem); +} diff --git a/types/scrollparent/tsconfig.json b/types/scrollparent/tsconfig.json new file mode 100644 index 0000000000..3737fe4c05 --- /dev/null +++ b/types/scrollparent/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "scrollparent-tests.tsx" + ] +} diff --git a/types/scrollparent/tslint.json b/types/scrollparent/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/scrollparent/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 7504813dcca8d81910286a9465b17d0b5b247af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Baumeyer?= Date: Mon, 25 Feb 2019 14:28:56 +0100 Subject: [PATCH 142/222] Fix mangopay2-nodejs-sdk types --- types/mangopay2-nodejs-sdk/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/mangopay2-nodejs-sdk/index.d.ts b/types/mangopay2-nodejs-sdk/index.d.ts index 516f1c44f9..78629b7232 100644 --- a/types/mangopay2-nodejs-sdk/index.d.ts +++ b/types/mangopay2-nodejs-sdk/index.d.ts @@ -1774,7 +1774,7 @@ declare namespace MangoPay { /** * This is the URL where to redirect users to proceed to 3D secure validation */ - SecureModeRedirectUrl: string; + SecureModeRedirectURL: string; /** * This is the URL where users are automatically redirected after 3D secure validation (if activated) @@ -2596,7 +2596,7 @@ declare namespace MangoPay { /** * This is the URL where to redirect users to proceed to 3D secure validation */ - SecureModeRedirectUrl: string; + SecureModeRedirectURL: string; } interface CreateCardDirectPayIn { From b1e0b3e7562297616b558f0edf13a05d7f737bfa Mon Sep 17 00:00:00 2001 From: Artur Kozak Date: Mon, 25 Feb 2019 15:08:05 +0100 Subject: [PATCH 143/222] Complete typings for ethereumjs-abi --- types/ethereumjs-abi/ethereumjs-abi-tests.ts | 20 ++++++++++++++++---- types/ethereumjs-abi/index.d.ts | 11 ++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/types/ethereumjs-abi/ethereumjs-abi-tests.ts b/types/ethereumjs-abi/ethereumjs-abi-tests.ts index f48cdd323c..28626b6304 100644 --- a/types/ethereumjs-abi/ethereumjs-abi-tests.ts +++ b/types/ethereumjs-abi/ethereumjs-abi-tests.ts @@ -1,5 +1,17 @@ -import { methodID, soliditySHA256, soliditySHA3 } from 'ethereumjs-abi'; +import * as abi from 'ethereumjs-abi'; -methodID('foo', ['uint256', 'string']); -soliditySHA3(['uint256', 'string'], [0, 'Alice']); -soliditySHA256(['uint256', 'string'], [0, 'Alice']); +const types = ['uint256', 'string']; +const values = [0, 'Alice']; +const signature = 'foo(uint256,string):(uint256)'; +abi.eventID('foo', types); +abi.methodID('foo', types); +abi.soliditySHA3(types, values); +abi.soliditySHA256(types, values); +abi.solidityRIPEMD160(types, values); +const simpleEncoded = abi.simpleEncode(signature, ...values); +abi.simpleDecode(signature, simpleEncoded); +const rawEncoded = abi.rawEncode(types, values); +abi.rawDecode(types, rawEncoded); +abi.solidityPack(types, values); +const serpentSig = abi.toSerpent(['int256', 'bytes']); +abi.fromSerpent(serpentSig); diff --git a/types/ethereumjs-abi/index.d.ts b/types/ethereumjs-abi/index.d.ts index 98ea94a6fa..6380068984 100644 --- a/types/ethereumjs-abi/index.d.ts +++ b/types/ethereumjs-abi/index.d.ts @@ -1,12 +1,21 @@ // Type definitions for ethereumjs-abi 0.6 // Project: https://github.com/ethereumjs/ethereumjs-abi, https://github.com/axic/ethereumjs-abi // Definitions by: Leonid Logvinov +// Artur Kozak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// export function soliditySHA3(argTypes: string[], args: any[]): Buffer; export function soliditySHA256(argTypes: string[], args: any[]): Buffer; +export function solidityRIPEMD160(argTypes: string[], args: any[]): Buffer; +export function eventID(name: string, types: string[]): Buffer; export function methodID(name: string, types: string[]): Buffer; export function simpleEncode(signature: string, ...args: any[]): Buffer; -export function rawDecode(signature: string[], data: Buffer): any[]; +export function simpleDecode(signature: string, data: Buffer): any[]; +export function rawEncode(types: string[], values: any[]): Buffer; +export function rawDecode(types: string[], data: Buffer): any[]; +export function stringify(types: string[], values: any[]): string; +export function solidityPack(types: string[], values: any[]): Buffer; +export function fromSerpent(signature: string): string[]; +export function toSerpent(types: string[]): string; From f4cc3df1cc25a28b6957818d836d0f0fd2bb1417 Mon Sep 17 00:00:00 2001 From: Drew Wyatt Date: Mon, 25 Feb 2019 10:04:59 -0500 Subject: [PATCH 144/222] flipped order of args in adjust --- types/ramda/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 2c21363b1a..e1b1f21334 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -473,8 +473,8 @@ declare namespace R { * Applies a function to the value at the given index of an array, returning a new copy of the array with the * element at the given index replaced with the result of the function application. */ - adjust(fn: (a: T) => T, index: number, list: ReadonlyArray): T[]; - adjust(fn: (a: T) => T, index: number): (list: ReadonlyArray) => T[]; + adjust(index: number, fn: (a: T) => T, list: ReadonlyArray): T[]; + adjust(index: number, fn: (a: T) => T): (list: ReadonlyArray) => T[]; /** * Returns true if all elements of the list match the predicate, false if there are any that don't. From b4c25760ecdb41156eafebee40482a33842d3739 Mon Sep 17 00:00:00 2001 From: "Roman Nuritdinov (Ky6uk)" Date: Mon, 25 Feb 2019 17:46:42 +0200 Subject: [PATCH 145/222] Add decorator support for react-click-outside --- types/react-click-outside/index.d.ts | 3 ++- .../react-click-outside-tests.tsx | 14 ++++++++++++++ types/react-click-outside/tsconfig.json | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/types/react-click-outside/index.d.ts b/types/react-click-outside/index.d.ts index c09dccb155..3684c87484 100644 --- a/types/react-click-outside/index.d.ts +++ b/types/react-click-outside/index.d.ts @@ -1,11 +1,12 @@ // Type definitions for react-click-outside 3.0 // Project: https://github.com/kentor/react-click-outside // Definitions by: Christian Rackerseder +// Roman Nuritdinov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; -declare function enhanceWithClickOutside

      (wrappedComponent: React.ComponentClass

      ): React.ComponentClass

      ; +declare function enhanceWithClickOutside>(wrappedComponent: C): C; declare namespace enhanceWithClickOutside { } export = enhanceWithClickOutside; diff --git a/types/react-click-outside/react-click-outside-tests.tsx b/types/react-click-outside/react-click-outside-tests.tsx index d51516281e..fe8e7af110 100644 --- a/types/react-click-outside/react-click-outside-tests.tsx +++ b/types/react-click-outside/react-click-outside-tests.tsx @@ -22,6 +22,20 @@ class StatefulComponent extends React.Component { } } +@enhanceWithClickOutside +class ComponentWithDecorator extends React.Component { + state = { isOpened: true }; + + handleClickOutside() { + this.setState({ isOpened: false }); + } + + render() { + return

      {this.props.text}
      ; + } +} + const ClickOutsideStatefulComponent = enhanceWithClickOutside(StatefulComponent); render(, document.getElementById('test')); +render(, document.getElementById('test')); diff --git a/types/react-click-outside/tsconfig.json b/types/react-click-outside/tsconfig.json index caf91fdc1d..68d52cdab4 100644 --- a/types/react-click-outside/tsconfig.json +++ b/types/react-click-outside/tsconfig.json @@ -16,10 +16,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "experimentalDecorators": true }, "files": [ "index.d.ts", "react-click-outside-tests.tsx" ] -} \ No newline at end of file +} From df31a02f0005cdee2f620d7c18c768c6c6e3ac2d Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 25 Feb 2019 16:48:31 +0100 Subject: [PATCH 146/222] Add helper PropsWithChildren --- types/react/index.d.ts | 8 +++++--- types/react/test/index.ts | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 97adab18d4..f7b7310d7d 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -468,7 +468,7 @@ declare namespace React { type FC

      = FunctionComponent

      ; interface FunctionComponent

      { - (props: P & { children?: ReactNode }, context?: any): ReactElement | null; + (props: PropsWithChildren

      , context?: any): ReactElement | null; propTypes?: WeakValidationMap

      ; contextTypes?: ValidationMap; defaultProps?: Partial

      ; @@ -476,7 +476,7 @@ declare namespace React { } interface RefForwardingComponent { - (props: P & { children?: ReactNode }, ref: Ref): ReactElement | null; + (props: PropsWithChildren

      , ref: Ref): ReactElement | null; propTypes?: WeakValidationMap

      ; contextTypes?: ValidationMap; defaultProps?: Partial

      ; @@ -722,6 +722,8 @@ declare namespace React { : P : P; + type PropsWithChildren

      = P & { children?: ReactNode }; + /** * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded, * or ComponentPropsWithoutRef when refs are not supported. @@ -747,7 +749,7 @@ declare namespace React { function memo

      ( Component: SFC

      , - propsAreEqual?: (prevProps: Readonly

      , nextProps: Readonly

      ) => boolean + propsAreEqual?: (prevProps: Readonly>, nextProps: Readonly>) => boolean ): NamedExoticComponent

      ; function memo>( Component: T, diff --git a/types/react/test/index.ts b/types/react/test/index.ts index d4fee49d30..fffde44f52 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -13,6 +13,7 @@ import TransitionGroup = require("react-addons-transition-group"); import update = require("react-addons-update"); import createReactClass = require("create-react-class"); import * as DOM from "react-dom-factories"; +import { PropsWithChildren } from '../index'; // NOTE: forward declarations for tests declare function setInterval(...args: any[]): any; @@ -803,3 +804,9 @@ const sfc: React.SFC = Memoized2; // this $ExpectError is failing on TypeScript@next // // $ExpectError Property '$$typeof' is missing in type // const specialSfc2: React.SpecialSFC = props => null; + +const propsWithChildren: PropsWithChildren = { + hello: "world", + foo: 42, + children: functionComponent, +}; From 9698a7d79585db53425dde2e1461647721a26d43 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 25 Feb 2019 16:56:10 +0100 Subject: [PATCH 147/222] [p-queue] Update types to v3.1 --- types/p-queue/index.d.ts | 102 +++++++++++++++++++++++++-------- types/p-queue/p-queue-tests.ts | 42 +++++++------- 2 files changed, 99 insertions(+), 45 deletions(-) diff --git a/types/p-queue/index.d.ts b/types/p-queue/index.d.ts index 10c1179815..96fda8426a 100644 --- a/types/p-queue/index.d.ts +++ b/types/p-queue/index.d.ts @@ -1,45 +1,56 @@ -// Type definitions for p-queue 3.0 +// Type definitions for p-queue 3.1 // Project: https://github.com/sindresorhus/p-queue#readme // Definitions by: BendingBender // Evan Shortiss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 + +/// + +import { EventEmitter } from 'events'; export = PQueue; -declare class PQueue { +/** + * Promise queue with concurrency control. + */ +declare class PQueue< + TEnqueueOptions extends PQueue.QueueAddOptions = PQueue.DefaultAddOptions +> extends EventEmitter { /** * Size of the queue. */ - size: number; + readonly size: number; /** * Number of pending promises. */ - pending: number; + readonly pending: number; /** * Whether the queue is currently paused. */ - isPaused: boolean; + readonly isPaused: boolean; - constructor(opts?: PQueue.Options); + constructor(opts?: PQueue.Options); /** - * Returns the promise returned by calling fn. + * Adds a sync or async task to the queue. Always returns a promise. * @param fn Promise-returning/async function. + * @param opts */ - add(fn: PQueue.Task, opts?: O): Promise; + add(fn: PQueue.Task, opts?: TEnqueueOptions): Promise; /** - * Same as .add(), but accepts an array of async functions and - * returns a promise that resolves when all async functions are resolved. + * Same as `.add()`, but accepts an array of sync or async functions + * and returns a promise that resolves when all functions are resolved. * @param fn Array of Promise-returning/async functions. */ - addAll(fns: Array>, opts?: O): Promise; + addAll(fns: Array>, opts?: TEnqueueOptions): Promise; /** * Returns a promise that settles when the queue becomes empty. + * * Can be called multiple times. Useful if you for example add * additional items at a later time. */ @@ -47,17 +58,18 @@ declare class PQueue; /** * Start (or resume) executing enqueued tasks within concurrency limit. - * No need to call this if queue is not paused (via options.autoStart = false - * or by .pause() method.) + * No need to call this if queue is not paused + * (via `options.autoStart = false` or by `.pause()` method.) */ start(): void; @@ -70,6 +82,20 @@ declare class PQueue void): this; + on(event: 'active', listener: () => void): this; + once(event: 'active', listener: () => void): this; + prependListener(event: 'active', listener: () => void): this; + prependOnceListener(event: 'active', listener: () => void): this; + removeListener(event: 'active', listener: () => void): this; + off(event: 'active', listener: () => void): this; + removeAllListeners(event?: 'active'): this; + listeners(event: 'active'): Array<() => void>; + rawListeners(event: 'active'): Array<() => void>; + emit(event: 'active'): boolean; + eventNames(): Array<'active'>; + listenerCount(type: 'active'): number; } declare namespace PQueue { @@ -77,30 +103,58 @@ declare namespace PQueue { [key: string]: any; } - interface QueueClassConstructor { - new(): QueueClass; + interface QueueClassConstructor { + new (): QueueClass; } - interface QueueClass { + interface QueueClass { size: number; - enqueue(run: () => void, options?: O): void; + enqueue(run: () => void, options?: TEnqueueOptions): void; dequeue(): (() => void) | undefined; } - interface Options { + interface Options { + /** + * Concurrency limit. Minimum: `1`. + * @default Infinity + */ concurrency?: number; + /** + * Whether queue tasks within concurrency limit, are auto-executed as soon as they're added. + * @default true + */ autoStart?: boolean; - queueClass?: QueueClassConstructor; + /** + * Class with a `enqueue` and `dequeue` method, and a `size` getter. See the + * [Custom QueueClass](https://github.com/sindresorhus/p-queue#custom-queueclass) section. + */ + queueClass?: QueueClassConstructor; + /** + * The max number of runs in the given interval of time. Minimum: `1`. + * @default Infinity + */ intervalCap?: number; + /** + * The length of time in milliseconds before the interval count resets. Must be finite. Minimum: `0`. + * @default 0 + */ interval?: number; + /** + * Whether the task must finish in the given interval or will be carried over into the next interval count. + * @default false + */ carryoverConcurrencyCount?: boolean; } interface DefaultAddOptions { + /** + * Priority of operation. Operations with greater priority will be scheduled first. + * @default 0 + */ priority?: number; } - type Task = () => Promise; + type Task = (() => PromiseLike) | (() => T); } diff --git a/types/p-queue/p-queue-tests.ts b/types/p-queue/p-queue-tests.ts index e12723a7d4..4ce6fbb13e 100644 --- a/types/p-queue/p-queue-tests.ts +++ b/types/p-queue/p-queue-tests.ts @@ -1,31 +1,31 @@ import PQueue = require('p-queue'); -const queue = new PQueue({concurrency: 1}); +const queue = new PQueue({ concurrency: 1 }); +new PQueue({ autoStart: false }); +new PQueue({ intervalCap: 1 }); +new PQueue({ interval: 0 }); +new PQueue({ carryoverConcurrencyCount: true }); -queue.add(() => Promise.resolve('sindresorhus.com')).then((sindre) => { - const str: string = sindre; -}); +queue.add(() => Promise.resolve('sindresorhus.com')); // $ExpectType Promise +queue.add(() => 'sindresorhus.com'); // $ExpectType Promise +queue.add(() => 'sindresorhus.com', { priority: 1 }); // $ExpectType Promise -queue.addAll([() => Promise.resolve('oh'), () => Promise.resolve('hi')]).then(r => { - r.indexOf('h'); -}); +queue.addAll([() => Promise.resolve('oh'), () => 'hi']); // $ExpectType Promise +queue.addAll([() => Promise.resolve('oh'), () => 1]); // $ExpectType Promise<(string | number)[]> +queue.addAll([() => Promise.resolve('oh'), () => 'hi'], { priority: 1 }); // $ExpectType Promise -Promise.resolve((): Promise => Promise.resolve('unicorn')) - .then(task => queue.add(task, {priority: 5})) - .then(unicorn => { - const str: string = unicorn; - }); - -queue.onEmpty().then(() => {}); -queue.onIdle().then(() => {}); +queue.onEmpty(); // $ExpectType Promise +queue.onIdle(); // $ExpectType Promise queue.start(); queue.pause(); queue.clear(); -let num: number; -num = queue.size; -num = queue.pending; -const paused = queue.isPaused; +queue.size; // $ExpectType number +queue.size = 1; // $ExpectError +queue.pending; // $ExpectType number +queue.pending = 5; // $ExpectError +queue.isPaused; // $ExpectType boolean +queue.isPaused = true; // $ExpectError class QueueClass implements PQueue.QueueClass<{ any: string }> { private readonly queue: Array<() => void>; @@ -45,5 +45,5 @@ class QueueClass implements PQueue.QueueClass<{ any: string }> { } } -const queue2 = new PQueue({queueClass: QueueClass}); -queue2.add(() => Promise.resolve(), {any: 'hi'}); +const queue2 = new PQueue({ queueClass: QueueClass }); +queue2.add(() => Promise.resolve(), { any: 'hi' }); From b5200f6fb7cccddadd4d17870aa53b8b5bd1198d Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 25 Feb 2019 17:46:39 +0100 Subject: [PATCH 148/222] Add for component --- types/react/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index f7b7310d7d..2a046f91b8 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -422,7 +422,7 @@ declare namespace React { // always pass children as variadic arguments to `createElement`. // In the future, if we can define its call signature conditionally // on the existence of `children` in `P`, then we should remove this. - readonly props: Readonly<{ children?: ReactNode }> & Readonly

      ; + readonly props: Readonly>; state: Readonly; /** * @deprecated From 81ef7909e02e1219e99e58c225743948c739fb16 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 25 Feb 2019 17:49:18 +0100 Subject: [PATCH 149/222] [ora] Update types to v3.1 --- types/ora/index.d.ts | 17 ++++++++++++++++- types/ora/ora-tests.ts | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/types/ora/index.d.ts b/types/ora/index.d.ts index 08a1946c5d..13104b0b5c 100644 --- a/types/ora/index.d.ts +++ b/types/ora/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ora 3.0 +// Type definitions for ora 3.1 // Project: https://github.com/sindresorhus/ora // Definitions by: Basarat Ali Syed // Christian Rackerseder @@ -45,6 +45,16 @@ declare namespace ora { */ color: Color; + /** + * Change the spinner. + */ + spinner: SpinnerName | Spinner; + + /** + * Change the spinner indent. + */ + indent: number; + /** * Start the spinner. * @@ -149,6 +159,11 @@ declare namespace ora { * @default true */ hideCursor?: boolean; + /** + * Indent the spinner with the given number of spaces. + * @default 0 + */ + indent?: number; /** * Interval between each frame. * diff --git a/types/ora/ora-tests.ts b/types/ora/ora-tests.ts index 2c1b8ee82d..4e06c11248 100644 --- a/types/ora/ora-tests.ts +++ b/types/ora/ora-tests.ts @@ -9,6 +9,7 @@ ora({ spinner: { interval: 80, frames: ['-', '+', '-'] } }); ora({ color: 'cyan' }); ora({ color: 'foo' }); // $ExpectError ora({ hideCursor: true }); +ora({ indent: 1 }); ora({ interval: 80 }); ora({ stream: new PassThrough() }); ora({ isEnabled: true }); @@ -17,6 +18,8 @@ spinner.color = 'yellow'; spinner.text = 'Loading rainbows'; spinner.isSpinning; // $ExpectType boolean spinner.isSpinning = true; // $ExpectError +spinner.spinner = 'dots'; +spinner.indent = 5; spinner.start(); spinner.start('Test text'); From c5c72bcb9b74c69427083f1c2c211c6319838e44 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 25 Feb 2019 17:59:27 +0100 Subject: [PATCH 150/222] [onetime] Move old types to sub-dir --- types/onetime/{ => v2}/index.d.ts | 0 types/onetime/{ => v2}/onetime-tests.ts | 0 types/onetime/{ => v2}/tsconfig.json | 11 ++++++++--- types/onetime/{ => v2}/tslint.json | 0 4 files changed, 8 insertions(+), 3 deletions(-) rename types/onetime/{ => v2}/index.d.ts (100%) rename types/onetime/{ => v2}/onetime-tests.ts (100%) rename types/onetime/{ => v2}/tsconfig.json (74%) rename types/onetime/{ => v2}/tslint.json (100%) diff --git a/types/onetime/index.d.ts b/types/onetime/v2/index.d.ts similarity index 100% rename from types/onetime/index.d.ts rename to types/onetime/v2/index.d.ts diff --git a/types/onetime/onetime-tests.ts b/types/onetime/v2/onetime-tests.ts similarity index 100% rename from types/onetime/onetime-tests.ts rename to types/onetime/v2/onetime-tests.ts diff --git a/types/onetime/tsconfig.json b/types/onetime/v2/tsconfig.json similarity index 74% rename from types/onetime/tsconfig.json rename to types/onetime/v2/tsconfig.json index 84d3da86b8..bda103d103 100644 --- a/types/onetime/tsconfig.json +++ b/types/onetime/v2/tsconfig.json @@ -8,10 +8,15 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "baseUrl": "../", + "baseUrl": "../../", "typeRoots": [ - "../" + "../../" ], + "paths": { + "onetime": [ + "onetime/v2" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -20,4 +25,4 @@ "index.d.ts", "onetime-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/onetime/tslint.json b/types/onetime/v2/tslint.json similarity index 100% rename from types/onetime/tslint.json rename to types/onetime/v2/tslint.json From 380ff1725213e2e4674d2d7ebd2762958d0bff39 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 25 Feb 2019 09:23:07 -0800 Subject: [PATCH 151/222] Two more cleanup items 1. Transducers-js' tests incorrectly assumed that tuple types were inferred from array literals. Added an annotation. 2. zipkin-context-cls and zipkin-transport-http both depend on zipkin, which requires either dom or node's Console to be defined. Added `lib: "dom"` in both tsconfigs. --- types/transducers-js/transducers-js-tests.ts | 4 ++-- types/zipkin-context-cls/tsconfig.json | 5 +++-- types/zipkin-transport-http/tsconfig.json | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/types/transducers-js/transducers-js-tests.ts b/types/transducers-js/transducers-js-tests.ts index 3e69ae06ed..f0f5facf41 100644 --- a/types/transducers-js/transducers-js-tests.ts +++ b/types/transducers-js/transducers-js-tests.ts @@ -161,12 +161,12 @@ function advancedIntoExample() { const string: string = into("", t.map((s: string) => s + s), ["a", "b"]); const object1: { [key: string]: number } = into( {}, - t.map((s: string) => [s, s.length]), + t.map((s: string) => [s, s.length] as [string, number]), ["a", "b"], ); const object2: { [key: string]: boolean } = into( {}, - t.map((kv: [string, number]) => [kv[0], true]), + t.map((kv: [string, number]) => [kv[0], true] as [string, boolean]), { a: 1, b: 2 } ); } diff --git a/types/zipkin-context-cls/tsconfig.json b/types/zipkin-context-cls/tsconfig.json index 57430d50b2..af624fda93 100644 --- a/types/zipkin-context-cls/tsconfig.json +++ b/types/zipkin-context-cls/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, @@ -20,4 +21,4 @@ "index.d.ts", "zipkin-context-cls-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/zipkin-transport-http/tsconfig.json b/types/zipkin-transport-http/tsconfig.json index 7ed663b14b..be30a49dab 100644 --- a/types/zipkin-transport-http/tsconfig.json +++ b/types/zipkin-transport-http/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, @@ -20,4 +21,4 @@ "index.d.ts", "zipkin-transport-http-tests.ts" ] -} \ No newline at end of file +} From 2347afcc47ef0d39d221b9ee404ff16adebefccc Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 25 Feb 2019 18:23:10 +0100 Subject: [PATCH 152/222] [onetime] Update types to v3.0 --- types/onetime/index.d.ts | 45 ++++++++++++++++++++++++++++++++++ types/onetime/onetime-tests.ts | 12 +++++++++ types/onetime/tsconfig.json | 23 +++++++++++++++++ types/onetime/tslint.json | 1 + 4 files changed, 81 insertions(+) create mode 100644 types/onetime/index.d.ts create mode 100644 types/onetime/onetime-tests.ts create mode 100644 types/onetime/tsconfig.json create mode 100644 types/onetime/tslint.json diff --git a/types/onetime/index.d.ts b/types/onetime/index.d.ts new file mode 100644 index 0000000000..f1c6b56ad0 --- /dev/null +++ b/types/onetime/index.d.ts @@ -0,0 +1,45 @@ +// Type definitions for onetime 3.0 +// Project: https://github.com/sindresorhus/onetime#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +export = oneTime; + +/** + * Ensure a function is only called once. When called multiple times it will return the return value from the first call. + * + * @param fn Function that should only be called once. + * @returns A function that only calls `fn` once. + */ +declare function oneTime( + fn: (...args: T) => R, + options?: oneTime.Options +): (...args: T) => R; + +declare namespace oneTime { + /** + * Get the number of times `fn` has been called. + * + * @param fn Function to get call count from. + * @returns A number representing how many times `fn` has been called. + * + * @example + * const foo = onetime(() => {}); + * foo(); + * foo(); + * foo(); + * + * console.log(onetime.callCount(foo)); + * //=> 3 + */ + function callCount(fn: (...args: any[]) => any): number | undefined; + + interface Options { + /** + * Throw an error when called more than once. + * @default false + */ + throw?: boolean; + } +} diff --git a/types/onetime/onetime-tests.ts b/types/onetime/onetime-tests.ts new file mode 100644 index 0000000000..4678eb45db --- /dev/null +++ b/types/onetime/onetime-tests.ts @@ -0,0 +1,12 @@ +import onetime = require('onetime'); + +const foo = onetime(() => 5); +foo(); // $ExpectType number + +const foo2 = onetime(() => true, { throw: true }); +foo2(); // $ExpectType boolean + +onetime((t1: boolean) => 5)(true); // $ExpectType number +onetime((t1: boolean, t2: string) => 5)(true, ''); // $ExpectType number + +onetime.callCount((t1: boolean, t2: string) => 5); // $ExpectType number | undefined diff --git a/types/onetime/tsconfig.json b/types/onetime/tsconfig.json new file mode 100644 index 0000000000..39df78e5bc --- /dev/null +++ b/types/onetime/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", + "onetime-tests.ts" + ] +} diff --git a/types/onetime/tslint.json b/types/onetime/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/onetime/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 339aca728cf3659831a968ddd2a785cf802140d1 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 25 Feb 2019 18:43:44 +0100 Subject: [PATCH 153/222] [screenfull] Move old types to sub-dir --- types/screenfull/{ => v3}/index.d.ts | 0 types/screenfull/{ => v3}/screenfull-tests.ts | 0 types/screenfull/{ => v3}/tsconfig.json | 11 ++++++++--- types/screenfull/{ => v3}/tslint.json | 0 4 files changed, 8 insertions(+), 3 deletions(-) rename types/screenfull/{ => v3}/index.d.ts (100%) rename types/screenfull/{ => v3}/screenfull-tests.ts (100%) rename types/screenfull/{ => v3}/tsconfig.json (74%) rename types/screenfull/{ => v3}/tslint.json (100%) diff --git a/types/screenfull/index.d.ts b/types/screenfull/v3/index.d.ts similarity index 100% rename from types/screenfull/index.d.ts rename to types/screenfull/v3/index.d.ts diff --git a/types/screenfull/screenfull-tests.ts b/types/screenfull/v3/screenfull-tests.ts similarity index 100% rename from types/screenfull/screenfull-tests.ts rename to types/screenfull/v3/screenfull-tests.ts diff --git a/types/screenfull/tsconfig.json b/types/screenfull/v3/tsconfig.json similarity index 74% rename from types/screenfull/tsconfig.json rename to types/screenfull/v3/tsconfig.json index 87cb31765a..0bceb56930 100644 --- a/types/screenfull/tsconfig.json +++ b/types/screenfull/v3/tsconfig.json @@ -9,10 +9,15 @@ "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, - "baseUrl": "../", + "baseUrl": "../../", "typeRoots": [ - "../" + "../../" ], + "paths": { + "screenfull": [ + "screenfull/v3" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -21,4 +26,4 @@ "index.d.ts", "screenfull-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/screenfull/tslint.json b/types/screenfull/v3/tslint.json similarity index 100% rename from types/screenfull/tslint.json rename to types/screenfull/v3/tslint.json From 8ac6e17a4d07e554e1fbd85c2a727c9e46d45a57 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 25 Feb 2019 19:01:35 +0100 Subject: [PATCH 154/222] Fix --- types/react/test/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/react/test/index.ts b/types/react/test/index.ts index fffde44f52..7f8b13a437 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -13,7 +13,6 @@ import TransitionGroup = require("react-addons-transition-group"); import update = require("react-addons-update"); import createReactClass = require("create-react-class"); import * as DOM from "react-dom-factories"; -import { PropsWithChildren } from '../index'; // NOTE: forward declarations for tests declare function setInterval(...args: any[]): any; @@ -805,7 +804,7 @@ const sfc: React.SFC = Memoized2; // // $ExpectError Property '$$typeof' is missing in type // const specialSfc2: React.SpecialSFC = props => null; -const propsWithChildren: PropsWithChildren = { +const propsWithChildren: React.PropsWithChildren = { hello: "world", foo: 42, children: functionComponent, From cffe8746b8f1b1f95bc3b5e0e7f9fdc38420c5da Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 25 Feb 2019 10:06:44 -0800 Subject: [PATCH 155/222] Update connect-datadog project url --- types/connect-datadog/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/connect-datadog/index.d.ts b/types/connect-datadog/index.d.ts index c3aad8aac7..df18c0c208 100644 --- a/types/connect-datadog/index.d.ts +++ b/types/connect-datadog/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for connect-datadog 0.0 -// Project: https://github.com/AppPress/node-connect-datadog +// Project: https://github.com/datadog/node-connect-datadog // Definitions by: Moshe Good // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 From 030a4fe9fea97ad1d44dc8817fae1ec3645ed38f Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 25 Feb 2019 20:12:48 +0100 Subject: [PATCH 156/222] [screenfull] Update types to v4.0 --- types/screenfull/index.d.ts | 85 ++++++++++++++++++++++++++++ types/screenfull/screenfull-tests.ts | 46 +++++++++++++++ types/screenfull/tsconfig.json | 24 ++++++++ types/screenfull/tslint.json | 3 + 4 files changed, 158 insertions(+) create mode 100644 types/screenfull/index.d.ts create mode 100644 types/screenfull/screenfull-tests.ts create mode 100644 types/screenfull/tsconfig.json create mode 100644 types/screenfull/tslint.json diff --git a/types/screenfull/index.d.ts b/types/screenfull/index.d.ts new file mode 100644 index 0000000000..2c7b93e453 --- /dev/null +++ b/types/screenfull/index.d.ts @@ -0,0 +1,85 @@ +// Type definitions for screenfull.js 4.0 +// Project: https://github.com/sindresorhus/screenfull.js +// Definitions by: Ilia Choly +// lionelb +// Joel Shepherd +// BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.5 + +export = screenfull; +export as namespace screenfull; + +declare const screenfull: screenfull.Screenfull | false; + +declare namespace screenfull { + interface Screenfull { + /** + * Returns a boolean whether fullscreen is active. + */ + readonly isFullscreen: boolean; + /** + * Returns the element currently in fullscreen, otherwise `null`. + */ + readonly element: Element | null; + /** + * Returns a boolean whether you are allowed to enter fullscreen. If your page is inside an `