From 6b3ba53fd7f2c0633385702ec480f13534098ad8 Mon Sep 17 00:00:00 2001 From: Dan Imbrogno Date: Thu, 24 Nov 2016 13:14:31 -0500 Subject: [PATCH 01/22] Fix knex timestamps definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per http://knexjs.org/ timestamps — table.timestamps() Adds a created_at and updated_at column on the database, setting these each to dateTime types. When true is passed as the first argument a timestamp type is used. Both colums default to being not null and the current timestamp when true is passed as the second argument. --- knex/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knex/index.d.ts b/knex/index.d.ts index 905841283d..ee53d99275 100644 --- a/knex/index.d.ts +++ b/knex/index.d.ts @@ -365,7 +365,7 @@ declare namespace Knex { dateTime(columnName: string): ColumnBuilder; time(columnName: string): ColumnBuilder; timestamp(columnName: string): ColumnBuilder; - timestamps(): ColumnBuilder; + timestamps(useTimestampType?: boolean, makeDefaultNow?: boolean): ColumnBuilder; binary(columnName: string): ColumnBuilder; enum(columnName: string, values: Value[]): ColumnBuilder; enu(columnName: string, values: Value[]): ColumnBuilder; From 224ba3918dcc25405cf4975c34b129a757d4a21b Mon Sep 17 00:00:00 2001 From: Dan Imbrogno Date: Thu, 24 Nov 2016 13:36:27 -0500 Subject: [PATCH 02/22] Adds test for typing --- knex/knex-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index eaab2ca8bd..231152f35c 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -419,6 +419,7 @@ knex.schema.createTable('users', function (table) { table.enu('favorite_color', ['red', 'blue', 'green']); table.timestamps(); table.timestamp('created_at').defaultTo(knex.fn.now()); + table.timestamps(true, true); }); knex.schema.renameTable('users', 'old_users'); From 9d67f745a7607ffa0421907b5cdef22f87fa2c4d Mon Sep 17 00:00:00 2001 From: Dean Harding Date: Tue, 6 Dec 2016 21:58:22 +1100 Subject: [PATCH 03/22] The PR contains three fairly simple changes: 1. Geometry has method computeFlatVertexNormals (added in mrdoob/three.js#9222) 2. The type of image in DataTexture is actually ImageData. 3. The type of the first parameter in AnimationAction.setLoop() is the enum AnimationActionLoopStyles. --- three/index.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/three/index.d.ts b/three/index.d.ts index 1a691e7878..b331662342 100644 --- a/three/index.d.ts +++ b/three/index.d.ts @@ -261,7 +261,7 @@ declare namespace THREE { reset(): AnimationAction; isRunning(): boolean; startAt(time: number): AnimationAction; - setLoop(mode: boolean, repetitions: number): AnimationAction; + setLoop(mode: AnimationActionLoopStyles, repetitions?: number): AnimationAction; setEffectiveWeight(weight: number): AnimationAction; getEffectiveWeight(): number; fadeIn(duration: number): AnimationAction; @@ -1285,6 +1285,11 @@ declare namespace THREE { */ computeVertexNormals(areaWeighted?: boolean): void; + /** + * Compute vertex normals, but duplicating face normals. + */ + computeFlatVertexNormals(): void; + /** * Computes morph normals. */ @@ -5729,7 +5734,7 @@ declare namespace THREE { encoding?: TextureEncoding ); - image: { data: ImageData; width: number; height: number; }; + image: ImageData; } export class VideoTexture extends Texture { From e31c49ce6e6c45c983d6cf05c4905f568d0abeb4 Mon Sep 17 00:00:00 2001 From: Dean Harding Date: Thu, 8 Dec 2016 18:38:13 +1100 Subject: [PATCH 04/22] repetitions isn't optional after all --- three/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/three/index.d.ts b/three/index.d.ts index b331662342..a7da5b8c10 100644 --- a/three/index.d.ts +++ b/three/index.d.ts @@ -261,7 +261,7 @@ declare namespace THREE { reset(): AnimationAction; isRunning(): boolean; startAt(time: number): AnimationAction; - setLoop(mode: AnimationActionLoopStyles, repetitions?: number): AnimationAction; + setLoop(mode: AnimationActionLoopStyles, repetitions: number): AnimationAction; setEffectiveWeight(weight: number): AnimationAction; getEffectiveWeight(): number; fadeIn(duration: number): AnimationAction; From 77298da2afae4624489273a3fd9dd95fd04bfd1f Mon Sep 17 00:00:00 2001 From: Fredrik Smedberg Date: Fri, 9 Dec 2016 16:36:23 +0100 Subject: [PATCH 05/22] Makes the type definitions compatible with WebdriverIO 4.4.0. Merged my changes (removed all callbacks) with WillLuce pull request #12416. --- webdriverio/index.d.ts | 467 ++++++++++++++++++++++++----------------- 1 file changed, 277 insertions(+), 190 deletions(-) diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index 44a0e6ea57..5734bc3990 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webdriverio 4.0.4 +// Type definitions for webdriverio 4.4.0 // Project: http://www.webdriver.io/ // Definitions by: Nick Malaguti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -30,96 +30,116 @@ declare namespace WebdriverIO { // Action export interface Client { - addValue(selector: string, value: string | number): Client; + addValue( + selector: string, + value: string | number + ): Client; + addValue(value: string | number): Client; addValue

( selector: string, value: string | number, - callback: (err: any) => P ): Client

; + addValue

(value: string | number): Client

; clearElement(selector: string): Client; - clearElement

( - selector: string, - callback: (err: any) => P - ): Client

; + clearElement(): Client; + clearElement

(selector: string): Client

; + clearElement

(): Client

; click(selector: string): Client; - click

( - selector: string, - callback: (err: any) => P - ): Client

; + click(): Client; + click

(selector: string): Client

; + click

(): Client

; doubleClick(selector: string): Client; - doubleClick

( - selector: string, - callback: (err: any) => P - ): Client

; + doubleClick(): Client; + doubleClick

(selector: string): Client

; + doubleClick

(): Client

; - dragAndDrop(sourceElem: string, destinationElem: string): Client; + dragAndDrop( + sourceElem: string, + destinationElem: string + ): Client; + dragAndDrop(destinationElem: string): Client; dragAndDrop

( sourceElem: string, - destinationElem: string, callback: (err: any) => P + destinationElem: string ): Client

; + dragAndDrop

(destinationElem: string): Client

; leftClick(selector: string): Client; - leftClick

( - selector: string, - callback: (err: any) => P - ): Client

; + leftClick(): Client; + leftClick

(selector: string): Client

; + leftClick

(): Client

; middleClick(selector: string): Client; - middleClick

( - selector: string, - callback: (err: any) => P - ): Client

; + middleClick(): Client; + middleClick

(selector: string): Client

; + middleClick

(): Client

; moveToObject(selector: string): Client; - moveToObject(selector: string, xoffset: number, yoffset: number): Client; - moveToObject

( + moveToObject(): Client; + moveToObject( selector: string, - callback: (err: any) => P - ): Client

; + xoffset: number, + yoffset: number + ): Client; + moveToObject( + xoffset: number, + yoffset: number + ): Client; + moveToObject

(selector: string): Client

; + moveToObject

(): Client

; moveToObject

( selector: string, xoffset: number, - yoffset: number, - callback: (err: any) => P + yoffset: number + ): Client

; + moveToObject

( + xoffset: number, + yoffset: number ): Client

; rightClick(selector: string): Client; - rightClick

( - selector: string, - callback: (err: any) => P - ): Client

; + rightClick(): Client; + rightClick

(selector: string): Client

; + rightClick

(): Client

; selectByAttribute(selector: string, attribute: string, value: string): Client; + selectByAttribute(attribute: string, value: string): Client; selectByAttribute

( selector: string, attribute: string, - value: string, - callback: (err: any) => P + value: string + ): Client

; + selectByAttribute

( + attribute: string, + value: string ): Client

; selectByIndex(selectElem: string, index: number): Client; + selectByIndex(index: number): Client; selectByIndex

( selectElem: string, - index: number, - callback: (err: any) => P + index: number ): Client

; + selectByIndex

(index: number): Client

; selectByValue(selectElem: string, value: string): Client; + selectByValue(value: string): Client; selectByValue

( selectElem: string, - value: string, - callback: (err: any) => P + value: string ): Client

; + selectByValue

(value: string): Client

; selectByVisibleText(selectElem: string, text: string): Client; + selectByVisibleText(text: string): Client; selectByVisibleText

( selectElem: string, - text: string, - callback: (err: any) => P + text: string ): Client

; + selectByVisibleText

(text: string): Client

; selectorExecute

( selectors: string | string[], @@ -134,17 +154,17 @@ declare namespace WebdriverIO { ): Client

; setValue(selector: string, values: number | string | Array): Client; + setValue(values: number | string | Array): Client; setValue

( selector: string, - values: number | string | Array, - callback: (err: any) => P + values: number | string | Array ): Client; + setValue

(values: number | string | Array): Client; submitForm(selector: string): Client; - submitForm

( - selector: string, - callback: (err: any) => P - ): Client; + submitForm(): Client; + submitForm

(selector: string): Client; + submitForm

(): Client; } // Appium @@ -187,13 +207,8 @@ declare namespace WebdriverIO { // Cookie export interface Client { deleteCookie(name?: string): Client; - deleteCookie

( - callback: (err: any) => P - ): Client

; - deleteCookie

( - name: string, - callback: (err: any) => P - ): Client

; + deleteCookie

(): Client

; + deleteCookie

(name: string): Client

; getCookie(): Client; getCookie(name: string): Client; @@ -206,10 +221,7 @@ declare namespace WebdriverIO { ): Client

; setCookie(cookie: Cookie): Client; - setCookie

( - cookie: Cookie, - callback: (err: any) => P - ): Client

; + setCookie

(cookie: Cookie): Client

