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 + } +} diff --git a/emojione/emojione-tests.ts b/emojione/emojione-tests.ts new file mode 100644 index 0000000000..ea5d04e217 --- /dev/null +++ b/emojione/emojione-tests.ts @@ -0,0 +1,13 @@ +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/index.d.ts b/emojione/index.d.ts new file mode 100644 index 0000000000..48b55e87cd --- /dev/null +++ b/emojione/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for emojione 2.2 +// Project: https://github.com/Ranks/emojione +// Definitions by: Danilo Bargen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +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; 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" } diff --git a/knex/index.d.ts b/knex/index.d.ts index 95bab7ac69..33edec4c5e 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; @@ -380,8 +380,8 @@ declare namespace Knex { foreign(column: string): ForeignConstraintBuilder; foreign(columns: string[]): MultikeyForeignConstraintBuilder; dropForeign(columnNames: string[], foreignKeyName?: string): TableBuilder; - dropUnique(columnNames: string[], indexName?: string): TableBuilder; - dropPrimary(constraintName?: string): TableBuilder; + dropUnique(columnNames: string[], indexName?: string): TableBuilder; + dropPrimary(constraintName?: string): TableBuilder; } interface CreateTableBuilder extends TableBuilder { diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index e149612ea9..8fd9cc971c 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -432,6 +432,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'); diff --git a/parsimmon/index.d.ts b/parsimmon/index.d.ts index 6dc61539ab..417cd962b5 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,300 @@ 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; + /** + * 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; + /** + * 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. + */ + 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..6be7eb307a 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; @@ -40,6 +38,7 @@ var indexPar: Parser; var fooPar: Parser; var barPar: Parser; +var fooOrBarPar: Parser; // -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -53,23 +52,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)); @@ -80,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; @@ -104,6 +109,8 @@ fooPar = fooPar.skip(barPar); barPar = barPar = fooPar.result(bar); +fooOrBarPar = fooPar.fallback(bar); + // -- -- -- -- -- -- -- -- -- -- -- -- -- fooArrPar = fooPar.many(); @@ -139,7 +146,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 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 */ diff --git a/three/index.d.ts b/three/index.d.ts index 1a691e7878..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: 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 { 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 diff --git a/uikit/index.d.ts b/uikit/index.d.ts index 3c2f8ceb73..cf2930bdaa 100644 --- a/uikit/index.d.ts +++ b/uikit/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for uikit 2.23.0 +// Type definitions for uikit 2.27 // Project: http://getuikit.org -// Definitions by: Giovanni Silva +// Definitions by: Giovanni Silva , Ivo Senner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -10,16 +10,53 @@ 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 { + /** + * 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 @@ -64,33 +101,42 @@ 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 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 @@ -104,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 @@ -133,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} @@ -189,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 @@ -243,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) @@ -281,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) @@ -289,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; } /** @@ -325,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 @@ -427,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. @@ -514,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. @@ -613,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 @@ -668,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. @@ -736,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 @@ -759,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. @@ -774,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 @@ -782,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 { /** @@ -811,7 +791,7 @@ declare namespace UIkit { *

Possible value

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

Possible value

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

Possible value

