From 0f4e20b7fa690c18ead85bee5280e73c407ecd5b Mon Sep 17 00:00:00 2001 From: AdrianFarmadin Date: Fri, 5 May 2017 17:28:52 +0200 Subject: [PATCH 01/16] Point, Polygon definitions --- types/rethinkdb/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/rethinkdb/index.d.ts b/types/rethinkdb/index.d.ts index f375a50fc7..94130520d1 100644 --- a/types/rethinkdb/index.d.ts +++ b/types/rethinkdb/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for RethinkDB 2.3 // Project: http://rethinkdb.com/ // Definitions by: Alex Gorbatchev +// Definitions by: Adrian Farmadin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Reference: https://rethinkdb.com/api/javascript/ From 96b6817d5e442e2c5329af0c5e860d11dc60d6db Mon Sep 17 00:00:00 2001 From: AdrianFarmadin Date: Fri, 5 May 2017 17:30:47 +0200 Subject: [PATCH 02/16] Point, Polygon definitions --- types/rethinkdb/index.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/types/rethinkdb/index.d.ts b/types/rethinkdb/index.d.ts index 94130520d1..a4cbd64313 100644 --- a/types/rethinkdb/index.d.ts +++ b/types/rethinkdb/index.d.ts @@ -1,7 +1,7 @@ // Type definitions for RethinkDB 2.3 // Project: http://rethinkdb.com/ // Definitions by: Alex Gorbatchev -// Definitions by: Adrian Farmadin +// Definitions by: Adrian Farmadin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Reference: https://rethinkdb.com/api/javascript/ @@ -38,6 +38,9 @@ declare module "rethinkdb" { export function asc(property: string): Sort; export function desc(property: string): Sort; + export function point(lng: number, lat: number): Point; + export function polygon(...point: Point[]): Polygon; + export var count: Aggregator; export function sum(prop: string): Aggregator; export function avg(prop: string): Aggregator; @@ -222,6 +225,18 @@ declare module "rethinkdb" { * See: https://rethinkdb.com/api/javascript/has_fields/ */ hasFields(...fields: string[]): T; + } + + interface Geometry { + + } + + interface Point { + + } + + interface Polygon extends Geometry { + } interface Table extends Sequence, HasFields { @@ -235,6 +250,8 @@ declare module "rethinkdb" { get(key: string): Sequence; // primary key getAll(key: string, index?: Index): Sequence; // without index defaults to primary key getAll(...keys: string[]): Sequence; + + getIntersecting(geometry: Geometry, index: Index): Sequence; } interface Sequence extends Operation, Writeable { From dc86e5222e397c382a99c36219f8fe5679a9ffa7 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 5 May 2017 09:56:00 -0700 Subject: [PATCH 03/16] fix header --- types/rethinkdb/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/rethinkdb/index.d.ts b/types/rethinkdb/index.d.ts index a4cbd64313..afe672468e 100644 --- a/types/rethinkdb/index.d.ts +++ b/types/rethinkdb/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for RethinkDB 2.3 // Project: http://rethinkdb.com/ -// Definitions by: Alex Gorbatchev -// Definitions by: Adrian Farmadin +// Definitions by: Alex Gorbatchev , Adrian Farmadin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // // Reference: https://rethinkdb.com/api/javascript/ From 0da14f6a5bd20ba88055fbcd162e79c6c13d6848 Mon Sep 17 00:00:00 2001 From: Ariel Saldana Date: Fri, 23 Feb 2018 10:00:58 -0500 Subject: [PATCH 04/16] Support for helper functions --- .github/CODEOWNERS | 2 +- types/showdown/index.d.ts | 15 +++++++++++++-- types/showdown/showdown-tests.ts | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a03915a264..8ce8955c37 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3379,7 +3379,7 @@ /types/shopify-buy/ @openminder /types/shortid/ @stpettersens @despairblue /types/shot/ @AJamesPhillips -/types/showdown/ @cbowdon @tan9 +/types/showdown/ @cbowdon @tan9 @arielsaldana /types/shrink-ray/ @forabi /types/siema/ @Irmiz @0x6368656174 @samnau /types/siesta/ @bquarmby diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index 3a1accb411..948fd966ec 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Showdown 1.7.2 +// Type definitions for Showdown 1.7.3 // Project: https://github.com/coreyti/showdown -// Definitions by: cbowdon , Pei-Tang Huang +// Definitions by: cbowdon , Pei-Tang Huang , Ariel-Saldana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = Showdown; @@ -362,10 +362,21 @@ declare namespace Showdown { */ new (converterOptions?: ConverterOptions): Converter; } + /** + * Helper Interface + */ + interface Helper { + replaceRecursiveRegExp(...args: any[]): string; + } /** Constructor function for a Converter */ var Converter: ConverterStatic; + /** + * Showdown helper + */ + var helper: Helper; + /** * Setting a "global" option affects all instances of showdown */ diff --git a/types/showdown/showdown-tests.ts b/types/showdown/showdown-tests.ts index e0d9093bc1..09a04b920c 100644 --- a/types/showdown/showdown-tests.ts +++ b/types/showdown/showdown-tests.ts @@ -17,6 +17,8 @@ var preloadedExtensions = [ 'my-ext' ], var configuredConverter = new showdown.Converter(); configuredConverter.addExtension({type: 'output', filter: (text, converter)=>{return text.replace('#', '*')}}, 'myext'); +console.log(showdown.helper); + console.log(converter.makeHtml(exampleMarkdown)); // should log '