; } export interface Client { @@ -277,80 +289,133 @@ declare namespace WebdriverIO { // Property export interface Client { getAttribute(selector: string, attributeName: string): Client; + getAttribute(attributeName: string): Client; getAttribute

( selector: string, attributeName: string, callback: (err: any, attribute: string | string[]) => P ): Client

; + getAttribute

( + attributeName: string, + callback: (err: any, attribute: string | string[]) => P + ): Client

; getCssProperty(selector: string, cssProperty: string): Client; + getCssProperty(cssProperty: string): Client; getCssProperty

( selector: string, cssProperty: string, callback: (err: any, cssProperty: CssProperty | CssProperty[]) => P ): Client

; + getCssProperty

( + cssProperty: string, + callback: (err: any, cssProperty: CssProperty | CssProperty[]) => P + ): Client

; getElementSize(selector: string): Client; + getElementSize(): Client; getElementSize(selector: string, dimension: string): Client; + getElementSize(dimension: string): Client; getElementSize

( selector: string, callback: (err: any, size: Size | Size[]) => P ): Client

; + getElementSize

( + callback: (err: any, size: Size | Size[]) => P + ): Client

; getElementSize

( selector: string, dimension: string, callback: (err: any, elementSize: number | number[]) => P ): Client

; + getElementSize

( + dimension: string, + callback: (err: any, elementSize: number | number[]) => P + ): Client

; getHTML(selector: string, includeSelectorTag?: boolean): Client; + getHTML(includeSelectorTag?: boolean): Client; getHTML

( selector: string, callback: (err: any, html: string | string[]) => P ): Client

; + getHTML

( + callback: (err: any, html: string | string[]) => P + ): Client

; getHTML

( selector: string, includeSelectorTag: boolean, callback: (err: any, html: string | string[]) => P ): Client

; + getHTML

( + includeSelectorTag: boolean, + callback: (err: any, html: string | string[]) => P + ): Client

; - getLocation(selector: string): Client; + getLocation(selector: string): Client; + getLocation(): Client; getLocation(selector: string, axis: string): Client; + getLocation(axis: string): Client; getLocation

( selector: string, - callback: (err: any, location: Location) => P + callback: (err: any, size: Size) => P + ): Client

; + getLocation

( + callback: (err: any, size: Size) => P ): Client

; getLocation

( selector: string, axis: string, callback: (err: any, location: number) => P ): Client

; + getLocation

( + axis: string, + callback: (err: any, location: number) => P + ): Client

; - getLocationInView(selector: string): Client; + getLocationInView(selector: string): Client; + getLocationInView(): Client; getLocationInView(selector: string, axis: string): Client; + getLocationInView(axis: string): Client; getLocationInView

( selector: string, - callback: (err: any, location: Location | Location[]) => P + callback: (err: any, size: Size | Size[]) => P + ): Client

; + getLocationInView

( + callback: (err: any, size: Size | Size[]) => P ): Client

; getLocationInView

( selector: string, axis: string, callback: (err: any, location: number | number[]) => P ): Client

; + getLocationInView

( + axis: string, + callback: (err: any, location: number | number[]) => P + ): Client

; getSource(): Client; getSource

(callback: (err: any, source: string) => P): Client

; getTagName(selector: string): Client; + getTagName(): Client; getTagName

( selector: string, callback: (err: any, tagName: string | string[]) => P ): Client

; + getTagName

( + callback: (err: any, tagName: string | string[]) => P + ): Client

; getText(selector: string): Client; + getText(): Client; getText

( selector: string, callback: (err: any, text: string | string[]) => P ): Client

; + getText

( + callback: (err: any, text: string | string[]) => P + ): Client

; getTitle(): Client; getTitle

( @@ -363,10 +428,14 @@ declare namespace WebdriverIO { ): Client

; getValue(selector: string): Client; + getValue(): Client; getValue

( selector: string, callback: (err: any, value: string | string[]) => P ): Client

; + getValue

( + callback: (err: any, value: string | string[]) => P + ): Client

; } export interface LogEntry { @@ -395,7 +464,7 @@ declare namespace WebdriverIO { value: any; } - export interface GeoLocation { + export interface Location { latitude: number; longitude: number; altitude: number; @@ -413,94 +482,60 @@ declare namespace WebdriverIO { // Navigation export interface Client { back(): Client; - back

( - callback: (err: any) => P - ): Client

; + back

(): Client

; forward(): Client; - forward

( - callback: (err: any) => P - ): Client

; + forward

(): Client

; refresh(): Client; - refresh

( - callback: (err: any) => P - ): Client

; + refresh

(): Client

; url(): Client>; url(url: string): Client; url

( callback: (err: any, result: RawResult) => P ): Client

; - url

( - url: string, - callback: (err: any) => P - ): Client

; + url

(url: string): Client

; } // Advanced input export interface Client { // you probably want to use the click and drag and drop commands instead buttonDown(button?: string | Button): Client; - buttonDown

( - callback: (err: any) => P - ): Client

; - buttonDown

( - button: string | Button, - callback: (err: any) => P - ): Client

; + buttonDown

(): Client

; + buttonDown

(button: string | Button): Client

; // you probably want to use the click and drag and drop commands instead buttonPress(button?: string | Button): Client; - buttonPress

( - callback: (err: any) => P - ): Client

; - buttonPress

( - button: string | Button, - callback: (err: any) => P - ): Client

; + buttonPress

(): Client

; + buttonPress

(button: string | Button): Client

; // you probably want to use the click and drag and drop commands instead buttonUp(button?: string | Button): Client; - buttonUp

( - callback: (err: any) => P - ): Client

; + buttonUp

(): Client

; buttonUp(button?: string | Button): Client; - buttonUp

( - button: string | Button, - callback: (err: any) => P - ): Client

; + buttonUp

(button: string | Button): Client

; // you probably want to use the click and drag and drop commands instead doDoubleClick(): Client; - doDoubleClick

( - callback: (err: any) => P - ): Client

; + doDoubleClick

(): Client

; // you probably want to use addValue and setValue instead keys(value: string | string[]): Client; - keys

( - value: string | string[], - callback: (err: any) => P - ): Client

; + keys

(value: string | string[]): Client

; // you probably want to use the moveToObject command instead moveTo(id: ElementId, xoffset?: number, yoffset?: number): Client; moveTo(xoffset?: number, yoffset?: number): Client; + moveTo

(id: ElementId): Client

; moveTo

( id: ElementId, - callback: (err: any) => P + xoffset: number ): Client

; moveTo

( id: ElementId, xoffset: number, - callback: (err: any) => P - ): Client

; - moveTo

( - id: ElementId, - xoffset: number, - yoffset: number, - callback: (err: any) => P + yoffset: number ): Client

; // touchClick @@ -516,14 +551,10 @@ declare namespace WebdriverIO { // Useful Protocol export interface Client { alertAccept(): Client; - alertAccept

( - callback: (err: any) => P - ): Client

; + alertAccept

(): Client

; alertDismiss(): Client; - alertDismiss

( - callback: (err: any) => P - ): Client

; + alertDismiss

(): Client

; alertText(text?: string): Client; alertText

( @@ -535,24 +566,14 @@ declare namespace WebdriverIO { ): Client

; frame(id: any): Client; - frame

( - id: any, - callback: (err: any) => P - ): Client

; + frame

(id: any): Client

; frameParent(): Client; - frameParent

( - callback: (err: any) => P - ): Client

; + frameParent

(): Client

; init(capabilities?: DesiredCapabilities): Client; - init

( - callback: (err: any) => P - ): Client

; - init

( - capabilities: DesiredCapabilities, - callback: (err: any) => P - ): Client

; + init

(): Client

; + init

(capabilities: DesiredCapabilities): Client

; log(type: string): Client>; log

( @@ -623,16 +644,10 @@ declare namespace WebdriverIO { ): Client

; elementIdClear(id: ElementId): Client; - elementIdClear

( - id: ElementId, - callback: (err: any) => P - ): Client

; + elementIdClear

(id: ElementId): Client

; elementIdClick(id: ElementId): Client; - elementIdClick

( - id: ElementId, - callback: (err: any) => P - ): Client

; + elementIdClick

(id: ElementId): Client

; elementIdCssProperty(id: ElementId, propertyName: string): Client>; elementIdCssProperty

( @@ -746,10 +761,7 @@ declare namespace WebdriverIO { // use submitForm instead submit(id: ElementId): Client; - submit

( - id: ElementId, - callback: (err: any) => P - ): Client

; + submit

(id: ElementId): Client

; // title } @@ -757,34 +769,54 @@ declare namespace WebdriverIO { // State export interface Client { isEnabled(selector: string): Client; + isEnabled(): Client; isEnabled

( selector: string, callback: (err: any, isEnabled: boolean) => P ): Client

; + isEnabled

( + callback: (err: any, isEnabled: boolean) => P + ): Client

; isExisting(selector: string): Client; + isExisting(): Client; isExisting

( selector: string, callback: (err: any, isExisting: boolean) => P ): Client

; + isExisting

( + callback: (err: any, isExisting: boolean) => P + ): Client

; isSelected(selector: string): Client; + isSelected(): Client; isSelected

( selector: string, callback: (err: any, isSelected: boolean) => P ): Client

; + isSelected

( + callback: (err: any, isSelected: boolean) => P + ): Client

; isVisible(selector: string): Client; + isVisible(): Client; isVisible

( selector: string, callback: (err: any, isVisible: boolean) => P ): Client

; + isVisible

( + callback: (err: any, isVisible: boolean) => P + ): Client

; isVisibleWithinViewport(selector: string): Client; + isVisibleWithinViewport(): Client; isVisibleWithinViewport

( selector: string, callback: (err: any, isVisible: boolean) => P ): Client

; + isVisibleWithinViewport

( + callback: (err: any, isVisible: boolean) => P + ): Client

; } export interface CommandHistoryEntry { @@ -797,37 +829,30 @@ declare namespace WebdriverIO { addCommand(commandName: string, customMethod: Function, overwrite?: boolean): Client; addCommand

( commandName: string, - customMethod: Function, - callback: (err: any) => P + customMethod: Function ): Client

; addCommand

( commandName: string, customMethod: Function, - overwrite: boolean, - callback: (err: any) => P + overwrite: boolean ): Client

; chooseFile(selector: string, localPath: string): Client; + chooseFile(localPath: string): Client; chooseFile

( selector: string, - localPath: string, - callback: (err: any) => P + localPath: string ): Client

; + chooseFile

(localPath: string): Client

; debug(): Client; - debug

( - callback: (err: any) => P - ): Client

; + debug

(): Client

; end(): Client; - end

( - callback: (err: any) => P - ): Client

; + end

(): Client

; endAll(): Client; - endAll

( - callback: (err: any) => P - ): Client

; + endAll

(): Client

; getCommandHistory(): Client; getCommandHistory

( @@ -835,7 +860,7 @@ declare namespace WebdriverIO { ): Client

; pause(milliseconds: number): Client; - pause

(milliseconds: number, callback: (err: any) => P): Client

; + pause

(milliseconds: number): Client

; saveScreenshot(filename?: string): Client; saveScreenshot

( @@ -847,131 +872,203 @@ declare namespace WebdriverIO { ): Client

; scroll(selector: string): Client; + scroll(): Client; scroll(selector: string, xoffset: number, yoffset: number): Client; scroll(xoffset: number, yoffset: number): Client; - scroll

( - selector: string, - callback: (err: any) => P - ): Client

; + scroll

(selector: string): Client

; + scroll

(): Client

; scroll

( selector: string, xoffset: number, - yoffset: number, - callback: (err: any) => P + yoffset: number ): Client

; scroll

( xoffset: number, - yoffset: number, - callback: (err: any) => P + yoffset: number ): Client

; uploadFile(localPath: string): Client; - uploadFile

( - localPath: string, - callback: (err: any) => P - ): Client

; + uploadFile

(localPath: string): Client

; waitForEnabled(selector: string, milliseconds?: number, reverse?: boolean): Client; + waitForEnabled(milliseconds?: number, reverse?: boolean): Client; waitForEnabled

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; + waitForEnabled

( + callback: (err: any, enabled: boolean) => P + ): Client

; waitForEnabled

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; + waitForEnabled

( + milliseconds: number, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForEnabled

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; + waitForEnabled

( + milliseconds: number, + reverse: boolean, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForExist(selector: string, milliseconds?: number, reverse?: boolean): Client; + waitForExist(milliseconds?: number, reverse?: boolean): Client; waitForExist

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; + waitForExist

( + callback: (err: any, enabled: boolean) => P + ): Client

; waitForExist

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; + waitForExist

( + milliseconds: number, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForExist

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; + waitForExist

( + milliseconds: number, + reverse: boolean, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForSelected(selector: string, milliseconds?: number, reverse?: boolean): Client; + waitForSelected(milliseconds?: number, reverse?: boolean): Client; waitForSelected

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; + waitForSelected

( + callback: (err: any, enabled: boolean) => P + ): Client

; waitForSelected

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; + waitForSelected

( + milliseconds: number, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForSelected

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; + waitForSelected

( + milliseconds: number, + reverse: boolean, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForText(selector: string, milliseconds?: number, reverse?: boolean): Client; + waitForText(milliseconds?: number, reverse?: boolean): Client; waitForText

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; + waitForText

( + callback: (err: any, enabled: boolean) => P + ): Client

; waitForText

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; + waitForText

( + milliseconds: number, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForText

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; + waitForText

( + milliseconds: number, + reverse: boolean, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForValue(selector: string, milliseconds?: number, reverse?: boolean): Client; + waitForValue(milliseconds?: number, reverse?: boolean): Client; waitForValue

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; + waitForValue

( + callback: (err: any, enabled: boolean) => P + ): Client

; waitForValue

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; + waitForValue

( + milliseconds: number, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForValue

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; + waitForValue

( + milliseconds: number, + reverse: boolean, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForVisible(selector: string, milliseconds?: number, reverse?: boolean): Client; + waitForVisible(milliseconds?: number, reverse?: boolean): Client; waitForVisible

( selector: string, callback: (err: any, enabled: boolean) => P ): Client

; + waitForVisible

( + callback: (err: any, enabled: boolean) => P + ): Client

; waitForVisible

( selector: string, milliseconds: number, callback: (err: any, enabled: boolean) => P ): Client

; + waitForVisible

( + milliseconds: number, + callback: (err: any, enabled: boolean) => P + ): Client

; waitForVisible

( selector: string, milliseconds: number, reverse: boolean, callback: (err: any, enabled: boolean) => P ): Client

; + waitForVisible

( + milliseconds: number, + reverse: boolean, + callback: (err: any, enabled: boolean) => P + ): Client

; waitUntil( condition: () => boolean | Q.IPromise, @@ -991,13 +1088,8 @@ declare namespace WebdriverIO { // Window export interface Client { close(windowHandle?: string): Client; - close

( - callback: (err: any) => P - ): Client

; - close

( - windowHandle: string, - callback: (err: any) => P - ): Client

; + close

(): Client

; + close

(windowHandle: string): Client

; getCurrentTabId(): Client; getCurrentTabId

( @@ -1030,18 +1122,12 @@ declare namespace WebdriverIO { setViewportSize(size: Size, type: boolean): Client; setViewportSize

( size: Size, - type: boolean, - callback: (err: any) => P + type: boolean ): Client

; switchTab(windowHandle?: string): Client; - switchTab

( - callback: (err: any) => P - ): Client

; - switchTab

( - windowHandle: string, - callback: (err: any) => P - ): Client

; + switchTab

(): Client

; + switchTab

(windowHandle: string): Client

; } export interface Options { @@ -1085,3 +1171,4 @@ declare var browser: WebdriverIO.Client; declare module "webdriverio" { export = WebdriverIO; } + From eff17369bce56deca94ea88524b9adcbe54e4687 Mon Sep 17 00:00:00 2001 From: Fredrik Smedberg Date: Mon, 12 Dec 2016 16:45:39 +0100 Subject: [PATCH 06/22] client.end() doesn't expect any parameters. Removed 'done' from the method call. --- webdriverio/webdriverio-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webdriverio/webdriverio-tests.ts b/webdriverio/webdriverio-tests.ts index 0e752e93ce..e36e9e6d46 100644 --- a/webdriverio/webdriverio-tests.ts +++ b/webdriverio/webdriverio-tests.ts @@ -61,7 +61,7 @@ describe("my webdriverio tests", function(){ }); after(function(done) { - client.end(done); + client.end(); }); }); From f3376775662f9ae583c12a7ba490f2fae60c81a4 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 13 Dec 2016 09:46:17 +0100 Subject: [PATCH 07/22] Add emojione type declarations --- emojione/emojione-test.ts | 15 +++++++++++++++ emojione/emojione.d.ts | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 emojione/emojione-test.ts create mode 100644 emojione/emojione.d.ts diff --git a/emojione/emojione-test.ts b/emojione/emojione-test.ts new file mode 100644 index 0000000000..cdb38d7c90 --- /dev/null +++ b/emojione/emojione-test.ts @@ -0,0 +1,15 @@ +/// + +emojione.sprites = true; +emojione.imagePathPNG = 'foobar'; +emojione.imagePathSVG = 'foobar'; +emojione.imagePathSVGSprites = 'foobar'; +emojione.imageType = 'svg'; +emojione.unicodeAlt = false; +emojione.ascii = true; +emojione.unicodeRegexp = '123.*'; +emojione.cacheBustParam = 'asdf'; +const myShort: string = emojione.toShort('hi'); +const myImage1: string = emojione.toImage('hi'); +const myImage2: string = emojione.shortnameToImage('hi'); +const myImage3: string = emojione.unicodeToImage('hi'); diff --git a/emojione/emojione.d.ts b/emojione/emojione.d.ts new file mode 100644 index 0000000000..f273d34460 --- /dev/null +++ b/emojione/emojione.d.ts @@ -0,0 +1,20 @@ +// Type definitions for emojione +// Project: https://github.com/Ranks/emojione +// Definitions by: Danilo Bargen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var emojione: { + sprites: boolean, + imagePathPNG: string, + imagePathSVG: string, + imagePathSVGSprites: string, + imageType: 'png' | 'svg', + unicodeAlt: boolean, + ascii: boolean, + unicodeRegexp: string, + cacheBustParam: string, + toShort: (str: string) => string, + toImage: (str: string) => string, + shortnameToImage: (str: string) => string, + unicodeToImage: (str: string) => string, +}; From 26460b45c5577758f60fc1f5aa7ce1a874d67a6c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 13 Dec 2016 07:11:41 -0800 Subject: [PATCH 08/22] Improve parsimmon types * Convert to tabs (was mixed tabs and spaces) * Remove `// TODO convert to generics`, since it appears to be generically typed already. * Break `Result` into `Success` and `Failure` types in a discriminated union. * Have `fail` return `Parser`. * Add two more `seqMap` overloads. * Result.expected is a `string[]`. According to the docs (https://github.com/jneen/parsimmon#basics): "a sorted, unique array of messages indicating what was expected." * Lint: Use Array for complex T, add missing semicolons, remove patch version, use `Parser` rather than `Parser` --- parsimmon/index.d.ts | 493 ++++++++++++++++++----------------- parsimmon/parsimmon-tests.ts | 30 ++- parsimmon/tslint.json | 1 + 3 files changed, 270 insertions(+), 254 deletions(-) create mode 100644 parsimmon/tslint.json diff --git a/parsimmon/index.d.ts b/parsimmon/index.d.ts index 6dc61539ab..85ea74cfd9 100644 --- a/parsimmon/index.d.ts +++ b/parsimmon/index.d.ts @@ -1,10 +1,8 @@ -// Type definitions for Parsimmon 1.0.0 +// Type definitions for Parsimmon 1.0 // Project: https://github.com/jneen/parsimmon // Definitions by: Bart van der Schoor , Mizunashi Mana , Boris Cherny , Benny van Reeven // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TODO convert to generics - /** * **NOTE:** You probably will never need to use this function. Most parsing * can be accomplished using `Parsimmon.regexp` and combination with @@ -41,284 +39,297 @@ declare function Parsimmon(fn: (input: string, i: number) => Parsimmon.Result): Parsimmon.Parser; declare namespace Parsimmon { - export type StreamType = string; + export type StreamType = string; - export interface Index { - /** zero-based character offset */ - offset: number; - /** one-based line offset */ - line: number; - /** one-based column offset */ - column: number; - } + export interface Index { + /** zero-based character offset */ + offset: number; + /** one-based line offset */ + line: number; + /** one-based column offset */ + column: number; + } - export interface Mark { - start: Index; - end: Index; - value: T; - } + export interface Mark { + start: Index; + end: Index; + value: T; + } - export interface Result { - status: boolean; - value?: T; - expected?: string; - index?: Index; - } + export type Result = Success | Failure; - export interface Parser { - /** - * parse the string - */ - parse(input: string): Result; - /** - * Like parser.parse(input) but either returns the parsed value or throws - * an error on failure. The error object contains additional properties - * about the error. - */ - tryParse(input: string): T; - /** - * returns a new parser which tries parser, and if it fails uses otherParser. - */ - or(otherParser: Parser): Parser; - or(otherParser: Parser): Parser; - /** - * returns a new parser which tries parser, and on success calls the given function - * with the result of the parse, which is expected to return another parser, which - * will be tried next + export interface Success { + status: true; + value: T; + } + + export interface Failure { + status: false; + expected: string[]; + index: Index; + } + + export interface Parser { + /** + * parse the string */ - chain(next: (result: T) => Parser): Parser; - /** - * returns a new parser which tries parser, and on success calls the given function - * with the result of the parse, which is expected to return another parser. - */ - then(call: (result: T) => Parser): Parser; - /** - * expects anotherParser to follow parser, and yields the result of anotherParser. - * NB: the result of parser here is ignored. - */ - then(anotherParser: Parser): Parser; - /** - * transforms the output of parser with the given function. - */ - map(call: (result: T) => U): Parser; - /** - * expects otherParser after parser, but preserves the yield value of parser. - */ - skip(otherParser: Parser): Parser; - /** - * returns a new parser with the same behavior, but which yields aResult. - */ - result(aResult: U): Parser; - /** - * expects parser zero or more times, and yields an array of the results. - */ - many(): Parser; - /** - * expects parser exactly n times, and yields an array of the results. - */ - times(n: number): Parser; - /** - * expects parser between min and max times, and yields an array of the results. - */ - times(min: number, max: number): Parser; - /** - * expects parser at most n times. Yields an array of the results. - */ - atMost(n: number): Parser; - /** - * expects parser at least n times. Yields an array of the results. - */ - atLeast(n: number): Parser; - /** - * returns a new parser whose failure message is the passed description. - */ - mark(): Parser>; - /** - * Returns a new parser whose failure message is description. - * For example, string('x').desc('the letter x') will indicate that 'the letter x' was expected. - */ - desc(description: string): Parser; - } - - /** - * Alias of `Parsimmon(fn)` for backwards compatibility. - */ - export function Parser(fn: (input: string, i: number) => Parsimmon.Result): Parser; - - /** - * To be used inside of Parsimmon(fn). Generates an object describing how - * far the successful parse went (index), and what value it created doing - * so. See documentation for Parsimmon(fn). - */ - export function makeSuccess(index: number, value: T): Result; - - /** - * To be used inside of Parsimmon(fn). Generates an object describing how - * far the unsuccessful parse went (index), and what kind of syntax it - * expected to see (expectation). See documentation for Parsimmon(fn). - */ - export function makeFailure(furthest: number, expectation: string): Result; - + parse(input: string): Result; /** - * Returns true if obj is a Parsimmon parser, otherwise false. + * Like parser.parse(input) but either returns the parsed value or throws + * an error on failure. The error object contains additional properties + * about the error. */ - export function isParser(obj: any): boolean; - + tryParse(input: string): T; /** - * is a parser that expects to find "my-string", and will yield the same. + * returns a new parser which tries parser, and if it fails uses otherParser. + */ + or(otherParser: Parser): Parser; + or(otherParser: Parser): Parser; + /** + * returns a new parser which tries parser, and on success calls the given function + * with the result of the parse, which is expected to return another parser, which + * will be tried next + */ + chain(next: (result: T) => Parser): Parser; + /** + * returns a new parser which tries parser, and on success calls the given function + * with the result of the parse, which is expected to return another parser. + */ + then(call: (result: T) => Parser): Parser; + /** + * expects anotherParser to follow parser, and yields the result of anotherParser. + * NB: the result of parser here is ignored. + */ + // tslint:disable-next-line:unified-signatures + then(anotherParser: Parser): Parser; + /** + * transforms the output of parser with the given function. + */ + map(call: (result: T) => U): Parser; + /** + * expects otherParser after parser, but preserves the yield value of parser. + */ + skip(otherParser: Parser): Parser; + /** + * returns a new parser with the same behavior, but which yields aResult. + */ + result(aResult: U): Parser; + /** + * expects parser zero or more times, and yields an array of the results. + */ + many(): Parser; + /** + * expects parser exactly n times, and yields an array of the results. + */ + times(n: number): Parser; + /** + * expects parser between min and max times, and yields an array of the results. + */ + // tslint:disable-next-line:unified-signatures + times(min: number, max: number): Parser; + /** + * expects parser at most n times. Yields an array of the results. + */ + atMost(n: number): Parser; + /** + * expects parser at least n times. Yields an array of the results. + */ + atLeast(n: number): Parser; + /** + * returns a new parser whose failure message is the passed description. + */ + mark(): Parser>; + /** + * Returns a new parser whose failure message is description. + * For example, string('x').desc('the letter x') will indicate that 'the letter x' was expected. + */ + desc(description: string): Parser; + } + + /** + * Alias of `Parsimmon(fn)` for backwards compatibility. */ - export function string(string: string): Parser; + export function Parser(fn: (input: string, i: number) => Parsimmon.Result): Parser; - /** - * Returns a parser that looks for exactly one character from string, and yields that character. - */ - export function oneOf(string: string): Parser; - - /** - * Returns a parser that looks for exactly one character NOT from string, and yields that character. - */ - export function noneOf(string: string): Parser; - - /** - * Returns a parser that looks for a match to the regexp and yields the given match group - * (defaulting to the entire match). The regexp will always match starting at the current - * parse location. The regexp may only use the following flags: imu. Any other flag will - * result in an error being thrown. + /** + * To be used inside of Parsimmon(fn). Generates an object describing how + * far the successful parse went (index), and what value it created doing + * so. See documentation for Parsimmon(fn). */ - export function regexp(myregex: RegExp, group?: number): Parser; + export function makeSuccess(index: number, value: T): Success; - /** - * This was the original name for Parsimmon.regexp, but now it is just an alias. - */ - export function regex(myregex: RegExp, group?: number): Parser; - - /** - * Returns a parser that doesn't consume any of the string, and yields result. + /** + * To be used inside of Parsimmon(fn). Generates an object describing how + * far the unsuccessful parse went (index), and what kind of syntax it + * expected to see (expectation). See documentation for Parsimmon(fn). */ - export function succeed(result: U): Parser; + export function makeFailure(furthest: number, expectation: string): Failure; - /** - * This is an alias for Parsimmon.succeed(result). - */ - export function of(result: U): Parser; - - /** - * accepts a variable number of parsers that it expects to find in order, yielding an array of the results. + /** + * Returns true if obj is a Parsimmon parser, otherwise false. */ - export function seq(p1: Parser): Parser<[T]>; - export function seq(p1: Parser, p2: Parser): Parser<[T, U]>; - export function seq(p1: Parser, p2: Parser, p3: Parser): Parser<[T, U, V]>; - export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser): Parser<[T, U, V, W]>; - export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser): Parser<[T, U, V, W, X]>; - export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser): Parser<[T, U, V, W, X, Y]>; - export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser, p7: Parser): Parser<[T, U, V, W, X, Y, Z]>; - export function seq(...parsers: Parser[]): Parser; - export function seq(...parsers: Parser[]): Parser; + export function isParser(obj: any): boolean; - /** - * Takes the string passed to parser.parse(string) and the error returned from - * parser.parse(string) and turns it into a human readable error message string. - * Note that there are certainly better ways to format errors, so feel free to write your own. - */ - export function formatError(string: string, error: Result): string; + /** + * is a parser that expects to find "my-string", and will yield the same. + */ + export function string(string: string): Parser; - /** - * Matches all parsers sequentially, and passes their results as the arguments to a function. - * Similar to calling Parsimmon.seq and then .map, but the values are not put in an array. - */ - export function seqMap(p1: Parser, cb: (a1: T) => U): Parser; - export function seqMap(p1: Parser, p2: Parser, cb: (a1: T, a2: U) => V): Parser; - export function seqMap(p1: Parser, p2: Parser, p3: Parser, cb: (a1: T, a2: U, a3: V) => W): Parser; - export function seqMap(p1: Parser, p2: Parser, p3: Parser, p4: Parser, cb: (a1: T, a2: U, a3: V, a4: W) => X): Parser; - export function seqMap(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, cb: (a1: T, a2: U, a3: V, a4: W, a5: X) => Y): Parser; - export function seqMap(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser, cb: (a1: T, a2: U, a3: V, a4: W, a5: X, a6: Y) => Z): Parser; + /** + * Returns a parser that looks for exactly one character from string, and yields that character. + */ + export function oneOf(string: string): Parser; - export type SuccessFunctionType = (index: number, result: U) => Result; - export type FailureFunctionType = (index: number, msg: string) => Result; - export type ParseFunctionType = (stream: StreamType, index: number) => Result; + /** + * Returns a parser that looks for exactly one character NOT from string, and yields that character. + */ + export function noneOf(string: string): Parser; + + /** + * Returns a parser that looks for a match to the regexp and yields the given match group + * (defaulting to the entire match). The regexp will always match starting at the current + * parse location. The regexp may only use the following flags: imu. Any other flag will + * result in an error being thrown. + */ + export function regexp(myregex: RegExp, group?: number): Parser; + + /** + * This was the original name for Parsimmon.regexp, but now it is just an alias. + */ + export function regex(myregex: RegExp, group?: number): Parser; + + /** + * Returns a parser that doesn't consume any of the string, and yields result. + */ + export function succeed(result: U): Parser; + + /** + * This is an alias for Parsimmon.succeed(result). + */ + export function of(result: U): Parser; + + /** + * accepts a variable number of parsers that it expects to find in order, yielding an array of the results. + */ + export function seq(p1: Parser): Parser<[T]>; + export function seq(p1: Parser, p2: Parser): Parser<[T, U]>; + export function seq(p1: Parser, p2: Parser, p3: Parser): Parser<[T, U, V]>; + export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser): Parser<[T, U, V, W]>; + export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser): Parser<[T, U, V, W, X]>; + export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser): Parser<[T, U, V, W, X, Y]>; + export function seq(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser, p7: Parser): Parser<[T, U, V, W, X, Y, Z]>; + export function seq(...parsers: Array>): Parser; + export function seq(...parsers: Array>): Parser; + + /** + * Takes the string passed to parser.parse(string) and the error returned from + * parser.parse(string) and turns it into a human readable error message string. + * Note that there are certainly better ways to format errors, so feel free to write your own. + */ + export function formatError(string: string, error: Result): string; + + /** + * Matches all parsers sequentially, and passes their results as the arguments to a function. + * Similar to calling Parsimmon.seq and then .map, but the values are not put in an array. + */ + export function seqMap(p1: Parser, cb: (a1: T) => U): Parser; + export function seqMap(p1: Parser, p2: Parser, cb: (a1: T, a2: U) => V): Parser; + export function seqMap(p1: Parser, p2: Parser, p3: Parser, cb: (a1: T, a2: U, a3: V) => W): Parser; + export function seqMap(p1: Parser, p2: Parser, p3: Parser, p4: Parser, cb: (a1: T, a2: U, a3: V, a4: W) => X): Parser; + export function seqMap(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, cb: (a1: T, a2: U, a3: V, a4: W, a5: X) => Y): Parser; + export function seqMap(p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser, cb: (a1: T, a2: U, a3: V, a4: W, a5: X, a6: Y) => Z): Parser; + export function seqMap( + p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser, p7: Parser, + cb: (a1: T, a2: U, a3: V, a4: W, a5: X, a6: Y, a7: Z) => A): Parser; + export function seqMap( + p1: Parser, p2: Parser, p3: Parser, p4: Parser, p5: Parser, p6: Parser, p7: Parser, p8: Parser, + cb: (a1: T, a2: U, a3: V, a4: W, a5: X, a6: Y, a7: Z, a8: A) => B): Parser; + + export type SuccessFunctionType = (index: number, result: U) => Result; + export type FailureFunctionType = (index: number, msg: string) => Result; + export type ParseFunctionType = (stream: StreamType, index: number) => Result; /** * allows to add custom primitive parsers. */ - export function custom(parsingFunction: (success: SuccessFunctionType, failure: FailureFunctionType) => ParseFunctionType): Parser; + export function custom(parsingFunction: (success: SuccessFunctionType, failure: FailureFunctionType) => ParseFunctionType): Parser; - /** - * accepts a variable number of parsers, and yields the value of the first one that succeeds, - * backtracking in between. + /** + * accepts a variable number of parsers, and yields the value of the first one that succeeds, + * backtracking in between. */ - export function alt(...parsers: Parser[]): Parser; - export function alt(...parsers: Parser[]): Parser; + export function alt(...parsers: Array>): Parser; + export function alt(...parsers: Array>): Parser; - /** - * Accepts two parsers, and expects zero or more matches for content, separated by separator, yielding an array. - */ - export function sepBy(content: Parser, separator: Parser): Parser + /** + * Accepts two parsers, and expects zero or more matches for content, separated by separator, yielding an array. + */ + export function sepBy(content: Parser, separator: Parser): Parser; - /** - * This is the same as Parsimmon.sepBy, but matches the content parser at least once. - */ - export function sepBy1(content: Parser, separator: Parser): Parser + /** + * This is the same as Parsimmon.sepBy, but matches the content parser at least once. + */ + export function sepBy1(content: Parser, separator: Parser): Parser; - /** - * accepts a function that returns a parser, which is evaluated the first time the parser is used. - * This is useful for referencing parsers that haven't yet been defined. + /** + * accepts a function that returns a parser, which is evaluated the first time the parser is used. + * This is useful for referencing parsers that haven't yet been defined. */ - export function lazy(f: () => Parser): Parser; - export function lazy(description: string, f: () => Parser): Parser; + export function lazy(f: () => Parser): Parser; + export function lazy(description: string, f: () => Parser): Parser; - /** - * fail paring with a message + /** + * fail paring with a message */ - export function fail(message: string): Parser; - export function fail(message: string): Parser; + export function fail(message: string): Parser; - /** - * is equivalent to Parsimmon.regex(/[a-z]/i) + /** + * is equivalent to Parsimmon.regex(/[a-z]/i) */ - export var letter: Parser; - /** - * is equivalent to Parsimmon.regex(/[a-z]*`/i) + export var letter: Parser; + /** + * is equivalent to Parsimmon.regex(/[a-z]*`/i) */ - export var letters: Parser; - /** - * is equivalent to Parsimmon.regex(/[0-9]/) + export var letters: Parser; + /** + * is equivalent to Parsimmon.regex(/[0-9]/) */ - export var digit: Parser; - /** - * is equivalent to Parsimmon.regex(/[0-9]*`/) + export var digit: Parser; + /** + * is equivalent to Parsimmon.regex(/[0-9]*`/) */ - export var digits: Parser; - /** - * is equivalent to Parsimmon.regex(/\s+/) + export var digits: Parser; + /** + * is equivalent to Parsimmon.regex(/\s+/) */ - export var whitespace: Parser; - /** - * is equivalent to Parsimmon.regex(/\s*`/) + export var whitespace: Parser; + /** + * is equivalent to Parsimmon.regex(/\s*`/) */ - export var optWhitespace: Parser; - /** - * consumes and yields the next character of the stream. + export var optWhitespace: Parser; + /** + * consumes and yields the next character of the stream. */ - export var any: Parser; - /** - * consumes and yields the entire remainder of the stream. + export var any: Parser; + /** + * consumes and yields the entire remainder of the stream. */ - export var all: Parser; - /** - * expects the end of the stream. + export var all: Parser; + /** + * expects the end of the stream. */ - export var eof: Parser; - /** - * is a parser that yields the current index of the parse. + export var eof: Parser; + /** + * is a parser that yields the current index of the parse. */ - export var index: Parser; - /** - * Returns a parser that yield a single character if it passes the predicate - */ - export function test(predicate: (char: string) => boolean): Parser; - /** - * Returns a parser yield a string containing all the next characters that pass the predicate - */ - export function takeWhile(predicate: (char: string) => boolean): Parser; + export var index: Parser; + /** + * Returns a parser that yield a single character if it passes the predicate + */ + export function test(predicate: (char: string) => boolean): Parser; + /** + * Returns a parser yield a string containing all the next characters that pass the predicate + */ + export function takeWhile(predicate: (char: string) => boolean): Parser; } export = Parsimmon; diff --git a/parsimmon/parsimmon-tests.ts b/parsimmon/parsimmon-tests.ts index 011148973a..e0c6e0b00c 100644 --- a/parsimmon/parsimmon-tests.ts +++ b/parsimmon/parsimmon-tests.ts @@ -1,9 +1,6 @@ import P = require('parsimmon'); -import Parser = P.Parser; -import Mark = P.Mark; -import Result = P.Result; -import Index = P.Index; +import { Parser, Mark, Result, Index } from "parsimmon"; // -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -18,6 +15,7 @@ class Bar { // -- -- -- -- -- -- -- -- -- -- -- -- -- var str: string; +var strArr: string[]; var bool: boolean; var num: number; var index: Index; @@ -53,23 +51,29 @@ var barArrPar: Parser; var fooMarkPar: Parser>; -index = fooMarkPar.parse(str).value.start; -index = fooMarkPar.parse(str).value.end; -foo = fooMarkPar.parse(str).value.value; +const result = fooMarkPar.parse(str); +if (result.status) { + index = result.value.start; + index = result.value.end; + foo = result.value.value; +} // -- -- -- -- -- -- -- -- -- -- -- -- -- var fooResult: Result; -bool = fooResult.status; -foo = fooResult.value; -str = fooResult.expected; -index = fooResult.index; +// https://github.com/Microsoft/TypeScript/issues/12882 +if (fooResult.status === true) { + foo = fooResult.value; +} else { + strArr = fooResult.expected; + index = fooResult.index; +} // -- -- -- -- -- -- -- -- -- -- -- -- -- fooResult = P.makeSuccess(0, foo); -fooResult = P.makeFailure(0, ''); +fooResult = P.makeFailure(0, ''); fooPar = P((input: string, i: number) => P.makeSuccess(0, foo)); fooPar = P.Parser((input: string, i: number) => P.makeSuccess(0, foo)); @@ -139,7 +143,7 @@ fooPar = P.lazy(() => { }); voidPar = P.fail(str); -fooPar = P.fail(str); +fooPar = P.fail(str); // -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/parsimmon/tslint.json b/parsimmon/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/parsimmon/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 43a2d51e2dad723f54e2f67c592d725e931debd1 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 13 Dec 2016 17:10:36 +0100 Subject: [PATCH 09/22] Update emojione format --- .../{emojione-test.ts => emojione-tests.ts} | 2 +- emojione/{emojione.d.ts => index.d.ts} | 0 emojione/tsconfig.json | 19 +++++++++++++++++++ emojione/tslint.json | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) rename emojione/{emojione-test.ts => emojione-tests.ts} (92%) rename emojione/{emojione.d.ts => index.d.ts} (100%) create mode 100644 emojione/tsconfig.json create mode 100644 emojione/tslint.json diff --git a/emojione/emojione-test.ts b/emojione/emojione-tests.ts similarity index 92% rename from emojione/emojione-test.ts rename to emojione/emojione-tests.ts index cdb38d7c90..075b9c530e 100644 --- a/emojione/emojione-test.ts +++ b/emojione/emojione-tests.ts @@ -1,4 +1,4 @@ -/// +/// emojione.sprites = true; emojione.imagePathPNG = 'foobar'; diff --git a/emojione/emojione.d.ts b/emojione/index.d.ts similarity index 100% rename from emojione/emojione.d.ts rename to emojione/index.d.ts diff --git a/emojione/tsconfig.json b/emojione/tsconfig.json new file mode 100644 index 0000000000..67f76849f1 --- /dev/null +++ b/emojione/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "emojione-tests.ts" + ] +} diff --git a/emojione/tslint.json b/emojione/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/emojione/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From af02184d5973809386e8b2e3db7bb45b60383771 Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Tue, 13 Dec 2016 11:11:05 -0500 Subject: [PATCH 10/22] d3-axis strictNullChecks, Fix, Enhancement: * [Enhancement] Validated, updated and activated for use with `strictNullChecks`. Tests updated * [Fix] Commented out tick and tickFormat signatures which have been separated out in to the overloads corresponding to a numeric continuous scale vs a time scale. Consolidated as well as separated out signatures for these two optional methods create compiler errors, the compiler ignores the optionality of each individual overload when checking type compatibility during assingment (Note, they are not mandatory for each specific scale, but when in existence will be used by d3-axis internally. So commenting out is not ideal, but rather a compromise.) * [Chore] Added additional test lines for th AxisScale interface when used with Band- and Point Scales * [Enhancement] Expanded the Axis.tickFormat signature to allow for the second argument passed to the format function internally, i.e. the zero-based index of the tick label in the array of tick labels (As per suggested use case provided by@gustavderdrache). Updated tests. * [Chore] Updated definition header * [Chore] Linting. Includes adding of a lint rule de-activation for "unified-signatures" --- d3-axis/d3-axis-tests.ts | 35 ++++++++++++++++++++++------------- d3-axis/index.d.ts | 26 ++++++++++++++++---------- d3-axis/tsconfig.json | 2 +- d3-axis/tslint.json | 6 ++++++ 4 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 d3-axis/tslint.json diff --git a/d3-axis/d3-axis-tests.ts b/d3-axis/d3-axis-tests.ts index a95c58c8b3..1aa50ba641 100644 --- a/d3-axis/d3-axis-tests.ts +++ b/d3-axis/d3-axis-tests.ts @@ -8,16 +8,20 @@ import * as d3Axis from 'd3-axis'; import { + scaleBand, + ScaleBand, scaleLinear, ScaleLinear, scaleOrdinal, ScaleOrdinal, + scalePoint, + ScalePoint, scalePow, ScalePower, scaleTime, - ScaleTime, + ScaleTime } from 'd3-scale'; -import { Selection } from 'd3-selection'; +import { select, Selection } from 'd3-selection'; import { Transition } from 'd3-transition'; import { timeMinute } from 'd3-time'; import { format } from 'd3-format'; @@ -41,15 +45,18 @@ let axisScaleString: d3Axis.AxisScale; axisScaleNumber = scaleLinear(); axisScaleDate = scaleTime(); axisScaleString = scaleOrdinal(); - +axisScaleNumber = scaleBand(); +axisScaleNumber = scalePoint(); +axisScaleString = scaleBand(); +axisScaleString = scalePoint(); // -------------------------------------------------------------------------- // Test AxisContainerElement // -------------------------------------------------------------------------- let containerElement: d3Axis.AxisContainerElement; -let svg: SVGSVGElement, - g: SVGGElement, - canvas: HTMLCanvasElement; +const svg: SVGSVGElement = select('svg').node() !; //mock +const g: SVGGElement = select('g').node() !; //mock +const canvas: HTMLCanvasElement = select('canvas').node() !; //mock containerElement = svg; containerElement = g; @@ -60,7 +67,7 @@ containerElement = g; // -------------------------------------------------------------------------- let topAxis: d3Axis.Axis = d3Axis.axisTop(scaleLinear()); -let rightAxis: d3Axis.Axis = d3Axis.axisRight(scaleTime()); +let rightAxis: d3Axis.Axis = d3Axis.axisRight(scaleTime()); let bottomAxis: d3Axis.Axis = d3Axis.axisBottom(scaleOrdinal()); let leftAxis: d3Axis.Axis = d3Axis.axisLeft(scaleLinear()); @@ -95,7 +102,7 @@ topAxis = topAxis.tickArguments([20, 's']); rightAxis = rightAxis.tickArguments([timeMinute.every(5)]); -let tickArguments: Array = leftAxis.tickArguments(); +let tickArguments: any[] = leftAxis.tickArguments(); // tickValues(...) ---------------------------------------------------------------- @@ -105,15 +112,17 @@ bottomAxis = bottomAxis.tickValues(['strongly negative', 'strongly positive']); leftAxis = leftAxis.tickValues(null); -let tickValues: Array = rightAxis.tickValues(); +let tickValues: Date[] | null = rightAxis.tickValues(); // tickFormat(...) ---------------------------------------------------------------- topAxis = topAxis.tickFormat(format(',.0f')); topAxis = topAxis.tickFormat(null); -let formatFn: (domainValue: string) => string = bottomAxis.tickFormat(); +let formatFn: ((domainValue: string, index: number) => string) | null = bottomAxis.tickFormat(); +bottomAxis.tickFormat(function (d, i) { return '#' + i; }); +bottomAxis.tickFormat(function (d) { return d + '!'; }); // tickSize(...) ---------------------------------------------------------------- rightAxis = rightAxis.tickSize(5); @@ -138,19 +147,19 @@ num = rightAxis.tickPadding(); // Test Apply Axis // -------------------------------------------------------------------------- -let gSelection: Selection; +let gSelection: Selection = select('g'); let gTransition = gSelection.transition(); gSelection.call(topAxis); gTransition.call(topAxis); -let svgSelection: Selection; +let svgSelection: Selection = select('g'); let svgTransition = svgSelection.transition(); svgSelection.call(leftAxis); svgTransition.call(leftAxis); -let canvasSelection: Selection; +let canvasSelection: Selection = select('canvas'); let canvasTransition = canvasSelection.transition(); // canvasSelection.call(rightAxis); // fails, incompatible context container element diff --git a/d3-axis/index.d.ts b/d3-axis/index.d.ts index e663743d44..cd8ed94714 100644 --- a/d3-axis/index.d.ts +++ b/d3-axis/index.d.ts @@ -1,8 +1,10 @@ -// Type definitions for D3JS d3-axis module v1.0.3 +// Type definitions for D3JS d3-axis module 1.0 // Project: https://github.com/d3/d3-axis/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Last module patch version validated against: 1.0.4 + import { Selection, TransitionLike } from 'd3-selection'; // -------------------------------------------------------------------------- @@ -31,13 +33,16 @@ export interface AxisTimeInterval { * for axis to use the scale without error */ export interface AxisScale { - (x: Domain): number; - domain(): Array; - range(): Array; - copy(): AxisScale; + (x: Domain): number | undefined; + domain(): Domain[]; + range(): number[]; + copy(): this; bandwidth?(): number; - ticks?(count: number | AxisTimeInterval): Array | Array; - tickFormat?(count: number | AxisTimeInterval, specifier?: string): ((d: number) => string) | ((d: Date) => string); + // TODO: Reconsider the below, note that the compiler does not differentiate the overloads w.r.t. optionality + // ticks?(count?: number): Domain[]; + // ticks?(count?: AxisTimeInterval): Date[]; + // tickFormat?(count?: number, specifier?: string): ((d: number) => string); + // tickFormat?(count?: number | AxisTimeInterval, specifier?: string): ((d: Date) => string); } /** @@ -170,15 +175,16 @@ export interface Axis { /** * Returns the currently set tick format function, which defaults to null. */ - tickFormat(): ((domainValue: Domain) => string) | null; + tickFormat(): ((domainValue: Domain, index: number) => string) | null; /** * Sets the tick format function and returns the axis. * * @param format A function mapping a value from the axis Domain to a formatted string - * for display purposes. + * for display purposes. When invoked, the format function is also passed a second argument representing the zero-based index + * of the tick label in the array of generated tick labels. */ - tickFormat(format: (domainValue: Domain) => string): this; + tickFormat(format: (domainValue: Domain, index: number) => string): this; /** * Reset the tick format function. A null format indicates that the scale’s diff --git a/d3-axis/tsconfig.json b/d3-axis/tsconfig.json index b568e25181..225b56ee11 100644 --- a/d3-axis/tsconfig.json +++ b/d3-axis/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/d3-axis/tslint.json b/d3-axis/tslint.json new file mode 100644 index 0000000000..68d10d72a6 --- /dev/null +++ b/d3-axis/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false + } +} From 737b44634be870c6fb435fc2f660acecce523769 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 13 Dec 2016 18:00:59 +0100 Subject: [PATCH 11/22] Remove reference from tests --- emojione/emojione-tests.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/emojione/emojione-tests.ts b/emojione/emojione-tests.ts index 075b9c530e..ea5d04e217 100644 --- a/emojione/emojione-tests.ts +++ b/emojione/emojione-tests.ts @@ -1,5 +1,3 @@ -/// - emojione.sprites = true; emojione.imagePathPNG = 'foobar'; emojione.imagePathSVG = 'foobar'; From 2fc133fc04d4b5a3a67f7e47559a122eb91dcd0a Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 13 Dec 2016 18:01:08 +0100 Subject: [PATCH 12/22] Export as namespace --- emojione/index.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/emojione/index.d.ts b/emojione/index.d.ts index f273d34460..f6136f04e0 100644 --- a/emojione/index.d.ts +++ b/emojione/index.d.ts @@ -3,18 +3,18 @@ // Definitions by: Danilo Bargen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare var emojione: { - sprites: boolean, - imagePathPNG: string, - imagePathSVG: string, - imagePathSVGSprites: string, - imageType: 'png' | 'svg', - unicodeAlt: boolean, - ascii: boolean, - unicodeRegexp: string, - cacheBustParam: string, - toShort: (str: string) => string, - toImage: (str: string) => string, - shortnameToImage: (str: string) => string, - unicodeToImage: (str: string) => string, -}; +export as namespace emojione; + +export var sprites: boolean; +export var imagePathPNG: string; +export var imagePathSVG: string; +export var imagePathSVGSprites: string; +export var imageType: 'png' | 'svg'; +export var unicodeAlt: boolean; +export var ascii: boolean; +export var unicodeRegexp: string; +export var cacheBustParam: string; +export function toShort(str: string): string; +export function toImage(str: string): string; +export function shortnameToImage(str: string): string; +export function unicodeToImage(str: string): string; From cb9f03c317ed0e1697f90be7abc29a76b9139a53 Mon Sep 17 00:00:00 2001 From: Fredrik Smedberg Date: Tue, 13 Dec 2016 18:31:23 +0100 Subject: [PATCH 13/22] Removed all callbacks and fixed the return types of many methods. They're now chainable and IntelliSense now correctly shows the merge of the Client object and the given data type, where applicable. --- webdriverio/index.d.ts | 577 ++++++++++--------------------- webdriverio/webdriverio-tests.ts | 53 ++- 2 files changed, 204 insertions(+), 426 deletions(-) diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index 5734bc3990..1ab7b20452 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -212,13 +212,8 @@ declare namespace WebdriverIO { getCookie(): Client; getCookie(name: string): Client; - getCookie

( - callback: (err: any, cookies: Cookie[]) => P - ): Client

; - getCookie

( - name: string, - callback: (err: any, cookie: Cookie) => P - ): Client

; + getCookie

(): Client

; + getCookie

(name: string): Client

; setCookie(cookie: Cookie): Client; setCookie

(cookie: Cookie): Client

; @@ -226,24 +221,16 @@ declare namespace WebdriverIO { export interface Client { session(action?: string, sessionId?: string): Client>; - session

( - callback: (err: any, result: RawResult) => P - ): Client

; + session

(): Client

; getGridNodeDetails(): Client; - getGridNodeDetails

( - callback: (err: any, details: Object) => P - ): Client

; + getGridNodeDetails

(): Client

; gridProxyDetails(): Client; - gridProxyDetails

( - callback: (err: any, result: Object) => P - ): Client

; + gridProxyDetails

(): Client

; gridTestSession(): Client; - gridProxyDetails

( - callback: (err: any, result: Object) => P - ): Client

; + gridProxyDetails

(): Client

; } // Mobile @@ -288,154 +275,106 @@ declare namespace WebdriverIO { // Property export interface Client { - getAttribute(selector: string, attributeName: string): Client; - getAttribute(attributeName: string): Client; + getAttribute(selector: string, attributeName: string): Client & string; + getAttribute(selector: string, attributeName: string): Client & string[]; + getAttribute(attributeName: string): Client & string; + getAttribute(attributeName: string): Client & string[]; getAttribute

( selector: string, - attributeName: string, - callback: (err: any, attribute: string | string[]) => P - ): Client

; - getAttribute

( - attributeName: string, - callback: (err: any, attribute: string | string[]) => P + attributeName: string ): Client

; + getAttribute

(attributeName: string): Client

; - getCssProperty(selector: string, cssProperty: string): Client; - getCssProperty(cssProperty: string): Client; + getCssProperty(selector: string, cssProperty: string): CssProperty; + getCssProperty(selector: string, cssProperty: string): CssProperty[]; + getCssProperty(cssProperty: string): CssProperty; + getCssProperty(cssProperty: string): CssProperty[]; getCssProperty

( selector: string, - cssProperty: string, - callback: (err: any, cssProperty: CssProperty | CssProperty[]) => P - ): Client

; - getCssProperty

( - cssProperty: string, - callback: (err: any, cssProperty: CssProperty | CssProperty[]) => P + cssProperty: string ): Client

; + getCssProperty

(cssProperty: string): Client

; - getElementSize(selector: string): Client; - getElementSize(): Client; - getElementSize(selector: string, dimension: string): Client; - getElementSize(dimension: string): Client; + getElementSize(selector: string): Client & Size; + getElementSize(selector: string): Client & Size[]; + getElementSize(): Client & Size|Size[]; + getElementSize(selector: string, dimension: string): number; + getElementSize(selector: string, dimension: string): number[]; + getElementSize(dimension: string): number ; + getElementSize(dimension: string): number[]; + getElementSize

(selector: string): Client

; + getElementSize

(): Client

; getElementSize

( selector: string, - callback: (err: any, size: Size | Size[]) => P - ): Client

; - getElementSize

( - callback: (err: any, size: Size | Size[]) => P - ): Client

; - getElementSize

( - selector: string, - dimension: string, - callback: (err: any, elementSize: number | number[]) => P - ): Client

; - getElementSize

( - dimension: string, - callback: (err: any, elementSize: number | number[]) => P + dimension: string ): Client

; + getElementSize

(dimension: string): Client

; - getHTML(selector: string, includeSelectorTag?: boolean): Client; - getHTML(includeSelectorTag?: boolean): Client; + getHTML(selector: string, includeSelectorTag?: boolean): string; + getHTML(selector: string, includeSelectorTag?: boolean): string[]; + getHTML(includeSelectorTag?: boolean): string; + getHTML(includeSelectorTag?: boolean): string[]; + getHTML

( + selector: string + ): Client

; + getHTML

(): Client

; getHTML

( selector: string, - callback: (err: any, html: string | string[]) => P - ): Client

; - getHTML

( - callback: (err: any, html: string | string[]) => P - ): Client

; - getHTML

( - selector: string, - includeSelectorTag: boolean, - callback: (err: any, html: string | string[]) => P - ): Client

; - getHTML

( - includeSelectorTag: boolean, - callback: (err: any, html: string | string[]) => P + includeSelectorTag: boolean ): Client

; + getHTML

(includeSelectorTag: boolean): Client

; - getLocation(selector: string): Client; - getLocation(): Client; - getLocation(selector: string, axis: string): Client; - getLocation(axis: string): Client; + getLocation(selector: string): Size; + getLocation(): Size; + getLocation(selector: string, axis: string): number; + getLocation(axis: string): number; + getLocation

(selector: string): Client

; + getLocation

(): Client

; getLocation

( selector: string, - callback: (err: any, size: Size) => P - ): Client

; - getLocation

( - callback: (err: any, size: Size) => P - ): Client

; - getLocation

( - selector: string, - axis: string, - callback: (err: any, location: number) => P - ): Client

; - getLocation

( - axis: string, - callback: (err: any, location: number) => P + axis: string ): Client

; + getLocation

(axis: string): Client

; - getLocationInView(selector: string): Client; - getLocationInView(): Client; - getLocationInView(selector: string, axis: string): Client; - getLocationInView(axis: string): Client; + getLocationInView(selector: string): Size; + getLocationInView(selector: string): Size[]; + getLocationInView(): Size; + getLocationInView(): Size[]; + getLocationInView(selector: string, axis: string): number; + getLocationInView(selector: string, axis: string): number[]; + getLocationInView(axis: string): number; + getLocationInView(axis: string): number[]; + getLocationInView

(selector: string): Client

; + getLocationInView

(): Client

; getLocationInView

( selector: string, - callback: (err: any, size: Size | Size[]) => P - ): Client

; - getLocationInView

( - callback: (err: any, size: Size | Size[]) => P - ): Client

; - getLocationInView

( - selector: string, - axis: string, - callback: (err: any, location: number | number[]) => P - ): Client

; - getLocationInView

( - axis: string, - callback: (err: any, location: number | number[]) => P + axis: string ): Client

; + getLocationInView

(axis: string): Client

; getSource(): Client; - getSource

(callback: (err: any, source: string) => P): Client

; + getSource

(): Client

; - getTagName(selector: string): Client; - getTagName(): Client; - getTagName

( - selector: string, - callback: (err: any, tagName: string | string[]) => P - ): Client

; - getTagName

( - callback: (err: any, tagName: string | string[]) => P - ): Client

; + getTagName(selector: string): string | string[]; + getTagName(): string | string[]; + getTagName

(selector: string): Client

; + getTagName

(): Client

; - getText(selector: string): Client; - getText(): Client; - getText

( - selector: string, - callback: (err: any, text: string | string[]) => P - ): Client

; - getText

( - callback: (err: any, text: string | string[]) => P - ): Client

; + getText(selector: string): string | string[]; + getText(): string | string[]; + getText

(selector: string): Client

; + getText

(): Client

; getTitle(): Client; - getTitle

( - callback: (err: any, title: string) => P - ): Client

; + getTitle

(): Client

; getUrl(): Client; - getUrl

( - callback: (err: any, title: string) => P - ): Client

; + getUrl

(): Client

; - getValue(selector: string): Client; - getValue(): Client; - getValue

( - selector: string, - callback: (err: any, value: string | string[]) => P - ): Client

; - getValue

( - callback: (err: any, value: string | string[]) => P - ): Client

; + getValue(selector: string): string | string[]; + getValue(): string | string[]; + getValue

(selector: string): Client

; + getValue

(): Client

; } export interface LogEntry { @@ -490,11 +429,9 @@ declare namespace WebdriverIO { refresh(): Client; refresh

(): Client

; - url(): Client>; + url(): Client> & RawResult; url(url: string): Client; - url

( - callback: (err: any, result: RawResult) => P - ): Client

; + url

(): Client

; url

(url: string): Client

; } @@ -557,13 +494,8 @@ declare namespace WebdriverIO { alertDismiss

(): Client

; alertText(text?: string): Client; - alertText

( - callback: (err: any, text: string) => P - ): Client

; - alertText

( - text: string, - callback: (err: any, text: string) => P - ): Client

; + alertText

(): Client

; + alertText

(text: string): Client

; frame(id: any): Client; frame

(id: any): Client

; @@ -576,34 +508,21 @@ declare namespace WebdriverIO { init

(capabilities: DesiredCapabilities): Client

; log(type: string): Client>; - log

( - type: string, - callback: (err: any, result: RawResult) => P - ): Client

; + log

(type: string): Client

; - logTypes(): Client>; - logTypes

( - callback: (err: any, result: RawResult) => P - ): Client

; + logTypes(): Client> & RawResult; + logTypes

(): Client

; - session(action?: string, sessionId?: string): Client>; - session

( - callback: (err: any, result: RawResult) => P - ): Client

; + session(action?: string, sessionId?: string): Client> & RawResult; + session

(): Client

; + session

(action: string): Client

; session

( action: string, - callback: (err: any, result: RawResult) => P - ): Client

; - session

( - action: string, - sessionId: string, - callback: (err: any, result: RawResult) => P + sessionId: string ): Client

; sessions(): Client>; - sessions

( - callback: (err: any, sessions: RawResult) => P - ): Client

; + sessions

(): Client

; // timeouts // timeoutsAsyncScript @@ -625,22 +544,16 @@ declare namespace WebdriverIO { // Element export interface Client { - element(selector: string): Client>; - element

( - selector: string, - callback: (err: any, result: RawResult) => P - ): Client

; + element(selector: string): Client> & RawResult; + element

(selector: string): Client

; - elementActive(): Client>; - elementActive

( - callback: (err: any, element: Element) => P - ): Client

; + elementActive(): Client> & RawResult; + elementActive

(): Client

; - elementIdAttribute(id: ElementId, attributeName: string): Client>; + elementIdAttribute(id: ElementId, attributeName: string): Client> & RawResult; elementIdAttribute

( id: ElementId, - attributeName: string, - callback: (err: any, result: RawResult) => P + attributeName: string ): Client

; elementIdClear(id: ElementId): Client; @@ -649,87 +562,56 @@ declare namespace WebdriverIO { elementIdClick(id: ElementId): Client; elementIdClick

(id: ElementId): Client

; - elementIdCssProperty(id: ElementId, propertyName: string): Client>; + elementIdCssProperty(id: ElementId, propertyName: string): Client> & RawResult; elementIdCssProperty

( id: ElementId, - propertyName: string, - callback: (err: any, result: RawResult) => P + propertyName: string ): Client

; - elementIdDisplayed(id: ElementId): Client>; - elementIdDisplayed

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdDisplayed(id: ElementId): Client> & RawResult; + elementIdDisplayed

(id: ElementId): Client

; - elementIdElement(id: ElementId, selector: string): Client>; + elementIdElement(id: ElementId, selector: string): Client> & RawResult; elementIdElement

( id: ElementId, - selector: string, - callback: (err: any, result: RawResult) => P + selector: string ): Client

; - elementIdElements(id: ElementId, selector: string): Client>; + elementIdElements(id: ElementId, selector: string): Client> & RawResult; elementIdElements

( id: ElementId, - selector: string, - callback: (err: any, result: RawResult) => P + selector: string ): Client

; - elementIdEnabled(id: ElementId): Client>; - elementIdEnabled

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdEnabled(id: ElementId): Client> & RawResult; + elementIdEnabled

(id: ElementId): Client

; - elementIdLocation(id: ElementId): Client>; - elementIdLocation

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdLocation(id: ElementId): Client> & RawResult; + elementIdLocation

(id: ElementId): Client

; - elementIdLocationInView(id: ElementId): Client>; - elementIdLocationInView

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdLocationInView(id: ElementId): Client> & RawResult; + elementIdLocationInView

(id: ElementId): Client

; - elementIdName(id: ElementId): Client>; - elementIdName

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdName(id: ElementId): RawResult; + elementIdName

(id: ElementId): Client

; - elementIdSelected(id: ElementId): Client>; - elementIdSelected

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdSelected(id: ElementId): Client> & RawResult; + elementIdSelected

(id: ElementId): Client

; - elementIdSize(id: ElementId): Client>; - elementIdSize

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdSize(id: ElementId): Client> & RawResult; + elementIdSize

(id: ElementId): Client

; - elementIdText(id: ElementId): Client>; - elementIdText

( - id: ElementId, - callback: (err: any, result: RawResult) => P - ): Client

; + elementIdText(id: ElementId): Client> & RawResult; + elementIdText

(id: ElementId): Client

; elementIdValue(id: ElementId, values: string | string[]): Client>; elementIdValue

( id: ElementId, - values: string | string[], - callback: (err: any, result: RawResult) => P + values: string | string[] ): Client

; - elements(selector: string): Client>; - elements

( - selector: string, - callback: (err: any, result: RawResult) => P - ): Client

; + elements(selector: string): Client> & RawResult; + elements

(selector: string): Client

; } // Unuseful Protocol @@ -738,10 +620,10 @@ declare namespace WebdriverIO { // cookie // use selectorExecute instead - execute(script: string | Function, ...args: any[]): Client>; + execute(script: string | Function, ...args: any[]): Client> & RawResult; // use selectorExecuteAsync instead - executeAsync(script: string | Function, ...args: any[]): Client>; + executeAsync(script: string | Function, ...args: any[]): Client> & RawResult; // file // imeActivate @@ -770,53 +652,28 @@ declare namespace WebdriverIO { export interface Client { isEnabled(selector: string): Client; isEnabled(): Client; - isEnabled

( - selector: string, - callback: (err: any, isEnabled: boolean) => P - ): Client

; - isEnabled

( - callback: (err: any, isEnabled: boolean) => P - ): Client

; + isEnabled

(selector: string): Client

; + isEnabled

(): Client

; isExisting(selector: string): Client; isExisting(): Client; - isExisting

( - selector: string, - callback: (err: any, isExisting: boolean) => P - ): Client

; - isExisting

( - callback: (err: any, isExisting: boolean) => P - ): Client

; + isExisting

(selector: string): Client

; + isExisting

(): Client

; isSelected(selector: string): Client; isSelected(): Client; - isSelected

( - selector: string, - callback: (err: any, isSelected: boolean) => P - ): Client

; - isSelected

( - callback: (err: any, isSelected: boolean) => P - ): Client

; + isSelected

(selector: string): Client

; + isSelected

(): Client

; isVisible(selector: string): Client; isVisible(): Client; - isVisible

( - selector: string, - callback: (err: any, isVisible: boolean) => P - ): Client

; - isVisible

( - callback: (err: any, isVisible: boolean) => P - ): Client

; + isVisible

(selector: string): Client

; + isVisible

(): Client

; isVisibleWithinViewport(selector: string): Client; isVisibleWithinViewport(): Client; - isVisibleWithinViewport

( - selector: string, - callback: (err: any, isVisible: boolean) => P - ): Client

; - isVisibleWithinViewport

( - callback: (err: any, isVisible: boolean) => P - ): Client

; + isVisibleWithinViewport

(selector: string): Client

; + isVisibleWithinViewport

(): Client

; } export interface CommandHistoryEntry { @@ -826,6 +683,8 @@ declare namespace WebdriverIO { // Utility export interface Client { + + addCommand(commandName: string, customMethod: Function, overwrite?: boolean): Client; addCommand

( commandName: string, @@ -855,21 +714,14 @@ declare namespace WebdriverIO { endAll

(): Client

; getCommandHistory(): Client; - getCommandHistory

( - callback: (err: any, history: CommandHistoryEntry[]) => P - ): Client

; + getCommandHistory

(): Client

; pause(milliseconds: number): Client; pause

(milliseconds: number): Client

; saveScreenshot(filename?: string): Client; - saveScreenshot

( - callback: (err: any, screenshot: Buffer) => P - ): Client

; - saveScreenshot

( - filename: string, - callback: (err: any, screenshot: Buffer) => P - ): Client

; + saveScreenshot

(): Client

; + saveScreenshot

(filename: string): Client

; scroll(selector: string): Client; scroll(): Client; @@ -892,182 +744,118 @@ declare namespace WebdriverIO { waitForEnabled(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForEnabled(milliseconds?: number, reverse?: boolean): Client; - waitForEnabled

( - selector: string, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForEnabled

( - callback: (err: any, enabled: boolean) => P - ): Client

; + waitForEnabled

(selector: string): Client

; + waitForEnabled

(): Client

; waitForEnabled

( selector: string, milliseconds: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForEnabled

( - milliseconds: number, - callback: (err: any, enabled: boolean) => P ): Client

; + waitForEnabled

(milliseconds: number): Client

; waitForEnabled

( selector: string, milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForEnabled

( milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForExist(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForExist(milliseconds?: number, reverse?: boolean): Client; + waitForExist

(selector: string): Client

; + waitForExist

(): Client

; waitForExist

( selector: string, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForExist

( - callback: (err: any, enabled: boolean) => P + milliseconds: number ): Client

; + waitForExist

(milliseconds: number): Client

; waitForExist

( selector: string, milliseconds: number, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForExist

( milliseconds: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForExist

( - selector: string, - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForExist

( - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForSelected(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForSelected(milliseconds?: number, reverse?: boolean): Client; + waitForSelected

(selector: string): Client

; + waitForSelected

(): Client

; waitForSelected

( selector: string, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForSelected

( - callback: (err: any, enabled: boolean) => P + milliseconds: number ): Client

; + waitForSelected

(milliseconds: number): Client

; waitForSelected

( selector: string, milliseconds: number, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForSelected

( milliseconds: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForSelected

( - selector: string, - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForSelected

( - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForText(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForText(milliseconds?: number, reverse?: boolean): Client; + waitForText

(selector: string): Client

; + waitForText

(): Client

; waitForText

( selector: string, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForText

( - callback: (err: any, enabled: boolean) => P + milliseconds: number ): Client

; + waitForText

(milliseconds: number): Client

; waitForText

( selector: string, milliseconds: number, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForText

( milliseconds: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForText

( - selector: string, - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForText

( - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForValue(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForValue(milliseconds?: number, reverse?: boolean): Client; + waitForValue

(selector: string): Client

; + waitForValue

(): Client

; waitForValue

( selector: string, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForValue

( - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForValue

( - selector: string, - milliseconds: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForValue

( - milliseconds: number, - callback: (err: any, enabled: boolean) => P + milliseconds: number ): Client

; + waitForValue

(milliseconds: number): Client

; waitForValue

( selector: string, milliseconds: number, reverse: boolean, - callback: (err: any, enabled: boolean) => P + ): Client

; waitForValue

( milliseconds: number, reverse: boolean, - callback: (err: any, enabled: boolean) => P + ): Client

; waitForVisible(selector: string, milliseconds?: number, reverse?: boolean): Client; waitForVisible(milliseconds?: number, reverse?: boolean): Client; + waitForVisible

(selector: string): Client

; + waitForVisible

(): Client

; waitForVisible

( selector: string, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForVisible

( - callback: (err: any, enabled: boolean) => P + milliseconds: number ): Client

; + waitForVisible

(milliseconds: number): Client

; waitForVisible

( selector: string, milliseconds: number, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitForVisible

( milliseconds: number, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForVisible

( - selector: string, - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P - ): Client

; - waitForVisible

( - milliseconds: number, - reverse: boolean, - callback: (err: any, enabled: boolean) => P + reverse: boolean ): Client

; waitUntil( @@ -1080,43 +868,34 @@ declare namespace WebdriverIO { condition: () => boolean | Q.IPromise, timeout?: number, timeoutMsg?: string, - interval?: number, - callback?: (err: any, enabled: boolean) => P + interval?: number ): Client

; } // Window export interface Client { + + close(windowHandle?: string): Client; close

(): Client

; close

(windowHandle: string): Client

; getCurrentTabId(): Client; - getCurrentTabId

( - callback: (err: any, tabId: string) => P - ): Client

; + getCurrentTabId

(): Client

; getTabIds(): Client; - getTabIds

( - callback: (err: any, tabIds: string[]) => P - ): Client

; + getTabIds

(): Client

; - getViewportSize(): Client; + getViewportSize(): Client & Size; getViewportSize(dimension: string): Client; - getViewportSize

( - callback: (err: any, size: Size) => P - ): Client

; - getViewportSize

( - dimension: string, - callback: (err: any, viewportSize: number) => P - ): Client

; + getViewportSize

(): Client

; + getViewportSize

(dimension: string): Client

; newWindow(url: string, windowName: string, windowFeatures: string): Client; newWindow

( url: string, windowName: string, - windowFeatures: string, - callback: (err: any, windowId: string) => P + windowFeatures: string ): Client

; setViewportSize(size: Size, type: boolean): Client; diff --git a/webdriverio/webdriverio-tests.ts b/webdriverio/webdriverio-tests.ts index e36e9e6d46..dc204b2052 100644 --- a/webdriverio/webdriverio-tests.ts +++ b/webdriverio/webdriverio-tests.ts @@ -6,15 +6,13 @@ import {assert} from "chai"; describe("webdriver.io page", function() { - it("should have the right title - the good old callback way", function(done) { - - browser - .url("/") - .getTitle(function(err, title) { - assert.equal(err, undefined); - assert.equal(title, "WebdriverIO - Selenium 2.0 javascript bindings for nodejs"); - }) - .call(done); + it("should have the right title - the good old callback way", function() { + assert.equal( + browser + .url("/") + .getTitle(), + "WebdriverIO - Selenium 2.0 javascript bindings for nodejs" + ); }); @@ -41,26 +39,27 @@ describe("my webdriverio tests", function(){ client.init(done); }); - it("Github test",function(done) { - client - .url("https://github.com/") - .getElementSize(".header-logo-wordmark", function(err: any, result: webdriverio.Size) { - assert.equal(undefined, err); - assert.strictEqual(result.height, 26); - assert.strictEqual(result.width, 89); - }) - .getTitle(function(err: any, title: string) { - assert.equal(undefined, err); - assert.strictEqual(title,"GitHub · Where software is built"); - }) - .getCssProperty("a[href='/plans']", "color", function(err: any, result: webdriverio.CssProperty){ - assert.equal(undefined, err); - assert.strictEqual(result.value, "rgba(64,120,192,1)"); - }) - .call(done); + it("Github test",function() { + client.url("https://github.com/"); + + var elementSize = client.getElementSize(".header-logo-wordmark"); + + var foo = client.getElementSize('div'); + + assert.isNumber(elementSize.height); + assert.isNumber(elementSize.width); + assert.strictEqual(elementSize.height, 26); + assert.strictEqual(elementSize.width, 89); + + var title = client.getTitle(); + assert.isString(title); + assert.strictEqual(title, "GitHub · Where software is built"); + + var cssProperty = client.getCssProperty("a[href='/plans']", "color"); + assert.strictEqual(cssProperty.value, "rgba(64,120,192,1)"); }); - after(function(done) { + after(function() { client.end(); }); }); From 5afc680bd0fc76c5a1419a2d1f4446aecd8b3534 Mon Sep 17 00:00:00 2001 From: Ivo Senner Date: Tue, 13 Dec 2016 13:42:35 +0100 Subject: [PATCH 14/22] Remove gitigore to keep tsconfig.json --- uikit/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 uikit/.gitignore diff --git a/uikit/.gitignore b/uikit/.gitignore deleted file mode 100644 index 7c794a3533..0000000000 --- a/uikit/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tsconfig.json -.idea/ \ No newline at end of file From d971501f0089154a43cafcb5efb2aec525d550c4 Mon Sep 17 00:00:00 2001 From: Ivo Senner Date: Tue, 13 Dec 2016 13:49:23 +0100 Subject: [PATCH 15/22] Increase version number --- uikit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uikit/index.d.ts b/uikit/index.d.ts index 3c2f8ceb73..3bb6087bb7 100644 --- a/uikit/index.d.ts +++ b/uikit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for uikit 2.23.0 +// Type definitions for uikit 2.27.2 // Project: http://getuikit.org // Definitions by: Giovanni Silva // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From d87badd90939de5669625fb1e6c21b80b25ad353 Mon Sep 17 00:00:00 2001 From: Ivo Senner Date: Tue, 13 Dec 2016 14:09:53 +0100 Subject: [PATCH 16/22] Update type definitions for UIkit.Modal --- uikit/index.d.ts | 70 ++++++++++++++++++++++++++++++++++++-------- uikit/uikit-tests.ts | 17 +++++++++-- 2 files changed, 72 insertions(+), 15 deletions(-) diff --git a/uikit/index.d.ts b/uikit/index.d.ts index 3bb6087bb7..7c04863cca 100644 --- a/uikit/index.d.ts +++ b/uikit/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for uikit 2.27.2 // Project: http://getuikit.org -// Definitions by: Giovanni Silva +// Definitions by: Giovanni Silva , Ivo Senner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -21,6 +21,43 @@ declare namespace UIkit { */ isActive(): boolean } + interface ModalOptions { + /** + * Allows controls from keyboard (ESC to close) + * @default true + *

Possible value

+ * boolean + */ + keyboard?: boolean + /** + * Allow modal to close automatically when clicking on the modal overlay + * @default true + *

Possible value

+ * boolean + */ + bgclose?: boolean + /** + * Set the height for overflow container to start scrolling + * @default 150 + *

Possible value

+ * integer + */ + minScrollHeight?: number + /** + * Vertically center the modal + * @default false + *

Possible value

+ * boolean + */ + center?: boolean + /** + * Close currently opened modals on opening modal + * @default true + *

Possible value

+ * boolean + */ + modal?: boolean + } /** * Create modal dialogs with different styles and transitions * Documentation: {@link http://getuikit.org/docs/modal.html} @@ -66,31 +103,40 @@ declare namespace UIkit { */ alert(message:string): void /** - * Create a confirm dialog and execute the function on positive confirmation + * Create a confirm dialog * @param {string} message The message to display. Can be Html - * @param {function} fn A function to execute on confirmation + * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - confirm(message:string, fn:() => any): void + confirm(message: string, options?: ModalOptions): void /** - * Create a prompt dialog, where the user enter information + * Create a confirm dialog and execute onconfirm on confirmation * @param {string} message The message to display. Can be Html - * @param {function} fn A function to execute on confirmation. The function - * receive the new value as a parameter + * @param {function} onconfirm A function to execute on confirmation + * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - prompt(message:string, fn:(newValue:string) => any): void + confirm(message:string, onconfirm:() => any, options?:ModalOptions): void + /** + * Create a confirm dialog and execute onconfirm on confirmation and oncancel on cancelation. + * @param {string} message The message to display. Can be Html + * @param {function} onconfirm A function to execute on confirmation + * @param {function} oncancel A function to execute on cancelation + * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options + */ + confirm(message:string, onconfirm:() => any, oncancel?:() => any, options?:ModalOptions): void /** * Create a prompt dialog, where the user enter information * @param {string} message The message to display. Can be Html * @param {string} value A value to init the input - * @param {function} fn A function to execute on confirmation. The function - * receive the new value as a parameter + * @param {function} fn A function to execute on submission. The function receive the new value as a parameter + * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - prompt(message:string, value:string, fn:(newValue:string) => any): void + prompt(message:string, value:string, onsubmit?:(newValue:string) => any, options?:ModalOptions): void /** * Create a modal that blocks the entire page * @param {string} content A content to display. Can be Html + * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - blockUI(content:string): ModalElement + blockUI(content:string, options?:ModalOptions): ModalElement /** * Select a modal element on page and return it. * @example diff --git a/uikit/uikit-tests.ts b/uikit/uikit-tests.ts index 402ae18d2f..8b634edc33 100644 --- a/uikit/uikit-tests.ts +++ b/uikit/uikit-tests.ts @@ -2,9 +2,20 @@ function testModal() { UIkit.modal.alert("Attention!"); - UIkit.modal.confirm("Are you sure?", function () { - // will be executed on confirm. - }); + + let options: UIkit.ModalOptions = { + keyboard: true, + bgclose: true, + minScrollHeight: 150, + center: false, + modal: true + }; + UIkit.modal.confirm("Are you sure?", () => {}); + UIkit.modal.confirm("Are you sure?", () => {}, {}); + UIkit.modal.confirm("Are you sure?", () => {}, () => {}); + UIkit.modal.confirm("Are you sure?", () => {}, () => {}, {}); + UIkit.modal.confirm("Are you sure?", () => {}, {}); + UIkit.modal.prompt("Name:", 'value', function (newvalue:string) { // will be executed on submit. }); From ce7d989b7d3f7c317b6f68caa62381fe449570ca Mon Sep 17 00:00:00 2001 From: Ivo Senner Date: Tue, 13 Dec 2016 15:08:32 +0100 Subject: [PATCH 17/22] Add tsconfig.json and tslint.json --- uikit/tsconfig.json | 19 +++++++++++++++++++ uikit/tslint.json | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 uikit/tsconfig.json create mode 100644 uikit/tslint.json diff --git a/uikit/tsconfig.json b/uikit/tsconfig.json new file mode 100644 index 0000000000..9c36affeab --- /dev/null +++ b/uikit/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "uikit-tests.ts" + ] +} diff --git a/uikit/tslint.json b/uikit/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/uikit/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From 9b5404d3c38d561de55e903e5d9ecc81441913d0 Mon Sep 17 00:00:00 2001 From: Ivo Senner Date: Tue, 13 Dec 2016 15:09:16 +0100 Subject: [PATCH 18/22] Make type definition pass linter --- uikit/index.d.ts | 513 ++++++++++++++++++----------------------------- 1 file changed, 197 insertions(+), 316 deletions(-) diff --git a/uikit/index.d.ts b/uikit/index.d.ts index 7c04863cca..cf2930bdaa 100644 --- a/uikit/index.d.ts +++ b/uikit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for uikit 2.27.2 +// Type definitions for uikit 2.27 // Project: http://getuikit.org // Definitions by: Giovanni Silva , Ivo Senner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,16 +10,16 @@ declare namespace UIkit { /** * Show the modal */ - show(): void + show(): void; /** * Hide the modal */ - hide(): void + hide(): void; /** * Return if the modal is active on the page * @return {boolean} True if the modal is current active on the page, false otherwise */ - isActive(): boolean + isActive(): boolean; } interface ModalOptions { /** @@ -28,35 +28,35 @@ declare namespace UIkit { *

Possible value

* boolean */ - keyboard?: boolean + keyboard?: boolean; /** * Allow modal to close automatically when clicking on the modal overlay * @default true *

Possible value

* boolean */ - bgclose?: boolean + bgclose?: boolean; /** * Set the height for overflow container to start scrolling * @default 150 *

Possible value

* integer */ - minScrollHeight?: number + minScrollHeight?: number; /** * Vertically center the modal * @default false *

Possible value

* boolean */ - center?: boolean + center?: boolean; /** * Close currently opened modals on opening modal * @default true *

Possible value

* boolean */ - modal?: boolean + modal?: boolean; } /** * Create modal dialogs with different styles and transitions @@ -101,20 +101,20 @@ declare namespace UIkit { * Create a alert dialog * @param {string} message The message to display. Can be Html */ - alert(message:string): void + alert(message: string): void; /** * Create a confirm dialog * @param {string} message The message to display. Can be Html * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - confirm(message: string, options?: ModalOptions): void + confirm(message: string, options?: ModalOptions): void; /** * Create a confirm dialog and execute onconfirm on confirmation * @param {string} message The message to display. Can be Html * @param {function} onconfirm A function to execute on confirmation * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - confirm(message:string, onconfirm:() => any, options?:ModalOptions): void + confirm(message: string, onconfirm: () => any, options?: ModalOptions): void; /** * Create a confirm dialog and execute onconfirm on confirmation and oncancel on cancelation. * @param {string} message The message to display. Can be Html @@ -122,7 +122,7 @@ declare namespace UIkit { * @param {function} oncancel A function to execute on cancelation * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - confirm(message:string, onconfirm:() => any, oncancel?:() => any, options?:ModalOptions): void + confirm(message: string, onconfirm: () => any, oncancel?: () => any, options?: ModalOptions): void; /** * Create a prompt dialog, where the user enter information * @param {string} message The message to display. Can be Html @@ -130,13 +130,13 @@ declare namespace UIkit { * @param {function} fn A function to execute on submission. The function receive the new value as a parameter * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - prompt(message:string, value:string, onsubmit?:(newValue:string) => any, options?:ModalOptions): void + prompt(message: string, value: string, onsubmit?: (newValue: string) => any, options?: ModalOptions): void; /** * Create a modal that blocks the entire page * @param {string} content A content to display. Can be Html * @param {ModalOptions} [options={bgclose: true, keyboard: false, modal: false}] The modal options */ - blockUI(content:string, options?:ModalOptions): ModalElement + blockUI(content: string, options?: ModalOptions): ModalElement; /** * Select a modal element on page and return it. * @example @@ -150,7 +150,7 @@ declare namespace UIkit { * } * */ - (selector:string|JQuery): ModalElement + (selector: string|JQuery): ModalElement; } /** * Create a smooth off-canvas sidebar that slides in and out of the page @@ -179,41 +179,41 @@ declare namespace UIkit { * Show an off-canvas matching the passed CSS selector * @param {string} selector A CSS selector */ - show(selector:string): void + show(selector: string): void; /** * Hide any active offcanvas. Set force to true, if you don't want any * animation * @param {boolean} force When seted to true do not run animations. * @default false */ - hide(force?:boolean): void + hide(force?: boolean): void; } interface LightBoxOptions { /** * Group name to group elements as a gallery to show. * @default false */ - group?: string + group?: string; /** * Animation duration between gallery item change * @default 400 */ - duration?: number + duration?: number; /** * Allow keyboard navigation * @default true */ - keyboard?: boolean + keyboard?: boolean; } interface LightBoxItem { - source: string - type: string + source: string; + type: string; } interface LightBoxElement { /** * Open the lightbox */ - show(): void + show(): void; } /** * Create a fancy lightbox for images and videos utilizing the @see {@link modal|Modal Component} @@ -235,38 +235,38 @@ declare namespace UIkit { interface LightBox { /** * Create dynamic lightbox - * @param {Array} items Group of items on the lightbox + * @param {LightBoxItem[]} items Group of items on the lightbox * @return {LightBoxElement} The lightbox element to show */ - create(items:Array): LightBoxElement + create(items: LightBoxItem[]): LightBoxElement; /** * Init element manually */ - (element:string|JQuery, options?:LightBoxOptions): LightBoxElement + (element: string|JQuery, options?: LightBoxOptions): LightBoxElement; } - type CallbackAutoComplete = () => string + type CallbackAutoComplete = () => string; interface AutoCompleteOptions { /** * Data source * @default [] */ - source?: string|string[]|CallbackAutoComplete + source?: string|string[]|CallbackAutoComplete; /** * Min. input length before triggering autocomplete * @default 3 */ - minLength?: number + minLength?: number; /** * Query name when sending ajax request * @default search */ - param?: string + param?: string; /** * Delay time after stop typing * @default 300 */ - delay?: number + delay?: number; } /** * Create inputs that allow users to choose from a list of pre-generated values while typing @@ -289,37 +289,32 @@ declare namespace UIkit { * On autocomplete dropdown show * * + * @param element + * @param options */ - interface AutoComplete { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options?:AutoCompleteOptions): any - } + type AutoComplete = (element: string|JQuery, options?: AutoCompleteOptions) => any; interface DatePickerOptions { /** * Start of the week * integer (0..6) * @default 1 */ - weekstart?: number + weekstart?: number; /** * Language string definitions * @default { months:['January',...], weekdays:['Sun',..,'Sat'] } */ - i18n?: {} + i18n?: {}; /** * Date format string * @default 'DD.MM.YYYY' */ - format?: string + format?: string; /** * Offset to the input value * @default 5 */ - offsettop?: number + offsettop?: number; /** * Min. date * bool (false to ignore the option) @@ -327,7 +322,7 @@ declare namespace UIkit { * integer (offset in days from current date) * @default false */ - minDate?: string|boolean|number + minDate?: string|boolean|number; /** * Max. date * bool (false to ignore the option) @@ -335,13 +330,13 @@ declare namespace UIkit { * integer (offset in days from current date) * @default false */ - maxDate?: string|boolean|number + maxDate?: string|boolean|number; /** * Position of the datepicker * 'auto', 'top', 'bottom' * @default 'auto' */ - pos?: string + pos?: string; } /** @@ -371,90 +366,76 @@ declare namespace UIkit { * * */ - interface DatePicker { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options?:DatePickerOptions): any - } + type DatePicker = (element: string|JQuery, options?: DatePickerOptions) => any; interface HtmlEditorOptions { /** * View mode * Possible values 'split','tab' * @default 'split' */ - mode?: string + mode?: string; /** * Button list to appear in the toolbar * @default [ "bold", "italic", "strike", "link", "picture", ... ] */ - toolbar?: string[] + toolbar?: string[]; /** * Min. browser width when to switch to responsive tab mode when in split mode * @default 1000 */ - maxsplitsize?: number + maxsplitsize?: number; /** * Label string for preview mode * @default 'Preview' */ - lblPreview?: string + lblPreview?: string; /** * Label string for code mode * @default 'Markdown' */ - lblCodeview?: string + lblCodeview?: string; } /** * Create a rich HTML or markdown editor with an immediate preview and syntax highlighting * Documentation {@link http://getuikit.org/docs/htmleditor.html} */ - interface HtmlEditor { - /** - * Init element manually - * @param element - * @param options - */ - (element: string|JQuery, options?: HtmlEditorOptions): any - } + type HtmlEditor = (element: string|JQuery, options?: HtmlEditorOptions) => any; interface SliderOptions { /** * Center items mode * @default false */ - center?: boolean + center?: boolean; /** * Mouse movement threshold in pixel until trigger element dragging * @default true */ - threshold?: boolean + threshold?: boolean; /** * Infinite scrolling * @default true */ - infinite?: boolean + infinite?: boolean; /** * Class added on active item in center mode * @default uk-active */ - activecls?: string + activecls?: string; /** * Defines whether or not the slider items should switch automatically * @default false */ - autoplay?: boolean + autoplay?: boolean; /** * Pause autoplay when hovering a slider * @default true */ - pauseOnHover?: boolean + pauseOnHover?: boolean; /** * Defines the timespan between switching slider items * @default 7000 */ - autoplayInterval?: number + autoplayInterval?: number; } /** * Create a list of items to use as a responsive carousel slider @@ -473,75 +454,68 @@ declare namespace UIkit { * * */ - interface Slider { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options?:SliderOptions): any - } + type Slider = (element: string|JQuery, options?: SliderOptions) => any; interface SlideSetOptions { /** * Default visible items in a set * @default 1 */ - default?: number + default?: number; /** * Visible items in a set at small breakpoint * @default null */ - small?: number + small?: number; /** * Visible items in a set at medium breakpoint * @default null */ - medium?: number + medium?: number; /** * Visible items in a set at large breakpoint * @default null */ - large?: number + large?: number; /** * Visible items in a set at xlarge breakpoint * @default null */ - xlarge?: number + xlarge?: number; /** * Animation name * @default 'fade' */ - animation?: string + animation?: string; /** * Animation duration in ms * @default 200 */ - duration?: number + duration?: number; /** * Animation delay between items in a set * @default 100 */ - delay?: number + delay?: number; /** * Items filter * @default "" */ - filter?: string + filter?: string; /** * Defines whether or not the slideset items should switch automatically. * @default false */ - autoplay?: boolean + autoplay?: boolean; /** * Pause autoplay when hovering a slideset. * @default true */ - pauseOnHover?: boolean + pauseOnHover?: boolean; /** * Defines the timespan between switching slideset items. * @default 7000 */ - autoplayInterval?: number + autoplayInterval?: number; } /** * Create sets and groups of items, allowing to loop through the sets. @@ -560,87 +534,80 @@ declare namespace UIkit { * * */ - interface SlideSet { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options?:SlideSetOptions): any - } + type SlideSet = (element: string|JQuery, options?: SlideSetOptions) => any; interface SlideShowOptions { /** * Defines the preferred transition between items. * @default 'fade */ - animation?: string + animation?: string; /** * Defines the transition duration. * @default 500 */ - duration?: number + duration?: number; /** * Defines the slideshow height. * @default 'auto' */ - height?: string + height?: string; /** * Defines the first slideshow item to be displayed. * @default 0 */ - start?: number + start?: number; /** * Defines whether or not the slideshow items should switch automatically. * @default false */ - autoplay?: boolean + autoplay?: boolean; /** * Pause autoplay when hovering a slideshow. * @default true */ - pauseOnHover?: boolean + pauseOnHover?: boolean; /** * Defines the timespan between switching slideshow items. * @default 7000 */ - autoplayInterval?: number + autoplayInterval?: number; /** * Defines whether or not a video starts automatically. * @default true */ - videoautoplay?: boolean + videoautoplay?: boolean; /** * Defines whether or not a video is muted. * @default false */ - videomute?: boolean + videomute?: boolean; /** * Defines whether or not the Ken Burns effect is active. If kenburns is a numeric value, it will be used as * the animation duration. * @default false */ - kenburns?: boolean + kenburns?: boolean; /** * Animation series. * @default 'uk-animation-middle-left, uk-animation-top-right, uk-animation-bottom-left, uk-animation-top-center,uk-animation-bottom-right' */ - kenburnsanimations?: string + kenburnsanimations?: string; /** * Defines the number of slices, if a "Slice" transition is set. * @default 15 */ - slices?: number + slices?: number; } /** * Create a responsive image or video slideshow with stunning transition effects, fullscreen mode and overlays. @@ -659,54 +626,40 @@ declare namespace UIkit { * * */ - interface SlideShow { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:SlideShowOptions): any - } + type SlideShow = (element: string|JQuery, options: SlideShowOptions) => any; interface ParallaxOptions { /** * Animation velocity during scrolling * @default 0.5 */ - velocity?: number + velocity?: number; /** * Element dimension reference for animation duration. * @default false */ - target?: boolean + target?: boolean; /** * Animation range depending on the viewport. *

Possible value

* float (0 to 1) * @default false */ - viewport?: number + viewport?: number; /** * Condition for the active status with a width as integer (e.g. 640) or a css media query * @default false *

Possible Value

* integer / string */ - media?: number|string + media?: number|string; } /** * Animate CSS properties depending on the scroll position of the document. * Documentation {@link http://getuikit.org/docs/parallax.html} */ - interface Parallax { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:ParallaxOptions): any - } + type Parallax = (element: string|JQuery, options: ParallaxOptions) => any; interface AccordionOptions { /** * Show first item on init @@ -714,56 +667,56 @@ declare namespace UIkit { *

Possible value

* boolean */ - showfirst?: boolean + showfirst?: boolean; /** * Allow multiple open items * @default true *

Possible value

* boolean */ - collapse?: boolean + collapse?: boolean; /** * Animate toggle * @default true *

Possible value

* boolean */ - animate?: boolean + animate?: boolean; /** * Animation function * @default swing *

Possible value

* string */ - easing?: string + easing?: string; /** * Animation duration * @default 300 *

Possible value

* integer */ - duration?: number + duration?: number; /** * Css selector for toggles * @default .uk-accordion-title *

Possible value

* string */ - toggle?: string + toggle?: string; /** * Css selector for content containers * @default .uk-accordion-content *

Possible value

* string */ - containers?: string + containers?: string; /** * Class to add when an item is active * @default uk-active *

Possible value

* string */ - clsactive?: string + clsactive?: string; } /** * Create a list of items, allowing each item's content to be expanded and collapsed by clicking its header. @@ -782,20 +735,12 @@ declare namespace UIkit { * * */ - interface Accordion { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:AccordionOptions): any - } - + type Accordion = (element: string|JQuery, options: AccordionOptions) => any; interface NotifyOptions { /** * The message to display */ - message?: string + message?: string; /** * A notification can be styled by adding a status to the message to indicate an info, success, warning or a @@ -805,13 +750,13 @@ declare namespace UIkit { * If you want to create one set its style with the CSS class uk-notify-message-yourStatus * @default 'info' */ - status?: string + status?: string; /** * Amount of tiem in milliseconds a messa is visible. Set to 0 for sticky message * @default 5000 */ - timeout?: number + timeout?: number; /** * Adjust the notification's position to different corners. @@ -820,7 +765,7 @@ declare namespace UIkit { * top-center, top-left, top-right, bottom-center, bottom-left, bottom-right * If you want to create one value set its style with the CSS uk-notify-yourPosition */ - pos?: string + pos?: string; } /** * Create toggleable notifications that fade out automatically @@ -828,27 +773,16 @@ declare namespace UIkit { */ interface Notify { /** - * Show a message with default options + * Show a notification * @param message The html message + * @param {string|NotifyOptions} [status] The status or options */ - (message:string): any + (message: string, status?: string|NotifyOptions): any; /** - * Show a message with a different status - * @param message The html message - * @param status The string status - */ - (message:string, status:string): any - /** - * Show a message with diferente options - * @param message The html message + * Show a notification * @param options Options */ - (message:string, options:NotifyOptions): any - /** - * Show a message with diferent options - * @param options Options - */ - (options:NotifyOptions): any + (options: NotifyOptions): any; } interface SearchOptions { /** @@ -857,7 +791,7 @@ declare namespace UIkit { *

Possible value

* string */ - source?: string + source?: string; /** * Min. input length before triggering autocomplete @@ -865,7 +799,7 @@ declare namespace UIkit { *

Possible value

* integer */ - minLength?: number + minLength?: number; /** * Query name when sending ajax request @@ -873,7 +807,7 @@ declare namespace UIkit { *

Possible value

* string */ - param?: string + param?: string; /** * Delay time after stop typing @@ -881,21 +815,14 @@ declare namespace UIkit { *

Possible value

* integer */ - delay?: number + delay?: number; } /** * Easily create a nicely looking search. * Documentation {@link http://getuikit.org/docs/search.html} */ - interface Search { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:SearchOptions): any - } + type Search = (element: string|JQuery, options: SearchOptions) => any; interface NestableOptions { /** * List group @@ -903,98 +830,98 @@ declare namespace UIkit { *

Possible value

* string */ - group?: string + group?: string; /** * Max nesting level * @default 10 *

Possible value

* integer */ - maxDepth?: number + maxDepth?: number; /** * Pixel threshold before starting to drag * @default 20 *

Possible value

* integer */ - threshold?: number + threshold?: number; /** * List node name * @default ul *

Possible value

* string */ - listNodeName?: string + listNodeName?: string; /** * Item node name * @default li *

Possible value

* string */ - itemNodeName?: string + itemNodeName?: string; /** * List base class * @default uk-nestable *

Possible value

* string */ - listBaseClass?: string + listBaseClass?: string; /** * List class * @default uk-nestable-list *

Possible value

* string */ - listClass?: string + listClass?: string; /** * List item class * @default uk-nestable-list-item *

Possible value

* string */ - listitemClass?: string + listitemClass?: string; /** * Item class * @default uk-nestable-item *

Possible value

* string */ - itemClass?: string + itemClass?: string; /** * Class added to dragged list * @default uk-nestable-list-dragged *

Possible value

* string */ - dragClass?: string + dragClass?: string; /** * Class added to <html> when moving * @default uk-nestable-moving *

Possible value

* string */ - movingClass?: string + movingClass?: string; /** * Class for drag handle * @default uk-nestable-handle *

Possible value

* string */ - handleClass?: string + handleClass?: string; /** * Class for collapsed items * @default uk-nestable-collapsed *

Possible value

* string */ - collapsedClass?: string + collapsedClass?: string; /** * Class for placeholder of currently dragged element * @default uk-nestable-placeholder *

Possible value

* string */ - placeClass?: string + placeClass?: string; /** * Elements with this class will not trigger dragging. Useful when having the complete item draggable and not * just the handle. @@ -1002,14 +929,14 @@ declare namespace UIkit { *

Possible value

* string */ - noDragClass?: string + noDragClass?: string; /** * Class for empty lists * @default uk-nestable-empty *

Possible value

* string */ - emptyClass?: string + emptyClass?: string; } /** @@ -1044,14 +971,7 @@ declare namespace UIkit { * * */ - interface Nestable { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:NestableOptions): any - } + type Nestable = (element: string|JQuery, options: NestableOptions) => any; interface SortableOptions { /** * List group @@ -1059,35 +979,35 @@ declare namespace UIkit { *

Possible value

* string */ - group?: string + group?: string; /** * Animation speed in ms * @default 150 *

Possible value

* integer */ - animation?: string + animation?: string; /** * Mouse movement threshold in pixel until trigger element dragging * @default 10 *

Possible value

* integer */ - threshold?: string + threshold?: string; /** * Custom class to define elements which can trigger sorting * @default '' *

Possible value

* string */ - handleClass?: string + handleClass?: string; /** * Custom class added to the dragged element * @default '' *

Possible value

* string */ - dragCustomClass?: string + dragCustomClass?: string; } /** @@ -1122,14 +1042,7 @@ declare namespace UIkit { * * */ - interface Sortable { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:SortableOptions): any - } + type Sortable = (element: string|JQuery, options: SortableOptions) => any; interface StickyOptions { /** * Top offset whent sticky should be triggered @@ -1137,70 +1050,70 @@ declare namespace UIkit { *

Possible value

* integer */ - top?: number + top?: number; /** * UIkit animation class * @default '' *

Possible value

* string */ - animation?: string + animation?: string; /** * Init class when the element is sticky for the first time * @default uk-sticky-init *

Possible value

* string */ - clsinit?: string + clsinit?: string; /** * Active class to add, when element is sticky * @default uk-active *

Possible value

* string */ - clsactive?: string + clsactive?: string; /** * Class to add, when element is not sticky * @default '' *

Possible value

* string */ - clsinactive?: string + clsinactive?: string; /** * Css selector where to get the width from in sticky mode. By default it takes the width from the created wrapper element. * @default '' *

Possible value

* string */ - getWidthFrom?: string + getWidthFrom?: string; /** * Condition for the active status with a width as integer (e.g. 640) or a css media query * @default false *

Possible value

* integer / string */ - media?: number|string + media?: number|string; /** * Make sure that a sticky element is not over a targeted element via location hash on dom-ready. * @default false *

Possible value

* boolean */ - target?: boolean + target?: boolean; /** * Show sticky element only when scrolling up. * @default false *

Possible value

* boolean */ - showup?: boolean + showup?: boolean; /** * Set to true to bind sticky to the parent or a Css selector to bind sticky to a specific element. * @default false *

Possible value

* mixed */ - boundary?: boolean|string + boundary?: boolean|string; } /** @@ -1225,14 +1138,7 @@ declare namespace UIkit { * * */ - interface Sticky { - /** - * Init the element manually - * @param element - * @param options - */ - (element:string|JQuery, options:StickyOptions): any - } + type Sticky = (element: string|JQuery, options: StickyOptions) => any; interface TimepickerOptions { /** * Defines the preferred time notation @@ -1240,35 +1146,28 @@ declare namespace UIkit { *

Possible value

* '24h' or '12h' */ - format?: string + format?: string; /** * Start time * @default 0 *

Possible value

* Integer between 0 and 24 */ - start?: number + start?: number; /** * End time * @default 24 *

Possible value

* Integer between 0 and 24 */ - end?: number + end?: number; } /** * Create a timepicker which can easily be used by selecting a time value from a pre filled dropdown. * Documentation {@link http://getuikit.org/docs/timepicker.html} */ - interface Timepicker { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:TimepickerOptions): any - } + type Timepicker = (element: string|JQuery, options: TimepickerOptions) => any; interface TooltipOptions { /** * Offset to the source element @@ -1276,56 +1175,49 @@ declare namespace UIkit { *

Possible value

* integer */ - offset?: number + offset?: number; /** * Tooltip position * @default 'top' *

Possible value

* string */ - pos?: string + pos?: string; /** * Fade in tooltip * @default false *

Possible value

* boolean */ - animation?: boolean + animation?: boolean; /** * Delay tooltip show in ms * @default 0 *

Possible value

* integer */ - delay?: number + delay?: number; /** * Custom class to add on show * @default '' *

Possible value

* string */ - cls?: string + cls?: string; /** * Toggled active class * @default 'uk-active' *

Possible value

* string */ - activeClass?: string + activeClass?: string; } /** * Easily create a nicely looking tooltip. * Documentation {@link http://getuikit.org/docs/tooltip.html} */ - interface Tooltip { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:TooltipOptions): any - } + type Tooltip = (element: string|JQuery, options: TooltipOptions) => any; interface UploadOptions { /** * Target url for the upload @@ -1333,62 +1225,62 @@ declare namespace UIkit { *

Possible value

* string */ - action?: string + action?: string; /** * Send each file one by one * @default true *

Possible value

* boolean */ - single?: boolean + single?: boolean; /** * Post query name * @default files[] *

Possible value

* string */ - param?: string + param?: string; /** * Additional request parameters * @default {} *

Possible value

* JSON Object */ - params?: {} + params?: {}; /** * File filter * @default *.* *

Possible value

* string */ - allow?: string + allow?: string; /** * Limit the number of files to upload * @default false *

Possible value

* integer */ - filelimit?: number + filelimit?: number; /** * Response type from server * @default text *

Possible Value

* (text|json) */ - "type"?: string - before?: (settings: UploadOptions, files: string|string[]) => any - beforeAll?: (files: string|string[]) => any - beforeSend?: (xhr: XMLHttpRequest) => any - progress?: (percent: number) => any - complete?: (response: any, xhr: XMLHttpRequest) => any - allcomplete?: (response: any, xhr: XMLHttpRequest) => any - notallowed?: (file: string|string[], settings: UploadOptions) => any - loadstart?: (event: any) => any - load?: (event: any) => any - loadend?: (event: any) => any - error?: (event: any) => any - abort?: (event: any) => any - readystatechange?: (event: any) => any + "type"?: string; + before?: (settings: UploadOptions, files: string|string[]) => any; + beforeAll?: (files: string|string[]) => any; + beforeSend?: (xhr: XMLHttpRequest) => any; + progress?: (percent: number) => any; + complete?: (response: any, xhr: XMLHttpRequest) => any; + allcomplete?: (response: any, xhr: XMLHttpRequest) => any; + notallowed?: (file: string|string[], settings: UploadOptions) => any; + loadstart?: (event: any) => any; + load?: (event: any) => any; + loadend?: (event: any) => any; + error?: (event: any) => any; + abort?: (event: any) => any; + readystatechange?: (event: any) => any; } /** @@ -1454,36 +1346,25 @@ declare namespace UIkit { * * */ - interface Upload { - /** - * Init element manually - * @param element - * @param options - */ - (element:string|JQuery, options:UploadOptions): any - } - export var modal:Modal; - export var lightbox:LightBox; - export var offcanvas:OffCanvas; - export var autocomplete:AutoComplete; - export var datepicker:DatePicker; - export var htmleditor:HtmlEditor; - export var slider:Slider; - export var slideset:SlideSet; - export var slideshow:SlideShow; - export var parallax:Parallax; - export var accordion:Accordion; - export var notify:Notify; - export var search:Search; - export var nestable:Nestable; - export var sortable:Sortable; - export var sticky:Sticky; - export var timepicker:Timepicker; - export var tooltip:Tooltip; - export var uploadSelect: Upload; - export var uploadDrop: Upload; -} - -declare module 'uikit' { - export = UIkit + type Upload = (element: string|JQuery, options: UploadOptions) => any; + var modal: Modal; + var lightbox: LightBox; + var offcanvas: OffCanvas; + var autocomplete: AutoComplete; + var datepicker: DatePicker; + var htmleditor: HtmlEditor; + var slider: Slider; + var slideset: SlideSet; + var slideshow: SlideShow; + var parallax: Parallax; + var accordion: Accordion; + var notify: Notify; + var search: Search; + var nestable: Nestable; + var sortable: Sortable; + var sticky: Sticky; + var timepicker: Timepicker; + var tooltip: Tooltip; + var uploadSelect: Upload; + var uploadDrop: Upload; } From c0fcdc35058d8f6131946e5be3906e3db8642d71 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Wed, 14 Dec 2016 19:45:13 +0100 Subject: [PATCH 19/22] Add version to header --- emojione/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emojione/index.d.ts b/emojione/index.d.ts index f6136f04e0..48b55e87cd 100644 --- a/emojione/index.d.ts +++ b/emojione/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for emojione +// Type definitions for emojione 2.2 // Project: https://github.com/Ranks/emojione // Definitions by: Danilo Bargen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 673d2740d771a5bdf08752a117ddc0276ecc69bd Mon Sep 17 00:00:00 2001 From: Panagiotis Rikarnto Siavelis Date: Wed, 14 Dec 2016 21:06:37 +0200 Subject: [PATCH 20/22] TableHeaderColumnProps.dataFormat 3rd parameter. Added 3rd parameter in TableHeaderColumnProps.dataFormat field. One can provide additional data to the 'dataFormat' function using 'formatExtraData'. --- react-bootstrap-table/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-bootstrap-table/index.d.ts b/react-bootstrap-table/index.d.ts index cc902fe4c2..b0b250f8c3 100644 --- a/react-bootstrap-table/index.d.ts +++ b/react-bootstrap-table/index.d.ts @@ -451,7 +451,7 @@ export interface TableHeaderColumnProps extends Props { To customize the column. This callback function should return a String or a React Component. In addition, this function taking two argument: cell and row. */ - dataFormat?: (cell: any, row: any) => string | ReactElement; + dataFormat?: (cell: any, row: any, formatExtraData?: any) => string | ReactElement; /** To to enable search or filter data on formatting. Default is false */ From 9896de4eb08d92eba02973d3918c81f1c9d72951 Mon Sep 17 00:00:00 2001 From: Fredrik Smedberg Date: Thu, 15 Dec 2016 15:47:26 +0100 Subject: [PATCH 21/22] Used ? to indicate optional arguments for some methods, which made it possible to merge similar declarations into fewer. --- webdriverio/index.d.ts | 420 ++++++++++++++++++++++++----------------- 1 file changed, 247 insertions(+), 173 deletions(-) diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index 1ab7b20452..fbc6925fa9 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -41,20 +41,14 @@ declare namespace WebdriverIO { ): Client

; addValue

(value: string | number): Client

; - clearElement(selector: string): Client; - clearElement(): Client; - clearElement

(selector: string): Client

; - clearElement

(): Client

; + clearElement(selector?: string): Client; + clearElement

(selector?: string): Client

; - click(selector: string): Client; - click(): Client; - click

(selector: string): Client

; - click

(): Client

; + click(selector?: string): Client; + click

(selector?: string): Client

; - doubleClick(selector: string): Client; - doubleClick(): Client; - doubleClick

(selector: string): Client

; - doubleClick

(): Client

; + doubleClick(selector?: string): Client; + doubleClick

(selector?: string): Client

; dragAndDrop( sourceElem: string, @@ -67,18 +61,13 @@ declare namespace WebdriverIO { ): Client

; dragAndDrop

(destinationElem: string): Client

; - leftClick(selector: string): Client; - leftClick(): Client; - leftClick

(selector: string): Client

; - leftClick

(): Client

; + leftClick(selector?: string): Client; + leftClick

(selector?: string): Client

; - middleClick(selector: string): Client; - middleClick(): Client; - middleClick

(selector: string): Client

; - middleClick

(): Client

; + middleClick(selector?: string): Client; + middleClick

(selector?: string): Client

; - moveToObject(selector: string): Client; - moveToObject(): Client; + moveToObject(selector?: string): Client; moveToObject( selector: string, xoffset: number, @@ -88,8 +77,7 @@ declare namespace WebdriverIO { xoffset: number, yoffset: number ): Client; - moveToObject

(selector: string): Client

; - moveToObject

(): Client

; + moveToObject

(selector?: string): Client

; moveToObject

( selector: string, xoffset: number, @@ -100,13 +88,18 @@ declare namespace WebdriverIO { yoffset: number ): Client

; - rightClick(selector: string): Client; - rightClick(): Client; - rightClick

(selector: string): Client

; - rightClick

(): Client

; + rightClick(selector?: string): Client; + rightClick

(selector?: string): Client

; - selectByAttribute(selector: string, attribute: string, value: string): Client; - selectByAttribute(attribute: string, value: string): Client; + selectByAttribute( + selector: string, + attribute: string, + value: string + ): Client; + selectByAttribute( + attribute: string, + value: string + ): Client; selectByAttribute

( selector: string, attribute: string, @@ -117,7 +110,10 @@ declare namespace WebdriverIO { value: string ): Client

; - selectByIndex(selectElem: string, index: number): Client; + selectByIndex( + selectElem: string, + index: number + ): Client; selectByIndex(index: number): Client; selectByIndex

( selectElem: string, @@ -125,7 +121,10 @@ declare namespace WebdriverIO { ): Client

; selectByIndex

(index: number): Client

; - selectByValue(selectElem: string, value: string): Client; + selectByValue( + selectElem: string, + value: string + ): Client; selectByValue(value: string): Client; selectByValue

( selectElem: string, @@ -133,7 +132,10 @@ declare namespace WebdriverIO { ): Client

; selectByValue

(value: string): Client

; - selectByVisibleText(selectElem: string, text: string): Client; + selectByVisibleText( + selectElem: string, + text: string + ): Client; selectByVisibleText(text: string): Client; selectByVisibleText

( selectElem: string, @@ -153,18 +155,23 @@ declare namespace WebdriverIO { ...args: any[] ): Client

; - setValue(selector: string, values: number | string | Array): Client; - setValue(values: number | string | Array): Client; + setValue( + selector: string, + values: number | string | Array + ): Client; + setValue( + values: number | string | Array + ): Client; setValue

( selector: string, values: number | string | Array ): Client; - setValue

(values: number | string | Array): Client; + setValue

( + values: number | string | Array + ): Client; - submitForm(selector: string): Client; - submitForm(): Client; - submitForm

(selector: string): Client; - submitForm

(): Client; + submitForm(selector?: string): Client; + submitForm

(selector?: string): Client

; } // Appium @@ -207,20 +214,21 @@ declare namespace WebdriverIO { // Cookie export interface Client { deleteCookie(name?: string): Client; - deleteCookie

(): Client

; - deleteCookie

(name: string): Client

; + deleteCookie

(name?: string): Client

; getCookie(): Client; getCookie(name: string): Client; - getCookie

(): Client

; - getCookie

(name: string): Client

; + getCookie

(name?: string): Client

; setCookie(cookie: Cookie): Client; setCookie

(cookie: Cookie): Client

; } export interface Client { - session(action?: string, sessionId?: string): Client>; + session( + action?: string, + sessionId?: string + ): Client>; session

(): Client

; getGridNodeDetails(): Client; @@ -275,8 +283,14 @@ declare namespace WebdriverIO { // Property export interface Client { - getAttribute(selector: string, attributeName: string): Client & string; - getAttribute(selector: string, attributeName: string): Client & string[]; + getAttribute( + selector: string, + attributeName: string + ): Client & string; + getAttribute( + selector: string, + attributeName: string + ): Client & string[]; getAttribute(attributeName: string): Client & string; getAttribute(attributeName: string): Client & string[]; getAttribute

( @@ -285,8 +299,14 @@ declare namespace WebdriverIO { ): Client

; getAttribute

(attributeName: string): Client

; - getCssProperty(selector: string, cssProperty: string): CssProperty; - getCssProperty(selector: string, cssProperty: string): CssProperty[]; + getCssProperty( + selector: string, + cssProperty: string + ): CssProperty; + getCssProperty( + selector: string, + cssProperty: string + ): CssProperty[]; getCssProperty(cssProperty: string): CssProperty; getCssProperty(cssProperty: string): CssProperty[]; getCssProperty

( @@ -298,38 +318,44 @@ declare namespace WebdriverIO { getElementSize(selector: string): Client & Size; getElementSize(selector: string): Client & Size[]; getElementSize(): Client & Size|Size[]; - getElementSize(selector: string, dimension: string): number; - getElementSize(selector: string, dimension: string): number[]; + getElementSize( + selector: string, + dimension: string + ): number; + getElementSize( + selector: string, + dimension: string + ): number[]; getElementSize(dimension: string): number ; getElementSize(dimension: string): number[]; - getElementSize

(selector: string): Client

; - getElementSize

(): Client

; + getElementSize

(selector?: string): Client

; getElementSize

( selector: string, dimension: string ): Client

; getElementSize

(dimension: string): Client

; - getHTML(selector: string, includeSelectorTag?: boolean): string; - getHTML(selector: string, includeSelectorTag?: boolean): string[]; + getHTML( + selector: string, + includeSelectorTag?: boolean + ): string; + getHTML( + selector: string, + includeSelectorTag?: boolean + ): string[]; getHTML(includeSelectorTag?: boolean): string; getHTML(includeSelectorTag?: boolean): string[]; - getHTML

( - selector: string - ): Client

; - getHTML

(): Client

; + getHTML

(selector?: string): Client

; getHTML

( selector: string, includeSelectorTag: boolean ): Client

; getHTML

(includeSelectorTag: boolean): Client

; - getLocation(selector: string): Size; - getLocation(): Size; + getLocation(selector?: string): Size; getLocation(selector: string, axis: string): number; getLocation(axis: string): number; - getLocation

(selector: string): Client

; - getLocation

(): Client

; + getLocation

(selector?: string): Client

; getLocation

( selector: string, axis: string @@ -340,12 +366,17 @@ declare namespace WebdriverIO { getLocationInView(selector: string): Size[]; getLocationInView(): Size; getLocationInView(): Size[]; - getLocationInView(selector: string, axis: string): number; - getLocationInView(selector: string, axis: string): number[]; + getLocationInView( + selector: string, + axis: string + ): number; + getLocationInView( + selector: string, + axis: string + ): number[]; getLocationInView(axis: string): number; getLocationInView(axis: string): number[]; - getLocationInView

(selector: string): Client

; - getLocationInView

(): Client

; + getLocationInView

(selector?: string): Client

; getLocationInView

( selector: string, axis: string @@ -355,15 +386,11 @@ declare namespace WebdriverIO { getSource(): Client; getSource

(): Client

; - getTagName(selector: string): string | string[]; - getTagName(): string | string[]; - getTagName

(selector: string): Client

; - getTagName

(): Client

; + getTagName(selector?: string): string | string[]; + getTagName

(selector?: string): Client

; - getText(selector: string): string | string[]; - getText(): string | string[]; - getText

(selector: string): Client

; - getText

(): Client

; + getText(selector?: string): string | string[]; + getText

(selector?: string): Client

; getTitle(): Client; getTitle

(): Client

; @@ -371,10 +398,8 @@ declare namespace WebdriverIO { getUrl(): Client; getUrl

(): Client

; - getValue(selector: string): string | string[]; - getValue(): string | string[]; - getValue

(selector: string): Client

; - getValue

(): Client

; + getValue(selector?: string): string | string[]; + getValue

(selector?: string): Client

; } export interface LogEntry { @@ -431,27 +456,22 @@ declare namespace WebdriverIO { url(): Client> & RawResult; url(url: string): Client; - url

(): Client

; - url

(url: string): Client

; + url

(url?: string): Client

; } // Advanced input export interface Client { // you probably want to use the click and drag and drop commands instead buttonDown(button?: string | Button): Client; - buttonDown

(): Client

; - buttonDown

(button: string | Button): Client

; + buttonDown

(button?: string | Button): Client

; // you probably want to use the click and drag and drop commands instead buttonPress(button?: string | Button): Client; - buttonPress

(): Client

; - buttonPress

(button: string | Button): Client

; + buttonPress

(button?: string | Button): Client

; // you probably want to use the click and drag and drop commands instead buttonUp(button?: string | Button): Client; - buttonUp

(): Client

; - buttonUp(button?: string | Button): Client; - buttonUp

(button: string | Button): Client

; + buttonUp

(button?: string | Button): Client

; // you probably want to use the click and drag and drop commands instead doDoubleClick(): Client; @@ -462,17 +482,20 @@ declare namespace WebdriverIO { keys

(value: string | string[]): Client

; // you probably want to use the moveToObject command instead - moveTo(id: ElementId, xoffset?: number, yoffset?: number): Client; - moveTo(xoffset?: number, yoffset?: number): Client; + moveTo( + id: ElementId, + xoffset?: number, + yoffset?: number + ): Client; + moveTo( + xoffset?: number, + yoffset?: number + ): Client; moveTo

(id: ElementId): Client

; - moveTo

( - id: ElementId, - xoffset: number - ): Client

; moveTo

( id: ElementId, xoffset: number, - yoffset: number + yoffset?: number ): Client

; // touchClick @@ -504,8 +527,7 @@ declare namespace WebdriverIO { frameParent

(): Client

; init(capabilities?: DesiredCapabilities): Client; - init

(): Client

; - init

(capabilities: DesiredCapabilities): Client

; + init

(capabilities?: DesiredCapabilities): Client

; log(type: string): Client>; log

(type: string): Client

; @@ -513,9 +535,11 @@ declare namespace WebdriverIO { logTypes(): Client> & RawResult; logTypes

(): Client

; - session(action?: string, sessionId?: string): Client> & RawResult; - session

(): Client

; - session

(action: string): Client

; + session( + action?: string, + sessionId?: string + ): Client> & RawResult; + session

(action?: string): Client

; session

( action: string, sessionId: string @@ -550,7 +574,10 @@ declare namespace WebdriverIO { elementActive(): Client> & RawResult; elementActive

(): Client

; - elementIdAttribute(id: ElementId, attributeName: string): Client> & RawResult; + elementIdAttribute( + id: ElementId, + attributeName: string + ): Client> & RawResult; elementIdAttribute

( id: ElementId, attributeName: string @@ -562,7 +589,10 @@ declare namespace WebdriverIO { elementIdClick(id: ElementId): Client; elementIdClick

(id: ElementId): Client

; - elementIdCssProperty(id: ElementId, propertyName: string): Client> & RawResult; + elementIdCssProperty( + id: ElementId, + propertyName: string + ): Client> & RawResult; elementIdCssProperty

( id: ElementId, propertyName: string @@ -571,13 +601,19 @@ declare namespace WebdriverIO { elementIdDisplayed(id: ElementId): Client> & RawResult; elementIdDisplayed

(id: ElementId): Client

; - elementIdElement(id: ElementId, selector: string): Client> & RawResult; + elementIdElement( + id: ElementId, + selector: string + ): Client> & RawResult; elementIdElement

( id: ElementId, selector: string ): Client

; - elementIdElements(id: ElementId, selector: string): Client> & RawResult; + elementIdElements( + id: ElementId, + selector: string + ): Client> & RawResult; elementIdElements

( id: ElementId, selector: string @@ -604,7 +640,10 @@ declare namespace WebdriverIO { elementIdText(id: ElementId): Client> & RawResult; elementIdText

(id: ElementId): Client

; - elementIdValue(id: ElementId, values: string | string[]): Client>; + elementIdValue( + id: ElementId, + values: string | string[] + ): Client>; elementIdValue

( id: ElementId, values: string | string[] @@ -650,30 +689,20 @@ declare namespace WebdriverIO { // State export interface Client { - isEnabled(selector: string): Client; - isEnabled(): Client; - isEnabled

(selector: string): Client

; - isEnabled

(): Client

; + isEnabled(selector?: string): Client; + isEnabled

(selector?: string): Client

; - isExisting(selector: string): Client; - isExisting(): Client; - isExisting

(selector: string): Client

; - isExisting

(): Client

; + isExisting(selector?: string): Client; + isExisting

(selector?: string): Client

; - isSelected(selector: string): Client; - isSelected(): Client; - isSelected

(selector: string): Client

; - isSelected

(): Client

; + isSelected(selector?: string): Client; + isSelected

(selector?: string): Client

; - isVisible(selector: string): Client; - isVisible(): Client; - isVisible

(selector: string): Client

; - isVisible

(): Client

; + isVisible(selector?: string): Client; + isVisible

(selector?: string): Client

; - isVisibleWithinViewport(selector: string): Client; - isVisibleWithinViewport(): Client; - isVisibleWithinViewport

(selector: string): Client

; - isVisibleWithinViewport

(): Client

; + isVisibleWithinViewport(selector?: string): Client; + isVisibleWithinViewport

(selector?: string): Client

; } export interface CommandHistoryEntry { @@ -683,20 +712,21 @@ declare namespace WebdriverIO { // Utility export interface Client { - - - addCommand(commandName: string, customMethod: Function, overwrite?: boolean): Client; - addCommand

( + addCommand( commandName: string, - customMethod: Function - ): Client

; + customMethod: Function, + overwrite?: boolean + ): Client; addCommand

( commandName: string, customMethod: Function, - overwrite: boolean + overwrite?: boolean ): Client

; - chooseFile(selector: string, localPath: string): Client; + chooseFile( + selector: string, + localPath: string + ): Client; chooseFile(localPath: string): Client; chooseFile

( selector: string, @@ -720,15 +750,19 @@ declare namespace WebdriverIO { pause

(milliseconds: number): Client

; saveScreenshot(filename?: string): Client; - saveScreenshot

(): Client

; - saveScreenshot

(filename: string): Client

; + saveScreenshot

(filename?: string): Client

; - scroll(selector: string): Client; - scroll(): Client; - scroll(selector: string, xoffset: number, yoffset: number): Client; - scroll(xoffset: number, yoffset: number): Client; - scroll

(selector: string): Client

; - scroll

(): Client

; + scroll(selector?: string): Client; + scroll( + selector: string, + xoffset: number, + yoffset: number + ): Client; + scroll( + xoffset: number, + yoffset: number + ): Client; + scroll

(selector?: string): Client

; scroll

( selector: string, xoffset: number, @@ -742,10 +776,16 @@ declare namespace WebdriverIO { uploadFile(localPath: string): Client; uploadFile

(localPath: string): Client

; - waitForEnabled(selector: string, milliseconds?: number, reverse?: boolean): Client; - waitForEnabled(milliseconds?: number, reverse?: boolean): Client; - waitForEnabled

(selector: string): Client

; - waitForEnabled

(): Client

; + waitForEnabled( + selector: string, + milliseconds?: number, + reverse?: boolean + ): Client; + waitForEnabled( + milliseconds?: number, + reverse?: boolean + ): Client; + waitForEnabled

(selector?: string): Client

; waitForEnabled

( selector: string, milliseconds: number, @@ -761,10 +801,16 @@ declare namespace WebdriverIO { reverse: boolean ): Client

; - waitForExist(selector: string, milliseconds?: number, reverse?: boolean): Client; - waitForExist(milliseconds?: number, reverse?: boolean): Client; - waitForExist

(selector: string): Client

; - waitForExist

(): Client

; + waitForExist( + selector: string, + milliseconds?: number, + reverse?: boolean + ): Client; + waitForExist( + milliseconds?: number, + reverse?: boolean + ): Client; + waitForExist

(selector?: string): Client

; waitForExist

( selector: string, milliseconds: number @@ -780,10 +826,16 @@ declare namespace WebdriverIO { reverse: boolean ): Client

; - waitForSelected(selector: string, milliseconds?: number, reverse?: boolean): Client; - waitForSelected(milliseconds?: number, reverse?: boolean): Client; - waitForSelected

(selector: string): Client

; - waitForSelected

(): Client

; + waitForSelected( + selector: string, + milliseconds?: number, + reverse?: boolean + ): Client; + waitForSelected( + milliseconds?: number, + reverse?: boolean + ): Client; + waitForSelected

(selector?: string): Client

; waitForSelected

( selector: string, milliseconds: number @@ -799,10 +851,16 @@ declare namespace WebdriverIO { reverse: boolean ): Client

; - waitForText(selector: string, milliseconds?: number, reverse?: boolean): Client; - waitForText(milliseconds?: number, reverse?: boolean): Client; - waitForText

(selector: string): Client

; - waitForText

(): Client

; + waitForText( + selector: string, + milliseconds?: number, + reverse?: boolean + ): Client; + waitForText( + milliseconds?: number, + reverse?: boolean + ): Client; + waitForText

(selector?: string): Client

; waitForText

( selector: string, milliseconds: number @@ -818,10 +876,16 @@ declare namespace WebdriverIO { reverse: boolean ): Client

; - waitForValue(selector: string, milliseconds?: number, reverse?: boolean): Client; - waitForValue(milliseconds?: number, reverse?: boolean): Client; - waitForValue

(selector: string): Client

; - waitForValue

(): Client

; + waitForValue( + selector: string, + milliseconds?: number, + reverse?: boolean + ): Client; + waitForValue( + milliseconds?: number, + reverse?: boolean + ): Client; + waitForValue

(selector?: string): Client

; waitForValue

( selector: string, milliseconds: number @@ -839,10 +903,16 @@ declare namespace WebdriverIO { ): Client

; - waitForVisible(selector: string, milliseconds?: number, reverse?: boolean): Client; - waitForVisible(milliseconds?: number, reverse?: boolean): Client; - waitForVisible

(selector: string): Client

; - waitForVisible

(): Client

; + waitForVisible( + selector: string, + milliseconds?: number, + reverse?: boolean + ): Client; + waitForVisible( + milliseconds?: number, + reverse?: boolean + ): Client; + waitForVisible

(selector?: string): Client

; waitForVisible

( selector: string, milliseconds: number @@ -877,8 +947,7 @@ declare namespace WebdriverIO { close(windowHandle?: string): Client; - close

(): Client

; - close

(windowHandle: string): Client

; + close

(windowHandle?: string): Client

; getCurrentTabId(): Client; getCurrentTabId

(): Client

; @@ -888,25 +957,30 @@ declare namespace WebdriverIO { getViewportSize(): Client & Size; getViewportSize(dimension: string): Client; - getViewportSize

(): Client

; - getViewportSize

(dimension: string): Client

; + getViewportSize

(dimension?: string): Client

; - newWindow(url: string, windowName: string, windowFeatures: string): Client; + newWindow( + url: string, + windowName: string, + windowFeatures: string + ): Client; newWindow

( url: string, windowName: string, windowFeatures: string ): Client

; - setViewportSize(size: Size, type: boolean): Client; + setViewportSize( + size: Size, + type: boolean + ): Client; setViewportSize

( size: Size, type: boolean ): Client

; switchTab(windowHandle?: string): Client; - switchTab

(): Client

; - switchTab

(windowHandle: string): Client

; + switchTab

(windowHandle?: string): Client

; } export interface Options { From b16be42e6dc51e6333372d3d92d10ffd6bb955d2 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 15 Dec 2016 13:39:51 -0800 Subject: [PATCH 22/22] Add `fallback` and simplify `or` --- parsimmon/index.d.ts | 15 +++++++++------ parsimmon/parsimmon-tests.ts | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/parsimmon/index.d.ts b/parsimmon/index.d.ts index 85ea74cfd9..417cd962b5 100644 --- a/parsimmon/index.d.ts +++ b/parsimmon/index.d.ts @@ -83,8 +83,7 @@ declare namespace Parsimmon { /** * returns a new parser which tries parser, and if it fails uses otherParser. */ - or(otherParser: Parser): Parser; - or(otherParser: Parser): Parser; + or(otherParser: Parser): Parser; /** * returns a new parser which tries parser, and on success calls the given function * with the result of the parse, which is expected to return another parser, which @@ -106,14 +105,18 @@ declare namespace Parsimmon { * transforms the output of parser with the given function. */ map(call: (result: T) => U): Parser; - /** - * expects otherParser after parser, but preserves the yield value of parser. - */ - skip(otherParser: Parser): Parser; /** * returns a new parser with the same behavior, but which yields aResult. */ result(aResult: U): Parser; + /** + * returns a new parser that returns the fallback value if the first parser failed. + */ + fallback(fallbackValue: U): Parser; + /** + * expects otherParser after parser, but preserves the yield value of parser. + */ + skip(otherParser: Parser): Parser; /** * expects parser zero or more times, and yields an array of the results. */ diff --git a/parsimmon/parsimmon-tests.ts b/parsimmon/parsimmon-tests.ts index e0c6e0b00c..6be7eb307a 100644 --- a/parsimmon/parsimmon-tests.ts +++ b/parsimmon/parsimmon-tests.ts @@ -38,6 +38,7 @@ var indexPar: Parser; var fooPar: Parser; var barPar: Parser; +var fooOrBarPar: Parser; // -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -84,7 +85,7 @@ fooResult = fooPar.parse(str); foo = fooPar.tryParse(str); fooPar = fooPar.or(fooPar); -anyPar = fooPar.or(barPar); +fooOrBarPar = fooPar.or(barPar); barPar = fooPar.chain((f) => { foo = f; @@ -108,6 +109,8 @@ fooPar = fooPar.skip(barPar); barPar = barPar = fooPar.result(bar); +fooOrBarPar = fooPar.fallback(bar); + // -- -- -- -- -- -- -- -- -- -- -- -- -- fooArrPar = fooPar.many();