* string */ - param?: string + param?: string; /** * Delay time after stop typing @@ -835,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 @@ -857,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. @@ -956,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; } /** @@ -998,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 @@ -1013,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; } /** @@ -1076,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 @@ -1091,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; } /** @@ -1179,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 @@ -1194,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 @@ -1230,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 @@ -1287,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; } /** @@ -1408,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; } 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 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. }); diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index 44a0e6ea57..fbc6925fa9 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,118 @@ 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(selector?: string): Client; + clearElement

(selector?: string): Client

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

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

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

(selector?: string): Client

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

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

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

(selector?: string): 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(selector?: string): Client; + leftClick

(selector?: string): Client

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

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

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

(selector?: string): Client

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

( + moveToObject(selector?: string): 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

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

; + moveToObject

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

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

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

(selector?: string): Client

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

; - - selectByAttribute(selector: string, attribute: string, value: string): Client; + 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( + 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( + 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( + 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[], @@ -133,18 +155,23 @@ declare namespace WebdriverIO { ...args: any[] ): Client

; - setValue(selector: string, 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, - 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(selector?: string): Client; + submitForm

(selector?: string): Client

; } // Appium @@ -187,51 +214,31 @@ 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

(name?: string): Client

; 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

(name?: string): Client

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

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

; + setCookie

(cookie: Cookie): Client

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

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

; + session( + action?: string, + sessionId?: string + ): 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 @@ -276,97 +283,123 @@ declare namespace WebdriverIO { // Property export interface Client { - getAttribute(selector: string, 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 + attributeName: string ): Client

; + getAttribute

(attributeName: string): Client

; - getCssProperty(selector: string, 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 + cssProperty: string ): Client

; + getCssProperty

(cssProperty: string): Client

; - getElementSize(selector: string): Client; - getElementSize(selector: string, 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

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

; - getElementSize

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

; + getElementSize

(dimension: string): Client

; - getHTML(selector: string, 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

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

; - getHTML

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

; + getHTML

(includeSelectorTag: boolean): Client

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

(selector?: string): Client

; getLocation

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

; - getLocation

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

; + getLocation

(axis: string): Client

; - getLocationInView(selector: string): Client; - getLocationInView(selector: string, 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

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

; - getLocationInView

( - selector: string, - 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

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

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

(selector?: string): Client

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

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

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

(selector?: string): 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

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

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

(selector?: string): Client

; } export interface LogEntry { @@ -395,7 +428,7 @@ declare namespace WebdriverIO { value: any; } - export interface GeoLocation { + export interface Location { latitude: number; longitude: number; altitude: number; @@ -413,94 +446,56 @@ 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(): Client> & RawResult; 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

(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

(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(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

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

; + xoffset?: number, + yoffset?: number + ): Client; + moveTo( + xoffset?: number, + yoffset?: number + ): Client; + moveTo

(id: ElementId): 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,73 +511,42 @@ 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

( - 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, - 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

(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

(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 @@ -604,117 +568,89 @@ 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; - 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( + 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

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

(id: ElementId): Client

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

; - - elementIdElement(id: ElementId, selector: string): Client>; + 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

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

(id: ElementId): Client

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

(id: ElementId): Client

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

(id: ElementId): Client

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

(id: ElementId): Client

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

(id: ElementId): Client

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

(id: ElementId): Client

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

(id: ElementId): Client

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

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

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

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

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

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

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

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

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

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

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

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

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

; - - elementIdValue(id: ElementId, values: string | string[]): Client>; + 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 @@ -723,10 +659,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 @@ -746,45 +682,27 @@ declare namespace WebdriverIO { // use submitForm instead submit(id: ElementId): Client; - submit

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

; + submit

(id: ElementId): Client

; // title } // State export interface Client { - isEnabled(selector: string): Client; - isEnabled

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

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

(selector?: string): Client

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

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

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

(selector?: string): Client

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

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

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

(selector?: string): Client

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

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

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

(selector?: string): Client

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

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

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

(selector?: string): Client

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

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

; - addCommand

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

; - chooseFile(selector: string, localPath: string): 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

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

; + getCommandHistory

(): Client

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

(milliseconds: number, callback: (err: any) => P): 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

(filename?: string): Client

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

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

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

(selector?: string): 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

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

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

(selector?: string): Client

; waitForEnabled

( selector: string, 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 ): Client

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

(selector?: string): Client

; waitForExist

( selector: string, - 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

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

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

(selector?: string): Client

; waitForSelected

( selector: string, - 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

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

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

(selector?: string): Client

; waitForText

( selector: string, - 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

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

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

(selector?: string): Client

; waitForValue

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

; - waitForValue

( - selector: string, - 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

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

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

; - waitForVisible

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

; - waitForVisible

( - selector: string, + 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

( + selector: string, + milliseconds: number + ): Client

; + waitForVisible

(milliseconds: number): Client

; + waitForVisible

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

; + waitForVisible

( + milliseconds: number, + reverse: boolean ): Client

; waitUntil( @@ -983,65 +938,49 @@ 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

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

; - close

( - windowHandle: string, - callback: (err: any) => P - ): 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

(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, - callback: (err: any, windowId: string) => P + windowFeatures: string ): Client

; - setViewportSize(size: Size, type: boolean): Client; + 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

(windowHandle?: string): Client

; } export interface Options { @@ -1085,3 +1024,4 @@ declare var browser: WebdriverIO.Client; declare module "webdriverio" { export = WebdriverIO; } + diff --git a/webdriverio/webdriverio-tests.ts b/webdriverio/webdriverio-tests.ts index 0e752e93ce..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,27 +39,28 @@ 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) { - client.end(done); + after(function() { + client.end(); }); });