hello, markdown

' From 7121790b73fade321587d43bd7041a742c33cc96 Mon Sep 17 00:00:00 2001 From: Benjamin Riggs Date: Sun, 25 Feb 2018 21:20:02 -0600 Subject: [PATCH 05/16] Fixed bugs, added dependency on 'events'. --- types/kurento-utils/index.d.ts | 14 +++++++++----- types/kurento-utils/kurento-utils-tests.ts | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/types/kurento-utils/index.d.ts b/types/kurento-utils/index.d.ts index 8074661881..a8a30005b6 100644 --- a/types/kurento-utils/index.d.ts +++ b/types/kurento-utils/index.d.ts @@ -1,10 +1,13 @@ -// Type definitions for kurento-utils 6.6 +// Type definitions for kurento-utils 6.7 // Project: https://github.com/Kurento/kurento-utils-js // Definitions by: Miloslav Nenadál +// Benjamin Riggs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export class WebRtcPeer { +import { EventEmitter } from 'events'; + +export class WebRtcPeer extends EventEmitter { /** * Using this property the user can get the peerConnection and use it directly. */ @@ -60,7 +63,7 @@ export class WebRtcPeer { */ addIceCandidate: ( iceCandidate: RTCIceCandidate, - callback?: () => void + callback?: (error: string | undefined) => void ) => void; /** * Using this method the user can get peerconnection’s local session descriptor. @@ -73,8 +76,9 @@ export class WebRtcPeer { /** * Creates an offer that is a request to find a remote peer with a specific configuration. */ - generateOffer: (error: string | undefined, sdp: string) => void; - + generateOffer: ( + callback: (error: string | undefined, sdp: string) => void + ) => void; /** * Create a WebRtcPeer as receive only. */ diff --git a/types/kurento-utils/kurento-utils-tests.ts b/types/kurento-utils/kurento-utils-tests.ts index 5866a2e157..380b1b1019 100644 --- a/types/kurento-utils/kurento-utils-tests.ts +++ b/types/kurento-utils/kurento-utils-tests.ts @@ -4,6 +4,10 @@ import * as kurentoUtils from 'kurento-utils'; const peer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv({}, error => {}); peer.showLocalVideo(); peer.getLocalStream().getAudioTracks(); + peer.generateOffer((error, sdp) => {}); + peer.on('icecandidate', (candidate: any) => { + peer.addIceCandidate(candidate, error => {}); + }); peer.getRemoteStream().getAudioTracks(); peer.processAnswer('answer', error => {}); peer.processOffer('offer', (error, {}) => {}); From be24886f7a4b628636a6dda8bfdb60fc47937556 Mon Sep 17 00:00:00 2001 From: Oleg Repin Date: Mon, 26 Feb 2018 11:28:31 +0300 Subject: [PATCH 06/16] [bull] add `defaultJobOptions` to `QueueOptions` --- types/bull/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index a7a9ea350b..97844cfbbb 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -5,6 +5,7 @@ // Marshall Cottrell // Weeco // Gabriel Terwesten +// Oleg Repin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -51,6 +52,8 @@ declare namespace Bull { settings?: AdvancedSettings; limiter?: RateLimiter; + + defaultJobOptions?: JobOptions; } interface AdvancedSettings { From 0428c407f07b7c5619c790cd96fe2deb88644a95 Mon Sep 17 00:00:00 2001 From: Hasse Feldthaus Date: Mon, 26 Feb 2018 09:40:41 +0100 Subject: [PATCH 07/16] Update index.d.ts Added Window to selector_object_callback type so $(window) is possible --- types/jquery/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 90f6ffbd03..8422f3ec5c 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -152,7 +152,7 @@ interface JQueryStatic { * @since 1.4 */ (selector_object_callback?: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery | - JQuery.PlainObject | + JQuery.PlainObject | Window | ((this: Document, $: JQueryStatic) => void)): JQuery; /** * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. From 0535a1af2d8d7bf2de60d284e5a304a33b1dd9fe Mon Sep 17 00:00:00 2001 From: James Hulse Date: Mon, 26 Feb 2018 17:56:13 +0000 Subject: [PATCH 08/16] Add missing word to promise constructor explanation --- types/es6-shim/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/es6-shim/index.d.ts b/types/es6-shim/index.d.ts index 51824fc932..2cf61a9362 100644 --- a/types/es6-shim/index.d.ts +++ b/types/es6-shim/index.d.ts @@ -500,7 +500,7 @@ interface PromiseConstructor { /** * Creates a new Promise. * @param executor A callback used to initialize the promise. This callback is passed two arguments: - * a resolve callback used resolve the promise with a value or the result of another promise, + * a resolve callback used to resolve the promise with a value or the result of another promise, * and a reject callback used to reject the promise with a provided reason or error. */ new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; From c79832e00141c34b9a49c09d6368175b58d0bb78 Mon Sep 17 00:00:00 2001 From: Adrian Farmadin Date: Mon, 26 Feb 2018 21:37:36 +0100 Subject: [PATCH 09/16] Point and Polygon functions for RethinkDb Geometry --- types/rethinkdb/index.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/types/rethinkdb/index.d.ts b/types/rethinkdb/index.d.ts index d45f359359..038a9d48e6 100644 --- a/types/rethinkdb/index.d.ts +++ b/types/rethinkdb/index.d.ts @@ -40,6 +40,9 @@ declare module "rethinkdb" { export function asc(property: string): Sort; export function desc(property: string): Sort; + export function point(lng: number, lat: number): Point; + export function polygon(...point: Point[]): Polygon; + export var count: Aggregator; export function sum(prop: string): Aggregator; export function avg(prop: string): Aggregator; @@ -233,7 +236,13 @@ declare module "rethinkdb" { * See: https://rethinkdb.com/api/javascript/has_fields/ */ hasFields(...fields: string[]): T; - } + } + + interface Geometry { } + + interface Point { } + + interface Polygon extends Geometry { } interface Table extends Sequence, HasFields { indexCreate(name: string, index?: ExpressionFunction): Operation; From c04400ee4be3aa5b6c272fae0e8693547f049a1f Mon Sep 17 00:00:00 2001 From: Netanel Draiman Date: Tue, 27 Feb 2018 18:05:22 +0200 Subject: [PATCH 10/16] [Dragula] updated moves() function arguments in DragulaOptions Updated moves() function arguments in DragulaOptions to include a sibling argument. --- types/dragula/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/dragula/index.d.ts b/types/dragula/index.d.ts index f91e8b70ac..51998fb583 100644 --- a/types/dragula/index.d.ts +++ b/types/dragula/index.d.ts @@ -13,7 +13,7 @@ declare namespace dragula { interface DragulaOptions { containers?: Element[]; isContainer?: (el?: Element) => boolean; - moves?: (el?: Element, container?: Element, handle?: Element) => boolean; + moves?: (el?: Element, container?: Element, handle?: Element, sibling?: Element) => boolean; accepts?: (el?: Element, target?: Element, source?: Element, sibling?: Element) => boolean; invalid?: (el?: Element, target?: Element) => boolean; direction?: string; From d1d1d18d98245d457c03947bf63079da71e714cd Mon Sep 17 00:00:00 2001 From: Dave Keen Date: Mon, 26 Feb 2018 19:59:43 +0100 Subject: [PATCH 11/16] Added chmod method to rsync types --- types/rsync/index.d.ts | 3 ++- types/rsync/rsync-tests.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/rsync/index.d.ts b/types/rsync/index.d.ts index e86d22647a..b67932eb5a 100644 --- a/types/rsync/index.d.ts +++ b/types/rsync/index.d.ts @@ -48,7 +48,7 @@ interface Rsync { stdout: StreamDataHandler, stderr: StreamDataHandler ): child_process.ChildProcess; - + // cwd cwd(cwd: string): string; @@ -63,6 +63,7 @@ interface Rsync { quiet(): Rsync; dirs(): Rsync; links(): Rsync; + chmod(flags: string): Rsync; dry(): Rsync; // accessor methods diff --git a/types/rsync/rsync-tests.ts b/types/rsync/rsync-tests.ts index 41ec4dd9b1..fe9bf39558 100644 --- a/types/rsync/rsync-tests.ts +++ b/types/rsync/rsync-tests.ts @@ -114,6 +114,7 @@ rsync.shell('ssh') .quiet() .dirs() .links() + .chmod("ug=rwX") .dry(); @@ -152,4 +153,4 @@ rsync.include('/a/file') .include('/b/file'); // as Array -rsync.include(['/a/file', '/b/file']); \ No newline at end of file +rsync.include(['/a/file', '/b/file']); From 1b53b01f4084b83fd301c8360486722799532047 Mon Sep 17 00:00:00 2001 From: Nick Schultz Date: Tue, 27 Feb 2018 15:57:47 -0500 Subject: [PATCH 12/16] add returning option to upsert and change return type accordingly --- types/sequelize/index.d.ts | 8 +++++--- types/sequelize/sequelize-tests.ts | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 643a9a8167..fc4fc03409 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3445,7 +3445,7 @@ declare namespace sequelize { /** * Options for Model.upsert method */ - interface UpsertOptions extends FieldsOptions, LoggingOptions, SearchPathOptions { + interface UpsertOptions extends FieldsOptions, LoggingOptions, SearchPathOptions, ReturningOptions { } /** @@ -3993,8 +3993,10 @@ declare namespace sequelize { * because SQLite always runs INSERT OR IGNORE + UPDATE, in a single query, so there is no way to know * whether the row was inserted or not. */ - upsert(values: TAttributes, options?: UpsertOptions): Promise; - insertOrUpdate(values: TAttributes, options?: UpsertOptions): Promise; + upsert(values: TAttributes, options?: UpsertOptions & { returning: false | undefined }): Promise; + upsert(values: TAttributes, options?: UpsertOptions & { returning: true }): Promise<[boolean, TInstance]>; + insertOrUpdate(values: TAttributes, options?: UpsertOptions & { returning: false | undefined }): Promise; + insertOrUpdate(values: TAttributes, options?: UpsertOptions & { returning: true }): Promise<[boolean, TInstance]>; /** * Create and insert multiple instances in bulk. diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index eea19959bd..2eabc511f2 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -1036,7 +1036,9 @@ findOrRetVal = User.findOrCreate( { where : { id : undefined }, defaults : { nam findOrRetVal = User.findOrCreate( { where : { email : 'unique.email.@d.com', companyId : Math.floor( Math.random() * 5 ) } } ); findOrRetVal = User.findOrCreate( { where : { objectId : 1 }, defaults : { bool : false } } ); -User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) } ); +let upsertPromiseNoOptions: Bluebird = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) } ); +let upsertPromiseReturning: Bluebird<[boolean, AnyInstance]> = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) }, { returning: true } ); +let upsertPromiseNotReturning: Bluebird = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) }, { returning: false } ); User.bulkCreate( [{ aNumber : 10 }, { aNumber : 12 }] ).then( ( i ) => i[0].isNewRecord ); User.bulkCreate( [{ username : 'bar' }, { username : 'bar' }, { username : 'bar' }] ); From b996d556729d14f0f106747bdbf57bc84e1a64c9 Mon Sep 17 00:00:00 2001 From: Nick Schultz Date: Tue, 27 Feb 2018 16:08:58 -0500 Subject: [PATCH 13/16] bump version to reflect a change from current npm version --- types/sequelize/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index fc4fc03409..7a9c64db6a 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Sequelize 4.27.0 +// Type definitions for Sequelize 4.27.8 // Project: http://sequelizejs.com // Definitions by: samuelneff // Peter Harris From 2a39618c9c51cf662fd733fc81901d679b411a64 Mon Sep 17 00:00:00 2001 From: Thomas Bruun Date: Fri, 23 Feb 2018 09:30:48 +0100 Subject: [PATCH 14/16] Stripe: Add status property to IRefund definition As described in the Stripe documentation: https://stripe.com/docs/api/node\#refund_object --- types/stripe/index.d.ts | 7 +++++++ types/stripe/stripe-tests.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 12f2b4abea..2289e02e55 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -7,6 +7,7 @@ // Brannon Jones // Kyle Kamperschroer // Kensuke Hoshikawa +// Thomas Bruun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -4688,6 +4689,12 @@ declare namespace Stripe { * This is the transaction number that appears on email receipts sent for this refund. */ receipt_number: string; + + /** + * Status of the refund. For credit card refunds, this can be succeeded or failed. + * For other types of refunds, it can be pending, succeeded, failed, or canceled. + */ + status: "pending" | "succeeded" | "failed" | "canceled"; } interface IRefundCreationOptions extends IDataOptionsWithMetadata { diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index b887ae6228..ff909076b2 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -66,7 +66,7 @@ stripe.charges.create({ }); charge.refunds.retrieve("re_15jzA4Ee31JkLCeQcxbTbjaL").then(function (refund) { - + var status: "pending" | "succeeded" | "failed" | "canceled" = refund.status; }); charge.refunds.update("re_15jzA4Ee31JkLCeQcxbTbjaL", { metadata: { test: "data" } }).then(function (refund) { From 07eb4e8a70f1ae23d37d283f0c33bd41c9f433f0 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Thu, 1 Mar 2018 15:59:23 +0000 Subject: [PATCH 15/16] ace: fix tokeninfo types --- types/ace/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/ace/index.d.ts b/types/ace/index.d.ts index 822c394a32..1f7dd9752b 100644 --- a/types/ace/index.d.ts +++ b/types/ace/index.d.ts @@ -52,6 +52,10 @@ declare namespace AceAjax { export interface TokenInfo { value: string; + + index?: number; + + start?: number; } export interface Position { @@ -575,7 +579,7 @@ declare namespace AceAjax { * @param row The row number to retrieve from * @param column The column number to retrieve from **/ - getTokenAt(row: number, column: number): TokenInfo; + getTokenAt(row: number, column: number): TokenInfo|null; /** * Sets the undo manager. From e4aa17e077f28c88abc3f71f9f83c9785fc2242c Mon Sep 17 00:00:00 2001 From: Diogo Correa Date: Wed, 7 Mar 2018 18:38:32 -0300 Subject: [PATCH 16/16] add react-avatar-editor definitions --- types/react-avatar-editor/index.d.ts | 51 +++++++++++++++++++ .../react-avatar-editor-tests.tsx | 47 +++++++++++++++++ types/react-avatar-editor/tsconfig.json | 25 +++++++++ types/react-avatar-editor/tslint.json | 1 + 4 files changed, 124 insertions(+) create mode 100644 types/react-avatar-editor/index.d.ts create mode 100644 types/react-avatar-editor/react-avatar-editor-tests.tsx create mode 100644 types/react-avatar-editor/tsconfig.json create mode 100644 types/react-avatar-editor/tslint.json diff --git a/types/react-avatar-editor/index.d.ts b/types/react-avatar-editor/index.d.ts new file mode 100644 index 0000000000..a3bbf49f3b --- /dev/null +++ b/types/react-avatar-editor/index.d.ts @@ -0,0 +1,51 @@ +// Type definitions for react-avatar-editor 10.3 +// Project: https://github.com/mosch/react-avatar-editor +// Definitions by: Diogo Corrêa +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from "react"; + +export interface ImageState { + height: number; + width: number; + x: number; + y: number; + resource: ImageData; +} + +export interface CroppedRect { + x: number; + y: number; + width: number; + height: number; +} + +export interface AvatarEditorProps { + image: string | File; + width?: number; + height?: number; + border?: number | number[]; + borderRadius?: number; + color?: number[]; + style?: object; + scale?: number; + position?: object; + rotate?: number; + crossOrigin?: string; + disableDrop?: boolean; + onDropFile?(event: DragEvent): void; + onLoadFailure?(event: Event): void; + onLoadSuccess?(imgInfo: ImageState): void; + onImageReady?(event: Event): void; + onMouseUp?(): void; + onMouseMove?(event: Event): void; + onImageChange?(): void; + onPositionChange?(): void; +} + +export default class AvatarEditor extends React.Component { + static getImage(): HTMLCanvasElement; + static getImageScaledToCanvas(): HTMLCanvasElement; + static getCroppingRect(): CroppedRect; +} diff --git a/types/react-avatar-editor/react-avatar-editor-tests.tsx b/types/react-avatar-editor/react-avatar-editor-tests.tsx new file mode 100644 index 0000000000..063d083f3f --- /dev/null +++ b/types/react-avatar-editor/react-avatar-editor-tests.tsx @@ -0,0 +1,47 @@ +import * as React from "react"; +import AvatarEditor, { ImageState, CroppedRect } from "react-avatar-editor"; + +const file: File = new File(["str"], "image.jpg"); +const image: ImageData = new ImageData(1, 2); +const imageState: ImageState = { + height: 1, + width: 1, + x: 1, + y: 1, + resource: image +}; + +class AvatarEditorTest extends React.Component { + render() { + return ( +
+ + + + + + + + + + + + + + + {}} /> + {}} /> + {}} /> + {}} /> + {}} /> + {}} /> + {}} /> + {}} /> +
+ ); + } +} + +const getImage: HTMLCanvasElement = AvatarEditor.getImage(); +const getImageScaledToCanvas: HTMLCanvasElement = AvatarEditor.getImageScaledToCanvas(); +const getCroppingRect: CroppedRect = AvatarEditor.getCroppingRect(); diff --git a/types/react-avatar-editor/tsconfig.json b/types/react-avatar-editor/tsconfig.json new file mode 100644 index 0000000000..b947d3271a --- /dev/null +++ b/types/react-avatar-editor/tsconfig.json @@ -0,0 +1,25 @@ +{ + "files": [ + "index.d.ts", + "react-avatar-editor-tests.tsx" + ], + "compilerOptions": { + "jsx": "react", + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/react-avatar-editor/tslint.json b/types/react-avatar-editor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-avatar-editor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }