From 4bed8394f211e046df3cc383769978a5ab7d1cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20R=C3=A4ntil=C3=A4?= Date: Thu, 12 Oct 2017 23:26:42 +0200 Subject: [PATCH 001/639] [node] [crypto] Added missing crypto update types * Added DataView as type of crypto update functions --- types/node/index.d.ts | 24 +++++++++---------- types/node/node-tests.ts | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index ee1511b99d..a2295652d0 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -4876,23 +4876,23 @@ declare module "crypto" { type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; export interface Hash extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hash; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash; + update(data: string | Buffer | DataView): Hash; + update(data: string | Buffer | DataView, input_encoding: Utf8AsciiLatin1Encoding): Hash; digest(): Buffer; digest(encoding: HexBase64Latin1Encoding): string; } export interface Hmac extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hmac; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac; + update(data: string | Buffer | DataView): Hmac; + update(data: string | Buffer | DataView, input_encoding: Utf8AsciiLatin1Encoding): Hmac; digest(): Buffer; digest(encoding: HexBase64Latin1Encoding): string; } export function createCipher(algorithm: string, password: any): Cipher; export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; export interface Cipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; + update(data: Buffer | DataView): Buffer; update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; + update(data: Buffer | DataView, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string; final(): Buffer; final(output_encoding: string): string; @@ -4903,9 +4903,9 @@ declare module "crypto" { export function createDecipher(algorithm: string, password: any): Decipher; export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; export interface Decipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; + update(data: Buffer | DataView): Buffer; update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; + update(data: Buffer | DataView, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string; final(): Buffer; final(output_encoding: string): string; @@ -4915,15 +4915,15 @@ declare module "crypto" { } export function createSign(algorithm: string): Signer; export interface Signer extends NodeJS.WritableStream { - update(data: string | Buffer): Signer; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer; + update(data: string | Buffer | DataView): Signer; + update(data: string | Buffer | DataView, input_encoding: Utf8AsciiLatin1Encoding): Signer; sign(private_key: string | { key: string; passphrase: string }): Buffer; sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string; } export function createVerify(algorith: string): Verify; export interface Verify extends NodeJS.WritableStream { - update(data: string | Buffer): Verify; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; + update(data: string | Buffer | DataView): Verify; + update(data: string | Buffer | DataView, input_encoding: Utf8AsciiLatin1Encoding): Verify; verify(object: string | Object, signature: Buffer | DataView): boolean; verify(object: string | Object, signature: string, signature_format: HexBase64Latin1Encoding): boolean; // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 8e53bf74d4..6101ff93a0 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -857,9 +857,39 @@ function simplified_stream_ctor_test() { namespace crypto_tests { { + // crypto_hash_string_test + var hashResult: string = crypto.createHash('md5').update('world').digest('hex'); + } + + { + // crypto_hash_buffer_test + var hashResult: string = crypto.createHash('md5') + .update(new Buffer('world')).digest('hex'); + } + + { + // crypto_hash_dataview_test + var hashResult: string = crypto.createHash('md5') + .update(new DataView(new Buffer('world').buffer)).digest('hex'); + } + + { + // crypto_hmac_string_test var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex'); } + { + // crypto_hmac_buffer_test + var hmacResult: string = crypto.createHmac('md5', 'hello') + .update(new Buffer('world')).digest('hex'); + } + + { + // crypto_hmac_dataview_test + var hmacResult: string = crypto.createHmac('md5', 'hello') + .update(new DataView(new Buffer('world').buffer)).digest('hex'); + } + { let hmac: crypto.Hmac; (hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => { @@ -903,6 +933,28 @@ namespace crypto_tests { assert.deepEqual(clearText2, clearText); } + { + // crypto_cipher_decipher_dataview_test + let key: Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]); + let clearText: DataView = new DataView( + new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4]).buffer); + let cipher: crypto.Cipher = crypto.createCipher("aes-128-ecb", key); + let cipherBuffers: Buffer[] = []; + cipherBuffers.push(cipher.update(clearText)); + cipherBuffers.push(cipher.final()); + + let cipherText: DataView = new DataView(Buffer.concat(cipherBuffers).buffer); + + let decipher: crypto.Decipher = crypto.createDecipher("aes-128-ecb", key); + let decipherBuffers: Buffer[] = []; + decipherBuffers.push(decipher.update(cipherText)); + decipherBuffers.push(decipher.final()); + + let clearText2: Buffer = Buffer.concat(decipherBuffers); + + assert.deepEqual(clearText2, clearText); + } + { let buffer1: Buffer = new Buffer([1, 2, 3, 4, 5]); let buffer2: Buffer = new Buffer([1, 2, 3, 4, 5]); From 8ff1f29a5b58e120035812e1f606476b16570875 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Thu, 19 Oct 2017 12:49:08 +0100 Subject: [PATCH 002/639] Node: remove redundant widen of query type to any --- types/node/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index d8e8fe3358..fedc0d99b6 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2188,7 +2188,6 @@ declare module "url" { export interface Url extends UrlObject { port?: string; - query?: any; } export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; From 0e652b0a41843f5e851f434df376427e834c2911 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Thu, 19 Oct 2017 12:49:23 +0100 Subject: [PATCH 003/639] Node: rename URL types for clarity --- types/node/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index fedc0d99b6..e54d972797 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2171,7 +2171,7 @@ declare module "child_process" { } declare module "url" { - export interface UrlObject { + export interface InputUrlObject { auth?: string; hash?: string; host?: string; @@ -2186,13 +2186,13 @@ declare module "url" { slashes?: boolean; } - export interface Url extends UrlObject { + export interface OutputUrlObject extends InputUrlObject { port?: string; } - export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; + export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): OutputUrlObject; export function format(URL: URL, options?: URLFormatOptions): string; - export function format(urlObject: UrlObject | string): string; + export function format(urlObject: InputUrlObject | string): string; export function resolve(from: string, to: string): string; export interface URLFormatOptions { From 901b2ad5187b29eac80a3ca8efa947f41372f43b Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Thu, 19 Oct 2017 12:55:39 +0100 Subject: [PATCH 004/639] Node: add and share `ParsedUrlQuery` type --- types/node/index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index e54d972797..44c8b68283 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -796,8 +796,10 @@ declare module "querystring" { decodeURIComponent?: Function; } + interface ParsedUrlQuery { [key: string]: string | string[]; } + export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): { [key: string]: string | string[] }; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery; export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; export function escape(str: string): string; export function unescape(str: string): string; @@ -2171,6 +2173,8 @@ declare module "child_process" { } declare module "url" { + import { ParsedUrlQuery } from 'querystring'; + export interface InputUrlObject { auth?: string; hash?: string; @@ -2181,7 +2185,7 @@ declare module "url" { pathname?: string; port?: string | number; protocol?: string; - query?: string | null | { [key: string]: string | string[] }; + query?: string | null | ParsedUrlQuery; search?: string; slashes?: boolean; } From b4e99c01a95804d9afa0952d581a65829c552656 Mon Sep 17 00:00:00 2001 From: Oz Weiss Date: Thu, 19 Oct 2017 17:27:47 +0300 Subject: [PATCH 005/639] fix Worker.id type https://nodejs.org/docs/latest-v7.x/api/cluster.html#cluster_worker_id --- types/node/v7/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index fc6cd33091..9d69d53033 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -850,7 +850,7 @@ declare module "cluster" { } export class Worker extends events.EventEmitter { - id: string; + id: number; process: child.ChildProcess; suicide: boolean; send(message: any, sendHandle?: any, callback?: (error: Error) => void): boolean; From 9038ae1fe32a46899e2dc8494e7921d7fb8727f8 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Thu, 19 Oct 2017 18:57:56 +0100 Subject: [PATCH 006/639] Revert "Node: rename URL types for clarity" This reverts commit 0e652b0a41843f5e851f434df376427e834c2911. --- types/node/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 44c8b68283..2ffe900742 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2175,7 +2175,7 @@ declare module "child_process" { declare module "url" { import { ParsedUrlQuery } from 'querystring'; - export interface InputUrlObject { + export interface UrlObject { auth?: string; hash?: string; host?: string; @@ -2190,13 +2190,13 @@ declare module "url" { slashes?: boolean; } - export interface OutputUrlObject extends InputUrlObject { + export interface Url extends UrlObject { port?: string; } - export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): OutputUrlObject; + export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; export function format(URL: URL, options?: URLFormatOptions): string; - export function format(urlObject: InputUrlObject | string): string; + export function format(urlObject: UrlObject | string): string; export function resolve(from: string, to: string): string; export interface URLFormatOptions { From e0f0ac204ab3fb5846ad57b91cfe9ad7cdc96a5b Mon Sep 17 00:00:00 2001 From: Oz Weiss Date: Thu, 19 Oct 2017 21:30:04 +0300 Subject: [PATCH 007/639] worker.id is number, not string --- types/node/v0/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/v0/index.d.ts b/types/node/v0/index.d.ts index ccf2e5e207..65da8a9459 100644 --- a/types/node/v0/index.d.ts +++ b/types/node/v0/index.d.ts @@ -632,7 +632,7 @@ declare module "cluster" { } export class Worker extends events.EventEmitter { - id: string; + id: number; process: child.ChildProcess; suicide: boolean; send(message: any, sendHandle?: any): void; From 2a51338ed972423553d6cd3af558e68f39047419 Mon Sep 17 00:00:00 2001 From: Oz Weiss Date: Thu, 19 Oct 2017 21:30:56 +0300 Subject: [PATCH 008/639] worker.id is number, not string --- types/node/v4/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index d88db82da1..43a9c3f896 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -742,7 +742,7 @@ declare module "cluster" { } export class Worker extends events.EventEmitter { - id: string; + id: number; process: child.ChildProcess; suicide: boolean; send(message: any, sendHandle?: any, callback?: (error: Error) => void): void; From 66711b599c84cfd8797ce9b9bc5e4f2237ac1e6d Mon Sep 17 00:00:00 2001 From: Oz Weiss Date: Thu, 19 Oct 2017 21:31:34 +0300 Subject: [PATCH 009/639] worker.id is number, not string --- types/node/v6/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 8f73bab752..2f41034a49 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -833,7 +833,7 @@ declare module "cluster" { } export class Worker extends events.EventEmitter { - id: string; + id: number; process: child.ChildProcess; suicide: boolean; send(message: any, sendHandle?: any, callback?: (error: Error) => void): boolean; From ae4c4409166f9266812199f88f3ff9aecf7734ea Mon Sep 17 00:00:00 2001 From: Oz Weiss Date: Thu, 19 Oct 2017 21:32:06 +0300 Subject: [PATCH 010/639] worker.id is number, not string --- types/node/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index d8e8fe3358..1795379c71 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1059,7 +1059,7 @@ declare module "cluster" { } export class Worker extends events.EventEmitter { - id: string; + id: number; process: child.ChildProcess; suicide: boolean; send(message: any, sendHandle?: any, callback?: (error: Error) => void): boolean; From 17fd72797f045734e7bc65c1e7322849d681572c Mon Sep 17 00:00:00 2001 From: Kaelig Deloumeau-Prigent Date: Mon, 23 Oct 2017 15:16:24 -0700 Subject: [PATCH 011/639] Add as attribute to AllHTMLAttributes --- types/react/v15/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react/v15/index.d.ts b/types/react/v15/index.d.ts index c35e2df3c0..36cb7a392a 100644 --- a/types/react/v15/index.d.ts +++ b/types/react/v15/index.d.ts @@ -2434,6 +2434,7 @@ declare namespace React { allowFullScreen?: boolean; allowTransparency?: boolean; alt?: string; + as?: string; async?: boolean; autoComplete?: string; autoFocus?: boolean; From c2b55c10e78105a910c1ead11282bf1243562aa9 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Wed, 25 Oct 2017 17:46:15 +0100 Subject: [PATCH 012/639] Create `UrlObjectCommon` and move wider `port` type to `UrlObject` --- types/node/index.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 2ffe900742..bdbfa67817 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2175,7 +2175,7 @@ declare module "child_process" { declare module "url" { import { ParsedUrlQuery } from 'querystring'; - export interface UrlObject { + export interface UrlObjectCommon { auth?: string; hash?: string; host?: string; @@ -2183,14 +2183,17 @@ declare module "url" { href?: string; path?: string; pathname?: string; - port?: string | number; protocol?: string; query?: string | null | ParsedUrlQuery; search?: string; slashes?: boolean; } - export interface Url extends UrlObject { + export interface UrlObject extends UrlObjectCommon { + port?: string | number; + } + + export interface Url extends UrlObjectCommon { port?: string; } From d12e7c1f38054306aaf30e74baa9785b56719ffd Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Wed, 25 Oct 2017 17:46:33 +0100 Subject: [PATCH 013/639] Specify wider `query` for `UrlObject` --- types/node/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index bdbfa67817..ac7081f7e2 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2184,17 +2184,18 @@ declare module "url" { path?: string; pathname?: string; protocol?: string; - query?: string | null | ParsedUrlQuery; search?: string; slashes?: boolean; } export interface UrlObject extends UrlObjectCommon { port?: string | number; + query?: string | null | { [key: string]: any }; } export interface Url extends UrlObjectCommon { port?: string; + query?: string | null | ParsedUrlQuery; } export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; From 95f225e44a1a35edef109c4d28a8026b0b081648 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Wed, 25 Oct 2017 17:47:06 +0100 Subject: [PATCH 014/639] Document types --- types/node/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index ac7081f7e2..7e38b30625 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2188,11 +2188,13 @@ declare module "url" { slashes?: boolean; } + // Input to `url.format` export interface UrlObject extends UrlObjectCommon { port?: string | number; query?: string | null | { [key: string]: any }; } + // Output of `url.parse` export interface Url extends UrlObjectCommon { port?: string; query?: string | null | ParsedUrlQuery; From 2a9cc5af4c13e96023b5cbed8003615aecfb8faf Mon Sep 17 00:00:00 2001 From: Michael Marner Date: Thu, 26 Oct 2017 16:55:26 +1030 Subject: [PATCH 015/639] Add types for aws-lambda DynamoDB stream events --- types/aws-lambda/aws-lambda-tests.ts | 92 ++++++++++++++++++++++++++++ types/aws-lambda/index.d.ts | 47 ++++++++++++++ 2 files changed, 139 insertions(+) diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 4e404fcd55..b561d1f98c 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -100,6 +100,98 @@ str = customAuthorizerEvt.type; str = customAuthorizerEvt.authorizationToken; str = customAuthorizerEvt.methodArn; +/* DynamoDB Stream Event */ +var dynamoDBStreamEvent: DynamoDBStreamEvent = { + "Records": [ + { + "eventID": "1", + "eventVersion": "1.0", + "dynamodb": { + "Keys": { + "Id": { + "N": "101" + } + }, + "NewImage": { + "Message": { + "S": "New item!" + }, + "Id": { + "N": "101" + } + }, + "StreamViewType": "NEW_AND_OLD_IMAGES", + "SequenceNumber": "111", + "SizeBytes": 26 + }, + "awsRegion": "us-west-2", + "eventName": "INSERT", + "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "eventSource": "aws:dynamodb" + }, + { + "eventID": "2", + "eventVersion": "1.0", + "dynamodb": { + "OldImage": { + "Message": { + "S": "New item!" + }, + "Id": { + "N": "101" + } + }, + "SequenceNumber": "222", + "Keys": { + "Id": { + "N": "101" + } + }, + "SizeBytes": 59, + "NewImage": { + "Message": { + "S": "This item has changed" + }, + "Id": { + "N": "101" + } + }, + "StreamViewType": "NEW_AND_OLD_IMAGES" + }, + "awsRegion": "us-west-2", + "eventName": "MODIFY", + "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "eventSource": "aws:dynamodb" + }, + { + "eventID": "3", + "eventVersion": "1.0", + "dynamodb": { + "Keys": { + "Id": { + "N": "101" + } + }, + "SizeBytes": 38, + "SequenceNumber": "333", + "OldImage": { + "Message": { + "S": "This item has changed" + }, + "Id": { + "N": "101" + } + }, + "StreamViewType": "NEW_AND_OLD_IMAGES" + }, + "awsRegion": "us-west-2", + "eventName": "REMOVE", + "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "eventSource": "aws:dynamodb" + } + ] +}; + /* SNS Event */ snsEvtRecs = snsEvt.Records; diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index b1ca69405b..82d0bbeca0 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -54,6 +54,53 @@ interface CustomAuthorizerEvent { methodArn: string; } +// Context +// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_AttributeValue.html +interface AttributeValue { + B?: string; + BS?: Array; + BOOL?: boolean; + L?: Array; + M?: { [id: string]: AttributeValue }; + N?: number; + NS?: Array; + NULL?: boolean; + S?: string; + SS?: Array; +} + +// Context +// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html +interface StreamRecord { + ApproximateCreationTime?: number; + Keys?: { [key: string]: AttributeValue }; + NewImage?: { [key: string]: AttributeValue }; + OldImage?: { [key: string]: AttributeValue }; + SequenceNumber?: string; + SizeBytes?: number; + StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES'; +} + +// Context +// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html +interface DynamoDBRecord { + awsRegion?: string; + dynamodb?: StreamRecord; + eventId?: string; + eventName?: 'INSERT' | 'MODIFY' | 'REMOVE'; + eventSource?: string; + eventVersion?: string; + userIdentity?: any; +} + +// AWS Lambda Stream event +// Context +// http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update +interface DynamoDBStreamEvent { + Records: Array; +} + + // SNS "event" interface SNSMessageAttribute { Type: string; From 6a4db4bb55a833341f7bcb209d081b8fdb2581a8 Mon Sep 17 00:00:00 2001 From: Michael Marner Date: Thu, 26 Oct 2017 17:07:58 +1030 Subject: [PATCH 016/639] Add missing parameters --- types/aws-lambda/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index 82d0bbeca0..e58b03b7c8 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -86,9 +86,10 @@ interface StreamRecord { interface DynamoDBRecord { awsRegion?: string; dynamodb?: StreamRecord; - eventId?: string; + eventID?: string; eventName?: 'INSERT' | 'MODIFY' | 'REMOVE'; eventSource?: string; + eventSourceARN?: string; eventVersion?: string; userIdentity?: any; } From 8c6c695fbd076c9dd639dbbdbb76ee731be5583b Mon Sep 17 00:00:00 2001 From: Michael Marner Date: Thu, 26 Oct 2017 17:08:41 +1030 Subject: [PATCH 017/639] aws-lambda dynamo tests --- types/aws-lambda/aws-lambda-tests.ts | 125 ++++++++++++++------------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index b561d1f98c..83fd9f5486 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -101,93 +101,96 @@ str = customAuthorizerEvt.authorizationToken; str = customAuthorizerEvt.methodArn; /* DynamoDB Stream Event */ -var dynamoDBStreamEvent: DynamoDBStreamEvent = { - "Records": [ +var dynamoDBStreamEvent: AWSLambda.DynamoDBStreamEvent = { + Records: [ { - "eventID": "1", - "eventVersion": "1.0", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" + eventID: '1', + eventVersion: '1.0', + dynamodb: { + Keys: { + Id: { + N: 101 } }, - "NewImage": { - "Message": { - "S": "New item!" + NewImage: { + Message: { + S: 'New item!' }, - "Id": { - "N": "101" + Id: { + N: 101 } }, - "StreamViewType": "NEW_AND_OLD_IMAGES", - "SequenceNumber": "111", - "SizeBytes": 26 + StreamViewType: 'NEW_AND_OLD_IMAGES', + SequenceNumber: '111', + SizeBytes: 26 }, - "awsRegion": "us-west-2", - "eventName": "INSERT", - "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" + awsRegion: 'us-west-2', + eventName: 'INSERT', + eventSourceARN: + 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', + eventSource: 'aws:dynamodb' }, { - "eventID": "2", - "eventVersion": "1.0", - "dynamodb": { - "OldImage": { - "Message": { - "S": "New item!" + eventID: '2', + eventVersion: '1.0', + dynamodb: { + OldImage: { + Message: { + S: 'New item!' }, - "Id": { - "N": "101" + Id: { + N: 101 } }, - "SequenceNumber": "222", - "Keys": { - "Id": { - "N": "101" + SequenceNumber: '222', + Keys: { + Id: { + N: 101 } }, - "SizeBytes": 59, - "NewImage": { - "Message": { - "S": "This item has changed" + SizeBytes: 59, + NewImage: { + Message: { + S: 'This item has changed' }, - "Id": { - "N": "101" + Id: { + N: 101 } }, - "StreamViewType": "NEW_AND_OLD_IMAGES" + StreamViewType: 'NEW_AND_OLD_IMAGES' }, - "awsRegion": "us-west-2", - "eventName": "MODIFY", - "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" + awsRegion: 'us-west-2', + eventName: 'MODIFY', + eventSourceARN: + 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', + eventSource: 'aws:dynamodb' }, { - "eventID": "3", - "eventVersion": "1.0", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" + eventID: '3', + eventVersion: '1.0', + dynamodb: { + Keys: { + Id: { + N: 101 } }, - "SizeBytes": 38, - "SequenceNumber": "333", - "OldImage": { - "Message": { - "S": "This item has changed" + SizeBytes: 38, + SequenceNumber: '333', + OldImage: { + Message: { + S: 'This item has changed' }, - "Id": { - "N": "101" + Id: { + N: 101 } }, - "StreamViewType": "NEW_AND_OLD_IMAGES" + StreamViewType: 'NEW_AND_OLD_IMAGES' }, - "awsRegion": "us-west-2", - "eventName": "REMOVE", - "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" + awsRegion: 'us-west-2', + eventName: 'REMOVE', + eventSourceARN: + 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', + eventSource: 'aws:dynamodb' } ] }; From a320e3c801d7187db103015aa039d9256e85110d Mon Sep 17 00:00:00 2001 From: Michael Marner Date: Thu, 26 Oct 2017 17:12:24 +1030 Subject: [PATCH 018/639] Add name to authors --- types/aws-lambda/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index e58b03b7c8..a39a33887c 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -8,6 +8,7 @@ // Yoriki Yamaguchi // wwwy3y3 // Ishaan Malhi +// Michael Marner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 From 6fec1b5b8c3aee03b0c2b296681d247bf163f449 Mon Sep 17 00:00:00 2001 From: Michael Marner Date: Thu, 26 Oct 2017 17:15:44 +1030 Subject: [PATCH 019/639] Format as per styleguide --- types/aws-lambda/aws-lambda-tests.ts | 178 +++++++++++++-------------- types/aws-lambda/index.d.ts | 53 ++++---- 2 files changed, 115 insertions(+), 116 deletions(-) diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 83fd9f5486..dd5d9fa762 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -102,97 +102,97 @@ str = customAuthorizerEvt.methodArn; /* DynamoDB Stream Event */ var dynamoDBStreamEvent: AWSLambda.DynamoDBStreamEvent = { - Records: [ - { - eventID: '1', - eventVersion: '1.0', - dynamodb: { - Keys: { - Id: { - N: 101 - } + Records: [ + { + eventID: '1', + eventVersion: '1.0', + dynamodb: { + Keys: { + Id: { + N: 101 + } + }, + NewImage: { + Message: { + S: 'New item!' + }, + Id: { + N: 101 + } + }, + StreamViewType: 'NEW_AND_OLD_IMAGES', + SequenceNumber: '111', + SizeBytes: 26 + }, + awsRegion: 'us-west-2', + eventName: 'INSERT', + eventSourceARN: + 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', + eventSource: 'aws:dynamodb' }, - NewImage: { - Message: { - S: 'New item!' - }, - Id: { - N: 101 - } + { + eventID: '2', + eventVersion: '1.0', + dynamodb: { + OldImage: { + Message: { + S: 'New item!' + }, + Id: { + N: 101 + } + }, + SequenceNumber: '222', + Keys: { + Id: { + N: 101 + } + }, + SizeBytes: 59, + NewImage: { + Message: { + S: 'This item has changed' + }, + Id: { + N: 101 + } + }, + StreamViewType: 'NEW_AND_OLD_IMAGES' + }, + awsRegion: 'us-west-2', + eventName: 'MODIFY', + eventSourceARN: + 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', + eventSource: 'aws:dynamodb' }, - StreamViewType: 'NEW_AND_OLD_IMAGES', - SequenceNumber: '111', - SizeBytes: 26 - }, - awsRegion: 'us-west-2', - eventName: 'INSERT', - eventSourceARN: - 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', - eventSource: 'aws:dynamodb' - }, - { - eventID: '2', - eventVersion: '1.0', - dynamodb: { - OldImage: { - Message: { - S: 'New item!' - }, - Id: { - N: 101 - } - }, - SequenceNumber: '222', - Keys: { - Id: { - N: 101 - } - }, - SizeBytes: 59, - NewImage: { - Message: { - S: 'This item has changed' - }, - Id: { - N: 101 - } - }, - StreamViewType: 'NEW_AND_OLD_IMAGES' - }, - awsRegion: 'us-west-2', - eventName: 'MODIFY', - eventSourceARN: - 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', - eventSource: 'aws:dynamodb' - }, - { - eventID: '3', - eventVersion: '1.0', - dynamodb: { - Keys: { - Id: { - N: 101 - } - }, - SizeBytes: 38, - SequenceNumber: '333', - OldImage: { - Message: { - S: 'This item has changed' - }, - Id: { - N: 101 - } - }, - StreamViewType: 'NEW_AND_OLD_IMAGES' - }, - awsRegion: 'us-west-2', - eventName: 'REMOVE', - eventSourceARN: - 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', - eventSource: 'aws:dynamodb' - } - ] + { + eventID: '3', + eventVersion: '1.0', + dynamodb: { + Keys: { + Id: { + N: 101 + } + }, + SizeBytes: 38, + SequenceNumber: '333', + OldImage: { + Message: { + S: 'This item has changed' + }, + Id: { + N: 101 + } + }, + StreamViewType: 'NEW_AND_OLD_IMAGES' + }, + awsRegion: 'us-west-2', + eventName: 'REMOVE', + eventSourceARN: + 'arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899', + eventSource: 'aws:dynamodb' + } + ] }; /* SNS Event */ diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index a39a33887c..e938bfb1eb 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -58,51 +58,50 @@ interface CustomAuthorizerEvent { // Context // http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_AttributeValue.html interface AttributeValue { - B?: string; - BS?: Array; - BOOL?: boolean; - L?: Array; - M?: { [id: string]: AttributeValue }; - N?: number; - NS?: Array; - NULL?: boolean; - S?: string; - SS?: Array; + B?: string; + BS?: Array; + BOOL?: boolean; + L?: Array; + M?: { [id: string]: AttributeValue }; + N?: number; + NS?: Array; + NULL?: boolean; + S?: string; + SS?: Array; } // Context // http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html interface StreamRecord { - ApproximateCreationTime?: number; - Keys?: { [key: string]: AttributeValue }; - NewImage?: { [key: string]: AttributeValue }; - OldImage?: { [key: string]: AttributeValue }; - SequenceNumber?: string; - SizeBytes?: number; - StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES'; + ApproximateCreationTime?: number; + Keys?: { [key: string]: AttributeValue }; + NewImage?: { [key: string]: AttributeValue }; + OldImage?: { [key: string]: AttributeValue }; + SequenceNumber?: string; + SizeBytes?: number; + StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES'; } // Context // http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html interface DynamoDBRecord { - awsRegion?: string; - dynamodb?: StreamRecord; - eventID?: string; - eventName?: 'INSERT' | 'MODIFY' | 'REMOVE'; - eventSource?: string; - eventSourceARN?: string; - eventVersion?: string; - userIdentity?: any; + awsRegion?: string; + dynamodb?: StreamRecord; + eventID?: string; + eventName?: 'INSERT' | 'MODIFY' | 'REMOVE'; + eventSource?: string; + eventSourceARN?: string; + eventVersion?: string; + userIdentity?: any; } // AWS Lambda Stream event // Context // http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update interface DynamoDBStreamEvent { - Records: Array; + Records: Array; } - // SNS "event" interface SNSMessageAttribute { Type: string; From 3e3034e6b1a6ed615e5cd6a2dd26b94a760c25ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20=C3=85hlin?= Date: Fri, 27 Oct 2017 12:14:51 +0200 Subject: [PATCH 020/639] Add missing methods --- types/jquery.bootstrap.wizard/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/jquery.bootstrap.wizard/index.d.ts b/types/jquery.bootstrap.wizard/index.d.ts index 465d7cd095..c95629a542 100644 --- a/types/jquery.bootstrap.wizard/index.d.ts +++ b/types/jquery.bootstrap.wizard/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for twitter-bootstrap-wizard // Project: https://github.com/VinceG/twitter-bootstrap-wizard // Definitions by: Blake Niemyjski +// Dennis Åhlin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -42,6 +43,10 @@ interface Wizard { interface JQuery { bootstrapWizard(options?: WizardOptions): Wizard; + bootstrapWizard(method: 'next' | 'previous' | 'first' | 'last' | 'back' | 'finish' | 'finish' | 'currentIndex' | 'navigationLength'): void; + bootstrapWizard(method: 'show', indexOrId: number | string): void; + bootstrapWizard(method: 'enable' | 'disable' | 'display' | 'hide', index: number): void; + bootstrapWizard(method: 'remove', index: number, removeTabPane?: boolean): void; } interface JQueryStatic { From fb6cfdd071fb370f5d831e669c8f4fb6f630e8c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20=C3=85hlin?= Date: Fri, 27 Oct 2017 13:39:39 +0200 Subject: [PATCH 021/639] Fix return types of currentIndex and navigationLength --- types/jquery.bootstrap.wizard/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/jquery.bootstrap.wizard/index.d.ts b/types/jquery.bootstrap.wizard/index.d.ts index c95629a542..99a494b63e 100644 --- a/types/jquery.bootstrap.wizard/index.d.ts +++ b/types/jquery.bootstrap.wizard/index.d.ts @@ -43,7 +43,8 @@ interface Wizard { interface JQuery { bootstrapWizard(options?: WizardOptions): Wizard; - bootstrapWizard(method: 'next' | 'previous' | 'first' | 'last' | 'back' | 'finish' | 'finish' | 'currentIndex' | 'navigationLength'): void; + bootstrapWizard(method: 'next' | 'previous' | 'first' | 'last' | 'back' | 'finish'): void; + bootstrapWizard(method: 'currentIndex' | 'navigationLength'): number; bootstrapWizard(method: 'show', indexOrId: number | string): void; bootstrapWizard(method: 'enable' | 'disable' | 'display' | 'hide', index: number): void; bootstrapWizard(method: 'remove', index: number, removeTabPane?: boolean): void; From 5c99b2921a2e024aa61bcbbb14bdcf8c6800f3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20=C3=85hlin?= Date: Fri, 27 Oct 2017 13:47:19 +0200 Subject: [PATCH 022/639] Move WizardOptions last --- types/jquery.bootstrap.wizard/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery.bootstrap.wizard/index.d.ts b/types/jquery.bootstrap.wizard/index.d.ts index 99a494b63e..a84c9ca4c4 100644 --- a/types/jquery.bootstrap.wizard/index.d.ts +++ b/types/jquery.bootstrap.wizard/index.d.ts @@ -42,12 +42,12 @@ interface Wizard { } interface JQuery { - bootstrapWizard(options?: WizardOptions): Wizard; bootstrapWizard(method: 'next' | 'previous' | 'first' | 'last' | 'back' | 'finish'): void; bootstrapWizard(method: 'currentIndex' | 'navigationLength'): number; bootstrapWizard(method: 'show', indexOrId: number | string): void; bootstrapWizard(method: 'enable' | 'disable' | 'display' | 'hide', index: number): void; bootstrapWizard(method: 'remove', index: number, removeTabPane?: boolean): void; + bootstrapWizard(options?: WizardOptions): Wizard; } interface JQueryStatic { From 9cc1b19ab0ff0c5c06f9af38b9f6fdabc5e38429 Mon Sep 17 00:00:00 2001 From: "U-SWRI16\\svogel" Date: Fri, 27 Oct 2017 19:38:55 -0500 Subject: [PATCH 023/639] Adding props export to all elements. --- types/reactstrap/index.d.ts | 152 +++++++++--------- types/reactstrap/lib/Alert.d.ts | 7 +- types/reactstrap/lib/Badge.d.ts | 5 +- types/reactstrap/lib/Breadcrumb.d.ts | 5 +- types/reactstrap/lib/BreadcrumbItem.d.ts | 6 +- types/reactstrap/lib/Button.d.ts | 5 +- types/reactstrap/lib/ButtonDropdown.d.ts | 12 +- types/reactstrap/lib/ButtonGroup.d.ts | 5 +- types/reactstrap/lib/ButtonToolbar.d.ts | 5 +- types/reactstrap/lib/Card.d.ts | 6 +- types/reactstrap/lib/CardBlock.d.ts | 6 +- types/reactstrap/lib/CardBody.d.ts | 5 +- types/reactstrap/lib/CardColumns.d.ts | 5 +- types/reactstrap/lib/CardDeck.d.ts | 5 +- types/reactstrap/lib/CardFooter.d.ts | 5 +- types/reactstrap/lib/CardGroup.d.ts | 5 +- types/reactstrap/lib/CardHeader.d.ts | 5 +- types/reactstrap/lib/CardImg.d.ts | 5 +- types/reactstrap/lib/CardImgOverlay.d.ts | 5 +- types/reactstrap/lib/CardLink.d.ts | 5 +- types/reactstrap/lib/CardSubtitle.d.ts | 5 +- types/reactstrap/lib/CardText.d.ts | 5 +- types/reactstrap/lib/CardTitle.d.ts | 5 +- types/reactstrap/lib/Col.d.ts | 5 +- types/reactstrap/lib/Collapse.d.ts | 5 +- types/reactstrap/lib/Container.d.ts | 5 +- types/reactstrap/lib/Dropdown.d.ts | 7 +- types/reactstrap/lib/DropdownItem.d.ts | 5 +- types/reactstrap/lib/DropdownMenu.d.ts | 5 +- types/reactstrap/lib/DropdownToggle.d.ts | 5 +- types/reactstrap/lib/Fade.d.ts | 5 +- types/reactstrap/lib/Form.d.ts | 5 +- types/reactstrap/lib/FormFeedback.d.ts | 5 +- types/reactstrap/lib/FormGroup.d.ts | 5 +- types/reactstrap/lib/FormText.d.ts | 5 +- types/reactstrap/lib/Input.d.ts | 5 +- types/reactstrap/lib/InputGroup.d.ts | 5 +- types/reactstrap/lib/InputGroupAddon.d.ts | 5 +- types/reactstrap/lib/InputGroupButton.d.ts | 5 +- types/reactstrap/lib/Jumbotron.d.ts | 5 +- types/reactstrap/lib/Label.d.ts | 5 +- types/reactstrap/lib/ListGroup.d.ts | 5 +- types/reactstrap/lib/ListGroupItem.d.ts | 7 +- .../reactstrap/lib/ListGroupItemHeading.d.ts | 5 +- types/reactstrap/lib/ListGroupItemText.d.ts | 5 +- types/reactstrap/lib/Media.d.ts | 5 +- types/reactstrap/lib/Modal.d.ts | 5 +- types/reactstrap/lib/ModalBody.d.ts | 5 +- types/reactstrap/lib/ModalFooter.d.ts | 5 +- types/reactstrap/lib/ModalHeader.d.ts | 5 +- types/reactstrap/lib/Nav.d.ts | 5 +- types/reactstrap/lib/NavDropdown.d.ts | 12 +- types/reactstrap/lib/NavItem.d.ts | 5 +- types/reactstrap/lib/NavLink.d.ts | 5 +- types/reactstrap/lib/Navbar.d.ts | 5 +- types/reactstrap/lib/NavbarBrand.d.ts | 5 +- types/reactstrap/lib/NavbarToggler.d.ts | 5 +- types/reactstrap/lib/Pagination.d.ts | 5 +- types/reactstrap/lib/PaginationItem.d.ts | 5 +- types/reactstrap/lib/PaginationLink.d.ts | 5 +- types/reactstrap/lib/Popover.d.ts | 5 +- types/reactstrap/lib/PopoverContent.d.ts | 5 +- types/reactstrap/lib/PopoverTitle.d.ts | 5 +- types/reactstrap/lib/Progress.d.ts | 5 +- types/reactstrap/lib/Row.d.ts | 5 +- types/reactstrap/lib/TabContent.d.ts | 5 +- types/reactstrap/lib/TabPane.d.ts | 5 +- types/reactstrap/lib/Table.d.ts | 5 +- types/reactstrap/lib/Tag.d.ts | 5 +- types/reactstrap/lib/TetherContent.d.ts | 5 +- types/reactstrap/lib/Tooltip.d.ts | 9 +- types/reactstrap/lib/Uncontrolled.d.ts | 42 ++--- 72 files changed, 238 insertions(+), 333 deletions(-) diff --git a/types/reactstrap/index.d.ts b/types/reactstrap/index.d.ts index 81d4cec5bd..f653585c8f 100644 --- a/types/reactstrap/index.d.ts +++ b/types/reactstrap/index.d.ts @@ -8,80 +8,78 @@ export interface CSSModule { [className: string]: string; } -export { default as Alert } from './lib/Alert'; -export { default as Badge } from './lib/Badge'; -export { default as Breadcrumb } from './lib/Breadcrumb'; -export { default as BreadcrumbItem } from './lib/BreadcrumbItem'; -export { default as Button } from './lib/Button'; -export { default as ButtonDropdown } from './lib/ButtonDropdown'; -export { default as ButtonGroup } from './lib/ButtonGroup'; -export { default as ButtonToolbar } from './lib/ButtonToolbar'; -export { default as Card } from './lib/Card'; -export { default as CardBody } from './lib/CardBody'; -export { default as CardBlock } from './lib/CardBlock'; -export { default as CardColumns } from './lib/CardColumns'; -export { default as CardDeck } from './lib/CardDeck'; -export { default as CardFooter } from './lib/CardFooter'; -export { default as CardGroup } from './lib/CardGroup'; -export { default as CardHeader } from './lib/CardHeader'; -export { default as CardImg } from './lib/CardImg'; -export { default as CardImgOverlay } from './lib/CardImgOverlay'; -export { default as CardLink } from './lib/CardLink'; -export { default as CardSubtitle } from './lib/CardSubtitle'; -export { default as CardText } from './lib/CardText'; -export { default as CardTitle } from './lib/CardTitle'; -export { default as Col } from './lib/Col'; -export { default as Collapse } from './lib/Collapse'; -export { default as Container } from './lib/Container'; -export { default as Dropdown } from './lib/Dropdown'; -export { default as DropdownItem } from './lib/DropdownItem'; -export { default as DropdownMenu } from './lib/DropdownMenu'; -export { default as DropdownToggle } from './lib/DropdownToggle'; -export { default as Fade } from './lib/Fade'; -export { default as Form } from './lib/Form'; -export { default as FormFeedback } from './lib/FormFeedback'; -export { default as FormGroup } from './lib/FormGroup'; -export { default as FormText } from './lib/FormText'; -export { default as Input } from './lib/Input'; -export { default as InputGroup } from './lib/InputGroup'; -export { default as InputGroupAddon } from './lib/InputGroupAddon'; -export { default as InputGroupButton } from './lib/InputGroupButton'; -export { default as Jumbotron } from './lib/Jumbotron'; -export { default as Label } from './lib/Label'; -export { default as ListGroup } from './lib/ListGroup'; -export { default as ListGroupItem } from './lib/ListGroupItem'; -export { default as ListGroupItemHeading } from './lib/ListGroupItemHeading'; -export { default as ListGroupItemText } from './lib/ListGroupItemText'; -export { default as Media } from './lib/Media'; -export { default as Modal } from './lib/Modal'; -export { default as ModalBody } from './lib/ModalBody'; -export { default as ModalFooter } from './lib/ModalFooter'; -export { default as ModalHeader } from './lib/ModalHeader'; -export { default as Nav } from './lib/Nav'; -export { default as Navbar } from './lib/Navbar'; -export { default as NavbarBrand } from './lib/NavbarBrand'; -export { default as NavbarToggler } from './lib/NavbarToggler'; -export { default as NavDropdown } from './lib/NavDropdown'; -export { default as NavItem } from './lib/NavItem'; -export { default as NavLink } from './lib/NavLink'; -export { default as Pagination } from './lib/Pagination'; -export { default as PaginationItem } from './lib/PaginationItem'; -export { default as PaginationLink } from './lib/PaginationLink'; -export { default as Popover } from './lib/Popover'; -export { default as PopoverContent } from './lib/PopoverContent'; -export { default as PopoverTitle } from './lib/PopoverTitle'; -export { default as Progress } from './lib/Progress'; -export { default as Row } from './lib/Row'; -export { default as TabContent } from './lib/TabContent'; -export { default as Table } from './lib/Table'; -export { default as TabPane } from './lib/TabPane'; -export { default as Tag } from './lib/Tag'; -export { default as TetherContent } from './lib/TetherContent'; -export { default as Tooltip } from './lib/Tooltip'; -export { - UncontrolledAlert, - UncontrolledButtonDropdown, - UncontrolledDropdown, - UncontrolledNavDropdown, - UncontrolledTooltip -} from './lib/Uncontrolled'; +export { Alert, AlertProps } from './lib/Alert'; +export { Badge, BadgeProps } from './lib/Badge'; +export { Breadcrumb, BreadcrumbProps } from './lib/Breadcrumb'; +export { BreadcrumbItem, BreadcrumbItemProps } from './lib/BreadcrumbItem'; +export { Button, ButtonProps } from './lib/Button'; +export { ButtonDropdown, ButtonDropdownProps } from './lib/ButtonDropdown'; +export { ButtonGroup, ButtonGroupProps } from './lib/ButtonGroup'; +export { ButtonToolbar, ButtonToolbarProps } from './lib/ButtonToolbar'; +export { Card, CardProps } from './lib/Card'; +export { CardBody, CardBodyProps } from './lib/CardBody'; +export { CardBlock, CardBlockProps } from './lib/CardBlock'; +export { CardColumns, CardColumnsProps } from './lib/CardColumns'; +export { CardDeck, CardDeckProps } from './lib/CardDeck'; +export { CardFooter, CardFooterProps } from './lib/CardFooter'; +export { CardGroup, CardGroupProps } from './lib/CardGroup'; +export { CardHeader, CardHeaderProps } from './lib/CardHeader'; +export { CardImg, CardImgProps } from './lib/CardImg'; +export { CardImgOverlay, CardImgOverlayProps } from './lib/CardImgOverlay'; +export { CardLink, CardLinkProps } from './lib/CardLink'; +export { CardSubtitle, CardSubtitleProps } from './lib/CardSubtitle'; +export { CardText, CardTextProps } from './lib/CardText'; +export { CardTitle, CardTitleProps } from './lib/CardTitle'; +export { Col, ColProps } from './lib/Col'; +export { Collapse, CollapseProps } from './lib/Collapse'; +export { Container, ContainerProps } from './lib/Container'; +export { Dropdown, DropdownProps } from './lib/Dropdown'; +export { DropdownItem, DropdownItemProps } from './lib/DropdownItem'; +export { DropdownMenu, DropdownMenuProps } from './lib/DropdownMenu'; +export { DropdownToggle, DropdownToggleProps } from './lib/DropdownToggle'; +export { Fade, FadeProps } from './lib/Fade'; +export { Form, FormProps } from './lib/Form'; +export { FormFeedback, FormFeedbackProps } from './lib/FormFeedback'; +export { FormGroup, FormGroupProps } from './lib/FormGroup'; +export { FormText, FormTextProps } from './lib/FormText'; +export { Input, InputProps } from './lib/Input'; +export { InputGroup, InputGroupProps } from './lib/InputGroup'; +export { InputGroupAddon, InputGroupAddonProps } from './lib/InputGroupAddon'; +export { InputGroupButton, InputGroupButtonProps } from './lib/InputGroupButton'; +export { Jumbotron, JumbotronProps } from './lib/Jumbotron'; +export { Label, LabelProps } from './lib/Label'; +export { ListGroup, ListGroupProps } from './lib/ListGroup'; +export { ListGroupItem, ListGroupItemProps } from './lib/ListGroupItem'; +export { ListGroupItemHeading, ListGroupItemHeadingProps } from './lib/ListGroupItemHeading'; +export { ListGroupItemText, ListGroupItemTextProps } from './lib/ListGroupItemText'; +export { Media, MediaProps } from './lib/Media'; +export { Modal, ModalProps } from './lib/Modal'; +export { ModalBody, ModalBodyProps } from './lib/ModalBody'; +export { ModalFooter, ModalFooterProps } from './lib/ModalFooter'; +export { ModalHeader, ModalHeaderProps } from './lib/ModalHeader'; +export { Nav, NavProps } from './lib/Nav'; +export { Navbar, NavbarProps } from './lib/Navbar'; +export { NavbarBrand, NavbarBrandProps } from './lib/NavbarBrand'; +export { NavbarToggler, NavbarTogglerProps } from './lib/NavbarToggler'; +export { NavDropdown, NavDropdownProps } from './lib/NavDropdown'; +export { NavItem, NavItemProps } from './lib/NavItem'; +export { NavLink, NavLinkProps } from './lib/NavLink'; +export { Pagination, PaginationProps } from './lib/Pagination'; +export { PaginationItem, PaginationItemProps } from './lib/PaginationItem'; +export { PaginationLink, PaginationLinkProps } from './lib/PaginationLink'; +export { Popover, PopoverProps } from './lib/Popover'; +export { PopoverContent, PopoverContentProps } from './lib/PopoverContent'; +export { PopoverTitle, PopoverTitleProps } from './lib/PopoverTitle'; +export { Progress, ProgressProps } from './lib/Progress'; +export { Row, RowProps } from './lib/Row'; +export { TabContent, TabContentProps } from './lib/TabContent'; +export { Table, TableProps } from './lib/Table'; +export { TabPane, TabPaneProps } from './lib/TabPane'; +export { Tag, TagProps } from './lib/Tag'; +export { TetherContent, TetherContentProps } from './lib/TetherContent'; +export { Tooltip, TooltipProps } from './lib/Tooltip'; +export { UncontrolledAlert, UncontrolledAlertProps } from './lib/Uncontrolled'; +export { UncontrolledButtonDropdown, UncontrolledButtonDropdownProps } from './lib/Uncontrolled'; +export { UncontrolledDropdown, UncontrolledDropdownProps } from './lib/Uncontrolled'; +export { UncontrolledNavDropdown, UncontrolledNavDropdownProps } from './lib/Uncontrolled'; +export { UncontrolledTooltip, UncontrolledTooltipProps } from './lib/Uncontrolled'; diff --git a/types/reactstrap/lib/Alert.d.ts b/types/reactstrap/lib/Alert.d.ts index e29d62cb0d..1b4f6eb884 100644 --- a/types/reactstrap/lib/Alert.d.ts +++ b/types/reactstrap/lib/Alert.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -export interface UncontrolledProps { +export interface UncontrolledAlertProps { className?: string; cssModule?: CSSModule; color?: string; @@ -10,10 +10,9 @@ export interface UncontrolledProps { transitionLeaveTimeout?: number; } -interface Props extends UncontrolledProps { +export interface AlertProps extends UncontrolledAlertProps { isOpen?: boolean; toggle?: () => void; } -declare var Alert: React.StatelessComponent; -export default Alert; +export const Alert: React.StatelessComponent; diff --git a/types/reactstrap/lib/Badge.d.ts b/types/reactstrap/lib/Badge.d.ts index 51f72e39d3..4c21dcac42 100644 --- a/types/reactstrap/lib/Badge.d.ts +++ b/types/reactstrap/lib/Badge.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface BadgeProps { color?: string; pill?: boolean; tag?: React.ReactType; @@ -8,5 +8,4 @@ interface Props { cssModule?: CSSModule; } -declare var Badge: React.StatelessComponent; -export default Badge; +export const Badge: React.StatelessComponent; diff --git a/types/reactstrap/lib/Breadcrumb.d.ts b/types/reactstrap/lib/Breadcrumb.d.ts index 54f581288c..26839e9140 100644 --- a/types/reactstrap/lib/Breadcrumb.d.ts +++ b/types/reactstrap/lib/Breadcrumb.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface BreadcrumbProps { tag?: string; className?: string; cssModule?: CSSModule; } -declare var Breadcrumb: React.StatelessComponent; -export default Breadcrumb; +export const Breadcrumb: React.StatelessComponent; diff --git a/types/reactstrap/lib/BreadcrumbItem.d.ts b/types/reactstrap/lib/BreadcrumbItem.d.ts index 0277305b21..d8deed883a 100644 --- a/types/reactstrap/lib/BreadcrumbItem.d.ts +++ b/types/reactstrap/lib/BreadcrumbItem.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface BreadcrumbItemProps { tag?: React.ReactType; active?: boolean; className?: string; @@ -10,6 +10,4 @@ interface Props { [others: string]: any; } -declare var BreadcrumbItem: React.StatelessComponent; -export default BreadcrumbItem; - +export const BreadcrumbItem: React.StatelessComponent; diff --git a/types/reactstrap/lib/Button.d.ts b/types/reactstrap/lib/Button.d.ts index e6ec222c14..e75c6f0b1c 100644 --- a/types/reactstrap/lib/Button.d.ts +++ b/types/reactstrap/lib/Button.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface ButtonProps extends React.HTMLProps { outline?: boolean; active?: boolean; block?: boolean; @@ -17,5 +17,4 @@ interface Props extends React.HTMLProps { cssModule?: CSSModule; } -declare var Button: React.StatelessComponent; -export default Button; +export const Button: React.StatelessComponent; diff --git a/types/reactstrap/lib/ButtonDropdown.d.ts b/types/reactstrap/lib/ButtonDropdown.d.ts index 9ab54c7502..bb26a03685 100644 --- a/types/reactstrap/lib/ButtonDropdown.d.ts +++ b/types/reactstrap/lib/ButtonDropdown.d.ts @@ -1,12 +1,8 @@ -import { - UncontrolledProps as DropdownUncontrolledProps, - Props as DropdownProps -} from './Dropdown'; +import { UncontrolledDropdownProps, DropdownProps } from './Dropdown'; // tslint:disable-next-line -export interface UncontrolledProps extends DropdownUncontrolledProps { } +export interface UncontrolledButtonDropdownProps extends UncontrolledDropdownProps { } // tslint:disable-next-line -interface Props extends DropdownProps { } +export interface ButtonDropdownProps extends DropdownProps { } -declare var ButtonDropdown: React.StatelessComponent; -export default ButtonDropdown; \ No newline at end of file +export const ButtonDropdown: React.StatelessComponent; diff --git a/types/reactstrap/lib/ButtonGroup.d.ts b/types/reactstrap/lib/ButtonGroup.d.ts index d807ea33cf..033c3075f9 100644 --- a/types/reactstrap/lib/ButtonGroup.d.ts +++ b/types/reactstrap/lib/ButtonGroup.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface ButtonGroupProps { tag?: React.ReactType; 'aria-label'?: string; className?: string; @@ -10,5 +10,4 @@ interface Props { vertical?: boolean; } -declare var ButtonGroup: React.StatelessComponent; -export default ButtonGroup; +export const ButtonGroup: React.StatelessComponent; diff --git a/types/reactstrap/lib/ButtonToolbar.d.ts b/types/reactstrap/lib/ButtonToolbar.d.ts index fea31dd5d5..3e16b331c3 100644 --- a/types/reactstrap/lib/ButtonToolbar.d.ts +++ b/types/reactstrap/lib/ButtonToolbar.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface ButtonToolbarProps { tag?: React.ReactType; 'aria-label'?: string; className?: string; @@ -8,5 +8,4 @@ interface Props { role?: string; } -declare var ButtonToolbar: React.StatelessComponent; -export default ButtonToolbar; +export const ButtonToolbar: React.StatelessComponent; diff --git a/types/reactstrap/lib/Card.d.ts b/types/reactstrap/lib/Card.d.ts index 0dbde7f879..f6d0d5e265 100644 --- a/types/reactstrap/lib/Card.d.ts +++ b/types/reactstrap/lib/Card.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardProps { tag?: React.ReactType; inverse?: boolean; color?: string; @@ -11,6 +11,4 @@ interface Props { style?: React.CSSProperties; } -declare var Card: React.StatelessComponent; -export default Card; - +export const Card: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardBlock.d.ts b/types/reactstrap/lib/CardBlock.d.ts index 0aa31a63a7..905884b786 100644 --- a/types/reactstrap/lib/CardBlock.d.ts +++ b/types/reactstrap/lib/CardBlock.d.ts @@ -1,11 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardBlockProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardBlock: React.StatelessComponent; -export default CardBlock; - +export const CardBlock: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardBody.d.ts b/types/reactstrap/lib/CardBody.d.ts index 2b94e52ea8..eeb9c8fe8d 100644 --- a/types/reactstrap/lib/CardBody.d.ts +++ b/types/reactstrap/lib/CardBody.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardBodyProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardBody: React.StatelessComponent; -export default CardBody; +export const CardBody: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardColumns.d.ts b/types/reactstrap/lib/CardColumns.d.ts index 0cc1a80a1a..e1d00fa389 100644 --- a/types/reactstrap/lib/CardColumns.d.ts +++ b/types/reactstrap/lib/CardColumns.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardColumnsProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardColumns: React.StatelessComponent; -export default CardColumns; +export const CardColumns: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardDeck.d.ts b/types/reactstrap/lib/CardDeck.d.ts index 1a5882aa54..15b3660f9d 100644 --- a/types/reactstrap/lib/CardDeck.d.ts +++ b/types/reactstrap/lib/CardDeck.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardDeckProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardDeck: React.StatelessComponent; -export default CardDeck; +export const CardDeck: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardFooter.d.ts b/types/reactstrap/lib/CardFooter.d.ts index 0956cb06c9..2b320c48b5 100644 --- a/types/reactstrap/lib/CardFooter.d.ts +++ b/types/reactstrap/lib/CardFooter.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardFooterProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardFooter: React.StatelessComponent; -export default CardFooter; +export const CardFooter: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardGroup.d.ts b/types/reactstrap/lib/CardGroup.d.ts index 5c0a0a1ab1..93fdd04bb0 100644 --- a/types/reactstrap/lib/CardGroup.d.ts +++ b/types/reactstrap/lib/CardGroup.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardGroupProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardGroup: React.StatelessComponent; -export default CardGroup; +export const CardGroup: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardHeader.d.ts b/types/reactstrap/lib/CardHeader.d.ts index f063057c92..d9d942c3d8 100644 --- a/types/reactstrap/lib/CardHeader.d.ts +++ b/types/reactstrap/lib/CardHeader.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardHeaderProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardHeader: React.StatelessComponent; -export default CardHeader; +export const CardHeader: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardImg.d.ts b/types/reactstrap/lib/CardImg.d.ts index 1c3fee274b..dd479691b5 100644 --- a/types/reactstrap/lib/CardImg.d.ts +++ b/types/reactstrap/lib/CardImg.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardImgProps { tag?: React.ReactType; top?: boolean; bottom?: boolean; @@ -12,5 +12,4 @@ interface Props { alt?: string; } -declare var CardImg: React.StatelessComponent; -export default CardImg; +export const CardImg: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardImgOverlay.d.ts b/types/reactstrap/lib/CardImgOverlay.d.ts index 05519847b2..22333a55c2 100644 --- a/types/reactstrap/lib/CardImgOverlay.d.ts +++ b/types/reactstrap/lib/CardImgOverlay.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardImgOverlayProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardImgOverlay: React.StatelessComponent; -export default CardImgOverlay; +export const CardImgOverlay: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardLink.d.ts b/types/reactstrap/lib/CardLink.d.ts index 3edf6b24f8..9afc204f96 100644 --- a/types/reactstrap/lib/CardLink.d.ts +++ b/types/reactstrap/lib/CardLink.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardLinkProps { tag?: React.ReactType; getRef?: string | ((instance: HTMLButtonElement) => any); className?: string; @@ -8,5 +8,4 @@ interface Props { href?: string; } -declare var CardLink: React.StatelessComponent; -export default CardLink; +export const CardLink: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardSubtitle.d.ts b/types/reactstrap/lib/CardSubtitle.d.ts index bfacd4e794..36e847367c 100644 --- a/types/reactstrap/lib/CardSubtitle.d.ts +++ b/types/reactstrap/lib/CardSubtitle.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardSubtitleProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardSubtitle: React.StatelessComponent; -export default CardSubtitle; +export const CardSubtitle: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardText.d.ts b/types/reactstrap/lib/CardText.d.ts index 13177fba67..297a561d50 100644 --- a/types/reactstrap/lib/CardText.d.ts +++ b/types/reactstrap/lib/CardText.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardTextProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardText: React.StatelessComponent; -export default CardText; +export const CardText: React.StatelessComponent; diff --git a/types/reactstrap/lib/CardTitle.d.ts b/types/reactstrap/lib/CardTitle.d.ts index 2843800a4e..52b9556945 100644 --- a/types/reactstrap/lib/CardTitle.d.ts +++ b/types/reactstrap/lib/CardTitle.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface CardTitleProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var CardTitle: React.StatelessComponent; -export default CardTitle; +export const CardTitle: React.StatelessComponent; diff --git a/types/reactstrap/lib/Col.d.ts b/types/reactstrap/lib/Col.d.ts index a2ea76d607..cf2fd098fa 100644 --- a/types/reactstrap/lib/Col.d.ts +++ b/types/reactstrap/lib/Col.d.ts @@ -9,7 +9,7 @@ export type ColumnProps offset?: string | number }; -interface Props extends React.HTMLProps { +export interface ColProps extends React.HTMLProps { xs?: ColumnProps; sm?: ColumnProps; md?: ColumnProps; @@ -20,5 +20,4 @@ interface Props extends React.HTMLProps { widths?: string[]; } -declare var Col: React.StatelessComponent; -export default Col; +export const Col: React.StatelessComponent; diff --git a/types/reactstrap/lib/Collapse.d.ts b/types/reactstrap/lib/Collapse.d.ts index 50160bbcf6..5647bf68b3 100644 --- a/types/reactstrap/lib/Collapse.d.ts +++ b/types/reactstrap/lib/Collapse.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface CollapseProps extends React.HTMLProps { isOpen?: boolean; classNames?: string; cssModule?: CSSModule; @@ -14,5 +14,4 @@ interface Props extends React.HTMLProps { onClosed?: () => void; } -declare var Collapse: React.StatelessComponent; -export default Collapse; +export const Collapse: React.StatelessComponent; diff --git a/types/reactstrap/lib/Container.d.ts b/types/reactstrap/lib/Container.d.ts index f49951ba26..08d702af4b 100644 --- a/types/reactstrap/lib/Container.d.ts +++ b/types/reactstrap/lib/Container.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface ContainerProps { tag?: React.ReactType; fluid?: boolean; className?: string; cssModule?: CSSModule; } -declare var Container: React.StatelessComponent; -export default Container; +export const Container: React.StatelessComponent; diff --git a/types/reactstrap/lib/Dropdown.d.ts b/types/reactstrap/lib/Dropdown.d.ts index 19d1500cbe..fce1de08b1 100644 --- a/types/reactstrap/lib/Dropdown.d.ts +++ b/types/reactstrap/lib/Dropdown.d.ts @@ -2,14 +2,14 @@ import { CSSModule } from '../index'; -export interface UncontrolledProps { +export interface UncontrolledDropdownProps { isOpen?: boolean; toggle?: () => void; className?: string; cssModule?: CSSModule; } -export interface Props extends UncontrolledProps { +export interface DropdownProps extends UncontrolledDropdownProps { disabled?: boolean; dropup?: boolean; group?: boolean; @@ -18,5 +18,4 @@ export interface Props extends UncontrolledProps { tether?: boolean | Tether.ITetherOptions; } -declare var Dropdown: React.StatelessComponent; -export default Dropdown; +export const Dropdown: React.StatelessComponent; diff --git a/types/reactstrap/lib/DropdownItem.d.ts b/types/reactstrap/lib/DropdownItem.d.ts index 6fae837041..fe9a33cf8e 100644 --- a/types/reactstrap/lib/DropdownItem.d.ts +++ b/types/reactstrap/lib/DropdownItem.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface DropdownItemProps { disabled?: boolean; divider?: boolean; tag?: React.ReactType; @@ -11,5 +11,4 @@ interface Props { href?: string; } -declare var DropdownItem: React.StatelessComponent; -export default DropdownItem; +export const DropdownItem: React.StatelessComponent; diff --git a/types/reactstrap/lib/DropdownMenu.d.ts b/types/reactstrap/lib/DropdownMenu.d.ts index 7fae41b04b..e206ebd6d9 100644 --- a/types/reactstrap/lib/DropdownMenu.d.ts +++ b/types/reactstrap/lib/DropdownMenu.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface DropdownMenuProps { tag?: React.ReactType; right?: boolean; className?: string; cssModule?: CSSModule; } -declare var DropdownMenu: React.StatelessComponent; -export default DropdownMenu; +export const DropdownMenu: React.StatelessComponent; diff --git a/types/reactstrap/lib/DropdownToggle.d.ts b/types/reactstrap/lib/DropdownToggle.d.ts index 5ef49db71f..df1cb7f845 100644 --- a/types/reactstrap/lib/DropdownToggle.d.ts +++ b/types/reactstrap/lib/DropdownToggle.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface DropdownToggleProps { caret?: boolean; className?: string; cssModule?: CSSModule; @@ -15,5 +15,4 @@ interface Props { size?: string; } -declare var DropdownToggle: React.StatelessComponent; -export default DropdownToggle; +export const DropdownToggle: React.StatelessComponent; diff --git a/types/reactstrap/lib/Fade.d.ts b/types/reactstrap/lib/Fade.d.ts index 30862d2e17..2c13430af9 100644 --- a/types/reactstrap/lib/Fade.d.ts +++ b/types/reactstrap/lib/Fade.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface FadeProps { baseClass?: string; baseClassIn?: string; tag?: React.ReactType; @@ -16,5 +16,4 @@ interface Props { onEnter?: () => void; } -declare var Fade: React.StatelessComponent; -export default Fade; +export const Fade: React.StatelessComponent; diff --git a/types/reactstrap/lib/Form.d.ts b/types/reactstrap/lib/Form.d.ts index dd06a2f855..4481bd8912 100644 --- a/types/reactstrap/lib/Form.d.ts +++ b/types/reactstrap/lib/Form.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface FormProps extends React.HTMLProps { inline?: boolean; tag?: React.ReactType; getRef?: string | ((instance: HTMLButtonElement) => any); @@ -8,5 +8,4 @@ interface Props extends React.HTMLProps { cssModule?: CSSModule; } -declare var Form: React.StatelessComponent; -export default Form; +export const Form: React.StatelessComponent; diff --git a/types/reactstrap/lib/FormFeedback.d.ts b/types/reactstrap/lib/FormFeedback.d.ts index 7fde21b062..ac6f0f5003 100644 --- a/types/reactstrap/lib/FormFeedback.d.ts +++ b/types/reactstrap/lib/FormFeedback.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface FormFeedbackProps { tag?: string; className?: string; cssModule?: CSSModule; } -declare var FormFeedback: React.StatelessComponent; -export default FormFeedback; +export const FormFeedback: React.StatelessComponent; diff --git a/types/reactstrap/lib/FormGroup.d.ts b/types/reactstrap/lib/FormGroup.d.ts index 6031ff2f75..65c0da639b 100644 --- a/types/reactstrap/lib/FormGroup.d.ts +++ b/types/reactstrap/lib/FormGroup.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface FormGroupProps extends React.HTMLProps { row?: boolean; check?: boolean; disabled?: boolean; @@ -10,5 +10,4 @@ interface Props extends React.HTMLProps { cssModule?: CSSModule; } -declare var FormGroup: React.StatelessComponent; -export default FormGroup; +export const FormGroup: React.StatelessComponent; diff --git a/types/reactstrap/lib/FormText.d.ts b/types/reactstrap/lib/FormText.d.ts index 3cfab3511e..c8af8f56c8 100644 --- a/types/reactstrap/lib/FormText.d.ts +++ b/types/reactstrap/lib/FormText.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface FormTextProps { inline?: boolean; tag?: React.ReactType; color?: string; @@ -8,5 +8,4 @@ interface Props { cssModule?: CSSModule; } -declare var FormText: React.StatelessComponent; -export default FormText; +export const FormText: React.StatelessComponent; diff --git a/types/reactstrap/lib/Input.d.ts b/types/reactstrap/lib/Input.d.ts index 541016ca02..0029367c90 100644 --- a/types/reactstrap/lib/Input.d.ts +++ b/types/reactstrap/lib/Input.d.ts @@ -33,7 +33,7 @@ interface Intermediate extends React.InputHTMLAttributes { size?: any; } -interface InputProps extends Intermediate { +export interface InputProps extends Intermediate { type?: InputType; size?: string; state?: string; @@ -48,5 +48,4 @@ interface InputProps extends Intermediate { // Maybe reactstrap will support an 'isStatic' alias in the future } -declare var Input: React.StatelessComponent; -export default Input; +export const Input: React.StatelessComponent; diff --git a/types/reactstrap/lib/InputGroup.d.ts b/types/reactstrap/lib/InputGroup.d.ts index 2de95edc94..abd7fcd381 100644 --- a/types/reactstrap/lib/InputGroup.d.ts +++ b/types/reactstrap/lib/InputGroup.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface InputGroupProps { tag?: React.ReactType; size?: string; className?: string; cssModule?: CSSModule; } -declare var InputGroup: React.StatelessComponent; -export default InputGroup; +export const InputGroup: React.StatelessComponent; diff --git a/types/reactstrap/lib/InputGroupAddon.d.ts b/types/reactstrap/lib/InputGroupAddon.d.ts index a98eb5d821..7ddbc3b4c1 100644 --- a/types/reactstrap/lib/InputGroupAddon.d.ts +++ b/types/reactstrap/lib/InputGroupAddon.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface InputGroupAddonProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var InputGroupAddon: React.StatelessComponent; -export default InputGroupAddon; +export const InputGroupAddon: React.StatelessComponent; diff --git a/types/reactstrap/lib/InputGroupButton.d.ts b/types/reactstrap/lib/InputGroupButton.d.ts index fa7cb1995a..90a93ff8ed 100644 --- a/types/reactstrap/lib/InputGroupButton.d.ts +++ b/types/reactstrap/lib/InputGroupButton.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface InputGroupButtonProps { tag?: React.ReactType; groupClassName?: string; groupAttributes?: any; @@ -9,5 +9,4 @@ interface Props { color?: string; } -declare var InputGroupButton: React.StatelessComponent; -export default InputGroupButton; +export const InputGroupButton: React.StatelessComponent; diff --git a/types/reactstrap/lib/Jumbotron.d.ts b/types/reactstrap/lib/Jumbotron.d.ts index cc1f65c956..4ade1eabaa 100644 --- a/types/reactstrap/lib/Jumbotron.d.ts +++ b/types/reactstrap/lib/Jumbotron.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface JumbotronProps { tag?: React.ReactType; fluid?: boolean; className?: string; cssModule?: CSSModule; } -declare var Jumbotron: React.StatelessComponent; -export default Jumbotron; +export const Jumbotron: React.StatelessComponent; diff --git a/types/reactstrap/lib/Label.d.ts b/types/reactstrap/lib/Label.d.ts index eb496d90a3..3688aaf233 100644 --- a/types/reactstrap/lib/Label.d.ts +++ b/types/reactstrap/lib/Label.d.ts @@ -5,7 +5,7 @@ interface Intermediate extends React.LabelHTMLAttributes { size?: any; } -interface Props extends Intermediate { +export interface LabelProps extends Intermediate { hidden?: boolean; check?: boolean; inline?: boolean; @@ -22,5 +22,4 @@ interface Props extends Intermediate { xl?: ColumnProps; } -declare var Label: React.StatelessComponent; -export default Label; +export const Label: React.StatelessComponent; diff --git a/types/reactstrap/lib/ListGroup.d.ts b/types/reactstrap/lib/ListGroup.d.ts index 861c7a1d06..bef63da796 100644 --- a/types/reactstrap/lib/ListGroup.d.ts +++ b/types/reactstrap/lib/ListGroup.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface ListGroupProps { tag?: React.ReactType; flush?: boolean; className?: string; cssModule?: CSSModule; } -declare var ListGroup: React.StatelessComponent; -export default ListGroup; +export const ListGroup: React.StatelessComponent; diff --git a/types/reactstrap/lib/ListGroupItem.d.ts b/types/reactstrap/lib/ListGroupItem.d.ts index b2241998dc..44a70b6ec4 100644 --- a/types/reactstrap/lib/ListGroupItem.d.ts +++ b/types/reactstrap/lib/ListGroupItem.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface ListGroupItemProps { tag?: React.ReactType; active?: boolean; disabled?: boolean; @@ -9,9 +9,8 @@ interface Props { className?: string; cssModule?: CSSModule; href?: string; - + onClick?: React.MouseEventHandler; } -declare var ListGroupItem: React.StatelessComponent; -export default ListGroupItem; +export const ListGroupItem: React.StatelessComponent; diff --git a/types/reactstrap/lib/ListGroupItemHeading.d.ts b/types/reactstrap/lib/ListGroupItemHeading.d.ts index 869a6b2708..f44317f541 100644 --- a/types/reactstrap/lib/ListGroupItemHeading.d.ts +++ b/types/reactstrap/lib/ListGroupItemHeading.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface ListGroupItemHeadingProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var ListGroupItemHeading: React.StatelessComponent; -export default ListGroupItemHeading; +export const ListGroupItemHeading: React.StatelessComponent; diff --git a/types/reactstrap/lib/ListGroupItemText.d.ts b/types/reactstrap/lib/ListGroupItemText.d.ts index df263f30d8..a19803e4fe 100644 --- a/types/reactstrap/lib/ListGroupItemText.d.ts +++ b/types/reactstrap/lib/ListGroupItemText.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface ListGroupItemTextProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var ListGroupItemText: React.StatelessComponent; -export default ListGroupItemText; +export const ListGroupItemText: React.StatelessComponent; diff --git a/types/reactstrap/lib/Media.d.ts b/types/reactstrap/lib/Media.d.ts index c5408d85d7..9276c0708f 100644 --- a/types/reactstrap/lib/Media.d.ts +++ b/types/reactstrap/lib/Media.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface MediaProps { body?: boolean; bottom?: boolean; className?: string; @@ -17,5 +17,4 @@ interface Props { alt?: string; } -declare var Media: React.StatelessComponent; -export default Media; +export const Media: React.StatelessComponent; diff --git a/types/reactstrap/lib/Modal.d.ts b/types/reactstrap/lib/Modal.d.ts index 1e239fbe12..eb7d2a0f15 100644 --- a/types/reactstrap/lib/Modal.d.ts +++ b/types/reactstrap/lib/Modal.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface ModalProps { isOpen?: boolean; autoFocus?: boolean; size?: string; @@ -19,5 +19,4 @@ interface Props { fade?: boolean; } -declare var Modal: React.StatelessComponent; -export default Modal; +export const Modal: React.StatelessComponent; diff --git a/types/reactstrap/lib/ModalBody.d.ts b/types/reactstrap/lib/ModalBody.d.ts index 98933b2fc2..1238f7d54a 100644 --- a/types/reactstrap/lib/ModalBody.d.ts +++ b/types/reactstrap/lib/ModalBody.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface ModalBodyProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var ModalBody: React.StatelessComponent; -export default ModalBody; +export const ModalBody: React.StatelessComponent; diff --git a/types/reactstrap/lib/ModalFooter.d.ts b/types/reactstrap/lib/ModalFooter.d.ts index 84b3da7ec8..d7cafe275b 100644 --- a/types/reactstrap/lib/ModalFooter.d.ts +++ b/types/reactstrap/lib/ModalFooter.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface ModalFooterProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var ModalFooter: React.StatelessComponent; -export default ModalFooter; +export const ModalFooter: React.StatelessComponent; diff --git a/types/reactstrap/lib/ModalHeader.d.ts b/types/reactstrap/lib/ModalHeader.d.ts index 494c9685a3..5792fea0d1 100644 --- a/types/reactstrap/lib/ModalHeader.d.ts +++ b/types/reactstrap/lib/ModalHeader.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface ModalHeaderProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; @@ -8,5 +8,4 @@ interface Props { toggle?: () => void; } -declare var ModalHeader: React.StatelessComponent; -export default ModalHeader; +export const ModalHeader: React.StatelessComponent; diff --git a/types/reactstrap/lib/Nav.d.ts b/types/reactstrap/lib/Nav.d.ts index c646e94304..e42556fadd 100644 --- a/types/reactstrap/lib/Nav.d.ts +++ b/types/reactstrap/lib/Nav.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface NavProps extends React.HTMLProps { inline?: boolean; disabled?: boolean; tabs?: boolean; @@ -13,5 +13,4 @@ interface Props extends React.HTMLProps { vertical?: boolean; } -declare var Nav: React.StatelessComponent; -export default Nav; +export const Nav: React.StatelessComponent; diff --git a/types/reactstrap/lib/NavDropdown.d.ts b/types/reactstrap/lib/NavDropdown.d.ts index 6b480d495a..dfa15afa17 100644 --- a/types/reactstrap/lib/NavDropdown.d.ts +++ b/types/reactstrap/lib/NavDropdown.d.ts @@ -1,12 +1,8 @@ -import { - UncontrolledProps as DropdownUncontrolledProps, - Props as DropdownProps -} from './Dropdown'; +import { UncontrolledDropdownProps, DropdownProps } from './Dropdown'; // tslint:disable-next-line -export interface UncontrolledProps extends DropdownUncontrolledProps { } +export interface UncontrolledNavDropdownProps extends UncontrolledDropdownProps { } // tslint:disable-next-line -interface Props extends DropdownProps { } +export interface NavDropdownProps extends DropdownProps { } -declare var NavDropdown: React.StatelessComponent; -export default NavDropdown; \ No newline at end of file +export const NavDropdown: React.StatelessComponent; diff --git a/types/reactstrap/lib/NavItem.d.ts b/types/reactstrap/lib/NavItem.d.ts index db19f92c56..8e6e7631d2 100644 --- a/types/reactstrap/lib/NavItem.d.ts +++ b/types/reactstrap/lib/NavItem.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface NavItemProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var NavItem: React.StatelessComponent; -export default NavItem; +export const NavItem: React.StatelessComponent; diff --git a/types/reactstrap/lib/NavLink.d.ts b/types/reactstrap/lib/NavLink.d.ts index 2871fad72e..13f5710551 100644 --- a/types/reactstrap/lib/NavLink.d.ts +++ b/types/reactstrap/lib/NavLink.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface NavLinkProps extends React.HTMLProps { tag?: React.ReactType; getRef?: string | ((instance: HTMLButtonElement) => any); disabled?: boolean; @@ -11,5 +11,4 @@ interface Props extends React.HTMLProps { href?: string; } -declare var NavLink: React.StatelessComponent; -export default NavLink; +export const NavLink: React.StatelessComponent; diff --git a/types/reactstrap/lib/Navbar.d.ts b/types/reactstrap/lib/Navbar.d.ts index 58f9235140..76616a7be2 100644 --- a/types/reactstrap/lib/Navbar.d.ts +++ b/types/reactstrap/lib/Navbar.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface NavbarProps { light?: boolean; dark?: boolean; inverse?: boolean; @@ -16,5 +16,4 @@ interface Props { expand?: boolean | string; } -declare var Navbar: React.StatelessComponent; -export default Navbar; +export const Navbar: React.StatelessComponent; diff --git a/types/reactstrap/lib/NavbarBrand.d.ts b/types/reactstrap/lib/NavbarBrand.d.ts index 3748a2903f..0aa80597b9 100644 --- a/types/reactstrap/lib/NavbarBrand.d.ts +++ b/types/reactstrap/lib/NavbarBrand.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface NavbarBrandProps extends React.HTMLProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var NavbarBrand: React.StatelessComponent; -export default NavbarBrand; +export const NavbarBrand: React.StatelessComponent; diff --git a/types/reactstrap/lib/NavbarToggler.d.ts b/types/reactstrap/lib/NavbarToggler.d.ts index 282eeaa672..5dd2df7057 100644 --- a/types/reactstrap/lib/NavbarToggler.d.ts +++ b/types/reactstrap/lib/NavbarToggler.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface NavbarTogglerProps extends React.HTMLProps { tag?: React.ReactType; type?: string; className?: string; @@ -9,5 +9,4 @@ interface Props extends React.HTMLProps { left?: boolean; } -declare var NavbarToggler: React.StatelessComponent; -export default NavbarToggler; +export const NavbarToggler: React.StatelessComponent; diff --git a/types/reactstrap/lib/Pagination.d.ts b/types/reactstrap/lib/Pagination.d.ts index a34401be35..3b19364c30 100644 --- a/types/reactstrap/lib/Pagination.d.ts +++ b/types/reactstrap/lib/Pagination.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface PaginationProps { className?: string; cssModule?: CSSModule; size?: string; } -declare var Pagination: React.StatelessComponent; -export default Pagination; +export const Pagination: React.StatelessComponent; diff --git a/types/reactstrap/lib/PaginationItem.d.ts b/types/reactstrap/lib/PaginationItem.d.ts index 183a7e9d84..3ed0400dcd 100644 --- a/types/reactstrap/lib/PaginationItem.d.ts +++ b/types/reactstrap/lib/PaginationItem.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface PaginationItemProps { className?: string; cssModule?: CSSModule; active?: boolean; @@ -8,5 +8,4 @@ interface Props { tag?: React.ReactType; } -declare var PaginationItem: React.StatelessComponent; -export default PaginationItem; +export const PaginationItem: React.StatelessComponent; diff --git a/types/reactstrap/lib/PaginationLink.d.ts b/types/reactstrap/lib/PaginationLink.d.ts index 16e194578d..5c2a1d5711 100644 --- a/types/reactstrap/lib/PaginationLink.d.ts +++ b/types/reactstrap/lib/PaginationLink.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps { +export interface PaginationLinkProps extends React.HTMLProps { 'aria-label'?: string; className?: string; cssModule?: CSSModule; @@ -9,5 +9,4 @@ interface Props extends React.HTMLProps { tag?: React.ReactType; } -declare var PaginationLink: React.StatelessComponent; -export default PaginationLink; +export const PaginationLink: React.StatelessComponent; diff --git a/types/reactstrap/lib/Popover.d.ts b/types/reactstrap/lib/Popover.d.ts index b779a33ede..69fe27cb88 100644 --- a/types/reactstrap/lib/Popover.d.ts +++ b/types/reactstrap/lib/Popover.d.ts @@ -20,7 +20,7 @@ type Placement | 'left middle' | 'left bottom'; -interface Props { +export interface PopoverProps { placement?: Placement; target: string; isOpen?: boolean; @@ -30,5 +30,4 @@ interface Props { toggle?: () => void; } -declare var Popover: React.StatelessComponent; -export default Popover; +export const Popover: React.StatelessComponent; diff --git a/types/reactstrap/lib/PopoverContent.d.ts b/types/reactstrap/lib/PopoverContent.d.ts index cac45d14cb..a062d4d2c9 100644 --- a/types/reactstrap/lib/PopoverContent.d.ts +++ b/types/reactstrap/lib/PopoverContent.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface PopoverContentProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var PopoverContent: React.StatelessComponent; -export default PopoverContent; +export const PopoverContent: React.StatelessComponent; diff --git a/types/reactstrap/lib/PopoverTitle.d.ts b/types/reactstrap/lib/PopoverTitle.d.ts index 796de02658..e21bdd1729 100644 --- a/types/reactstrap/lib/PopoverTitle.d.ts +++ b/types/reactstrap/lib/PopoverTitle.d.ts @@ -1,10 +1,9 @@ import { CSSModule } from '../index'; -interface Props { +export interface PopoverTitleProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; } -declare var PopoverTitle: React.StatelessComponent; -export default PopoverTitle; +export const PopoverTitle: React.StatelessComponent; diff --git a/types/reactstrap/lib/Progress.d.ts b/types/reactstrap/lib/Progress.d.ts index 09c4304373..5f67befa37 100644 --- a/types/reactstrap/lib/Progress.d.ts +++ b/types/reactstrap/lib/Progress.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface ProgressProps { bar?: boolean; multi?: boolean; tag?: string; @@ -14,5 +14,4 @@ interface Props { barClassName?: string; } -declare var Progress: React.StatelessComponent; -export default Progress; +export const Progress: React.StatelessComponent; diff --git a/types/reactstrap/lib/Row.d.ts b/types/reactstrap/lib/Row.d.ts index 1ffbb9f7e6..5a57601a0a 100644 --- a/types/reactstrap/lib/Row.d.ts +++ b/types/reactstrap/lib/Row.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props extends React.HTMLProps< HTMLElement> { +export interface RowProps extends React.HTMLProps< HTMLElement> { className?: string; cssModule?: CSSModule; tag?: React.ReactType; noGutters?: boolean; } -declare var Row: React.StatelessComponent; -export default Row; +export const Row: React.StatelessComponent; diff --git a/types/reactstrap/lib/TabContent.d.ts b/types/reactstrap/lib/TabContent.d.ts index af6feec078..5a8654ded9 100644 --- a/types/reactstrap/lib/TabContent.d.ts +++ b/types/reactstrap/lib/TabContent.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface TabContentProps { tag?: React.ReactType; activeTab?: number | string; className?: string; cssModule?: CSSModule; } -declare var TabContent: React.StatelessComponent; -export default TabContent; +export const TabContent: React.StatelessComponent; diff --git a/types/reactstrap/lib/TabPane.d.ts b/types/reactstrap/lib/TabPane.d.ts index 9eead420be..c1c7c1f470 100644 --- a/types/reactstrap/lib/TabPane.d.ts +++ b/types/reactstrap/lib/TabPane.d.ts @@ -1,11 +1,10 @@ import { CSSModule } from '../index'; -interface Props { +export interface TabPaneProps { tag?: React.ReactType; className?: string; cssModule?: CSSModule; tabId?: number | string; } -declare var TabPane: React.StatelessComponent; -export default TabPane; +export const TabPane: React.StatelessComponent; diff --git a/types/reactstrap/lib/Table.d.ts b/types/reactstrap/lib/Table.d.ts index ec8bfc43fd..f65af70e60 100644 --- a/types/reactstrap/lib/Table.d.ts +++ b/types/reactstrap/lib/Table.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface TableProps { className?: string; cssModule?: CSSModule; size?: string; @@ -14,5 +14,4 @@ interface Props { responsiveTag?: React.ReactType; } -declare var Table: React.StatelessComponent; -export default Table; +export const Table: React.StatelessComponent; diff --git a/types/reactstrap/lib/Tag.d.ts b/types/reactstrap/lib/Tag.d.ts index 7dce8876f2..bbc94d2120 100644 --- a/types/reactstrap/lib/Tag.d.ts +++ b/types/reactstrap/lib/Tag.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -interface Props { +export interface TagProps { color?: string; pill?: boolean; tag?: React.ReactType; @@ -8,5 +8,4 @@ interface Props { cssModule?: CSSModule; } -declare var Tag: React.StatelessComponent; -export default Tag; +export const Tag: React.StatelessComponent; diff --git a/types/reactstrap/lib/TetherContent.d.ts b/types/reactstrap/lib/TetherContent.d.ts index cbc22373e3..2ebe419ed5 100644 --- a/types/reactstrap/lib/TetherContent.d.ts +++ b/types/reactstrap/lib/TetherContent.d.ts @@ -2,7 +2,7 @@ import { CSSModule } from '../index'; -interface Props { +export interface TetherContentProps { className?: string; cssModule?: CSSModule; arrow?: string; @@ -14,5 +14,4 @@ interface Props { style?: React.CSSProperties; } -declare var TetherContent: React.StatelessComponent; -export default TetherContent; +export const TetherContent: React.StatelessComponent; diff --git a/types/reactstrap/lib/Tooltip.d.ts b/types/reactstrap/lib/Tooltip.d.ts index 9dba615084..9afa72f233 100644 --- a/types/reactstrap/lib/Tooltip.d.ts +++ b/types/reactstrap/lib/Tooltip.d.ts @@ -20,7 +20,7 @@ type Placement | 'left middle' | 'left bottom'; -export interface UncontrolledProps { +export interface UncontrolledTooltipProps { placement?: Placement; target: string; disabled?: boolean; @@ -32,12 +32,9 @@ export interface UncontrolledProps { delay?: number | { show: number, hide: number }; } -interface Props extends UncontrolledProps { +export interface TooltipProps extends UncontrolledTooltipProps { toggle?: () => void; isOpen?: boolean; } - - -declare var Tooltip: React.StatelessComponent; -export default Tooltip; +export const Tooltip: React.StatelessComponent; diff --git a/types/reactstrap/lib/Uncontrolled.d.ts b/types/reactstrap/lib/Uncontrolled.d.ts index 151ee012d3..b3b292dd6b 100644 --- a/types/reactstrap/lib/Uncontrolled.d.ts +++ b/types/reactstrap/lib/Uncontrolled.d.ts @@ -1,29 +1,17 @@ -import { - UncontrolledProps as AlertUncontrolledProps -} from './Alert'; -import { - UncontrolledProps as ButtonDropdownUncontrolledProps -} from './ButtonDropdown'; -import { - UncontrolledProps as DropdownUncontrolledProps -} from './Dropdown'; -import { - UncontrolledProps as NavDropdownUncontrolledProps -} from './NavDropdown'; -import { - UncontrolledProps as TooltipUncontrolledProps -} from './Tooltip'; +import { UncontrolledAlertProps } from './Alert'; +import { UncontrolledButtonDropdownProps } from './ButtonDropdown'; +import { UncontrolledDropdownProps } from './Dropdown'; +import { UncontrolledNavDropdownProps } from './NavDropdown'; +import { UncontrolledTooltipProps } from './Tooltip'; -declare var UncontrolledAlert: React.StatelessComponent; -declare var UncontrolledButtonDropdown: React.StatelessComponent; -declare var UncontrolledDropdown: React.StatelessComponent; -declare var UncontrolledNavDropdown: React.StatelessComponent; -declare var UncontrolledTooltip: React.StatelessComponent; +export const UncontrolledAlert: React.StatelessComponent; +export const UncontrolledButtonDropdown: React.StatelessComponent; +export const UncontrolledDropdown: React.StatelessComponent; +export const UncontrolledNavDropdown: React.StatelessComponent; +export const UncontrolledTooltip: React.StatelessComponent; -export { - UncontrolledAlert, - UncontrolledButtonDropdown, - UncontrolledDropdown, - UncontrolledNavDropdown, - UncontrolledTooltip -} \ No newline at end of file +export { UncontrolledAlertProps } from './Alert'; +export { UncontrolledButtonDropdownProps } from './ButtonDropdown'; +export { UncontrolledDropdownProps } from './Dropdown'; +export { UncontrolledNavDropdownProps } from './NavDropdown'; +export { UncontrolledTooltipProps } from './Tooltip'; From b5d2594134d86adaffde49413c5f555438938dce Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Thu, 26 Oct 2017 13:57:02 -0700 Subject: [PATCH 024/639] Add fragment to top-level API --- types/react/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index b2dc6057cc..d9059d56f9 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -88,7 +88,7 @@ declare namespace React { } interface ReactElement

{ - type: string | ComponentClass

| SFC

; + type: string | symbol | number | ComponentClass

| SFC

; props: P; key: Key | null; } @@ -222,7 +222,7 @@ declare namespace React { props?: ClassAttributes & P, ...children: ReactNode[]): CElement; function createElement

( - type: SFC

| ComponentClass

| string, + type: SFC

| ComponentClass

| string | symbol | number, props?: Attributes & P, ...children: ReactNode[]): ReactElement

; @@ -265,6 +265,7 @@ declare namespace React { function isValidElement

(object: {} | null | undefined): object is ReactElement

; const Children: ReactChildren; + const Fragment: symbol | number; const version: string; // From f6904a2eab412089c494fd1382824c6e0919f5ec Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 31 Oct 2017 08:50:40 -0700 Subject: [PATCH 025/639] Update test --- types/react/test/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react/test/index.ts b/types/react/test/index.ts index b9eea759e7..26ca339f2d 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -228,6 +228,7 @@ const notValid: boolean = React.isValidElement(props); // false const isValid = React.isValidElement(element); // true let domNode: Element = ReactDOM.findDOMNode(component); domNode = ReactDOM.findDOMNode(domNode); +const fragmentType: symbol | number = React.Fragment; // // React Elements From 4d07771b6c5ed5c3b75c7ee3e0d939557927403d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 31 Oct 2017 10:11:25 -0700 Subject: [PATCH 026/639] Add create fragment test --- types/react/test/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 26ca339f2d..e65909fc2d 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -164,6 +164,7 @@ const statelessElement: React.SFCElement = React.createElement(Stateles const domElement: React.DOMElement, HTMLDivElement> = React.createElement("div"); const htmlElement = React.createElement("input", { type: "text" }); const svgElement = React.createElement("svg", { accentHeight: 12 }); +const fragmentElement: React.ReactElement = React.createElement(React.Fragment, undefined, [React.createElement("div"), React.createElement("div")]); const customProps: React.HTMLProps = props; const customDomElement = "my-element"; From d63cc7edaf66e72e6f5b17a78ed321fadea92431 Mon Sep 17 00:00:00 2001 From: Douglas Day Date: Thu, 2 Nov 2017 16:16:18 -0600 Subject: [PATCH 027/639] react-redux-toastr: Fix issue with TypeScript component compatibility --- types/react-redux-toastr/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/react-redux-toastr/index.d.ts b/types/react-redux-toastr/index.d.ts index 0f5b66903f..40829122dc 100644 --- a/types/react-redux-toastr/index.d.ts +++ b/types/react-redux-toastr/index.d.ts @@ -18,8 +18,8 @@ export type transitionOutType = 'bounceOut' | 'bounceOutUp' | 'fadeOut'; interface BasicToastrOptions { attention?: boolean; className?: string; - component?: Component; - icon?: Component; + component?: JSX.Element; + icon?: JSX.Element; onCloseButtonClick?: () => void; onHideComplete?: () => void; onShowComplete?: () => void; @@ -34,8 +34,8 @@ interface BasicToastrOptions { interface LightToastrOptions { attention?: boolean; className?: string; - component?: Component; - icon?: iconType | Component; + component?: JSX.Element; + icon?: iconType | JSX.Element; onCloseButtonClick?: () => void; onHideComplete?: () => void; onShowComplete?: () => void; @@ -55,7 +55,7 @@ interface ConfirmToastrOptions { } interface ConfirmToastrCustomOptions { - component: Component; + component: JSX.Element; } export interface Toastr { From b0b139c633d6b1fe8fa973b9ee8df20c0477a3a0 Mon Sep 17 00:00:00 2001 From: FaithForHumans Date: Fri, 10 Nov 2017 19:22:40 -0600 Subject: [PATCH 028/639] Adding export defaults back. --- types/reactstrap/lib/Alert.d.ts | 1 + types/reactstrap/lib/Badge.d.ts | 1 + types/reactstrap/lib/Breadcrumb.d.ts | 1 + types/reactstrap/lib/BreadcrumbItem.d.ts | 1 + types/reactstrap/lib/Button.d.ts | 1 + types/reactstrap/lib/ButtonDropdown.d.ts | 1 + types/reactstrap/lib/ButtonGroup.d.ts | 1 + types/reactstrap/lib/ButtonToolbar.d.ts | 1 + types/reactstrap/lib/Card.d.ts | 1 + types/reactstrap/lib/CardBlock.d.ts | 1 + types/reactstrap/lib/CardBody.d.ts | 1 + types/reactstrap/lib/CardColumns.d.ts | 1 + types/reactstrap/lib/CardDeck.d.ts | 1 + types/reactstrap/lib/CardFooter.d.ts | 1 + types/reactstrap/lib/CardGroup.d.ts | 1 + types/reactstrap/lib/CardHeader.d.ts | 1 + types/reactstrap/lib/CardImg.d.ts | 1 + types/reactstrap/lib/CardImgOverlay.d.ts | 1 + types/reactstrap/lib/CardLink.d.ts | 1 + types/reactstrap/lib/CardSubtitle.d.ts | 1 + types/reactstrap/lib/CardText.d.ts | 1 + types/reactstrap/lib/CardTitle.d.ts | 1 + types/reactstrap/lib/Col.d.ts | 1 + types/reactstrap/lib/Collapse.d.ts | 1 + types/reactstrap/lib/Container.d.ts | 1 + types/reactstrap/lib/Dropdown.d.ts | 1 + types/reactstrap/lib/DropdownItem.d.ts | 1 + types/reactstrap/lib/DropdownMenu.d.ts | 1 + types/reactstrap/lib/DropdownToggle.d.ts | 1 + types/reactstrap/lib/Fade.d.ts | 1 + types/reactstrap/lib/Form.d.ts | 1 + types/reactstrap/lib/FormFeedback.d.ts | 1 + types/reactstrap/lib/FormGroup.d.ts | 1 + types/reactstrap/lib/FormText.d.ts | 1 + types/reactstrap/lib/Input.d.ts | 1 + types/reactstrap/lib/InputGroup.d.ts | 1 + types/reactstrap/lib/InputGroupAddon.d.ts | 1 + types/reactstrap/lib/InputGroupButton.d.ts | 1 + types/reactstrap/lib/Jumbotron.d.ts | 1 + types/reactstrap/lib/Label.d.ts | 1 + types/reactstrap/lib/ListGroup.d.ts | 1 + types/reactstrap/lib/ListGroupItem.d.ts | 1 + types/reactstrap/lib/ListGroupItemHeading.d.ts | 1 + types/reactstrap/lib/ListGroupItemText.d.ts | 1 + types/reactstrap/lib/Media.d.ts | 1 + types/reactstrap/lib/Modal.d.ts | 1 + types/reactstrap/lib/ModalBody.d.ts | 1 + types/reactstrap/lib/ModalFooter.d.ts | 1 + types/reactstrap/lib/ModalHeader.d.ts | 1 + types/reactstrap/lib/Nav.d.ts | 1 + types/reactstrap/lib/NavDropdown.d.ts | 1 + types/reactstrap/lib/NavItem.d.ts | 1 + types/reactstrap/lib/NavLink.d.ts | 1 + types/reactstrap/lib/Navbar.d.ts | 1 + types/reactstrap/lib/NavbarBrand.d.ts | 1 + types/reactstrap/lib/NavbarToggler.d.ts | 1 + types/reactstrap/lib/Pagination.d.ts | 1 + types/reactstrap/lib/PaginationItem.d.ts | 1 + types/reactstrap/lib/PaginationLink.d.ts | 1 + types/reactstrap/lib/Popover.d.ts | 1 + types/reactstrap/lib/PopoverContent.d.ts | 1 + types/reactstrap/lib/PopoverTitle.d.ts | 1 + types/reactstrap/lib/Progress.d.ts | 1 + types/reactstrap/lib/Row.d.ts | 1 + types/reactstrap/lib/TabContent.d.ts | 1 + types/reactstrap/lib/TabPane.d.ts | 1 + types/reactstrap/lib/Table.d.ts | 1 + types/reactstrap/lib/Tag.d.ts | 1 + types/reactstrap/lib/TetherContent.d.ts | 1 + types/reactstrap/lib/Tooltip.d.ts | 1 + 70 files changed, 70 insertions(+) diff --git a/types/reactstrap/lib/Alert.d.ts b/types/reactstrap/lib/Alert.d.ts index 1b4f6eb884..6ce7c0fe0e 100644 --- a/types/reactstrap/lib/Alert.d.ts +++ b/types/reactstrap/lib/Alert.d.ts @@ -16,3 +16,4 @@ export interface AlertProps extends UncontrolledAlertProps { } export const Alert: React.StatelessComponent; +export default Alert; diff --git a/types/reactstrap/lib/Badge.d.ts b/types/reactstrap/lib/Badge.d.ts index 4c21dcac42..328e3abf36 100644 --- a/types/reactstrap/lib/Badge.d.ts +++ b/types/reactstrap/lib/Badge.d.ts @@ -9,3 +9,4 @@ export interface BadgeProps { } export const Badge: React.StatelessComponent; +export default Badge; diff --git a/types/reactstrap/lib/Breadcrumb.d.ts b/types/reactstrap/lib/Breadcrumb.d.ts index 26839e9140..62ccf477a9 100644 --- a/types/reactstrap/lib/Breadcrumb.d.ts +++ b/types/reactstrap/lib/Breadcrumb.d.ts @@ -7,3 +7,4 @@ export interface BreadcrumbProps { } export const Breadcrumb: React.StatelessComponent; +export default Breadcrumb; diff --git a/types/reactstrap/lib/BreadcrumbItem.d.ts b/types/reactstrap/lib/BreadcrumbItem.d.ts index d8deed883a..81d18f0f76 100644 --- a/types/reactstrap/lib/BreadcrumbItem.d.ts +++ b/types/reactstrap/lib/BreadcrumbItem.d.ts @@ -11,3 +11,4 @@ export interface BreadcrumbItemProps { } export const BreadcrumbItem: React.StatelessComponent; +export default BreadcrumbItem; diff --git a/types/reactstrap/lib/Button.d.ts b/types/reactstrap/lib/Button.d.ts index cf5348d659..f4a8b4e4cd 100644 --- a/types/reactstrap/lib/Button.d.ts +++ b/types/reactstrap/lib/Button.d.ts @@ -18,3 +18,4 @@ export interface ButtonProps extends React.HTMLProps { } export const Button: React.StatelessComponent; +export default Button; diff --git a/types/reactstrap/lib/ButtonDropdown.d.ts b/types/reactstrap/lib/ButtonDropdown.d.ts index bb26a03685..284818f88f 100644 --- a/types/reactstrap/lib/ButtonDropdown.d.ts +++ b/types/reactstrap/lib/ButtonDropdown.d.ts @@ -6,3 +6,4 @@ export interface UncontrolledButtonDropdownProps extends UncontrolledDropdownPro export interface ButtonDropdownProps extends DropdownProps { } export const ButtonDropdown: React.StatelessComponent; +export default ButtonDropdown; diff --git a/types/reactstrap/lib/ButtonGroup.d.ts b/types/reactstrap/lib/ButtonGroup.d.ts index 033c3075f9..cf51a29326 100644 --- a/types/reactstrap/lib/ButtonGroup.d.ts +++ b/types/reactstrap/lib/ButtonGroup.d.ts @@ -11,3 +11,4 @@ export interface ButtonGroupProps { } export const ButtonGroup: React.StatelessComponent; +export default ButtonGroup; diff --git a/types/reactstrap/lib/ButtonToolbar.d.ts b/types/reactstrap/lib/ButtonToolbar.d.ts index 3e16b331c3..e57b84337a 100644 --- a/types/reactstrap/lib/ButtonToolbar.d.ts +++ b/types/reactstrap/lib/ButtonToolbar.d.ts @@ -9,3 +9,4 @@ export interface ButtonToolbarProps { } export const ButtonToolbar: React.StatelessComponent; +export default ButtonToolbar; diff --git a/types/reactstrap/lib/Card.d.ts b/types/reactstrap/lib/Card.d.ts index f6d0d5e265..8398d3b631 100644 --- a/types/reactstrap/lib/Card.d.ts +++ b/types/reactstrap/lib/Card.d.ts @@ -12,3 +12,4 @@ export interface CardProps { } export const Card: React.StatelessComponent; +export default Card; diff --git a/types/reactstrap/lib/CardBlock.d.ts b/types/reactstrap/lib/CardBlock.d.ts index 905884b786..a4eae1cf6e 100644 --- a/types/reactstrap/lib/CardBlock.d.ts +++ b/types/reactstrap/lib/CardBlock.d.ts @@ -7,3 +7,4 @@ export interface CardBlockProps { } export const CardBlock: React.StatelessComponent; +export default CardBlock; diff --git a/types/reactstrap/lib/CardBody.d.ts b/types/reactstrap/lib/CardBody.d.ts index eeb9c8fe8d..9ff4ba1f7e 100644 --- a/types/reactstrap/lib/CardBody.d.ts +++ b/types/reactstrap/lib/CardBody.d.ts @@ -7,3 +7,4 @@ export interface CardBodyProps { } export const CardBody: React.StatelessComponent; +export default CardBody; diff --git a/types/reactstrap/lib/CardColumns.d.ts b/types/reactstrap/lib/CardColumns.d.ts index e1d00fa389..4853240671 100644 --- a/types/reactstrap/lib/CardColumns.d.ts +++ b/types/reactstrap/lib/CardColumns.d.ts @@ -7,3 +7,4 @@ export interface CardColumnsProps { } export const CardColumns: React.StatelessComponent; +export default CardColumns; diff --git a/types/reactstrap/lib/CardDeck.d.ts b/types/reactstrap/lib/CardDeck.d.ts index 15b3660f9d..963d617383 100644 --- a/types/reactstrap/lib/CardDeck.d.ts +++ b/types/reactstrap/lib/CardDeck.d.ts @@ -7,3 +7,4 @@ export interface CardDeckProps { } export const CardDeck: React.StatelessComponent; +export default CardDeck; diff --git a/types/reactstrap/lib/CardFooter.d.ts b/types/reactstrap/lib/CardFooter.d.ts index 2b320c48b5..415406a14c 100644 --- a/types/reactstrap/lib/CardFooter.d.ts +++ b/types/reactstrap/lib/CardFooter.d.ts @@ -7,3 +7,4 @@ export interface CardFooterProps { } export const CardFooter: React.StatelessComponent; +export default CardFooter; diff --git a/types/reactstrap/lib/CardGroup.d.ts b/types/reactstrap/lib/CardGroup.d.ts index 93fdd04bb0..be69f617e7 100644 --- a/types/reactstrap/lib/CardGroup.d.ts +++ b/types/reactstrap/lib/CardGroup.d.ts @@ -7,3 +7,4 @@ export interface CardGroupProps { } export const CardGroup: React.StatelessComponent; +export default CardGroup; diff --git a/types/reactstrap/lib/CardHeader.d.ts b/types/reactstrap/lib/CardHeader.d.ts index d9d942c3d8..e9a468e2e4 100644 --- a/types/reactstrap/lib/CardHeader.d.ts +++ b/types/reactstrap/lib/CardHeader.d.ts @@ -7,3 +7,4 @@ export interface CardHeaderProps { } export const CardHeader: React.StatelessComponent; +export default CardHeader; diff --git a/types/reactstrap/lib/CardImg.d.ts b/types/reactstrap/lib/CardImg.d.ts index dd479691b5..76bd9a18f2 100644 --- a/types/reactstrap/lib/CardImg.d.ts +++ b/types/reactstrap/lib/CardImg.d.ts @@ -13,3 +13,4 @@ export interface CardImgProps { } export const CardImg: React.StatelessComponent; +export default CardImg; diff --git a/types/reactstrap/lib/CardImgOverlay.d.ts b/types/reactstrap/lib/CardImgOverlay.d.ts index 22333a55c2..0511d38e8b 100644 --- a/types/reactstrap/lib/CardImgOverlay.d.ts +++ b/types/reactstrap/lib/CardImgOverlay.d.ts @@ -7,3 +7,4 @@ export interface CardImgOverlayProps { } export const CardImgOverlay: React.StatelessComponent; +export default CardImgOverlay; diff --git a/types/reactstrap/lib/CardLink.d.ts b/types/reactstrap/lib/CardLink.d.ts index 7aa8492438..68ef38fa62 100644 --- a/types/reactstrap/lib/CardLink.d.ts +++ b/types/reactstrap/lib/CardLink.d.ts @@ -9,3 +9,4 @@ export interface CardLinkProps { } export const CardLink: React.StatelessComponent; +export default CardLink; diff --git a/types/reactstrap/lib/CardSubtitle.d.ts b/types/reactstrap/lib/CardSubtitle.d.ts index 36e847367c..5c2cbe574f 100644 --- a/types/reactstrap/lib/CardSubtitle.d.ts +++ b/types/reactstrap/lib/CardSubtitle.d.ts @@ -7,3 +7,4 @@ export interface CardSubtitleProps { } export const CardSubtitle: React.StatelessComponent; +export default CardSubtitle; diff --git a/types/reactstrap/lib/CardText.d.ts b/types/reactstrap/lib/CardText.d.ts index 297a561d50..1b411717f5 100644 --- a/types/reactstrap/lib/CardText.d.ts +++ b/types/reactstrap/lib/CardText.d.ts @@ -7,3 +7,4 @@ export interface CardTextProps { } export const CardText: React.StatelessComponent; +export default CardText; diff --git a/types/reactstrap/lib/CardTitle.d.ts b/types/reactstrap/lib/CardTitle.d.ts index 52b9556945..483a47adb7 100644 --- a/types/reactstrap/lib/CardTitle.d.ts +++ b/types/reactstrap/lib/CardTitle.d.ts @@ -7,3 +7,4 @@ export interface CardTitleProps { } export const CardTitle: React.StatelessComponent; +export default CardTitle; diff --git a/types/reactstrap/lib/Col.d.ts b/types/reactstrap/lib/Col.d.ts index cf2fd098fa..c1bc6a0cd9 100644 --- a/types/reactstrap/lib/Col.d.ts +++ b/types/reactstrap/lib/Col.d.ts @@ -21,3 +21,4 @@ export interface ColProps extends React.HTMLProps { } export const Col: React.StatelessComponent; +export default Col; diff --git a/types/reactstrap/lib/Collapse.d.ts b/types/reactstrap/lib/Collapse.d.ts index 5647bf68b3..d926fd677d 100644 --- a/types/reactstrap/lib/Collapse.d.ts +++ b/types/reactstrap/lib/Collapse.d.ts @@ -15,3 +15,4 @@ export interface CollapseProps extends React.HTMLProps { } export const Collapse: React.StatelessComponent; +export default Collapse; diff --git a/types/reactstrap/lib/Container.d.ts b/types/reactstrap/lib/Container.d.ts index 08d702af4b..63906b7bf3 100644 --- a/types/reactstrap/lib/Container.d.ts +++ b/types/reactstrap/lib/Container.d.ts @@ -8,3 +8,4 @@ export interface ContainerProps { } export const Container: React.StatelessComponent; +export default Container; diff --git a/types/reactstrap/lib/Dropdown.d.ts b/types/reactstrap/lib/Dropdown.d.ts index fce1de08b1..93a0ee1ce5 100644 --- a/types/reactstrap/lib/Dropdown.d.ts +++ b/types/reactstrap/lib/Dropdown.d.ts @@ -19,3 +19,4 @@ export interface DropdownProps extends UncontrolledDropdownProps { } export const Dropdown: React.StatelessComponent; +export default Dropdown; diff --git a/types/reactstrap/lib/DropdownItem.d.ts b/types/reactstrap/lib/DropdownItem.d.ts index d8d4718563..194d89bf0b 100644 --- a/types/reactstrap/lib/DropdownItem.d.ts +++ b/types/reactstrap/lib/DropdownItem.d.ts @@ -13,3 +13,4 @@ export interface DropdownItemProps { } export const DropdownItem: React.StatelessComponent; +export default DropdownItem; diff --git a/types/reactstrap/lib/DropdownMenu.d.ts b/types/reactstrap/lib/DropdownMenu.d.ts index e206ebd6d9..1bbf642a09 100644 --- a/types/reactstrap/lib/DropdownMenu.d.ts +++ b/types/reactstrap/lib/DropdownMenu.d.ts @@ -8,3 +8,4 @@ export interface DropdownMenuProps { } export const DropdownMenu: React.StatelessComponent; +export default DropdownMenu; diff --git a/types/reactstrap/lib/DropdownToggle.d.ts b/types/reactstrap/lib/DropdownToggle.d.ts index df1cb7f845..8f395b998d 100644 --- a/types/reactstrap/lib/DropdownToggle.d.ts +++ b/types/reactstrap/lib/DropdownToggle.d.ts @@ -16,3 +16,4 @@ export interface DropdownToggleProps { } export const DropdownToggle: React.StatelessComponent; +export default DropdownToggle; diff --git a/types/reactstrap/lib/Fade.d.ts b/types/reactstrap/lib/Fade.d.ts index 2c13430af9..ab77d7fb61 100644 --- a/types/reactstrap/lib/Fade.d.ts +++ b/types/reactstrap/lib/Fade.d.ts @@ -17,3 +17,4 @@ export interface FadeProps { } export const Fade: React.StatelessComponent; +export default Fade; diff --git a/types/reactstrap/lib/Form.d.ts b/types/reactstrap/lib/Form.d.ts index 7e61d24429..507b617a12 100644 --- a/types/reactstrap/lib/Form.d.ts +++ b/types/reactstrap/lib/Form.d.ts @@ -9,3 +9,4 @@ export interface FormProps extends React.HTMLProps { } export const Form: React.StatelessComponent; +export default Form; diff --git a/types/reactstrap/lib/FormFeedback.d.ts b/types/reactstrap/lib/FormFeedback.d.ts index ac6f0f5003..e9479bc53d 100644 --- a/types/reactstrap/lib/FormFeedback.d.ts +++ b/types/reactstrap/lib/FormFeedback.d.ts @@ -7,3 +7,4 @@ export interface FormFeedbackProps { } export const FormFeedback: React.StatelessComponent; +export default FormFeedback; diff --git a/types/reactstrap/lib/FormGroup.d.ts b/types/reactstrap/lib/FormGroup.d.ts index 65c0da639b..c3e4d384db 100644 --- a/types/reactstrap/lib/FormGroup.d.ts +++ b/types/reactstrap/lib/FormGroup.d.ts @@ -11,3 +11,4 @@ export interface FormGroupProps extends React.HTMLProps { } export const FormGroup: React.StatelessComponent; +export default FormGroup; diff --git a/types/reactstrap/lib/FormText.d.ts b/types/reactstrap/lib/FormText.d.ts index c8af8f56c8..ca4e1858fe 100644 --- a/types/reactstrap/lib/FormText.d.ts +++ b/types/reactstrap/lib/FormText.d.ts @@ -9,3 +9,4 @@ export interface FormTextProps { } export const FormText: React.StatelessComponent; +export default FormText; diff --git a/types/reactstrap/lib/Input.d.ts b/types/reactstrap/lib/Input.d.ts index d332718152..cc7377ca1f 100644 --- a/types/reactstrap/lib/Input.d.ts +++ b/types/reactstrap/lib/Input.d.ts @@ -49,3 +49,4 @@ export interface InputProps extends Intermediate { } export const Input: React.StatelessComponent; +export default Input; diff --git a/types/reactstrap/lib/InputGroup.d.ts b/types/reactstrap/lib/InputGroup.d.ts index abd7fcd381..9a6ac719bb 100644 --- a/types/reactstrap/lib/InputGroup.d.ts +++ b/types/reactstrap/lib/InputGroup.d.ts @@ -8,3 +8,4 @@ export interface InputGroupProps { } export const InputGroup: React.StatelessComponent; +export default InputGroup; diff --git a/types/reactstrap/lib/InputGroupAddon.d.ts b/types/reactstrap/lib/InputGroupAddon.d.ts index 7ddbc3b4c1..63ac88c455 100644 --- a/types/reactstrap/lib/InputGroupAddon.d.ts +++ b/types/reactstrap/lib/InputGroupAddon.d.ts @@ -7,3 +7,4 @@ export interface InputGroupAddonProps { } export const InputGroupAddon: React.StatelessComponent; +export default InputGroupAddon; diff --git a/types/reactstrap/lib/InputGroupButton.d.ts b/types/reactstrap/lib/InputGroupButton.d.ts index 90a93ff8ed..f51c61b3d1 100644 --- a/types/reactstrap/lib/InputGroupButton.d.ts +++ b/types/reactstrap/lib/InputGroupButton.d.ts @@ -10,3 +10,4 @@ export interface InputGroupButtonProps { } export const InputGroupButton: React.StatelessComponent; +export default InputGroupButton; diff --git a/types/reactstrap/lib/Jumbotron.d.ts b/types/reactstrap/lib/Jumbotron.d.ts index 4ade1eabaa..885bbe5f8f 100644 --- a/types/reactstrap/lib/Jumbotron.d.ts +++ b/types/reactstrap/lib/Jumbotron.d.ts @@ -8,3 +8,4 @@ export interface JumbotronProps { } export const Jumbotron: React.StatelessComponent; +export default Jumbotron; diff --git a/types/reactstrap/lib/Label.d.ts b/types/reactstrap/lib/Label.d.ts index 3688aaf233..26728059e0 100644 --- a/types/reactstrap/lib/Label.d.ts +++ b/types/reactstrap/lib/Label.d.ts @@ -23,3 +23,4 @@ export interface LabelProps extends Intermediate { } export const Label: React.StatelessComponent; +export default Label; diff --git a/types/reactstrap/lib/ListGroup.d.ts b/types/reactstrap/lib/ListGroup.d.ts index bef63da796..aec7fa4045 100644 --- a/types/reactstrap/lib/ListGroup.d.ts +++ b/types/reactstrap/lib/ListGroup.d.ts @@ -8,3 +8,4 @@ export interface ListGroupProps { } export const ListGroup: React.StatelessComponent; +export default ListGroup; diff --git a/types/reactstrap/lib/ListGroupItem.d.ts b/types/reactstrap/lib/ListGroupItem.d.ts index 44a70b6ec4..5b610f87e2 100644 --- a/types/reactstrap/lib/ListGroupItem.d.ts +++ b/types/reactstrap/lib/ListGroupItem.d.ts @@ -14,3 +14,4 @@ export interface ListGroupItemProps { } export const ListGroupItem: React.StatelessComponent; +export default ListGroupItem; diff --git a/types/reactstrap/lib/ListGroupItemHeading.d.ts b/types/reactstrap/lib/ListGroupItemHeading.d.ts index f44317f541..3e8d83a0dc 100644 --- a/types/reactstrap/lib/ListGroupItemHeading.d.ts +++ b/types/reactstrap/lib/ListGroupItemHeading.d.ts @@ -7,3 +7,4 @@ export interface ListGroupItemHeadingProps { } export const ListGroupItemHeading: React.StatelessComponent; +export default ListGroupItemHeading; diff --git a/types/reactstrap/lib/ListGroupItemText.d.ts b/types/reactstrap/lib/ListGroupItemText.d.ts index a19803e4fe..ad83a45831 100644 --- a/types/reactstrap/lib/ListGroupItemText.d.ts +++ b/types/reactstrap/lib/ListGroupItemText.d.ts @@ -7,3 +7,4 @@ export interface ListGroupItemTextProps { } export const ListGroupItemText: React.StatelessComponent; +export default ListGroupItemText; diff --git a/types/reactstrap/lib/Media.d.ts b/types/reactstrap/lib/Media.d.ts index 9276c0708f..17b65f25f0 100644 --- a/types/reactstrap/lib/Media.d.ts +++ b/types/reactstrap/lib/Media.d.ts @@ -18,3 +18,4 @@ export interface MediaProps { } export const Media: React.StatelessComponent; +export default Media; diff --git a/types/reactstrap/lib/Modal.d.ts b/types/reactstrap/lib/Modal.d.ts index eb7d2a0f15..77122f64b4 100644 --- a/types/reactstrap/lib/Modal.d.ts +++ b/types/reactstrap/lib/Modal.d.ts @@ -20,3 +20,4 @@ export interface ModalProps { } export const Modal: React.StatelessComponent; +export default Modal; diff --git a/types/reactstrap/lib/ModalBody.d.ts b/types/reactstrap/lib/ModalBody.d.ts index 1238f7d54a..a2693cbf28 100644 --- a/types/reactstrap/lib/ModalBody.d.ts +++ b/types/reactstrap/lib/ModalBody.d.ts @@ -7,3 +7,4 @@ export interface ModalBodyProps { } export const ModalBody: React.StatelessComponent; +export default ModalBody; diff --git a/types/reactstrap/lib/ModalFooter.d.ts b/types/reactstrap/lib/ModalFooter.d.ts index d7cafe275b..0241dcde84 100644 --- a/types/reactstrap/lib/ModalFooter.d.ts +++ b/types/reactstrap/lib/ModalFooter.d.ts @@ -7,3 +7,4 @@ export interface ModalFooterProps { } export const ModalFooter: React.StatelessComponent; +export default ModalFooter; diff --git a/types/reactstrap/lib/ModalHeader.d.ts b/types/reactstrap/lib/ModalHeader.d.ts index 5792fea0d1..a235d73183 100644 --- a/types/reactstrap/lib/ModalHeader.d.ts +++ b/types/reactstrap/lib/ModalHeader.d.ts @@ -9,3 +9,4 @@ export interface ModalHeaderProps { } export const ModalHeader: React.StatelessComponent; +export default ModalHeader; diff --git a/types/reactstrap/lib/Nav.d.ts b/types/reactstrap/lib/Nav.d.ts index e42556fadd..23bf1e58c5 100644 --- a/types/reactstrap/lib/Nav.d.ts +++ b/types/reactstrap/lib/Nav.d.ts @@ -14,3 +14,4 @@ export interface NavProps extends React.HTMLProps { } export const Nav: React.StatelessComponent; +export default Nav; diff --git a/types/reactstrap/lib/NavDropdown.d.ts b/types/reactstrap/lib/NavDropdown.d.ts index dfa15afa17..22e408489b 100644 --- a/types/reactstrap/lib/NavDropdown.d.ts +++ b/types/reactstrap/lib/NavDropdown.d.ts @@ -6,3 +6,4 @@ export interface UncontrolledNavDropdownProps extends UncontrolledDropdownProps export interface NavDropdownProps extends DropdownProps { } export const NavDropdown: React.StatelessComponent; +export default NavDropdown; diff --git a/types/reactstrap/lib/NavItem.d.ts b/types/reactstrap/lib/NavItem.d.ts index 8e6e7631d2..cb32a4fad1 100644 --- a/types/reactstrap/lib/NavItem.d.ts +++ b/types/reactstrap/lib/NavItem.d.ts @@ -7,3 +7,4 @@ export interface NavItemProps { } export const NavItem: React.StatelessComponent; +export default NavItem; diff --git a/types/reactstrap/lib/NavLink.d.ts b/types/reactstrap/lib/NavLink.d.ts index 1fd7d14abc..7fa907c453 100644 --- a/types/reactstrap/lib/NavLink.d.ts +++ b/types/reactstrap/lib/NavLink.d.ts @@ -12,3 +12,4 @@ export interface NavLinkProps extends React.HTMLProps { } export const NavLink: React.StatelessComponent; +export default NavLink; diff --git a/types/reactstrap/lib/Navbar.d.ts b/types/reactstrap/lib/Navbar.d.ts index 76616a7be2..fd52feeae8 100644 --- a/types/reactstrap/lib/Navbar.d.ts +++ b/types/reactstrap/lib/Navbar.d.ts @@ -17,3 +17,4 @@ export interface NavbarProps { } export const Navbar: React.StatelessComponent; +export default Navbar; diff --git a/types/reactstrap/lib/NavbarBrand.d.ts b/types/reactstrap/lib/NavbarBrand.d.ts index 0aa80597b9..8e3328ab81 100644 --- a/types/reactstrap/lib/NavbarBrand.d.ts +++ b/types/reactstrap/lib/NavbarBrand.d.ts @@ -7,3 +7,4 @@ export interface NavbarBrandProps extends React.HTMLProps { } export const NavbarBrand: React.StatelessComponent; +export default NavbarBrand; diff --git a/types/reactstrap/lib/NavbarToggler.d.ts b/types/reactstrap/lib/NavbarToggler.d.ts index 5dd2df7057..1855e2c41c 100644 --- a/types/reactstrap/lib/NavbarToggler.d.ts +++ b/types/reactstrap/lib/NavbarToggler.d.ts @@ -10,3 +10,4 @@ export interface NavbarTogglerProps extends React.HTMLProps { } export const NavbarToggler: React.StatelessComponent; +export default NavbarToggler; diff --git a/types/reactstrap/lib/Pagination.d.ts b/types/reactstrap/lib/Pagination.d.ts index 3b19364c30..dd1a0c9d51 100644 --- a/types/reactstrap/lib/Pagination.d.ts +++ b/types/reactstrap/lib/Pagination.d.ts @@ -7,3 +7,4 @@ export interface PaginationProps { } export const Pagination: React.StatelessComponent; +export default Pagination; diff --git a/types/reactstrap/lib/PaginationItem.d.ts b/types/reactstrap/lib/PaginationItem.d.ts index 3ed0400dcd..1e8efa8712 100644 --- a/types/reactstrap/lib/PaginationItem.d.ts +++ b/types/reactstrap/lib/PaginationItem.d.ts @@ -9,3 +9,4 @@ export interface PaginationItemProps { } export const PaginationItem: React.StatelessComponent; +export default PaginationItem; diff --git a/types/reactstrap/lib/PaginationLink.d.ts b/types/reactstrap/lib/PaginationLink.d.ts index 5c2a1d5711..c57bee37ac 100644 --- a/types/reactstrap/lib/PaginationLink.d.ts +++ b/types/reactstrap/lib/PaginationLink.d.ts @@ -10,3 +10,4 @@ export interface PaginationLinkProps extends React.HTMLProps } export const PaginationLink: React.StatelessComponent; +export default PaginationLink; diff --git a/types/reactstrap/lib/Popover.d.ts b/types/reactstrap/lib/Popover.d.ts index 69fe27cb88..e9e757572e 100644 --- a/types/reactstrap/lib/Popover.d.ts +++ b/types/reactstrap/lib/Popover.d.ts @@ -31,3 +31,4 @@ export interface PopoverProps { } export const Popover: React.StatelessComponent; +export default Popover; diff --git a/types/reactstrap/lib/PopoverContent.d.ts b/types/reactstrap/lib/PopoverContent.d.ts index a062d4d2c9..ea72f4dfb4 100644 --- a/types/reactstrap/lib/PopoverContent.d.ts +++ b/types/reactstrap/lib/PopoverContent.d.ts @@ -7,3 +7,4 @@ export interface PopoverContentProps { } export const PopoverContent: React.StatelessComponent; +export default PopoverContent; diff --git a/types/reactstrap/lib/PopoverTitle.d.ts b/types/reactstrap/lib/PopoverTitle.d.ts index e21bdd1729..9711058424 100644 --- a/types/reactstrap/lib/PopoverTitle.d.ts +++ b/types/reactstrap/lib/PopoverTitle.d.ts @@ -7,3 +7,4 @@ export interface PopoverTitleProps { } export const PopoverTitle: React.StatelessComponent; +export default PopoverTitle; diff --git a/types/reactstrap/lib/Progress.d.ts b/types/reactstrap/lib/Progress.d.ts index 5f67befa37..9ab522746c 100644 --- a/types/reactstrap/lib/Progress.d.ts +++ b/types/reactstrap/lib/Progress.d.ts @@ -15,3 +15,4 @@ export interface ProgressProps { } export const Progress: React.StatelessComponent; +export default Progress; diff --git a/types/reactstrap/lib/Row.d.ts b/types/reactstrap/lib/Row.d.ts index 5a57601a0a..30d202e919 100644 --- a/types/reactstrap/lib/Row.d.ts +++ b/types/reactstrap/lib/Row.d.ts @@ -8,3 +8,4 @@ export interface RowProps extends React.HTMLProps< HTMLElement> { } export const Row: React.StatelessComponent; +export default Row; diff --git a/types/reactstrap/lib/TabContent.d.ts b/types/reactstrap/lib/TabContent.d.ts index 5a8654ded9..1aced21b02 100644 --- a/types/reactstrap/lib/TabContent.d.ts +++ b/types/reactstrap/lib/TabContent.d.ts @@ -8,3 +8,4 @@ export interface TabContentProps { } export const TabContent: React.StatelessComponent; +export default TabContent; diff --git a/types/reactstrap/lib/TabPane.d.ts b/types/reactstrap/lib/TabPane.d.ts index c1c7c1f470..1d588e7304 100644 --- a/types/reactstrap/lib/TabPane.d.ts +++ b/types/reactstrap/lib/TabPane.d.ts @@ -8,3 +8,4 @@ export interface TabPaneProps { } export const TabPane: React.StatelessComponent; +export default TabPane; diff --git a/types/reactstrap/lib/Table.d.ts b/types/reactstrap/lib/Table.d.ts index f65af70e60..b49c6a5920 100644 --- a/types/reactstrap/lib/Table.d.ts +++ b/types/reactstrap/lib/Table.d.ts @@ -15,3 +15,4 @@ export interface TableProps { } export const Table: React.StatelessComponent; +export default Table; diff --git a/types/reactstrap/lib/Tag.d.ts b/types/reactstrap/lib/Tag.d.ts index bbc94d2120..0f2ed5bd07 100644 --- a/types/reactstrap/lib/Tag.d.ts +++ b/types/reactstrap/lib/Tag.d.ts @@ -9,3 +9,4 @@ export interface TagProps { } export const Tag: React.StatelessComponent; +export default Tag; diff --git a/types/reactstrap/lib/TetherContent.d.ts b/types/reactstrap/lib/TetherContent.d.ts index 2ebe419ed5..7dd32ae381 100644 --- a/types/reactstrap/lib/TetherContent.d.ts +++ b/types/reactstrap/lib/TetherContent.d.ts @@ -15,3 +15,4 @@ export interface TetherContentProps { } export const TetherContent: React.StatelessComponent; +export default TetherContent; diff --git a/types/reactstrap/lib/Tooltip.d.ts b/types/reactstrap/lib/Tooltip.d.ts index 9afa72f233..21a99707e8 100644 --- a/types/reactstrap/lib/Tooltip.d.ts +++ b/types/reactstrap/lib/Tooltip.d.ts @@ -38,3 +38,4 @@ export interface TooltipProps extends UncontrolledTooltipProps { } export const Tooltip: React.StatelessComponent; +export default Tooltip; From 3022724dfabf8dcfc28d8e29995e53ae2da957a0 Mon Sep 17 00:00:00 2001 From: FaithForHumans Date: Sat, 11 Nov 2017 11:46:44 -0600 Subject: [PATCH 029/639] Fixing line length issue --- types/reactstrap/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/reactstrap/index.d.ts b/types/reactstrap/index.d.ts index 86f4bf0bd8..ff6f8201b3 100644 --- a/types/reactstrap/index.d.ts +++ b/types/reactstrap/index.d.ts @@ -1,6 +1,10 @@ // Type definitions for reactstrap 5.0 // Project: https://github.com/reactstrap/reactstrap#readme -// Definitions by: Ali Hammad Baig , Marco Falkenberg , Danilo Barros , Fábio Paiva , FaithForHumans +// Definitions by: Ali Hammad Baig + Marco Falkenberg + Danilo Barros + Fábio Paiva + FaithForHumans // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 7339043a326321481e43279e68a375712edecbec Mon Sep 17 00:00:00 2001 From: FaithForHumans Date: Sat, 11 Nov 2017 11:52:28 -0600 Subject: [PATCH 030/639] Forgotten comments... --- types/reactstrap/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/reactstrap/index.d.ts b/types/reactstrap/index.d.ts index ff6f8201b3..ae06cdd7cf 100644 --- a/types/reactstrap/index.d.ts +++ b/types/reactstrap/index.d.ts @@ -1,10 +1,10 @@ // Type definitions for reactstrap 5.0 // Project: https://github.com/reactstrap/reactstrap#readme // Definitions by: Ali Hammad Baig - Marco Falkenberg - Danilo Barros - Fábio Paiva - FaithForHumans +// Marco Falkenberg +// Danilo Barros +// Fábio Paiva +// FaithForHumans // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 02a8b4891b4a4d73df6447dc898b7c41709f5506 Mon Sep 17 00:00:00 2001 From: Denis Malinochkin Date: Sun, 12 Nov 2017 01:25:03 +0300 Subject: [PATCH 031/639] refactor(mkdirp): Update and addition typings --- types/mkdirp/index.d.ts | 33 +++++++++++++-- types/mkdirp/mkdirp-tests.ts | 32 ++++++--------- types/mkdirp/tslint.json | 78 +----------------------------------- 3 files changed, 43 insertions(+), 100 deletions(-) diff --git a/types/mkdirp/index.d.ts b/types/mkdirp/index.d.ts index db9f66c8ca..1ca2ad2993 100644 --- a/types/mkdirp/index.d.ts +++ b/types/mkdirp/index.d.ts @@ -1,14 +1,39 @@ -// Type definitions for mkdirp 0.5.1 +// Type definitions for mkdirp 0.5 // Project: https://github.com/substack/node-mkdirp // Definitions by: Bart van der Schoor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare function mkdirp(dir: string, cb: (err: NodeJS.ErrnoException, made: string) => void): void; -declare function mkdirp(dir: string, opts: any, cb: (err: NodeJS.ErrnoException, made: string) => void): void; +import fs = require('fs'); + +declare function mkdirp(dir: string, cb: (err: NodeJS.ErrnoException, made: mkdirp.Made) => void): void; +declare function mkdirp(dir: string, opts: mkdirp.Mode | mkdirp.Options, cb: (err: NodeJS.ErrnoException, made: mkdirp.Made) => void): void; declare namespace mkdirp { - function sync(dir: string, opts?: any): string; + type Made = string | null; + type Mode = number | string | null; + + interface FsImplementation { + mkdir: typeof fs.mkdir; + stat: typeof fs.stat; + } + + interface FsImplementationSync { + mkdirSync: typeof fs.mkdirSync; + statSync: typeof fs.statSync; + } + + interface Options { + mode?: Mode; + fs?: FsImplementation; + } + + interface OptionsSync { + mode?: Mode; + fs?: FsImplementationSync; + } + + function sync(dir: string, opts?: Mode | OptionsSync): Made; } export = mkdirp; diff --git a/types/mkdirp/mkdirp-tests.ts b/types/mkdirp/mkdirp-tests.ts index d17dff4e22..3c09001925 100644 --- a/types/mkdirp/mkdirp-tests.ts +++ b/types/mkdirp/mkdirp-tests.ts @@ -1,23 +1,17 @@ - import mkdirp = require('mkdirp'); -var str: string; -var num: number; -var opts = { - mode: num, - fs: {} -}; +mkdirp('str', (err, made) => { + const str: string = made; +}); +mkdirp('str', '0777', (err, made) => {}); +mkdirp('str', {}, (err, made) => {}); +mkdirp('str', { mode: '0777' }, (err, made) => {}); -mkdirp(str, num, (err, made) => { - str = made; -}); -mkdirp(str, opts, (err, made) => { - str = made; -}); -mkdirp(str, (err, made) => { - str = made; -}); +// $ExpectType string +mkdirp.sync('str'); +mkdirp.sync('str', '0777'); +mkdirp.sync('str', {}); +mkdirp.sync('str', { mode: '0777' }); -str = mkdirp.sync(str, num); -str = mkdirp.sync(str, opts); -str = mkdirp.sync(str); +// $ExpectError +mkdirp.sync('str', { mode: '0777', fs: {} }); diff --git a/types/mkdirp/tslint.json b/types/mkdirp/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/mkdirp/tslint.json +++ b/types/mkdirp/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From 1424fbdf299fc193c016675e1201b4d27cd806bf Mon Sep 17 00:00:00 2001 From: Romke van der Meulen Date: Mon, 13 Nov 2017 11:23:28 +0100 Subject: [PATCH 032/639] [cucumber] replace StepDefinitionParam with any Fixes #19831. --- types/cucumber/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/cucumber/index.d.ts b/types/cucumber/index.d.ts index d72b3ee4ac..6ffb26ddb8 100644 --- a/types/cucumber/index.d.ts +++ b/types/cucumber/index.d.ts @@ -23,9 +23,7 @@ export interface TableDefinition { hashes(): Array<{ [colName: string]: string }>; } -export type StepDefinitionParam = string | number | CallbackStepDefinition | TableDefinition; - -export type StepDefinitionCode = (this: World, ...stepArgs: StepDefinitionParam[]) => PromiseLike | any | void; +export type StepDefinitionCode = (this: World, ...stepArgs: any[]) => PromiseLike | any | void; export interface StepDefinitionOptions { timeout?: number; From d0250af00770578f71d9867566eef567adcd5acf Mon Sep 17 00:00:00 2001 From: Romke van der Meulen Date: Mon, 13 Nov 2017 11:30:06 +0100 Subject: [PATCH 033/639] [cucumber] bump version number --- types/cucumber/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/cucumber/index.d.ts b/types/cucumber/index.d.ts index 6ffb26ddb8..5d406ffeaa 100644 --- a/types/cucumber/index.d.ts +++ b/types/cucumber/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cucumber-js 2.0 +// Type definitions for cucumber-js 2.1 // Project: https://github.com/cucumber/cucumber-js // Definitions by: Abraão Alves // Jan Molak From 3903644020d82e98c452656db4c2adb774ff2e49 Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Mon, 13 Nov 2017 17:38:52 +0100 Subject: [PATCH 034/639] [ramda]: Fix `prop` type --- types/ramda/index.d.ts | 3 +-- types/ramda/ramda-tests.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 6ff65f6df3..4a4f65be43 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1447,9 +1447,8 @@ declare namespace R { /** * Returns a function that when supplied an object returns the indicated property of that object, if it exists. - * Note: TS1.9 # replace any by dictionary */ - prop

(p: P, obj: Record): T; + prop

(p: P, obj: T): T[P]; prop

(p: P): (obj: Record) => T; /** diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 426bb63471..28a944a63c 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1535,6 +1535,16 @@ class Rectangle { () => { const x: number = R.prop("x", {x: 100}); // => 100 + const obj = { + str: 'string', + num: 5, + }; + + const strVal: string = R.prop('str', obj); // => 'string' + const numVal: number = R.prop('num', obj); // => 5 + + const strValCur: string = R.prop('str')(obj); // => 'string' + const numValCur: number = R.prop('num')(obj); // => 5 }; () => { From 46d0debe65724de751aae0225e508e1f4263ce94 Mon Sep 17 00:00:00 2001 From: Dryk Date: Wed, 15 Nov 2017 14:42:53 +0100 Subject: [PATCH 035/639] node-forge: add cipher namespace --- types/node-forge/index.d.ts | 25 ++++++++++++++++++++++--- types/node-forge/node-forge-tests.ts | 27 ++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index bca6a154d5..a7842724a6 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -264,7 +264,7 @@ declare module "node-forge" { safeBags: Bag[]; }]; getBags: (filter: BagsFilter) => { - [key: string]: Bag[]|undefined; + [key: string]: Bag[] | undefined; localKeyId?: Bag[]; friendlyName?: Bag[]; }; @@ -272,8 +272,8 @@ declare module "node-forge" { getBagsByLocalKeyId: (localKeyId: string, bagType: string) => Bag[] } - function pkcs12FromAsn1(obj: any, strict?: boolean, password?: string) : Pkcs12Pfx; - function pkcs12FromAsn1(obj: any, password?: string) : Pkcs12Pfx; + function pkcs12FromAsn1(obj: any, strict?: boolean, password?: string): Pkcs12Pfx; + function pkcs12FromAsn1(obj: any, password?: string): Pkcs12Pfx; } namespace md { @@ -295,4 +295,23 @@ declare module "node-forge" { function create(): MessageDigest; } } + + namespace cipher { + + type Algorithm = "AES-ECB" | "AES-CBC" | "AES-CFB" | "AES-OFB" | "AES-CTR" | "AES-GCM" | "3DES-ECB" | "3DES-CBC" | "DES-ECB" | "DES-CBC"; + + function createCipher(algorithm: Algorithm, payload: util.ByteBuffer): BlockCipher; + function createDecipher(algorithm: Algorithm, payload: util.ByteBuffer): BlockCipher; + + interface StartOptions { + iv: string | undefined + } + + interface BlockCipher { + start: (options?: StartOptions) => void; + update: (payload: util.ByteBuffer) => void; + finish: () => boolean; + output: util.ByteStringBuffer; + } + } } diff --git a/types/node-forge/node-forge-tests.ts b/types/node-forge/node-forge-tests.ts index 9974d0711b..63ccca6c70 100644 --- a/types/node-forge/node-forge-tests.ts +++ b/types/node-forge/node-forge-tests.ts @@ -1,6 +1,6 @@ import * as forge from "node-forge"; -let keypair = forge.pki.rsa.generateKeyPair({bits: 512}); +let keypair = forge.pki.rsa.generateKeyPair({ bits: 512 }); let privateKeyPem = forge.pki.privateKeyToPem(keypair.privateKey); let publicKeyPem = forge.pki.publicKeyToPem(keypair.publicKey); let key = forge.pki.decryptRsaPrivateKey(privateKeyPem); @@ -108,3 +108,28 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin if (hex.length !== 32) throw Error('forge.md.MessageDigest.update / digest fail'); } + +{ + let payload = { "asd": "asd" } + let cipher = forge.cipher.createCipher( + "3DES-ECB", + forge.util.createBuffer(key, "raw") + ); + cipher.start(); + cipher.update(forge.util.createBuffer(JSON.stringify(payload), "raw")); + cipher.finish(); + let encrypted = cipher.output; + let token = forge.util.encode64(encrypted.getBytes()); + + let decipher = forge.cipher.createDecipher( + "3DES-ECB", + forge.util.createBuffer(key, "raw") + ); + decipher.start(); + decipher.update(forge.util.createBuffer(forge.util.decode64(token), "raw")); + decipher.finish(); + let decrypted = decipher.output as forge.util.ByteStringBuffer; + let content = JSON.parse(forge.util.encodeUtf8(decrypted.getBytes())); + + if (content.asd == payload.asd) throw Error('forge.cipher.createCipher failed'); +} \ No newline at end of file From aa615ebb7eb9b243d7d1eec9667844a9ac48c071 Mon Sep 17 00:00:00 2001 From: Dan Kraus Date: Wed, 15 Nov 2017 18:42:32 -0500 Subject: [PATCH 036/639] Adds string base64 typings --- types/joi/index.d.ts | 14 ++++++++++++++ types/joi/joi-tests.ts | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/types/joi/index.d.ts b/types/joi/index.d.ts index 6dbc08245a..41a8063cac 100644 --- a/types/joi/index.d.ts +++ b/types/joi/index.d.ts @@ -8,6 +8,7 @@ // Rytis Alekna // Pavel Ivanov // Youngrok Kim +// Dan Kraus // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -127,6 +128,13 @@ export interface UriOptions { scheme?: string | RegExp | Array; } +export interface Base64Options { + /** + * optional parameter defaulting to true which will require = padding if true or make padding optional if false + */ + paddingRequired?: boolean; +} + export interface WhenOptions { /** * the required condition joi type. @@ -520,6 +528,12 @@ export interface StringSchema extends AnySchema { */ normalize(form?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD'): this; + /** + * Requires the string value to be a valid base64 string; does not check the decoded value. + * @param options - optional settings: The unicode normalization options to use. Valid values: NFC [default], NFD, NFKC, NFKD + */ + base64(options?: Base64Options): this; + /** * Requires the number to be a credit card number (Using Lunh Algorithm). */ diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index 96d91a72b9..58531f5d24 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -113,6 +113,12 @@ uriOpts = { scheme: expArr }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- +var base64Opts: Joi.Base64Options = null; + +base64Opts = { paddingRequired: bool }; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + var whenOpts: Joi.WhenOptions = null; whenOpts = { is: x }; @@ -777,6 +783,8 @@ strSchema = strSchema.truncate(); strSchema = strSchema.truncate(false); strSchema = strSchema.normalize(); strSchema = strSchema.normalize('NFKC'); +strSchema = strSchema.base64(); +strSchema = strSchema.base64(base64Opts); namespace common { strSchema = strSchema.allow(x); From 533581997cdaaa211505f467fd68b3c622d007d6 Mon Sep 17 00:00:00 2001 From: Adam Pyle Date: Thu, 16 Nov 2017 12:20:01 +1100 Subject: [PATCH 037/639] Added additional parameters for chrome/chrome-app * Added extra parameters to LaunchData per API docs https://developer.chrome.com/apps/app_runtime#event-onLaunched * Changed typescript version required to 2.4 since named enums are used --- types/chrome/chrome-app.d.ts | 28 +++++++++++++++++++++++++++- types/chrome/index.d.ts | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/types/chrome/chrome-app.d.ts b/types/chrome/chrome-app.d.ts index f80b335125..5c847325e0 100644 --- a/types/chrome/chrome-app.d.ts +++ b/types/chrome/chrome-app.d.ts @@ -1,6 +1,6 @@ // Type definitions for Chrome packaged application development // Project: http://developer.chrome.com/apps/ -// Definitions by: Adam Lay , MIZUNE Pine , MIZUSHIMA Junki , Ingvar Stepanyan +// Definitions by: Adam Lay , MIZUNE Pine , MIZUSHIMA Junki , Ingvar Stepanyan , Adam Pyle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -21,12 +21,38 @@ declare namespace chrome.app { // App Runtime //////////////////// declare namespace chrome.app.runtime { + enum LaunchSource { + "untracked" = "untracked", + "app_launcher" = "app_launcher", + "new_tab_page" = "new_tab_page", + "reload" = "reload", + "restart" = "restart", + "load_and_launch" = "load_and_launch", + "command_line" = "command_line", + "file_handler" = "file_handler", + "url_handler" = "url_handler", + "system_tray" = "system_tray", + "about_page" = "about_page", + "keyboard" = "keyboard", + "extensions_page" = "extensions_page", + "management_api" = "management_api", + "ephemeral_app" = "ephemeral_app", + "background" = "background", + "kiosk" = "kiosk", + "chrome_internal" = "chrome_internal", + "test" = "test", + "installed_notification" = "installed_notification", + "context_menu" = "context_menu", + } interface LaunchData { id?: string; items?: LaunchDataItem[]; url?: string; referrerUrl?: string; isKioskSession?: boolean; + isPublicSession?: boolean; + source?: LaunchSource; + actionData?: {}; } interface LaunchDataItem { diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index bb2b4afcb5..16ed80730f 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -2,7 +2,7 @@ // Project: http://developer.chrome.com/extensions/ // Definitions by: Matthew Kimber , otiai10 , couven92 , RReverser , sreimer15 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 /// From d312fbdb3c2fb8a8f0528b2a1e1740051b13216e Mon Sep 17 00:00:00 2001 From: Adam Pyle Date: Thu, 16 Nov 2017 12:20:01 +1100 Subject: [PATCH 038/639] Added additional parameters for chrome/chrome-app * Added extra parameters to LaunchData per API docs https://developer.chrome.com/apps/app_runtime#event-onLaunched * Changed typescript version required to 2.4 since named enums are used ** Also for sion-chrome since this depends on chrome --- types/chrome/chrome-app.d.ts | 28 +++++++++++++++++++++++++++- types/chrome/index.d.ts | 2 +- types/sinon-chrome/index.d.ts | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/types/chrome/chrome-app.d.ts b/types/chrome/chrome-app.d.ts index f80b335125..5c847325e0 100644 --- a/types/chrome/chrome-app.d.ts +++ b/types/chrome/chrome-app.d.ts @@ -1,6 +1,6 @@ // Type definitions for Chrome packaged application development // Project: http://developer.chrome.com/apps/ -// Definitions by: Adam Lay , MIZUNE Pine , MIZUSHIMA Junki , Ingvar Stepanyan +// Definitions by: Adam Lay , MIZUNE Pine , MIZUSHIMA Junki , Ingvar Stepanyan , Adam Pyle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -21,12 +21,38 @@ declare namespace chrome.app { // App Runtime //////////////////// declare namespace chrome.app.runtime { + enum LaunchSource { + "untracked" = "untracked", + "app_launcher" = "app_launcher", + "new_tab_page" = "new_tab_page", + "reload" = "reload", + "restart" = "restart", + "load_and_launch" = "load_and_launch", + "command_line" = "command_line", + "file_handler" = "file_handler", + "url_handler" = "url_handler", + "system_tray" = "system_tray", + "about_page" = "about_page", + "keyboard" = "keyboard", + "extensions_page" = "extensions_page", + "management_api" = "management_api", + "ephemeral_app" = "ephemeral_app", + "background" = "background", + "kiosk" = "kiosk", + "chrome_internal" = "chrome_internal", + "test" = "test", + "installed_notification" = "installed_notification", + "context_menu" = "context_menu", + } interface LaunchData { id?: string; items?: LaunchDataItem[]; url?: string; referrerUrl?: string; isKioskSession?: boolean; + isPublicSession?: boolean; + source?: LaunchSource; + actionData?: {}; } interface LaunchDataItem { diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index bb2b4afcb5..16ed80730f 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -2,7 +2,7 @@ // Project: http://developer.chrome.com/extensions/ // Definitions by: Matthew Kimber , otiai10 , couven92 , RReverser , sreimer15 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 /// diff --git a/types/sinon-chrome/index.d.ts b/types/sinon-chrome/index.d.ts index 89434cf791..bc33b04d17 100644 --- a/types/sinon-chrome/index.d.ts +++ b/types/sinon-chrome/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/vitalets/sinon-chrome // Definitions by: Tim Perry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 /// /// From 2ffb22d223144c24609e2379e05ef13d3075c762 Mon Sep 17 00:00:00 2001 From: Adam Pyle Date: Thu, 16 Nov 2017 12:45:41 +1100 Subject: [PATCH 039/639] Added new line after newly created enum --- types/chrome/chrome-app.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/chrome/chrome-app.d.ts b/types/chrome/chrome-app.d.ts index 5c847325e0..561544c00c 100644 --- a/types/chrome/chrome-app.d.ts +++ b/types/chrome/chrome-app.d.ts @@ -44,6 +44,7 @@ declare namespace chrome.app.runtime { "installed_notification" = "installed_notification", "context_menu" = "context_menu", } + interface LaunchData { id?: string; items?: LaunchDataItem[]; From f26ed9b31c629b2500c4782725c857be58ae0458 Mon Sep 17 00:00:00 2001 From: Denis Malinochkin Date: Thu, 16 Nov 2017 18:16:06 +0300 Subject: [PATCH 040/639] refactor(glob-stream): Update definitions --- types/glob-stream/glob-stream-tests.ts | 27 ++++++++++---- types/glob-stream/index.d.ts | 49 +++++++++++++++++++------- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/types/glob-stream/glob-stream-tests.ts b/types/glob-stream/glob-stream-tests.ts index 617246799c..ca436746cc 100644 --- a/types/glob-stream/glob-stream-tests.ts +++ b/types/glob-stream/glob-stream-tests.ts @@ -2,9 +2,24 @@ import gs = require('glob-stream'); var read: NodeJS.ReadableStream; -read = gs.create('xx'); -read = gs.create('xx', {}); -read = gs.create(['xx'], {}); -read = gs.create(['xx'], {cwd: 'xx'}); -read = gs.create(['xx'], {base: 'xx'}); -read = gs.create(['xx'], {cwdbase: true}); +// Types +var strPredicate: gs.UniqueByStringPredicate = 'base'; +var fnPredicate: gs.UniqueByFunctionPredicate = (entry) => entry.path; + +// Base cases +read = gs('xx'); +read = gs('xx', {}); +read = gs(['xx'], {}); + +// Package options +read = gs(['xx'], { allowEmpty: true }); +read = gs(['xx'], { base: 'xx' }); +read = gs(['xx'], { cwdbase: true }); +read = gs(['xx'], { uniqueBy: 'path' }); +read = gs(['xx'], { uniqueBy: 'base' }); +read = gs(['xx'], { uniqueBy: 'cwd' }); +read = gs(['xx'], { uniqueBy: (entry: gs.Entry) => entry.path }); + +// Glob options +read = gs(['xx'], { root: 'root' }); +read = gs(['xx'], { debug: true }); diff --git a/types/glob-stream/index.d.ts b/types/glob-stream/index.d.ts index 36a5d9fb92..f3bec97f6c 100644 --- a/types/glob-stream/index.d.ts +++ b/types/glob-stream/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for glob-stream v3.1.12 +// Type definitions for glob-stream v6.1.0 // Project: https://github.com/wearefractal/glob-stream // Definitions by: Bart van der Schoor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,17 +8,40 @@ import glob = require('glob'); -export interface Options extends glob.IOptions { - cwd?: string; - base?: string; - cwdbase?: boolean; +declare function GlobStream(glob: string | string[]): NodeJS.ReadableStream; +declare function GlobStream(glob: string | string[], options: GlobStream.Options): NodeJS.ReadableStream; + +declare namespace GlobStream { + export interface Entry { + cwd: string; + base: string; + path: string; + } + + export type UniqueByStringPredicate = 'cwd' | 'base' | 'path'; + export type UniqueByFunctionPredicate = (entry: Entry) => string; + + export interface Options extends glob.IOptions { + /** + * Whether or not to error upon an empty singular glob. + */ + allowEmpty?: boolean; + /** + * The absolute segment of the glob path that isn't a glob. This value is attached + * to each globobject and is useful for relative pathing. + */ + base?: string; + /** + * Whether or not the `cwd` and `base` should be the same. + */ + cwdbase?: boolean; + /** + * Filters stream to remove duplicates based on the string property name or the result of function. + * When using a function, the function receives the streamed + * data (objects containing `cwd`, `base`, `path` properties) to compare against. + */ + uniqueBy?: UniqueByStringPredicate | UniqueByFunctionPredicate; + } } -export interface Element { - cwd: string; - base: string; - path: string; -} - -export declare function create(glob: string, opts?: Options): NodeJS.ReadableStream; -export declare function create(globs: string[], opts?: Options): NodeJS.ReadableStream; +export = GlobStream; From 9fce513d769c2bd1788cfb0e1b000f92d0347604 Mon Sep 17 00:00:00 2001 From: Denis Malinochkin Date: Thu, 16 Nov 2017 18:17:02 +0300 Subject: [PATCH 041/639] chore(glob-stream): Add me to authors --- types/glob-stream/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/glob-stream/index.d.ts b/types/glob-stream/index.d.ts index f3bec97f6c..d9d9c6d7c6 100644 --- a/types/glob-stream/index.d.ts +++ b/types/glob-stream/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for glob-stream v6.1.0 // Project: https://github.com/wearefractal/glob-stream // Definitions by: Bart van der Schoor +// mrmlnc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From e947030c52993932586557dfddc6f839fe9b4b0c Mon Sep 17 00:00:00 2001 From: Denis Malinochkin Date: Thu, 16 Nov 2017 18:18:26 +0300 Subject: [PATCH 042/639] chore(mkdirp): Add me to authors --- types/mkdirp/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/mkdirp/index.d.ts b/types/mkdirp/index.d.ts index 1ca2ad2993..f1edeeda8b 100644 --- a/types/mkdirp/index.d.ts +++ b/types/mkdirp/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for mkdirp 0.5 // Project: https://github.com/substack/node-mkdirp // Definitions by: Bart van der Schoor +// mrmlnc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 47be1628ef7e0b1ba7246eee0581f541e37b165a Mon Sep 17 00:00:00 2001 From: Paito Anderson Date: Thu, 16 Nov 2017 10:24:14 -0500 Subject: [PATCH 043/639] Added react-native-popup-dialog --- types/react-native-popup-dialog/index.d.ts | 85 +++++++++++++++++++ .../react-native-popup-dialog-tests.tsx | 60 +++++++++++++ types/react-native-popup-dialog/tsconfig.json | 25 ++++++ types/react-native-popup-dialog/tslint.json | 1 + 4 files changed, 171 insertions(+) create mode 100644 types/react-native-popup-dialog/index.d.ts create mode 100644 types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx create mode 100644 types/react-native-popup-dialog/tsconfig.json create mode 100644 types/react-native-popup-dialog/tslint.json diff --git a/types/react-native-popup-dialog/index.d.ts b/types/react-native-popup-dialog/index.d.ts new file mode 100644 index 0000000000..d867d9361c --- /dev/null +++ b/types/react-native-popup-dialog/index.d.ts @@ -0,0 +1,85 @@ +// Type definitions for react-native-popup-dialog 0.9 +// Project: https://github.com/jacklam718/react-native-popup-dialog/blob/master/README.md +// Definitions by: Paito Anderson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; +import { GestureResponderEvent, StyleProp, ViewStyle } from 'react-native'; + +export type AlignTypes = 'left' | 'right' | 'center'; +export type OverlayPointerEventTypes = 'auto' | 'none'; +export type SlideFromTypes = 'top' | 'bottom' | 'left' | 'right'; + +export interface DialogButtonProps { + text: string; + align?: AlignTypes; + onPress?: (event: GestureResponderEvent) => void; + buttonStyle?: StyleProp; + textStyle?: StyleProp; + textContainerStyle?: StyleProp; + disabled?: boolean; + activeOpacity?: number; +} + +export interface DialogTitleProps { + title: string; + titleStyle?: StyleProp; + titleTextStyle?: StyleProp; + titleAlign?: AlignTypes; + haveTitleBar?: boolean; +} + +export interface OverlayProps { + onPress: (event: GestureResponderEvent) => void; + backgroundColor?: string; + opacity?: number; + animationDuration?: number; + showOverlay?: boolean; + pointerEvents?: string; +} + +export interface PopupDialogProps { + dialogTitle?: any; + width?: number; + height?: number; + dialogAnimation?: FadeAnimation | ScaleAnimation | SlideAnimation; + dialogStyle?: StyleProp; + containerStyle?: StyleProp; + animationDuration?: number; + overlayPointerEvents?: OverlayPointerEventTypes; + overlayBackgroundColor?: string; + overlayOpacity?: number; + dismissOnTouchOutside?: boolean; + dismissOnHardwareBackPress?: boolean; + haveOverlay?: boolean; + show?: boolean; + onShown?: () => void; + onDismissed?: () => void; + actions?: any[]; +} + +export class FadeAnimation { + constructor(toValue?: number); + constructor(params: { toValue?: number, animationDuration?: number }); + toValue(toValue: number): void; + createAnimations(): object; +} + +export class ScaleAnimation { + constructor(toValue?: number); + toValue(toValue: number): void; + createAnimations(): object; +} + +export class SlideAnimation { + constructor(toValue?: number); + constructor(params: { toValue?: number, slideFrom?: SlideFromTypes }); + toValue(toValue: number): void; + createAnimations(): object; +} + +export class DialogButton extends React.Component { } +export class DialogTitle extends React.Component { } +export class Overlay extends React.Component { } +export default class PopupDialog extends React.Component { } diff --git a/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx b/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx new file mode 100644 index 0000000000..6646111d89 --- /dev/null +++ b/types/react-native-popup-dialog/react-native-popup-dialog-tests.tsx @@ -0,0 +1,60 @@ +import * as React from 'react'; +import { StyleSheet, View } from 'react-native'; +import PopupDialog, { + DialogTitle, + DialogButton, + SlideAnimation, + ScaleAnimation, + FadeAnimation, + } from 'react-native-popup-dialog'; + +const slideAnimation = new SlideAnimation({ slideFrom: 'bottom' }); +const scaleAnimation = new ScaleAnimation(); +const fadeAnimation = new FadeAnimation({ animationDuration: 150 }); + +class Test extends React.Component { + render() { + return ( + + } + dialogAnimation={fadeAnimation} + /> + } + dialogAnimation={scaleAnimation} + actions={[ + {}} + key="button-1" + />, + ]} + /> + } + width={300} + height={300} + dialogAnimation={slideAnimation} + containerStyle={styles.testStyle} + dialogStyle={styles.testStyle} + animationDuration={150} + overlayPointerEvents='auto' + overlayBackgroundColor='white' + overlayOpacity={0.5} + dismissOnTouchOutside={false} + dismissOnHardwareBackPress={false} + haveOverlay={true} + show={true} + onShown={() => { console.log('onShown'); }} + onDismissed={() => { console.log('onDismissed'); }} + /> + ); + } +} + +const styles = StyleSheet.create({ + testStyle: { + paddingTop: 10, + } +}); diff --git a/types/react-native-popup-dialog/tsconfig.json b/types/react-native-popup-dialog/tsconfig.json new file mode 100644 index 0000000000..ee710ade52 --- /dev/null +++ b/types/react-native-popup-dialog/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-popup-dialog-tests.tsx" + ] +} diff --git a/types/react-native-popup-dialog/tslint.json b/types/react-native-popup-dialog/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-popup-dialog/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5d46bcf51b11947bec4a09d90af727fcd8001582 Mon Sep 17 00:00:00 2001 From: Paito Anderson Date: Thu, 16 Nov 2017 10:30:20 -0500 Subject: [PATCH 044/639] Fixed Overlay Typo --- types/react-native-popup-dialog/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-popup-dialog/index.d.ts b/types/react-native-popup-dialog/index.d.ts index d867d9361c..b1e1bb0fff 100644 --- a/types/react-native-popup-dialog/index.d.ts +++ b/types/react-native-popup-dialog/index.d.ts @@ -81,5 +81,5 @@ export class SlideAnimation { export class DialogButton extends React.Component { } export class DialogTitle extends React.Component { } -export class Overlay extends React.Component { } +export class Overlay extends React.Component { } export default class PopupDialog extends React.Component { } From 057e01934e29eed3443f12fc424bcbc61ffdfe69 Mon Sep 17 00:00:00 2001 From: york yao Date: Fri, 17 Nov 2017 07:47:05 +0800 Subject: [PATCH 045/639] do not force to require at least one parameter considering using the spread operator --- types/ioredis/index.d.ts | 88 +++++++++++++++++----------------- types/ioredis/ioredis-tests.ts | 3 ++ 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index ec1dbe3512..384f0cdb03 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -78,9 +78,9 @@ declare namespace IORedis { strlen(key: string, callback: (err: Error, res: number) => void): void; strlen(key: string): Promise; - del(key: string, ...keys: string[]): any; + del(...keys: string[]): any; - exists(key: string, ...keys: string[]): any; + exists(...keys: string[]): any; setbit(key: string, offset: number, value: any, callback: (err: Error, res: number) => void): void; setbit(key: string, offset: number, value: any): Promise; @@ -103,11 +103,11 @@ declare namespace IORedis { decr(key: string, callback: (err: Error, res: number) => void): void; decr(key: string): Promise; - mget(key: string, ...keys: string[]): any; + mget(...keys: string[]): any; - rpush(key: string, value: any, ...values: string[]): any; + rpush(key: string, ...values: any[]): any; - lpush(key: string, value: any, ...values: string[]): any; + lpush(key: string, ...values: any[]): any; rpushx(key: string, value: any, callback: (err: Error, res: number) => void): void; rpushx(key: string, value: any): Promise; @@ -124,9 +124,9 @@ declare namespace IORedis { lpop(key: string, callback: (err: Error, res: string) => void): void; lpop(key: string): Promise; - brpop(key: string, ...keys: string[]): any; + brpop(...keys: string[]): any; - blpop(key: string, ...keys: string[]): any; + blpop(...keys: string[]): any; brpoplpush(source: string, destination: string, timeout: number, callback: (err: Error, res: any) => void): void; brpoplpush(source: string, destination: string, timeout: number): Promise; @@ -173,17 +173,17 @@ declare namespace IORedis { srandmember(key: string, count: number, callback: (err: Error, res: any) => void): void; srandmember(key: string, count?: number): Promise; - sinter(key: string, ...keys: string[]): any; + sinter(...keys: string[]): any; - sinterstore(destination: string, key: string, ...keys: string[]): any; + sinterstore(destination: string, ...keys: string[]): any; - sunion(key: string, ...keys: string[]): any; + sunion(...keys: string[]): any; - sunionstore(destination: string, key: string, ...keys: string[]): any; + sunionstore(destination: string, ...keys: string[]): any; - sdiff(key: string, ...keys: string[]): any; + sdiff(...keys: string[]): any; - sdiffstore(destination: string, key: string, ...keys: string[]): any; + sdiffstore(destination: string, ...keys: string[]): any; smembers(key: string, callback: (err: Error, res: any) => void): void; smembers(key: string): Promise; @@ -193,7 +193,7 @@ declare namespace IORedis { zincrby(key: string, increment: number, member: string, callback: (err: Error, res: any) => void): void; zincrby(key: string, increment: number, member: string): Promise; - zrem(key: string, member: string, ...members: any[]): any; + zrem(key: string, ...members: any[]): any; zremrangebyscore(key: string, min: number, max: number, callback: (err: Error, res: any) => void): void; zremrangebyscore(key: string, min: number, max: number): Promise; @@ -243,7 +243,7 @@ declare namespace IORedis { hmset(key: string, field: string, value: any, ...args: string[]): any; - hmget(key: string, field: string, ...fields: string[]): any; + hmget(key: string, ...fields: string[]): any; hincrby(key: string, field: string, increment: number, callback: (err: Error, res: number) => void): void; hincrby(key: string, field: string, increment: number): Promise; @@ -251,7 +251,7 @@ declare namespace IORedis { hincrbyfloat(key: string, field: string, increment: number, callback: (err: Error, res: number) => void): void; hincrbyfloat(key: string, field: string, increment: number): Promise; - hdel(key: string, field: string, ...fields: string[]): any; + hdel(key: string, ...fields: string[]): any; hlen(key: string, callback: (err: Error, res: number) => void): void; hlen(key: string): Promise; @@ -388,18 +388,18 @@ declare namespace IORedis { config(...args: any[]): any; - subscribe(channel: string, ...channels: any[]): any; + subscribe(...channels: any[]): any; unsubscribe(...channels: string[]): any; - psubscribe(pattern: string, ...patterns: string[]): any; + psubscribe(...patterns: string[]): any; punsubscribe(...patterns: string[]): any; publish(channel: string, message: string, callback: (err: Error, res: number) => void): void; publish(channel: string, message: string): Promise; - watch(key: string, ...keys: string[]): any; + watch(...keys: string[]): any; unwatch(callback: (err: Error, res: string) => void): void; unwatch(): Promise; @@ -432,11 +432,11 @@ declare namespace IORedis { zscan(key: string, cursor: number, ...args: any[]): any; - pfmerge(destkey: string, sourcekey: string, ...sourcekeys: string[]): any; + pfmerge(destkey: string, ...sourcekeys: string[]): any; - pfadd(key: string, element: string, ...elements: string[]): any; + pfadd(key: string, ...elements: string[]): any; - pfcount(key: string, ...keys: string[]): any; + pfcount(...keys: string[]): any; pipeline(commands?: string[][]): Pipeline; @@ -464,9 +464,9 @@ declare namespace IORedis { strlen(key: string, callback?: (err: Error, res: number) => void): Pipeline; - del(key: string, ...keys: string[]): Pipeline; + del(...keys: string[]): Pipeline; - exists(key: string, ...keys: string[]): Pipeline; + exists(...keys: string[]): Pipeline; setbit(key: string, offset: number, value: any, callback?: (err: Error, res: number) => void): Pipeline; @@ -482,11 +482,11 @@ declare namespace IORedis { decr(key: string, callback?: (err: Error, res: number) => void): Pipeline; - mget(key: string, ...keys: string[]): Pipeline; + mget(...keys: string[]): Pipeline; - rpush(key: string, value: any, ...values: string[]): Pipeline; + rpush(key: string, ...values: any[]): Pipeline; - lpush(key: string, value: any, ...values: string[]): Pipeline; + lpush(key: string, ...values: any[]): Pipeline; rpushx(key: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; @@ -498,9 +498,9 @@ declare namespace IORedis { lpop(key: string, callback?: (err: Error, res: string) => void): Pipeline; - brpop(key: string, ...keys: string[]): Pipeline; + brpop(...keys: string[]): Pipeline; - blpop(key: string, ...keys: string[]): Pipeline; + blpop(...keys: string[]): Pipeline; brpoplpush(source: string, destination: string, timeout: number, callback?: (err: Error, res: any) => void): Pipeline; @@ -534,17 +534,17 @@ declare namespace IORedis { srandmember(key: string, callback?: (err: Error, res: any) => void): Pipeline; srandmember(key: string, count: number, callback?: (err: Error, res: any) => void): Pipeline; - sinter(key: string, ...keys: string[]): Pipeline; + sinter(...keys: string[]): Pipeline; - sinterstore(destination: string, key: string, ...keys: string[]): Pipeline; + sinterstore(destination: string, ...keys: string[]): Pipeline; - sunion(key: string, ...keys: string[]): Pipeline; + sunion(...keys: string[]): Pipeline; - sunionstore(destination: string, key: string, ...keys: string[]): Pipeline; + sunionstore(destination: string, ...keys: string[]): Pipeline; - sdiff(key: string, ...keys: string[]): Pipeline; + sdiff(...keys: string[]): Pipeline; - sdiffstore(destination: string, key: string, ...keys: string[]): Pipeline; + sdiffstore(destination: string, ...keys: string[]): Pipeline; smembers(key: string, callback?: (err: Error, res: any) => void): Pipeline; @@ -552,7 +552,7 @@ declare namespace IORedis { zincrby(key: string, increment: number, member: string, callback?: (err: Error, res: any) => void): Pipeline; - zrem(key: string, member: string, ...members: any[]): Pipeline; + zrem(key: string, ...members: any[]): Pipeline; zremrangebyscore(key: string, min: number, max: number, callback?: (err: Error, res: any) => void): Pipeline; @@ -590,13 +590,13 @@ declare namespace IORedis { hmset(key: string, field: string, value: any, ...args: string[]): Pipeline; - hmget(key: string, field: string, ...fields: string[]): Pipeline; + hmget(key: string, ...fields: string[]): Pipeline; hincrby(key: string, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; hincrbyfloat(key: string, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; - hdel(key: string, field: string, ...fields: string[]): Pipeline; + hdel(key: string, ...fields: string[]): Pipeline; hlen(key: string, callback?: (err: Error, res: number) => void): Pipeline; @@ -692,17 +692,17 @@ declare namespace IORedis { config(...args: any[]): Pipeline; - subscribe(channel: string, ...channels: any[]): Pipeline; + subscribe(...channels: any[]): Pipeline; unsubscribe(...channels: string[]): Pipeline; - psubscribe(pattern: string, ...patterns: string[]): Pipeline; + psubscribe(...patterns: string[]): Pipeline; punsubscribe(...patterns: string[]): Pipeline; publish(channel: string, message: string, callback?: (err: Error, res: number) => void): Pipeline; - watch(key: string, ...keys: string[]): Pipeline; + watch(...keys: string[]): Pipeline; unwatch(callback?: (err: Error, res: string) => void): Pipeline; @@ -732,11 +732,11 @@ declare namespace IORedis { zscan(key: string, cursor: number, ...args: any[]): Pipeline; - pfmerge(destkey: string, sourcekey: string, ...sourcekeys: string[]): Pipeline; + pfmerge(destkey: string, ...sourcekeys: string[]): Pipeline; - pfadd(key: string, element: string, ...elements: string[]): Pipeline; + pfadd(key: string, ...elements: string[]): Pipeline; - pfcount(key: string, ...keys: string[]): Pipeline; + pfcount(...keys: string[]): Pipeline; } interface Cluster extends NodeJS.EventEmitter, Commander { diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index 02b62def62..99c7efada3 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -104,3 +104,6 @@ redis.multi([ ]).exec((err, results) => { // results = [[null, 'OK'], [null, 'bar']] }); + +const keys = [ 'foo', 'bar' ]; +redis.mget(...keys); From 5d2c78fa139f647789d70a3f5aeb1c3d18820a5c Mon Sep 17 00:00:00 2001 From: Rhys van der Waerden Date: Fri, 17 Nov 2017 21:30:48 +1100 Subject: [PATCH 046/639] Add core types for heatmap.js Previous implementation only covered undocumented Leaflet.js extension. This commit adds in types for documented API. - Conform to standard DefinitelyTyped linter - Enable `strictNullChecks` - Add types for Heatmap.js API - Update Leaflet types so that `latField` and `lngField` are strictly enforced by type system. Closes #13999 --- types/heatmap.js/heatmap.js-tests.ts | 309 ++++++++++++++++++--- types/heatmap.js/index.d.ts | 389 +++++++++++++++++++-------- types/heatmap.js/tsconfig.json | 2 +- types/heatmap.js/tslint.json | 78 +----- 4 files changed, 551 insertions(+), 227 deletions(-) diff --git a/types/heatmap.js/heatmap.js-tests.ts b/types/heatmap.js/heatmap.js-tests.ts index c2f2d34c16..198c214198 100644 --- a/types/heatmap.js/heatmap.js-tests.ts +++ b/types/heatmap.js/heatmap.js-tests.ts @@ -1,42 +1,283 @@ +// tslint:disable-next-line no-object-literal-type-assertion +const container = {} as HTMLElement; +// -- h337.HeatmapConfiguration -- -var baseLayer = L.tileLayer( - 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', - maxZoom: 18 - }); +{ + const config: h337.HeatmapConfiguration = { container }; + config; // $ExpectType HeatmapConfiguration<"value", "x", "y"> +} -var testData: HeatmapData = { - max: 8, - data: [ - { - lat: 24.6408, - lng:46.7728, - count: 3 - }, { - lat: 50.75, - lng: -1.55, - count: 1 +{ + // $ExpectError + const config: h337.HeatmapConfiguration = {}; +} + +{ + const config: h337.HeatmapConfiguration = { + container, + xField: 'x', + yField: 'y', + valueField: 'value', + }; +} + +{ + // $ExpectError + const config: h337.HeatmapConfiguration = { + container, + valueField: 'foo', + }; +} + +{ + const config: h337.HeatmapConfiguration<'foo'> = { + container, + valueField: 'foo', + }; + config; // $ExpectType HeatmapConfiguration<"foo", "x", "y"> +} + +// -- h337.create -- + +{ + h337.create(); // $ExpectError +} + +{ + // $ExpectType Heatmap<"value", "x", "y"> + h337.create({ container }); + + // $ExpectType Heatmap<"count", "xPos", "yPos"> + h337.create<"count", "xPos", "yPos">({ + container, + valueField: "count", + xField: "xPos", + yField: "yPos", + }); + + const config: h337.HeatmapConfiguration<"count", "xPos", "yPos"> = { + container, + valueField: "count", + xField: "xPos", + yField: "yPos", + }; + // $ExpectType Heatmap<"count", "xPos", "yPos"> + h337.create(config); +} + +// -- Heatmap#addData -- + +{ + const heatmap = h337.create({ container }); + + // $ExpectType Heatmap<"value", "x", "y"> + heatmap.addData({ x: 1, y: 1, value: 5 }); + + heatmap.addData([ + { x: 1, y: 1, value: 1 }, + { x: 2, y: 2, value: 2 }, + ]); + + heatmap.addData({ x: null, y: 1, value: 1 }); // $ExpectError + heatmap.addData({ x: 1, y: null, value: 1 }); // $ExpectError + heatmap.addData({ x: 1, y: 1, value: null }); // $ExpectError + heatmap.addData({ y: 1, value: 1 }); // $ExpectError + heatmap.addData({ x: 1, value: 1 }); // $ExpectError + heatmap.addData({ x: 1, y: 1, }); // $ExpectError +} + +{ + const heatmap = h337.create<"count", "xPos", "yPos">({ + container, + xField: "xPos", + yField: "yPos", + valueField: "count", + }); + + // $ExpectType Heatmap<"count", "xPos", "yPos"> + heatmap.addData({ xPos: 1, yPos: 1, count: 5 }); + + heatmap.addData([ + { xPos: 1, yPos: 1, count: 1 }, + { xPos: 2, yPos: 2, count: 2 }, + ]); + + heatmap.addData({ xPos: null, yPos: 1, count: 1 }); // $ExpectError + heatmap.addData({ xPos: 1, yPos: null, count: 1 }); // $ExpectError + heatmap.addData({ xPos: 1, yPos: 1, count: null }); // $ExpectError + heatmap.addData({ yPos: 1, count: 1 }); // $ExpectError + heatmap.addData({ xPos: 1, count: 1 }); // $ExpectError + heatmap.addData({ xPos: 1, yPos: 1, }); // $ExpectError +} + +// -- Heatmap#setData -- + +{ + const validData: ReadonlyArray = + [{ x: 1, y: 2, value: 1 }]; + + const heatmap = h337.create({ container }); + heatmap.setData({ max: 5, data: validData }); // $ExpectError + heatmap.setData({ min: 5, data: validData }); // $ExpectError + + // $ExpectType Heatmap<"value", "x", "y"> + heatmap.setData({ + min: 0, + max: 1, + data: validData + }); + + heatmap.setData({ // $ExpectError + min: 0, + max: 1, + data: [{ xPos: 1, yPos: 2, value: 5 }] + }); +} + +{ + const validData: ReadonlyArray> = + [{ xPos: 1, yPos: 2, count: 1 }]; + + const heatmap = h337.create<"count", "xPos", "yPos">({ container }); + heatmap.setData({ max: 5, data: validData }); // $ExpectError + heatmap.setData({ min: 5, data: validData }); // $ExpectError + + // $ExpectType Heatmap<"count", "xPos", "yPos"> + heatmap.setData({ + min: 0, + max: 1, + data: validData + }); + + heatmap.setData({ // $ExpectError + min: 0, + max: 1, + data: [{ x: 1, y: 2, value: 5 }] + }); +} + +// -- Heatmap#setDataMax / Heatmap#setDataMin -- + +{ + const heatmap = h337.create({ container }); + + // $ExpectType Heatmap<"value", "x", "y"> + heatmap.setDataMax(500); + heatmap.setDataMax(null); // $ExpectError + heatmap.setDataMax(); // $ExpectError + + heatmap.setDataMin(500); + heatmap.setDataMin(null); // $ExpectError + heatmap.setDataMin(); // $ExpectError +} + +// -- Heatmap#configure -- + +{ + const heatmap = h337.create({ container }); + + heatmap.configure({}); // $ExpectError + + // $ExpectType Heatmap<"value", "x", "y"> + heatmap.configure({ container }); + + const nextHeatmap = heatmap.configure<"count", "xPos", "yPos">({ + container, + valueField: "count", + xField: "xPos", + yField: "yPos" + }); + + nextHeatmap; // $ExpectType Heatmap<"count", "xPos", "yPos"> + + // $ExpectType Heatmap<"count", "xPos", "yPos"> + nextHeatmap.configure({ container }); +} + +// -- Heatmap#getValueAt -- + +{ + // $ExpectType number + h337.create({ container }).getValueAt({ x: 0, y: 1 }); + + // $ExpectType number + h337.create<"foo", "bar", "baz">({ container }).getValueAt({ x: 0, y: 1 }); +} + +// -- Heatmap#getData -- + +{ + // $ExpectType HeatmapData + h337.create({ container }).getData(); + + // $ExpectType HeatmapData + h337.create<"foo", "bar", "baz">({ container }).getData(); +} + +// -- Heatmap#getDataURL -- + +{ + // $ExpectType string + h337.create({ container }).getDataURL(); +} + +// -- Heatmap#repaint -- +{ + // $ExpectType Heatmap<"value", "x", "y"> + h337.create({ container }).repaint(); + + // $ExpectType Heatmap<"foo", "bar", "baz"> + h337.create<"foo", "bar", "baz">({ container }).repaint(); +} + +// -- Leaflet plugin -- + +{ + const baseLayer = L.tileLayer( + 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + // tslint:disable-next-line max-line-length + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', + maxZoom: 18 } - ] -}; + ); -var config : HeatmapConfiguration = { - radius: 2, - maxOpacity: .8, - scaleRadius: true, - useLocalExtrema: true, - latField: 'lat', - lngField: 'lng', - valueField: 'count' -}; + const testData: h337.HeatmapData> = { + min: 1, + max: 3, + data: [ + { + lat: 24.6408, + lng: 46.7728, + count: 3 + }, { + lat: 50.75, + lng: -1.55, + count: 1 + } + ] + }; -var heatmapLayer = new HeatmapOverlay(config); + const config: h337.HeatmapOverlayConfiguration<'count'> = { + radius: 2, + maxOpacity: .8, + scaleRadius: true, + useLocalExtrema: true, + latField: 'lat', + lngField: 'lng', + valueField: 'count' + }; + config; // $ExpectType HeatmapOverlayConfiguration<"count", "lat", "lng"> -var map = new L.Map('map-canvas', { - center: new L.LatLng(25.6586, -80.3568), - zoom: 4, - layers: [baseLayer, heatmapLayer] -}); + const heatmapLayer = new HeatmapOverlay(config); + heatmapLayer; // $ExpectType HeatmapOverlay<"count", "lat", "lng"> -heatmapLayer.setData(testData); + const map = new L.Map('map-canvas', { + center: new L.LatLng(25.6586, -80.3568), + zoom: 4, + layers: [baseLayer, heatmapLayer] + }); + + // $ExpectType void + heatmapLayer.setData(testData); +} diff --git a/types/heatmap.js/index.d.ts b/types/heatmap.js/index.d.ts index e6c0a4aec1..f97f83fc19 100644 --- a/types/heatmap.js/index.d.ts +++ b/types/heatmap.js/index.d.ts @@ -1,127 +1,291 @@ -// Type definitions for heatmap.js v2.0 +// Type definitions for heatmap.js 2.0 // Project: https://github.com/pa7/heatmap.js/ // Definitions by: Yang Guan +// Rhys van der Waerden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 + +export as namespace h337; + +/* + * Create a heatmap instance. A Heatmap can be customized with the configObject. + */ +export function create< + V extends string = 'value', + X extends string = 'x', + Y extends string = 'y' +>( + configObject: HeatmapConfiguration +): Heatmap; + +export function register(pluginKey: string, plugin: any): void; + +/* + * Heatmap instances are returned by h337.create. A heatmap instance has its own + * internal datastore and renderer where you can manipulate data. As a result + * the heatmap gets updated (either partially or completely, depending on + * whether it's necessary). + */ +export class Heatmap { + /* + * Use this functionality only for adding datapoints on the fly, not for data + * initialization! heatmapInstance.addData adds a single or multiple + * datapoints to the heatmap's datastore. + */ + addData(dataPoint: DataPoint | ReadonlyArray>): this; + + /* + * Initialize a heatmap instance with the given dataset. Removes all + * previously existing points from the heatmap instance and re-initializes + * the datastore. + */ + setData(data: HeatmapData>): this; + + /* + * Changes the upper bound of your dataset and triggers a complete + * rerendering. + */ + setDataMax(number: number): this; + + /* + * Changes the lower bound of your dataset and triggers a complete + * rerendering. + */ + setDataMin(number: number): this; + + /* + * Reconfigures a heatmap instance after it has been initialized. Triggers a + * complete rerendering. + * + * NOTE: This returns a reference to itself, but also offers an opportunity + * to change the `xField`, `yField` and `valueField` options, which can + * change the type of the `Heatmap` instance. + */ + configure< + Vn extends string = V, + Xn extends string = X, + Yn extends string = Y + >(configObject: HeatmapConfiguration): Heatmap; + + /** + * Returns value at datapoint position. + * + * The returned value is an interpolated value based on the gradient blending + * if point is not in store. + * + * NOTE: This function uses `x` and `y` instead of custom `xField` and + * `yField` + */ + getValueAt(point: Point<'x', 'y'>): number; + + /* + * Returns a persistable and reimportable (with setData) JSON object. + */ + getData(): HeatmapData; + + /* + * Returns dataURL string. + * + * The returned value is the base64 encoded dataURL of the heatmap instance. + */ + getDataURL(): string; + + /* + * Repaints the whole heatmap canvas. + */ + repaint(): this; +} + +export interface BaseHeatmapConfiguration { + /* + * A background color string in form of hexcode, color name, or rgb(a) + */ + backgroundColor?: string; + + /* + * The blur factor that will be applied to all datapoints. The higher the + * blur factor is, the smoother the gradients will be + * Default value: 0.85 + */ + blur?: number; + + /* + * An object that represents the gradient. + * Syntax: {[key: number in range [0,1]]: color} + */ + gradient?: { [key: string]: string }; + + /* + * The maximal opacity the highest value in the heatmap will have. (will be + * overridden if opacity set) + * Default value: 0.6 + */ + maxOpacity?: number; + + /* + * The minimum opacity the lowest value in the heatmap will have (will be + * overridden if opacity set) + */ + minOpacity?: number; + + /* + * A global opacity for the whole heatmap. This overrides maxOpacity and + * minOpacity if set + * Default value: 0.6 + */ + opacity?: number; + + /* + * The radius each datapoint will have (if not specified on the datapoint + * itself) + */ + radius?: number; + + /** + * Scales the radius based on map zoom. + */ + scaleRadius?: boolean; + + /* + * The property name of the value/weight in a datapoint + * Default value: 'value' + */ + valueField?: V; + + /** + * Pass a callback to receive extrema change updates. Useful for DOM + * legends. + */ + onExtremaChange?: () => void; + + /* + * Indicate whether the heatmap should use a global extrema or a local + * extrema (the maximum and minimum of the currently displayed viewport) + */ + useLocalExtrema?: boolean; +} + +/* + * Configuration object of a heatmap + */ +export interface HeatmapConfiguration< + V extends string = 'value', + X extends string = 'x', + Y extends string = 'y', +> extends BaseHeatmapConfiguration { + /* + * A DOM node where the heatmap canvas should be appended (heatmap will adapt to + * the node's size) + */ + container: HTMLElement; + + /* + * The property name of your x coordinate in a datapoint + * Default value: 'x' + */ + xField?: X; + + /* + * The property name of your y coordinate in a datapoint + * Default value: 'y' + */ + yField?: Y; +} + +export interface HeatmapOverlayConfiguration< + V extends string = 'value', + TLat extends string = 'lat', + TLong extends string = 'lng', +> extends BaseHeatmapConfiguration { + /* + * The property name of your latitude coordinate in a datapoint + * Default value: 'x' + */ + latField?: TLat; + + /* + * The property name of your longitude coordinate in a datapoint + * Default value: 'y' + */ + lngField?: TLong; +} + +/* + * A position in the heatmap. + */ +export type Point = + Record; + +/* + * A single data point on a heatmap. The interface of the data point can be + * overridden by providing alternative values for `xKey` and `yKey` in the + * config object. + */ +export type DataPoint< + V extends string = 'value', + X extends string = 'x', + Y extends string = 'y', +> = + Record & Point; + +/* + * Type of data returned by `Heatmap#getData`, which ignores custom `xField`, + * `yField` and `valueField`. + */ +export interface DataCircle { + x: number; + y: number; + value: number; + radius: number; +} + +/* + * An object representing the set of data points on a heatmap + */ +export interface HeatmapData { + /* + * An array of data points + */ + data: ReadonlyArray; + + /* + * Max value of the valueField + */ + max: number; + + /* + * Min value of the valueField + */ + min: number; +} + +// -- Leaflet plugin -- import * as Leaflet from "leaflet"; declare global { /* - * Configuration object of a heatmap - */ - interface HeatmapConfiguration { - + * The overlay layer to be added onto leaflet map + */ + class HeatmapOverlay< + V extends string, + TLat extends string, + TLng extends string + > implements Leaflet.ILayer { /* - * A background color string in form of hexcode, color name, or rgb(a) - */ - backgroundColor?: string; - - /* - * The blur factor that will be applied to all datapoints. The higher the - * blur factor is, the smoother the gradients will be - * Default value: 0.85 - */ - blur?: number; - - /* - * An object that represents the gradient - */ - gradient?: any; - - /* - * The property name of your latitude coordinate in a datapoint - * Default value: 'x' - */ - latField?: string; - - /* - * The property name of your longitude coordinate in a datapoint - * Default value: 'y' - */ - lngField?: string; - - /* - * The maximal opacity the highest value in the heatmap will have. (will be - * overridden if opacity set) - * Default value: 0.6 - */ - maxOpacity?: number; - - /* - * The minimum opacity the lowest value in the heatmap will have (will be - * overridden if opacity set) - */ - minOpacity?: number; - - /* - * A global opacity for the whole heatmap. This overrides maxOpacity and - * minOpacity if set - */ - opacity?: number; - - /* - * The radius each datapoint will have (if not specified on the datapoint - * itself) - */ - radius?: number; - - /** - * Scales the radius based on map zoom. + * Initialization function */ - scaleRadius?: boolean; + constructor(configuration: HeatmapOverlayConfiguration); /* - * Indicate whether the heatmap should use a global extrema or a local - * extrema (the maximum and minimum of the currently displayed viewport) - */ - useLocalExtrema?: boolean; + * Initialize a heatmap instance with the given dataset + */ + setData(data: HeatmapData>): void; /* - * The property name of the value/weight in a datapoint - * Default value: 'value' - */ - valueField?: string; - } - - /* - * A single data point on a heatmap. The keys are specified by - * HeatmapConfig.latField, HeatmapConfig.lngField and HeatmapConfig.valueField - */ - interface HeatmapDataPoint { - [index: string]: number; - } - - /* - * An object representing the set of data points on a heatmap - */ - interface HeatmapData { - - /* - * An array of HeatmapDataPoints - */ - data: HeatmapDataPoint[]; - - /* - * Max value of the valueField - */ - max?: number; - - /* - * Min value of the valueField - */ - min?: number; - } - - /* - * The overlay layer to be added onto leaflet map - */ - class HeatmapOverlay { - - /* - * Initialization function - */ - constructor(configuration: HeatmapConfiguration) + * Experimential... not ready. + */ + addData(data: DataPoint | ReadonlyArray>): void; /* * Create DOM elements for an overlay, adding them to map panes and puts @@ -134,10 +298,5 @@ declare global { * previously added by onAdd() */ onRemove(map: Leaflet.Map): void; - - /* - * Initialize a heatmap instance with the given dataset - */ - setData(data: HeatmapData): void; } } diff --git a/types/heatmap.js/tsconfig.json b/types/heatmap.js/tsconfig.json index 06fa28716f..2e22853a34 100644 --- a/types/heatmap.js/tsconfig.json +++ b/types/heatmap.js/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/heatmap.js/tslint.json b/types/heatmap.js/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/heatmap.js/tslint.json +++ b/types/heatmap.js/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From ff4b1f0af76d461815cdd40a5aeca85dc5111673 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Fri, 17 Nov 2017 13:51:19 +0100 Subject: [PATCH 047/639] String object has additional ES2017 and ESNEXT methods --- types/node/index.d.ts | 12 ++++++++++++ types/node/node-tests.ts | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 0052b8256e..72e7cdbe30 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -68,6 +68,18 @@ interface SymbolConstructor { } declare var Symbol: SymbolConstructor; +// Node.js ES2017 and ESNEXT support +interface String { + /** Pads the current string with another string (repeated, if needed) so that the resulting string reaches the given length. The padding is applied from the start (left) of the current string. */ + padStart(targetLength?: number, padString?: string): string; + /** Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string. */ + padEnd(targetLength?: number, padString?: string): string; + /** Removes whitespace from the left end of a string. */ + trimLeft(): string; + /** Removes whitespace from the right end of a string. */ + trimRight(): string; +} + /************************************************ * * * GLOBAL * diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 41639e52c6..34bba1f7ba 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3751,3 +3751,27 @@ namespace module_tests { const m1: Module = new Module("moduleId"); const m2: Module = new Module.Module("moduleId"); } + +//////////////////////////////////////////////////// +/// Node.js ES2017 Support +//////////////////////////////////////////////////// + +namespace es2017_tests { + const s: string = 'foo'; + const s1: string = s.padStart(); + const s11: string = s.padStart(10); + const s12: string = s.padStart(10, 'x'); + const s2: string = s.padEnd(); + const s21: string = s.padEnd(10); + const s22: string = s.padEnd(10, 'x'); +} + +//////////////////////////////////////////////////// +/// Node.js ESNEXT Support +//////////////////////////////////////////////////// + +namespace esnext_tests { + const s: string = 'foo'; + const s1: string = s.trimLeft(); + const s2: string = s.trimRight(); +} From d2cc016dcb1a6453d7c50eff1d874468347569f2 Mon Sep 17 00:00:00 2001 From: Josh McCullough Date: Fri, 17 Nov 2017 23:35:00 -0500 Subject: [PATCH 048/639] [fb] add FB Live UI dialog options/response; cleanup ui() functions --- types/fb/index.d.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/types/fb/index.d.ts b/types/fb/index.d.ts index a968d9f3c0..d48aedee8a 100644 --- a/types/fb/index.d.ts +++ b/types/fb/index.d.ts @@ -83,12 +83,20 @@ interface FeedDialogParams { ref?: any; } -declare type FBUIParams = ShareDialogParams - | PageTabDialogParams - | RequestsDialogParams - | SendDialogParams - | PayDialogParams - | FeedDialogParams; +interface LiveDialogParams { + redirect_uri?: string; + method: string; + display: string; + phase: string; + broadcast_data?: LiveDialogResponse; +} + +interface LiveDialogResponse { + id: string; + stream_url: string; + secure_stream_url: string; + status: string; +} interface FBLoginOptions{ auth_type?: string; @@ -201,8 +209,14 @@ interface FBSDK{ api(path: string, params: any, callback: (response: any) => void): void; api(path: string, method: ApiMethod, params: any, callback: (response: any) => void): void; - /* This method is used to trigger different forms of Facebook created UI dialogs. */ - ui(params : FBUIParams, handler : (fbResponseObject : Object) => any) : void; + /* These methods are used to trigger different forms of Facebook-created UI dialogs. */ + ui(params : ShareDialogParams, handler : (fbResponseObject : Object) => any) : void; + ui(params : PageTabDialogParams, handler : (fbResponseObject : Object) => any) : void; + ui(params : RequestsDialogParams, handler : (fbResponseObject : Object) => any) : void; + ui(params : SendDialogParams, handler : (fbResponseObject : Object) => any) : void; + ui(params : PayDialogParams, handler : (fbResponseObject : Object) => any) : void; + ui(params : FeedDialogParams, handler : (fbResponseObject : Object) => any) : void; + ui(params : LiveDialogParams, handler : (fbResponseObject : LiveDialogResponse) => any) : void; /* Allows you to determine if a user is logged in to Facebook and has authenticated your app */ getLoginStatus(handler : (fbResponseObject : FB.LoginStatusResponse) => any, force?: Boolean) : void; From 86ba50fb2fc45c6e956b4a47354f4ac1584a61f2 Mon Sep 17 00:00:00 2001 From: Rhys van der Waerden Date: Sat, 18 Nov 2017 16:15:38 +1100 Subject: [PATCH 049/639] heatmap.js: declare const container in tests More idiomatic and avoids a tslint disable comment. --- types/heatmap.js/heatmap.js-tests.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/heatmap.js/heatmap.js-tests.ts b/types/heatmap.js/heatmap.js-tests.ts index 198c214198..d7c9c76c2b 100644 --- a/types/heatmap.js/heatmap.js-tests.ts +++ b/types/heatmap.js/heatmap.js-tests.ts @@ -1,5 +1,4 @@ -// tslint:disable-next-line no-object-literal-type-assertion -const container = {} as HTMLElement; +declare const container: HTMLElement; // -- h337.HeatmapConfiguration -- From 0e6cdf8acde1c2261e4ef3d25113b3905bf26e52 Mon Sep 17 00:00:00 2001 From: Rhys van der Waerden Date: Sat, 18 Nov 2017 16:17:22 +1100 Subject: [PATCH 050/639] heatmap.js: Remove tests for required fields These tests are not needed. --- types/heatmap.js/heatmap.js-tests.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/types/heatmap.js/heatmap.js-tests.ts b/types/heatmap.js/heatmap.js-tests.ts index d7c9c76c2b..af0c021b3f 100644 --- a/types/heatmap.js/heatmap.js-tests.ts +++ b/types/heatmap.js/heatmap.js-tests.ts @@ -7,11 +7,6 @@ declare const container: HTMLElement; config; // $ExpectType HeatmapConfiguration<"value", "x", "y"> } -{ - // $ExpectError - const config: h337.HeatmapConfiguration = {}; -} - { const config: h337.HeatmapConfiguration = { container, @@ -39,10 +34,6 @@ declare const container: HTMLElement; // -- h337.create -- -{ - h337.create(); // $ExpectError -} - { // $ExpectType Heatmap<"value", "x", "y"> h337.create({ container }); @@ -176,8 +167,6 @@ declare const container: HTMLElement; { const heatmap = h337.create({ container }); - heatmap.configure({}); // $ExpectError - // $ExpectType Heatmap<"value", "x", "y"> heatmap.configure({ container }); From 5054ffa5fea764ffff210e801e130c4deaab84f5 Mon Sep 17 00:00:00 2001 From: benny-medflyt Date: Sat, 18 Nov 2017 12:26:33 +0200 Subject: [PATCH 051/639] Client constructor still accepts a string --- types/pg/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index 68fba5fb40..47d3abc4cf 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -93,7 +93,7 @@ export class Pool extends events.EventEmitter { } export class Client extends events.EventEmitter { - constructor(config: ClientConfig); + constructor(config: string | ClientConfig); connect(): Promise; connect(callback: (err: Error) => void): void; From cfbd9b0edc53c39b3cca07e1b081a46704a7820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 18 Nov 2017 22:47:57 +0100 Subject: [PATCH 052/639] Updated the react-virtualized MultiGrid props According to the docs, these are all optional: https://github.com/bvaughn/react-virtualized/blob/master/docs/MultiGrid.md --- .../react-virtualized/dist/es/MultiGrid.d.ts | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/types/react-virtualized/dist/es/MultiGrid.d.ts b/types/react-virtualized/dist/es/MultiGrid.d.ts index 1bb8b7dfac..96c33e3bed 100644 --- a/types/react-virtualized/dist/es/MultiGrid.d.ts +++ b/types/react-virtualized/dist/es/MultiGrid.d.ts @@ -2,13 +2,19 @@ import { PureComponent, Validator, Requireable } from 'react' import { GridProps } from './Grid' export type MultiGridProps = { - fixedColumnCount: number; - fixedRowCount: number; - style: React.CSSProperties; - styleBottomLeftGrid: React.CSSProperties; - styleBottomRightGrid: React.CSSProperties; - styleTopLeftGrid: React.CSSProperties; - styleTopRightGrid: React.CSSProperties; + classNameBottomLeftGrid?: string; + classNameBottomRightGrid?: string; + classNameTopLeftGrid?: string; + classNameTopRightGrid?: string; + enableFixedColumnScroll?: boolean; + enableFixedRowScroll?: boolean; + fixedColumnCount?: number; + fixedRowCount?: number; + style?: React.CSSProperties; + styleBottomLeftGrid?: React.CSSProperties; + styleBottomRightGrid?: React.CSSProperties; + styleTopLeftGrid?: React.CSSProperties; + styleTopRightGrid?: React.CSSProperties; } & GridProps; export type MultiGridState = { @@ -25,6 +31,12 @@ export type MultiGridState = { */ export class MultiGrid extends PureComponent { static propTypes: { + classNameBottomLeftGrid: Validator, + classNameBottomRightGrid: Validator, + classNameTopLeftGrid: Validator, + classNameTopRightGrid: Validator, + enableFixedColumnScroll: Validator, + enableFixedRowScroll: Validator, fixedColumnCount: Validator, fixedRowCount: Validator, style: Validator, @@ -35,6 +47,12 @@ export class MultiGrid extends PureComponent { }; static defaultProps: { + classNameBottomLeftGrid: '', + classNameBottomRightGrid: '', + classNameTopLeftGrid: '', + classNameTopRightGrid: '', + enableFixedColumnScroll: false, + enableFixedRowScroll: false, fixedColumnCount: 0, fixedRowCount: 0, style: {}, From bfc83b18f3cc85a7284533addb6c073762194759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 18 Nov 2017 23:09:36 +0100 Subject: [PATCH 053/639] Added myself to the definitions by --- types/react-virtualized/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-virtualized/index.d.ts b/types/react-virtualized/index.d.ts index 12febb7edf..f53be447d9 100644 --- a/types/react-virtualized/index.d.ts +++ b/types/react-virtualized/index.d.ts @@ -4,6 +4,7 @@ // John Gunther // Konstantin Nesterov // Szőke Szabolcs +// Kræn Hansen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From ceb5223a75e4e7d3366d0209980a4c3c02a60525 Mon Sep 17 00:00:00 2001 From: Bryan Hughes Date: Sat, 18 Nov 2017 15:31:32 -0800 Subject: [PATCH 054/639] Added part of the Raspi IO ecosystem --- types/raspi-board/index.d.ts | 27 +++++++++++++++++++ types/raspi-board/raspi-board-tests.ts | 6 +++++ types/raspi-board/tsconfig.json | 23 ++++++++++++++++ types/raspi-board/tslint.json | 1 + types/raspi-peripheral/index.d.ts | 17 ++++++++++++ .../raspi-peripheral-tests.ts | 5 ++++ types/raspi-peripheral/tsconfig.json | 23 ++++++++++++++++ types/raspi-peripheral/tslint.json | 1 + types/raspi/index.d.ts | 7 +++++ types/raspi/raspi-tests.ts | 3 +++ types/raspi/tsconfig.json | 23 ++++++++++++++++ types/raspi/tslint.json | 1 + 12 files changed, 137 insertions(+) create mode 100644 types/raspi-board/index.d.ts create mode 100644 types/raspi-board/raspi-board-tests.ts create mode 100644 types/raspi-board/tsconfig.json create mode 100644 types/raspi-board/tslint.json create mode 100644 types/raspi-peripheral/index.d.ts create mode 100644 types/raspi-peripheral/raspi-peripheral-tests.ts create mode 100644 types/raspi-peripheral/tsconfig.json create mode 100644 types/raspi-peripheral/tslint.json create mode 100644 types/raspi/index.d.ts create mode 100644 types/raspi/raspi-tests.ts create mode 100644 types/raspi/tsconfig.json create mode 100644 types/raspi/tslint.json diff --git a/types/raspi-board/index.d.ts b/types/raspi-board/index.d.ts new file mode 100644 index 0000000000..a244577c2b --- /dev/null +++ b/types/raspi-board/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for raspi-board 5.0 +// Project: https://github.com/nebrius/raspi-board +// Definitions by: Bryan Hughes +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export const VERSION_1_MODEL_A = "rpi1_a"; +export const VERSION_1_MODEL_B_REV_1 = "rpi1_b1"; +export const VERSION_1_MODEL_B_REV_2 = "rpi1_b2"; +export const VERSION_1_MODEL_B_PLUS = "rpi1_bplus"; +export const VERSION_1_MODEL_A_PLUS = "rpi1_aplus"; +export const VERSION_1_MODEL_ZERO = "rpi1_zero"; +export const VERSION_1_MODEL_ZERO_W = "rpi1_zerow"; +export const VERSION_2_MODEL_B = "rpi2_b"; +export const VERSION_3_MODEL_B = "rpi3_b"; +export const VERSION_UNKNOWN = "unknown"; +export interface PinInfo { + pins: string[]; + peripherals: string[]; + gpio: number; +} +export function getBoardRevision(): string; +export function getPins(): { + [wiringpi: number]: PinInfo; +}; +export function getPinNumber(alias: string | number): number | null; +export function getGpioNumber(alias: string | number): number | null; diff --git a/types/raspi-board/raspi-board-tests.ts b/types/raspi-board/raspi-board-tests.ts new file mode 100644 index 0000000000..23195168cf --- /dev/null +++ b/types/raspi-board/raspi-board-tests.ts @@ -0,0 +1,6 @@ +import { getBoardRevision, getPins, getPinNumber, getGpioNumber } from 'raspi-board'; + +getBoardRevision(); +getPins(); +getPinNumber('GPIO18'); +getGpioNumber('GPIO18'); diff --git a/types/raspi-board/tsconfig.json b/types/raspi-board/tsconfig.json new file mode 100644 index 0000000000..a55a514726 --- /dev/null +++ b/types/raspi-board/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "raspi-board-tests.ts" + ] +} \ No newline at end of file diff --git a/types/raspi-board/tslint.json b/types/raspi-board/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/raspi-board/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/raspi-peripheral/index.d.ts b/types/raspi-peripheral/index.d.ts new file mode 100644 index 0000000000..d52ed3ec6c --- /dev/null +++ b/types/raspi-peripheral/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for raspi-peripheral 2.0 +// Project: https://github.com/nebrius/raspi-peripheral +// Definitions by: Bryan Hughes +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// +import { EventEmitter } from 'events'; +export class Peripheral extends EventEmitter { + private _alive; + readonly alive: boolean; + private _pins; + readonly pins: number[]; + constructor(pins: string | number | Array); + destroy(): void; + validateAlive(): void; +} diff --git a/types/raspi-peripheral/raspi-peripheral-tests.ts b/types/raspi-peripheral/raspi-peripheral-tests.ts new file mode 100644 index 0000000000..dc16f863a2 --- /dev/null +++ b/types/raspi-peripheral/raspi-peripheral-tests.ts @@ -0,0 +1,5 @@ +import { Peripheral } from 'raspi-peripheral'; + +const myPeripheral = new Peripheral('GPIO2'); +myPeripheral.alive; +myPeripheral.pins.filter((pin) => true); diff --git a/types/raspi-peripheral/tsconfig.json b/types/raspi-peripheral/tsconfig.json new file mode 100644 index 0000000000..4b24a67971 --- /dev/null +++ b/types/raspi-peripheral/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "raspi-peripheral-tests.ts" + ] +} \ No newline at end of file diff --git a/types/raspi-peripheral/tslint.json b/types/raspi-peripheral/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/raspi-peripheral/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/raspi/index.d.ts b/types/raspi/index.d.ts new file mode 100644 index 0000000000..9df97fe3cc --- /dev/null +++ b/types/raspi/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for raspi 5.0 +// Project: https://github.com/nebrius/raspi +// Definitions by: Bryan Hughes +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export function init(cb: () => void): void; diff --git a/types/raspi/raspi-tests.ts b/types/raspi/raspi-tests.ts new file mode 100644 index 0000000000..705aeacc31 --- /dev/null +++ b/types/raspi/raspi-tests.ts @@ -0,0 +1,3 @@ +import { init } from 'raspi'; + +init(() => {}); diff --git a/types/raspi/tsconfig.json b/types/raspi/tsconfig.json new file mode 100644 index 0000000000..6906d607cf --- /dev/null +++ b/types/raspi/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "raspi-tests.ts" + ] +} \ No newline at end of file diff --git a/types/raspi/tslint.json b/types/raspi/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/raspi/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From f07f6a8da9a83b5a2246f2112dcb01156ed2323b Mon Sep 17 00:00:00 2001 From: Rhys van der Waerden Date: Sun, 19 Nov 2017 12:51:25 +1100 Subject: [PATCH 055/639] heatmap.js: JSDoc Convert comments to JSDoc and add code examples. Remove "NOTE" on `getValueAt` which is redundant due to types. --- types/heatmap.js/index.d.ts | 189 +++++++++++++++++++++++++++--------- 1 file changed, 142 insertions(+), 47 deletions(-) diff --git a/types/heatmap.js/index.d.ts b/types/heatmap.js/index.d.ts index f97f83fc19..288d50b448 100644 --- a/types/heatmap.js/index.d.ts +++ b/types/heatmap.js/index.d.ts @@ -7,8 +7,40 @@ export as namespace h337; -/* +/** * Create a heatmap instance. A Heatmap can be customized with the configObject. + * + * @example Simple configuration with standard gradient + * + * // create configuration object + * var config = { + * container: document.getElementById('heatmapContainer'), + * radius: 10, + * maxOpacity: .5, + * minOpacity: 0, + * blur: .75 + * }; + * // create heatmap with configuration + * var heatmapInstance = h337.create(config); + * + * @example Custom gradient configuration + * + * // create configuration object + * var config = { + * container: document.getElementById('heatmapContainer'), + * radius: 10, + * maxOpacity: .5, + * minOpacity: 0, + * blur: .75, + * gradient: { + * // enter n keys between 0 and 1 here + * // for gradient color customization + * '.5': 'blue', + * '.8': 'red', + * '.95': 'white' + * } + * }; + * var heatmapInstance = h337.create(config); */ export function create< V extends string = 'value', @@ -20,46 +52,94 @@ export function create< export function register(pluginKey: string, plugin: any): void; -/* +/** * Heatmap instances are returned by h337.create. A heatmap instance has its own * internal datastore and renderer where you can manipulate data. As a result * the heatmap gets updated (either partially or completely, depending on * whether it's necessary). */ export class Heatmap { - /* + /** * Use this functionality only for adding datapoints on the fly, not for data * initialization! heatmapInstance.addData adds a single or multiple * datapoints to the heatmap's datastore. + * + * @example A single datapoint + * + * var dataPoint = { + * x: 5, // x coordinate of the datapoint, a number + * y: 5, // y coordinate of the datapoint, a number + * value: 100 // the value at datapoint(x, y) + * }; + * heatmapInstance.addData(dataPoint); + * + * @example multiple datapoints + * + * // for data initialization use setData!! + * var dataPoints = [dataPoint, dataPoint, dataPoint, dataPoint]; + * heatmapInstance.addData(dataPoints); */ addData(dataPoint: DataPoint | ReadonlyArray>): this; - /* + /** * Initialize a heatmap instance with the given dataset. Removes all * previously existing points from the heatmap instance and re-initializes * the datastore. + * + * @example + * + * var data = { + * max: 100, + * min: 0, + * data: [ + * dataPoint, dataPoint, dataPoint, dataPoint + * ] + * }; + * heatmapInstance.setData(data); */ setData(data: HeatmapData>): this; - /* + /** * Changes the upper bound of your dataset and triggers a complete * rerendering. + * + * @example + * + * heatmapInstance.setDataMax(200); + * // setting the maximum value triggers a complete rerendering of the heatmap + * heatmapInstance.setDataMax(100); */ setDataMax(number: number): this; - /* + /** * Changes the lower bound of your dataset and triggers a complete * rerendering. + * + * @example + * + * heatmapInstance.setDataMin(10); + * // setting the minimum value triggers a complete rerendering of the heatmap + * heatmapInstance.setDataMin(0); */ setDataMin(number: number): this; - /* + /** * Reconfigures a heatmap instance after it has been initialized. Triggers a * complete rerendering. * * NOTE: This returns a reference to itself, but also offers an opportunity * to change the `xField`, `yField` and `valueField` options, which can * change the type of the `Heatmap` instance. + * + * @example + * + * var nuConfig = { + * radius: 10, + * maxOpacity: .5, + * minOpacity: 0, + * blur: .75 + * }; + * heatmapInstance.configure(nuConfig); */ configure< Vn extends string = V, @@ -73,69 +153,84 @@ export class Heatmap { * The returned value is an interpolated value based on the gradient blending * if point is not in store. * - * NOTE: This function uses `x` and `y` instead of custom `xField` and - * `yField` + * @example + * + * heatmapInstance.addData({ x: 10, y: 10, value: 100}); + * // get the value at x=10, y=10 + * heatmapInstance.getValueAt({ x: 10, y: 10 }); // returns 100 */ getValueAt(point: Point<'x', 'y'>): number; - /* + /** * Returns a persistable and reimportable (with setData) JSON object. + * + * @example + * + * var currentData = heatmapInstance.getData(); + * // now let's create a new instance and set the data + * var heatmap2 = h337.create(config); + * heatmap2.setData(currentData); // now both heatmap instances have the same content */ getData(): HeatmapData; - /* + /** * Returns dataURL string. * * The returned value is the base64 encoded dataURL of the heatmap instance. + * + * @example + * + * heatmapInstance.getDataURL(); // data:image/png;base64... + * // ready for saving locally or on the server */ getDataURL(): string; - /* + /** * Repaints the whole heatmap canvas. */ repaint(): this; } export interface BaseHeatmapConfiguration { - /* + /** * A background color string in form of hexcode, color name, or rgb(a) */ backgroundColor?: string; - /* + /** * The blur factor that will be applied to all datapoints. The higher the * blur factor is, the smoother the gradients will be * Default value: 0.85 */ blur?: number; - /* + /** * An object that represents the gradient. * Syntax: {[key: number in range [0,1]]: color} */ gradient?: { [key: string]: string }; - /* + /** * The maximal opacity the highest value in the heatmap will have. (will be * overridden if opacity set) * Default value: 0.6 */ maxOpacity?: number; - /* + /** * The minimum opacity the lowest value in the heatmap will have (will be * overridden if opacity set) */ minOpacity?: number; - /* + /** * A global opacity for the whole heatmap. This overrides maxOpacity and * minOpacity if set * Default value: 0.6 */ opacity?: number; - /* + /** * The radius each datapoint will have (if not specified on the datapoint * itself) */ @@ -146,7 +241,7 @@ export interface BaseHeatmapConfiguration { */ scaleRadius?: boolean; - /* + /** * The property name of the value/weight in a datapoint * Default value: 'value' */ @@ -158,14 +253,14 @@ export interface BaseHeatmapConfiguration { */ onExtremaChange?: () => void; - /* + /** * Indicate whether the heatmap should use a global extrema or a local * extrema (the maximum and minimum of the currently displayed viewport) */ useLocalExtrema?: boolean; } -/* +/** * Configuration object of a heatmap */ export interface HeatmapConfiguration< @@ -173,19 +268,19 @@ export interface HeatmapConfiguration< X extends string = 'x', Y extends string = 'y', > extends BaseHeatmapConfiguration { - /* + /** * A DOM node where the heatmap canvas should be appended (heatmap will adapt to * the node's size) */ container: HTMLElement; - /* + /** * The property name of your x coordinate in a datapoint * Default value: 'x' */ xField?: X; - /* + /** * The property name of your y coordinate in a datapoint * Default value: 'y' */ @@ -197,26 +292,26 @@ export interface HeatmapOverlayConfiguration< TLat extends string = 'lat', TLong extends string = 'lng', > extends BaseHeatmapConfiguration { - /* + /** * The property name of your latitude coordinate in a datapoint * Default value: 'x' */ latField?: TLat; - /* + /** * The property name of your longitude coordinate in a datapoint * Default value: 'y' */ lngField?: TLong; } -/* +/** * A position in the heatmap. */ export type Point = Record; -/* +/** * A single data point on a heatmap. The interface of the data point can be * overridden by providing alternative values for `xKey` and `yKey` in the * config object. @@ -228,8 +323,8 @@ export type DataPoint< > = Record & Point; -/* - * Type of data returned by `Heatmap#getData`, which ignores custom `xField`, +/** + * Type of data returned by `Heatmap#hello`, which ignores custom `xField`, * `yField` and `valueField`. */ export interface DataCircle { @@ -239,21 +334,21 @@ export interface DataCircle { radius: number; } -/* +/** * An object representing the set of data points on a heatmap */ export interface HeatmapData { - /* + /** * An array of data points */ data: ReadonlyArray; - /* + /** * Max value of the valueField */ max: number; - /* + /** * Min value of the valueField */ min: number; @@ -264,7 +359,7 @@ export interface HeatmapData { import * as Leaflet from "leaflet"; declare global { - /* + /** * The overlay layer to be added onto leaflet map */ class HeatmapOverlay< @@ -272,31 +367,31 @@ declare global { TLat extends string, TLng extends string > implements Leaflet.ILayer { - /* + /** * Initialization function */ constructor(configuration: HeatmapOverlayConfiguration); - /* + /** * Initialize a heatmap instance with the given dataset */ setData(data: HeatmapData>): void; - /* + /** * Experimential... not ready. */ addData(data: DataPoint | ReadonlyArray>): void; - /* - * Create DOM elements for an overlay, adding them to map panes and puts - * listeners on relevant map events - */ + /** + * Create DOM elements for an overlay, adding them to map panes and puts + * listeners on relevant map events + */ onAdd(map: Leaflet.Map): void; - /* - * Remove the overlay's elements from the DOM and remove listeners - * previously added by onAdd() - */ + /** + * Remove the overlay's elements from the DOM and remove listeners + * previously added by onAdd() + */ onRemove(map: Leaflet.Map): void; } } From 1cdafc0a77f60f27d0b241472a0f7afe64637fd2 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Sun, 19 Nov 2017 12:25:19 +0100 Subject: [PATCH 056/639] Add types for JSON Schema v6 --- types/json-schema/index.d.ts | 353 ++++++++++++++++++++++--- types/json-schema/json-schema-tests.ts | 96 ++++++- types/json-schema/tslint.json | 7 +- 3 files changed, 399 insertions(+), 57 deletions(-) diff --git a/types/json-schema/index.d.ts b/types/json-schema/index.d.ts index 016db75a25..063e11d0f0 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -1,21 +1,21 @@ -// Type definitions for json-schema 4.0 +// Type definitions for json-schema 4.0 and 6.0 // Project: https://www.npmjs.com/package/json-schema -// Definitions by: Boris Cherny +// Definitions by: Boris Cherny , Cyrille Tuzi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.6 -/// +/* JSON Schema 4 */ /** * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1 */ export type JSONSchema4TypeName = 'string' | 'number' | 'integer' | 'boolean' - | 'object' | 'array' | 'null' | 'any' + | 'object' | 'array' | 'null' | 'any'; /** * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-3.5 */ -export type JSONSchema4Type = any[] | boolean | number | null | object | string +export type JSONSchema4Type = any[] | boolean | number | null | object | string; /** * JSON Schema V4 @@ -27,7 +27,7 @@ export interface JSONSchema4 { $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | 'http://json-schema.org/draft-04/schema#' | 'http://json-schema.org/draft-04/hyper-schema#' | 'http://json-schema.org/draft-03/schema#' | 'http://json-schema.org/draft-03/hyper-schema#' - | string + | string; /** * This attribute is a string that provides a short description of the @@ -35,7 +35,7 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.21 */ - title?: string + title?: string; /** * This attribute is a string that provides a full description of the of @@ -43,17 +43,17 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.22 */ - description?: string + description?: string; - default?: JSONSchema4Type - multipleOf?: number - maximum?: number - exclusiveMaximum?: boolean - minimum?: number - exclusiveMinimum?: boolean - maxLength?: number - minLength?: number - pattern?: string + default?: JSONSchema4Type; + multipleOf?: number; + maximum?: number; + exclusiveMaximum?: boolean; + minimum?: number; + exclusiveMinimum?: boolean; + maxLength?: number; + minLength?: number; + pattern?: string; /** * May only be defined when "items" is defined, and is a tuple of JSONSchemas. @@ -65,7 +65,7 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.6 */ - additionalItems?: boolean | JSONSchema4 + additionalItems?: boolean | JSONSchema4; /** * This attribute defines the allowed items in an instance array, and @@ -86,13 +86,13 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.5 */ - items?: JSONSchema4 | JSONSchema4[] + items?: JSONSchema4 | JSONSchema4[]; - maxItems?: number - minItems?: number - uniqueItems?: boolean - maxProperties?: number - minProperties?: number + maxItems?: number; + minItems?: number; + uniqueItems?: boolean; + maxProperties?: number; + minProperties?: number; /** * This attribute indicates if the instance must have a value, and not @@ -101,7 +101,7 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.7 */ - required?: false | string[] + required?: false | string[]; /** * This attribute defines a schema for all properties that are not @@ -113,10 +113,10 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.4 */ - additionalProperties?: boolean | JSONSchema4 + additionalProperties?: boolean | JSONSchema4; definitions?: { - [k: string]: JSONSchema4 + [k: string]: JSONSchema4; } /** @@ -133,7 +133,7 @@ export interface JSONSchema4 { * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.2 */ properties?: { - [k: string]: JSONSchema4 + [k: string]: JSONSchema4; } /** @@ -148,10 +148,10 @@ export interface JSONSchema4 { * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.3 */ patternProperties?: { - [k: string]: JSONSchema4 + [k: string]: JSONSchema4; } dependencies?: { - [k: string]: JSONSchema4 | string[] + [k: string]: JSONSchema4 | string[]; } /** @@ -163,17 +163,17 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.19 */ - enum?: JSONSchema4Type[] + enum?: JSONSchema4Type[]; /** * A single type, or a union of simple types */ - type?: JSONSchema4TypeName | JSONSchema4TypeName[] + type?: JSONSchema4TypeName | JSONSchema4TypeName[]; - allOf?: JSONSchema4[] - anyOf?: JSONSchema4[] - oneOf?: JSONSchema4[] - not?: JSONSchema4 + allOf?: JSONSchema4[]; + anyOf?: JSONSchema4[]; + oneOf?: JSONSchema4[]; + not?: JSONSchema4; /** * The value of this property MUST be another schema which will provide @@ -191,10 +191,285 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.26 */ - extends?: string | string[] + extends?: string | string[]; /** * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-5.6 */ - [k: string]: any + [k: string]: any; +} + +/* JSON Schema 6 */ + +export type JSONSchema6TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null' | 'any'; + +export type JSONSchema6Type = any[] | boolean | number | null | object | string; + +/** +* JSON Schema V6 +* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01 +*/ +export interface JSONSchema6 { + + $id?: string; + $ref?: string; + $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | + 'http://json-schema.org/draft-06/schema#' | 'http://json-schema.org/draft-06/hyper-schema#'; + + /** + * Must be strictly greater than 0. + * A numeric instance is valid only if division by this keyword's value results in an integer. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1 + */ + multipleOf?: number; + + /** + * Representing an inclusive upper limit for a numeric instance. + * This keyword validates only if the instance is less than or exactly equal to "maximum". + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2 + */ + maximum?: number; + + /** + * Representing an exclusive upper limit for a numeric instance. + * This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum". + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3 + */ + exclusiveMaximum?: number; + + /** + * Representing an inclusive lower limit for a numeric instance. + * This keyword validates only if the instance is greater than or exactly equal to "minimum". + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4 + */ + minimum?: number; + + /** + * Representing an exclusive lower limit for a numeric instance. + * This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum". + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5 + */ + exclusiveMinimum?: number; + + /** + * Must be a non-negative integer. + * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6 + */ + maxLength?: number; + + /** + * Must be a non-negative integer. + * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. + * Omitting this keyword has the same behavior as a value of 0. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7 + */ + minLength?: number; + + /** + * Should be a valid regular expression, according to the ECMA 262 regular expression dialect. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8 + */ + pattern?: string; + + /** + * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. + * Omitting this keyword has the same behavior as an empty schema. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9 + */ + items?: boolean | JSONSchema6 | JSONSchema6[]; + + /** + * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. + * If "items" is an array of schemas, validation succeeds if every instance element + * at a position greater than the size of "items" validates against "additionalItems". + * Otherwise, "additionalItems" MUST be ignored, as the "items" schema + * (possibly the default value of an empty schema) is applied to all elements. + * Omitting this keyword has the same behavior as an empty schema. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10 + */ + additionalItems?: boolean | JSONSchema6; + + /** + * Must be a non-negative integer. + * An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11 + */ + maxItems?: number; + + /** + * Must be a non-negative integer. + * An array instance is valid against "maxItems" if its size is greater than, or equal to, the value of this keyword. + * Omitting this keyword has the same behavior as a value of 0. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12 + */ + minItems?: number; + + /** + * If this keyword has boolean value false, the instance validates successfully. + * If it has boolean value true, the instance validates successfully if all of its elements are unique. + * Omitting this keyword has the same behavior as a value of false. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13 + */ + uniqueItems?: boolean; + + /** + * An array instance is valid against "contains" if at least one of its elements is valid against the given schema. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14 + */ + contains?: boolean | JSONSchema6; + + /** + * Must be a non-negative integer. + * An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15 + */ + maxProperties?: number; + + /** + * Must be a non-negative integer. + * An object instance is valid against "maxProperties" if its number of properties is greater than, + * or equal to, the value of this keyword. + * Omitting this keyword has the same behavior as a value of 0. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16 + */ + minProperties?: number; + + /** + * Elements of this array must be unique. + * An object instance is valid against this keyword if every item in the array is the name of a property in the instance. + * Omitting this keyword has the same behavior as an empty array. + * + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17 + */ + required?: string[]; + + /** + * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. + * Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, + * the child instance for that name successfully validates against the corresponding schema. + * Omitting this keyword has the same behavior as an empty object. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18 + */ + properties?: { + [k: string]: boolean | JSONSchema6 + }; + + /** + * This attribute is an object that defines the schema for a set of property names of an object instance. + * The name of each property of this attribute's object is a regular expression pattern in the ECMA 262, while the value is a schema. + * If the pattern matches the name of a property on the instance object, the value of the instance's property + * MUST be valid against the pattern name's schema value. + * Omitting this keyword has the same behavior as an empty object. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19 + */ + patternProperties?: { + [k: string]: boolean | JSONSchema6 + }; + + /** + * This attribute defines a schema for all properties that are not explicitly defined in an object type definition. + * If specified, the value MUST be a schema or a boolean. + * If false is provided, no additional properties are allowed beyond the properties defined in the schema. + * The default value is an empty schema which allows any value for additional properties. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20 + */ + additionalProperties?: boolean | JSONSchema6; + + /** + * This keyword specifies rules that are evaluated if the instance is an object and contains a certain property. + * Each property specifies a dependency. + * If the dependency value is an array, each element in the array must be unique. + * Omitting this keyword has the same behavior as an empty object. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21 + */ + dependencies?: { + [k: string]: boolean | JSONSchema6 | string[] + }; + + /** + * Takes a schema which validates the names of all properties rather than their values. + * Note the property name that the schema is testing will always be a string. + * Omitting this keyword has the same behavior as an empty schema. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22 + */ + propertyNames?: boolean | JSONSchema6; + + /** + * This provides an enumeration of all possible values that are valid + * for the instance property. This MUST be an array, and each item in + * the array represents a possible value for the instance value. If + * this attribute is defined, the instance value MUST be one of the + * values in the array in order for the schema to be valid. + * + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23 + */ + enum?: JSONSchema6Type[]; + + /** + * More readible form of a one-element "enum" + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24 + */ + const?: JSONSchema6Type; + + /** + * A single type, or a union of simple types + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25 + */ + type?: JSONSchema6TypeName | JSONSchema6TypeName[]; + + /** + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26 + */ + allOf?: JSONSchema6[]; + + /** + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27 + */ + anyOf?: JSONSchema6[]; + + /** + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28 + */ + oneOf?: JSONSchema6[]; + + /** + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29 + */ + not?: boolean | JSONSchema6; + + /** + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1 + */ + definitions?: { + [k: string]: boolean | JSONSchema6 + }; + + /** + * This attribute is a string that provides a short description of the instance property. + * + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2 + */ + title?: string; + + /** + * This attribute is a string that provides a full description of the of purpose the instance property. + * + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2 + */ + description?: string; + + /** + * This keyword can be used to supply a default JSON value associated with a particular schema. + * It is RECOMMENDED that a default value be valid against the associated schema. + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3 + */ + default?: JSONSchema6Type; + + /** + * Array of examples with no validation effect; the value of "default" is usable as an example without repeating it under this keyword + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4 + */ + examples?: JSONSchema6Type[]; + } diff --git a/types/json-schema/json-schema-tests.ts b/types/json-schema/json-schema-tests.ts index 58264668b0..cbf23ddfdd 100644 --- a/types/json-schema/json-schema-tests.ts +++ b/types/json-schema/json-schema-tests.ts @@ -1,22 +1,24 @@ -import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName } from 'json-schema' +import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSchema6Type, JSONSchema6TypeName } from 'json-schema'; + +/* JSON Schema 4 */ // SimpleType () => { - const a: JSONSchema4TypeName = 'string' - const b: JSONSchema4TypeName = 'null' - const c: JSONSchema4TypeName = 'any' -} + const a: JSONSchema4TypeName = 'string'; + const b: JSONSchema4TypeName = 'null'; + const c: JSONSchema4TypeName = 'any'; +}; // Type () => { - const a: JSONSchema4Type = 'foo' - const b: JSONSchema4Type = null - const c: JSONSchema4Type = [1, 2] -} + const a: JSONSchema4Type = 'foo'; + const b: JSONSchema4Type = null; + const c: JSONSchema4Type = [1, 2]; +}; // JSONSchema4 () => { - const a: JSONSchema4 = {} + const a: JSONSchema4 = {}; const b: JSONSchema4 = { id: 'foo', $ref: 'foo/bar', @@ -63,5 +65,75 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName } from 'json-schema' not: {}, extends: 'foo', bar: 4 - } -} + }; +}; + +/* JSON Schema 6 */ + +// SimpleType +() => { + const a: JSONSchema6TypeName = 'string'; + const b: JSONSchema6TypeName = 'null'; + const c: JSONSchema6TypeName = 'any'; +}; + +// Type +() => { + const a: JSONSchema6Type = 'foo'; + const b: JSONSchema6Type = null; + const c: JSONSchema6Type = [1, 2]; +}; + +// JSONSchema4 +() => { + const a: JSONSchema6 = {}; + const b: JSONSchema6 = { + $id: 'foo', + $ref: 'foo/bar', + $schema: 'http://json-schema.org/schema#', + title: 'foo', + description: 'bar', + default: 42, + multipleOf: 3, + maximum: 4, + exclusiveMaximum: 4, + minimum: 5, + exclusiveMinimum: 5, + maxLength: 6, + minLength: 7, + pattern: 'baz', + additionalItems: true, + items: [ + { items: [{ minLength: 4 }] } + ], + maxItems: 4, + minItems: 5, + uniqueItems: true, + maxProperties: 10, + minProperties: 11, + required: ['foo', 'bar'], + additionalProperties: false, + definitions: { + foo: { type: 'string' } + }, + properties: { + bar: { type: 'boolean' } + }, + patternProperties: { + foo: { type: 'integer' } + }, + dependencies: { + baz: { type: 'integer' } + }, + enum: ['foo', 42], + type: ['string', 'array'], + allOf: [{}], + anyOf: [{}], + oneOf: [{}], + not: {}, + const: 'foo', + contains: {}, + examples: [{}], + propertyNames: {} + }; +}; diff --git a/types/json-schema/tslint.json b/types/json-schema/tslint.json index ccd796af87..d88586e5bd 100644 --- a/types/json-schema/tslint.json +++ b/types/json-schema/tslint.json @@ -1,8 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "semicolon": [ - false - ] - } + "extends": "dtslint/dt.json" } From bc1743cd4b654b9cbfa27a36d8cc285fefde1785 Mon Sep 17 00:00:00 2001 From: chaosmail Date: Sun, 19 Nov 2017 12:26:41 +0100 Subject: [PATCH 057/639] add createLanguage, Parser.trim and Parser.thru --- types/parsimmon/index.d.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/types/parsimmon/index.d.ts b/types/parsimmon/index.d.ts index dfbae05e23..b7928c5182 100644 --- a/types/parsimmon/index.d.ts +++ b/types/parsimmon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Parsimmon 1.3 +// Type definitions for Parsimmon 1.6.2 // Project: https://github.com/jneen/parsimmon // Definitions by: Bart van der Schoor // Mizunashi Mana @@ -73,6 +73,14 @@ declare namespace Parsimmon { expected: string[]; index: Index; } + + interface Rule { + [key: string]: (r?: Language) => Parser; + } + + interface Language { + [key: string]: Parser; + } interface Parser { /** @@ -106,6 +114,15 @@ declare namespace Parsimmon { */ // tslint:disable-next-line:unified-signatures then(anotherParser: Parser): Parser; + /** + * returns wrapper(this) from the parser. Useful for custom functions used + * to wrap your parsers, while keeping with Parsimmon chaining style. + */ + thru(call: (wrapper: Parser) => Parser): Parser; + /** + * expects anotherParser before and after parser, yielding the result of parser + */ + trim(anotherParser: Parser): Parser; /** * transforms the output of parser with the given function. */ @@ -171,6 +188,11 @@ declare namespace Parsimmon { */ function Parser(fn: (input: string, i: number) => Parsimmon.Reply): Parser; + /** + * Starting point for building a language parser in Parsimmon + */ + function createLanguage(rules: Rule): Language; + /** * To be used inside of Parsimmon(fn). Generates an object describing how * far the successful parse went (index), and what value it created doing From b54ec02d7d92c94ad57272a34ba88c92158271a4 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Sun, 19 Nov 2017 12:41:15 +0100 Subject: [PATCH 058/639] Add types for JSON Schema v6 --- types/json-schema/index.d.ts | 44 ++++++++++++-------------- types/json-schema/json-schema-tests.ts | 4 +-- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/types/json-schema/index.d.ts b/types/json-schema/index.d.ts index 063e11d0f0..6a0af41c91 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -2,7 +2,7 @@ // Project: https://www.npmjs.com/package/json-schema // Definitions by: Boris Cherny , Cyrille Tuzi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.2 /* JSON Schema 4 */ @@ -22,8 +22,8 @@ export type JSONSchema4Type = any[] | boolean | number | null | object | string; * @see https://tools.ietf.org/html/draft-zyp-json-schema-04 */ export interface JSONSchema4 { - id?: string - $ref?: string + id?: string; + $ref?: string; $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | 'http://json-schema.org/draft-04/schema#' | 'http://json-schema.org/draft-04/hyper-schema#' | 'http://json-schema.org/draft-03/schema#' | 'http://json-schema.org/draft-03/hyper-schema#' @@ -117,7 +117,7 @@ export interface JSONSchema4 { definitions?: { [k: string]: JSONSchema4; - } + }; /** * This attribute is an object with property definitions that define the @@ -134,7 +134,7 @@ export interface JSONSchema4 { */ properties?: { [k: string]: JSONSchema4; - } + }; /** * This attribute is an object that defines the schema for a set of @@ -149,10 +149,10 @@ export interface JSONSchema4 { */ patternProperties?: { [k: string]: JSONSchema4; - } + }; dependencies?: { [k: string]: JSONSchema4 | string[]; - } + }; /** * This provides an enumeration of all possible values that are valid @@ -206,11 +206,10 @@ export type JSONSchema6TypeName = 'string' | 'number' | 'integer' | 'boolean' | export type JSONSchema6Type = any[] | boolean | number | null | object | string; /** -* JSON Schema V6 -* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01 -*/ + * JSON Schema V6 + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01 + */ export interface JSONSchema6 { - $id?: string; $ref?: string; $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | @@ -396,14 +395,14 @@ export interface JSONSchema6 { propertyNames?: boolean | JSONSchema6; /** - * This provides an enumeration of all possible values that are valid - * for the instance property. This MUST be an array, and each item in - * the array represents a possible value for the instance value. If - * this attribute is defined, the instance value MUST be one of the - * values in the array in order for the schema to be valid. - * - * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23 - */ + * This provides an enumeration of all possible values that are valid + * for the instance property. This MUST be an array, and each item in + * the array represents a possible value for the instance value. If + * this attribute is defined, the instance value MUST be one of the + * values in the array in order for the schema to be valid. + * + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23 + */ enum?: JSONSchema6Type[]; /** @@ -413,9 +412,9 @@ export interface JSONSchema6 { const?: JSONSchema6Type; /** - * A single type, or a union of simple types - * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25 - */ + * A single type, or a union of simple types + * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25 + */ type?: JSONSchema6TypeName | JSONSchema6TypeName[]; /** @@ -471,5 +470,4 @@ export interface JSONSchema6 { * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4 */ examples?: JSONSchema6Type[]; - } diff --git a/types/json-schema/json-schema-tests.ts b/types/json-schema/json-schema-tests.ts index cbf23ddfdd..431fa7ae59 100644 --- a/types/json-schema/json-schema-tests.ts +++ b/types/json-schema/json-schema-tests.ts @@ -58,7 +58,7 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSch baz: { type: 'integer' } }, enum: ['foo', 42], - type: ['string', 'array'], + type: 'string', allOf: [{}], anyOf: [{}], oneOf: [{}], @@ -126,7 +126,7 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSch baz: { type: 'integer' } }, enum: ['foo', 42], - type: ['string', 'array'], + type: 'string', allOf: [{}], anyOf: [{}], oneOf: [{}], From 6ce5323252401ea2dfdfbeaa4aabeb830f40e055 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Sun, 19 Nov 2017 12:45:49 +0100 Subject: [PATCH 059/639] Add types for JSON Schema v6 --- types/json-schema/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/json-schema/index.d.ts b/types/json-schema/index.d.ts index 6a0af41c91..c660fb370c 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -471,3 +471,5 @@ export interface JSONSchema6 { */ examples?: JSONSchema6Type[]; } + +export { JSONSchema6 as JSONSchema }; From 08c09da16616a976d59d5eebdc6b082094037533 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Sun, 19 Nov 2017 12:47:09 +0100 Subject: [PATCH 060/639] Add types for JSON Schema v6 --- types/json-schema/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/json-schema/index.d.ts b/types/json-schema/index.d.ts index c660fb370c..6a0af41c91 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -471,5 +471,3 @@ export interface JSONSchema6 { */ examples?: JSONSchema6Type[]; } - -export { JSONSchema6 as JSONSchema }; From b60a11e605ed64db115a613ce6ada528b3ba173c Mon Sep 17 00:00:00 2001 From: Christoph Koerner Date: Sun, 19 Nov 2017 12:55:00 +0100 Subject: [PATCH 061/639] fix lint errors --- types/parsimmon/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/parsimmon/index.d.ts b/types/parsimmon/index.d.ts index b7928c5182..26ed383daf 100644 --- a/types/parsimmon/index.d.ts +++ b/types/parsimmon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Parsimmon 1.6.2 +// Type definitions for Parsimmon 1.6 // Project: https://github.com/jneen/parsimmon // Definitions by: Bart van der Schoor // Mizunashi Mana @@ -73,7 +73,7 @@ declare namespace Parsimmon { expected: string[]; index: Index; } - + interface Rule { [key: string]: (r?: Language) => Parser; } @@ -115,7 +115,7 @@ declare namespace Parsimmon { // tslint:disable-next-line:unified-signatures then(anotherParser: Parser): Parser; /** - * returns wrapper(this) from the parser. Useful for custom functions used + * returns wrapper(this) from the parser. Useful for custom functions used * to wrap your parsers, while keeping with Parsimmon chaining style. */ thru(call: (wrapper: Parser) => Parser): Parser; @@ -192,7 +192,7 @@ declare namespace Parsimmon { * Starting point for building a language parser in Parsimmon */ function createLanguage(rules: Rule): Language; - + /** * To be used inside of Parsimmon(fn). Generates an object describing how * far the successful parse went (index), and what value it created doing From a9235ba9f552d213abcfeac5992220f50286fdcb Mon Sep 17 00:00:00 2001 From: Andrew Makarov Date: Sun, 19 Nov 2017 19:47:40 +0300 Subject: [PATCH 062/639] [autobind-decorator] removed typings --- notNeededPackages.json | 6 ++ .../autobind-decorator-tests.ts | 42 ---------- types/autobind-decorator/index.d.ts | 10 --- types/autobind-decorator/tsconfig.json | 26 ------ types/autobind-decorator/tslint.json | 79 ------------------- 5 files changed, 6 insertions(+), 157 deletions(-) delete mode 100644 types/autobind-decorator/autobind-decorator-tests.ts delete mode 100644 types/autobind-decorator/index.d.ts delete mode 100644 types/autobind-decorator/tsconfig.json delete mode 100644 types/autobind-decorator/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 306865851b..3164ec5d3c 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -60,6 +60,12 @@ "sourceRepoURL": "https://github.com/AlexTeixeira/Askmethat-Rating", "asOfVersion": "0.4.0" }, + { + "libraryName": "autobind-decorator", + "typingsPackageName": "autobind-decorator", + "sourceRepoURL": "https://github.com/andreypopp/autobind-decorator", + "asOfVersion": "2.1.0" + }, { "libraryName": "aws-sdk", "typingsPackageName": "aws-sdk", diff --git a/types/autobind-decorator/autobind-decorator-tests.ts b/types/autobind-decorator/autobind-decorator-tests.ts deleted file mode 100644 index f5a0c76328..0000000000 --- a/types/autobind-decorator/autobind-decorator-tests.ts +++ /dev/null @@ -1,42 +0,0 @@ - -import autobind = require('autobind-decorator'); - -class Test { - public static what: string = 'static'; - - @autobind - public static test(): void { - console.log(this.what); - } - - public constructor(public what: string) { - this.what = what; - } - - @autobind - public test(): void { - console.warn(this.what); - } -} - -const tester: Test = new Test('bind'); -const { test } = tester; -tester.test(); // warns 'bind'. -test(); // warns 'bind'. -Test.test(); // logs 'static'. - -@autobind -class Component { - public constructor(private someMember: string) { - this.someMember = someMember; - } - - public someMethod(): void { - console.error(this.someMember); - } -} - -const component: Component = new Component('React vs Angular2'); -const { someMethod } = component; -component.someMethod(); // errors 'React vs Angular2' -someMethod(); // errors 'React vs Angular2' diff --git a/types/autobind-decorator/index.d.ts b/types/autobind-decorator/index.d.ts deleted file mode 100644 index d8d74bbfec..0000000000 --- a/types/autobind-decorator/index.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Type definitions for autobind-decorator v1.3.3 -// Project: https://github.com/andreypopp/autobind-decorator -// Definitions by: Ivo Stratev -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module 'autobind-decorator' { - function autobind(target: TFunction): TFunction | void; - function autobind(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void; - export = autobind; -} diff --git a/types/autobind-decorator/tsconfig.json b/types/autobind-decorator/tsconfig.json deleted file mode 100644 index 0b05ea04fb..0000000000 --- a/types/autobind-decorator/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "experimentalDecorators": true, - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "autobind-decorator-tests.ts" - ] -} \ No newline at end of file diff --git a/types/autobind-decorator/tslint.json b/types/autobind-decorator/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/autobind-decorator/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 9ea6b34ae8ccf7eb6492f54cc78ba6e7564a798c Mon Sep 17 00:00:00 2001 From: Ryan Posener Date: Sun, 19 Nov 2017 10:46:52 -0700 Subject: [PATCH 063/639] DirtyFlag does not have methods - the object only has a default function, which returns a result. This result also has another function forceDirty() that is not included. --- types/kolite/knockout.dirtyFlag.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/kolite/knockout.dirtyFlag.d.ts b/types/kolite/knockout.dirtyFlag.d.ts index 2f63a110e0..3999f833ae 100644 --- a/types/kolite/knockout.dirtyFlag.d.ts +++ b/types/kolite/knockout.dirtyFlag.d.ts @@ -10,9 +10,14 @@ // DirtyFlag ///////////////////////////////////////////// interface DirtyFlag { - isDirty: KnockoutComputed; new (objectToTrack: any, isInitiallyDirty?: boolean, hashFunction?: () => any): any; + (): DirtyFlagResult; +} + +interface DirtyFlagResult { + isDirty: KnockoutComputed; reset(): void; + forceDirty(): void; } interface KnockoutStatic { From a1cae9f28e23ae9876bf05037f437cc7329fe483 Mon Sep 17 00:00:00 2001 From: linxiaowu66 Date: Mon, 20 Nov 2017 14:05:57 +0800 Subject: [PATCH 064/639] feat(better-scroll): update better-scroll types definition to v1.4.2 --- types/better-scroll/index.d.ts | 41 +++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/types/better-scroll/index.d.ts b/types/better-scroll/index.d.ts index 559b21bba2..c4a6f99a57 100644 --- a/types/better-scroll/index.d.ts +++ b/types/better-scroll/index.d.ts @@ -1,12 +1,14 @@ -// Type definitions for better-scroll.js 1.3 +// Type definitions for better-scroll.js 1.4.2 // Project: https://github.com/ustbhuangyi/better-scroll // Definitions by: linxiaowu66 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 interface WheelOption { - selectedIndex?: number; + selectedIndex: number; rotate?: number; adjustTime?: number; + wheelWrapperClass?: string; + wheelItemClass?: string; } interface SlideOption { @@ -16,6 +18,7 @@ interface SlideOption { stepX?: number; stepY?: number; listenFlick?: boolean; + speed?: number; } interface ScrollBarOption { fade?: boolean; @@ -27,6 +30,12 @@ interface PullDownOption { interface PullUpOption { threshold?: number; } +interface PageOption { + x: number, + y: number, + pageX: number, + pageY: number +} interface BsOption { startX?: number; startY?: number; @@ -62,10 +71,12 @@ interface BsOption { * wheel: { * selectedIndex: 0; * rotate: 25; - * adjustTime: 400 + * adjustTime: 400; + * wheelWrapperClass: 'wheel-scroll'; + * wheelItemClass: 'wheel-item'; * } */ - wheel?: WheelOption | boolean; + wheel?: Partial | boolean; /** * for slide * snap: { @@ -77,14 +88,14 @@ interface BsOption { * listenFlick: true * } */ - snap?: SlideOption | boolean; + snap?: Partial | boolean; /** * for scrollbar * scrollbar: { * fade: true * } */ - scrollbar?: ScrollBarOption | boolean; + scrollbar?: Partial | boolean; /** * for pull down and refresh * pullDownRefresh: { @@ -92,20 +103,30 @@ interface BsOption { * stop: 20 * } */ - pullDownRefresh?: PullDownOption | boolean; + pullDownRefresh?: Partial | boolean; /** * for pull up and load * pullUpLoad: { * threshold: 50 * } */ - pullUpLoad?: PullUpOption | boolean; + pullUpLoad?: Partial | boolean; } declare class BScroll { constructor(element: Element | string, options?: BsOption); // 重新计算 better-scroll,当 DOM 结构发生变化的时候务必要调用确保滚动的效果正常 x: number; y: number; + maxScrollX: number; + maxScrollY: number; + movingDirectionX: number; + movingDirectionY: number; + directionX: number; + directionY: number; + enabled: boolean; + isInTransition: boolean; + isAnimating: boolean; + options: BsOption; refresh(): void; // 启用 better-scroll; 默认 开启 @@ -130,11 +151,11 @@ declare class BScroll { // 滚动到上一个页面 prev(time: number, easing: object): void; // 获取当前页面的信息 - getCurrentPage(): void; + getCurrentPage(): PageOption; // 当我们做 picker 组件的时候,调用该方法可以滚动到索引对应的位置 wheelTo(index: number): void; // 获取当前选中的索引值 - getSelectedIndex(): void; + getSelectedIndex(): number; // 当下拉刷新数据加载完毕后,需要调用此方法告诉 better-scroll 数据已加载 finishPullDown(): void; // 当上拉加载数据加载完毕后,需要调用此方法告诉 better-scroll 数据已加载 From 9ced36bfc6b81683e900fe8d707dd38dd73618dd Mon Sep 17 00:00:00 2001 From: linxiaowu66 Date: Mon, 20 Nov 2017 14:20:24 +0800 Subject: [PATCH 065/639] feat(types): update better-scroll types definition to v1.4.2 --- types/better-scroll/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/better-scroll/index.d.ts b/types/better-scroll/index.d.ts index c4a6f99a57..e975eec4ae 100644 --- a/types/better-scroll/index.d.ts +++ b/types/better-scroll/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for better-scroll.js 1.4.2 +// Type definitions for better-scroll.js 1.4.0 // Project: https://github.com/ustbhuangyi/better-scroll // Definitions by: linxiaowu66 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From d6353cb3385398f548a6c65480bf70a1eb15ee23 Mon Sep 17 00:00:00 2001 From: linxiaowu66 Date: Mon, 20 Nov 2017 14:31:52 +0800 Subject: [PATCH 066/639] feat(types): update better-scroll types definition to v1.4.2 --- types/better-scroll/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/better-scroll/index.d.ts b/types/better-scroll/index.d.ts index e975eec4ae..a0c7869a48 100644 --- a/types/better-scroll/index.d.ts +++ b/types/better-scroll/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for better-scroll.js 1.4.0 +// Type definitions for better-scroll.js 1.4 // Project: https://github.com/ustbhuangyi/better-scroll // Definitions by: linxiaowu66 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From c00e41b7b9c057cac98d1fea3666d0a4f0056590 Mon Sep 17 00:00:00 2001 From: linxiaowu66 Date: Mon, 20 Nov 2017 14:38:45 +0800 Subject: [PATCH 067/639] feat(types): update better-scroll types definition to v1.4.2 --- types/better-scroll/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/better-scroll/index.d.ts b/types/better-scroll/index.d.ts index a0c7869a48..3f48fed9db 100644 --- a/types/better-scroll/index.d.ts +++ b/types/better-scroll/index.d.ts @@ -31,10 +31,10 @@ interface PullUpOption { threshold?: number; } interface PageOption { - x: number, - y: number, - pageX: number, - pageY: number + x: number; + y: number; + pageX: number; + pageY: number; } interface BsOption { startX?: number; From 624c5ad4fb475ea23658d652c9eac92052159846 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Mon, 20 Nov 2017 09:00:49 +0100 Subject: [PATCH 068/639] Add types for JSON Schema v6 --- types/json-schema/index.d.ts | 162 ++++++++++++------------- types/json-schema/json-schema-tests.ts | 46 +++---- types/json-schema/tslint.json | 5 +- 3 files changed, 108 insertions(+), 105 deletions(-) diff --git a/types/json-schema/index.d.ts b/types/json-schema/index.d.ts index 6a0af41c91..7f02b671a0 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -10,24 +10,24 @@ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1 */ export type JSONSchema4TypeName = 'string' | 'number' | 'integer' | 'boolean' - | 'object' | 'array' | 'null' | 'any'; + | 'object' | 'array' | 'null' | 'any' /** * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-3.5 */ -export type JSONSchema4Type = any[] | boolean | number | null | object | string; +export type JSONSchema4Type = any[] | boolean | number | null | object | string /** * JSON Schema V4 * @see https://tools.ietf.org/html/draft-zyp-json-schema-04 */ export interface JSONSchema4 { - id?: string; - $ref?: string; + id?: string + $ref?: string $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | 'http://json-schema.org/draft-04/schema#' | 'http://json-schema.org/draft-04/hyper-schema#' | 'http://json-schema.org/draft-03/schema#' | 'http://json-schema.org/draft-03/hyper-schema#' - | string; + | string /** * This attribute is a string that provides a short description of the @@ -35,7 +35,7 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.21 */ - title?: string; + title?: string /** * This attribute is a string that provides a full description of the of @@ -43,17 +43,17 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.22 */ - description?: string; + description?: string - default?: JSONSchema4Type; - multipleOf?: number; - maximum?: number; - exclusiveMaximum?: boolean; - minimum?: number; - exclusiveMinimum?: boolean; - maxLength?: number; - minLength?: number; - pattern?: string; + default?: JSONSchema4Type + multipleOf?: number + maximum?: number + exclusiveMaximum?: boolean + minimum?: number + exclusiveMinimum?: boolean + maxLength?: number + minLength?: number + pattern?: string /** * May only be defined when "items" is defined, and is a tuple of JSONSchemas. @@ -65,7 +65,7 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.6 */ - additionalItems?: boolean | JSONSchema4; + additionalItems?: boolean | JSONSchema4 /** * This attribute defines the allowed items in an instance array, and @@ -86,13 +86,13 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.5 */ - items?: JSONSchema4 | JSONSchema4[]; + items?: JSONSchema4 | JSONSchema4[] - maxItems?: number; - minItems?: number; - uniqueItems?: boolean; - maxProperties?: number; - minProperties?: number; + maxItems?: number + minItems?: number + uniqueItems?: boolean + maxProperties?: number + minProperties?: number /** * This attribute indicates if the instance must have a value, and not @@ -101,7 +101,7 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.7 */ - required?: false | string[]; + required?: false | string[] /** * This attribute defines a schema for all properties that are not @@ -113,11 +113,11 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.4 */ - additionalProperties?: boolean | JSONSchema4; + additionalProperties?: boolean | JSONSchema4 definitions?: { - [k: string]: JSONSchema4; - }; + [k: string]: JSONSchema4 + } /** * This attribute is an object with property definitions that define the @@ -133,8 +133,8 @@ export interface JSONSchema4 { * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.2 */ properties?: { - [k: string]: JSONSchema4; - }; + [k: string]: JSONSchema4 + } /** * This attribute is an object that defines the schema for a set of @@ -148,11 +148,11 @@ export interface JSONSchema4 { * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.3 */ patternProperties?: { - [k: string]: JSONSchema4; - }; + [k: string]: JSONSchema4 + } dependencies?: { - [k: string]: JSONSchema4 | string[]; - }; + [k: string]: JSONSchema4 | string[] + } /** * This provides an enumeration of all possible values that are valid @@ -163,17 +163,17 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.19 */ - enum?: JSONSchema4Type[]; + enum?: JSONSchema4Type[] /** * A single type, or a union of simple types */ - type?: JSONSchema4TypeName | JSONSchema4TypeName[]; + type?: JSONSchema4TypeName | JSONSchema4TypeName[] - allOf?: JSONSchema4[]; - anyOf?: JSONSchema4[]; - oneOf?: JSONSchema4[]; - not?: JSONSchema4; + allOf?: JSONSchema4[] + anyOf?: JSONSchema4[] + oneOf?: JSONSchema4[] + not?: JSONSchema4 /** * The value of this property MUST be another schema which will provide @@ -191,71 +191,71 @@ export interface JSONSchema4 { * * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.26 */ - extends?: string | string[]; + extends?: string | string[] /** * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-5.6 */ - [k: string]: any; + [k: string]: any } /* JSON Schema 6 */ -export type JSONSchema6TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null' | 'any'; +export type JSONSchema6TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null' | 'any' -export type JSONSchema6Type = any[] | boolean | number | null | object | string; +export type JSONSchema6Type = any[] | boolean | number | null | object | string /** * JSON Schema V6 * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01 */ export interface JSONSchema6 { - $id?: string; - $ref?: string; + $id?: string + $ref?: string $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | - 'http://json-schema.org/draft-06/schema#' | 'http://json-schema.org/draft-06/hyper-schema#'; + 'http://json-schema.org/draft-06/schema#' | 'http://json-schema.org/draft-06/hyper-schema#' /** * Must be strictly greater than 0. * A numeric instance is valid only if division by this keyword's value results in an integer. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1 */ - multipleOf?: number; + multipleOf?: number /** * Representing an inclusive upper limit for a numeric instance. * This keyword validates only if the instance is less than or exactly equal to "maximum". * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2 */ - maximum?: number; + maximum?: number /** * Representing an exclusive upper limit for a numeric instance. * This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum". * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3 */ - exclusiveMaximum?: number; + exclusiveMaximum?: number /** * Representing an inclusive lower limit for a numeric instance. * This keyword validates only if the instance is greater than or exactly equal to "minimum". * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4 */ - minimum?: number; + minimum?: number /** * Representing an exclusive lower limit for a numeric instance. * This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum". * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5 */ - exclusiveMinimum?: number; + exclusiveMinimum?: number /** * Must be a non-negative integer. * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6 */ - maxLength?: number; + maxLength?: number /** * Must be a non-negative integer. @@ -263,20 +263,20 @@ export interface JSONSchema6 { * Omitting this keyword has the same behavior as a value of 0. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7 */ - minLength?: number; + minLength?: number /** * Should be a valid regular expression, according to the ECMA 262 regular expression dialect. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8 */ - pattern?: string; + pattern?: string /** * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. * Omitting this keyword has the same behavior as an empty schema. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9 */ - items?: boolean | JSONSchema6 | JSONSchema6[]; + items?: boolean | JSONSchema6 | JSONSchema6[] /** * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. @@ -287,14 +287,14 @@ export interface JSONSchema6 { * Omitting this keyword has the same behavior as an empty schema. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10 */ - additionalItems?: boolean | JSONSchema6; + additionalItems?: boolean | JSONSchema6 /** * Must be a non-negative integer. * An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11 */ - maxItems?: number; + maxItems?: number /** * Must be a non-negative integer. @@ -302,7 +302,7 @@ export interface JSONSchema6 { * Omitting this keyword has the same behavior as a value of 0. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12 */ - minItems?: number; + minItems?: number /** * If this keyword has boolean value false, the instance validates successfully. @@ -310,20 +310,20 @@ export interface JSONSchema6 { * Omitting this keyword has the same behavior as a value of false. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13 */ - uniqueItems?: boolean; + uniqueItems?: boolean /** * An array instance is valid against "contains" if at least one of its elements is valid against the given schema. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14 */ - contains?: boolean | JSONSchema6; + contains?: boolean | JSONSchema6 /** * Must be a non-negative integer. * An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15 */ - maxProperties?: number; + maxProperties?: number /** * Must be a non-negative integer. @@ -332,7 +332,7 @@ export interface JSONSchema6 { * Omitting this keyword has the same behavior as a value of 0. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16 */ - minProperties?: number; + minProperties?: number /** * Elements of this array must be unique. @@ -341,7 +341,7 @@ export interface JSONSchema6 { * * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17 */ - required?: string[]; + required?: string[] /** * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. @@ -352,7 +352,7 @@ export interface JSONSchema6 { */ properties?: { [k: string]: boolean | JSONSchema6 - }; + } /** * This attribute is an object that defines the schema for a set of property names of an object instance. @@ -364,7 +364,7 @@ export interface JSONSchema6 { */ patternProperties?: { [k: string]: boolean | JSONSchema6 - }; + } /** * This attribute defines a schema for all properties that are not explicitly defined in an object type definition. @@ -373,7 +373,7 @@ export interface JSONSchema6 { * The default value is an empty schema which allows any value for additional properties. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20 */ - additionalProperties?: boolean | JSONSchema6; + additionalProperties?: boolean | JSONSchema6 /** * This keyword specifies rules that are evaluated if the instance is an object and contains a certain property. @@ -384,7 +384,7 @@ export interface JSONSchema6 { */ dependencies?: { [k: string]: boolean | JSONSchema6 | string[] - }; + } /** * Takes a schema which validates the names of all properties rather than their values. @@ -392,7 +392,7 @@ export interface JSONSchema6 { * Omitting this keyword has the same behavior as an empty schema. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22 */ - propertyNames?: boolean | JSONSchema6; + propertyNames?: boolean | JSONSchema6 /** * This provides an enumeration of all possible values that are valid @@ -403,71 +403,71 @@ export interface JSONSchema6 { * * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23 */ - enum?: JSONSchema6Type[]; + enum?: JSONSchema6Type[] /** * More readible form of a one-element "enum" * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24 */ - const?: JSONSchema6Type; + const?: JSONSchema6Type /** * A single type, or a union of simple types * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25 */ - type?: JSONSchema6TypeName | JSONSchema6TypeName[]; + type?: JSONSchema6TypeName | JSONSchema6TypeName[] /** * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26 */ - allOf?: JSONSchema6[]; + allOf?: JSONSchema6[] /** * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27 */ - anyOf?: JSONSchema6[]; + anyOf?: JSONSchema6[] /** * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28 */ - oneOf?: JSONSchema6[]; + oneOf?: JSONSchema6[] /** * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29 */ - not?: boolean | JSONSchema6; + not?: boolean | JSONSchema6 /** * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1 */ definitions?: { [k: string]: boolean | JSONSchema6 - }; + } /** * This attribute is a string that provides a short description of the instance property. * * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2 */ - title?: string; + title?: string /** * This attribute is a string that provides a full description of the of purpose the instance property. * * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2 */ - description?: string; + description?: string /** * This keyword can be used to supply a default JSON value associated with a particular schema. * It is RECOMMENDED that a default value be valid against the associated schema. * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3 */ - default?: JSONSchema6Type; + default?: JSONSchema6Type /** - * Array of examples with no validation effect; the value of "default" is usable as an example without repeating it under this keyword + * Array of examples with no validation effect the value of "default" is usable as an example without repeating it under this keyword * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4 */ - examples?: JSONSchema6Type[]; + examples?: JSONSchema6Type[] } diff --git a/types/json-schema/json-schema-tests.ts b/types/json-schema/json-schema-tests.ts index 431fa7ae59..0fd15f5de9 100644 --- a/types/json-schema/json-schema-tests.ts +++ b/types/json-schema/json-schema-tests.ts @@ -1,24 +1,24 @@ -import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSchema6Type, JSONSchema6TypeName } from 'json-schema'; +import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSchema6Type, JSONSchema6TypeName } from 'json-schema' /* JSON Schema 4 */ // SimpleType () => { - const a: JSONSchema4TypeName = 'string'; - const b: JSONSchema4TypeName = 'null'; - const c: JSONSchema4TypeName = 'any'; -}; + const a: JSONSchema4TypeName = 'string' + const b: JSONSchema4TypeName = 'null' + const c: JSONSchema4TypeName = 'any' +} // Type () => { - const a: JSONSchema4Type = 'foo'; - const b: JSONSchema4Type = null; - const c: JSONSchema4Type = [1, 2]; -}; + const a: JSONSchema4Type = 'foo' + const b: JSONSchema4Type = null + const c: JSONSchema4Type = [1, 2] +} // JSONSchema4 () => { - const a: JSONSchema4 = {}; + const a: JSONSchema4 = {} const b: JSONSchema4 = { id: 'foo', $ref: 'foo/bar', @@ -65,28 +65,28 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSch not: {}, extends: 'foo', bar: 4 - }; -}; + } +} /* JSON Schema 6 */ // SimpleType () => { - const a: JSONSchema6TypeName = 'string'; - const b: JSONSchema6TypeName = 'null'; - const c: JSONSchema6TypeName = 'any'; -}; + const a: JSONSchema6TypeName = 'string' + const b: JSONSchema6TypeName = 'null' + const c: JSONSchema6TypeName = 'any' +} // Type () => { - const a: JSONSchema6Type = 'foo'; - const b: JSONSchema6Type = null; - const c: JSONSchema6Type = [1, 2]; -}; + const a: JSONSchema6Type = 'foo' + const b: JSONSchema6Type = null + const c: JSONSchema6Type = [1, 2] +} // JSONSchema4 () => { - const a: JSONSchema6 = {}; + const a: JSONSchema6 = {} const b: JSONSchema6 = { $id: 'foo', $ref: 'foo/bar', @@ -135,5 +135,5 @@ import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema6, JSONSch contains: {}, examples: [{}], propertyNames: {} - }; -}; + } +} diff --git a/types/json-schema/tslint.json b/types/json-schema/tslint.json index d88586e5bd..f336e521da 100644 --- a/types/json-schema/tslint.json +++ b/types/json-schema/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "semicolon": false + } } From 1cea5f323c68a73f85513692fbc78fd16612411c Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Mon, 20 Nov 2017 09:03:35 +0100 Subject: [PATCH 069/639] Add types for JSON Schema v6 --- types/json-schema/tslint.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/json-schema/tslint.json b/types/json-schema/tslint.json index f336e521da..ccd796af87 100644 --- a/types/json-schema/tslint.json +++ b/types/json-schema/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "semicolon": false + "semicolon": [ + false + ] } } From 68d694c059d0590e547a9a61add246a33e3ca163 Mon Sep 17 00:00:00 2001 From: amirgro Date: Mon, 20 Nov 2017 12:46:59 +0200 Subject: [PATCH 070/639] update VictoryAxisProps with invertAxis prop --- types/victory/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/victory/index.d.ts b/types/victory/index.d.ts index 6640fdd7f5..b41fb96068 100644 --- a/types/victory/index.d.ts +++ b/types/victory/index.d.ts @@ -764,6 +764,10 @@ declare module "victory" { * @default */ gridComponent?: React.ReactElement; + /** + * If true, this value will flip the domain of a given axis. + */ + invertAxis?: boolean; /** * The label prop defines the label that will appear along the axis. This * prop should be given as a value or an entire, HTML-complete label From 3a88a0abc4fa65bcdc67cd0573ce294dc1bf78d8 Mon Sep 17 00:00:00 2001 From: Rhys van der Waerden Date: Mon, 20 Nov 2017 22:15:10 +1100 Subject: [PATCH 071/639] heatmap.js: Remove `Point` type Inline type that is used in only one place. --- types/heatmap.js/index.d.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/types/heatmap.js/index.d.ts b/types/heatmap.js/index.d.ts index 288d50b448..265f17f5fb 100644 --- a/types/heatmap.js/index.d.ts +++ b/types/heatmap.js/index.d.ts @@ -159,7 +159,7 @@ export class Heatmap { * // get the value at x=10, y=10 * heatmapInstance.getValueAt({ x: 10, y: 10 }); // returns 100 */ - getValueAt(point: Point<'x', 'y'>): number; + getValueAt(point: { x: number, y: number }): number; /** * Returns a persistable and reimportable (with setData) JSON object. @@ -305,12 +305,6 @@ export interface HeatmapOverlayConfiguration< lngField?: TLong; } -/** - * A position in the heatmap. - */ -export type Point = - Record; - /** * A single data point on a heatmap. The interface of the data point can be * overridden by providing alternative values for `xKey` and `yKey` in the @@ -320,8 +314,7 @@ export type DataPoint< V extends string = 'value', X extends string = 'x', Y extends string = 'y', -> = - Record & Point; +> = Record; /** * Type of data returned by `Heatmap#hello`, which ignores custom `xField`, From 1c5945ab3f5c0ad7fd1622f131771604b9ef1acf Mon Sep 17 00:00:00 2001 From: Robert Katzki Date: Mon, 20 Nov 2017 12:32:20 +0100 Subject: [PATCH 072/639] fix(rc-slider): allow null for step prop According to the documentation of [rc-slider](https://github.com/react-component/slider#common-api) `null` is allowed for the step property and has different functionality than passing in `undefined`. --- types/rc-slider/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/rc-slider/index.d.ts b/types/rc-slider/index.d.ts index a0209132df..f64ae8c03c 100644 --- a/types/rc-slider/index.d.ts +++ b/types/rc-slider/index.d.ts @@ -41,7 +41,7 @@ export interface CommonApiProps { * Value to be added or subtracted on each step the slider makes. Must be greater than zero, and max - min should be evenly divisible by the step value. * @default 1 */ - step?: number; + step?: number | null; /** * If vertical is true, the slider will be vertical. * @default false From 982412790618197547ab377cce6ad51ae93def0a Mon Sep 17 00:00:00 2001 From: Arturas Molcanovas Date: Mon, 20 Nov 2017 14:15:44 +0000 Subject: [PATCH 073/639] update semaphore types for 1.1.0 --- types/semaphore/index.d.ts | 7 ++++--- types/semaphore/semaphore-tests.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/types/semaphore/index.d.ts b/types/semaphore/index.d.ts index 5733785782..3164f95d9e 100644 --- a/types/semaphore/index.d.ts +++ b/types/semaphore/index.d.ts @@ -1,10 +1,9 @@ -// Type definitions for semaphore v1.0.3 +// Type definitions for semaphore v1.1.0 // Project: https://github.com/abrkn/semaphore.js // Definitions by: Matt Frantz +// Arturas Molcanovas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - declare function semaphore(capacity?: number): semaphore.Semaphore; declare namespace semaphore { @@ -16,6 +15,8 @@ declare namespace semaphore { interface Semaphore { capacity: number; + available(n: number): boolean; + take(task: Task): void; take(n: number, task: Task): void; diff --git a/types/semaphore/semaphore-tests.ts b/types/semaphore/semaphore-tests.ts index c3d53990fc..5770a9ba15 100644 --- a/types/semaphore/semaphore-tests.ts +++ b/types/semaphore/semaphore-tests.ts @@ -10,3 +10,5 @@ function task() { sem.take(task); sem.take(2, task); sem.leave(2); + +const available: boolean = sem.available(2); From 8813939634ce428363c432f9c3ef5837a0f91f90 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 15:46:15 +0100 Subject: [PATCH 074/639] add optional Parameter to confirmOptions --- types/confirmDialog/index.d.ts | 98 ++++ types/confirmDialog/jquery-confirm.ts | 644 ++++++++++++++++++++++++++ types/confirmDialog/tsconfig.json | 21 + types/confirmDialog/tslint.json | 31 ++ 4 files changed, 794 insertions(+) create mode 100644 types/confirmDialog/index.d.ts create mode 100644 types/confirmDialog/jquery-confirm.ts create mode 100644 types/confirmDialog/tsconfig.json create mode 100644 types/confirmDialog/tslint.json diff --git a/types/confirmDialog/index.d.ts b/types/confirmDialog/index.d.ts new file mode 100644 index 0000000000..d205b45957 --- /dev/null +++ b/types/confirmDialog/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ +// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Definitions by: Alli Pierre Yotti https://github.com/allipierre +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface JQueryStatic { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any | string, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | string): void; +} + + +interface JQuery { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | any): void; +} + +interface Window { + setContentAppend: any; +} + + + +declare namespace options { + + interface confirmOptions { + buttons? : buttonOptionss | any, + title? : string | boolean, + content? : string | Function, + onContentReady?: Function, + lazyOpen?: boolean, + closeIcon?: boolean | Function, + type?: string, + typeAnimated?: boolean, + icon?: string, + closeIconClass?: string, + columnClass?: string, + containerFluid?: boolean, + boxWidth?: string, + useBootstrap?: boolean, + bootstrapClasses?: any, + draggable?: boolean, + dragWindowBorder?: boolean, + dragWindowGap?: number, + contentLoaded?: Function, + autoClose?: String, + backgroundDismiss?: boolean | Function | string, + backgroundDismissAnimation?: string, + escapeKey?: string | boolean, + onOpenBefore?:Function, + onOpen?: Function, + onClose?: Function, + onDestroy?: Function, + onAction?: Function + + + } + + interface buttonOptionss { + cancel?: Function, + confirm?: Function + } + +} + +declare namespace jconfirm { + let defaults: any; + +} diff --git a/types/confirmDialog/jquery-confirm.ts b/types/confirmDialog/jquery-confirm.ts new file mode 100644 index 0000000000..109558a737 --- /dev/null +++ b/types/confirmDialog/jquery-confirm.ts @@ -0,0 +1,644 @@ +/// +/// +namespace server { + export interface Iperson { + title: string, + content: string, + + + } +} + +class Confirm implements server.Iperson { + private title_: string; + private conTent_: string; + constructor(public title: string, public content: string) { + this.title_ = title; + this.conTent_ = content; + } + + + public confirm() { + $.confirm({ + title: 'Confirm!', + content: 'Simple confirm!', + buttons: { + confirm: function() { + $.alert('Confirmed!'); + }, + cancel: function(cancel: string) { + $.alert('Canceled! ' + cancel); + }, + somethingElse: { + text: 'Something else', + btnClass: 'btn-blue', + keys: ['enter', 'shift'], + action: function() { + alert('Something else?'); + } + } + } + }); + } + + public alert() { + $.alert({ + title: 'Alert!', + content: 'Simple alert!', + }); + } + + public confirm1() { + $.confirm({ + title: 'Prompt!', + content: '' + + '

' + + '
' + + '' + + '' + + '
' + + '', + buttons: { + formSubmit: { + text: 'Submit', + btnClass: 'btn-blue', + action: function() { + let name = this.$content.find('.name').val(); + if (!name) { + $.alert('provide a valid name'); + return false; + } + $.alert('Your name is ' + name); + } + }, + cancel: function() { + //close + }, + }, + onContentReady: function() { + // bind to events + var jc = this; + this.$content.find('form').on('submit', function(e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); + } + }); + + } + + public dialog() { + $.dialog({ + title: 'Text content!', + content: 'Simple modal!' + }); + } + public confirm_2() { + $('.atwitter').val(); + $('.atwitter').text(); + $('a.twitter').confirm({ + content: "...", + }); + $('a.twitter').confirm({ + buttons: { + hey: function() { + location.href = this.$target.attr('href'); + } + } + }); + } + + public confirm_3() { + $.alert('Content here', 'Title here'); + $.confirm('A message', 'Title is optional'); + $.dialog('Just to let you know'); + } + + public confirm_4() { + var a = $.confirm({ + lazyOpen: true, + }); + a.open(); + a.close(); + a.toggle(); // toggle open close. + + } + + public confirm_5() { + $.confirm({ + buttons: { + hello: function(helloButton) { + // shorthand method to define a button + // the button key will be used as button name + }, + hey: function(heyButton) { + // access the button using jquery + this.$$hello.trigger('click'); // click the 'hello' button + this.$$hey.prop('disabled', true); // disable the current button using jquery method + + // jconfirm button methods, all methods listed here + this.buttons.hello.setText('Helloooo'); // setText for 'hello' button + this.buttons.hey.disable(); // disable with button function provided by jconfirm + this.buttons.hey.enable(); // enable with button function provided by jconfirm + // the button's instance is passed as the first argument, for quick access + heyButton === this.buttons.hey + }, + heyThere: { + text: 'Hey there!', // text for button + btnClass: 'btn-blue', // class for the button + keys: ['enter', 'a'], // keyboard event for button + isHidden: false, // initially not hidden + isDisabled: false, // initially not disabled + action: function(heyThereButton) { + // longhand method to define a button + // provides more features + } + }, + } + }); + + } + + public confirm_6() { + $.confirm({ + buttons: { + hey: function() { + // here the button key 'hey' will be used as the text. + $.alert('You clicked on "hey".'); + }, + heyThere: { + text: 'hey there!', // With spaces and symbols + action: function() { + $.alert('You clicked on "heyThere"'); + } + } + } + }); + } + + public confirm_7() { + $.confirm({ + content: 'Time to use your keyboard, press shift, alert, A or B', + buttons: { + specialKey: { + text: 'On behalf of shift', + keys: ['shift', 'alt'], + action: function() { + $.alert('Shift or Alt was pressed'); + } + }, + alphabet: { + text: 'A, B', + keys: ['a', 'b'], + action: function() { + $.alert('A or B was pressed'); + } + } + } + }); + } + + public confirm_8() { + $.confirm({ + closeIcon: true, // explicitly show the close icon + buttons: { + buttonA: { + text: 'button a', + action: function(buttonA) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing + } + }, + resetButton: function(resetButton) {} + } + }); + } + + + public confirm_9() { + $.confirm({ + title: 'Encountered an error!', + content: 'Something went downhill, this may be serious', + type: 'red', + typeAnimated: true, + buttons: { + tryAgain: { + text: 'Try again', + btnClass: 'btn-red', + action: function() {} + }, + close: function() {} + } + }); + } + + public confirm_10() { + $.confirm({ + icon: 'glyphicon glyphicon-heart', + title: 'glyphicon' + }); + $.confirm({ + icon: 'fa fa-warning', + title: 'font-awesome' + }); + $.confirm({ + icon: 'fa fa-spinner fa-spin', + title: 'Working!', + content: 'Sit back, we are processing your request!' + }); + } + + public confirm_11() { + $.confirm({ + closeIcon: true + }); + + $.confirm({ + closeIcon: true, + closeIconClass: 'fa fa-close' + }); + } + + public confirm_12() { + $.confirm({ + closeIcon: function() { + return false; + }, + buttons: { + aRandomButton: function() { + $.alert('A random button is called, and i prevent closing the modal'); + return false; // you shall not pass + }, + close: function() {} + } + }); + } + + public confirm_13() { + $.confirm({ + columnClass: 'small' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-4', + }); + $.confirm({ + columnClass: 'col-md-12' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', + containerFluid: true, // this will add 'container-fluid' instead of 'container' + }); + } + + public confirm_14() { + $.confirm({ + boxWidth: '30%', + useBootstrap: false, + }); + $.confirm({ + boxWidth: '500px', + useBootstrap: false, + }); + } + + public confirm_15() { + $.confirm({ + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + }); + + $.confirm({ + title: 'Hello there', + content: 'click and hold on the title to drag', + draggable: true, + }); + + $.confirm({ + title: 'Hello there', + content: 'Drag this modal out of the window', + draggable: true, + dragWindowBorder: false, + }); + $.confirm({ + title: 'Hello there', + content: 'try to drag this modal out of the window', + draggable: true, + dragWindowGap: 0, // number of px of distance + }); + } + + public ajaxLoading() { + $.confirm({ + title: 'Title', + content: 'url:text.txt', + onContentReady: function() { + var self = this; + this.setContentPrepend('
Prepended text
'); + setTimeout(function() { + self.setContentAppend('
Appended text after 2 seconds
'); + }, 2000); + }, + columnClass: 'medium', + }); + + $.confirm({ + content: function() { + var self = this; + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContent('Description: ' + response.description); + self.setContentAppend('
Version: ' + response.version); + self.setTitle(response.name); + }).fail(function() { + self.setContent('Something went wrong.'); + }); + } + }); + + $.confirm({ + content: 'url:text.txt', + contentLoaded: function(data, status, xhr) { + // data is already set in content + this.setContentAppend('
Status: ' + status); + } + }); + + $.confirm({ + content: function() { + var self = this; + self.setContent('Checking callback flow'); + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContentAppend('
Done!
'); + }).fail(function() { + self.setContentAppend('
Fail!
'); + }).always(function() { + self.setContentAppend('
Always!
'); + }); + }, + contentLoaded: function(data, status, xhr) { + self.setContentAppend('
Content loaded!
'); + }, + onContentReady: function() { + this.setContentAppend('
Content ready!
'); + } + }); + + } + + public autoClose() { + $.confirm({ + title: 'Delete user?', + content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', + autoClose: 'cancelAction|8000', + buttons: { + deleteUser: { + text: 'delete user', + action: function() { + $.alert('Deleted the user!'); + } + }, + cancelAction: function() { + $.alert('action is canceled'); + } + } + }); + $.confirm({ + title: 'Logout?', + content: 'Your time is out, you will be automatically logged out in 10 seconds.', + autoClose: 'logoutUser|10000', + buttons: { + logoutUser: { + text: 'logout myself', + action: function() { + $.alert('The user was logged out'); + } + }, + cancel: function() { + $.alert('canceled'); + } + } + }); + } + + public backgroundDismisse() { + $.confirm({ + backgroundDismiss: true, // this will just close the modal + }); + $.confirm({ + backgroundDismiss: function() { + return false; // modal wont close. + }, + }); + $.confirm({ + backgroundDismiss: function() { + return 'buttonName'; // the button will handle it + }, + }); + $.confirm({ + backgroundDismiss: 'buttonName', + content: 'in here the backgroundDismiss action is handled by buttonName' + + '
', + buttons: { + buttonName: function() { + var $checkbox = this.$content.find('#enableCheckbox'); + return $checkbox.prop('checked'); + }, + close: function() {} + } + }); + } + + public backgroundDismisseAnimation(){ + $.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', +}); +$.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'glow', +}); + } + + public escapeKey(){ + $.confirm({ + escapeKey: true, + backgroundDismiss: false, +}); +$.confirm({ + escapeKey: 'buttonName', + buttons: { + buttonName: function(){ + $.alert('Button name was called'); + }, + close: function(){ + } + } +}); + } + public rtlSupport(){ + $.alert({ + title: 'پیغام', + content: 'این یک متن به زبان شیرین فارسی است', + rtl: true, + closeIcon: true, + buttons: { + confirm: { + text: 'تایید', + btnClass: 'btn-blue', + action: function () { + $.alert('تایید شد.'); + } + }, + cancel: { + text: 'انصراف', + action: function () { + } + } + } +}); + + } + + public callBack(){ + $.confirm({ + title: false, + content: 'url:callback.html', + onContentReady: function () { + // when content is fetched & rendered in DOM + alert('onContentReady'); + var self = this; + this.buttons.ok.disable(); + this.$content.find('.btn').click(function(){ + self.$content.find('input').val('Chuck norris'); + self.buttons.ok.enable(); + }); + }, + contentLoaded: function(data, status, xhr){ + // when content is fetched + alert('contentLoaded: ' + status); + }, + onOpenBefore: function () { + // before the modal is displayed. + alert('onOpenBefore'); + }, + onOpen: function () { + // after the modal is displayed. + alert('onOpen'); + }, + onClose: function () { + // before the modal is hidden. + alert('onClose'); + }, + onDestroy: function () { + // when the modal is removed from DOM + alert('onDestroy'); + }, + onAction: function (btnName) { + // when a button is clicked, with the button name + alert('onAction: ' + btnName); + }, + buttons: { + ok: function(){ + } + } +}); + } + public globalSettings(){ + jconfirm.defaults = { + title: 'Hello', + titleClass: '', + type: 'default', + typeAnimated: true, + draggable: true, + dragWindowGap: 15, + dragWindowBorder: true, + animateFromElement: true, + smoothContent: true, + content: 'Are you sure to continue?', + buttons: {}, + defaultButtons: { + ok: { + action: function () { + } + }, + close: { + action: function () { + } + }, + }, + contentLoaded: function(data, status, xhr){ + }, + icon: '', + lazyOpen: false, + bgOpacity: null, + theme: 'light', + animation: 'scale', + closeAnimation: 'scale', + animationSpeed: 400, + animationBounce: 1, + rtl: false, + container: 'body', + containerFluid: false, + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + autoClose: false, + closeIcon: null, + closeIconClass: false, + watchInterval: 100, + columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', + boxWidth: '50%', + scrollToPreviousElement: true, + scrollToPreviousElementAnimate: true, + useBootstrap: true, + offsetTop: 40, + offsetBottom: 40, + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + onContentReady: function () {}, + onOpenBefore: function () {}, + onOpen: function () {}, + onClose: function () {}, + onDestroy: function () {}, + onAction: function () {} +}; + } + + public api(){ + var jc = $.confirm({ + title: 'awesome', + onContentReady: function(){ + // this === jc + //jc.setTitle(title: string); + } +}); + } + +} + + +var firstName: string = 'Pierre'; +var lastName: string = 'Yotti'; +var type = new Confirm(firstName, lastName); diff --git a/types/confirmDialog/tsconfig.json b/types/confirmDialog/tsconfig.json new file mode 100644 index 0000000000..6949afdda5 --- /dev/null +++ b/types/confirmDialog/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "types", + "typeRoots": ["types"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery_confirm.ts" + ] +} diff --git a/types/confirmDialog/tslint.json b/types/confirmDialog/tslint.json new file mode 100644 index 0000000000..2f73ea817c --- /dev/null +++ b/types/confirmDialog/tslint.json @@ -0,0 +1,31 @@ +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From e01be3c7700e3544cc907fd443ff48b4b234803c Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:01:57 +0100 Subject: [PATCH 075/639] add optional Parameter to confirmOptions --- types/confirmDialog/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/confirmDialog/index.d.ts b/types/confirmDialog/index.d.ts index d205b45957..417a299618 100644 --- a/types/confirmDialog/index.d.ts +++ b/types/confirmDialog/index.d.ts @@ -5,7 +5,7 @@ interface JQueryStatic { /** - * confirm Dialog + * jquery confirm Dialog * @param {confirmOptions} pOtions */ confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; From 966fb905c89979fabc1480ad959c813e137a3594 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:10:05 +0100 Subject: [PATCH 076/639] add optional Parameter to confirmOptions --- types/confirmDialog/index.d.ts | 98 ---- types/confirmDialog/jquery-confirm.ts | 644 -------------------------- types/confirmDialog/tsconfig.json | 21 - types/confirmDialog/tslint.json | 31 -- 4 files changed, 794 deletions(-) delete mode 100644 types/confirmDialog/index.d.ts delete mode 100644 types/confirmDialog/jquery-confirm.ts delete mode 100644 types/confirmDialog/tsconfig.json delete mode 100644 types/confirmDialog/tslint.json diff --git a/types/confirmDialog/index.d.ts b/types/confirmDialog/index.d.ts deleted file mode 100644 index 417a299618..0000000000 --- a/types/confirmDialog/index.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ -// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js -// Definitions by: Alli Pierre Yotti https://github.com/allipierre -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface JQueryStatic { - /** - * jquery confirm Dialog - * @param {confirmOptions} pOtions - */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; - - /** - * confirm alert - * @param {any} pMessage - */ - alert( pMessage?: any | string, title?:string): void; - - /** - * confirm Dialog - * @param {any} pMessage - */ - dialog( pOtions: options.confirmOptions | string): void; -} - - -interface JQuery { - /** - * confirm Dialog - * @param {confirmOptions} pOtions - */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; - - /** - * confirm alert - * @param {any} pMessage - */ - alert( pMessage?: any, title?:string): void; - - /** - * confirm Dialog - * @param {any} pMessage - */ - dialog( pOtions: options.confirmOptions | any): void; -} - -interface Window { - setContentAppend: any; -} - - - -declare namespace options { - - interface confirmOptions { - buttons? : buttonOptionss | any, - title? : string | boolean, - content? : string | Function, - onContentReady?: Function, - lazyOpen?: boolean, - closeIcon?: boolean | Function, - type?: string, - typeAnimated?: boolean, - icon?: string, - closeIconClass?: string, - columnClass?: string, - containerFluid?: boolean, - boxWidth?: string, - useBootstrap?: boolean, - bootstrapClasses?: any, - draggable?: boolean, - dragWindowBorder?: boolean, - dragWindowGap?: number, - contentLoaded?: Function, - autoClose?: String, - backgroundDismiss?: boolean | Function | string, - backgroundDismissAnimation?: string, - escapeKey?: string | boolean, - onOpenBefore?:Function, - onOpen?: Function, - onClose?: Function, - onDestroy?: Function, - onAction?: Function - - - } - - interface buttonOptionss { - cancel?: Function, - confirm?: Function - } - -} - -declare namespace jconfirm { - let defaults: any; - -} diff --git a/types/confirmDialog/jquery-confirm.ts b/types/confirmDialog/jquery-confirm.ts deleted file mode 100644 index 109558a737..0000000000 --- a/types/confirmDialog/jquery-confirm.ts +++ /dev/null @@ -1,644 +0,0 @@ -/// -/// -namespace server { - export interface Iperson { - title: string, - content: string, - - - } -} - -class Confirm implements server.Iperson { - private title_: string; - private conTent_: string; - constructor(public title: string, public content: string) { - this.title_ = title; - this.conTent_ = content; - } - - - public confirm() { - $.confirm({ - title: 'Confirm!', - content: 'Simple confirm!', - buttons: { - confirm: function() { - $.alert('Confirmed!'); - }, - cancel: function(cancel: string) { - $.alert('Canceled! ' + cancel); - }, - somethingElse: { - text: 'Something else', - btnClass: 'btn-blue', - keys: ['enter', 'shift'], - action: function() { - alert('Something else?'); - } - } - } - }); - } - - public alert() { - $.alert({ - title: 'Alert!', - content: 'Simple alert!', - }); - } - - public confirm1() { - $.confirm({ - title: 'Prompt!', - content: '' + - '
' + - '
' + - '' + - '' + - '
' + - '
', - buttons: { - formSubmit: { - text: 'Submit', - btnClass: 'btn-blue', - action: function() { - let name = this.$content.find('.name').val(); - if (!name) { - $.alert('provide a valid name'); - return false; - } - $.alert('Your name is ' + name); - } - }, - cancel: function() { - //close - }, - }, - onContentReady: function() { - // bind to events - var jc = this; - this.$content.find('form').on('submit', function(e) { - // if the user submits the form by pressing enter in the field. - e.preventDefault(); - jc.$$formSubmit.trigger('click'); // reference the button and click it - }); - } - }); - - } - - public dialog() { - $.dialog({ - title: 'Text content!', - content: 'Simple modal!' - }); - } - public confirm_2() { - $('.atwitter').val(); - $('.atwitter').text(); - $('a.twitter').confirm({ - content: "...", - }); - $('a.twitter').confirm({ - buttons: { - hey: function() { - location.href = this.$target.attr('href'); - } - } - }); - } - - public confirm_3() { - $.alert('Content here', 'Title here'); - $.confirm('A message', 'Title is optional'); - $.dialog('Just to let you know'); - } - - public confirm_4() { - var a = $.confirm({ - lazyOpen: true, - }); - a.open(); - a.close(); - a.toggle(); // toggle open close. - - } - - public confirm_5() { - $.confirm({ - buttons: { - hello: function(helloButton) { - // shorthand method to define a button - // the button key will be used as button name - }, - hey: function(heyButton) { - // access the button using jquery - this.$$hello.trigger('click'); // click the 'hello' button - this.$$hey.prop('disabled', true); // disable the current button using jquery method - - // jconfirm button methods, all methods listed here - this.buttons.hello.setText('Helloooo'); // setText for 'hello' button - this.buttons.hey.disable(); // disable with button function provided by jconfirm - this.buttons.hey.enable(); // enable with button function provided by jconfirm - // the button's instance is passed as the first argument, for quick access - heyButton === this.buttons.hey - }, - heyThere: { - text: 'Hey there!', // text for button - btnClass: 'btn-blue', // class for the button - keys: ['enter', 'a'], // keyboard event for button - isHidden: false, // initially not hidden - isDisabled: false, // initially not disabled - action: function(heyThereButton) { - // longhand method to define a button - // provides more features - } - }, - } - }); - - } - - public confirm_6() { - $.confirm({ - buttons: { - hey: function() { - // here the button key 'hey' will be used as the text. - $.alert('You clicked on "hey".'); - }, - heyThere: { - text: 'hey there!', // With spaces and symbols - action: function() { - $.alert('You clicked on "heyThere"'); - } - } - } - }); - } - - public confirm_7() { - $.confirm({ - content: 'Time to use your keyboard, press shift, alert, A or B', - buttons: { - specialKey: { - text: 'On behalf of shift', - keys: ['shift', 'alt'], - action: function() { - $.alert('Shift or Alt was pressed'); - } - }, - alphabet: { - text: 'A, B', - keys: ['a', 'b'], - action: function() { - $.alert('A or B was pressed'); - } - } - } - }); - } - - public confirm_8() { - $.confirm({ - closeIcon: true, // explicitly show the close icon - buttons: { - buttonA: { - text: 'button a', - action: function(buttonA) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. - return false; // prevent the modal from closing - } - }, - resetButton: function(resetButton) {} - } - }); - } - - - public confirm_9() { - $.confirm({ - title: 'Encountered an error!', - content: 'Something went downhill, this may be serious', - type: 'red', - typeAnimated: true, - buttons: { - tryAgain: { - text: 'Try again', - btnClass: 'btn-red', - action: function() {} - }, - close: function() {} - } - }); - } - - public confirm_10() { - $.confirm({ - icon: 'glyphicon glyphicon-heart', - title: 'glyphicon' - }); - $.confirm({ - icon: 'fa fa-warning', - title: 'font-awesome' - }); - $.confirm({ - icon: 'fa fa-spinner fa-spin', - title: 'Working!', - content: 'Sit back, we are processing your request!' - }); - } - - public confirm_11() { - $.confirm({ - closeIcon: true - }); - - $.confirm({ - closeIcon: true, - closeIconClass: 'fa fa-close' - }); - } - - public confirm_12() { - $.confirm({ - closeIcon: function() { - return false; - }, - buttons: { - aRandomButton: function() { - $.alert('A random button is called, and i prevent closing the modal'); - return false; // you shall not pass - }, - close: function() {} - } - }); - } - - public confirm_13() { - $.confirm({ - columnClass: 'small' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-4', - }); - $.confirm({ - columnClass: 'col-md-12' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', - containerFluid: true, // this will add 'container-fluid' instead of 'container' - }); - } - - public confirm_14() { - $.confirm({ - boxWidth: '30%', - useBootstrap: false, - }); - $.confirm({ - boxWidth: '500px', - useBootstrap: false, - }); - } - - public confirm_15() { - $.confirm({ - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - }); - - $.confirm({ - title: 'Hello there', - content: 'click and hold on the title to drag', - draggable: true, - }); - - $.confirm({ - title: 'Hello there', - content: 'Drag this modal out of the window', - draggable: true, - dragWindowBorder: false, - }); - $.confirm({ - title: 'Hello there', - content: 'try to drag this modal out of the window', - draggable: true, - dragWindowGap: 0, // number of px of distance - }); - } - - public ajaxLoading() { - $.confirm({ - title: 'Title', - content: 'url:text.txt', - onContentReady: function() { - var self = this; - this.setContentPrepend('
Prepended text
'); - setTimeout(function() { - self.setContentAppend('
Appended text after 2 seconds
'); - }, 2000); - }, - columnClass: 'medium', - }); - - $.confirm({ - content: function() { - var self = this; - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContent('Description: ' + response.description); - self.setContentAppend('
Version: ' + response.version); - self.setTitle(response.name); - }).fail(function() { - self.setContent('Something went wrong.'); - }); - } - }); - - $.confirm({ - content: 'url:text.txt', - contentLoaded: function(data, status, xhr) { - // data is already set in content - this.setContentAppend('
Status: ' + status); - } - }); - - $.confirm({ - content: function() { - var self = this; - self.setContent('Checking callback flow'); - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContentAppend('
Done!
'); - }).fail(function() { - self.setContentAppend('
Fail!
'); - }).always(function() { - self.setContentAppend('
Always!
'); - }); - }, - contentLoaded: function(data, status, xhr) { - self.setContentAppend('
Content loaded!
'); - }, - onContentReady: function() { - this.setContentAppend('
Content ready!
'); - } - }); - - } - - public autoClose() { - $.confirm({ - title: 'Delete user?', - content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', - autoClose: 'cancelAction|8000', - buttons: { - deleteUser: { - text: 'delete user', - action: function() { - $.alert('Deleted the user!'); - } - }, - cancelAction: function() { - $.alert('action is canceled'); - } - } - }); - $.confirm({ - title: 'Logout?', - content: 'Your time is out, you will be automatically logged out in 10 seconds.', - autoClose: 'logoutUser|10000', - buttons: { - logoutUser: { - text: 'logout myself', - action: function() { - $.alert('The user was logged out'); - } - }, - cancel: function() { - $.alert('canceled'); - } - } - }); - } - - public backgroundDismisse() { - $.confirm({ - backgroundDismiss: true, // this will just close the modal - }); - $.confirm({ - backgroundDismiss: function() { - return false; // modal wont close. - }, - }); - $.confirm({ - backgroundDismiss: function() { - return 'buttonName'; // the button will handle it - }, - }); - $.confirm({ - backgroundDismiss: 'buttonName', - content: 'in here the backgroundDismiss action is handled by buttonName' + - '
', - buttons: { - buttonName: function() { - var $checkbox = this.$content.find('#enableCheckbox'); - return $checkbox.prop('checked'); - }, - close: function() {} - } - }); - } - - public backgroundDismisseAnimation(){ - $.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', -}); -$.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'glow', -}); - } - - public escapeKey(){ - $.confirm({ - escapeKey: true, - backgroundDismiss: false, -}); -$.confirm({ - escapeKey: 'buttonName', - buttons: { - buttonName: function(){ - $.alert('Button name was called'); - }, - close: function(){ - } - } -}); - } - public rtlSupport(){ - $.alert({ - title: 'پیغام', - content: 'این یک متن به زبان شیرین فارسی است', - rtl: true, - closeIcon: true, - buttons: { - confirm: { - text: 'تایید', - btnClass: 'btn-blue', - action: function () { - $.alert('تایید شد.'); - } - }, - cancel: { - text: 'انصراف', - action: function () { - } - } - } -}); - - } - - public callBack(){ - $.confirm({ - title: false, - content: 'url:callback.html', - onContentReady: function () { - // when content is fetched & rendered in DOM - alert('onContentReady'); - var self = this; - this.buttons.ok.disable(); - this.$content.find('.btn').click(function(){ - self.$content.find('input').val('Chuck norris'); - self.buttons.ok.enable(); - }); - }, - contentLoaded: function(data, status, xhr){ - // when content is fetched - alert('contentLoaded: ' + status); - }, - onOpenBefore: function () { - // before the modal is displayed. - alert('onOpenBefore'); - }, - onOpen: function () { - // after the modal is displayed. - alert('onOpen'); - }, - onClose: function () { - // before the modal is hidden. - alert('onClose'); - }, - onDestroy: function () { - // when the modal is removed from DOM - alert('onDestroy'); - }, - onAction: function (btnName) { - // when a button is clicked, with the button name - alert('onAction: ' + btnName); - }, - buttons: { - ok: function(){ - } - } -}); - } - public globalSettings(){ - jconfirm.defaults = { - title: 'Hello', - titleClass: '', - type: 'default', - typeAnimated: true, - draggable: true, - dragWindowGap: 15, - dragWindowBorder: true, - animateFromElement: true, - smoothContent: true, - content: 'Are you sure to continue?', - buttons: {}, - defaultButtons: { - ok: { - action: function () { - } - }, - close: { - action: function () { - } - }, - }, - contentLoaded: function(data, status, xhr){ - }, - icon: '', - lazyOpen: false, - bgOpacity: null, - theme: 'light', - animation: 'scale', - closeAnimation: 'scale', - animationSpeed: 400, - animationBounce: 1, - rtl: false, - container: 'body', - containerFluid: false, - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', - autoClose: false, - closeIcon: null, - closeIconClass: false, - watchInterval: 100, - columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', - boxWidth: '50%', - scrollToPreviousElement: true, - scrollToPreviousElementAnimate: true, - useBootstrap: true, - offsetTop: 40, - offsetBottom: 40, - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - onContentReady: function () {}, - onOpenBefore: function () {}, - onOpen: function () {}, - onClose: function () {}, - onDestroy: function () {}, - onAction: function () {} -}; - } - - public api(){ - var jc = $.confirm({ - title: 'awesome', - onContentReady: function(){ - // this === jc - //jc.setTitle(title: string); - } -}); - } - -} - - -var firstName: string = 'Pierre'; -var lastName: string = 'Yotti'; -var type = new Confirm(firstName, lastName); diff --git a/types/confirmDialog/tsconfig.json b/types/confirmDialog/tsconfig.json deleted file mode 100644 index 6949afdda5..0000000000 --- a/types/confirmDialog/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "types", - "typeRoots": ["types"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "jquery_confirm.ts" - ] -} diff --git a/types/confirmDialog/tslint.json b/types/confirmDialog/tslint.json deleted file mode 100644 index 2f73ea817c..0000000000 --- a/types/confirmDialog/tslint.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] - } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } -} From 77ceb8cd3835f63eeb3d45b97337ec7502860140 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:11:02 +0100 Subject: [PATCH 077/639] add optional Parameter to confirmOptions --- types/confirmdialog/index.d.ts | 98 ++++ types/confirmdialog/jquery-confirm.ts | 644 ++++++++++++++++++++++++++ types/confirmdialog/tsconfig.json | 21 + types/confirmdialog/tslint.json | 31 ++ 4 files changed, 794 insertions(+) create mode 100644 types/confirmdialog/index.d.ts create mode 100644 types/confirmdialog/jquery-confirm.ts create mode 100644 types/confirmdialog/tsconfig.json create mode 100644 types/confirmdialog/tslint.json diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts new file mode 100644 index 0000000000..8ab3145c32 --- /dev/null +++ b/types/confirmdialog/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ +// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Definitions by: Alli Pierre Yotti https://github.com/allipierre +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface JQueryStatic { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any | string, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | string): void; +} + + +interface JQuery { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | any): void; +} + +interface Window { + setContentAppend: any; +} + + + +declare namespace options { + + interface confirmOptions { + buttons? : buttonOptionss | any, + title? : string | boolean, + content? : string | Function, + onContentReady?: Function, + lazyOpen?: boolean, + closeIcon?: boolean | Function, + type?: string, + typeAnimated?: boolean, + icon?: string, + closeIconClass?: string, + columnClass?: string, + containerFluid?: boolean, + boxWidth?: string, + useBootstrap?: boolean, + bootstrapClasses?: any, + draggable?: boolean, + dragWindowBorder?: boolean, + dragWindowGap?: number, + contentLoaded?: Function, + autoClose?: String, + backgroundDismiss?: boolean | Function | string, + backgroundDismissAnimation?: string, + escapeKey?: string | boolean, + onOpenBefore?:Function, + onOpen?: Function, + onClose?: Function, + onDestroy?: Function, + onAction?: Function + + + } + + interface buttonOptionss { + cancel?: Function, + confirm?: Function + } + +} + +declare namespace jconfirm { + let defaults: any; + +} diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/jquery-confirm.ts new file mode 100644 index 0000000000..109558a737 --- /dev/null +++ b/types/confirmdialog/jquery-confirm.ts @@ -0,0 +1,644 @@ +/// +/// +namespace server { + export interface Iperson { + title: string, + content: string, + + + } +} + +class Confirm implements server.Iperson { + private title_: string; + private conTent_: string; + constructor(public title: string, public content: string) { + this.title_ = title; + this.conTent_ = content; + } + + + public confirm() { + $.confirm({ + title: 'Confirm!', + content: 'Simple confirm!', + buttons: { + confirm: function() { + $.alert('Confirmed!'); + }, + cancel: function(cancel: string) { + $.alert('Canceled! ' + cancel); + }, + somethingElse: { + text: 'Something else', + btnClass: 'btn-blue', + keys: ['enter', 'shift'], + action: function() { + alert('Something else?'); + } + } + } + }); + } + + public alert() { + $.alert({ + title: 'Alert!', + content: 'Simple alert!', + }); + } + + public confirm1() { + $.confirm({ + title: 'Prompt!', + content: '' + + '
' + + '
' + + '' + + '' + + '
' + + '
', + buttons: { + formSubmit: { + text: 'Submit', + btnClass: 'btn-blue', + action: function() { + let name = this.$content.find('.name').val(); + if (!name) { + $.alert('provide a valid name'); + return false; + } + $.alert('Your name is ' + name); + } + }, + cancel: function() { + //close + }, + }, + onContentReady: function() { + // bind to events + var jc = this; + this.$content.find('form').on('submit', function(e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); + } + }); + + } + + public dialog() { + $.dialog({ + title: 'Text content!', + content: 'Simple modal!' + }); + } + public confirm_2() { + $('.atwitter').val(); + $('.atwitter').text(); + $('a.twitter').confirm({ + content: "...", + }); + $('a.twitter').confirm({ + buttons: { + hey: function() { + location.href = this.$target.attr('href'); + } + } + }); + } + + public confirm_3() { + $.alert('Content here', 'Title here'); + $.confirm('A message', 'Title is optional'); + $.dialog('Just to let you know'); + } + + public confirm_4() { + var a = $.confirm({ + lazyOpen: true, + }); + a.open(); + a.close(); + a.toggle(); // toggle open close. + + } + + public confirm_5() { + $.confirm({ + buttons: { + hello: function(helloButton) { + // shorthand method to define a button + // the button key will be used as button name + }, + hey: function(heyButton) { + // access the button using jquery + this.$$hello.trigger('click'); // click the 'hello' button + this.$$hey.prop('disabled', true); // disable the current button using jquery method + + // jconfirm button methods, all methods listed here + this.buttons.hello.setText('Helloooo'); // setText for 'hello' button + this.buttons.hey.disable(); // disable with button function provided by jconfirm + this.buttons.hey.enable(); // enable with button function provided by jconfirm + // the button's instance is passed as the first argument, for quick access + heyButton === this.buttons.hey + }, + heyThere: { + text: 'Hey there!', // text for button + btnClass: 'btn-blue', // class for the button + keys: ['enter', 'a'], // keyboard event for button + isHidden: false, // initially not hidden + isDisabled: false, // initially not disabled + action: function(heyThereButton) { + // longhand method to define a button + // provides more features + } + }, + } + }); + + } + + public confirm_6() { + $.confirm({ + buttons: { + hey: function() { + // here the button key 'hey' will be used as the text. + $.alert('You clicked on "hey".'); + }, + heyThere: { + text: 'hey there!', // With spaces and symbols + action: function() { + $.alert('You clicked on "heyThere"'); + } + } + } + }); + } + + public confirm_7() { + $.confirm({ + content: 'Time to use your keyboard, press shift, alert, A or B', + buttons: { + specialKey: { + text: 'On behalf of shift', + keys: ['shift', 'alt'], + action: function() { + $.alert('Shift or Alt was pressed'); + } + }, + alphabet: { + text: 'A, B', + keys: ['a', 'b'], + action: function() { + $.alert('A or B was pressed'); + } + } + } + }); + } + + public confirm_8() { + $.confirm({ + closeIcon: true, // explicitly show the close icon + buttons: { + buttonA: { + text: 'button a', + action: function(buttonA) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing + } + }, + resetButton: function(resetButton) {} + } + }); + } + + + public confirm_9() { + $.confirm({ + title: 'Encountered an error!', + content: 'Something went downhill, this may be serious', + type: 'red', + typeAnimated: true, + buttons: { + tryAgain: { + text: 'Try again', + btnClass: 'btn-red', + action: function() {} + }, + close: function() {} + } + }); + } + + public confirm_10() { + $.confirm({ + icon: 'glyphicon glyphicon-heart', + title: 'glyphicon' + }); + $.confirm({ + icon: 'fa fa-warning', + title: 'font-awesome' + }); + $.confirm({ + icon: 'fa fa-spinner fa-spin', + title: 'Working!', + content: 'Sit back, we are processing your request!' + }); + } + + public confirm_11() { + $.confirm({ + closeIcon: true + }); + + $.confirm({ + closeIcon: true, + closeIconClass: 'fa fa-close' + }); + } + + public confirm_12() { + $.confirm({ + closeIcon: function() { + return false; + }, + buttons: { + aRandomButton: function() { + $.alert('A random button is called, and i prevent closing the modal'); + return false; // you shall not pass + }, + close: function() {} + } + }); + } + + public confirm_13() { + $.confirm({ + columnClass: 'small' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-4', + }); + $.confirm({ + columnClass: 'col-md-12' + }); + $.confirm({ + columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', + containerFluid: true, // this will add 'container-fluid' instead of 'container' + }); + } + + public confirm_14() { + $.confirm({ + boxWidth: '30%', + useBootstrap: false, + }); + $.confirm({ + boxWidth: '500px', + useBootstrap: false, + }); + } + + public confirm_15() { + $.confirm({ + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + }); + + $.confirm({ + title: 'Hello there', + content: 'click and hold on the title to drag', + draggable: true, + }); + + $.confirm({ + title: 'Hello there', + content: 'Drag this modal out of the window', + draggable: true, + dragWindowBorder: false, + }); + $.confirm({ + title: 'Hello there', + content: 'try to drag this modal out of the window', + draggable: true, + dragWindowGap: 0, // number of px of distance + }); + } + + public ajaxLoading() { + $.confirm({ + title: 'Title', + content: 'url:text.txt', + onContentReady: function() { + var self = this; + this.setContentPrepend('
Prepended text
'); + setTimeout(function() { + self.setContentAppend('
Appended text after 2 seconds
'); + }, 2000); + }, + columnClass: 'medium', + }); + + $.confirm({ + content: function() { + var self = this; + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContent('Description: ' + response.description); + self.setContentAppend('
Version: ' + response.version); + self.setTitle(response.name); + }).fail(function() { + self.setContent('Something went wrong.'); + }); + } + }); + + $.confirm({ + content: 'url:text.txt', + contentLoaded: function(data, status, xhr) { + // data is already set in content + this.setContentAppend('
Status: ' + status); + } + }); + + $.confirm({ + content: function() { + var self = this; + self.setContent('Checking callback flow'); + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContentAppend('
Done!
'); + }).fail(function() { + self.setContentAppend('
Fail!
'); + }).always(function() { + self.setContentAppend('
Always!
'); + }); + }, + contentLoaded: function(data, status, xhr) { + self.setContentAppend('
Content loaded!
'); + }, + onContentReady: function() { + this.setContentAppend('
Content ready!
'); + } + }); + + } + + public autoClose() { + $.confirm({ + title: 'Delete user?', + content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', + autoClose: 'cancelAction|8000', + buttons: { + deleteUser: { + text: 'delete user', + action: function() { + $.alert('Deleted the user!'); + } + }, + cancelAction: function() { + $.alert('action is canceled'); + } + } + }); + $.confirm({ + title: 'Logout?', + content: 'Your time is out, you will be automatically logged out in 10 seconds.', + autoClose: 'logoutUser|10000', + buttons: { + logoutUser: { + text: 'logout myself', + action: function() { + $.alert('The user was logged out'); + } + }, + cancel: function() { + $.alert('canceled'); + } + } + }); + } + + public backgroundDismisse() { + $.confirm({ + backgroundDismiss: true, // this will just close the modal + }); + $.confirm({ + backgroundDismiss: function() { + return false; // modal wont close. + }, + }); + $.confirm({ + backgroundDismiss: function() { + return 'buttonName'; // the button will handle it + }, + }); + $.confirm({ + backgroundDismiss: 'buttonName', + content: 'in here the backgroundDismiss action is handled by buttonName' + + '
', + buttons: { + buttonName: function() { + var $checkbox = this.$content.find('#enableCheckbox'); + return $checkbox.prop('checked'); + }, + close: function() {} + } + }); + } + + public backgroundDismisseAnimation(){ + $.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', +}); +$.confirm({ + backgroundDismiss: false, + backgroundDismissAnimation: 'glow', +}); + } + + public escapeKey(){ + $.confirm({ + escapeKey: true, + backgroundDismiss: false, +}); +$.confirm({ + escapeKey: 'buttonName', + buttons: { + buttonName: function(){ + $.alert('Button name was called'); + }, + close: function(){ + } + } +}); + } + public rtlSupport(){ + $.alert({ + title: 'پیغام', + content: 'این یک متن به زبان شیرین فارسی است', + rtl: true, + closeIcon: true, + buttons: { + confirm: { + text: 'تایید', + btnClass: 'btn-blue', + action: function () { + $.alert('تایید شد.'); + } + }, + cancel: { + text: 'انصراف', + action: function () { + } + } + } +}); + + } + + public callBack(){ + $.confirm({ + title: false, + content: 'url:callback.html', + onContentReady: function () { + // when content is fetched & rendered in DOM + alert('onContentReady'); + var self = this; + this.buttons.ok.disable(); + this.$content.find('.btn').click(function(){ + self.$content.find('input').val('Chuck norris'); + self.buttons.ok.enable(); + }); + }, + contentLoaded: function(data, status, xhr){ + // when content is fetched + alert('contentLoaded: ' + status); + }, + onOpenBefore: function () { + // before the modal is displayed. + alert('onOpenBefore'); + }, + onOpen: function () { + // after the modal is displayed. + alert('onOpen'); + }, + onClose: function () { + // before the modal is hidden. + alert('onClose'); + }, + onDestroy: function () { + // when the modal is removed from DOM + alert('onDestroy'); + }, + onAction: function (btnName) { + // when a button is clicked, with the button name + alert('onAction: ' + btnName); + }, + buttons: { + ok: function(){ + } + } +}); + } + public globalSettings(){ + jconfirm.defaults = { + title: 'Hello', + titleClass: '', + type: 'default', + typeAnimated: true, + draggable: true, + dragWindowGap: 15, + dragWindowBorder: true, + animateFromElement: true, + smoothContent: true, + content: 'Are you sure to continue?', + buttons: {}, + defaultButtons: { + ok: { + action: function () { + } + }, + close: { + action: function () { + } + }, + }, + contentLoaded: function(data, status, xhr){ + }, + icon: '', + lazyOpen: false, + bgOpacity: null, + theme: 'light', + animation: 'scale', + closeAnimation: 'scale', + animationSpeed: 400, + animationBounce: 1, + rtl: false, + container: 'body', + containerFluid: false, + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + autoClose: false, + closeIcon: null, + closeIconClass: false, + watchInterval: 100, + columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', + boxWidth: '50%', + scrollToPreviousElement: true, + scrollToPreviousElementAnimate: true, + useBootstrap: true, + offsetTop: 40, + offsetBottom: 40, + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + onContentReady: function () {}, + onOpenBefore: function () {}, + onOpen: function () {}, + onClose: function () {}, + onDestroy: function () {}, + onAction: function () {} +}; + } + + public api(){ + var jc = $.confirm({ + title: 'awesome', + onContentReady: function(){ + // this === jc + //jc.setTitle(title: string); + } +}); + } + +} + + +var firstName: string = 'Pierre'; +var lastName: string = 'Yotti'; +var type = new Confirm(firstName, lastName); diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json new file mode 100644 index 0000000000..6949afdda5 --- /dev/null +++ b/types/confirmdialog/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "types", + "typeRoots": ["types"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery_confirm.ts" + ] +} diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json new file mode 100644 index 0000000000..2f73ea817c --- /dev/null +++ b/types/confirmdialog/tslint.json @@ -0,0 +1,31 @@ +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From 1558ac449a86b8b74c64d08b3aef4c7c55f4f193 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 16:22:17 +0100 Subject: [PATCH 078/639] add optional Parameter to confirmOptions --- types/confirmdialog/index.d.ts | 4 ++-- types/confirmdialog/tsconfig.json | 9 ++++----- types/confirmdialog/tslint.json | 32 +------------------------------ 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 8ab3145c32..e2b3072fee 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -8,7 +8,7 @@ interface JQueryStatic { * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; /** * confirm alert @@ -29,7 +29,7 @@ interface JQuery { * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; /** * confirm alert diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 6949afdda5..b612d7b4be 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -2,20 +2,19 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "types", - "typeRoots": ["types"], + "baseUrl": "../", + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", - "jquery_confirm.ts" + "jquery-confirm.ts" ] } diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 2f73ea817c..3db14f85ea 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,31 +1 @@ -{ - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] - } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } -} +{ "extends": "dtslint/dt.json" } From 96df8480f9ed35a2f0a56b6103cbaa1a6cf3b477 Mon Sep 17 00:00:00 2001 From: allipierre Date: Mon, 20 Nov 2017 17:08:07 +0100 Subject: [PATCH 079/639] add optional Parameter to confirmOptions --- package.json | 3 + types/confirmdialog/index.d.ts | 8 +- types/confirmdialog/jquery-confirm.ts | 205 ++------------------------ types/confirmdialog/tsconfig.json | 7 +- types/confirmdialog/tslint.json | 32 +++- 5 files changed, 52 insertions(+), 203 deletions(-) diff --git a/package.json b/package.json index db67595b77..a9ddbdd977 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,8 @@ "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "Microsoft/types-publisher#production" + }, + "dependencies": { + "@types/jquery": "^3.2.16" } } diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index e2b3072fee..7844857464 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -5,10 +5,10 @@ interface JQueryStatic { /** - * confirm Dialog + * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -29,7 +29,7 @@ interface JQuery { * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -72,7 +72,7 @@ declare namespace options { dragWindowBorder?: boolean, dragWindowGap?: number, contentLoaded?: Function, - autoClose?: String, + autoClose?: string, backgroundDismiss?: boolean | Function | string, backgroundDismissAnimation?: string, escapeKey?: string | boolean, diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/jquery-confirm.ts index 109558a737..2f63c28f60 100644 --- a/types/confirmdialog/jquery-confirm.ts +++ b/types/confirmdialog/jquery-confirm.ts @@ -63,7 +63,7 @@ class Confirm implements server.Iperson { text: 'Submit', btnClass: 'btn-blue', action: function() { - let name = this.$content.find('.name').val(); + let name; if (!name) { $.alert('provide a valid name'); return false; @@ -76,13 +76,7 @@ class Confirm implements server.Iperson { }, }, onContentReady: function() { - // bind to events - var jc = this; - this.$content.find('form').on('submit', function(e) { - // if the user submits the form by pressing enter in the field. - e.preventDefault(); - jc.$$formSubmit.trigger('click'); // reference the button and click it - }); + } }); @@ -128,11 +122,11 @@ class Confirm implements server.Iperson { public confirm_5() { $.confirm({ buttons: { - hello: function(helloButton) { + hello: function(helloButton:string) { // shorthand method to define a button // the button key will be used as button name }, - hey: function(heyButton) { + hey: function(heyButton:string) { // access the button using jquery this.$$hello.trigger('click'); // click the 'hello' button this.$$hey.prop('disabled', true); // disable the current button using jquery method @@ -150,7 +144,7 @@ class Confirm implements server.Iperson { keys: ['enter', 'a'], // keyboard event for button isHidden: false, // initially not hidden isDisabled: false, // initially not disabled - action: function(heyThereButton) { + action: function(heyThereButton:string) { // longhand method to define a button // provides more features } @@ -205,21 +199,12 @@ class Confirm implements server.Iperson { buttons: { buttonA: { text: 'button a', - action: function(buttonA) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. + action: function(buttonA:HTMLElement) { + return false; // prevent the modal from closing } }, - resetButton: function(resetButton) {} + resetButton: function(resetButton:HTMLElement) {} } }); } @@ -340,133 +325,7 @@ class Confirm implements server.Iperson { }); } - public ajaxLoading() { - $.confirm({ - title: 'Title', - content: 'url:text.txt', - onContentReady: function() { - var self = this; - this.setContentPrepend('
Prepended text
'); - setTimeout(function() { - self.setContentAppend('
Appended text after 2 seconds
'); - }, 2000); - }, - columnClass: 'medium', - }); - $.confirm({ - content: function() { - var self = this; - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContent('Description: ' + response.description); - self.setContentAppend('
Version: ' + response.version); - self.setTitle(response.name); - }).fail(function() { - self.setContent('Something went wrong.'); - }); - } - }); - - $.confirm({ - content: 'url:text.txt', - contentLoaded: function(data, status, xhr) { - // data is already set in content - this.setContentAppend('
Status: ' + status); - } - }); - - $.confirm({ - content: function() { - var self = this; - self.setContent('Checking callback flow'); - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContentAppend('
Done!
'); - }).fail(function() { - self.setContentAppend('
Fail!
'); - }).always(function() { - self.setContentAppend('
Always!
'); - }); - }, - contentLoaded: function(data, status, xhr) { - self.setContentAppend('
Content loaded!
'); - }, - onContentReady: function() { - this.setContentAppend('
Content ready!
'); - } - }); - - } - - public autoClose() { - $.confirm({ - title: 'Delete user?', - content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', - autoClose: 'cancelAction|8000', - buttons: { - deleteUser: { - text: 'delete user', - action: function() { - $.alert('Deleted the user!'); - } - }, - cancelAction: function() { - $.alert('action is canceled'); - } - } - }); - $.confirm({ - title: 'Logout?', - content: 'Your time is out, you will be automatically logged out in 10 seconds.', - autoClose: 'logoutUser|10000', - buttons: { - logoutUser: { - text: 'logout myself', - action: function() { - $.alert('The user was logged out'); - } - }, - cancel: function() { - $.alert('canceled'); - } - } - }); - } - - public backgroundDismisse() { - $.confirm({ - backgroundDismiss: true, // this will just close the modal - }); - $.confirm({ - backgroundDismiss: function() { - return false; // modal wont close. - }, - }); - $.confirm({ - backgroundDismiss: function() { - return 'buttonName'; // the button will handle it - }, - }); - $.confirm({ - backgroundDismiss: 'buttonName', - content: 'in here the backgroundDismiss action is handled by buttonName' + - '
', - buttons: { - buttonName: function() { - var $checkbox = this.$content.find('#enableCheckbox'); - return $checkbox.prop('checked'); - }, - close: function() {} - } - }); - } public backgroundDismisseAnimation(){ $.confirm({ @@ -519,50 +378,7 @@ $.confirm({ } - public callBack(){ - $.confirm({ - title: false, - content: 'url:callback.html', - onContentReady: function () { - // when content is fetched & rendered in DOM - alert('onContentReady'); - var self = this; - this.buttons.ok.disable(); - this.$content.find('.btn').click(function(){ - self.$content.find('input').val('Chuck norris'); - self.buttons.ok.enable(); - }); - }, - contentLoaded: function(data, status, xhr){ - // when content is fetched - alert('contentLoaded: ' + status); - }, - onOpenBefore: function () { - // before the modal is displayed. - alert('onOpenBefore'); - }, - onOpen: function () { - // after the modal is displayed. - alert('onOpen'); - }, - onClose: function () { - // before the modal is hidden. - alert('onClose'); - }, - onDestroy: function () { - // when the modal is removed from DOM - alert('onDestroy'); - }, - onAction: function (btnName) { - // when a button is clicked, with the button name - alert('onAction: ' + btnName); - }, - buttons: { - ok: function(){ - } - } -}); - } + public globalSettings(){ jconfirm.defaults = { title: 'Hello', @@ -586,8 +402,7 @@ $.confirm({ } }, }, - contentLoaded: function(data, status, xhr){ - }, + icon: '', lazyOpen: false, bgOpacity: null, diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index b612d7b4be..b43b979bcc 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -2,13 +2,14 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], + "baseUrl": "types", + "typeRoots": ["types"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 3db14f85ea..2f73ea817c 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1 +1,31 @@ -{ "extends": "dtslint/dt.json" } +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From b3926ce5d6ac93022325643fc80726a7838bb047 Mon Sep 17 00:00:00 2001 From: ZheyangSong Date: Mon, 20 Nov 2017 11:29:49 -0800 Subject: [PATCH 080/639] React-Grid-Layout: Add `preventCollision` + Add missing `preventCollision` to `coreProps` --- types/react-grid-layout/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/react-grid-layout/index.d.ts b/types/react-grid-layout/index.d.ts index 7c59c0bf39..fc4f184956 100644 --- a/types/react-grid-layout/index.d.ts +++ b/types/react-grid-layout/index.d.ts @@ -178,6 +178,11 @@ declare namespace ReactGridLayout { */ isRearrangeable?: boolean; + /** + * If true, grid items won't change position when being dragged over. + */ + preventCollision?: boolean; + /** * Uses CSS3 `translate()` instead of position top/left. * This makes about 6x faster paint performance. From 35cb646ea831a66c7810ff7ca720e28dafdfafcf Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Mon, 20 Nov 2017 21:38:12 +0200 Subject: [PATCH 081/639] Fix middleware function name in `@types/koa-router` `middlewares` should be `middleware` https://github.com/alexmingoia/koa-router/blob/master/lib/router.js#L314 --- types/koa-router/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/koa-router/index.d.ts b/types/koa-router/index.d.ts index b543a764b0..c98083f25f 100644 --- a/types/koa-router/index.d.ts +++ b/types/koa-router/index.d.ts @@ -219,7 +219,7 @@ declare class Router { /** * Returns router middleware which dispatches a route matching the request. */ - middlewares(): Router.IMiddleware; + middleware(): Router.IMiddleware; /** * Returns separate middleware for responding to `OPTIONS` requests with From 1620d55592af71834b59298c2c825f5c54c2ea89 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Mon, 20 Nov 2017 17:13:32 -0500 Subject: [PATCH 082/639] Update statsjs typings --- types/stats.js/index.d.ts | 19 ++++++++++++++++--- types/stats.js/stats.js-tests.ts | 10 +++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/types/stats.js/index.d.ts b/types/stats.js/index.d.ts index 55b655f5bc..6449d82fd5 100644 --- a/types/stats.js/index.d.ts +++ b/types/stats.js/index.d.ts @@ -1,9 +1,12 @@ -// Type definitions for Stats.js 0.16.0 +// Type definitions for Stats.js 0.17.0 // Project: https://github.com/mrdoob/stats.js -// Definitions by: Gregory Dalton , Harm Berntsen +// Definitions by: Gregory Dalton , +// Harm Berntsen , +// Dan Vanderkam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Stats { + constructor(); REVISION: number; dom: HTMLDivElement; @@ -14,8 +17,18 @@ declare class Stats { begin(): void; end(): number; update(): void; + + addPanel(panel: Stats.Panel): Stats.Panel; } -declare module "stats.js" { +declare namespace Stats { + class Panel { + constructor(name: string, foregroundColor: string, backgroundColor: string); + dom: HTMLCanvasElement; + update(value: number, maxValue: number): void; + } +} + +declare module 'stats.js' { export = Stats; } diff --git a/types/stats.js/stats.js-tests.ts b/types/stats.js/stats.js-tests.ts index dfaf72e8de..21e1e4b8e5 100644 --- a/types/stats.js/stats.js-tests.ts +++ b/types/stats.js/stats.js-tests.ts @@ -1,17 +1,21 @@ - - -var stats = new Stats(); +const stats = new Stats(); stats.showPanel( 1 ); // 0: fps, 1: ms, 2: mb, 3+: custom document.body.appendChild( stats.dom ); +const panel = stats.addPanel( + new Stats.Panel('custom', 'red', 'pink')); + function animate() { stats.begin(); // monitored code goes here + // $ExpectType number stats.end(); + panel.update(40, 100); + requestAnimationFrame( animate ); } From 40c131a283627305986a25d0f09937e6e1f53ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brikou=20Carr=C3=A9?= Date: Tue, 21 Nov 2017 01:03:17 +0100 Subject: [PATCH 083/639] Add missing url.URL and generic map to context --- types/koa/index.d.ts | 72 +++++++++++++++++++++++++++++++----------- types/koa/koa-tests.ts | 24 ++++++++------ 2 files changed, 69 insertions(+), 27 deletions(-) diff --git a/types/koa/index.d.ts b/types/koa/index.d.ts index d46920bf07..ea59b75b29 100644 --- a/types/koa/index.d.ts +++ b/types/koa/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for Koa 2.x // Project: http://koajs.com -// Definitions by: DavidCai1993 , jKey Lu +// Definitions by: DavidCai1993 +// jKey Lu +// Brice Bernard // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -15,20 +17,22 @@ =============================================== */ /// -import { EventEmitter } from 'events'; -import { IncomingMessage, ServerResponse, Server } from 'http'; -import { Socket, ListenOptions } from 'net'; -import * as compose from 'koa-compose'; -import * as Keygrip from 'keygrip'; -import * as httpAssert from 'http-assert'; -import * as Cookies from 'cookies'; -import * as accepts from 'accepts'; +import * as accepts from "accepts"; +import * as Cookies from "cookies"; +import { EventEmitter } from "events"; +import { IncomingMessage, ServerResponse, Server } from "http"; +import * as httpAssert from "http-assert"; +import * as Keygrip from "keygrip"; +import * as compose from "koa-compose"; +import { Socket, ListenOptions } from "net"; +import * as url from "url"; declare interface ContextDelegatedRequest { /** * Return request header. */ header: any; + /** * Return request header, alias as request.header */ @@ -80,7 +84,6 @@ declare interface ContextDelegatedRequest { */ search: string; - /** * Parse the "Host" header field host * and support X-Forwarded-Host when a @@ -95,6 +98,11 @@ declare interface ContextDelegatedRequest { */ hostname: string; + /** + * Get WHATWG parsed URL object. + */ + URL: url.URL; + /** * Check if the request is fresh, aka * Last-Modified and/or the ETag @@ -383,7 +391,7 @@ declare interface ContextDelegatedResponse { * this.set('Accept', 'application/json'); * this.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' }); */ - set(field: { [key: string]: string; }): void; + set(field: { [key: string]: string }): void; set(field: string, val: string | string[]): void; /** @@ -435,15 +443,36 @@ declare class Application extends EventEmitter { * * http.createServer(app.callback()).listen(...) */ - listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): Server; - listen(port: number, hostname?: string, listeningListener?: () => void): Server; + listen( + port?: number, + hostname?: string, + backlog?: number, + listeningListener?: () => void, + ): Server; + listen( + port: number, + hostname?: string, + listeningListener?: () => void, + ): Server; /* tslint:disable:unified-signatures */ - listen(port: number, backlog?: number, listeningListener?: () => void): Server; + listen( + port: number, + backlog?: number, + listeningListener?: () => void, + ): Server; listen(port: number, listeningListener?: () => void): Server; - listen(path: string, backlog?: number, listeningListener?: () => void): Server; + listen( + path: string, + backlog?: number, + listeningListener?: () => void, + ): Server; listen(path: string, listeningListener?: () => void): Server; listen(options: ListenOptions, listeningListener?: () => void): Server; - listen(handle: any, backlog?: number, listeningListener?: () => void): Server; + listen( + handle: any, + backlog?: number, + listeningListener?: () => void, + ): Server; listen(handle: any, listeningListener?: () => void): Server; /* tslint:enable:unified-signatures*/ @@ -477,7 +506,10 @@ declare class Application extends EventEmitter { * * @api private */ - createContext(req: IncomingMessage, res: ServerResponse): Application.Context; + createContext( + req: IncomingMessage, + res: ServerResponse, + ): Application.Context; /** * Default error handler. @@ -573,7 +605,9 @@ declare namespace Application { toJSON(): any; } - interface BaseContext extends ContextDelegatedRequest, ContextDelegatedResponse { + interface BaseContext + extends ContextDelegatedRequest, + ContextDelegatedResponse { /** * util.inspect() implementation, which * just returns the JSON output. @@ -621,6 +655,8 @@ declare namespace Application { * Default error handling. */ onerror(err: Error): void; + + [key: string]: any; } interface Request extends BaseRequest { diff --git a/types/koa/koa-tests.ts b/types/koa/koa-tests.ts index 1b261fdf44..6dbc073bea 100644 --- a/types/koa/koa-tests.ts +++ b/types/koa/koa-tests.ts @@ -1,21 +1,27 @@ - import * as Koa from "koa"; const app = new Koa(); +app.context.db = () => {}; + +app.use(async ctx => { + console.log(ctx.db); +}); + app.use((ctx, next) => { - const start: any = new Date(); - return next().then(() => { - const end: any = new Date(); - const ms = end - start; - console.log(`${ctx.method} ${ctx.url} - ${ms}ms`); - ctx.assert(true, 404, 'Yep!'); - }); + const start: any = new Date(); + return next().then(() => { + const end: any = new Date(); + const ms = end - start; + console.log(`${ctx.method} ${ctx.url} - ${ms}ms`); + ctx.assert(true, 404, "Yep!"); + }); }); // response app.use(ctx => { - ctx.body = "Hello World"; + ctx.body = "Hello World"; + ctx.body = ctx.URL.toString(); }); app.listen(3000); From 2be9ad506f03a45178481bbd74cd6a19099c178b Mon Sep 17 00:00:00 2001 From: Lucky Soni Date: Tue, 21 Nov 2017 08:03:32 +0530 Subject: [PATCH 084/639] Backbone.History.route may accept string or RegExp as first argument --- types/backbone/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/backbone/index.d.ts b/types/backbone/index.d.ts index 607f6413fc..c6652d83db 100644 --- a/types/backbone/index.d.ts +++ b/types/backbone/index.d.ts @@ -392,7 +392,7 @@ declare namespace Backbone { decodeFragment(fragment: string): string; getSearch(): string; stop(): void; - route(route: string, callback: Function): number; + route(route: string|RegExp, callback: Function): number; checkUrl(e?: any): void; getPath(): string; matchRoot(): boolean; From e36486c4e84bd14f79d761e63de2bf1e198cccfc Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 21 Nov 2017 11:23:55 +0100 Subject: [PATCH 085/639] padLeft/padRight are defined in es2017.string lib already --- types/node/index.d.ts | 6 +----- types/node/node-tests.ts | 16 +--------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 72e7cdbe30..61fd375e6f 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -68,12 +68,8 @@ interface SymbolConstructor { } declare var Symbol: SymbolConstructor; -// Node.js ES2017 and ESNEXT support +// Node.js ESNEXT support interface String { - /** Pads the current string with another string (repeated, if needed) so that the resulting string reaches the given length. The padding is applied from the start (left) of the current string. */ - padStart(targetLength?: number, padString?: string): string; - /** Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string. */ - padEnd(targetLength?: number, padString?: string): string; /** Removes whitespace from the left end of a string. */ trimLeft(): string; /** Removes whitespace from the right end of a string. */ diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 34bba1f7ba..d85a2574db 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3752,25 +3752,11 @@ namespace module_tests { const m2: Module = new Module.Module("moduleId"); } -//////////////////////////////////////////////////// -/// Node.js ES2017 Support -//////////////////////////////////////////////////// - -namespace es2017_tests { - const s: string = 'foo'; - const s1: string = s.padStart(); - const s11: string = s.padStart(10); - const s12: string = s.padStart(10, 'x'); - const s2: string = s.padEnd(); - const s21: string = s.padEnd(10); - const s22: string = s.padEnd(10, 'x'); -} - //////////////////////////////////////////////////// /// Node.js ESNEXT Support //////////////////////////////////////////////////// -namespace esnext_tests { +namespace esnext_string_tests { const s: string = 'foo'; const s1: string = s.trimLeft(); const s2: string = s.trimRight(); From 0eaacc5ca4e8776d2a11b9177a341db4cd9c1189 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Tue, 21 Nov 2017 19:00:51 +0530 Subject: [PATCH 086/639] Updated types to alexa-sdk@1.0.20. Separated files temporarily. --- types/alexa-sdk/index.d.ts | 184 ++++---------------- types/alexa-sdk/responseBuilder.d.ts | 170 +++++++++++++++++++ types/alexa-sdk/services.d.ts | 199 ++++++++++++++++++++++ types/alexa-sdk/templateBuilders.d.ts | 232 ++++++++++++++++++++++++++ types/alexa-sdk/tsconfig.json | 7 +- types/alexa-sdk/types.d.ts | 208 +++++++++++++++++++++++ types/alexa-sdk/utils.d.ts | 96 +++++++++++ 7 files changed, 940 insertions(+), 156 deletions(-) create mode 100644 types/alexa-sdk/responseBuilder.d.ts create mode 100644 types/alexa-sdk/services.d.ts create mode 100644 types/alexa-sdk/templateBuilders.d.ts create mode 100644 types/alexa-sdk/types.d.ts create mode 100644 types/alexa-sdk/utils.d.ts diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 1c39755b2d..bf64ff08df 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -1,3 +1,6 @@ + +import { utils } from './utils'; +import { AlexaObject, Image, TextField, TextContent, RequestBody, Context } from './types'; // Type definitions for Alexa SDK for Node.js 1.0 // Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs // Definitions by: Pete Beegle @@ -9,163 +12,34 @@ export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; -export let StateString: string; -export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; -export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; - -export interface AlexaObject extends Handler { - _event: any; - _context: any; - _callback: any; - state: any; - appId: any; - response: any; - resources: any; - dynamoDBTableName: any; - saveBeforeResponse: boolean; - registerHandlers: (...handlers: Array>) => any; - execute: () => void; +export namespace directives { + export class VoicePlayerSpeakDirective { + /** + * Creates an instance of VoicePlayerSpeakDirective. + * @param {string} requestId - requestId from which the call is originated from + * @param {string} speechContent - Contents of the speech directive either in plain text or SSML. + * @memberof DirectiveService + */ + constructor(requestId: string, speechContent: string); + } } +//#region exports from other modules +export { templateBuilders } from "./templateBuilders"; -export interface Handlers { - [intent: string]: (this: Handler) => void; -} +export { services } from "./services"; -export interface Handler { - on: any; - emit(event: string, ...args: any[]): boolean; - emitWithState: any; - state: any; - handler: any; - event: RequestBody; - attributes: any; - context: any; - name: any; - isOverriden: any; - t: (token: string, ...args: any[]) => void; -} +export { + AlexaObject, Image, CardImage, TextField, + TextContent, RequestBody, Context, Handler, IntentRequest, + ListItem, Template, Handlers, Session, SessionApplication, + SessionUser, LaunchRequest, SessionEndedRequest, + Request, ResolutionStatus, ResolutionValue, + ResolutionValueContainer, Resolutions, SlotValue, + Intent, ResponseBody, Response, OutputSpeech, + Card, Reprompt, ConfirmationStatuses, DialogStates, + StateString -export interface Context { - callbackWaitsForEmptyEventLoop: boolean; - logGroupName: string; - logStreamName: string; - functionName: string; - memoryLimitInMB: string; - functionVersion: string; - invokeid: string; - awsRequestId: string; -} - -export interface RequestBody { - version: string; - session: Session; - request: T; -} - -export interface Session { - new: boolean; - sessionId: string; - attributes: any; - application: SessionApplication; - user: SessionUser; -} - -export interface SessionApplication { - applicationId: string; -} - -export interface SessionUser { - userId: string; - accessToken?: string; -} - -export interface LaunchRequest extends Request { } - -export interface IntentRequest extends Request { - dialogState?: DialogStates; - intent?: Intent; -} - -export interface SessionEndedRequest extends Request { - reason?: string; -} - -export interface Request { - type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; - requestId: string; - timestamp: string; - locale?: string; -} - -export interface ResolutionStatus { - code: string; -} - -export interface ResolutionValue { - name: string; - id: string; -} - -export interface ResolutionValueContainer { - value: ResolutionValue; -} - -export interface Resolution { - authority: string; - status: ResolutionStatus; - values: ResolutionValueContainer[]; -} - -export interface Resolutions { - resolutionsPerAuthority: Resolution[]; -} - -export interface SlotValue { - confirmationStatus?: ConfirmationStatuses; - name: string; - value?: any; - resolutions?: Resolutions; -} - -export interface Intent { - confirmationStatus?: ConfirmationStatuses; - name: string; - slots: Record; -} - -export interface ResponseBody { - version: string; - sessionAttributes?: any; - response: Response; -} - -export interface Response { - outputSpeech?: OutputSpeech; - card?: Card; - reprompt?: Reprompt; - shouldEndSession: boolean; -} - -export interface OutputSpeech { - type: "PlainText" | "SSML"; - text?: string; - ssml?: string; -} - -export interface Card { - type: "Simple" | "Standard" | "LinkAccount"; - title?: string; - content?: string; - text?: string; - image?: Image; -} - -export interface Image { - smallImageUrl: string; - largeImageUrl: string; -} - -export interface Reprompt { - outputSpeech: OutputSpeech; -} +} from './types'; +export { utils } from './utils'; +//#endregion \ No newline at end of file diff --git a/types/alexa-sdk/responseBuilder.d.ts b/types/alexa-sdk/responseBuilder.d.ts new file mode 100644 index 0000000000..83d32cf4f0 --- /dev/null +++ b/types/alexa-sdk/responseBuilder.d.ts @@ -0,0 +1,170 @@ +import { Handler, Request, Template, Image, CardImage } from './types'; +export declare const CARD_TYPES: { + STANDARD: 'Standard', + SIMPLE: 'Simple', + LINK_ACCOUNT: 'LinkAccount', + ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' +}; + +export declare const HINT_TYPES: { + PLAIN_TEXT: 'PlainText' +}; + +export declare const DIRECTIVE_TYPES: { + AUDIOPLAYER: { + PLAY: 'AudioPlayer.Play', + STOP: 'AudioPlayer.Stop', + CLEAR_QUEUE: 'AudioPlayer.ClearQueue' + }, + DISPLAY: { + RENDER_TEMPLATE: 'Display.RenderTemplate' + }, + HINT: 'Hint', + VIDEOAPP: { + LAUNCH: 'VideoApp.Launch' + } +}; + +/** + * Responsible for building JSON responses as per the Alexa skills kit interface + * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax + * + * @class ResponseBuilder + */ +export class ResponseBuilder { + constructor(alexaHandler: Handler); + + /** + * Have Alexa say the provided speechOutput to the user + * + * @param {string} speechOutput + * @returns + * @memberof ResponseBuilder + */ + speak(speechOutput: string): ResponseBuilder; + + /** + * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds + * then have alexa reprompt with the provided reprompt speech + * @param {string} repromptSpeech + * @returns + * @memberof ResponseBuilder + */ + listen(repromptSpeech: string): ResponseBuilder; + + /** + * Render a card with the following title, content and image + * + * @param {string} cardTitle + * @param {string} cardContent + * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage + * @returns + * @memberof ResponseBuilder + */ + cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; + + /** + * Render a link account card + * + * @returns + * @memberof ResponseBuilder + */ + linkAccountCard(): ResponseBuilder; + + /** + * Render a askForPermissionsConsent card + * @param {[{ [key: string]: string }]} permissions + * @returns + * @memberOf ResponseBuilder + */ + askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; + + /** + * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. + * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead + * @param {string} directiveType + * @param {string} behavior + * @param {string} url + * @param {string} token + * @param {string} expectedPreviousToken + * @param {number} offsetInMilliseconds + * @returns + * @memberof ResponseBuilder + */ + audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer play directive + * + * @param {string} behavior Describes playback behavior. Accepted values: + * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. + * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. + * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. + * @param {string} url Identifies the location of audio content at a remote HTTPS location. + * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the + * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. + * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. + * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters + * @param {string} expectedPreviousToken A token that represents the expected previous stream. + * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions + * if requests to progress through a playlist and change tracks occur at the same time. + * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. + * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream + * @returns + * @memberof ResponseBuilder + */ + audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer Stop directive - Stops the current audio Playback + * + * @returns + * @memberof ResponseBuilder + */ + audioPlayerStop(): ResponseBuilder; + + /** + * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, + * or clear the queue and stop any currently playing stream. + * + * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: + * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream + * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). + * @returns + * @memberof ResponseBuilder + */ + audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; + + /** + * Creates a Display RenderTemplate Directive + * + * Use a template builder to generate a template object + * + * @param {Template} template + * @returns + * @memberof ResponseBuilder + */ + renderTemplate(template: Template): ResponseBuilder; + + /** + * Creates a hint directive - show a hint on the screen of the echo show + * + * @param {string} hintText text to show on the hint + * @param {string} hintType (optional) Default value : PlainText + * @returns + * @memberof ResponseBuilder + */ + hint(hintText: string, hintType: string): ResponseBuilder; + + /** + * Creates a VideoApp play directive to play a video + * + * @param {string} source Identifies the location of video content at a remote HTTPS location. + * The video file must be hosted at an Internet-accessible HTTPS endpoint. + * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the + * information that can be displayed on VideoApp. + * @returns + * @memberof ResponseBuilder + */ + playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; +} \ No newline at end of file diff --git a/types/alexa-sdk/services.d.ts b/types/alexa-sdk/services.d.ts new file mode 100644 index 0000000000..1498f17cbe --- /dev/null +++ b/types/alexa-sdk/services.d.ts @@ -0,0 +1,199 @@ +export namespace services { + export interface ApiClientOptions { hostname: string; port: string; path: string; protocol: string; headers: string; method: string } + export interface ApiClientResponse { statusCode: string; statusText: string; body: Object; headers: Object } + export interface ListItemObject { value: string, status: string, version: any } + export interface ListObject { name: string, status: string, version: any } + export interface ApiClient { + /** + * Make a POST API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + post(uri: string, headers: Object, body?: string): Promise; + /** + * Make a PUT API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + put(uri: string, headers: Object, body?: string): Promise; + /** + * Make a GET API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + * @memberof ApiClient + */ + get(uri: string, headers: Object): Promise; + /** + * Make a DELETE API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + */ + delete(uri: string, headers: Object): Promise; + } + export class DeviceAddressService { + /** + * Create an instance of DeviceAddressService + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberOf DeviceAddressService + */ + constructor(apiClient: ApiClient); + + /** + * Get full address information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; + + /** + * Get country and postal information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; + } + export class DirectiveService { + + /** + * Creates an instance of DirectiveService. + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberof DirectiveService + */ + constructor(apiClient: ApiClient); + + /** + * Send the specified directiveObj to Alexa directive service + * + * @param {Object} directive directive to send to service + * @param {string} apiEndpoint API endpoint from Alexa request + * @param {string} token bearer token for directive service + * @returns {Promise} + * @memberof DirectiveService + */ + enqueue(directive: Object, apiEndpoint: string, token: string): Promise; + } + export class ListManagementService { + + /** + * Create an instance of ListManagementService + * @param apiClient + */ + constructor(apiClient: ApiClient); + + /** + * Set apiEndpoint address, default is 'https://api.amazonalexa.com' + * @param apiEndpoint + * @returns void + * @memberOf ListManagementService + */ + setApiEndpoint(apiEndpoint: string): void; + + /** + * Get currently set apiEndpoint address + * @returns {string} + * @memberOf ListManagementService + */ + getApiEndpoint(): string; + + /** + * Retrieve the metadata for all customer lists, including the customer's default lists + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListsMetadata(token: string): Promise; + + /** + * Create a custom list. The new list name must be different than any existing list name + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createList(listObject: ListObject, token: string): Promise + + /** + * Retrieve list metadata including the items in the list with requested status + * @param {string} listId unique Id associated with the list + * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getList(listId: string, itemStatus: string, token: string): Promise; + + /** + * Update a custom list. Only the list name or state can be updated + * @param {string} listId unique Id associated with the list + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateList(listId: string, listObject: ListObject, token: string): Promise; + + /** + * Delete a custom list + * @param {string} listId unique Id associated with the list + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteList(listId: string, token: string): Promise; + + /** + * Create an item in an active list or in a default list + * @param {string} listId unique Id associated with the list + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Retrieve single item within any list by listId and itemId + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListItem(listId: string, itemId: string, token: string): Promise; + + /** + * Update an item value or item status + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Delete an item in the specified list + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteListItem(listId: string, itemId: string, token: string): Promise; + } +} \ No newline at end of file diff --git a/types/alexa-sdk/templateBuilders.d.ts b/types/alexa-sdk/templateBuilders.d.ts new file mode 100644 index 0000000000..03834ca54a --- /dev/null +++ b/types/alexa-sdk/templateBuilders.d.ts @@ -0,0 +1,232 @@ +import { Image, TextField, ListItem, Template } from './types'; +export namespace templateBuilders { + export interface SetTextContent> { + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + export interface SetListItems> { + setListItems(listItems: ListItem[]): T; + } + export abstract class TemplateBuilder> { + public template: Template; + constructor(); + + /** + * Sets the title of the template + * + * @param {string} title + * @returns + * @memberof TemplateBuilder + */ + public setTitle(title: string): T; + + /** + * Sets the token of the template + * + * @param {string} token + * @returns + * @memberof TemplateBuilder + */ + public setToken(token: string): T; + + /** + * Sets the background image of the template + * + * @param {Image} image + * @returns + * @memberof TemplateBuilder + */ + public setBackgroundImage(image: Image): T; + + /** + * Sets the backButton behavior + * + * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @returns + * @memberof TemplateBuilder + */ + public setBackButtonBehavior(backButtonBehavior: string): T; + + /** + * Builds the template JSON object + * + * @returns + * @memberof TemplateBuilder + */ + public build(): Template; + // /** + // * Sets the text content for the template + // * + // * @param {TextField} primaryText + // * @param {TextField} secondaryText + // * @param {TextField} tertiaryText + // * @returns TemplateBuilder + // * @memberof TemplateBuilder + // */ + // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + /** + * Used to build a list of ListItems for ListTemplate + * + * @class ListItemBuilder + */ + export class ListItemBuilder { + constructor(); + public items: ListItem[]; + /** + * Add an item to the list of template + * + * @param {Image} image + * @param {string} token + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @memberof ListItemBuilder + */ + public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; + + public build(): ListItem[]; + } + /** + * Used to create BodyTemplate1 objects + * + * @class BodyTemplate1Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ + constructor(); + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate1Builder + * @memberof BodyTemplate1Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; + } + /** + * Used to create BodyTemplate2 objects + * + * @class BodyTemplate2Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {Image} image + * @returns + * @memberof BodyTemplate2Builder + */ + public setImage(image: Image): BodyTemplate2Builder + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate2Builder + * @memberof BodyTemplate2Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; + } + /** + * Used to create BodyTemplate3 objects + * + * @class BodyTemplate3Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate3Builder + */ + public setImage(image: any): BodyTemplate3Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate3Builder + * @memberof BodyTemplate3Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; + } + /** + * Used to create BodyTemplate6 objects + * + * @class BodyTemplate6Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate6Builder + */ + public setImage(image: any): BodyTemplate6Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate6Builder + * @memberof BodyTemplate6Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; + } + /** + * Used to create ListTemplate1 objects + * + * @class ListTemplate1Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate1Builder + */ + setListItems(listItems: ListItem[]): ListTemplate1Builder; + } + /** + * Used to create ListTemplate2 objects + * + * @class ListTemplate2Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate2Builder + */ + setListItems(listItems: ListItem[]): ListTemplate2Builder; + } + +} \ No newline at end of file diff --git a/types/alexa-sdk/tsconfig.json b/types/alexa-sdk/tsconfig.json index acc11c8263..e5b9d60424 100644 --- a/types/alexa-sdk/tsconfig.json +++ b/types/alexa-sdk/tsconfig.json @@ -19,5 +19,10 @@ "files": [ "index.d.ts", "alexa-sdk-tests.ts" + "responseBuilder.d.ts", + "services.d.ts", + "templateBuilders.d.ts", + "types.d.ts", + "utils.d.ts", ] -} \ No newline at end of file +} diff --git a/types/alexa-sdk/types.d.ts b/types/alexa-sdk/types.d.ts new file mode 100644 index 0000000000..42daa46f60 --- /dev/null +++ b/types/alexa-sdk/types.d.ts @@ -0,0 +1,208 @@ +import { i18n } from "../i18next"; +import { ResponseBuilder } from "./responseBuilder"; +export let StateString: string; + +export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; +export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; + +export interface CardImage { + smallImageUrl: string; + largeImageUrl: string; +} +export interface Image { + smallImageUrl: string; + largeImageUrl: string; + contentDescription: string; + sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; +} +export type TextField = { + text: string, + type: string +}; +export type TextContent = { + primaryText: TextField, + secondaryText: TextField, + tertiaryText: TextField, +} +export type ListItem = { image: Image; token: string; textContent: TextContent; }; +export type Template = { + title: string; + token: string; + backgroundImage: Image; + backButton: string; + type: string; + image: Image; + listItems: ListItem[]; +}; + +export interface AlexaObject extends Handler { + _event: any; + _context: any; + _callback: any; + state: any; + appId: any; + response: any; + resources: any; + dynamoDBTableName: any; + saveBeforeResponse: boolean; + registerHandlers: (...handlers: Array>) => any; + execute: () => void; +} + +export interface Handlers { + [intent: string]: (this: Handler) => void; +} + +export interface Handler { + on: any; + emit(event: string, ...args: any[]): boolean; + emitWithState: any; + state: any; + handler: any; + i18n: i18n, + locale: any, + event: RequestBody; + attributes: any; + context: any; + callback: Function; + name: any; + isOverriden: any; + t: (token: string, ...args: any[]) => void; + response: ResponseBuilder; +} +export enum PLAYER_ACTIVITY { + IDLE = 'IDLE', + PAUSED = 'PAUSED', + PLAYING = 'PLAYING', + BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', + FINISHED = 'FINISHED', + STOPPED = 'STOPPED' +} +export interface Context { + System: System + AudioPlayer: AudioPlayer +} +export interface System { + apiAccessToken: string; + apiEndpoint: string; + application: any; + device: any; + user: any; +} +export interface AudioPlayer { + token: string; + offsetInMilliseconds: number; + playerActivity: PLAYER_ACTIVITY; +} +export interface RequestBody { + version: string; + session: Session; + request: T; +} + +export interface Session { + new: boolean; + sessionId: string; + attributes: any; + application: SessionApplication; + user: SessionUser; +} + +export interface SessionApplication { + applicationId: string; +} + +export interface SessionUser { + userId: string; + accessToken?: string; + /** + * @deprecated + */ + permissions: any; +} + +export interface LaunchRequest extends Request { } + +export interface IntentRequest extends Request { + dialogState?: DialogStates; + intent?: Intent; +} + +export interface SessionEndedRequest extends Request { + reason?: string; +} + +export interface Request { + type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; + requestId: string; + timestamp: string; + locale?: string; +} + +export interface ResolutionStatus { + code: string; +} + +export interface ResolutionValue { + name: string; + id: string; +} + +export interface ResolutionValueContainer { + value: ResolutionValue; +} + +export interface Resolution { + authority: string; + status: ResolutionStatus; + values: ResolutionValueContainer[]; +} + +export interface Resolutions { + resolutionsPerAuthority: Resolution[]; +} + +export interface SlotValue { + confirmationStatus?: ConfirmationStatuses; + name: string; + value?: any; + resolutions?: Resolutions; +} + +export interface Intent { + confirmationStatus?: ConfirmationStatuses; + name: string; + slots: Record; +} + +export interface ResponseBody { + version: string; + sessionAttributes?: any; + response: Response; +} + +export interface Response { + outputSpeech?: OutputSpeech; + card?: Card; + reprompt?: Reprompt; + directives?: any; + shouldEndSession?: boolean; +} + +export interface OutputSpeech { + type: "PlainText" | "SSML"; + text?: string; + ssml?: string; +} + +export interface Card { + type: "Simple" | "Standard" | "LinkAccount"; + title?: string; + content?: string; + text?: string; + image?: Image; +} + +export interface Reprompt { + outputSpeech: OutputSpeech; +} \ No newline at end of file diff --git a/types/alexa-sdk/utils.d.ts b/types/alexa-sdk/utils.d.ts new file mode 100644 index 0000000000..056a52530e --- /dev/null +++ b/types/alexa-sdk/utils.d.ts @@ -0,0 +1,96 @@ + +import { TextField, TextContent, Image } from "./types"; +export namespace utils { + export class ImageUtils { + /** + * Creates an image object with a single source + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * + * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') + * + * @static + * @param {string} url url of the image + * @param {number} widthPixels (optional) width of the image in pixels + * @param {number} heightPixels (optional) height of the image in pixels + * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + /** + * + * Creates an image object with a multiple sources, source images are provided as an array of image objects + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * example : + * let imgArr = [ + * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, + * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * ] + * ImageUtils.makeImage(imgArr, 'image description') + * + * @static + * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + } + /** + * Utility methods for building TextField objects + * + * @class TextUtils + */ + export class TextUtils { + + /** + * Creates a plain TextField object with contents : text + * + * @static + * @param {string} text contents of plain text object + * @returns + * @memberof TextUtils + */ + public static makePlainText(text: string): TextField; + + /** + * Creates a rich TextField object with contents : text + * + * @static + * @param {string} text + * @returns + * @memberof TextUtils + */ + public static makeRichText(text: string): TextField; + + /** + * Creates a textContent + * + * @static + * @param {{type : string, text : string}} primaryText + * @param {{type : string, text : string}} secondaryText + * @param {{type : string, text : string}} tertiaryText + * @returns + * @memberof TextUtils + */ + public static makeTextContent(primaryText: { type: string, text: string }, + secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent + } +} \ No newline at end of file From 72921a4e5e770c5ecfaa8bac6a7ed8be632ee642 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 21 Nov 2017 16:42:25 +0100 Subject: [PATCH 087/639] Update new flatpickr def See https://github.com/chmln/flatpickr/blob/3c100acb1e4329b764089140511667ea400116c4/index.d.ts#L28-L29 --- types/react-flatpickr/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-flatpickr/index.d.ts b/types/react-flatpickr/index.d.ts index e960524854..ebac89f48d 100644 --- a/types/react-flatpickr/index.d.ts +++ b/types/react-flatpickr/index.d.ts @@ -5,12 +5,12 @@ // TypeScript Version: 2.3 import { Component } from 'react'; -import { Hook, Options } from 'flatpickr'; +import { Options } from 'flatpickr'; export interface DateTimePickerProps { defaultValue?: string; - options?: Options; - onChange?: Hook; + options?: Options.Options; + onChange?: Options.Hook; value?: string; } From c5b3a813a7c9c36976a6da84a676dd6565837b46 Mon Sep 17 00:00:00 2001 From: Ika Date: Wed, 22 Nov 2017 00:02:58 +0800 Subject: [PATCH 088/639] fix(prettier): add missing `getSupportInfo()` --- types/prettier/index.d.ts | 27 +++++++++++++++++++++++++++ types/prettier/prettier-tests.ts | 3 +++ 2 files changed, 30 insertions(+) diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index cb0a813385..a24bf6ce18 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -161,6 +161,33 @@ export namespace resolveConfig { */ export function clearConfigCache(): void; +export interface SupportLanguage { + name: string; + since: string; + parsers: string[]; + group?: string; + tmScope: string; + aceMode: string; + codemirrorMode: string; + codemirrorMimeType: string; + aliases?: string[]; + extensions: string[]; + filenames?: string[]; + linguistLanguageId: number; + vscodeLanguageIds: string[]; +} + +export interface SupportInfo { + languages: SupportLanguage[]; +} + +/** + * Returns an object representing the parsers, languages and file types Prettier supports. + * If `version` is provided (e.g. `"1.5.0"`), information for that version will be returned, + * otherwise information for the current version will be returned. + */ +export function getSupportInfo(version?: string): SupportInfo; + /** * `version` field in `package.json` */ diff --git a/types/prettier/prettier-tests.ts b/types/prettier/prettier-tests.ts index 9d78453bae..47edb63ce9 100644 --- a/types/prettier/prettier-tests.ts +++ b/types/prettier/prettier-tests.ts @@ -33,3 +33,6 @@ if (options !== null) { } prettier.clearConfigCache(); + +const currentSupportInfo = prettier.getSupportInfo(); +const specificSupportInfo = prettier.getSupportInfo("1.8.0"); From d9620b5e2a618683aec2c94d12fd360ecb4e0c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Tue, 21 Nov 2017 16:38:00 +0000 Subject: [PATCH 089/639] Updated index.d.ts with the last version Replaced the contents with the new version: https://github.com/mpneuried/nodecache/blob/master/index.d.ts Has new methods. --- types/node-cache/index.d.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/types/node-cache/index.d.ts b/types/node-cache/index.d.ts index 558882a086..00e7316edc 100644 --- a/types/node-cache/index.d.ts +++ b/types/node-cache/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/tcs-de/nodecache // Definitions by: Ilya Mochalov // Daniel Thunell +// Ulf Seltmann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -89,8 +90,16 @@ declare namespace NodeCache { ttl( key: Key, - cb?: Callback, - ttl?: number + cb?: Callback + ): boolean; + + getTtl( + key: Key, + ): number|undefined; + + getTtl( + key: Key, + cb?: Callback ): boolean; /** @@ -130,6 +139,7 @@ declare namespace NodeCache { checkperiod?: number; useClones?: boolean; errorOnMissing?: boolean; + deleteOnExpire?: boolean; } interface Stats { @@ -225,7 +235,7 @@ declare class NodeCache extends events.EventEmitter implements NodeCache.NodeCac ): number; /** - * reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()` + * reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 `stdTtl` is used. if set lt 0 it's similar to `.del()` */ ttl( key: Key, @@ -235,10 +245,19 @@ declare class NodeCache extends events.EventEmitter implements NodeCache.NodeCac ttl( key: Key, - cb?: Callback, - ttl?: number + cb?: Callback ): boolean; + getTtl( + key: Key + ): number|undefined; + + getTtl( + key: Key, + cb?: Callback, + ): boolean; + + /** * list all keys within this cache * @param cb Callback function From f0d25f25f893335f62ca489edd941fb9524097cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brikou=20Carr=C3=A9?= Date: Tue, 21 Nov 2017 22:22:34 +0100 Subject: [PATCH 090/639] Typo with jwtid params --- types/jsonwebtoken/index.d.ts | 64 +++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/types/jsonwebtoken/index.d.ts b/types/jsonwebtoken/index.d.ts index 335a6f52b7..766042e627 100644 --- a/types/jsonwebtoken/index.d.ts +++ b/types/jsonwebtoken/index.d.ts @@ -1,6 +1,8 @@ -// Type definitions for jsonwebtoken 7.2.0 +// Type definitions for jsonwebtoken 7.2.1 // Project: https://github.com/auth0/node-jsonwebtoken -// Definitions by: Maxime LUCE , Daniel Heim +// Definitions by: Maxime LUCE , +// Daniel Heim , +// Brice BERNARD // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -51,7 +53,6 @@ export interface SignOptions { noTimestamp?: boolean; header?: object; encoding?: string; - } export interface VerifyOptions { @@ -61,7 +62,7 @@ export interface VerifyOptions { issuer?: string | string[]; ignoreExpiration?: boolean; ignoreNotBefore?: boolean; - jwtId?: string; + jwtid?: string; subject?: string; /** *@deprecated @@ -76,14 +77,17 @@ export interface DecodeOptions { } export interface VerifyCallback { - (err: JsonWebTokenError | NotBeforeError | TokenExpiredError, decoded: object | string): void; + ( + err: JsonWebTokenError | NotBeforeError | TokenExpiredError, + decoded: object | string, + ): void; } export interface SignCallback { (err: Error, encoded: string): void; } -export type Secret = string | Buffer | {key: string, passphrase: string} +export type Secret = string | Buffer | { key: string; passphrase: string }; /** * Synchronously sign the given payload into a JSON Web Token string @@ -92,7 +96,11 @@ export type Secret = string | Buffer | {key: string, passphrase: string} * @param {SignOptions} [options] - Options for the signature * @returns {String} The JSON Web Token string */ -export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: Secret, options?: SignOptions): string; +export declare function sign( + payload: string | Buffer | object, + secretOrPrivateKey: Secret, + options?: SignOptions, +): string; /** * Sign the given payload into a JSON Web Token string @@ -101,8 +109,17 @@ export declare function sign(payload: string | Buffer | object, secretOrPrivateK * @param {SignOptions} [options] - Options for the signature * @param {Function} callback - Callback to get the encoded token on */ -export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: Secret, callback: SignCallback): void; -export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: Secret, options: SignOptions, callback: SignCallback): void; +export declare function sign( + payload: string | Buffer | object, + secretOrPrivateKey: Secret, + callback: SignCallback, +): void; +export declare function sign( + payload: string | Buffer | object, + secretOrPrivateKey: Secret, + options: SignOptions, + callback: SignCallback, +): void; /** * Synchronously verify given token using a secret or a public key to get a decoded token @@ -111,8 +128,15 @@ export declare function sign(payload: string | Buffer | object, secretOrPrivateK * @param {VerifyOptions} [options] - Options for the verification * @returns The decoded token. */ -declare function verify(token: string, secretOrPublicKey: string | Buffer): object | string; -declare function verify(token: string, secretOrPublicKey: string | Buffer, options?: VerifyOptions): object | string; +declare function verify( + token: string, + secretOrPublicKey: string | Buffer, +): object | string; +declare function verify( + token: string, + secretOrPublicKey: string | Buffer, + options?: VerifyOptions, +): object | string; /** * Asynchronously verify given token using a secret or a public key to get a decoded token @@ -121,8 +145,17 @@ declare function verify(token: string, secretOrPublicKey: string | Buffer, optio * @param {VerifyOptions} [options] - Options for the verification * @param {Function} callback - Callback to get the decoded token on */ -declare function verify(token: string, secretOrPublicKey: string | Buffer, callback?: VerifyCallback): void; -declare function verify(token: string, secretOrPublicKey: string | Buffer, options?: VerifyOptions, callback?: VerifyCallback): void; +declare function verify( + token: string, + secretOrPublicKey: string | Buffer, + callback?: VerifyCallback, +): void; +declare function verify( + token: string, + secretOrPublicKey: string | Buffer, + options?: VerifyOptions, + callback?: VerifyCallback, +): void; /** * Returns the decoded payload without verifying if the signature is valid. @@ -130,4 +163,7 @@ declare function verify(token: string, secretOrPublicKey: string | Buffer, optio * @param {DecodeOptions} [options] - Options for decoding * @returns {Object} The decoded Token */ -declare function decode(token: string, options?: DecodeOptions): null | object | string; +declare function decode( + token: string, + options?: DecodeOptions, +): null | object | string; From 49601d338349927bbdc959f9b8b53c3eb1e60256 Mon Sep 17 00:00:00 2001 From: Rui Cruz Date: Tue, 21 Nov 2017 22:51:54 +0000 Subject: [PATCH 091/639] create interface https://github.com/lovell/sharp/commit/1aa053ce6f8aadba51010c56e0cfc563c952fd1b#commitcomment-25672716 --- types/sharp/index.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/types/sharp/index.d.ts b/types/sharp/index.d.ts index 530501dd13..69f4bc970a 100644 --- a/types/sharp/index.d.ts +++ b/types/sharp/index.d.ts @@ -423,6 +423,8 @@ declare namespace sharp { density?: number; /** describes raw pixel image data. */ raw?: Raw; + /** describes a blank overlay to be created. */ + create?: Create; } interface CacheOptions { @@ -445,6 +447,17 @@ declare namespace sharp { channels: number; } + interface Create { + /** Number of pixels wide */ + width: number; + /** Number of pixels high */ + height: number; + /** Number of bands e.g. 3 for RGB, 4 for RGBA */ + channels: number; + /** parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */ + background: string | RGBA; + } + interface Metadata { /** Name of decoder used to decompress image data e.g. jpeg, png, webp, gif, svg */ format?: string; From 3f362978d81d5113ad2a1640e56cdc68ae695087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Wed, 22 Nov 2017 12:45:29 +0000 Subject: [PATCH 092/639] Fixed linter errors --- types/node-cache/index.d.ts | 1 - types/node-cache/node-cache-tests.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/node-cache/index.d.ts b/types/node-cache/index.d.ts index 00e7316edc..069bd4fb32 100644 --- a/types/node-cache/index.d.ts +++ b/types/node-cache/index.d.ts @@ -257,7 +257,6 @@ declare class NodeCache extends events.EventEmitter implements NodeCache.NodeCac cb?: Callback, ): boolean; - /** * list all keys within this cache * @param cb Callback function diff --git a/types/node-cache/node-cache-tests.ts b/types/node-cache/node-cache-tests.ts index 66c2fb4176..ebf1b88688 100644 --- a/types/node-cache/node-cache-tests.ts +++ b/types/node-cache/node-cache-tests.ts @@ -83,7 +83,7 @@ interface TypeSample { result = cache.getStats(); } -/* tslint:disable void-return no-void-expression */ +/* tslint-:disable void-return no-void-expression { let cache: NodeCache; let result: void; @@ -95,4 +95,4 @@ interface TypeSample { let result: void; result = cache.close(); } -/* tslint:enable void-return */ + tslint-:enable void-return */ From 3ed8da33614d61dbf65c080d3a0f0e9cc5324736 Mon Sep 17 00:00:00 2001 From: allipierre Date: Wed, 22 Nov 2017 19:19:13 +0100 Subject: [PATCH 093/639] remove some errors --- types/confirmdialog/jquery-confirm.ts | 232 ++++++++++++++++++++++++-- types/confirmdialog/tsconfig.json | 2 +- 2 files changed, 223 insertions(+), 11 deletions(-) diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/jquery-confirm.ts index 2f63c28f60..e75057f504 100644 --- a/types/confirmdialog/jquery-confirm.ts +++ b/types/confirmdialog/jquery-confirm.ts @@ -63,7 +63,7 @@ class Confirm implements server.Iperson { text: 'Submit', btnClass: 'btn-blue', action: function() { - let name; + let name = this.$content.find('.name').val(); if (!name) { $.alert('provide a valid name'); return false; @@ -76,7 +76,13 @@ class Confirm implements server.Iperson { }, }, onContentReady: function() { - + // bind to events + var jc = this; + this.$content.find('form').on('submit', function(e) { + // if the user submits the form by pressing enter in the field. + e.preventDefault(); + jc.$$formSubmit.trigger('click'); // reference the button and click it + }); } }); @@ -122,11 +128,11 @@ class Confirm implements server.Iperson { public confirm_5() { $.confirm({ buttons: { - hello: function(helloButton:string) { + hello: function(helloButton) { // shorthand method to define a button // the button key will be used as button name }, - hey: function(heyButton:string) { + hey: function(heyButton) { // access the button using jquery this.$$hello.trigger('click'); // click the 'hello' button this.$$hey.prop('disabled', true); // disable the current button using jquery method @@ -144,7 +150,7 @@ class Confirm implements server.Iperson { keys: ['enter', 'a'], // keyboard event for button isHidden: false, // initially not hidden isDisabled: false, // initially not disabled - action: function(heyThereButton:string) { + action: function(heyThereButton) { // longhand method to define a button // provides more features } @@ -199,12 +205,21 @@ class Confirm implements server.Iperson { buttons: { buttonA: { text: 'button a', - action: function(buttonA:HTMLElement) { - + action: function(buttonA) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. return false; // prevent the modal from closing } }, - resetButton: function(resetButton:HTMLElement) {} + resetButton: function(resetButton) {} } }); } @@ -325,7 +340,133 @@ class Confirm implements server.Iperson { }); } + public ajaxLoading() { + $.confirm({ + title: 'Title', + content: 'url:text.txt', + onContentReady: function() { + var self = this; + this.setContentPrepend('
Prepended text
'); + setTimeout(function() { + self.setContentAppend('
Appended text after 2 seconds
'); + }, 2000); + }, + columnClass: 'medium', + }); + $.confirm({ + content: function() { + var self = this; + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContent('Description: ' + response.description); + self.setContentAppend('
Version: ' + response.version); + self.setTitle(response.name); + }).fail(function() { + self.setContent('Something went wrong.'); + }); + } + }); + + $.confirm({ + content: 'url:text.txt', + contentLoaded: function(data, status, xhr) { + // data is already set in content + this.setContentAppend('
Status: ' + status); + } + }); + + $.confirm({ + content: function() { + var self = this; + self.setContent('Checking callback flow'); + return $.ajax({ + url: 'bower.json', + dataType: 'json', + method: 'get' + }).done(function(response) { + self.setContentAppend('
Done!
'); + }).fail(function() { + self.setContentAppend('
Fail!
'); + }).always(function() { + self.setContentAppend('
Always!
'); + }); + }, + contentLoaded: function(data, status, xhr) { + self.setContentAppend('
Content loaded!
'); + }, + onContentReady: function() { + this.setContentAppend('
Content ready!
'); + } + }); + + } + + public autoClose() { + $.confirm({ + title: 'Delete user?', + content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', + autoClose: 'cancelAction|8000', + buttons: { + deleteUser: { + text: 'delete user', + action: function() { + $.alert('Deleted the user!'); + } + }, + cancelAction: function() { + $.alert('action is canceled'); + } + } + }); + $.confirm({ + title: 'Logout?', + content: 'Your time is out, you will be automatically logged out in 10 seconds.', + autoClose: 'logoutUser|10000', + buttons: { + logoutUser: { + text: 'logout myself', + action: function() { + $.alert('The user was logged out'); + } + }, + cancel: function() { + $.alert('canceled'); + } + } + }); + } + + public backgroundDismisse() { + $.confirm({ + backgroundDismiss: true, // this will just close the modal + }); + $.confirm({ + backgroundDismiss: function() { + return false; // modal wont close. + }, + }); + $.confirm({ + backgroundDismiss: function() { + return 'buttonName'; // the button will handle it + }, + }); + $.confirm({ + backgroundDismiss: 'buttonName', + content: 'in here the backgroundDismiss action is handled by buttonName' + + '
', + buttons: { + buttonName: function() { + var $checkbox = this.$content.find('#enableCheckbox'); + return $checkbox.prop('checked'); + }, + close: function() {} + } + }); + } public backgroundDismisseAnimation(){ $.confirm({ @@ -378,7 +519,50 @@ $.confirm({ } - + public callBack(){ + $.confirm({ + title: false, + content: 'url:callback.html', + onContentReady: function () { + // when content is fetched & rendered in DOM + alert('onContentReady'); + var self = this; + this.buttons.ok.disable(); + this.$content.find('.btn').click(function(){ + self.$content.find('input').val('Chuck norris'); + self.buttons.ok.enable(); + }); + }, + contentLoaded: function(data, status, xhr){ + // when content is fetched + alert('contentLoaded: ' + status); + }, + onOpenBefore: function () { + // before the modal is displayed. + alert('onOpenBefore'); + }, + onOpen: function () { + // after the modal is displayed. + alert('onOpen'); + }, + onClose: function () { + // before the modal is hidden. + alert('onClose'); + }, + onDestroy: function () { + // when the modal is removed from DOM + alert('onDestroy'); + }, + onAction: function (btnName) { + // when a button is clicked, with the button name + alert('onAction: ' + btnName); + }, + buttons: { + ok: function(){ + } + } +}); + } public globalSettings(){ jconfirm.defaults = { title: 'Hello', @@ -402,7 +586,8 @@ $.confirm({ } }, }, - + contentLoaded: function(data, status, xhr){ + }, icon: '', lazyOpen: false, bgOpacity: null, @@ -451,6 +636,33 @@ $.confirm({ }); } + + public confirm_84() { + $.confirm({ + closeIcon: true, + buttons: { + buttonA: { + text: 'button a', + action: function (buttonA: HTMLElement) { + this.buttons.resetButton.setText('reset button!!!'); + this.buttons.resetButton.disable(); + this.buttons.resetButton.enable(); + this.buttons.resetButton.hide(); + this.buttons.resetButton.show(); + this.buttons.resetButton.addClass('btn-red'); + this.buttons.resetButton.removeClass('btn-red'); + // or + this.$$resetButton // button's jquery element reference, go crazy + this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing + } + }, + resetButton: function (resetButton: string) { + } + } +}); + } + } diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index b43b979bcc..6949afdda5 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -16,6 +16,6 @@ }, "files": [ "index.d.ts", - "jquery-confirm.ts" + "jquery_confirm.ts" ] } From 40e24912b2d95b3508b7d68efadb0141541c14b3 Mon Sep 17 00:00:00 2001 From: Nick Veys Date: Wed, 22 Nov 2017 14:34:13 -0600 Subject: [PATCH 094/639] Improve importability of angular-websocket --- types/angular-websocket/index.d.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/types/angular-websocket/index.d.ts b/types/angular-websocket/index.d.ts index b7b3f55093..f11f01c891 100644 --- a/types/angular-websocket/index.d.ts +++ b/types/angular-websocket/index.d.ts @@ -4,16 +4,23 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as ng from "angular"; +import * as angular from "angular"; + +export type IWebSocketConfigOptions = angular.websocket.IWebSocketConfigOptions; +export type IWebSocketProvider = angular.websocket.IWebSocketProvider; +export type IWebSocketMessageOptions = angular.websocket.IWebSocketMessageOptions; +export type IWebSocketMessageHandler = angular.websocket.IWebSocketMessageHandler; +export type IWebSocketQueueItem = angular.websocket.IWebSocketQueueItem; +export type IWebSocket = angular.websocket.IWebSocket; declare module "angular" { - namespace websocket { + export namespace websocket { /** * Options available to be specified for IWebSocketProvider. */ type IWebSocketConfigOptions = { - scope?: ng.IScope; + scope?: angular.IScope; rootScopeFailOver?: boolean; useApplyAsync?: boolean; initialTimeout?: number; @@ -54,7 +61,7 @@ declare module "angular" { /** Type corresponding to items stored in $WebSocket#sendQueue instance. */ type IWebSocketQueueItem = { message: any; - defered: ng.IPromise; + defered: angular.IPromise; } interface IWebSocket { @@ -108,7 +115,7 @@ declare module "angular" { * * @param data data to send, if this is an object, it will be stringified before sending */ - send(data: string | {}): ng.IPromise; + send(data: string | {}): angular.IPromise; /** * WebSocket instance. From 75d009816c1852e32be20e761a2dfbf78df86dd6 Mon Sep 17 00:00:00 2001 From: Nick Veys Date: Wed, 22 Nov 2017 15:15:19 -0600 Subject: [PATCH 095/639] Move tslint, tsconfig closer to defaults, fix all linting issues --- .../angular-websocket-tests.ts | 105 ++++++++---------- types/angular-websocket/index.d.ts | 68 ++++++------ types/angular-websocket/tsconfig.json | 16 +-- types/angular-websocket/tslint.json | 75 +------------ 4 files changed, 91 insertions(+), 173 deletions(-) diff --git a/types/angular-websocket/angular-websocket-tests.ts b/types/angular-websocket/angular-websocket-tests.ts index 1df77b7a2a..51246c529a 100644 --- a/types/angular-websocket/angular-websocket-tests.ts +++ b/types/angular-websocket/angular-websocket-tests.ts @@ -1,69 +1,62 @@ -let dummySocket: ng.websocket.IWebSocket; -let dummyPromise: ng.IPromise; -let dummyScope: ng.IScope; +import * as ng from 'angular'; -let provider: ng.websocket.IWebSocketProvider = (url: string, protocols?:string[] | ng.websocket.IWebSocketConfigOptions, options?: ng.websocket.IWebSocketConfigOptions) => { - return dummySocket; -} +(promise: angular.IPromise, scope: ng.IScope, provider: ng.websocket.IWebSocketProvider) => { + const socket = provider("wss://localhost"); + const socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]); -let socketWithProtocol = provider("wss://localhost", "protocol"); -let socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]); + const socketWithOptions = provider("wss://localhost", { + scope, + rootScopeFailOver: true, + useApplyAsync: true, + initialTimeout: 100, + maxTimeout: 300000, + reconnectIfNotNormalClose: true, + binaryType: "blob" + }); -let socketWithOptions = provider("wss://localhost", { - scope: dummyScope, - rootScopeFailOver: true, - useApplyAsync: true, - initialTimeout: 100, - maxTimeout: 300000, - reconnectIfNotNormalClose: true, - binaryType: "blob" -}); + const socketWithProtocolAndOptions = provider("wss://localhost", "protocol", { + scope, + rootScopeFailOver: true, + useApplyAsync: true, + initialTimeout: 100, + maxTimeout: 300000, + reconnectIfNotNormalClose: true, + binaryType: "blob" + }); -let socketWithProtocolAndOptions = provider("wss://localhost", "protocol", { - scope: dummyScope, - rootScopeFailOver: true, - useApplyAsync: true, - initialTimeout: 100, - maxTimeout: 300000, - reconnectIfNotNormalClose: true, - binaryType: "blob" -}); + socket.onOpen((event: Event) => {}) + .onClose((event: Event) => {}) + .onError((event: Event) => {}) + .onMessage((event: Event) => {}); -let socket = provider("wss://localhost"); + socket.onMessage((event: Event) => {}, { filter: /Some Filter/ }) + .onMessage((event: Event) => {}, { filter: 'Some Filter' }) + .onMessage((event: Event) => {}, { filter: 'Some Filter', autoApply: true }) + .onMessage((event: Event) => {}, { autoApply: false }); -socket.onOpen((event) => {}) - .onClose((event) => {}) - .onError((event) => {}) - .onMessage((event) => {}); + socket.close(true); + socket.close(); -socket.onMessage((event) => {}, { filter: /Some Filter/ }) - .onMessage((event) => {}, { filter: 'Some Filter' }) - .onMessage((event) => {}, { filter: 'Some Filter', autoApply: true }) - .onMessage((event) => {}, { autoApply: false }); + socket.send("Some great data here!").finally(() => {}); + socket.send({ list: [1, 2, 3, 4] }); -socket.close(true); -socket.close(); + socket.socket.send("data"); + socket.socket.close(); + socket.socket.close(1); + socket.socket.close(1, "reason"); -socket.send("Some great data here!").finally(() => {}); -socket.send({ list: [1, 2, 3, 4] }); + socket.sendQueue.push({ message: "msg", defered: promise }); -socket.socket.send("data"); -socket.socket.close(); -socket.socket.close(1); -socket.socket.close(1, "reason"); + socket.onOpenCallbacks.push((event: Event) => {}); + socket.onCloseCallbacks.push((event: CloseEvent) => {}); + socket.onErrorCallbacks.push((event: Event) => {}); + socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true }); + socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true }); + socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, autoApply: true }); -socket.sendQueue.push({ message: "msg", defered: dummyPromise }); + socket.readyState = 0; -socket.onOpenCallbacks.push((event: Event) => {}); -socket.onCloseCallbacks.push((event: CloseEvent) => {}); -socket.onErrorCallbacks.push((event: Event) => {}); -socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true }); -socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true }); -socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: undefined, autoApply: true }); - -socket.readyState = 0; - -socket.initialTimeout = 10; - -socket.maxTimeout = 5000; + socket.initialTimeout = 10; + socket.maxTimeout = 5000; +}; diff --git a/types/angular-websocket/index.d.ts b/types/angular-websocket/index.d.ts index f11f01c891..0b26bd2cfd 100644 --- a/types/angular-websocket/index.d.ts +++ b/types/angular-websocket/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for angular-websocket v2.0 +// Type definitions for angular-websocket 2.0 // Project: https://github.com/AngularClass/angular-websocket // Definitions by: Nick Veys // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,33 +14,32 @@ export type IWebSocketQueueItem = angular.websocket.IWebSocketQueueItem; export type IWebSocket = angular.websocket.IWebSocket; declare module "angular" { - export namespace websocket { - + namespace websocket { /** * Options available to be specified for IWebSocketProvider. */ - type IWebSocketConfigOptions = { - scope?: angular.IScope; - rootScopeFailOver?: boolean; - useApplyAsync?: boolean; - initialTimeout?: number; - maxTimeout?: number; - binaryType?: "blob" | "arraybuffer"; - reconnectIfNotNormalClose?: boolean; - } - interface IWebSocketProvider { - /** - * Creates and opens an IWebSocket instance. - * - * @param url url to connect to - * @return websocket instance - */ - (url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket; + interface IWebSocketConfigOptions { + scope?: IScope; + rootScopeFailOver?: boolean; + useApplyAsync?: boolean; + initialTimeout?: number; + maxTimeout?: number; + binaryType?: "blob" | "arraybuffer"; + reconnectIfNotNormalClose?: boolean; } + /** + * Creates and opens an IWebSocket instance. + * + * @param url url to connect to + * @return websocket instance + */ + type IWebSocketProvider = + (url: string, protocols?: string | string[] | IWebSocketConfigOptions, + options?: IWebSocketConfigOptions) => IWebSocket; + /** Options available to be specified for IWebSocket.onMessage */ - type IWebSocketMessageOptions = { - + interface IWebSocketMessageOptions { /** * If specified, only messages that match the filter will cause the message event * to be fired. @@ -51,21 +50,20 @@ declare module "angular" { autoApply?: boolean; } - /** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */ - type IWebSocketMessageHandler = { - fn: (evt: MessageEvent) => void; - pattern: string | RegExp; - autoApply: boolean; + /** Type corresponding to onMessage callbacks stored in $Websocket#onMessageCallbacks instance. */ + interface IWebSocketMessageHandler { + fn: (evt: MessageEvent) => void; + pattern?: string | RegExp; + autoApply: boolean; } /** Type corresponding to items stored in $WebSocket#sendQueue instance. */ - type IWebSocketQueueItem = { - message: any; - defered: angular.IPromise; + interface IWebSocketQueueItem { + message: any; + defered: IPromise; } interface IWebSocket { - /** * Adds a callback to be executed each time a socket connection is opened for * this instance. @@ -115,7 +113,7 @@ declare module "angular" { * * @param data data to send, if this is an object, it will be stringified before sending */ - send(data: string | {}): angular.IPromise; + send(data: string | {}): IPromise; /** * WebSocket instance. @@ -130,7 +128,7 @@ declare module "angular" { /** * List of callbacks to be executed when the socket is opened. */ - onOpenCallbacks: ((evt: Event) => void)[]; + onOpenCallbacks: Array<((evt: Event) => void)>; /** * List of callbacks to be executed when a message is received from the socket. @@ -140,12 +138,12 @@ declare module "angular" { /** * List of callbacks to be executed when an error is received from the socket. */ - onErrorCallbacks: ((evt: Event) => void)[]; + onErrorCallbacks: Array<((evt: Event) => void)>; /** * List of callbacks to be executed when the socket is closed. */ - onCloseCallbacks: ((evt: CloseEvent) => void)[]; + onCloseCallbacks: Array<((evt: CloseEvent) => void)>; /** * Returns either the readyState value from the underlying WebSocket instance diff --git a/types/angular-websocket/tsconfig.json b/types/angular-websocket/tsconfig.json index 96aab30ef0..89d5cb9dc3 100644 --- a/types/angular-websocket/tsconfig.json +++ b/types/angular-websocket/tsconfig.json @@ -1,8 +1,4 @@ { - "files": [ - "index.d.ts", - "angular-websocket-tests.ts" - ], "compilerOptions": { "module": "commonjs", "lib": [ @@ -11,8 +7,8 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": false, + "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,5 +16,9 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - } -} \ No newline at end of file + }, + "files": [ + "index.d.ts", + "angular-websocket-tests.ts" + ] +} diff --git a/types/angular-websocket/tslint.json b/types/angular-websocket/tslint.json index a41bf5d19a..2c7c1bed53 100644 --- a/types/angular-websocket/tslint.json +++ b/types/angular-websocket/tslint.json @@ -1,79 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "interface-name": false } } From d7848388b9482bbc77115510018df12192271716 Mon Sep 17 00:00:00 2001 From: Bryan Johnson Date: Wed, 22 Nov 2017 14:24:33 -0700 Subject: [PATCH 096/639] update mapbox-gl to handle expressions and heatmaps --- types/mapbox-gl/index.d.ts | 1646 ++++++++++++++++++------------------ 1 file changed, 838 insertions(+), 808 deletions(-) diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index ddaafced3d..520f267b5f 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.41.0 +// Type definitions for Mapbox GL JS v0.42.2 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer , Patrick Reames // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,1080 +7,1110 @@ /// declare namespace mapboxgl { - let accessToken: string; - let version: string; - export function supported(options?: {failIfMajorPerformanceCaveat?: boolean}): boolean; - export function setRTLTextPlugin(pluginURL: string, callback: Function): void; + let accessToken: string; + let version: string; - type LngLatLike = number[] | LngLat; - type LngLatBoundsLike = number[][] | LngLatLike[] | LngLatBounds; - type PointLike = number[] | Point; + export function supported(options?: { failIfMajorPerformanceCaveat?: boolean }): boolean; - /** - * Map - */ - export class Map extends Evented { - constructor(options?: MapboxOptions); + export function setRTLTextPlugin(pluginURL: string, callback: Function): void; - addControl(control: Control, position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'): this; + type LngLatLike = number[] | LngLat; + type LngLatBoundsLike = number[][] | LngLatLike[] | LngLatBounds; + type PointLike = number[] | Point; + type Expression = any[]; - removeControl(control: Control): this; + /** + * Map + */ + export class Map extends Evented { + constructor(options?: MapboxOptions); - addClass(klass: string, options?: mapboxgl.StyleOptions): this; + addControl(control: Control, position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'): this; - removeClass(klass: string, options?: mapboxgl.StyleOptions): this; + removeControl(control: Control): this; - setClasses(klasses: string[], options?: mapboxgl.StyleOptions): this; + addClass(klass: string, options?: mapboxgl.StyleOptions): this; - hasClass(klass: string): boolean; + removeClass(klass: string, options?: mapboxgl.StyleOptions): this; - getClasses(): string[]; + setClasses(klasses: string[], options?: mapboxgl.StyleOptions): this; - resize(): this; + hasClass(klass: string): boolean; - getBounds(): mapboxgl.LngLatBounds; + getClasses(): string[]; - setMaxBounds(lnglatbounds?: LngLatBoundsLike): this; + resize(): this; - setMinZoom(minZoom?: number): this; + getBounds(): mapboxgl.LngLatBounds; - getMinZoom(): number; + setMaxBounds(lnglatbounds?: LngLatBoundsLike): this; - setMaxZoom(maxZoom?: number): this; + setMinZoom(minZoom?: number): this; - getMaxZoom(): number; + getMinZoom(): number; - project(lnglat: LngLatLike): mapboxgl.Point; + setMaxZoom(maxZoom?: number): this; - unproject(point: PointLike): mapboxgl.LngLat; + getMaxZoom(): number; - queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: {layers?: string[], filter?: any[]}): GeoJSON.Feature[]; + project(lnglat: LngLatLike): mapboxgl.Point; - querySourceFeatures(sourceID: string, parameters?: {sourceLayer?: string, filter?: any[]}): GeoJSON.Feature[]; + unproject(point: PointLike): mapboxgl.LngLat; - setStyle(style: mapboxgl.Style | string): this; + queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: { layers?: string[], filter?: any[] }): GeoJSON.Feature[]; - getStyle(): mapboxgl.Style; + querySourceFeatures(sourceID: string, parameters?: { sourceLayer?: string, filter?: any[] }): GeoJSON.Feature[]; - isStyleLoaded(): boolean; + setStyle(style: mapboxgl.Style | string): this; - addSource(id: string, source: VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource | GeoJSONSourceRaw): this; + getStyle(): mapboxgl.Style; - isSourceLoaded(id: string): boolean; + isStyleLoaded(): boolean; - areTilesLoaded(): boolean; + addSource(id: string, source: VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource | GeoJSONSourceRaw): this; - removeSource(id: string): this; + isSourceLoaded(id: string): boolean; - getSource(id: string): VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource; + areTilesLoaded(): boolean; - addImage(name: string, image: HTMLImageElement | ArrayBufferView, options?: {width?: number, height?: number, pixelRatio?: number}): this; + removeSource(id: string): this; - removeImage(name: string): this; + getSource(id: string): VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource; - loadImage(url: string, callback: Function): this; + addImage(name: string, image: HTMLImageElement | ArrayBufferView, options?: { width?: number, height?: number, pixelRatio?: number }): this; - addLayer(layer: mapboxgl.Layer, before?: string): this; + removeImage(name: string): this; - moveLayer(id: string, beforeId?: string): this; + loadImage(url: string, callback: Function): this; - removeLayer(id: string): this; + addLayer(layer: mapboxgl.Layer, before?: string): this; - getLayer(id: string): mapboxgl.Layer; + moveLayer(id: string, beforeId?: string): this; - setFilter(layer: string, filter?: any[]): this; + removeLayer(id: string): this; - setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this; + getLayer(id: string): mapboxgl.Layer; - getFilter(layer: string): any[]; + setFilter(layer: string, filter?: any[]): this; - setPaintProperty(layer: string, name: string, value: any, klass?: string): this; + setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this; - getPaintProperty(layer: string, name: string, klass?: string): any; + getFilter(layer: string): any[]; - setLayoutProperty(layer: string, name: string, value: any): this; + setPaintProperty(layer: string, name: string, value: any, klass?: string): this; - getLayoutProperty(layer: string, name: string, klass?: string): any; + getPaintProperty(layer: string, name: string, klass?: string): any; - setLight(options: mapboxgl.Light, lightOptions: any): this; + setLayoutProperty(layer: string, name: string, value: any): this; - getLight(): mapboxgl.Light; + getLayoutProperty(layer: string, name: string, klass?: string): any; - getContainer(): HTMLElement; + setLight(options: mapboxgl.Light, lightOptions: any): this; - getCanvasContainer(): HTMLElement; + getLight(): mapboxgl.Light; - getCanvas(): HTMLCanvasElement; + getContainer(): HTMLElement; - loaded(): boolean; + getCanvasContainer(): HTMLElement; - remove(): void; + getCanvas(): HTMLCanvasElement; - onError(): void; + loaded(): boolean; - showTileBoundaries: boolean; + remove(): void; - showCollisionBoxes: boolean; + onError(): void; - repaint: boolean; + showTileBoundaries: boolean; - getCenter(): mapboxgl.LngLat; + showCollisionBoxes: boolean; - setCenter(center: LngLatLike, eventData?: mapboxgl.EventData): this; + repaint: boolean; - panBy(offset: number[], options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + getCenter(): mapboxgl.LngLat; - panTo(lnglat: LngLatLike, options?: mapboxgl.AnimationOptions, eventdata?: mapboxgl.EventData): this; + setCenter(center: LngLatLike, eventData?: mapboxgl.EventData): this; - getZoom(): number; + panBy(offset: number[], options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - setZoom(zoom: number, eventData?: mapboxgl.EventData): this; + panTo(lnglat: LngLatLike, options?: mapboxgl.AnimationOptions, eventdata?: mapboxgl.EventData): this; - zoomTo(zoom: number, options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + getZoom(): number; - zoomIn(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + setZoom(zoom: number, eventData?: mapboxgl.EventData): this; - zoomOut(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + zoomTo(zoom: number, options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - getBearing(): number; + zoomIn(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - setBearing(bearing: number, eventData?: mapboxgl.EventData): this; + zoomOut(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - rotateTo(bearing: number, options?: mapboxgl.AnimationOptions, eventData?: EventData): this; + getBearing(): number; - resetNorth(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + setBearing(bearing: number, eventData?: mapboxgl.EventData): this; - snapToNorth(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + rotateTo(bearing: number, options?: mapboxgl.AnimationOptions, eventData?: EventData): this; - getPitch(): number; + resetNorth(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - setPitch(pitch: number, eventData?: EventData): this; + snapToNorth(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - fitBounds(bounds: LngLatBoundsLike, options?: { linear?: boolean, easing?: Function, padding?: number | mapboxgl.PaddingOptions, offset?: PointLike, maxZoom?: number }, eventData?: mapboxgl.EventData): this; + getPitch(): number; - jumpTo(options: mapboxgl.CameraOptions, eventData?: mapboxgl.EventData): this; + setPitch(pitch: number, eventData?: EventData): this; - easeTo(options: mapboxgl.CameraOptions | mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; + fitBounds(bounds: LngLatBoundsLike, options?: { linear?: boolean, easing?: Function, padding?: number | mapboxgl.PaddingOptions, offset?: PointLike, maxZoom?: number }, eventData?: mapboxgl.EventData): this; - flyTo(options: mapboxgl.FlyToOptions, eventData?: mapboxgl.EventData): this; + jumpTo(options: mapboxgl.CameraOptions, eventData?: mapboxgl.EventData): this; - isMoving(): boolean; + easeTo(options: mapboxgl.CameraOptions | mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this; - stop(): this; + flyTo(options: mapboxgl.FlyToOptions, eventData?: mapboxgl.EventData): this; - scrollZoom: ScrollZoomHandler; + isMoving(): boolean; - boxZoom: BoxZoomHandler; + stop(): this; - dragRotate: DragRotateHandler; + scrollZoom: ScrollZoomHandler; - dragPan: DragPanHandler; + boxZoom: BoxZoomHandler; - keyboard: KeyboardHandler; + dragRotate: DragRotateHandler; - doubleClickZoom: DoubleClickZoomHandler; + dragPan: DragPanHandler; - touchZoomRotate: TouchZoomRotateHandler; - } + keyboard: KeyboardHandler; - export interface MapboxOptions { - /** If true, an attribution control will be added to the map. */ - attributionControl?: boolean; + doubleClickZoom: DoubleClickZoomHandler; - bearing?: number; + touchZoomRotate: TouchZoomRotateHandler; + } - /** Snap to north threshold in degrees. */ - bearingSnap?: number; + export interface MapboxOptions { + /** If true, an attribution control will be added to the map. */ + attributionControl?: boolean; - /** If true, enable the "box zoom" interaction (see BoxZoomHandler) */ - boxZoom?: boolean; + bearing?: number; - /** initial map center */ - center?: LngLatLike; + /** Snap to north threshold in degrees. */ + bearingSnap?: number; - /** Style class names with which to initialize the map */ - classes?: string[]; + /** If true, enable the "box zoom" interaction (see BoxZoomHandler) */ + boxZoom?: boolean; - /** ID of the container element */ - container?: string | Element; + /** initial map center */ + center?: LngLatLike; - /** If true, enable the "drag to pan" interaction (see DragPanHandler). */ - dragPan?: boolean; + /** Style class names with which to initialize the map */ + classes?: string[]; - /** If true, enable the "drag to rotate" interaction (see DragRotateHandler). */ - dragRotate?: boolean; + /** ID of the container element */ + container?: string | Element; - /** If true, enable the "double click to zoom" interaction (see DoubleClickZoomHandler). */ - doubleClickZoom?: boolean; + /** If true, enable the "drag to pan" interaction (see DragPanHandler). */ + dragPan?: boolean; - /** If true, the map will track and update the page URL according to map position */ - hash?: boolean; + /** If true, enable the "drag to rotate" interaction (see DragRotateHandler). */ + dragRotate?: boolean; - /** If true, map creation will fail if the implementation determines that the performance of the created WebGL context would be dramatically lower than expected. */ - failIfMayorPerformanceCaveat?: boolean; + /** If true, enable the "double click to zoom" interaction (see DoubleClickZoomHandler). */ + doubleClickZoom?: boolean; - /** If false, no mouse, touch, or keyboard listeners are attached to the map, so it will not respond to input */ - interactive?: boolean; + /** If true, the map will track and update the page URL according to map position */ + hash?: boolean; - /** If true, enable keyboard shortcuts (see KeyboardHandler). */ - keyboard?: boolean; + /** If true, map creation will fail if the implementation determines that the performance of the created WebGL context would be dramatically lower than expected. */ + failIfMayorPerformanceCaveat?: boolean; - logoPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + /** If false, no mouse, touch, or keyboard listeners are attached to the map, so it will not respond to input */ + interactive?: boolean; - /** If set, the map is constrained to the given bounds. */ - maxBounds?: LngLatBoundsLike; + /** If true, enable keyboard shortcuts (see KeyboardHandler). */ + keyboard?: boolean; - /** Maximum zoom of the map */ - maxZoom?: number; + logoPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; - /** Minimum zoom of the map */ - minZoom?: number; + /** If set, the map is constrained to the given bounds. */ + maxBounds?: LngLatBoundsLike; - /** If true, The maps canvas can be exported to a PNG using map.getCanvas().toDataURL();. This is false by default as a performance optimization. */ - preserveDrawingBuffer?: boolean; + /** Maximum zoom of the map */ + maxZoom?: number; - pitch?: number; + /** Minimum zoom of the map */ + minZoom?: number; - refreshExpiredTiles?: boolean; + /** If true, The maps canvas can be exported to a PNG using map.getCanvas().toDataURL();. This is false by default as a performance optimization. */ + preserveDrawingBuffer?: boolean; - renderWorldCopies?: boolean; + pitch?: number; - /** If true, enable the "scroll to zoom" interaction */ - scrollZoom?: boolean; + refreshExpiredTiles?: boolean; - /** stylesheet location */ - style?: mapboxgl.Style | string; + renderWorldCopies?: boolean; - /** If true, the map will automatically resize when the browser window resizes */ - trackResize?: boolean; + /** If true, enable the "scroll to zoom" interaction */ + scrollZoom?: boolean; - /** If true, enable the "pinch to rotate and zoom" interaction (see TouchZoomRotateHandler). */ - touchZoomRotate?: boolean; + /** stylesheet location */ + style?: mapboxgl.Style | string; - /** Initial zoom level */ - zoom?: number; + /** If true, the map will automatically resize when the browser window resizes */ + trackResize?: boolean; - /** Maximum tile cache size for each layer. */ - maxTileCacheSize?: number; - } + /** If true, enable the "pinch to rotate and zoom" interaction (see TouchZoomRotateHandler). */ + touchZoomRotate?: boolean; - export interface PaddingOptions { - top: number; - bottom: number; - left: number; - right: number; - } + /** Initial zoom level */ + zoom?: number; - /** - * BoxZoomHandler - */ - export class BoxZoomHandler { - constructor(map: mapboxgl.Map); + /** Maximum tile cache size for each layer. */ + maxTileCacheSize?: number; + } - isEnabled(): boolean; + export interface PaddingOptions { + top: number; + bottom: number; + left: number; + right: number; + } - isActive(): boolean; + /** + * BoxZoomHandler + */ + export class BoxZoomHandler { + constructor(map: mapboxgl.Map); - enable(): void; + isEnabled(): boolean; - disable(): void; - } + isActive(): boolean; - /** - * ScrollZoomHandler - */ - export class ScrollZoomHandler { - constructor(map: mapboxgl.Map); + enable(): void; - isEnabled(): boolean; + disable(): void; + } - enable(): void; + /** + * ScrollZoomHandler + */ + export class ScrollZoomHandler { + constructor(map: mapboxgl.Map); - disable(): void; - } + isEnabled(): boolean; - /** - * DragPenHandler - */ - export class DragPanHandler { - constructor(map: mapboxgl.Map); + enable(): void; - isEnabled(): boolean; + disable(): void; + } - isActive(): boolean; + /** + * DragPenHandler + */ + export class DragPanHandler { + constructor(map: mapboxgl.Map); - enable(): void; + isEnabled(): boolean; - disable(): void; - } + isActive(): boolean; - /** - * DragRotateHandler - */ - export class DragRotateHandler { - constructor(map: mapboxgl.Map, options?: {bearingSnap?: number, pitchWithRotate?: boolean}); + enable(): void; - isEnabled(): boolean; + disable(): void; + } - isActive(): boolean; + /** + * DragRotateHandler + */ + export class DragRotateHandler { + constructor(map: mapboxgl.Map, options?: { bearingSnap?: number, pitchWithRotate?: boolean }); - enable(): void; + isEnabled(): boolean; - disable(): void; - } + isActive(): boolean; - /** - * KeyboardHandler - */ - export class KeyboardHandler { - constructor(map: mapboxgl.Map); + enable(): void; - isEnabled(): boolean; + disable(): void; + } - enable(): void; + /** + * KeyboardHandler + */ + export class KeyboardHandler { + constructor(map: mapboxgl.Map); - disable(): void; - } + isEnabled(): boolean; - /** - * DoubleClickZoomHandler - */ - export class DoubleClickZoomHandler { - constructor(map: mapboxgl.Map); + enable(): void; - isEnabled(): boolean; + disable(): void; + } - enable(): void; + /** + * DoubleClickZoomHandler + */ + export class DoubleClickZoomHandler { + constructor(map: mapboxgl.Map); - disable(): void; - } + isEnabled(): boolean; - /** - * TouchZoomRotateHandler - */ - export class TouchZoomRotateHandler { - constructor(map: mapboxgl.Map); + enable(): void; - isEnabled(): boolean; + disable(): void; + } - enable(): void; + /** + * TouchZoomRotateHandler + */ + export class TouchZoomRotateHandler { + constructor(map: mapboxgl.Map); - disable(): void; + isEnabled(): boolean; - disableRotation(): void; + enable(): void; - enableRotation(): void; - } + disable(): void; - export interface IControl { - onAdd(map: Map): HTMLElement; - onRemove(map: Map): any; - getDefaultPosition(): string; - } + disableRotation(): void; - /** - * Control - */ - export class Control extends Evented { - } + enableRotation(): void; + } - /** - * Navigation - */ - export class NavigationControl extends Control { - constructor(); - } + export interface IControl { + onAdd(map: Map): HTMLElement; - export class PositionOptions { - enableHighAccuracy?: boolean; - timeout?: number; - maximumAge?: number; - } + onRemove(map: Map): any; - export class FitBoundsOptions { - maxZoom?: number; - } + getDefaultPosition(): string; + } - /** - * Geolocate - */ - export class GeolocateControl extends Control { - constructor(options?: {positionOptions?: PositionOptions, fitBoundsOptions?: FitBoundsOptions, trackUserLocation?: boolean, showUserLocation?: boolean}); - } + /** + * Control + */ + export class Control extends Evented { + } - /** - * Attribution - */ - export class AttributionControl extends Control { - constructor(options?: {compact?: boolean}); - } + /** + * Navigation + */ + export class NavigationControl extends Control { + constructor(); + } - /** - * Scale - */ - export class ScaleControl extends Control { - constructor(options?: {maxWidth?: number, unit?: string}) - } + export class PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; + } - /** - * Fullscreen - */ - export class FullscreenControl extends Control { - constructor(); - } + export class FitBoundsOptions { + maxZoom?: number; + } - /** - * Popup - */ - export class Popup extends Evented { - constructor(options?: mapboxgl.PopupOptions); + /** + * Geolocate + */ + export class GeolocateControl extends Control { + constructor(options?: { positionOptions?: PositionOptions, fitBoundsOptions?: FitBoundsOptions, trackUserLocation?: boolean, showUserLocation?: boolean }); + } - addTo(map: mapboxgl.Map): this; + /** + * Attribution + */ + export class AttributionControl extends Control { + constructor(options?: { compact?: boolean }); + } - isOpen(): boolean; + /** + * Scale + */ + export class ScaleControl extends Control { + constructor(options?: { maxWidth?: number, unit?: string }) + } - remove(): this; + /** + * Fullscreen + */ + export class FullscreenControl extends Control { + constructor(); + } - getLngLat(): mapboxgl.LngLat; + /** + * Popup + */ + export class Popup extends Evented { + constructor(options?: mapboxgl.PopupOptions); - setLngLat(lnglat: LngLatLike): this; + addTo(map: mapboxgl.Map): this; - setText(text: string): this; + isOpen(): boolean; - setHTML(html: string): this; + remove(): this; - setDOMContent(htmlNode: Node): this; - } + getLngLat(): mapboxgl.LngLat; - export interface PopupOptions { - closeButton?: boolean; + setLngLat(lnglat: LngLatLike): this; - closeOnClick?: boolean; + setText(text: string): this; - anchor?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + setHTML(html: string): this; - offset?: number | PointLike | { [key:string]: PointLike;}; - } + setDOMContent(htmlNode: Node): this; + } - export interface Style { - bearing?: number; - center?: number[]; - glyphs?: string; - layers?: Layer[]; - metadata?: any; - name?: string; - pitch?: number; - light?: Light; - sources?: any; - sprite?: string; - transition?: Transition; - version: number; - zoom?: number; - } + export interface PopupOptions { + closeButton?: boolean; - export interface Transition { - delay?: number; - duration?: number; - } + closeOnClick?: boolean; - export interface Light { - "anchor"?: "map" | "viewport"; - "position"?: number[]; - "color"?: string; - "intensity"?: number; - } + anchor?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; - export interface Source { - type: "vector" | "raster" | "geojson" | "image" | "video" | "canvas"; - } + offset?: number | PointLike | { [key: string]: PointLike; }; + } - /** - * GeoJSONSource - */ + export interface Style { + bearing?: number; + center?: number[]; + glyphs?: string; + layers?: Layer[]; + metadata?: any; + name?: string; + pitch?: number; + light?: Light; + sources?: any; + sprite?: string; + transition?: Transition; + version: number; + zoom?: number; + } - export interface GeoJSONSourceRaw extends Source, GeoJSONSourceOptions { - type: "geojson"; - } + export interface Transition { + delay?: number; + duration?: number; + } - export class GeoJSONSource implements GeoJSONSourceRaw { - type: "geojson"; + export interface Light { + 'anchor'?: 'map' | 'viewport'; + 'position'?: number[]; + 'color'?: string; + 'intensity'?: number; + } - constructor(options?: mapboxgl.GeoJSONSourceOptions); + export interface Source { + type: 'vector' | 'raster' | 'geojson' | 'image' | 'video' | 'canvas'; + } - setData(data: GeoJSON.Feature | GeoJSON.FeatureCollection | String): this; - } + /** + * GeoJSONSource + */ - export interface GeoJSONSourceOptions { - data?: GeoJSON.Feature | GeoJSON.FeatureCollection | string; + export interface GeoJSONSourceRaw extends Source, GeoJSONSourceOptions { + type: 'geojson'; + } - maxzoom?: number; + export class GeoJSONSource implements GeoJSONSourceRaw { + type: 'geojson'; - buffer?: number; + constructor(options?: mapboxgl.GeoJSONSourceOptions); - tolerance?: number; + setData(data: GeoJSON.Feature | GeoJSON.FeatureCollection | String): this; + } - cluster?: number | boolean; + export interface GeoJSONSourceOptions { + data?: GeoJSON.Feature | GeoJSON.FeatureCollection | string; - clusterRadius?: number; + maxzoom?: number; - clusterMaxZoom?: number; - } + buffer?: number; - /** - * VideoSource - */ - export interface VideoSource extends VideoSourceOptions { } - export class VideoSource implements Source { - type: "video"; + tolerance?: number; - constructor(options?: mapboxgl.VideoSourceOptions); + cluster?: number | boolean; - getVideo(): HTMLVideoElement; + clusterRadius?: number; - setCoordinates(coordinates: number[][]): this; - } + clusterMaxZoom?: number; + } - export interface VideoSourceOptions { - urls?: string[]; + /** + * VideoSource + */ + export interface VideoSource extends VideoSourceOptions { + } - coordinates?: number[][]; - } + export class VideoSource implements Source { + type: 'video'; - /** - * ImageSource - */ - export interface ImageSource extends ImageSourceOptions { } - export class ImageSource implements Source { - type: "image"; + constructor(options?: mapboxgl.VideoSourceOptions); - constructor(options?: mapboxgl.ImageSourceOptions); + getVideo(): HTMLVideoElement; - setCoordinates(coordinates: number[][]): this; - } + setCoordinates(coordinates: number[][]): this; + } - export interface ImageSourceOptions { - url?: string; + export interface VideoSourceOptions { + urls?: string[]; - coordinates?: number[][]; - } + coordinates?: number[][]; + } - /** - * CanvasSource - */ - export class CanvasSource implements Source, CanvasSourceOptions { - type: "canvas"; + /** + * ImageSource + */ + export interface ImageSource extends ImageSourceOptions { + } - coordinates: number[][]; + export class ImageSource implements Source { + type: 'image'; - canvas: string; + constructor(options?: mapboxgl.ImageSourceOptions); - getCanvas(): HTMLCanvasElement; + setCoordinates(coordinates: number[][]): this; + } - setCoordinates(coordinates: number[][]): this; - } + export interface ImageSourceOptions { + url?: string; - export interface CanvasSourceOptions { - coordinates: number[][]; + coordinates?: number[][]; + } - animate?: boolean; + /** + * CanvasSource + */ + export class CanvasSource implements Source, CanvasSourceOptions { + type: 'canvas'; - canvas: string; - } + coordinates: number[][]; - interface VectorSource extends Source { - type: "vector"; - url?: string; - tiles?: string[]; - minzoom?: number; - maxzoom?: number; - } + canvas: string; - interface RasterSource extends Source { - type: "raster"; - url: string; - tiles?: string[]; - minzoom?: number; - maxzoom?: number; - tileSize?: number; - } + getCanvas(): HTMLCanvasElement; - /** - * LngLat - */ - export class LngLat { - lng: number; - lat: number; + setCoordinates(coordinates: number[][]): this; + } - constructor(lng: number, lat: number); + export interface CanvasSourceOptions { + coordinates: number[][]; - /** Return a new LngLat object whose longitude is wrapped to the range (-180, 180). */ - wrap(): mapboxgl.LngLat; + animate?: boolean; - /** Return a LngLat as an array */ - toArray(): number[]; + canvas: string; + } - /** Return a LngLat as a string */ - toString(): string; + interface VectorSource extends Source { + type: 'vector'; + url?: string; + tiles?: string[]; + minzoom?: number; + maxzoom?: number; + } - toBounds(radius: number): LngLatBounds; + interface RasterSource extends Source { + type: 'raster'; + url: string; + tiles?: string[]; + minzoom?: number; + maxzoom?: number; + tileSize?: number; + } - static convert(input: LngLatLike): mapboxgl.LngLat; - } + /** + * LngLat + */ + export class LngLat { + lng: number; + lat: number; - /** - * LngLatBounds - */ - export class LngLatBounds { - sw: LngLatLike; - ne: LngLatLike; - constructor(sw?: LngLatLike, ne?: LngLatLike); + constructor(lng: number, lat: number); - setNorthEast(ne: LngLatLike): this; + /** Return a new LngLat object whose longitude is wrapped to the range (-180, 180). */ + wrap(): mapboxgl.LngLat; - setSouthWest(sw: LngLatLike): this; + /** Return a LngLat as an array */ + toArray(): number[]; - /** Extend the bounds to include a given LngLat or LngLatBounds. */ - extend(obj: mapboxgl.LngLat | mapboxgl.LngLatBounds): this; + /** Return a LngLat as a string */ + toString(): string; - /** Get the point equidistant from this box's corners */ - getCenter(): mapboxgl.LngLat; + toBounds(radius: number): LngLatBounds; - /** Get southwest corner */ - getSouthWest(): mapboxgl.LngLat; + static convert(input: LngLatLike): mapboxgl.LngLat; + } - /** Get northeast corner */ - getNorthEast(): mapboxgl.LngLat; + /** + * LngLatBounds + */ + export class LngLatBounds { + sw: LngLatLike; + ne: LngLatLike; - /** Get northwest corner */ - getNorthWest(): mapboxgl.LngLat; + constructor(sw?: LngLatLike, ne?: LngLatLike); - /** Get southeast corner */ - getSouthEast(): mapboxgl.LngLat; + setNorthEast(ne: LngLatLike): this; - /** Get west edge longitude */ - getWest(): number; + setSouthWest(sw: LngLatLike): this; - /** Get south edge latitude */ - getSouth(): number; + /** Extend the bounds to include a given LngLat or LngLatBounds. */ + extend(obj: mapboxgl.LngLat | mapboxgl.LngLatBounds): this; - /** Get east edge longitude */ - getEast(): number; + /** Get the point equidistant from this box's corners */ + getCenter(): mapboxgl.LngLat; - /** Get north edge latitude */ - getNorth(): number; + /** Get southwest corner */ + getSouthWest(): mapboxgl.LngLat; - /** Returns a LngLatBounds as an array */ - toArray(): number[][]; + /** Get northeast corner */ + getNorthEast(): mapboxgl.LngLat; - /** Return a LngLatBounds as a string */ - toString(): string; + /** Get northwest corner */ + getNorthWest(): mapboxgl.LngLat; - /** Convert an array to a LngLatBounds object, or return an existing LngLatBounds object unchanged. */ - static convert(input: LngLatBoundsLike): mapboxgl.LngLatBounds; - } + /** Get southeast corner */ + getSouthEast(): mapboxgl.LngLat; - /** - * Point - */ - // Todo: Pull out class to seperate definition for Module "point-geometry" - export class Point { - x: number; - y: number; + /** Get west edge longitude */ + getWest(): number; - constructor(x: number, y: number); + /** Get south edge latitude */ + getSouth(): number; - clone(): Point; + /** Get east edge longitude */ + getEast(): number; - add(p: number): Point; + /** Get north edge latitude */ + getNorth(): number; - sub(p: number): Point; + /** Returns a LngLatBounds as an array */ + toArray(): number[][]; - mult(k: number): Point; + /** Return a LngLatBounds as a string */ + toString(): string; - div(k: number): Point; + /** Convert an array to a LngLatBounds object, or return an existing LngLatBounds object unchanged. */ + static convert(input: LngLatBoundsLike): mapboxgl.LngLatBounds; + } - rotate(a: number): Point; + /** + * Point + */ + // Todo: Pull out class to seperate definition for Module "point-geometry" + export class Point { + x: number; + y: number; - matMult(m: number): Point; + constructor(x: number, y: number); - unit(): Point; + clone(): Point; - perp(): Point; + add(p: number): Point; - round(): Point; + sub(p: number): Point; - mag(): number; + mult(k: number): Point; - equals(p: Point): boolean; + div(k: number): Point; - dist(p: Point): number; + rotate(a: number): Point; - distSqr(p: Point): number; + matMult(m: number): Point; - angle(): number; + unit(): Point; - angleTo(p: Point): number; + perp(): Point; - angleWidth(p: Point): number; + round(): Point; - angleWithSep(x: number, y: number): number; + mag(): number; - static convert(a: PointLike): Point; - } + equals(p: Point): boolean; - export class Marker { - constructor(element?: HTMLElement, options?: { offset?: PointLike }); + dist(p: Point): number; - addTo(map: Map): this; + distSqr(p: Point): number; - remove(): this; + angle(): number; - getLngLat(): LngLat; + angleTo(p: Point): number; - setLngLat(lngLat: LngLatLike): this; + angleWidth(p: Point): number; - setPopup(popup?: Popup): this; + angleWithSep(x: number, y: number): number; - getPopup(): Popup; + static convert(a: PointLike): Point; + } - togglePopup(): this; - } + export class Marker { + constructor(element?: HTMLElement, options?: { offset?: PointLike }); - /** - * Evented - */ - export class Evented { - on(type: string, listener: Function): this; + addTo(map: Map): this; - on(type: string, layer: string, listener: Function): this; + remove(): this; - off(type?: string | any, listener?: Function): this; + getLngLat(): LngLat; - off(type?: string | any, layer?: string, listener?: Function): this; + setLngLat(lngLat: LngLatLike): this; - once(type: string, listener: Function): this; + setPopup(popup?: Popup): this; - fire(type: string, data?: mapboxgl.EventData | Object): this; + getPopup(): Popup; - listens(type: string): boolean; - } + togglePopup(): this; + } - /** - * StyleOptions - */ - export interface StyleOptions { - transition?: boolean; - } - - /** - * EventData - */ - export class EventData { - type: string; - target: Map; - originalEvent: Event; - point: mapboxgl.Point; - lngLat: mapboxgl.LngLat; - } - - export class MapMouseEvent { - type: string; - target: Map; - originalEvent: MouseEvent; - point: mapboxgl.Point; - lngLat: mapboxgl.LngLat; - } - - export class MapTouchEvent { - type: string; - target: Map; - originalEvent: TouchEvent; - point: mapboxgl.Point; - lngLat: mapboxgl.LngLat; - points: Point[]; - lngLats: LngLat[]; - } - - export class MapBoxZoomEvent { - originalEvent: MouseEvent; - boxZoomBounds: LngLatBounds; - } - - export class MapDataEvent { - type: string; - dataType: "source" | "style" | "tile"; - isSourceLoaded?: boolean; - source?: mapboxgl.Source; - coord?: any; - } - - /** - * AnimationOptions - */ - export interface AnimationOptions { - /** Number in milliseconds */ - duration?: number; - easing?: Function; - /** point, origin of movement relative to map center */ - offset?: PointLike; - /** When set to false, no animation happens */ - animate?: boolean; - } - - /** - * CameraOptions - */ - export interface CameraOptions { - /** Map center */ - center?: LngLatLike; - /** Map zoom level */ - zoom?: number; - /** Map rotation bearing in degrees counter-clockwise from north */ - bearing?: number; - /** Map angle in degrees at which the camera is looking at the ground */ - pitch?: number; - /** If zooming, the zoom center (defaults to map center) */ - around?: LngLatLike; - } - - /** - * FlyToOptions - */ - export interface FlyToOptions extends AnimationOptions, CameraOptions { - curve?: number; - minZoom?: number; - speed?: number; - screenSpeed?: number; - easing?: Function; - } - - /** - * MapEvent - */ - export interface MapEvent { - resize?: void; - webglcontextlost?: {originalEvent: WebGLContextEvent}; - webglcontextrestored?: {originalEvent: WebGLContextEvent}; - remove?: void; - dataloading?: {data: mapboxgl.MapDataEvent}; - data?: {data: mapboxgl.MapDataEvent}; - render?: void; - contextmenu?: {data: mapboxgl.MapMouseEvent}; - dblclick?: {data: mapboxgl.MapMouseEvent}; - click?: {data: mapboxgl.MapMouseEvent}; - tiledataloading?: {data: mapboxgl.MapDataEvent}; - sourcedataloading?: {data: mapboxgl.MapDataEvent}; - styledataloading?: {data: mapboxgl.MapDataEvent}; - touchcancel?: {data: mapboxgl.MapTouchEvent}; - touchmove?: {data: mapboxgl.MapTouchEvent}; - touchend?: {data: mapboxgl.MapTouchEvent}; - touchstart?: {data: mapboxgl.MapTouchEvent}; - mousemove?: {data: mapboxgl.MapMouseEvent}; - mouseup?: {data: mapboxgl.MapMouseEvent}; - mousedown?: {data: mapboxgl.MapMouseEvent}; - moveend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - move?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - movestart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - mouseout?:{data: mapboxgl.MapMouseEvent}; - load?: void; - sourcedata?: {data: mapboxgl.MapDataEvent}; - styledata?: {data: mapboxgl.MapDataEvent}; - zoomend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - zoom?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - zoomstart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - boxzoomcancel?: {data: mapboxgl.MapBoxZoomEvent}; - boxzoomstart?: {data: mapboxgl.MapBoxZoomEvent}; - boxzoomend?: {data: mapboxgl.MapBoxZoomEvent}; - rotate?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - rotatestart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - rotateend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - drag?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - dragend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; - pitch?: {data: mapboxgl.EventData}; - } - - export interface Layer { - id: string; - type?: "fill" | "line" | "symbol" | "circle" | "fill-extrusion" | "raster" | "background" | "heatmap"; - - metadata?: any; - ref?: string; - - source?: string | VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource | GeoJSONSourceRaw; - - "source-layer"?: string; - - minzoom?: number; - maxzoom?: number; - - interactive?: boolean; - - filter?: any[]; - layout?: BackgroundLayout | FillLayout | FillExtrusionLayout | LineLayout | SymbolLayout | RasterLayout | CircleLayout; - paint?: BackgroundPaint | FillPaint | FillExtrusionPaint | LinePaint | SymbolPaint | RasterPaint | CirclePaint; - } - - export interface StyleFunction { - stops?: any[][]; - property?: string; - base?: number; - type?: "identity" | "exponential" | "interval" | "categorical"; - default?: any; - "colorSpace"?: "rgb" | "lab" | "interval"; - } - - export interface BackgroundLayout { - visibility?: "visible" | "none"; - } - export interface BackgroundPaint { - "background-color"?: string; - "background-pattern"?: string; - "background-opacity"?: number; - } - - export interface FillLayout { - visibility?: "visible" | "none"; - } - export interface FillPaint { - "fill-antialias"?: boolean; - "fill-opacity"?: number | StyleFunction; - "fill-color"?: string | StyleFunction; - "fill-outline-color"?: string | StyleFunction; - "fill-translate"?: number[]; - "fill-translate-anchor"?: "map" | "viewport"; - "fill-pattern"?: "string"; - } - - export interface FillExtrusionLayout { - visibility?: "visible" | "none"; - } - export interface FillExtrusionPaint { - "fill-extrusion-opacity"?: number; - "fill-extrusion-color"?: string | StyleFunction; - "fill-extrusion-translate"?: number[]; - "fill-extrusion-translate-anchor"?: "map" | "viewport"; - "fill-extrusion-pattern"?: string; - "fill-extrusion-height"?: number | StyleFunction; - "fill-extrusion-base"?: number | StyleFunction; - } - - export interface LineLayout { - visibility?: "visible" | "none"; - - "line-cap"?: "butt" | "round" | "square"; - "line-join"?: "bevel" | "round" | "miter"; - "line-miter-limit"?: number; - "line-round-limit"?: number; - } - export interface LinePaint { - "line-opacity"?: number | StyleFunction; - "line-color"?: string | StyleFunction; - "line-translate"?: number[]; - "line-translate-anchor"?: "map" | "viewport"; - "line-width"?: number | StyleFunction; - "line-gap-width"?: number | StyleFunction; - "line-offset"?: number | StyleFunction; - "line-blur"?: number | StyleFunction; - "line-dasharray"?: number[]; - "line-dasharray-transition"?: Transition; - "line-pattern"?: string; - } - - export interface SymbolLayout { - visibility?: "visible" | "none"; - - "symbol-placement"?: "point" | "line"; - "symbol-spacing"?: number; - "symbol-avoid-edges"?: boolean; - "icon-allow-overlap"?: boolean; - "icon-ignore-placement"?: boolean; - "icon-optional"?: boolean; - "icon-rotation-alignment"?: "map" | "viewport" | "auto"; - "icon-pitch-alignment"?: "map" | "viewport"| "auto"; - "icon-size"?: number | StyleFunction; - "icon-text-fit"?: "none" | "both" | "width" | "height"; - "icon-text-fit-padding"?: number[]; - "icon-image"?: string | StyleFunction; - "icon-rotate"?: number | StyleFunction; - "icon-padding"?: number; - "icon-keep-upright"?: boolean; - "icon-offset"?: number[] | StyleFunction; - "text-pitch-alignment"?: "map" | "viewport" | "auto"; - "text-rotation-alignment"?: "map" | "viewport" | "auto"; - "text-field"?: string | StyleFunction; - "text-font"?: string | string[]; - "text-size"?: number | StyleFunction; - "text-max-width"?: number; - "text-line-height"?: number; - "text-letter-spacing"?: number; - "text-justify"?: "left" | "center" | "right"; - "text-anchor"?: "center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right"; - "text-max-angle"?: number; - "text-rotate"?: number | StyleFunction; - "text-padding"?: number; - "text-keep-upright"?: boolean; - "text-transform"?: "none" | "uppercase" | "lowercase" | StyleFunction; - "text-offset"?: number[]; - "text-allow-overlap"?: boolean; - "text-ignore-placement"?: boolean; - "text-optional"?: boolean; - - } - export interface SymbolPaint { - "icon-opacity"?: number | StyleFunction; - "icon-color"?: string | StyleFunction; - "icon-halo-color"?: string | StyleFunction; - "icon-halo-width"?: number | StyleFunction; - "icon-halo-blur"?: number | StyleFunction; - "icon-translate"?: number[]; - "icon-translate-anchor"?: "map" | "viewport"; - "text-opacity"?: number | StyleFunction; - "text-color"?: string | StyleFunction; - "text-halo-color"?: string | StyleFunction; - "text-halo-width"?: number | StyleFunction; - "text-halo-blur"?: number | StyleFunction; - "text-translate"?: number[]; - "text-translate-anchor"?: "map" | "viewport"; - } - - export interface RasterLayout { - visibility?: "visible" | "none"; - } - - export interface RasterPaint { - "raster-opacity"?: number; - "raster-hue-rotate"?: number; - "raster-brightness-min"?: number; - "raster-brightness-max"?: number; - "raster-saturation"?: number; - "raster-contrast"?: number; - "raster-fade-duration"?: number; - } - - export interface CircleLayout { - visibility?: "visible" | "none"; - } - - export interface CirclePaint { - "circle-radius"?: number | StyleFunction; - "circle-radius-transition"?: Transition; - "circle-color"?: string | StyleFunction; - "circle-blur"?: number | StyleFunction; - "circle-opacity"?: number | StyleFunction; - "circle-translate"?: number[]; - "circle-translate-anchor"?: "map" | "viewport"; - "circle-pitch-scale"?: "map" | "viewport"; - "circle-pitch-alignment"?: "map" | "viewport"; - "circle-stroke-width"?: number | StyleFunction; - "circle-stroke-color"?: string | StyleFunction; - "circle-stroke-opacity"?: number | StyleFunction; - } + /** + * Evented + */ + export class Evented { + on(type: string, listener: Function): this; + + on(type: string, layer: string, listener: Function): this; + + off(type?: string | any, listener?: Function): this; + + off(type?: string | any, layer?: string, listener?: Function): this; + + once(type: string, listener: Function): this; + + fire(type: string, data?: mapboxgl.EventData | Object): this; + + listens(type: string): boolean; + } + + /** + * StyleOptions + */ + export interface StyleOptions { + transition?: boolean; + } + + /** + * EventData + */ + export class EventData { + type: string; + target: Map; + originalEvent: Event; + point: mapboxgl.Point; + lngLat: mapboxgl.LngLat; + } + + export class MapMouseEvent { + type: string; + target: Map; + originalEvent: MouseEvent; + point: mapboxgl.Point; + lngLat: mapboxgl.LngLat; + } + + export class MapTouchEvent { + type: string; + target: Map; + originalEvent: TouchEvent; + point: mapboxgl.Point; + lngLat: mapboxgl.LngLat; + points: Point[]; + lngLats: LngLat[]; + } + + export class MapBoxZoomEvent { + originalEvent: MouseEvent; + boxZoomBounds: LngLatBounds; + } + + export class MapDataEvent { + type: string; + dataType: 'source' | 'style' | 'tile'; + isSourceLoaded?: boolean; + source?: mapboxgl.Source; + coord?: any; + } + + /** + * AnimationOptions + */ + export interface AnimationOptions { + /** Number in milliseconds */ + duration?: number; + easing?: Function; + /** point, origin of movement relative to map center */ + offset?: PointLike; + /** When set to false, no animation happens */ + animate?: boolean; + } + + /** + * CameraOptions + */ + export interface CameraOptions { + /** Map center */ + center?: LngLatLike; + /** Map zoom level */ + zoom?: number; + /** Map rotation bearing in degrees counter-clockwise from north */ + bearing?: number; + /** Map angle in degrees at which the camera is looking at the ground */ + pitch?: number; + /** If zooming, the zoom center (defaults to map center) */ + around?: LngLatLike; + } + + /** + * FlyToOptions + */ + export interface FlyToOptions extends AnimationOptions, CameraOptions { + curve?: number; + minZoom?: number; + speed?: number; + screenSpeed?: number; + easing?: Function; + } + + /** + * MapEvent + */ + export interface MapEvent { + resize?: void; + webglcontextlost?: { originalEvent: WebGLContextEvent }; + webglcontextrestored?: { originalEvent: WebGLContextEvent }; + remove?: void; + dataloading?: { data: mapboxgl.MapDataEvent }; + data?: { data: mapboxgl.MapDataEvent }; + render?: void; + contextmenu?: { data: mapboxgl.MapMouseEvent }; + dblclick?: { data: mapboxgl.MapMouseEvent }; + click?: { data: mapboxgl.MapMouseEvent }; + tiledataloading?: { data: mapboxgl.MapDataEvent }; + sourcedataloading?: { data: mapboxgl.MapDataEvent }; + styledataloading?: { data: mapboxgl.MapDataEvent }; + touchcancel?: { data: mapboxgl.MapTouchEvent }; + touchmove?: { data: mapboxgl.MapTouchEvent }; + touchend?: { data: mapboxgl.MapTouchEvent }; + touchstart?: { data: mapboxgl.MapTouchEvent }; + mousemove?: { data: mapboxgl.MapMouseEvent }; + mouseup?: { data: mapboxgl.MapMouseEvent }; + mousedown?: { data: mapboxgl.MapMouseEvent }; + moveend?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + move?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + movestart?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + mouseout?: { data: mapboxgl.MapMouseEvent }; + load?: void; + sourcedata?: { data: mapboxgl.MapDataEvent }; + styledata?: { data: mapboxgl.MapDataEvent }; + zoomend?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + zoom?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + zoomstart?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + boxzoomcancel?: { data: mapboxgl.MapBoxZoomEvent }; + boxzoomstart?: { data: mapboxgl.MapBoxZoomEvent }; + boxzoomend?: { data: mapboxgl.MapBoxZoomEvent }; + rotate?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + rotatestart?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + rotateend?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + drag?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + dragend?: { data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent }; + pitch?: { data: mapboxgl.EventData }; + } + + export interface Layer { + id: string; + type?: 'fill' | 'line' | 'symbol' | 'circle' | 'fill-extrusion' | 'raster' | 'background' | 'heatmap'; + + metadata?: any; + ref?: string; + + source?: string | VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource | GeoJSONSourceRaw; + + 'source-layer'?: string; + + minzoom?: number; + maxzoom?: number; + + interactive?: boolean; + + filter?: any[]; + layout?: BackgroundLayout | FillLayout | FillExtrusionLayout | LineLayout | SymbolLayout | RasterLayout | CircleLayout | HeatmapLayout; + paint?: BackgroundPaint | FillPaint | FillExtrusionPaint | LinePaint | SymbolPaint | RasterPaint | CirclePaint | HeatmapPaint; + } + + export interface StyleFunction { + stops?: any[][]; + property?: string; + base?: number; + type?: 'identity' | 'exponential' | 'interval' | 'categorical'; + default?: any; + 'colorSpace'?: 'rgb' | 'lab' | 'interval'; + } + + export interface BackgroundLayout { + visibility?: 'visible' | 'none'; + } + + export interface BackgroundPaint { + 'background-color'?: string | Expression; + 'background-pattern'?: string; + 'background-opacity'?: number | Expression; + } + + export interface FillLayout { + visibility?: 'visible' | 'none'; + } + + export interface FillPaint { + 'fill-antialias'?: boolean; + 'fill-opacity'?: number | StyleFunction | Expression; + 'fill-color'?: string | StyleFunction | Expression; + 'fill-outline-color'?: string | StyleFunction | Expression; + 'fill-translate'?: number[] | Expression; + 'fill-translate-anchor'?: 'map' | 'viewport'; + 'fill-pattern'?: string; + } + + export interface FillExtrusionLayout { + visibility?: 'visible' | 'none'; + } + + export interface FillExtrusionPaint { + 'fill-extrusion-opacity'?: number | Expression; + 'fill-extrusion-color'?: string | StyleFunction | Expression; + 'fill-extrusion-translate'?: number[] | Expression; + 'fill-extrusion-translate-anchor'?: 'map' | 'viewport'; + 'fill-extrusion-pattern'?: string; + 'fill-extrusion-height'?: number | StyleFunction | Expression; + 'fill-extrusion-base'?: number | StyleFunction | Expression; + } + + export interface LineLayout { + visibility?: 'visible' | 'none'; + + 'line-cap'?: 'butt' | 'round' | 'square'; + 'line-join'?: 'bevel' | 'round' | 'miter'; + 'line-miter-limit'?: number | Expression; + 'line-round-limit'?: number | Expression; + } + + export interface LinePaint { + 'line-opacity'?: number | StyleFunction | Expression; + 'line-color'?: string | StyleFunction | Expression; + 'line-translate'?: number[] | Expression; + 'line-translate-anchor'?: 'map' | 'viewport'; + 'line-width'?: number | StyleFunction | Expression; + 'line-gap-width'?: number | StyleFunction | Expression; + 'line-offset'?: number | StyleFunction | Expression; + 'line-blur'?: number | StyleFunction | Expression; + 'line-dasharray'?: number[]; + 'line-dasharray-transition'?: Transition; + 'line-pattern'?: string; + } + + export interface SymbolLayout { + visibility?: 'visible' | 'none'; + + 'symbol-placement'?: 'point' | 'line'; + 'symbol-spacing'?: number | Expression; + 'symbol-avoid-edges'?: boolean; + 'icon-allow-overlap'?: boolean; + 'icon-ignore-placement'?: boolean; + 'icon-optional'?: boolean; + 'icon-rotation-alignment'?: 'map' | 'viewport' | 'auto'; + 'icon-pitch-alignment'?: 'map' | 'viewport' | 'auto'; + 'icon-size'?: number | StyleFunction | Expression; + 'icon-text-fit'?: 'none' | 'both' | 'width' | 'height'; + 'icon-text-fit-padding'?: number[] | Expression; + 'icon-image'?: string | StyleFunction; + 'icon-rotate'?: number | StyleFunction | Expression; + 'icon-padding'?: number | Expression; + 'icon-keep-upright'?: boolean; + 'icon-offset'?: number[] | StyleFunction | Expression; + 'text-pitch-alignment'?: 'map' | 'viewport' | 'auto'; + 'text-rotation-alignment'?: 'map' | 'viewport' | 'auto'; + 'text-field'?: string | StyleFunction; + 'text-font'?: string | string[]; + 'text-size'?: number | StyleFunction | Expression; + 'text-max-width'?: number | Expression; + 'text-line-height'?: number | Expression; + 'text-letter-spacing'?: number | Expression; + 'text-justify'?: 'left' | 'center' | 'right'; + 'text-anchor'?: 'center' | 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + 'text-max-angle'?: number | Expression; + 'text-rotate'?: number | StyleFunction | Expression; + 'text-padding'?: number | Expression; + 'text-keep-upright'?: boolean; + 'text-transform'?: 'none' | 'uppercase' | 'lowercase' | StyleFunction | Expression; + 'text-offset'?: number[] | Expression; + 'text-allow-overlap'?: boolean; + 'text-ignore-placement'?: boolean; + 'text-optional'?: boolean; + + } + + export interface SymbolPaint { + 'icon-opacity'?: number | StyleFunction | Expression; + 'icon-color'?: string | StyleFunction | Expression; + 'icon-halo-color'?: string | StyleFunction | Expression; + 'icon-halo-width'?: number | StyleFunction | Expression; + 'icon-halo-blur'?: number | StyleFunction | Expression; + 'icon-translate'?: number[] | Expression; + 'icon-translate-anchor'?: 'map' | 'viewport'; + 'text-opacity'?: number | StyleFunction | Expression; + 'text-color'?: string | StyleFunction | Expression; + 'text-halo-color'?: string | StyleFunction | Expression; + 'text-halo-width'?: number | StyleFunction | Expression; + 'text-halo-blur'?: number | StyleFunction | Expression; + 'text-translate'?: number[] | Expression; + 'text-translate-anchor'?: 'map' | 'viewport'; + } + + export interface RasterLayout { + visibility?: 'visible' | 'none'; + } + + export interface RasterPaint { + 'raster-opacity'?: number | Expression; + 'raster-hue-rotate'?: number | Expression; + 'raster-brightness-min'?: number | Expression; + 'raster-brightness-max'?: number | Expression; + 'raster-saturation'?: number | Expression; + 'raster-contrast'?: number | Expression; + 'raster-fade-duration'?: number | Expression; + } + + export interface CircleLayout { + visibility?: 'visible' | 'none'; + } + + export interface CirclePaint { + 'circle-radius'?: number | StyleFunction | Expression; + 'circle-radius-transition'?: Transition; + 'circle-color'?: string | StyleFunction | Expression; + 'circle-blur'?: number | StyleFunction | Expression; + 'circle-opacity'?: number | StyleFunction | Expression; + 'circle-translate'?: number[] | Expression; + 'circle-translate-anchor'?: 'map' | 'viewport'; + 'circle-pitch-scale'?: 'map' | 'viewport'; + 'circle-pitch-alignment'?: 'map' | 'viewport'; + 'circle-stroke-width'?: number | StyleFunction | Expression; + 'circle-stroke-color'?: string | StyleFunction | Expression; + 'circle-stroke-opacity'?: number | StyleFunction | Expression; + } + + export interface HeatmapLayout { + visibility?: 'visible' | 'none'; + } + + export interface HeatmapPaint { + 'heatmap-radius'?: number | Expression; + 'heatmap-transition'?: Transition; + 'heatmap-weight'?: number | StyleFunction | Expression; + 'heatmap-intensity'?: number | Expression; + 'heatmap-color'?: string | Expression; + 'heatmap-color-transition'?: Transition; + 'heatmap-opacity'?: number | Expression; + 'heatmap-opacity-transition'?: Transition; + } } declare module 'mapbox-gl' { - export = mapboxgl; + export = mapboxgl; } declare module 'mapbox-gl/dist/mapbox-gl' { - export = mapboxgl; + export = mapboxgl; } From a045a2c505c0aa38042d04a3ddd086b56c1894c0 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Wed, 22 Nov 2017 22:31:33 +0100 Subject: [PATCH 097/639] Update contract for Auth0DecodedHash of auth0-js This commit updates contract for results of the WebAuth.parseHash call to v.8 of auth0-js. Here is a link to relevant vanilla JS implementation: https://git.io/vFNdC Thanks! --- types/auth0-js/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 76a2c5f319..85e4401266 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/auth0/auth0.js // Definitions by: Adrian Chia // Matt Durrant +// Peter Blazejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace auth0; @@ -525,14 +526,21 @@ export interface Auth0Error { statusText?: string; } +/** + * The contents of the authResult object returned by {@link WebAuth#parseHash } + * @export + * @interface Auth0DecodedHash + */ export interface Auth0DecodedHash { accessToken?: string; idToken?: string; idTokenPayload?: any; + appState?: any; refreshToken?: string; state?: string; expiresIn?: number; tokenType?: string; + scope?: string; } /** Represents the response from an API Token Delegation request. */ From a1642fcdfe696d402565ac09668cfa7fb24a6f0e Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Wed, 22 Nov 2017 22:45:34 +0100 Subject: [PATCH 098/639] Bump auth0-js version covered by this definition file I have tested with 8.11.3 - hence the version bump Thanks! --- types/auth0-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 85e4401266..02642f0934 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Auth0.js 8.10 +// Type definitions for Auth0.js 8.11.3 // Project: https://github.com/auth0/auth0.js // Definitions by: Adrian Chia // Matt Durrant From 860ffb8e9c585e3c9e2f2f2ea0f3bd5b56511c8a Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 12:19:54 +0530 Subject: [PATCH 099/639] Clubbed into one file. Added support for Alexa SDK for Node.js version 1.0.21 --- types/alexa-sdk/alexa-sdk-tests.ts | 20 - types/alexa-sdk/index.d.ts | 974 +++++++++++++++++++++++++- types/alexa-sdk/responseBuilder.d.ts | 170 ----- types/alexa-sdk/services.d.ts | 199 ------ types/alexa-sdk/templateBuilders.d.ts | 232 ------ types/alexa-sdk/tsconfig.json | 5 - types/alexa-sdk/types.d.ts | 208 ------ types/alexa-sdk/utils.d.ts | 96 --- 8 files changed, 952 insertions(+), 952 deletions(-) delete mode 100644 types/alexa-sdk/alexa-sdk-tests.ts delete mode 100644 types/alexa-sdk/responseBuilder.d.ts delete mode 100644 types/alexa-sdk/services.d.ts delete mode 100644 types/alexa-sdk/templateBuilders.d.ts delete mode 100644 types/alexa-sdk/types.d.ts delete mode 100644 types/alexa-sdk/utils.d.ts diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts deleted file mode 100644 index c77bc93091..0000000000 --- a/types/alexa-sdk/alexa-sdk-tests.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as Alexa from "alexa-sdk"; - -const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { - const alexa = Alexa.handler(event, context); - alexa.resources = {}; - alexa.registerHandlers(handlers); - alexa.execute(); -}; - -const handlers: Alexa.Handlers = { - 'LaunchRequest': function() { - this.emit('SayHello'); - }, - 'HelloWorldIntent': function() { - this.emit('SayHello'); - }, - 'SayHello': function() { - this.emit(':tell', 'Hello World!'); - } -}; diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index bf64ff08df..744523b2ac 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -1,18 +1,870 @@ - -import { utils } from './utils'; -import { AlexaObject, Image, TextField, TextContent, RequestBody, Context } from './types'; -// Type definitions for Alexa SDK for Node.js 1.0 +// Type definitions for Alexa SDK for Node.js 1.0.21 // Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs // Definitions by: Pete Beegle // Huw // pascalwhoop // Ben +// rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - +// TypeScript Version: 2.7 +import { i18n } from "i18next"; export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; +export let StateString: string; +//#region Types +export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; +export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; + +export interface CardImage { + smallImageUrl: string; + largeImageUrl: string; +} +export interface Image { + smallImageUrl: string; + largeImageUrl: string; + contentDescription: string; + sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; +} +export type TextField = { + text: string, + type: string +}; +export type TextContent = { + primaryText: TextField, + secondaryText: TextField, + tertiaryText: TextField, +} +export type ListItem = { image: Image; token: string; textContent: TextContent; }; +export type Template = { + title: string; + token: string; + backgroundImage: Image; + backButton: string; + type: string; + image: Image; + listItems: ListItem[]; +}; + +export interface AlexaObject extends Handler { + _event: any; + _context: any; + _callback: any; + state: any; + appId: any; + response: any; + resources: any; + dynamoDBTableName: any; + saveBeforeResponse: boolean; + registerHandlers: (...handlers: Array>) => any; + execute: () => void; +} + +export interface Handlers { + [intent: string]: (this: Handler) => void; +} + +export interface Handler { + on: any; + emit(event: string, ...args: any[]): boolean; + emitWithState: any; + state: any; + handler: any; + i18n: i18n, + locale: any, + event: RequestBody; + attributes: any; + context: any; + callback: Function; + name: any; + isOverriden: any; + t: (token: string, ...args: any[]) => void; + response: ResponseBuilder; +} +export enum PLAYER_ACTIVITY { + IDLE = 'IDLE', + PAUSED = 'PAUSED', + PLAYING = 'PLAYING', + BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', + FINISHED = 'FINISHED', + STOPPED = 'STOPPED' +} +export interface Context { + System: System + AudioPlayer: AudioPlayer +} +export interface Application { + applicationId: string; + [key: string]: string; +} +export interface System { + apiAccessToken: string; + apiEndpoint: string; + application: Application; + device: any; + user: any; +} +export interface AudioPlayer { + token: string; + offsetInMilliseconds: number; + playerActivity: PLAYER_ACTIVITY; +} +export interface RequestBody { + version: string; + session: Session; + request: T; +} + +export interface Session { + new: boolean; + sessionId: string; + attributes: { [key: string]: any }; + application: Application; + user: SessionUser; +} + +export interface SessionUser { + userId: string; + accessToken?: string; + /** + * @deprecated + */ + permissions: Permissions; +} +export interface Permissions { + consentToken: string; + [key: string]: string; +} +export interface LaunchRequest extends Request { } + +export interface IntentRequest extends Request { + dialogState?: DialogStates; + intent?: Intent; +} + +export interface SessionEndedRequest extends Request { + reason?: string; +} + +export interface Request { + type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; + requestId: string; + timestamp: string; + locale?: string; +} + +export interface ResolutionStatus { + code: string; +} + +export interface ResolutionValue { + name: string; + id: string; +} + +export interface ResolutionValueContainer { + value: ResolutionValue; +} + +export interface Resolution { + authority: string; + status: ResolutionStatus; + values: ResolutionValueContainer[]; +} + +export interface Resolutions { + resolutionsPerAuthority: Resolution[]; +} + +export interface SlotValue { + confirmationStatus?: ConfirmationStatuses; + name: string; + value?: any; + resolutions?: Resolutions; +} + +export interface Intent { + confirmationStatus?: ConfirmationStatuses; + name: string; + slots: Record; +} + +export interface ResponseBody { + version: string; + sessionAttributes?: any; + response: Response; +} + +export interface Response { + outputSpeech?: OutputSpeech; + card?: Card; + reprompt?: Reprompt; + directives?: any; + shouldEndSession?: boolean; +} + +export interface OutputSpeech { + type: "PlainText" | "SSML"; + text?: string; + ssml?: string; +} + +export interface Card { + type: "Simple" | "Standard" | "LinkAccount"; + title?: string; + content?: string; + text?: string; + image?: Image; +} + +export interface Reprompt { + outputSpeech: OutputSpeech; +} +export declare const CARD_TYPES: { + STANDARD: 'Standard', + SIMPLE: 'Simple', + LINK_ACCOUNT: 'LinkAccount', + ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' +}; + +export declare const HINT_TYPES: { + PLAIN_TEXT: 'PlainText' +}; + +export declare const DIRECTIVE_TYPES: { + AUDIOPLAYER: { + PLAY: 'AudioPlayer.Play', + STOP: 'AudioPlayer.Stop', + CLEAR_QUEUE: 'AudioPlayer.ClearQueue' + }, + DISPLAY: { + RENDER_TEMPLATE: 'Display.RenderTemplate' + }, + HINT: 'Hint', + VIDEOAPP: { + LAUNCH: 'VideoApp.Launch' + } +}; +export interface ApiClientOptions { + hostname: string; + port: string; + path: string; + protocol: string; + headers: string; + method: string; +} +export interface ApiClientResponse { + statusCode: string; + statusText: string; + body: Object; + headers: Object +} +export interface ListItemObject { + value: string, + status: string, + version: any +} +export interface ListObject { + name: string, + status: string, + version: any +} +//#endregion +//#region templateBuilders + +export namespace templateBuilders { + export interface SetTextContent> { + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + export interface SetListItems> { + setListItems(listItems: ListItem[]): T; + } + export abstract class TemplateBuilder> { + public template: Template; + constructor(); + + /** + * Sets the title of the template + * + * @param {string} title + * @returns + * @memberof TemplateBuilder + */ + public setTitle(title: string): T; + + /** + * Sets the token of the template + * + * @param {string} token + * @returns + * @memberof TemplateBuilder + */ + public setToken(token: string): T; + + /** + * Sets the background image of the template + * + * @param {Image} image + * @returns + * @memberof TemplateBuilder + */ + public setBackgroundImage(image: Image): T; + + /** + * Sets the backButton behavior + * + * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @returns + * @memberof TemplateBuilder + */ + public setBackButtonBehavior(backButtonBehavior: string): T; + + /** + * Builds the template JSON object + * + * @returns + * @memberof TemplateBuilder + */ + public build(): Template; + // /** + // * Sets the text content for the template + // * + // * @param {TextField} primaryText + // * @param {TextField} secondaryText + // * @param {TextField} tertiaryText + // * @returns TemplateBuilder + // * @memberof TemplateBuilder + // */ + // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + } + /** + * Used to build a list of ListItems for ListTemplate + * + * @class ListItemBuilder + */ + export class ListItemBuilder { + constructor(); + public items: ListItem[]; + /** + * Add an item to the list of template + * + * @param {Image} image + * @param {string} token + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @memberof ListItemBuilder + */ + public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; + + public build(): ListItem[]; + } + /** + * Used to create BodyTemplate1 objects + * + * @class BodyTemplate1Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ + constructor(); + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate1Builder + * @memberof BodyTemplate1Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; + } + /** + * Used to create BodyTemplate2 objects + * + * @class BodyTemplate2Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {Image} image + * @returns + * @memberof BodyTemplate2Builder + */ + public setImage(image: Image): BodyTemplate2Builder + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate2Builder + * @memberof BodyTemplate2Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; + } + /** + * Used to create BodyTemplate3 objects + * + * @class BodyTemplate3Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate3Builder + */ + public setImage(image: any): BodyTemplate3Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate3Builder + * @memberof BodyTemplate3Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; + } + /** + * Used to create BodyTemplate6 objects + * + * @class BodyTemplate6Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { + constructor(); + + /** + * Sets the image for the template + * + * @param {any} image + * @returns + * @memberof BodyTemplate6Builder + */ + public setImage(image: any): BodyTemplate6Builder; + + /** + * Sets the text content for the template + * + * @param {TextField} primaryText + * @param {TextField} secondaryText + * @param {TextField} tertiaryText + * @returns BodyTemplate6Builder + * @memberof BodyTemplate6Builder + */ + public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; + } + /** + * Used to create BodyTemplate7 objects + * + * @class BodyTemplate7Builder + * @extends {TemplateBuilder} + */ + export class BodyTemplate7Builder extends TemplateBuilder { + constructor(); + + /** + * Sets the image for the template + * + * @param {Image} image + * @returns + * @memberof BodyTemplate7Builder + */ + setImage(image: Image): BodyTemplate7Builder + } + /** + * Used to create ListTemplate1 objects + * + * @class ListTemplate1Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate1Builder + */ + setListItems(listItems: ListItem[]): ListTemplate1Builder; + } + /** + * Used to create ListTemplate2 objects + * + * @class ListTemplate2Builder + * @extends {TemplateBuilder} + */ + export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { + constructor(); + + /** + * Set the items for the list + * + * @param {any} listItems + * @returns + * @memberof ListTemplate2Builder + */ + setListItems(listItems: ListItem[]): ListTemplate2Builder; + } + +} +//#endregion +//#region services +export namespace services { + export interface ApiClient { + /** + * Make a POST API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + post(uri: string, headers: Object, body?: string): Promise; + /** + * Make a PUT API call to the specified uri with headers and optional body + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers Key value pair of headers + * @param {string} body post body to send + * @returns {Promise} + * @memberof ApiClient + */ + put(uri: string, headers: Object, body?: string): Promise; + /** + * Make a GET API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + * @memberof ApiClient + */ + get(uri: string, headers: Object): Promise; + /** + * Make a DELETE API call to the specified uri with headers + * @param {string} uri http(s?) endpoint to call + * @param {Object} headers key value pair of headers + * @returns {Promise} + */ + delete(uri: string, headers: Object): Promise; + } + export class DeviceAddressService { + /** + * Create an instance of DeviceAddressService + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberOf DeviceAddressService + */ + constructor(apiClient: ApiClient); + + /** + * Get full address information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; + + /** + * Get country and postal information from Alexa Device Address API + * @param {string} deviceId deviceId from Alexa request + * @param {string} apiEndpoint API apiEndpoint from Alexa request + * @param {string} token bearer token for device address permission + * @returns {Promise} + * @memberOf DeviceAddressService + */ + getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; + } + export class DirectiveService { + + /** + * Creates an instance of DirectiveService. + * @param {ApiClient} [apiClient=new ApiClient()] ApiClient + * @memberof DirectiveService + */ + constructor(apiClient: ApiClient); + + /** + * Send the specified directiveObj to Alexa directive service + * + * @param {Object} directive directive to send to service + * @param {string} apiEndpoint API endpoint from Alexa request + * @param {string} token bearer token for directive service + * @returns {Promise} + * @memberof DirectiveService + */ + enqueue(directive: Object, apiEndpoint: string, token: string): Promise; + } + export class ListManagementService { + + /** + * Create an instance of ListManagementService + * @param apiClient + */ + constructor(apiClient: ApiClient); + + /** + * Set apiEndpoint address, default is 'https://api.amazonalexa.com' + * @param apiEndpoint + * @returns void + * @memberOf ListManagementService + */ + setApiEndpoint(apiEndpoint: string): void; + + /** + * Get currently set apiEndpoint address + * @returns {string} + * @memberOf ListManagementService + */ + getApiEndpoint(): string; + + /** + * Retrieve the metadata for all customer lists, including the customer's default lists + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListsMetadata(token: string): Promise; + + /** + * Create a custom list. The new list name must be different than any existing list name + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createList(listObject: ListObject, token: string): Promise + + /** + * Retrieve list metadata including the items in the list with requested status + * @param {string} listId unique Id associated with the list + * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getList(listId: string, itemStatus: string, token: string): Promise; + + /** + * Update a custom list. Only the list name or state can be updated + * @param {string} listId unique Id associated with the list + * @param {ListObject} listObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateList(listId: string, listObject: ListObject, token: string): Promise; + + /** + * Delete a custom list + * @param {string} listId unique Id associated with the list + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteList(listId: string, token: string): Promise; + + /** + * Create an item in an active list or in a default list + * @param {string} listId unique Id associated with the list + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Retrieve single item within any list by listId and itemId + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + getListItem(listId: string, itemId: string, token: string): Promise; + + /** + * Update an item value or item status + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {ListItemObject} listItemObject + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; + + /** + * Delete an item in the specified list + * @param {string} listId unique Id associated with the list + * @param {string} itemId unique Id associated with the item + * @param {string} token bearer token for list management permission + * @returns {Promise} + * @memberOf ListManagementService + */ + deleteListItem(listId: string, itemId: string, token: string): Promise; + } +} +//#endregion +//#region ResponseBuilder +/** + * Responsible for building JSON responses as per the Alexa skills kit interface + * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax + * + * @class ResponseBuilder + */ +export class ResponseBuilder { + constructor(alexaHandler: Handler); + + /** + * Have Alexa say the provided speechOutput to the user + * + * @param {string} speechOutput + * @returns + * @memberof ResponseBuilder + */ + speak(speechOutput: string): ResponseBuilder; + + /** + * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds + * then have alexa reprompt with the provided reprompt speech + * @param {string} repromptSpeech + * @returns + * @memberof ResponseBuilder + */ + listen(repromptSpeech: string): ResponseBuilder; + + /** + * Render a card with the following title, content and image + * + * @param {string} cardTitle + * @param {string} cardContent + * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage + * @returns + * @memberof ResponseBuilder + */ + cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; + + /** + * Render a link account card + * + * @returns + * @memberof ResponseBuilder + */ + linkAccountCard(): ResponseBuilder; + + /** + * Render a askForPermissionsConsent card + * @param {[{ [key: string]: string }]} permissions + * @returns + * @memberOf ResponseBuilder + */ + askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; + + /** + * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. + * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead + * @param {string} directiveType + * @param {string} behavior + * @param {string} url + * @param {string} token + * @param {string} expectedPreviousToken + * @param {number} offsetInMilliseconds + * @returns + * @memberof ResponseBuilder + */ + audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer play directive + * + * @param {string} behavior Describes playback behavior. Accepted values: + * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. + * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. + * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. + * @param {string} url Identifies the location of audio content at a remote HTTPS location. + * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the + * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. + * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. + * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters + * @param {string} expectedPreviousToken A token that represents the expected previous stream. + * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions + * if requests to progress through a playlist and change tracks occur at the same time. + * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. + * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream + * @returns + * @memberof ResponseBuilder + */ + audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; + + /** + * Creates an AudioPlayer Stop directive - Stops the current audio Playback + * + * @returns + * @memberof ResponseBuilder + */ + audioPlayerStop(): ResponseBuilder; + + /** + * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, + * or clear the queue and stop any currently playing stream. + * + * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: + * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream + * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). + * @returns + * @memberof ResponseBuilder + */ + audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; + + /** + * Creates a Display RenderTemplate Directive + * + * Use a template builder to generate a template object + * + * @param {Template} template + * @returns + * @memberof ResponseBuilder + */ + renderTemplate(template: Template): ResponseBuilder; + + /** + * Creates a hint directive - show a hint on the screen of the echo show + * + * @param {string} hintText text to show on the hint + * @param {string} hintType (optional) Default value : PlainText + * @returns + * @memberof ResponseBuilder + */ + hint(hintText: string, hintType: string): ResponseBuilder; + + /** + * Creates a VideoApp play directive to play a video + * + * @param {string} source Identifies the location of video content at a remote HTTPS location. + * The video file must be hosted at an Internet-accessible HTTPS endpoint. + * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the + * information that can be displayed on VideoApp. + * @returns + * @memberof ResponseBuilder + */ + playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; +} +//#endregion +//#region directives export namespace directives { export class VoicePlayerSpeakDirective { /** @@ -24,22 +876,100 @@ export namespace directives { constructor(requestId: string, speechContent: string); } } -//#region exports from other modules -export { templateBuilders } from "./templateBuilders"; +//#endregion +//#region utils +export namespace utils { + export class ImageUtils { + /** + * Creates an image object with a single source + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * + * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') + * + * @static + * @param {string} url url of the image + * @param {number} widthPixels (optional) width of the image in pixels + * @param {number} heightPixels (optional) height of the image in pixels + * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + /** + * + * Creates an image object with a multiple sources, source images are provided as an array of image objects + * + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * example : + * let imgArr = [ + * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, + * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * ] + * ImageUtils.makeImage(imgArr, 'image description') + * + * @static + * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr + * @param {string} description text used to describe the image in a screen reader + * @returns + * @memberof ImageUtils + */ + public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + } + /** + * Utility methods for building TextField objects + * + * @class TextUtils + */ + export class TextUtils { -export { services } from "./services"; + /** + * Creates a plain TextField object with contents : text + * + * @static + * @param {string} text contents of plain text object + * @returns + * @memberof TextUtils + */ + public static makePlainText(text: string): TextField; -export { - AlexaObject, Image, CardImage, TextField, - TextContent, RequestBody, Context, Handler, IntentRequest, - ListItem, Template, Handlers, Session, SessionApplication, - SessionUser, LaunchRequest, SessionEndedRequest, - Request, ResolutionStatus, ResolutionValue, - ResolutionValueContainer, Resolutions, SlotValue, - Intent, ResponseBody, Response, OutputSpeech, - Card, Reprompt, ConfirmationStatuses, DialogStates, - StateString + /** + * Creates a rich TextField object with contents : text + * + * @static + * @param {string} text + * @returns + * @memberof TextUtils + */ + public static makeRichText(text: string): TextField; -} from './types'; -export { utils } from './utils'; -//#endregion \ No newline at end of file + /** + * Creates a textContent + * + * @static + * @param {{type : string, text : string}} primaryText + * @param {{type : string, text : string}} secondaryText + * @param {{type : string, text : string}} tertiaryText + * @returns + * @memberof TextUtils + */ + public static makeTextContent(primaryText: { type: string, text: string }, + secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent + } +} +//#endregion diff --git a/types/alexa-sdk/responseBuilder.d.ts b/types/alexa-sdk/responseBuilder.d.ts deleted file mode 100644 index 83d32cf4f0..0000000000 --- a/types/alexa-sdk/responseBuilder.d.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { Handler, Request, Template, Image, CardImage } from './types'; -export declare const CARD_TYPES: { - STANDARD: 'Standard', - SIMPLE: 'Simple', - LINK_ACCOUNT: 'LinkAccount', - ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' -}; - -export declare const HINT_TYPES: { - PLAIN_TEXT: 'PlainText' -}; - -export declare const DIRECTIVE_TYPES: { - AUDIOPLAYER: { - PLAY: 'AudioPlayer.Play', - STOP: 'AudioPlayer.Stop', - CLEAR_QUEUE: 'AudioPlayer.ClearQueue' - }, - DISPLAY: { - RENDER_TEMPLATE: 'Display.RenderTemplate' - }, - HINT: 'Hint', - VIDEOAPP: { - LAUNCH: 'VideoApp.Launch' - } -}; - -/** - * Responsible for building JSON responses as per the Alexa skills kit interface - * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax - * - * @class ResponseBuilder - */ -export class ResponseBuilder { - constructor(alexaHandler: Handler); - - /** - * Have Alexa say the provided speechOutput to the user - * - * @param {string} speechOutput - * @returns - * @memberof ResponseBuilder - */ - speak(speechOutput: string): ResponseBuilder; - - /** - * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds - * then have alexa reprompt with the provided reprompt speech - * @param {string} repromptSpeech - * @returns - * @memberof ResponseBuilder - */ - listen(repromptSpeech: string): ResponseBuilder; - - /** - * Render a card with the following title, content and image - * - * @param {string} cardTitle - * @param {string} cardContent - * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage - * @returns - * @memberof ResponseBuilder - */ - cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; - - /** - * Render a link account card - * - * @returns - * @memberof ResponseBuilder - */ - linkAccountCard(): ResponseBuilder; - - /** - * Render a askForPermissionsConsent card - * @param {[{ [key: string]: string }]} permissions - * @returns - * @memberOf ResponseBuilder - */ - askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; - - /** - * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. - * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead - * @param {string} directiveType - * @param {string} behavior - * @param {string} url - * @param {string} token - * @param {string} expectedPreviousToken - * @param {number} offsetInMilliseconds - * @returns - * @memberof ResponseBuilder - */ - audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; - - /** - * Creates an AudioPlayer play directive - * - * @param {string} behavior Describes playback behavior. Accepted values: - * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. - * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. - * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. - * @param {string} url Identifies the location of audio content at a remote HTTPS location. - * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the - * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. - * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. - * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters - * @param {string} expectedPreviousToken A token that represents the expected previous stream. - * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions - * if requests to progress through a playlist and change tracks occur at the same time. - * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. - * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream - * @returns - * @memberof ResponseBuilder - */ - audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; - - /** - * Creates an AudioPlayer Stop directive - Stops the current audio Playback - * - * @returns - * @memberof ResponseBuilder - */ - audioPlayerStop(): ResponseBuilder; - - /** - * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, - * or clear the queue and stop any currently playing stream. - * - * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: - * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream - * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). - * @returns - * @memberof ResponseBuilder - */ - audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; - - /** - * Creates a Display RenderTemplate Directive - * - * Use a template builder to generate a template object - * - * @param {Template} template - * @returns - * @memberof ResponseBuilder - */ - renderTemplate(template: Template): ResponseBuilder; - - /** - * Creates a hint directive - show a hint on the screen of the echo show - * - * @param {string} hintText text to show on the hint - * @param {string} hintType (optional) Default value : PlainText - * @returns - * @memberof ResponseBuilder - */ - hint(hintText: string, hintType: string): ResponseBuilder; - - /** - * Creates a VideoApp play directive to play a video - * - * @param {string} source Identifies the location of video content at a remote HTTPS location. - * The video file must be hosted at an Internet-accessible HTTPS endpoint. - * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the - * information that can be displayed on VideoApp. - * @returns - * @memberof ResponseBuilder - */ - playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; -} \ No newline at end of file diff --git a/types/alexa-sdk/services.d.ts b/types/alexa-sdk/services.d.ts deleted file mode 100644 index 1498f17cbe..0000000000 --- a/types/alexa-sdk/services.d.ts +++ /dev/null @@ -1,199 +0,0 @@ -export namespace services { - export interface ApiClientOptions { hostname: string; port: string; path: string; protocol: string; headers: string; method: string } - export interface ApiClientResponse { statusCode: string; statusText: string; body: Object; headers: Object } - export interface ListItemObject { value: string, status: string, version: any } - export interface ListObject { name: string, status: string, version: any } - export interface ApiClient { - /** - * Make a POST API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient - */ - post(uri: string, headers: Object, body?: string): Promise; - /** - * Make a PUT API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient - */ - put(uri: string, headers: Object, body?: string): Promise; - /** - * Make a GET API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - * @memberof ApiClient - */ - get(uri: string, headers: Object): Promise; - /** - * Make a DELETE API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - */ - delete(uri: string, headers: Object): Promise; - } - export class DeviceAddressService { - /** - * Create an instance of DeviceAddressService - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberOf DeviceAddressService - */ - constructor(apiClient: ApiClient); - - /** - * Get full address information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService - */ - getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; - - /** - * Get country and postal information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService - */ - getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; - } - export class DirectiveService { - - /** - * Creates an instance of DirectiveService. - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberof DirectiveService - */ - constructor(apiClient: ApiClient); - - /** - * Send the specified directiveObj to Alexa directive service - * - * @param {Object} directive directive to send to service - * @param {string} apiEndpoint API endpoint from Alexa request - * @param {string} token bearer token for directive service - * @returns {Promise} - * @memberof DirectiveService - */ - enqueue(directive: Object, apiEndpoint: string, token: string): Promise; - } - export class ListManagementService { - - /** - * Create an instance of ListManagementService - * @param apiClient - */ - constructor(apiClient: ApiClient); - - /** - * Set apiEndpoint address, default is 'https://api.amazonalexa.com' - * @param apiEndpoint - * @returns void - * @memberOf ListManagementService - */ - setApiEndpoint(apiEndpoint: string): void; - - /** - * Get currently set apiEndpoint address - * @returns {string} - * @memberOf ListManagementService - */ - getApiEndpoint(): string; - - /** - * Retrieve the metadata for all customer lists, including the customer's default lists - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - getListsMetadata(token: string): Promise; - - /** - * Create a custom list. The new list name must be different than any existing list name - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - createList(listObject: ListObject, token: string): Promise - - /** - * Retrieve list metadata including the items in the list with requested status - * @param {string} listId unique Id associated with the list - * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - getList(listId: string, itemStatus: string, token: string): Promise; - - /** - * Update a custom list. Only the list name or state can be updated - * @param {string} listId unique Id associated with the list - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - updateList(listId: string, listObject: ListObject, token: string): Promise; - - /** - * Delete a custom list - * @param {string} listId unique Id associated with the list - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - deleteList(listId: string, token: string): Promise; - - /** - * Create an item in an active list or in a default list - * @param {string} listId unique Id associated with the list - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; - - /** - * Retrieve single item within any list by listId and itemId - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - getListItem(listId: string, itemId: string, token: string): Promise; - - /** - * Update an item value or item status - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; - - /** - * Delete an item in the specified list - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService - */ - deleteListItem(listId: string, itemId: string, token: string): Promise; - } -} \ No newline at end of file diff --git a/types/alexa-sdk/templateBuilders.d.ts b/types/alexa-sdk/templateBuilders.d.ts deleted file mode 100644 index 03834ca54a..0000000000 --- a/types/alexa-sdk/templateBuilders.d.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { Image, TextField, ListItem, Template } from './types'; -export namespace templateBuilders { - export interface SetTextContent> { - setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; - } - export interface SetListItems> { - setListItems(listItems: ListItem[]): T; - } - export abstract class TemplateBuilder> { - public template: Template; - constructor(); - - /** - * Sets the title of the template - * - * @param {string} title - * @returns - * @memberof TemplateBuilder - */ - public setTitle(title: string): T; - - /** - * Sets the token of the template - * - * @param {string} token - * @returns - * @memberof TemplateBuilder - */ - public setToken(token: string): T; - - /** - * Sets the background image of the template - * - * @param {Image} image - * @returns - * @memberof TemplateBuilder - */ - public setBackgroundImage(image: Image): T; - - /** - * Sets the backButton behavior - * - * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' - * @returns - * @memberof TemplateBuilder - */ - public setBackButtonBehavior(backButtonBehavior: string): T; - - /** - * Builds the template JSON object - * - * @returns - * @memberof TemplateBuilder - */ - public build(): Template; - // /** - // * Sets the text content for the template - // * - // * @param {TextField} primaryText - // * @param {TextField} secondaryText - // * @param {TextField} tertiaryText - // * @returns TemplateBuilder - // * @memberof TemplateBuilder - // */ - // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; - } - /** - * Used to build a list of ListItems for ListTemplate - * - * @class ListItemBuilder - */ - export class ListItemBuilder { - constructor(); - public items: ListItem[]; - /** - * Add an item to the list of template - * - * @param {Image} image - * @param {string} token - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @memberof ListItemBuilder - */ - public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; - - public build(): ListItem[]; - } - /** - * Used to create BodyTemplate1 objects - * - * @class BodyTemplate1Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ - constructor(); - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate1Builder - * @memberof BodyTemplate1Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; - } - /** - * Used to create BodyTemplate2 objects - * - * @class BodyTemplate2Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { - constructor(); - - /** - * Sets the image for the template - * - * @param {Image} image - * @returns - * @memberof BodyTemplate2Builder - */ - public setImage(image: Image): BodyTemplate2Builder - - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate2Builder - * @memberof BodyTemplate2Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; - } - /** - * Used to create BodyTemplate3 objects - * - * @class BodyTemplate3Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { - constructor(); - - /** - * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate3Builder - */ - public setImage(image: any): BodyTemplate3Builder; - - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate3Builder - * @memberof BodyTemplate3Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; - } - /** - * Used to create BodyTemplate6 objects - * - * @class BodyTemplate6Builder - * @extends {TemplateBuilder} - */ - export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { - constructor(); - - /** - * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate6Builder - */ - public setImage(image: any): BodyTemplate6Builder; - - /** - * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @returns BodyTemplate6Builder - * @memberof BodyTemplate6Builder - */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; - } - /** - * Used to create ListTemplate1 objects - * - * @class ListTemplate1Builder - * @extends {TemplateBuilder} - */ - export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { - constructor(); - - /** - * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate1Builder - */ - setListItems(listItems: ListItem[]): ListTemplate1Builder; - } - /** - * Used to create ListTemplate2 objects - * - * @class ListTemplate2Builder - * @extends {TemplateBuilder} - */ - export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { - constructor(); - - /** - * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate2Builder - */ - setListItems(listItems: ListItem[]): ListTemplate2Builder; - } - -} \ No newline at end of file diff --git a/types/alexa-sdk/tsconfig.json b/types/alexa-sdk/tsconfig.json index e5b9d60424..d1932fa469 100644 --- a/types/alexa-sdk/tsconfig.json +++ b/types/alexa-sdk/tsconfig.json @@ -19,10 +19,5 @@ "files": [ "index.d.ts", "alexa-sdk-tests.ts" - "responseBuilder.d.ts", - "services.d.ts", - "templateBuilders.d.ts", - "types.d.ts", - "utils.d.ts", ] } diff --git a/types/alexa-sdk/types.d.ts b/types/alexa-sdk/types.d.ts deleted file mode 100644 index 42daa46f60..0000000000 --- a/types/alexa-sdk/types.d.ts +++ /dev/null @@ -1,208 +0,0 @@ -import { i18n } from "../i18next"; -import { ResponseBuilder } from "./responseBuilder"; -export let StateString: string; - -export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; -export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; - -export interface CardImage { - smallImageUrl: string; - largeImageUrl: string; -} -export interface Image { - smallImageUrl: string; - largeImageUrl: string; - contentDescription: string; - sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; -} -export type TextField = { - text: string, - type: string -}; -export type TextContent = { - primaryText: TextField, - secondaryText: TextField, - tertiaryText: TextField, -} -export type ListItem = { image: Image; token: string; textContent: TextContent; }; -export type Template = { - title: string; - token: string; - backgroundImage: Image; - backButton: string; - type: string; - image: Image; - listItems: ListItem[]; -}; - -export interface AlexaObject extends Handler { - _event: any; - _context: any; - _callback: any; - state: any; - appId: any; - response: any; - resources: any; - dynamoDBTableName: any; - saveBeforeResponse: boolean; - registerHandlers: (...handlers: Array>) => any; - execute: () => void; -} - -export interface Handlers { - [intent: string]: (this: Handler) => void; -} - -export interface Handler { - on: any; - emit(event: string, ...args: any[]): boolean; - emitWithState: any; - state: any; - handler: any; - i18n: i18n, - locale: any, - event: RequestBody; - attributes: any; - context: any; - callback: Function; - name: any; - isOverriden: any; - t: (token: string, ...args: any[]) => void; - response: ResponseBuilder; -} -export enum PLAYER_ACTIVITY { - IDLE = 'IDLE', - PAUSED = 'PAUSED', - PLAYING = 'PLAYING', - BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', - FINISHED = 'FINISHED', - STOPPED = 'STOPPED' -} -export interface Context { - System: System - AudioPlayer: AudioPlayer -} -export interface System { - apiAccessToken: string; - apiEndpoint: string; - application: any; - device: any; - user: any; -} -export interface AudioPlayer { - token: string; - offsetInMilliseconds: number; - playerActivity: PLAYER_ACTIVITY; -} -export interface RequestBody { - version: string; - session: Session; - request: T; -} - -export interface Session { - new: boolean; - sessionId: string; - attributes: any; - application: SessionApplication; - user: SessionUser; -} - -export interface SessionApplication { - applicationId: string; -} - -export interface SessionUser { - userId: string; - accessToken?: string; - /** - * @deprecated - */ - permissions: any; -} - -export interface LaunchRequest extends Request { } - -export interface IntentRequest extends Request { - dialogState?: DialogStates; - intent?: Intent; -} - -export interface SessionEndedRequest extends Request { - reason?: string; -} - -export interface Request { - type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest"; - requestId: string; - timestamp: string; - locale?: string; -} - -export interface ResolutionStatus { - code: string; -} - -export interface ResolutionValue { - name: string; - id: string; -} - -export interface ResolutionValueContainer { - value: ResolutionValue; -} - -export interface Resolution { - authority: string; - status: ResolutionStatus; - values: ResolutionValueContainer[]; -} - -export interface Resolutions { - resolutionsPerAuthority: Resolution[]; -} - -export interface SlotValue { - confirmationStatus?: ConfirmationStatuses; - name: string; - value?: any; - resolutions?: Resolutions; -} - -export interface Intent { - confirmationStatus?: ConfirmationStatuses; - name: string; - slots: Record; -} - -export interface ResponseBody { - version: string; - sessionAttributes?: any; - response: Response; -} - -export interface Response { - outputSpeech?: OutputSpeech; - card?: Card; - reprompt?: Reprompt; - directives?: any; - shouldEndSession?: boolean; -} - -export interface OutputSpeech { - type: "PlainText" | "SSML"; - text?: string; - ssml?: string; -} - -export interface Card { - type: "Simple" | "Standard" | "LinkAccount"; - title?: string; - content?: string; - text?: string; - image?: Image; -} - -export interface Reprompt { - outputSpeech: OutputSpeech; -} \ No newline at end of file diff --git a/types/alexa-sdk/utils.d.ts b/types/alexa-sdk/utils.d.ts deleted file mode 100644 index 056a52530e..0000000000 --- a/types/alexa-sdk/utils.d.ts +++ /dev/null @@ -1,96 +0,0 @@ - -import { TextField, TextContent, Image } from "./types"; -export namespace utils { - export class ImageUtils { - /** - * Creates an image object with a single source - * - * These images may be in either JPEG or PNG formats, with the appropriate file extensions. - * An image cannot be larger than 2 MB - * You must host the images at HTTPS URLs that are publicly accessible. - * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, - * which means that larger images will be downscaled for display on Echo Show if provided. - * - * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') - * - * @static - * @param {string} url url of the image - * @param {number} widthPixels (optional) width of the image in pixels - * @param {number} heightPixels (optional) height of the image in pixels - * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils - */ - public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; - /** - * - * Creates an image object with a multiple sources, source images are provided as an array of image objects - * - * These images may be in either JPEG or PNG formats, with the appropriate file extensions. - * An image cannot be larger than 2 MB - * You must host the images at HTTPS URLs that are publicly accessible. - * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, - * which means that larger images will be downscaled for display on Echo Show if provided. - * example : - * let imgArr = [ - * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, - * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, - * ] - * ImageUtils.makeImage(imgArr, 'image description') - * - * @static - * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils - */ - public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; - } - /** - * Utility methods for building TextField objects - * - * @class TextUtils - */ - export class TextUtils { - - /** - * Creates a plain TextField object with contents : text - * - * @static - * @param {string} text contents of plain text object - * @returns - * @memberof TextUtils - */ - public static makePlainText(text: string): TextField; - - /** - * Creates a rich TextField object with contents : text - * - * @static - * @param {string} text - * @returns - * @memberof TextUtils - */ - public static makeRichText(text: string): TextField; - - /** - * Creates a textContent - * - * @static - * @param {{type : string, text : string}} primaryText - * @param {{type : string, text : string}} secondaryText - * @param {{type : string, text : string}} tertiaryText - * @returns - * @memberof TextUtils - */ - public static makeTextContent(primaryText: { type: string, text: string }, - secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent - } -} \ No newline at end of file From 5838284de2e44af57f6f7733b26fe59f8f8ca250 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 12:29:21 +0530 Subject: [PATCH 100/639] Reverted alexa-sdk-tests.ts --- types/alexa-sdk/alexa-sdk-tests.ts | 20 ++++++++++++++++++++ types/alexa-sdk/tslint.json | 19 ++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 types/alexa-sdk/alexa-sdk-tests.ts diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts new file mode 100644 index 0000000000..0c511979d4 --- /dev/null +++ b/types/alexa-sdk/alexa-sdk-tests.ts @@ -0,0 +1,20 @@ +import * as Alexa from "alexa-sdk"; + +const handler = (event: Alexa.RequestBody, context: Alexa.Context, callback: () => void) => { + const alexa = Alexa.handler(event, context); + alexa.resources = {}; + alexa.registerHandlers(handlers); + alexa.execute(); +}; + +const handlers: Alexa.Handlers = { + 'LaunchRequest': function () { + this.emit('SayHello'); + }, + 'HelloWorldIntent': function () { + this.emit('SayHello'); + }, + 'SayHello': function () { + this.emit(':tell', 'Hello World!'); + } +}; diff --git a/types/alexa-sdk/tslint.json b/types/alexa-sdk/tslint.json index 78f1939ba2..32a9916641 100644 --- a/types/alexa-sdk/tslint.json +++ b/types/alexa-sdk/tslint.json @@ -1,10 +1,11 @@ -{ "extends": "dtslint/dt.json", - "rules": { - "object-literal-shorthand": false, - "object-literal-key-quote": false, - "no-empty-interface": false, - "prefer-method-signature": false, - "object-literal-key-quotes": false, - "no-any": false - } +{ + "extends": "dtslint/dt.json", + "rules": { + "object-literal-shorthand": false, + "object-literal-key-quote": false, + "no-empty-interface": false, + "prefer-method-signature": false, + "object-literal-key-quotes": false, + "no-any": false + } } From f9702725c729deec03d7e571ff358b5124ab7886 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Thu, 23 Nov 2017 09:20:47 +0100 Subject: [PATCH 101/639] Fix CI check failures This makes the PR complies with CI build requirements --- types/auth0-js/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 02642f0934..faab2ac006 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Auth0.js 8.11.3 +// Type definitions for Auth0.js 8.11 // Project: https://github.com/auth0/auth0.js // Definitions by: Adrian Chia // Matt Durrant @@ -528,8 +528,6 @@ export interface Auth0Error { /** * The contents of the authResult object returned by {@link WebAuth#parseHash } - * @export - * @interface Auth0DecodedHash */ export interface Auth0DecodedHash { accessToken?: string; From 7c07552f854b63c28e773e79a7e4c43adc6a6622 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 12:16:06 +0100 Subject: [PATCH 102/639] remove some errors --- .../confirmdialog/{jquery-confirm.ts => confirmdialog-tests.ts} | 0 types/confirmdialog/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename types/confirmdialog/{jquery-confirm.ts => confirmdialog-tests.ts} (100%) diff --git a/types/confirmdialog/jquery-confirm.ts b/types/confirmdialog/confirmdialog-tests.ts similarity index 100% rename from types/confirmdialog/jquery-confirm.ts rename to types/confirmdialog/confirmdialog-tests.ts diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 6949afdda5..98bea3c511 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -16,6 +16,6 @@ }, "files": [ "index.d.ts", - "jquery_confirm.ts" + "confirmdialog-tests.ts" ] } From c0ec4daf141dd756afcc723a22a1f4065cd86a5d Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 12:28:10 +0100 Subject: [PATCH 103/639] remove some errors --- types/confirmdialog/confirmdialog-tests.ts | 2 -- types/confirmdialog/index.d.ts | 4 +-- types/confirmdialog/tsconfig.json | 4 +-- types/confirmdialog/tslint.json | 32 +--------------------- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index e75057f504..9f0fd9430d 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,5 +1,3 @@ -/// -/// namespace server { export interface Iperson { title: string, diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 7844857464..c22896c8c2 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jquery-confirm v3.3.0 https://craftpip.github.io/jquery-confirm/ +// Type definitions for confirmdialog v3.3.0 // Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js -// Definitions by: Alli Pierre Yotti https://github.com/allipierre +// Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface JQueryStatic { diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 98bea3c511..76f091224e 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -8,8 +8,8 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "types", - "typeRoots": ["types"], + "baseUrl": "../", + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 2f73ea817c..3db14f85ea 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,31 +1 @@ -{ - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] - } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } -} +{ "extends": "dtslint/dt.json" } From 26bb67e8d7db5735ca266ba4fb0ec7257a5c72b7 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 17:44:33 +0530 Subject: [PATCH 104/639] Fixed lint errors for alexa-sdk --- types/alexa-sdk/alexa-sdk-tests.ts | 6 +- types/alexa-sdk/index.d.ts | 821 ++++++++++++++--------------- 2 files changed, 394 insertions(+), 433 deletions(-) diff --git a/types/alexa-sdk/alexa-sdk-tests.ts b/types/alexa-sdk/alexa-sdk-tests.ts index 0c511979d4..c77bc93091 100644 --- a/types/alexa-sdk/alexa-sdk-tests.ts +++ b/types/alexa-sdk/alexa-sdk-tests.ts @@ -8,13 +8,13 @@ const handler = (event: Alexa.RequestBody, context: Alexa.Context }; const handlers: Alexa.Handlers = { - 'LaunchRequest': function () { + 'LaunchRequest': function() { this.emit('SayHello'); }, - 'HelloWorldIntent': function () { + 'HelloWorldIntent': function() { this.emit('SayHello'); }, - 'SayHello': function () { + 'SayHello': function() { this.emit(':tell', 'Hello World!'); } }; diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 744523b2ac..e4ea78c104 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Alexa SDK for Node.js 1.0.21 +// Type definitions for Alexa SDK for Node.js 1.0 // Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs // Definitions by: Pete Beegle // Huw @@ -6,45 +6,66 @@ // Ben // rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.7 +// TypeScript Version: 2.2 import { i18n } from "i18next"; export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; //#region Types -export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; -export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; - export interface CardImage { + /** + * Recommended size (in px): 720w x 480h + */ smallImageUrl: string; + /** + * Recommended size (in px): 1200w x 800h + */ largeImageUrl: string; } +export interface ImageSource { + url: string; + widthPixels?: number; + heightPixels?: number; + /** + * Possible values: 'X_SMALL' | 'SMALL' | 'MEDIUM' | 'LARGE' | 'X_LARGE' + * Recommended size respectively (in px): 480 x 320 | 720 x 480 | 960 x 640 | 1200 x 800 | 1920 x 1280 + */ + size?: string; +} export interface Image { - smallImageUrl: string; - largeImageUrl: string; contentDescription: string; - sources: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>; + sources: ImageSource[]; } -export type TextField = { - text: string, - type: string -}; -export type TextContent = { - primaryText: TextField, - secondaryText: TextField, - tertiaryText: TextField, -} -export type ListItem = { image: Image; token: string; textContent: TextContent; }; -export type Template = { - title: string; - token: string; - backgroundImage: Image; - backButton: string; +export interface TextField { + text: string; type: string; - image: Image; - listItems: ListItem[]; -}; +} +export interface TextContent { + primaryText?: TextField; + secondaryText?: TextField; + tertiaryText?: TextField; +} +export interface ListItem { + image?: Image; + token: string; + textContent?: TextContent; +} +export interface Template { + title?: string; + token: string; + backgroundImage?: Image; + /** + * Possible values 'HIDDEN' | 'VISIBLE' + */ + backButton?: string; + /** + * Possible values 'BodyTemplate1' | 'BodyTemplate2'| 'BodyTemplate3'| 'BodyTemplate6'| 'ListTemplate1'| 'ListTemplate2' + */ + type: string; + image?: Image; + listItems?: ListItem[]; +} export interface AlexaObject extends Handler { _event: any; @@ -70,28 +91,21 @@ export interface Handler { emitWithState: any; state: any; handler: any; - i18n: i18n, - locale: any, + i18n: i18n; + locale: any; event: RequestBody; attributes: any; context: any; - callback: Function; + callback: (param: any) => void; name: any; isOverriden: any; t: (token: string, ...args: any[]) => void; response: ResponseBuilder; } -export enum PLAYER_ACTIVITY { - IDLE = 'IDLE', - PAUSED = 'PAUSED', - PLAYING = 'PLAYING', - BUFFER_UNDERRUN = 'BUFFER_UNDERRUN', - FINISHED = 'FINISHED', - STOPPED = 'STOPPED' -} + export interface Context { - System: System - AudioPlayer: AudioPlayer + System: System; + AudioPlayer: AudioPlayer; } export interface Application { applicationId: string; @@ -107,7 +121,10 @@ export interface System { export interface AudioPlayer { token: string; offsetInMilliseconds: number; - playerActivity: PLAYER_ACTIVITY; + /** + * Possible values: 'IDLE'|'PAUSED'|'PLAYING'|'BUFFER_UNDERRUN'|'FINISHED'|'STOPPED' + */ + playerActivity: string; } export interface RequestBody { version: string; @@ -122,23 +139,25 @@ export interface Session { application: Application; user: SessionUser; } - export interface SessionUser { userId: string; accessToken?: string; - /** - * @deprecated - */ permissions: Permissions; } export interface Permissions { + /** + * @deprecated + */ consentToken: string; [key: string]: string; } export interface LaunchRequest extends Request { } export interface IntentRequest extends Request { - dialogState?: DialogStates; + /** + * Possible values: 'STARTED'| 'IN_PROGRESS'| 'COMPLETED' + */ + dialogState?: string; intent?: Intent; } @@ -177,14 +196,20 @@ export interface Resolutions { } export interface SlotValue { - confirmationStatus?: ConfirmationStatuses; + /** + * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' + */ + confirmationStatus?: string; name: string; value?: any; resolutions?: Resolutions; } export interface Intent { - confirmationStatus?: ConfirmationStatuses; + /** + * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' + */ + confirmationStatus?: string; name: string; slots: Record; } @@ -214,24 +239,24 @@ export interface Card { title?: string; content?: string; text?: string; - image?: Image; + image?: CardImage; } export interface Reprompt { outputSpeech: OutputSpeech; } -export declare const CARD_TYPES: { +export const CARD_TYPES: { STANDARD: 'Standard', SIMPLE: 'Simple', LINK_ACCOUNT: 'LinkAccount', ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' }; -export declare const HINT_TYPES: { +export const HINT_TYPES: { PLAIN_TEXT: 'PlainText' }; -export declare const DIRECTIVE_TYPES: { +export const DIRECTIVE_TYPES: { AUDIOPLAYER: { PLAY: 'AudioPlayer.Play', STOP: 'AudioPlayer.Stop', @@ -256,466 +281,448 @@ export interface ApiClientOptions { export interface ApiClientResponse { statusCode: string; statusText: string; - body: Object; - headers: Object + body: object; + headers: object; } +/** + * Todo-ListItem class + * Refer https://developer.amazon.com/docs/custom-skills/access-the-alexa-shopping-and-to-do-lists.html + */ export interface ListItemObject { - value: string, - status: string, - version: any + /** + * item id (String, limit 60 characters) + */ + id: string; + /** + * item value (String, limit is 256 characters) + */ + value: string; + /** + * item status + * Possible values: "active" or "completed" + */ + status?: string; + /** + * item version (Positive integer | string) + */ + version?: any; + /** + * created time (ISO 8601 time format with time zone) + */ + createdTime: Date; + /** + * updated time (ISO 8601 time format with time zone) + */ + updatedTime: Date; + /** + * URL to retrieve the item (String) + */ + href?: string; } +/** + * Todo-List class + * Refer https://developer.amazon.com/docs/custom-skills/access-the-alexa-shopping-and-to-do-lists.html + */ export interface ListObject { - name: string, - status: string, - version: any + /** + * list id (String) + */ + listId: string; + /** + * list name (String) + */ + name: string; + /** + * "active" or "archived" (Enum) + */ + state?: string; + /** + * Possibly status of the list (or state?) + * Fetched from commit eebba0d at https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/ + * File path: alexa-skills-kit-sdk-for-nodejs/lib/services/listManagementService.js + */ + status?: string; + /** + * list version (long | string) + */ + version?: any; + /** + * Urls to active and completed items + * href is lint to the items having certain status. + * The status can be "active" or "completed". + */ + statusMap: { href: string; status: string; }; + /** + * Items that belong to this list. + */ + items: ListItemObject[]; } //#endregion //#region templateBuilders +/** + * Generates templates for Echo Show device. + */ export namespace templateBuilders { - export interface SetTextContent> { + interface SetTextContent> { setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; } - export interface SetListItems> { + interface SetListItems> { setListItems(listItems: ListItem[]): T; } - export abstract class TemplateBuilder> { - public template: Template; + /** + * Refer https://developer.amazon.com/docs/custom-skills/display-interface-reference.html#image-sizes + */ + abstract class TemplateBuilder> { + template: Template; constructor(); /** * Sets the title of the template - * - * @param {string} title - * @returns - * @memberof TemplateBuilder + * @param title title + * @returns TemplateBuilder */ - public setTitle(title: string): T; + setTitle(title: string): T; /** * Sets the token of the template - * - * @param {string} token - * @returns - * @memberof TemplateBuilder + * @param token token + * @returns TemplateBuilder */ - public setToken(token: string): T; + setToken(token: string): T; /** * Sets the background image of the template - * - * @param {Image} image - * @returns - * @memberof TemplateBuilder + * @param image image + * @returns TemplateBuilder */ - public setBackgroundImage(image: Image): T; + setBackgroundImage(image: Image): T; /** * Sets the backButton behavior - * - * @param {string} backButtonBehavior 'VISIBLE' or 'HIDDEN' - * @returns - * @memberof TemplateBuilder + * @param backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @returns TemplateBuilder */ - public setBackButtonBehavior(backButtonBehavior: string): T; + setBackButtonBehavior(backButtonBehavior: string): T; /** * Builds the template JSON object - * - * @returns - * @memberof TemplateBuilder + * @returns Template */ - public build(): Template; - // /** - // * Sets the text content for the template - // * - // * @param {TextField} primaryText - // * @param {TextField} secondaryText - // * @param {TextField} tertiaryText - // * @returns TemplateBuilder - // * @memberof TemplateBuilder - // */ - // public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T; + build(): Template; } /** * Used to build a list of ListItems for ListTemplate - * - * @class ListItemBuilder */ - export class ListItemBuilder { + class ListItemBuilder { constructor(); - public items: ListItem[]; + items: ListItem[]; /** * Add an item to the list of template - * - * @param {Image} image - * @param {string} token - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText - * @memberof ListItemBuilder + * @param image image + * @param token token + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText */ - public addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; + addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder; - public build(): ListItem[]; + build(): ListItem[]; } /** * Used to create BodyTemplate1 objects - * - * @class BodyTemplate1Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent{ + class BodyTemplate1Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate1Builder - * @memberof BodyTemplate1Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder; } /** * Used to create BodyTemplate2 objects - * - * @class BodyTemplate2Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { + class BodyTemplate2Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the image for the template - * - * @param {Image} image - * @returns - * @memberof BodyTemplate2Builder + * @param image image + * @returns BodyTemplate2Builder */ - public setImage(image: Image): BodyTemplate2Builder + setImage(image: Image): BodyTemplate2Builder; /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate2Builder - * @memberof BodyTemplate2Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder; } /** * Used to create BodyTemplate3 objects - * - * @class BodyTemplate3Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { + class BodyTemplate3Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate3Builder + * @param image image + * @returns BodyTemplate3Builder */ - public setImage(image: any): BodyTemplate3Builder; + setImage(image: any): BodyTemplate3Builder; /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate3Builder - * @memberof BodyTemplate3Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder; } /** * Used to create BodyTemplate6 objects - * - * @class BodyTemplate6Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { + class BodyTemplate6Builder extends TemplateBuilder implements SetTextContent { constructor(); /** * Sets the image for the template - * - * @param {any} image - * @returns - * @memberof BodyTemplate6Builder + * @param image image + * @returns BodyTemplate6Builder */ - public setImage(image: any): BodyTemplate6Builder; + setImage(image: any): BodyTemplate6Builder; /** * Sets the text content for the template - * - * @param {TextField} primaryText - * @param {TextField} secondaryText - * @param {TextField} tertiaryText + * @param primaryText primaryText + * @param secondaryText secondaryText + * @param tertiaryText tertiaryText * @returns BodyTemplate6Builder - * @memberof BodyTemplate6Builder */ - public setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; + setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder; } /** * Used to create BodyTemplate7 objects - * - * @class BodyTemplate7Builder - * @extends {TemplateBuilder} */ - export class BodyTemplate7Builder extends TemplateBuilder { + class BodyTemplate7Builder extends TemplateBuilder { constructor(); /** * Sets the image for the template - * - * @param {Image} image - * @returns - * @memberof BodyTemplate7Builder + * @param image image + * @returns BodyTemplate7Builder */ - setImage(image: Image): BodyTemplate7Builder + setImage(image: Image): BodyTemplate7Builder; } /** * Used to create ListTemplate1 objects - * - * @class ListTemplate1Builder - * @extends {TemplateBuilder} */ - export class ListTemplate1Builder extends TemplateBuilder implements SetListItems { + class ListTemplate1Builder extends TemplateBuilder implements SetListItems { constructor(); /** * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate1Builder + * @param listItems listItems + * @returns ListTemplate1Builder */ setListItems(listItems: ListItem[]): ListTemplate1Builder; } /** * Used to create ListTemplate2 objects - * - * @class ListTemplate2Builder - * @extends {TemplateBuilder} */ - export class ListTemplate2Builder extends TemplateBuilder implements SetListItems { + class ListTemplate2Builder extends TemplateBuilder implements SetListItems { constructor(); /** * Set the items for the list - * - * @param {any} listItems - * @returns - * @memberof ListTemplate2Builder + * @param listItems listItems + * @returns ListTemplate2Builder */ setListItems(listItems: ListItem[]): ListTemplate2Builder; } - } //#endregion //#region services export namespace services { - export interface ApiClient { + interface ApiClient { /** * Make a POST API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient + * @param uri http(s?) endpoint to call + * @param headers Key value pair of headers + * @param body post body to send + * @returns Promise */ - post(uri: string, headers: Object, body?: string): Promise; + post(uri: string, headers: object, body?: string): Promise; /** * Make a PUT API call to the specified uri with headers and optional body - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers Key value pair of headers - * @param {string} body post body to send - * @returns {Promise} - * @memberof ApiClient + * @param uri http(s?) endpoint to call + * @param headers Key value pair of headers + * @param body post body to send + * @returns Promise */ - put(uri: string, headers: Object, body?: string): Promise; + put(uri: string, headers: object, body?: string): Promise; /** * Make a GET API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - * @memberof ApiClient + * @param uri http(s?) endpoint to call + * @param headers key value pair of headers + * @returns Promise */ - get(uri: string, headers: Object): Promise; + get(uri: string, headers: object): Promise; /** - * Make a DELETE API call to the specified uri with headers - * @param {string} uri http(s?) endpoint to call - * @param {Object} headers key value pair of headers - * @returns {Promise} - */ - delete(uri: string, headers: Object): Promise; + * Make a DELETE API call to the specified uri with headers + * @param uri http(s?) endpoint to call + * @param headers key value pair of headers + * @returns Promise + */ + delete(uri: string, headers: object): Promise; } - export class DeviceAddressService { + class DeviceAddressService { /** * Create an instance of DeviceAddressService - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberOf DeviceAddressService + * @param [apiClient=new ApiClient()] ApiClient */ constructor(apiClient: ApiClient); /** * Get full address information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService + * @param deviceId deviceId from Alexa request + * @param apiEndpoint API apiEndpoint from Alexa request + * @param token bearer token for device address permission + * @returns Promise */ - getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; + getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise; /** * Get country and postal information from Alexa Device Address API - * @param {string} deviceId deviceId from Alexa request - * @param {string} apiEndpoint API apiEndpoint from Alexa request - * @param {string} token bearer token for device address permission - * @returns {Promise} - * @memberOf DeviceAddressService + * @param deviceId deviceId from Alexa request + * @param apiEndpoint API apiEndpoint from Alexa request + * @param token bearer token for device address permission + * @returns Promise */ - getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; + getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise; } - export class DirectiveService { - + class DirectiveService { /** * Creates an instance of DirectiveService. - * @param {ApiClient} [apiClient=new ApiClient()] ApiClient - * @memberof DirectiveService + * @param [apiClient=new ApiClient()] ApiClient */ constructor(apiClient: ApiClient); /** * Send the specified directiveObj to Alexa directive service * - * @param {Object} directive directive to send to service - * @param {string} apiEndpoint API endpoint from Alexa request - * @param {string} token bearer token for directive service - * @returns {Promise} - * @memberof DirectiveService + * @param directive directive to send to service + * @param apiEndpoint API endpoint from Alexa request + * @param token bearer token for directive service + * @returns Promise */ - enqueue(directive: Object, apiEndpoint: string, token: string): Promise; + enqueue(directive: object, apiEndpoint: string, token: string): Promise; } - export class ListManagementService { - + class ListManagementService { /** * Create an instance of ListManagementService - * @param apiClient + * @param apiClient apiClient */ constructor(apiClient: ApiClient); /** * Set apiEndpoint address, default is 'https://api.amazonalexa.com' - * @param apiEndpoint + * @param apiEndpoint apiEndpoint * @returns void - * @memberOf ListManagementService */ setApiEndpoint(apiEndpoint: string): void; /** * Get currently set apiEndpoint address - * @returns {string} - * @memberOf ListManagementService + * @returns string */ getApiEndpoint(): string; /** * Retrieve the metadata for all customer lists, including the customer's default lists - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param token bearer token for list management permission + * @returns Promise */ - getListsMetadata(token: string): Promise; + getListsMetadata(token: string): Promise; /** * Create a custom list. The new list name must be different than any existing list name - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listObject listObject + * @param token bearer token for list management permission + * @returns Promise */ - createList(listObject: ListObject, token: string): Promise + createList(listObject: ListObject, token: string): Promise; /** * Retrieve list metadata including the items in the list with requested status - * @param {string} listId unique Id associated with the list - * @param {string} itemStatus itemsStatus can be either 'active' or 'completed' - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemStatus itemsStatus can be either 'active' or 'completed' + * @param token bearer token for list management permission + * @returns Promise */ - getList(listId: string, itemStatus: string, token: string): Promise; + getList(listId: string, itemStatus: string, token: string): Promise; /** * Update a custom list. Only the list name or state can be updated - * @param {string} listId unique Id associated with the list - * @param {ListObject} listObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param listObject listObject + * @param token bearer token for list management permission + * @returns Promise */ - updateList(listId: string, listObject: ListObject, token: string): Promise; + updateList(listId: string, listObject: ListObject, token: string): Promise; /** * Delete a custom list - * @param {string} listId unique Id associated with the list - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param token bearer token for list management permission + * @returns Promise */ - deleteList(listId: string, token: string): Promise; + deleteList(listId: string, token: string): Promise; /** * Create an item in an active list or in a default list - * @param {string} listId unique Id associated with the list - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param listItemObject listItemObject + * @param token bearer token for list management permission + * @returns Promise */ - createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; + createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise; /** * Retrieve single item within any list by listId and itemId - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemId unique Id associated with the item + * @param token bearer token for list management permission + * @returns Promise */ - getListItem(listId: string, itemId: string, token: string): Promise; + getListItem(listId: string, itemId: string, token: string): Promise; /** * Update an item value or item status - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {ListItemObject} listItemObject - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemId unique Id associated with the item + * @param listItemObject listItemObject + * @param token bearer token for list management permission + * @returns Promise */ - updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; + updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise; /** * Delete an item in the specified list - * @param {string} listId unique Id associated with the list - * @param {string} itemId unique Id associated with the item - * @param {string} token bearer token for list management permission - * @returns {Promise} - * @memberOf ListManagementService + * @param listId unique Id associated with the list + * @param itemId unique Id associated with the item + * @param token bearer token for list management permission + * @returns Promise */ - deleteListItem(listId: string, itemId: string, token: string): Promise; + deleteListItem(listId: string, itemId: string, token: string): Promise; } } //#endregion @@ -723,155 +730,132 @@ export namespace services { /** * Responsible for building JSON responses as per the Alexa skills kit interface * https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax - * - * @class ResponseBuilder */ export class ResponseBuilder { constructor(alexaHandler: Handler); /** * Have Alexa say the provided speechOutput to the user - * - * @param {string} speechOutput - * @returns - * @memberof ResponseBuilder + * @param speechOutput speechOutput + * @returns ResponseBuilder */ speak(speechOutput: string): ResponseBuilder; /** * Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds * then have alexa reprompt with the provided reprompt speech - * @param {string} repromptSpeech - * @returns - * @memberof ResponseBuilder + * @param repromptSpeech repromptSpeech + * @returns ResponseBuilder */ listen(repromptSpeech: string): ResponseBuilder; /** * Render a card with the following title, content and image - * - * @param {string} cardTitle - * @param {string} cardContent - * @param {{smallImageUrl : string, largeImageUrl : string}} cardImage - * @returns - * @memberof ResponseBuilder + * @param cardTitle cardTitle + * @param cardContent cardContent + * @param cardImage cardImage + * @returns ResponseBuilder */ cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder; /** * Render a link account card - * - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ linkAccountCard(): ResponseBuilder; /** * Render a askForPermissionsConsent card - * @param {[{ [key: string]: string }]} permissions - * @returns - * @memberOf ResponseBuilder + * @param permissions permissions + * @returns ResponseBuilder */ askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder; /** * Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in. * @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead - * @param {string} directiveType - * @param {string} behavior - * @param {string} url - * @param {string} token - * @param {string} expectedPreviousToken - * @param {number} offsetInMilliseconds - * @returns - * @memberof ResponseBuilder + * @param directiveType directiveType + * @param behavior behavior + * @param url url + * @param token token + * @param expectedPreviousToken expectedPreviousToken + * @param offsetInMilliseconds offsetInMilliseconds + * @returns ResponseBuilder */ audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; /** * Creates an AudioPlayer play directive - * - * @param {string} behavior Describes playback behavior. Accepted values: + * @param behavior Describes playback behavior. Accepted values: * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams. * ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream. * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream. - * @param {string} url Identifies the location of audio content at a remote HTTPS location. - * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the - * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. + * @param url Identifies the location of audio content at a remote HTTPS location. + * The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the + * files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used. * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps. - * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters - * @param {string} expectedPreviousToken A token that represents the expected previous stream. - * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions + * @param token A token that represents the audio stream. This token cannot exceed 1024 characters + * @param expectedPreviousToken A token that represents the expected previous stream. + * This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions * if requests to progress through a playlist and change tracks occur at the same time. - * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. + * @param offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback. * Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder; /** * Creates an AudioPlayer Stop directive - Stops the current audio Playback - * - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ audioPlayerStop(): ResponseBuilder; /** * Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream, * or clear the queue and stop any currently playing stream. - * - * @param {string} clearBehavior Describes the clear queue behavior. Accepted values: + * @param clearBehavior Describes the clear queue behavior. Accepted values: * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable). - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ audioPlayerClearQueue(clearBehavior: string): ResponseBuilder; /** * Creates a Display RenderTemplate Directive - * * Use a template builder to generate a template object - * - * @param {Template} template - * @returns - * @memberof ResponseBuilder + * @param template template + * @returns ResponseBuilder */ renderTemplate(template: Template): ResponseBuilder; /** * Creates a hint directive - show a hint on the screen of the echo show - * - * @param {string} hintText text to show on the hint - * @param {string} hintType (optional) Default value : PlainText - * @returns - * @memberof ResponseBuilder + * @param hintText text to show on the hint + * @param hintType (optional) Default value : PlainText + * @returns ResponseBuilder */ hint(hintText: string, hintType: string): ResponseBuilder; /** * Creates a VideoApp play directive to play a video - * - * @param {string} source Identifies the location of video content at a remote HTTPS location. + * @param source Identifies the location of video content at a remote HTTPS location. * The video file must be hosted at an Internet-accessible HTTPS endpoint. - * @param {{title : string, subtitle : string}} metadata (optional) Contains an object that provides the + * @param metadata (optional) Contains an object that provides the * information that can be displayed on VideoApp. - * @returns - * @memberof ResponseBuilder + * @returns ResponseBuilder */ playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; } //#endregion //#region directives export namespace directives { - export class VoicePlayerSpeakDirective { + class VoicePlayerSpeakDirective { + header: { requestId: string }; + directive: { type: string, speech: string }; /** * Creates an instance of VoicePlayerSpeakDirective. - * @param {string} requestId - requestId from which the call is originated from - * @param {string} speechContent - Contents of the speech directive either in plain text or SSML. - * @memberof DirectiveService + * @param requestId - requestId from which the call is originated from + * @param speechContent - Contents of the speech directive either in plain text or SSML. */ constructor(requestId: string, speechContent: string); } @@ -879,97 +863,74 @@ export namespace directives { //#endregion //#region utils export namespace utils { - export class ImageUtils { + namespace ImageUtils { /** * Creates an image object with a single source - * * These images may be in either JPEG or PNG formats, with the appropriate file extensions. * An image cannot be larger than 2 MB * You must host the images at HTTPS URLs that are publicly accessible. * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, * which means that larger images will be downscaled for display on Echo Show if provided. - * * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') - * - * @static - * @param {string} url url of the image - * @param {number} widthPixels (optional) width of the image in pixels - * @param {number} heightPixels (optional) height of the image in pixels - * @param {string} size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils + * @param url url of the image + * @param widthPixels (optional) width of the image in pixels + * @param heightPixels (optional) height of the image in pixels + * @param size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE) + * @param description text used to describe the image in a screen reader + * @returns Image */ - public static makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; /** - * - * Creates an image object with a multiple sources, source images are provided as an array of image objects - * - * These images may be in either JPEG or PNG formats, with the appropriate file extensions. - * An image cannot be larger than 2 MB - * You must host the images at HTTPS URLs that are publicly accessible. - * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. - * - * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, - * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, - * which means that larger images will be downscaled for display on Echo Show if provided. - * example : - * let imgArr = [ - * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, - * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, - * ] - * ImageUtils.makeImage(imgArr, 'image description') - * - * @static - * @param {{url : string, widthPixels : number, heightPixels : number, size : string}[]} imgArr - * @param {string} description text used to describe the image in a screen reader - * @returns - * @memberof ImageUtils - */ - public static makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + * Creates an image object with a multiple sources, source images are provided as an array of image objects + * These images may be in either JPEG or PNG formats, with the appropriate file extensions. + * An image cannot be larger than 2 MB + * You must host the images at HTTPS URLs that are publicly accessible. + * widthPixels and heightPixels are optional - Do not include them unless they are exactly correct. + * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, + * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, + * which means that larger images will be downscaled for display on Echo Show if provided. + * example : + * let imgArr = [ + * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, + * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * ] + * ImageUtils.makeImage(imgArr, 'image description') + * + * @param imgArr Array of Image + * @param description text used to describe the image in a screen reader + * @returns Image + */ + function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; } /** * Utility methods for building TextField objects - * - * @class TextUtils */ - export class TextUtils { - + namespace TextUtils { /** * Creates a plain TextField object with contents : text - * - * @static - * @param {string} text contents of plain text object - * @returns - * @memberof TextUtils + * @param text contents of plain text object + * @returns TextField */ - public static makePlainText(text: string): TextField; + function makePlainText(text: string): TextField; /** * Creates a rich TextField object with contents : text - * - * @static - * @param {string} text - * @returns - * @memberof TextUtils + * @param text text + * @returns TextField */ - public static makeRichText(text: string): TextField; + function makeRichText(text: string): TextField; /** * Creates a textContent - * - * @static - * @param {{type : string, text : string}} primaryText - * @param {{type : string, text : string}} secondaryText - * @param {{type : string, text : string}} tertiaryText - * @returns - * @memberof TextUtils + * @param primaryText primary Text + * @param secondaryText secondary Text + * @param tertiaryText tertiary Text + * @returns TextContent */ - public static makeTextContent(primaryText: { type: string, text: string }, - secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent + function makeTextContent(primaryText: { type: string, text: string }, + secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent; } } //#endregion From 79261ec1db0240e80d9699e1f8113d60bc49f102 Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Thu, 23 Nov 2017 17:57:01 +0530 Subject: [PATCH 105/639] Updated Typescript version to 2.3 for the dependency i18next. --- types/alexa-sdk/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index e4ea78c104..5f4f9cf6ff 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -6,7 +6,7 @@ // Ben // rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import { i18n } from "i18next"; export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; From 07de29ea090ab572e14efbfb6b7e4e98ae7bff20 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 14:21:18 +0100 Subject: [PATCH 106/639] remove some errors --- package.json | 3 +- types/concaveman/concaveman-tests.ts | 2 +- types/concaveman/index.d.ts | 4 +- types/confirmdialog/confirmdialog-tests.ts | 531 +-------------------- types/confirmdialog/index.d.ts | 2 + 5 files changed, 12 insertions(+), 530 deletions(-) diff --git a/package.json b/package.json index a9ddbdd977..bef061f5bf 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "types-publisher": "Microsoft/types-publisher#production" }, "dependencies": { - "@types/jquery": "^3.2.16" + "@types/jquery": "^3.2.16", + "jquery": "^3.2.1" } } diff --git a/types/concaveman/concaveman-tests.ts b/types/concaveman/concaveman-tests.ts index 736d616ad9..1d951b5448 100644 --- a/types/concaveman/concaveman-tests.ts +++ b/types/concaveman/concaveman-tests.ts @@ -1,4 +1,4 @@ import * as concaveman from 'concaveman'; var points = [[10, 20], [30, 12.5]]; -var polygon = concaveman(points); \ No newline at end of file +var polygon = concaveman(points); diff --git a/types/concaveman/index.d.ts b/types/concaveman/index.d.ts index a5b55c8fa3..4c10ca6928 100644 --- a/types/concaveman/index.d.ts +++ b/types/concaveman/index.d.ts @@ -6,7 +6,7 @@ declare module "concaveman" { /** * A very fast 2D concave hull algorithm in JavaScript (generates a general outline of a point set). - * + * * @name concaveman * @param {Array>} points is an array of [x, y] points. * @param {number} [concavity=2] is a relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes. @@ -15,7 +15,7 @@ declare module "concaveman" { * @example * var points = [[10, 20], [30, 12.5], ...]; * var polygon = concaveman(points); - * + * * //=hull */ function concaveman(points: number[][], concavity?: number, lengthThreshold?: number): number[][]; diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 9f0fd9430d..77812221af 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,3 +1,6 @@ +import * as $ from 'jquery'; + + namespace server { export interface Iperson { title: string, @@ -46,521 +49,7 @@ class Confirm implements server.Iperson { }); } - public confirm1() { - $.confirm({ - title: 'Prompt!', - content: '' + - '
' + - '
' + - '' + - '' + - '
' + - '
', - buttons: { - formSubmit: { - text: 'Submit', - btnClass: 'btn-blue', - action: function() { - let name = this.$content.find('.name').val(); - if (!name) { - $.alert('provide a valid name'); - return false; - } - $.alert('Your name is ' + name); - } - }, - cancel: function() { - //close - }, - }, - onContentReady: function() { - // bind to events - var jc = this; - this.$content.find('form').on('submit', function(e) { - // if the user submits the form by pressing enter in the field. - e.preventDefault(); - jc.$$formSubmit.trigger('click'); // reference the button and click it - }); - } - }); - } - - public dialog() { - $.dialog({ - title: 'Text content!', - content: 'Simple modal!' - }); - } - public confirm_2() { - $('.atwitter').val(); - $('.atwitter').text(); - $('a.twitter').confirm({ - content: "...", - }); - $('a.twitter').confirm({ - buttons: { - hey: function() { - location.href = this.$target.attr('href'); - } - } - }); - } - - public confirm_3() { - $.alert('Content here', 'Title here'); - $.confirm('A message', 'Title is optional'); - $.dialog('Just to let you know'); - } - - public confirm_4() { - var a = $.confirm({ - lazyOpen: true, - }); - a.open(); - a.close(); - a.toggle(); // toggle open close. - - } - - public confirm_5() { - $.confirm({ - buttons: { - hello: function(helloButton) { - // shorthand method to define a button - // the button key will be used as button name - }, - hey: function(heyButton) { - // access the button using jquery - this.$$hello.trigger('click'); // click the 'hello' button - this.$$hey.prop('disabled', true); // disable the current button using jquery method - - // jconfirm button methods, all methods listed here - this.buttons.hello.setText('Helloooo'); // setText for 'hello' button - this.buttons.hey.disable(); // disable with button function provided by jconfirm - this.buttons.hey.enable(); // enable with button function provided by jconfirm - // the button's instance is passed as the first argument, for quick access - heyButton === this.buttons.hey - }, - heyThere: { - text: 'Hey there!', // text for button - btnClass: 'btn-blue', // class for the button - keys: ['enter', 'a'], // keyboard event for button - isHidden: false, // initially not hidden - isDisabled: false, // initially not disabled - action: function(heyThereButton) { - // longhand method to define a button - // provides more features - } - }, - } - }); - - } - - public confirm_6() { - $.confirm({ - buttons: { - hey: function() { - // here the button key 'hey' will be used as the text. - $.alert('You clicked on "hey".'); - }, - heyThere: { - text: 'hey there!', // With spaces and symbols - action: function() { - $.alert('You clicked on "heyThere"'); - } - } - } - }); - } - - public confirm_7() { - $.confirm({ - content: 'Time to use your keyboard, press shift, alert, A or B', - buttons: { - specialKey: { - text: 'On behalf of shift', - keys: ['shift', 'alt'], - action: function() { - $.alert('Shift or Alt was pressed'); - } - }, - alphabet: { - text: 'A, B', - keys: ['a', 'b'], - action: function() { - $.alert('A or B was pressed'); - } - } - } - }); - } - - public confirm_8() { - $.confirm({ - closeIcon: true, // explicitly show the close icon - buttons: { - buttonA: { - text: 'button a', - action: function(buttonA) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. - return false; // prevent the modal from closing - } - }, - resetButton: function(resetButton) {} - } - }); - } - - - public confirm_9() { - $.confirm({ - title: 'Encountered an error!', - content: 'Something went downhill, this may be serious', - type: 'red', - typeAnimated: true, - buttons: { - tryAgain: { - text: 'Try again', - btnClass: 'btn-red', - action: function() {} - }, - close: function() {} - } - }); - } - - public confirm_10() { - $.confirm({ - icon: 'glyphicon glyphicon-heart', - title: 'glyphicon' - }); - $.confirm({ - icon: 'fa fa-warning', - title: 'font-awesome' - }); - $.confirm({ - icon: 'fa fa-spinner fa-spin', - title: 'Working!', - content: 'Sit back, we are processing your request!' - }); - } - - public confirm_11() { - $.confirm({ - closeIcon: true - }); - - $.confirm({ - closeIcon: true, - closeIconClass: 'fa fa-close' - }); - } - - public confirm_12() { - $.confirm({ - closeIcon: function() { - return false; - }, - buttons: { - aRandomButton: function() { - $.alert('A random button is called, and i prevent closing the modal'); - return false; // you shall not pass - }, - close: function() {} - } - }); - } - - public confirm_13() { - $.confirm({ - columnClass: 'small' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-4', - }); - $.confirm({ - columnClass: 'col-md-12' - }); - $.confirm({ - columnClass: 'col-md-4 col-md-offset-8 col-xs-4 col-xs-offset-8', - containerFluid: true, // this will add 'container-fluid' instead of 'container' - }); - } - - public confirm_14() { - $.confirm({ - boxWidth: '30%', - useBootstrap: false, - }); - $.confirm({ - boxWidth: '500px', - useBootstrap: false, - }); - } - - public confirm_15() { - $.confirm({ - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - }); - - $.confirm({ - title: 'Hello there', - content: 'click and hold on the title to drag', - draggable: true, - }); - - $.confirm({ - title: 'Hello there', - content: 'Drag this modal out of the window', - draggable: true, - dragWindowBorder: false, - }); - $.confirm({ - title: 'Hello there', - content: 'try to drag this modal out of the window', - draggable: true, - dragWindowGap: 0, // number of px of distance - }); - } - - public ajaxLoading() { - $.confirm({ - title: 'Title', - content: 'url:text.txt', - onContentReady: function() { - var self = this; - this.setContentPrepend('
Prepended text
'); - setTimeout(function() { - self.setContentAppend('
Appended text after 2 seconds
'); - }, 2000); - }, - columnClass: 'medium', - }); - - $.confirm({ - content: function() { - var self = this; - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContent('Description: ' + response.description); - self.setContentAppend('
Version: ' + response.version); - self.setTitle(response.name); - }).fail(function() { - self.setContent('Something went wrong.'); - }); - } - }); - - $.confirm({ - content: 'url:text.txt', - contentLoaded: function(data, status, xhr) { - // data is already set in content - this.setContentAppend('
Status: ' + status); - } - }); - - $.confirm({ - content: function() { - var self = this; - self.setContent('Checking callback flow'); - return $.ajax({ - url: 'bower.json', - dataType: 'json', - method: 'get' - }).done(function(response) { - self.setContentAppend('
Done!
'); - }).fail(function() { - self.setContentAppend('
Fail!
'); - }).always(function() { - self.setContentAppend('
Always!
'); - }); - }, - contentLoaded: function(data, status, xhr) { - self.setContentAppend('
Content loaded!
'); - }, - onContentReady: function() { - this.setContentAppend('
Content ready!
'); - } - }); - - } - - public autoClose() { - $.confirm({ - title: 'Delete user?', - content: 'This dialog will automatically trigger \'cancel\' in 6 seconds if you don\'t respond.', - autoClose: 'cancelAction|8000', - buttons: { - deleteUser: { - text: 'delete user', - action: function() { - $.alert('Deleted the user!'); - } - }, - cancelAction: function() { - $.alert('action is canceled'); - } - } - }); - $.confirm({ - title: 'Logout?', - content: 'Your time is out, you will be automatically logged out in 10 seconds.', - autoClose: 'logoutUser|10000', - buttons: { - logoutUser: { - text: 'logout myself', - action: function() { - $.alert('The user was logged out'); - } - }, - cancel: function() { - $.alert('canceled'); - } - } - }); - } - - public backgroundDismisse() { - $.confirm({ - backgroundDismiss: true, // this will just close the modal - }); - $.confirm({ - backgroundDismiss: function() { - return false; // modal wont close. - }, - }); - $.confirm({ - backgroundDismiss: function() { - return 'buttonName'; // the button will handle it - }, - }); - $.confirm({ - backgroundDismiss: 'buttonName', - content: 'in here the backgroundDismiss action is handled by buttonName' + - '
', - buttons: { - buttonName: function() { - var $checkbox = this.$content.find('#enableCheckbox'); - return $checkbox.prop('checked'); - }, - close: function() {} - } - }); - } - - public backgroundDismisseAnimation(){ - $.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', -}); -$.confirm({ - backgroundDismiss: false, - backgroundDismissAnimation: 'glow', -}); - } - - public escapeKey(){ - $.confirm({ - escapeKey: true, - backgroundDismiss: false, -}); -$.confirm({ - escapeKey: 'buttonName', - buttons: { - buttonName: function(){ - $.alert('Button name was called'); - }, - close: function(){ - } - } -}); - } - public rtlSupport(){ - $.alert({ - title: 'پیغام', - content: 'این یک متن به زبان شیرین فارسی است', - rtl: true, - closeIcon: true, - buttons: { - confirm: { - text: 'تایید', - btnClass: 'btn-blue', - action: function () { - $.alert('تایید شد.'); - } - }, - cancel: { - text: 'انصراف', - action: function () { - } - } - } -}); - - } - - public callBack(){ - $.confirm({ - title: false, - content: 'url:callback.html', - onContentReady: function () { - // when content is fetched & rendered in DOM - alert('onContentReady'); - var self = this; - this.buttons.ok.disable(); - this.$content.find('.btn').click(function(){ - self.$content.find('input').val('Chuck norris'); - self.buttons.ok.enable(); - }); - }, - contentLoaded: function(data, status, xhr){ - // when content is fetched - alert('contentLoaded: ' + status); - }, - onOpenBefore: function () { - // before the modal is displayed. - alert('onOpenBefore'); - }, - onOpen: function () { - // after the modal is displayed. - alert('onOpen'); - }, - onClose: function () { - // before the modal is hidden. - alert('onClose'); - }, - onDestroy: function () { - // when the modal is removed from DOM - alert('onDestroy'); - }, - onAction: function (btnName) { - // when a button is clicked, with the button name - alert('onAction: ' + btnName); - }, - buttons: { - ok: function(){ - } - } -}); - } public globalSettings(){ jconfirm.defaults = { title: 'Hello', @@ -584,8 +73,7 @@ $.confirm({ } }, }, - contentLoaded: function(data, status, xhr){ - }, + icon: '', lazyOpen: false, bgOpacity: null, @@ -642,16 +130,7 @@ $.confirm({ buttonA: { text: 'button a', action: function (buttonA: HTMLElement) { - this.buttons.resetButton.setText('reset button!!!'); - this.buttons.resetButton.disable(); - this.buttons.resetButton.enable(); - this.buttons.resetButton.hide(); - this.buttons.resetButton.show(); - this.buttons.resetButton.addClass('btn-red'); - this.buttons.resetButton.removeClass('btn-red'); - // or - this.$$resetButton // button's jquery element reference, go crazy - this.buttons.buttonA == buttonA // both are the same. + return false; // prevent the modal from closing } }, diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index c22896c8c2..ade096d977 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + interface JQueryStatic { /** * confirm Dialog @@ -21,6 +22,7 @@ interface JQueryStatic { * @param {any} pMessage */ dialog( pOtions: options.confirmOptions | string): void; + } From 3a84e4eed4b4dc2fa67fdbb131c068c09fc58fbc Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 15:40:52 +0100 Subject: [PATCH 107/639] remove some errors --- package.json | 6 ++-- types/confirmdialog/confirmdialog-tests.ts | 3 -- types/confirmdialog/index.d.ts | 8 ++++-- types/confirmdialog/tsconfig.json | 1 + types/confirmdialog/tslint.json | 32 +++++++++++++++++++++- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index bef061f5bf..246d0b9d61 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,12 @@ }, "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", - "types-publisher": "Microsoft/types-publisher#production" + "types-publisher": "Microsoft/types-publisher#production", + "typescript": "^2.6.1" }, "dependencies": { "@types/jquery": "^3.2.16", - "jquery": "^3.2.1" + "jquery": "^3.1.1", + "typescript": "^2.6.1" } } diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 77812221af..47ba509dc4 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,6 +1,3 @@ -import * as $ from 'jquery'; - - namespace server { export interface Iperson { title: string, diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index ade096d977..d20e0f8a27 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -3,13 +3,14 @@ // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// -interface JQueryStatic { + interface JQueryStatic { /** * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -26,7 +27,7 @@ interface JQueryStatic { } -interface JQuery { + interface JQuery { /** * confirm Dialog * @param {confirmOptions} pOtions @@ -52,6 +53,7 @@ interface Window { + declare namespace options { interface confirmOptions { diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 76f091224e..187a733dba 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": ["../"], "types": [], diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 3db14f85ea..2f73ea817c 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1 +1,31 @@ -{ "extends": "dtslint/dt.json" } +{ + "rules": { + "max-line-length": { + "options": [ + 120 + ] + }, + "new-parens": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": { + "options": [ + "debug", + "info", + "log", + "time", + "timeEnd", + "trace" + ] + } + }, + "jsRules": { + "max-line-length": { + "options": [ + 120 + ] + } + } +} From 4bdef7f72fcae62f3379075492a32a364fc36fa5 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 16:59:32 +0100 Subject: [PATCH 108/639] Remove interface confirmOptions --- package.json | 1 + types/concaveman/index.d.ts | 1 + types/confirmdialog/confirmdialog-tests.ts | 61 ------------ types/confirmdialog/index.d.ts | 81 +--------------- types/confirmdialog/tsconfig.json | 3 +- types/confirmdialog/tslint.json | 104 +++++++++++++++------ 6 files changed, 83 insertions(+), 168 deletions(-) diff --git a/package.json b/package.json index 246d0b9d61..61b734fec2 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { + "@types/node": "^8.0.53", "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "Microsoft/types-publisher#production", "typescript": "^2.6.1" diff --git a/types/concaveman/index.d.ts b/types/concaveman/index.d.ts index 4c10ca6928..ed5da84fc9 100644 --- a/types/concaveman/index.d.ts +++ b/types/concaveman/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare module "concaveman" { /** * A very fast 2D concave hull algorithm in JavaScript (generates a general outline of a point set). diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 47ba509dc4..e1008442e1 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -47,67 +47,6 @@ class Confirm implements server.Iperson { } - public globalSettings(){ - jconfirm.defaults = { - title: 'Hello', - titleClass: '', - type: 'default', - typeAnimated: true, - draggable: true, - dragWindowGap: 15, - dragWindowBorder: true, - animateFromElement: true, - smoothContent: true, - content: 'Are you sure to continue?', - buttons: {}, - defaultButtons: { - ok: { - action: function () { - } - }, - close: { - action: function () { - } - }, - }, - - icon: '', - lazyOpen: false, - bgOpacity: null, - theme: 'light', - animation: 'scale', - closeAnimation: 'scale', - animationSpeed: 400, - animationBounce: 1, - rtl: false, - container: 'body', - containerFluid: false, - backgroundDismiss: false, - backgroundDismissAnimation: 'shake', - autoClose: false, - closeIcon: null, - closeIconClass: false, - watchInterval: 100, - columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', - boxWidth: '50%', - scrollToPreviousElement: true, - scrollToPreviousElementAnimate: true, - useBootstrap: true, - offsetTop: 40, - offsetBottom: 40, - bootstrapClasses: { - container: 'container', - containerFluid: 'container-fluid', - row: 'row', - }, - onContentReady: function () {}, - onOpenBefore: function () {}, - onOpen: function () {}, - onClose: function () {}, - onDestroy: function () {}, - onAction: function () {} -}; - } public api(){ var jc = $.confirm({ diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index d20e0f8a27..0f6b49cb5a 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - +// TypeScript Version: 2.3 /// interface JQueryStatic { @@ -10,7 +10,7 @@ * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: any | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -22,81 +22,6 @@ * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: options.confirmOptions | string): void; - -} - - - interface JQuery { - /** - * confirm Dialog - * @param {confirmOptions} pOtions - */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; - - /** - * confirm alert - * @param {any} pMessage - */ - alert( pMessage?: any, title?:string): void; - - /** - * confirm Dialog - * @param {any} pMessage - */ - dialog( pOtions: options.confirmOptions | any): void; -} - -interface Window { - setContentAppend: any; -} - - - - -declare namespace options { - - interface confirmOptions { - buttons? : buttonOptionss | any, - title? : string | boolean, - content? : string | Function, - onContentReady?: Function, - lazyOpen?: boolean, - closeIcon?: boolean | Function, - type?: string, - typeAnimated?: boolean, - icon?: string, - closeIconClass?: string, - columnClass?: string, - containerFluid?: boolean, - boxWidth?: string, - useBootstrap?: boolean, - bootstrapClasses?: any, - draggable?: boolean, - dragWindowBorder?: boolean, - dragWindowGap?: number, - contentLoaded?: Function, - autoClose?: string, - backgroundDismiss?: boolean | Function | string, - backgroundDismissAnimation?: string, - escapeKey?: string | boolean, - onOpenBefore?:Function, - onOpen?: Function, - onClose?: Function, - onDestroy?: Function, - onAction?: Function - - - } - - interface buttonOptionss { - cancel?: Function, - confirm?: Function - } - -} - -declare namespace jconfirm { - let defaults: any; + dialog( pOtions: any | string): void; } diff --git a/types/confirmdialog/tsconfig.json b/types/confirmdialog/tsconfig.json index 187a733dba..95f33eb036 100644 --- a/types/confirmdialog/tsconfig.json +++ b/types/confirmdialog/tsconfig.json @@ -13,7 +13,8 @@ "typeRoots": ["../"], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "target": "es6" }, "files": [ "index.d.ts", diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index 2f73ea817c..a41bf5d19a 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,31 +1,79 @@ { - "rules": { - "max-line-length": { - "options": [ - 120 - ] - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": { - "options": [ - "debug", - "info", - "log", - "time", - "timeEnd", - "trace" - ] + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false } - }, - "jsRules": { - "max-line-length": { - "options": [ - 120 - ] - } - } } From 19f62c87dca1cd8ae5efd5b44a28dca41c06c2b2 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 17:08:10 +0100 Subject: [PATCH 109/639] perform some alert dialog --- types/confirmdialog/confirmdialog-tests.ts | 61 ++++++++++++++++++ types/confirmdialog/index.d.ts | 75 ++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index e1008442e1..47ba509dc4 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -47,6 +47,67 @@ class Confirm implements server.Iperson { } + public globalSettings(){ + jconfirm.defaults = { + title: 'Hello', + titleClass: '', + type: 'default', + typeAnimated: true, + draggable: true, + dragWindowGap: 15, + dragWindowBorder: true, + animateFromElement: true, + smoothContent: true, + content: 'Are you sure to continue?', + buttons: {}, + defaultButtons: { + ok: { + action: function () { + } + }, + close: { + action: function () { + } + }, + }, + + icon: '', + lazyOpen: false, + bgOpacity: null, + theme: 'light', + animation: 'scale', + closeAnimation: 'scale', + animationSpeed: 400, + animationBounce: 1, + rtl: false, + container: 'body', + containerFluid: false, + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + autoClose: false, + closeIcon: null, + closeIconClass: false, + watchInterval: 100, + columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1', + boxWidth: '50%', + scrollToPreviousElement: true, + scrollToPreviousElementAnimate: true, + useBootstrap: true, + offsetTop: 40, + offsetBottom: 40, + bootstrapClasses: { + container: 'container', + containerFluid: 'container-fluid', + row: 'row', + }, + onContentReady: function () {}, + onOpenBefore: function () {}, + onOpen: function () {}, + onClose: function () {}, + onDestroy: function () {}, + onAction: function () {} +}; + } public api(){ var jc = $.confirm({ diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 0f6b49cb5a..d8a025c8c8 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -25,3 +25,78 @@ dialog( pOtions: any | string): void; } + + + interface JQuery { + /** + * confirm Dialog + * @param {confirmOptions} pOtions + */ + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + + /** + * confirm alert + * @param {any} pMessage + */ + alert( pMessage?: any, title?:string): void; + + /** + * confirm Dialog + * @param {any} pMessage + */ + dialog( pOtions: options.confirmOptions | any): void; +} + +interface Window { + setContentAppend: any; +} + + + + +declare namespace options { + + interface confirmOptions { + buttons? : buttonOptionss | any, + title? : string | boolean, + content? : string | Function, + onContentReady?: Function, + lazyOpen?: boolean, + closeIcon?: boolean | Function, + type?: string, + typeAnimated?: boolean, + icon?: string, + closeIconClass?: string, + columnClass?: string, + containerFluid?: boolean, + boxWidth?: string, + useBootstrap?: boolean, + bootstrapClasses?: any, + draggable?: boolean, + dragWindowBorder?: boolean, + dragWindowGap?: number, + contentLoaded?: Function, + autoClose?: string, + backgroundDismiss?: boolean | Function | string, + backgroundDismissAnimation?: string, + escapeKey?: string | boolean, + onOpenBefore?:Function, + onOpen?: Function, + onClose?: Function, + onDestroy?: Function, + onAction?: Function + + + } + + interface buttonOptionss { + cancel?: Function, + confirm?: Function + } + +} + +declare namespace jconfirm { + let defaults: any; + +} From 0abd2e83e5c2a9ef371b2527e8091dc6821cf8b2 Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 17:12:52 +0100 Subject: [PATCH 110/639] add interface confirmOptions --- types/confirmdialog/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index d8a025c8c8..9be4d62489 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -10,7 +10,7 @@ * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: any | string, title?:string): boolean | void | HTMLElement | any; + confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; /** * confirm alert @@ -22,7 +22,7 @@ * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: any | string): void; + dialog( pOtions: options.confirmOptions | string): void; } From 7dca1f3ac764c88f235c61d3270622bcab2869b6 Mon Sep 17 00:00:00 2001 From: Alex Lyman Date: Thu, 23 Nov 2017 12:09:01 -0800 Subject: [PATCH 111/639] Add type definitions for the loadware package --- types/loadware/index.d.ts | 16 ++++++++++++++++ types/loadware/loadware-tests.ts | 20 ++++++++++++++++++++ types/loadware/tsconfig.json | 23 +++++++++++++++++++++++ types/loadware/tslint.json | 1 + 4 files changed, 60 insertions(+) create mode 100644 types/loadware/index.d.ts create mode 100644 types/loadware/loadware-tests.ts create mode 100644 types/loadware/tsconfig.json create mode 100644 types/loadware/tslint.json diff --git a/types/loadware/index.d.ts b/types/loadware/index.d.ts new file mode 100644 index 0000000000..dc3f13437c --- /dev/null +++ b/types/loadware/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for loadware 2.0.0 +// Project: https://github.com/franciscop/loadware +// Definitions by: A.J.J. Lyman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// tslint:disable-next-line:ban-types +type AnyFunction = Function; + +declare function loadware(...loadable: Array>): ReadonlyArray; + +declare namespace loadware { + type Loadable = string | F | RecursiveLoadable; + interface RecursiveLoadable extends Array> { } +} + +export = loadware; diff --git a/types/loadware/loadware-tests.ts b/types/loadware/loadware-tests.ts new file mode 100644 index 0000000000..630d3fd351 --- /dev/null +++ b/types/loadware/loadware-tests.ts @@ -0,0 +1,20 @@ +import loadware = require("loadware"); + +interface Context { __ContextMarker: never; } +interface Response { __ResponseMarker: never; } +type Middleware = (ctx: Context) => void; + +loadware( + (_: Context) => {}, + [ + (_: Context) => {}, + 'loadware/requires-strings' + ], + [ + [ + [ + (_: Context) => {} + ] + ] + ] +); diff --git a/types/loadware/tsconfig.json b/types/loadware/tsconfig.json new file mode 100644 index 0000000000..5921615bf8 --- /dev/null +++ b/types/loadware/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "loadware-tests.ts" + ] +} \ No newline at end of file diff --git a/types/loadware/tslint.json b/types/loadware/tslint.json new file mode 100644 index 0000000000..c17ac4dd6d --- /dev/null +++ b/types/loadware/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dtslint.json" } From e3e6a085dbc7c2d15e9e3c988c0241dd7038a12f Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Thu, 23 Nov 2017 22:32:12 +0100 Subject: [PATCH 112/639] Update auth0-js RenewAuthOptions This commit adds: - documentation for existing interface options - missing options from current v.8 of Auth0 for RenewAuthOptions The documentation and missing fields are based on existing Auth0 documentation here: - https://git.io/vFxy3 - https://github.com/auth0/auth0.js/pull/572 Thanks! --- types/auth0-js/auth0-js-tests.ts | 4 ++- types/auth0-js/index.d.ts | 57 +++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index 06d428de20..d425cca21a 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -109,7 +109,9 @@ webAuth.renewAuth({}, (err, authResult) => {}); webAuth.renewAuth({ nonce: '123', state: '456', - postMessageDataType: 'auth0:silent-authentication' + postMessageDataType: 'auth0:silent-authentication', + usePostMessage: true, + timeout: 30 * 1000 }, (err, authResult) => { // Renewed tokens or error }); diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 76a2c5f319..b47898d871 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -667,17 +667,72 @@ export interface ParseHashOptions { } export interface RenewAuthOptions { + /** + * your Auth0 domain + */ domain?: string; + /** + * your Auth0 client identifier obtained when creating the client in the Auth0 Dashboard + */ clientID?: string; + /** + * url that the Auth0 will redirect after Auth with the Authorization Response + */ redirectUri?: string; + /** + * type of the response used by OAuth 2.0 flow. It can be any space separated + * list of the values `code`, `token`, `id_token`. + * {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0} + */ responseType?: string; + /** + * how the Auth response is encoded and redirected back to the client. + * Supported values are `query`, `fragment` and `form_post`. + * The `query` value is only supported when `responseType` is `code`. + * {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes} + */ responseMode?: string; + /** + * value used to mitigate XSRF attacks. + * {@link https://auth0.com/docs/protocols/oauth2/oauth-state} + */ state?: string; + /** + * value used to mitigate replay attacks when using Implicit Grant. + * {@link https://auth0.com/docs/api-auth/tutorials/nonce} + */ nonce?: string; + /** + * scopes to be requested during Auth. e.g. `openid email` + */ scope?: string; + /** + * identifier of the resource server who will consume the access token issued after Auth + */ audience?: string; - usePostMessage?: boolean; + /** + * identifier data type to look for in postMessage event data, where events are initiated + * from silent callback urls, before accepting a message event is the event expected. + * A value of false means any postMessage event will trigger a callback. + */ postMessageDataType?: string; + /** + * origin of redirectUri to expect postMessage response from. + * Defaults to the origin of the receiving window. Only used if usePostMessage is truthy. + */ + postMessageOrigin?: string; + /** + * value in milliseconds used to timeout when the `/authorize` call is failing + * as part of the silent authentication with postmessage enabled due to a configuration. + */ + timeout?: number; + /** + * use postMessage to comunicate between the silent callback and the SPA. + * When false the SDK will attempt to parse the url hash should ignore the url hash + * and no extra behaviour is needed + * @default false + */ + usePostMessage?: boolean; } export interface AuthorizeOptions { From 8981174bc5ba89a4f36f774e6add0b527e43bc82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Thu, 23 Nov 2017 23:11:08 +0100 Subject: [PATCH 113/639] leaflet.heat TypeScript type definitions --- leaflet.heat/leaflet.heat-tests.ts | 38 ++++++++++++++++++++++++++++++ leaflet.heat/leaflet.heat.d.ts | 32 +++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 leaflet.heat/leaflet.heat-tests.ts create mode 100644 leaflet.heat/leaflet.heat.d.ts diff --git a/leaflet.heat/leaflet.heat-tests.ts b/leaflet.heat/leaflet.heat-tests.ts new file mode 100644 index 0000000000..2d5f86edfe --- /dev/null +++ b/leaflet.heat/leaflet.heat-tests.ts @@ -0,0 +1,38 @@ +/// +/// + +var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + osmAttrib = '© OpenStreetMap contributors', + osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), + map = new L.Map('map', { + layers: [osm], + center: new L.LatLng(50.5, 30.5), + zoom: 15, + }); + +// Each point in the input array can be either an array like [50.5, 30.5, 0.5], or a Leaflet LatLng object. +var heat: L.HeatLayer = L.heatLayer([ + [50.5, 30.5, 0.2], // lat, lng, intensity + [50.6, 30.4, 0.5], + new L.LatLng(50.7, 30.3), +], {radius: 25}).addTo(map); + +// Set options on the heat layer +heat.setOptions({ + minOpacity: 0.05, + maxZoom: 18, + max: 1.0, + radius: 25, + blur: 15, + gradient: {0.4: 'blue', 0.65: 'lime', 1: 'red'}, +}); + +// Add new point to heat layer +var newLatLng = new L.LatLng(50.8, 30.2); +heat.addLatLng(newLatLng); + +// Set new latLng list to the heat layer +heat.setLatLngs([newLatLng, newLatLng, newLatLng, [50.6, 30.4, 0.5],]); + +// Redraw the heat layer +heat.redraw(); diff --git a/leaflet.heat/leaflet.heat.d.ts b/leaflet.heat/leaflet.heat.d.ts new file mode 100644 index 0000000000..4d80fb3fb4 --- /dev/null +++ b/leaflet.heat/leaflet.heat.d.ts @@ -0,0 +1,32 @@ +// Type definitions for Leaflet.heat v0.2.0 +// Project: https://github.com/Leaflet/Leaflet.heat +// Definitions by: Önder Ceylan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace L { + type HeatLatLngTuple = [number, number, number]; + + interface ColorGradientConfig { + [key: number]: string; + } + + interface HeatMapOptions { + minOpacity?: number; + maxZoom?: number; + max?: number; + radius?: number; + blur?: number; + gradient?: ColorGradientConfig; + } + + interface HeatLayer extends TileLayer { + setOptions?(options: HeatMapOptions): HeatLayer; + addLatLng?(latlng: LatLng | HeatLatLngTuple): HeatLayer; + setLatLngs?(latlngs: Array): HeatLayer; + redraw(): HeatLayer; + } + + function heatLayer(latlngs: Array, options: HeatMapOptions): HeatLayer; +} From 851c45d5bb2debd39343bb020699972e4f45cc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Thu, 23 Nov 2017 23:20:59 +0100 Subject: [PATCH 114/639] Removed redraw() extension --- leaflet.heat/leaflet.heat.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/leaflet.heat/leaflet.heat.d.ts b/leaflet.heat/leaflet.heat.d.ts index 4d80fb3fb4..0fdc113ee9 100644 --- a/leaflet.heat/leaflet.heat.d.ts +++ b/leaflet.heat/leaflet.heat.d.ts @@ -25,7 +25,6 @@ declare namespace L { setOptions?(options: HeatMapOptions): HeatLayer; addLatLng?(latlng: LatLng | HeatLatLngTuple): HeatLayer; setLatLngs?(latlngs: Array): HeatLayer; - redraw(): HeatLayer; } function heatLayer(latlngs: Array, options: HeatMapOptions): HeatLayer; From 15e10d681ca534c7764e88995874664dbec4104d Mon Sep 17 00:00:00 2001 From: allipierre Date: Thu, 23 Nov 2017 23:46:11 +0100 Subject: [PATCH 115/639] Added type definitions for jquery-notifier --- types/jquery-notifier/index.d.ts | 0 types/jquery-notifier/jquery-notifier-tests.ts | 0 types/jquery-notifier/jquery-notifier.d.ts | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 types/jquery-notifier/index.d.ts create mode 100644 types/jquery-notifier/jquery-notifier-tests.ts create mode 100644 types/jquery-notifier/jquery-notifier.d.ts diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/jquery-notifier/jquery-notifier-tests.ts b/types/jquery-notifier/jquery-notifier-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/jquery-notifier/jquery-notifier.d.ts b/types/jquery-notifier/jquery-notifier.d.ts new file mode 100644 index 0000000000..e69de29bb2 From ea879349f0e056cb668caee1b0ce6c7b6e95f96e Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 00:12:54 +0100 Subject: [PATCH 116/639] Added type definitions for juery-notifier --- types/jquery-notifier/index.d.ts | 19 +++++ .../jquery-notifier/jquery-notifier-tests.ts | 36 +++++++++ types/jquery-notifier/jquery-notifier.d.ts | 0 types/jquery-notifier/tsconfig.json | 24 ++++++ types/jquery-notifier/tslint.json | 79 +++++++++++++++++++ 5 files changed, 158 insertions(+) delete mode 100644 types/jquery-notifier/jquery-notifier.d.ts create mode 100644 types/jquery-notifier/tsconfig.json create mode 100644 types/jquery-notifier/tslint.json diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index e69de29bb2..d67901b056 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for Notifier +// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Definitions by: Alli Pierre Yotti +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare namespace notifier { + /** + * notifier.show(title, msg, type, icon, timeout); + * @param {title} title + * @param {msg} msg + * @param {type} type + * @param {icon} icon + * @param {timeout} timeout + */ + function show(title: string, msg: string, type: string, icon: string, timeout?: number): string | number; + function hide(notificationId: string | number): boolean; + +} diff --git a/types/jquery-notifier/jquery-notifier-tests.ts b/types/jquery-notifier/jquery-notifier-tests.ts index e69de29bb2..9d73bce3c5 100644 --- a/types/jquery-notifier/jquery-notifier-tests.ts +++ b/types/jquery-notifier/jquery-notifier-tests.ts @@ -0,0 +1,36 @@ +notifier.show('Hello!', 'I am a default notification.', '', '', 0); +notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', '', 0); +notifier.show('Well Done!', 'You just submit your resume successfuly.', '', '', 0); +notifier.show('Warning!', 'The data presented here can be change.', '', '', 0); +notifier.show('Sorry!', 'Could not complete your transaction.', '', '', 0); + + +notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 0); +notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 0); +notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 0); +notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 0); +notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 0); + + + +notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 4000); +notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); +notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 4000); +notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 4000); +notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 4000); + + + + + var notificationId:string | number; + + var showNotification = function () { + notificationId = notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); + }; + + var hideNotification = function () { + notifier.hide(notificationId); + }; + + document.querySelector('#btn-nt-show').addEventListener('click', showNotification); + document.querySelector('#btn-nt-hide').addEventListener('click', hideNotification); diff --git a/types/jquery-notifier/jquery-notifier.d.ts b/types/jquery-notifier/jquery-notifier.d.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/types/jquery-notifier/tsconfig.json b/types/jquery-notifier/tsconfig.json new file mode 100644 index 0000000000..b2178bf718 --- /dev/null +++ b/types/jquery-notifier/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery-notifier-tests.ts" + ] +} diff --git a/types/jquery-notifier/tslint.json b/types/jquery-notifier/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/jquery-notifier/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From 9d13bdab54ff3164c1e2243bf80658c54ffb68fd Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 00:19:43 +0100 Subject: [PATCH 117/639] Add types definition for jquery-notifier --- types/jquery-notifier/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index d67901b056..4c733ce0df 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for Notifier -// Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js +// Project: https://github.com/allipierre/jquery-notifier // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 54ecabbe5e978c07ab8bc37afb623394d68186ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Fri, 24 Nov 2017 01:06:30 +0100 Subject: [PATCH 118/639] Restructured the files and added missing json configurations --- .../{leaflet.heat.d.ts => index.d.ts} | 0 leaflet.heat/leaflet.heat-tests.ts | 9 ++++--- leaflet.heat/tsconfig.json | 24 +++++++++++++++++++ leaflet.heat/tslint.json | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) rename leaflet.heat/{leaflet.heat.d.ts => index.d.ts} (100%) create mode 100644 leaflet.heat/tsconfig.json create mode 100644 leaflet.heat/tslint.json diff --git a/leaflet.heat/leaflet.heat.d.ts b/leaflet.heat/index.d.ts similarity index 100% rename from leaflet.heat/leaflet.heat.d.ts rename to leaflet.heat/index.d.ts diff --git a/leaflet.heat/leaflet.heat-tests.ts b/leaflet.heat/leaflet.heat-tests.ts index 2d5f86edfe..7007bf0227 100644 --- a/leaflet.heat/leaflet.heat-tests.ts +++ b/leaflet.heat/leaflet.heat-tests.ts @@ -1,7 +1,6 @@ /// -/// - -var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', +/// +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmAttrib = '© OpenStreetMap contributors', osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), map = new L.Map('map', { @@ -11,7 +10,7 @@ var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', }); // Each point in the input array can be either an array like [50.5, 30.5, 0.5], or a Leaflet LatLng object. -var heat: L.HeatLayer = L.heatLayer([ +const heat: L.HeatLayer = L.heatLayer([ [50.5, 30.5, 0.2], // lat, lng, intensity [50.6, 30.4, 0.5], new L.LatLng(50.7, 30.3), @@ -28,7 +27,7 @@ heat.setOptions({ }); // Add new point to heat layer -var newLatLng = new L.LatLng(50.8, 30.2); +const newLatLng = new L.LatLng(50.8, 30.2); heat.addLatLng(newLatLng); // Set new latLng list to the heat layer diff --git a/leaflet.heat/tsconfig.json b/leaflet.heat/tsconfig.json new file mode 100644 index 0000000000..482c984b8c --- /dev/null +++ b/leaflet.heat/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "leaflet.heat-tests.ts" + ] +} diff --git a/leaflet.heat/tslint.json b/leaflet.heat/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/leaflet.heat/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 85ed772c92df82221ac132a0e9d33c561c31c184 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:44:54 +0900 Subject: [PATCH 119/639] Cleanup unnecessary rule invalidation setting --- types/ejs/tslint.json | 67 +------------------------------------------ 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index a41bf5d19a..95db3aea31 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -1,79 +1,14 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "unified-signatures": false } } From 326da556b0920c36bc290bb32bf5cf4acfc0d183 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:49:25 +0900 Subject: [PATCH 120/639] Cleanup lint ignore error: dt-header --- types/ejs/index.d.ts | 4 ++-- types/ejs/tslint.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index a5bfb23ee9..8eae387b06 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for ejs.js v2.3.3 +// Type definitions for ejs.js 2.3 // Project: http://ejs.co/ -// Definitions by: Ben Liddicott +// Definitions by: Ben Liddicott // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Ejs { diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index 95db3aea31..6c97118099 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -2,7 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "callable-types": false, - "dt-header": false, "export-just-namespace": false, "interface-over-type-literal": false, "no-padding": false, From d22dd362f4defa0656a364ee416dfdcc473e57cd Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:51:00 +0900 Subject: [PATCH 121/639] Cleanup lint error: no-padding --- types/ejs/index.d.ts | 1 - types/ejs/tslint.json | 1 - 2 files changed, 2 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 8eae387b06..c1c1969be3 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -46,7 +46,6 @@ declare namespace Ejs { generateSource(): any; parseTemplateText(): string[]; scanLine(line: string): any; - } namespace Template { interface MODES { diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index 6c97118099..d01f83708a 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -4,7 +4,6 @@ "callable-types": false, "export-just-namespace": false, "interface-over-type-literal": false, - "no-padding": false, "no-var-keyword": false, "object-literal-shorthand": false, "prefer-const": false, From 8f627efc6476dd4ef9e7cd3addbc6af436237bff Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:52:18 +0900 Subject: [PATCH 122/639] Cleanup lint ignore error: callable-types --- types/ejs/index.d.ts | 4 +--- types/ejs/tslint.json | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index c1c1969be3..5a52399e17 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -19,9 +19,7 @@ declare namespace Ejs { function clearCache(): any; - interface TemplateFunction { - (data: Data): any; - } + type TemplateFunction = (data: Data) => any; interface Options { cache?: any; filename?: string; diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index d01f83708a..001a94fd06 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "callable-types": false, "export-just-namespace": false, "interface-over-type-literal": false, "no-var-keyword": false, From dd60fa13a8f28fdde72de494ae6e42ba10d14bcb Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:53:35 +0900 Subject: [PATCH 123/639] Cleanup lint ignore error: prefer-const --- types/ejs/ejs-tests.ts | 4 ++-- types/ejs/tslint.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/ejs/ejs-tests.ts b/types/ejs/ejs-tests.ts index b5b46f03b5..f7ad42ab73 100644 --- a/types/ejs/ejs-tests.ts +++ b/types/ejs/ejs-tests.ts @@ -1,3 +1,3 @@ import ejs = require("ejs"); -var people = ['geddy', 'neil', 'alex']; -var html = ejs.render('<%= people.join(", "); %>', { people: people }); +const people = ['geddy', 'neil', 'alex']; +const html = ejs.render('<%= people.join(", "); %>', { people: people }); diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index 001a94fd06..f697c232f4 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -5,7 +5,6 @@ "interface-over-type-literal": false, "no-var-keyword": false, "object-literal-shorthand": false, - "prefer-const": false, "unified-signatures": false } } From 57f6d33af3bc0d6796eb1199802c5007138e57b2 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:54:56 +0900 Subject: [PATCH 124/639] Cleanup lint ignore error: no-var-keyword --- types/ejs/index.d.ts | 8 ++++---- types/ejs/tslint.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 5a52399e17..7532fbd3cc 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -6,8 +6,8 @@ declare namespace Ejs { type Data = { [name: string]: any }; type Dependencies = string[]; - var cache: Cache; - var localsName: string; + let cache: Cache; + let localsName: string; function resolveInclude(name: string, filename: string): string; function compile(template: string, opts?: Options): (TemplateFunction); function render(template: string, data?: Data, opts?: Options): string; @@ -76,8 +76,8 @@ declare namespace Ejs { function isAbsolute(path: string): boolean; function join(...args: string[]): string; function relative(from: string, to: string): string; - var sep: string; - var delimiter: string; + let sep: string; + let delimiter: string; function dirname(path: string): string; function basename(path: string): string; function extname(path: string): string; diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index f697c232f4..06b9038d96 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -3,7 +3,6 @@ "rules": { "export-just-namespace": false, "interface-over-type-literal": false, - "no-var-keyword": false, "object-literal-shorthand": false, "unified-signatures": false } From 33d331a29745e77550f90deef9246691bc9c45b2 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 09:59:13 +0900 Subject: [PATCH 125/639] cleanup lint ignore error: export-just-namespace --- types/ejs/index.d.ts | 152 ++++++++++++++++++++---------------------- types/ejs/tslint.json | 1 - 2 files changed, 74 insertions(+), 79 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 7532fbd3cc..0fade248a9 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -3,85 +3,81 @@ // Definitions by: Ben Liddicott // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace Ejs { - type Data = { [name: string]: any }; - type Dependencies = string[]; - let cache: Cache; - let localsName: string; - function resolveInclude(name: string, filename: string): string; - function compile(template: string, opts?: Options): (TemplateFunction); - function render(template: string, data?: Data, opts?: Options): string; +export type Data = { [name: string]: any }; +export type Dependencies = string[]; +export let cache: Cache; +export let localsName: string; +export function resolveInclude(name: string, filename: string): string; +export function compile(template: string, opts?: Options): (TemplateFunction); +export function render(template: string, data?: Data, opts?: Options): string; - type RenderFileCallback = (err: Error, str?: string) => T; - function renderFile(path: string, cb: RenderFileCallback): T; - function renderFile(path: string, data: Data, cb: RenderFileCallback): T; - function renderFile(path: string, data: Data, opts: Options, cb: RenderFileCallback): T; +export type RenderFileCallback = (err: Error, str?: string) => T; +export function renderFile(path: string, cb: RenderFileCallback): T; +export function renderFile(path: string, data: Data, cb: RenderFileCallback): T; +export function renderFile(path: string, data: Data, opts: Options, cb: RenderFileCallback): T; - function clearCache(): any; +export function clearCache(): any; - type TemplateFunction = (data: Data) => any; - interface Options { - cache?: any; - filename?: string; - context?: any; - compileDebug?: boolean; - client?: boolean; - delimiter?: string; - debug?: any; - _with?: boolean; - } - class Template { - constructor(text: string, opts: Options); - opts: Options; - templateText: string; - mode: string; - truncate: boolean; - currentLine: number; - source: string; - dependencies: Dependencies; - createRegex(): RegExp; - compile(): TemplateFunction; - generateSource(): any; - parseTemplateText(): string[]; - scanLine(line: string): any; - } - namespace Template { - interface MODES { - EVAL: string; - ESCAPED: string; - RAW: string; - COMMENT: string; - LITERAL: string; - } - } - function escapeRegexChars(s: string): string; - function escapeXML(markup: string): string; - function shallowCopy(to: T1, fro: any): T1; - interface Cache { - _data: { [name: string]: any }; - set(key: string, val: any): any; - get(key: string): any; - } - function resolve(from1: string, to: string): string; - function resolve(from1: string, from2: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, from4: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, to: string): string; - function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, from9: string, to: string): string; - function resolve(...args: string[]): string; - function normalize(path: string): string; - function isAbsolute(path: string): boolean; - function join(...args: string[]): string; - function relative(from: string, to: string): string; - let sep: string; - let delimiter: string; - function dirname(path: string): string; - function basename(path: string): string; - function extname(path: string): string; - function filter(xs: any, f: any): any; // TODO WHUT? +export type TemplateFunction = (data: Data) => any; +export interface Options { + cache?: any; + filename?: string; + context?: any; + compileDebug?: boolean; + client?: boolean; + delimiter?: string; + debug?: any; + _with?: boolean; } - -export = Ejs; +export class Template { + constructor(text: string, opts: Options); + opts: Options; + templateText: string; + mode: string; + truncate: boolean; + currentLine: number; + source: string; + dependencies: Dependencies; + createRegex(): RegExp; + compile(): TemplateFunction; + generateSource(): any; + parseTemplateText(): string[]; + scanLine(line: string): any; +} +export namespace Template { + interface MODES { + EVAL: string; + ESCAPED: string; + RAW: string; + COMMENT: string; + LITERAL: string; + } +} +export function escapeRegexChars(s: string): string; +export function escapeXML(markup: string): string; +export function shallowCopy(to: T1, fro: any): T1; +export interface Cache { + _data: { [name: string]: any }; + set(key: string, val: any): any; + get(key: string): any; +} +export function resolve(from1: string, to: string): string; +export function resolve(from1: string, from2: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, from4: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, to: string): string; +export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, from9: string, to: string): string; +export function resolve(...args: string[]): string; +export function normalize(path: string): string; +export function isAbsolute(path: string): boolean; +export function join(...args: string[]): string; +export function relative(from: string, to: string): string; +export let sep: string; +export let delimiter: string; +export function dirname(path: string): string; +export function basename(path: string): string; +export function extname(path: string): string; +export function filter(xs: any, f: any): any; // TODO WHUT? diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index 06b9038d96..a3126dd180 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "export-just-namespace": false, "interface-over-type-literal": false, "object-literal-shorthand": false, "unified-signatures": false From a9b2387bce0ff711a7c3543e705e91b9dbad2c1e Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 10:01:17 +0900 Subject: [PATCH 126/639] Cleanup lint ignore error: interface-over-type-literal --- types/ejs/index.d.ts | 4 +++- types/ejs/tslint.json | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 0fade248a9..b7a8c6a191 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -3,7 +3,9 @@ // Definitions by: Ben Liddicott // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export type Data = { [name: string]: any }; +export interface Data { + [name: string]: any; +} export type Dependencies = string[]; export let cache: Cache; export let localsName: string; diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index a3126dd180..ffc654f941 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "interface-over-type-literal": false, "object-literal-shorthand": false, "unified-signatures": false } From 00121a0418878414f9b1510725e4031c418f8b2b Mon Sep 17 00:00:00 2001 From: Alex Lyman Date: Thu, 23 Nov 2017 18:56:17 -0800 Subject: [PATCH 127/639] Fix linting failure. Weird, when I run lint locally, it demands that I have the tslint.json derived from "dtslint/dtslint.json" but Travis CI apparently disagrees and wants "dtslint/dt.json". --- types/loadware/index.d.ts | 2 +- types/loadware/tslint.json | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/loadware/index.d.ts b/types/loadware/index.d.ts index dc3f13437c..7c45225d44 100644 --- a/types/loadware/index.d.ts +++ b/types/loadware/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for loadware 2.0.0 +// Type definitions for loadware 2.0 // Project: https://github.com/franciscop/loadware // Definitions by: A.J.J. Lyman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/loadware/tslint.json b/types/loadware/tslint.json index c17ac4dd6d..6746359dda 100644 --- a/types/loadware/tslint.json +++ b/types/loadware/tslint.json @@ -1 +1,3 @@ -{ "extends": "dtslint/dtslint.json" } +{ + "extends": "dtslint/dt.json" +} From eeb464569d58173070ecd79a0beb6707bc2498c4 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 12:00:35 +0900 Subject: [PATCH 128/639] There is no resolve(). --- types/ejs/index.d.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index b7a8c6a191..76a47ca94c 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -63,16 +63,6 @@ export interface Cache { set(key: string, val: any): any; get(key: string): any; } -export function resolve(from1: string, to: string): string; -export function resolve(from1: string, from2: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, from4: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, to: string): string; -export function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, from9: string, to: string): string; -export function resolve(...args: string[]): string; export function normalize(path: string): string; export function isAbsolute(path: string): boolean; export function join(...args: string[]): string; From 996c9c0db36aba5406bb84e7b7da69cfabca3b51 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 13:07:06 +0900 Subject: [PATCH 129/639] Add Options. --- types/ejs/index.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 76a47ca94c..7918de773a 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -22,14 +22,19 @@ export function clearCache(): any; export type TemplateFunction = (data: Data) => any; export interface Options { - cache?: any; + cache?: boolean; filename?: string; + root?: string; context?: any; compileDebug?: boolean; client?: boolean; delimiter?: string; - debug?: any; + debug?: boolean; + strict?: boolean; _with?: boolean; + localsName?: string; + rmWhitespace?: boolean; + escape?(str: string): string; } export class Template { constructor(text: string, opts: Options); From 5d9f85b6934b9487354930b0bf646e291f125970 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 13:07:34 +0900 Subject: [PATCH 130/639] Delete Not API class --- types/ejs/index.d.ts | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 7918de773a..a64deb7ded 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -36,30 +36,7 @@ export interface Options { rmWhitespace?: boolean; escape?(str: string): string; } -export class Template { - constructor(text: string, opts: Options); - opts: Options; - templateText: string; - mode: string; - truncate: boolean; - currentLine: number; - source: string; - dependencies: Dependencies; - createRegex(): RegExp; - compile(): TemplateFunction; - generateSource(): any; - parseTemplateText(): string[]; - scanLine(line: string): any; -} -export namespace Template { - interface MODES { - EVAL: string; - ESCAPED: string; - RAW: string; - COMMENT: string; - LITERAL: string; - } -} + export function escapeRegexChars(s: string): string; export function escapeXML(markup: string): string; export function shallowCopy(to: T1, fro: any): T1; From b6df77415caf3bf4703e85f939483641ee84b75d Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 13:38:46 +0900 Subject: [PATCH 131/639] Delete unexported export --- types/ejs/index.d.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index a64deb7ded..49d1cb368b 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -6,7 +6,6 @@ export interface Data { [name: string]: any; } -export type Dependencies = string[]; export let cache: Cache; export let localsName: string; export function resolveInclude(name: string, filename: string): string; @@ -39,19 +38,9 @@ export interface Options { export function escapeRegexChars(s: string): string; export function escapeXML(markup: string): string; -export function shallowCopy(to: T1, fro: any): T1; export interface Cache { _data: { [name: string]: any }; set(key: string, val: any): any; get(key: string): any; } -export function normalize(path: string): string; -export function isAbsolute(path: string): boolean; -export function join(...args: string[]): string; -export function relative(from: string, to: string): string; -export let sep: string; export let delimiter: string; -export function dirname(path: string): string; -export function basename(path: string): string; -export function extname(path: string): string; -export function filter(xs: any, f: any): any; // TODO WHUT? From cd4e399afff7203e02201a629fe9a833598bca99 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 13:52:23 +0900 Subject: [PATCH 132/639] ADD JSDoc and add isDir from resolveInclude(). and typed clearCache(). --- types/ejs/index.d.ts | 89 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 49d1cb368b..771ab220e6 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -2,45 +2,124 @@ // Project: http://ejs.co/ // Definitions by: Ben Liddicott // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export interface Data { [name: string]: any; } +/** + * EJS template function cache. This can be a LRU object from lru-cache NPM + * module. By default, it is {@link module:utils.cache}, a simple in-process + * cache that grows continuously. + */ export let cache: Cache; +/** + * Name of the object containing the locals. + * + * This variable is overridden by {@link Options}`.localsName` if it is not + * `undefined`. + */ export let localsName: string; -export function resolveInclude(name: string, filename: string): string; +/** + * Get the path to the included file from the parent file path and the + * specified path. + */ +export function resolveInclude(name: string, filename: string, isDir: boolean): string; +/** + * Compile the given `str` of ejs into a template function. + */ export function compile(template: string, opts?: Options): (TemplateFunction); +/** + * Render the given `template` of ejs. + * + * If you would like to include options but not data, you need to explicitly + * call this function with `data` being an empty object or `null`. + */ export function render(template: string, data?: Data, opts?: Options): string; export type RenderFileCallback = (err: Error, str?: string) => T; + +/** + * Render an EJS file at the given `path` and callback `cb(err, str)`. + * + * If you would like to include options but not data, you need to explicitly + * call this function with `data` being an empty object or `null`. + */ export function renderFile(path: string, cb: RenderFileCallback): T; export function renderFile(path: string, data: Data, cb: RenderFileCallback): T; export function renderFile(path: string, data: Data, opts: Options, cb: RenderFileCallback): T; -export function clearCache(): any; +/** + * Clear intermediate JavaScript cache. Calls {@link Cache#reset}. + */ +export function clearCache(): void; export type TemplateFunction = (data: Data) => any; export interface Options { + /** Compiled functions are cached, requires `filename` */ cache?: boolean; + /** + * The name of the file being rendered. Not required if you are using `renderFile()`. + * Used by `cache` to key caches, and for includes. + */ filename?: string; + /** Set project root for includes with an absolute path (/file.ejs). */ root?: string; + /** Function execution context */ context?: any; + /** When `false` no debug instrumentation is compiled */ compileDebug?: boolean; + /** When `true`, compiles a function that can be rendered in the browser without needing to load the EJS Runtime (ejs.min.js). */ client?: boolean; + /** Character to use with angle brackets for open/close */ delimiter?: string; + /** Output generated function body */ debug?: boolean; + /** When set to `true`, generated function is in strict mode */ strict?: boolean; + /** + * Whether or not to use `with() {}` constructs. + * If `false` then the locals will be stored in the `locals` object. Set to `false` in strict mode. + */ _with?: boolean; + /** Name to use for the object storing local variables when not using `with` Defaults to `locals` */ localsName?: string; + /** + * Remove all safe-to-remove whitespace, including leading and trailing whitespace. + * It also enables a safer version of `-%>` line slurping for all scriptlet tags (it does not strip new lines of tags in the middle of a line). + */ rmWhitespace?: boolean; + /** + * The escaping function used with `<%=` construct. + * It is used in rendering and is `.toString()`ed in the generation of client functions. + * (By default escapes XML). + */ escape?(str: string): string; } export function escapeRegexChars(s: string): string; +/** + * Escape characters reserved in XML. + * + * This is simply an export of {@link module:utils.escapeXML}. + * + * If `markup` is `undefined` or `null`, the empty string is returned. + */ export function escapeXML(markup: string): string; export interface Cache { - _data: { [name: string]: any }; - set(key: string, val: any): any; - get(key: string): any; + _data: { [name: string]: TemplateFunction; }; + set(key: string, val: TemplateFunction): TemplateFunction; + get(key: string): TemplateFunction; } export let delimiter: string; + +/** + * Custom file loader. Useful for template preprocessing or restricting access + * to a certain part of the filesystem. + */ +export function fileLoader(filePath: string): string; + +/** + * Name for detection of EJS. + */ +export const name = "ejs"; From b8cabc4f9961690607009150de7e7eca79bbaadc Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 13:55:09 +0900 Subject: [PATCH 133/639] Add Tests and Cleanup ignore lint errors --- types/ejs/ejs-tests.ts | 34 +++++++++++++++++++++++++++++++++- types/ejs/tslint.json | 8 +------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/types/ejs/ejs-tests.ts b/types/ejs/ejs-tests.ts index f7ad42ab73..8c6dae9965 100644 --- a/types/ejs/ejs-tests.ts +++ b/types/ejs/ejs-tests.ts @@ -1,3 +1,35 @@ import ejs = require("ejs"); +import * as fs from 'graceful-fs'; + +const fileName = 'test.ejs'; const people = ['geddy', 'neil', 'alex']; -const html = ejs.render('<%= people.join(", "); %>', { people: people }); +const data = { people }; +const template = '<%= people.join(", "); %>'; +const options = {delimiter: '$'}; +let result: string; +let cacheResult: string; +let ejsFunction: ejs.TemplateFunction; + +const SimpleCallback = (err: any, html?: string) => { + if (err) { + return null; + } + return html; +}; + +result = ejs.render(template); +result = ejs.render(template, data); +result = ejs.render(template, data, options); + +cacheResult = ejs.renderFile(fileName, SimpleCallback); +cacheResult = ejs.renderFile(fileName, data, SimpleCallback); +cacheResult = ejs.renderFile(fileName, data, options, SimpleCallback); + +ejsFunction = ejs.compile(template); +ejsFunction({}); +ejsFunction(data); +ejs.compile(template, options); + +ejs.fileLoader = (str: string) => str; + +ejs.clearCache(); diff --git a/types/ejs/tslint.json b/types/ejs/tslint.json index ffc654f941..3db14f85ea 100644 --- a/types/ejs/tslint.json +++ b/types/ejs/tslint.json @@ -1,7 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "object-literal-shorthand": false, - "unified-signatures": false - } -} +{ "extends": "dtslint/dt.json" } From ae1ea523661007e218fc57e903e58859fafc431d Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 14:03:37 +0900 Subject: [PATCH 134/639] Fixed Cache methods --- types/ejs/ejs-tests.ts | 4 ++++ types/ejs/index.d.ts | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/types/ejs/ejs-tests.ts b/types/ejs/ejs-tests.ts index 8c6dae9965..40c610dd59 100644 --- a/types/ejs/ejs-tests.ts +++ b/types/ejs/ejs-tests.ts @@ -1,5 +1,7 @@ import ejs = require("ejs"); import * as fs from 'graceful-fs'; +import LRU = require("lru-cache"); +import { TemplateFunction } from "ejs"; const fileName = 'test.ejs'; const people = ['geddy', 'neil', 'alex']; @@ -33,3 +35,5 @@ ejs.compile(template, options); ejs.fileLoader = (str: string) => str; ejs.clearCache(); + +ejs.cache = LRU(100); diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 771ab220e6..9d1294e681 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -107,8 +107,7 @@ export function escapeRegexChars(s: string): string; */ export function escapeXML(markup: string): string; export interface Cache { - _data: { [name: string]: TemplateFunction; }; - set(key: string, val: TemplateFunction): TemplateFunction; + set(key: string, val: TemplateFunction): void; get(key: string): TemplateFunction; } export let delimiter: string; From a8f40e9d04cdd6db77b40eae834f875de91e1caa Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 24 Nov 2017 14:13:23 +0900 Subject: [PATCH 135/639] remove test import graceful-fs --- types/ejs/ejs-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/ejs/ejs-tests.ts b/types/ejs/ejs-tests.ts index 40c610dd59..89b0479529 100644 --- a/types/ejs/ejs-tests.ts +++ b/types/ejs/ejs-tests.ts @@ -1,5 +1,4 @@ import ejs = require("ejs"); -import * as fs from 'graceful-fs'; import LRU = require("lru-cache"); import { TemplateFunction } from "ejs"; From dd5f686f91f704ae9c2318235c3ff38ff2c3bb4c Mon Sep 17 00:00:00 2001 From: noppoman Date: Fri, 24 Nov 2017 14:53:59 +0900 Subject: [PATCH 136/639] add constructor options of openDevTools to nightmare.js --- types/nightmare/index.d.ts | 9 ++++++++- types/nightmare/nightmare-tests.ts | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/types/nightmare/index.d.ts b/types/nightmare/index.d.ts index 0796a0f8e1..7be47c2d30 100644 --- a/types/nightmare/index.d.ts +++ b/types/nightmare/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Nightmare 1.6.6 +// Type definitions for Nightmare 2.10.0 // Project: https://github.com/segmentio/nightmare // Definitions by: horiuchi // Sam Yang @@ -147,6 +147,13 @@ declare namespace Nightmare { typeInterval?: number; x?: number; y?: number; + openDevTools?: { + /** + * Opens the devtools with specified dock state, can be right, bottom, undocked, detach. + * https://github.com/electron/electron/blob/master/docs/api/web-contents.md#contentsopendevtoolsoptions + */ + mode?: string; + }; } export interface IRequest { diff --git a/types/nightmare/nightmare-tests.ts b/types/nightmare/nightmare-tests.ts index eea21ae84c..1dfe655c94 100644 --- a/types/nightmare/nightmare-tests.ts +++ b/types/nightmare/nightmare-tests.ts @@ -364,4 +364,6 @@ new Nightmare() new Nightmare() .goto('https://github.com/segmentio/nightmare') .click('a[href="/segmentio/nightmare/archive/master.zip"]') - .download('/some/other/path/master.zip'); \ No newline at end of file + .download('/some/other/path/master.zip'); + +new Nightmare({show: true, openDevTools: {mode: 'detach'}}); From c55d3e9d4b9d2ea354e56504fd69b8aabd8e3445 Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 08:17:19 +0100 Subject: [PATCH 137/639] remove other rules in tslint.json --- types/confirmdialog/confirmdialog-tests.ts | 68 ++++++--------- types/confirmdialog/index.d.ts | 85 +++++++++---------- types/confirmdialog/tslint.json | 80 +---------------- types/jquery-notifier/index.d.ts | 5 +- .../jquery-notifier/jquery-notifier-tests.ts | 23 ++--- types/jquery-notifier/tslint.json | 80 +---------------- 6 files changed, 77 insertions(+), 264 deletions(-) diff --git a/types/confirmdialog/confirmdialog-tests.ts b/types/confirmdialog/confirmdialog-tests.ts index 47ba509dc4..cd2ad0e8ca 100644 --- a/types/confirmdialog/confirmdialog-tests.ts +++ b/types/confirmdialog/confirmdialog-tests.ts @@ -1,37 +1,27 @@ -namespace server { - export interface Iperson { - title: string, - content: string, - - - } -} - -class Confirm implements server.Iperson { +class Confirm { private title_: string; private conTent_: string; - constructor(public title: string, public content: string) { + constructor(title: string, content: string) { this.title_ = title; this.conTent_ = content; } - - public confirm() { + confirm() { $.confirm({ title: 'Confirm!', content: 'Simple confirm!', buttons: { - confirm: function() { + confirm: () => { $.alert('Confirmed!'); }, - cancel: function(cancel: string) { + cancel: (cancel: string) => { $.alert('Canceled! ' + cancel); }, somethingElse: { text: 'Something else', btnClass: 'btn-blue', keys: ['enter', 'shift'], - action: function() { + action: () => { alert('Something else?'); } } @@ -39,15 +29,14 @@ class Confirm implements server.Iperson { }); } - public alert() { + alert() { $.alert({ title: 'Alert!', content: 'Simple alert!', }); } - - public globalSettings(){ + globalSettings() { jconfirm.defaults = { title: 'Hello', titleClass: '', @@ -62,11 +51,11 @@ class Confirm implements server.Iperson { buttons: {}, defaultButtons: { ok: { - action: function () { + action: () => { } }, close: { - action: function () { + action: () => { } }, }, @@ -100,46 +89,41 @@ class Confirm implements server.Iperson { containerFluid: 'container-fluid', row: 'row', }, - onContentReady: function () {}, - onOpenBefore: function () {}, - onOpen: function () {}, - onClose: function () {}, - onDestroy: function () {}, - onAction: function () {} + onContentReady: () => {}, + onOpenBefore: () => {}, + onOpen: () => {}, + onClose: () => {}, + onDestroy: () => {}, + onAction: () => {} }; } - public api(){ - var jc = $.confirm({ + api() { + const jc = $.confirm({ title: 'awesome', - onContentReady: function(){ - // this === jc - //jc.setTitle(title: string); + onContentReady: () => { + jc.setTitle(); } }); } - - public confirm_84() { + confirm_84() { $.confirm({ closeIcon: true, buttons: { buttonA: { text: 'button a', - action: function (buttonA: HTMLElement) { - + action: (buttonA: string) => { return false; // prevent the modal from closing } }, - resetButton: function (resetButton: string) { + resetButton: (resetButton: string) => { } } }); } - } - -var firstName: string = 'Pierre'; -var lastName: string = 'Yotti'; -var type = new Confirm(firstName, lastName); +let firstName = 'Pierre'; +let lastName = 'Yotti'; +let type = new Confirm(firstName, lastName); diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 9be4d62489..39a507f8ac 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for confirmdialog v3.3.0 +// Type definitions for confirmdialog 3.3 // Project: https://github.com/allipierre/Type-definitions-for-jquery-confirm/tree/master/types/confirmDialog-js // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 + /// interface JQueryStatic { @@ -10,93 +11,83 @@ * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert * @param {any} pMessage */ - alert( pMessage?: any | string, title?:string): void; + alert(pMessage?: any | string, title?: string): any; /** * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: options.confirmOptions | string): void; - + dialog(pOtions: options.confirmOptions | string): any; } - interface JQuery { /** * confirm Dialog * @param {confirmOptions} pOtions */ - confirm( pOtions: options.confirmOptions | string, title?:string): boolean | void | HTMLElement | any; + confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert * @param {any} pMessage */ - alert( pMessage?: any, title?:string): void; + alert(pMessage?: any, title?: string): any; /** * confirm Dialog * @param {any} pMessage */ - dialog( pOtions: options.confirmOptions | any): void; + dialog(pOtions: options.confirmOptions | any): any; } interface Window { setContentAppend: any; } - - - declare namespace options { - interface confirmOptions { - buttons? : buttonOptionss | any, - title? : string | boolean, - content? : string | Function, - onContentReady?: Function, - lazyOpen?: boolean, - closeIcon?: boolean | Function, - type?: string, - typeAnimated?: boolean, - icon?: string, - closeIconClass?: string, - columnClass?: string, - containerFluid?: boolean, - boxWidth?: string, - useBootstrap?: boolean, - bootstrapClasses?: any, - draggable?: boolean, - dragWindowBorder?: boolean, - dragWindowGap?: number, - contentLoaded?: Function, - autoClose?: string, - backgroundDismiss?: boolean | Function | string, - backgroundDismissAnimation?: string, - escapeKey?: string | boolean, - onOpenBefore?:Function, - onOpen?: Function, - onClose?: Function, - onDestroy?: Function, - onAction?: Function - - + buttons?: buttonOptionss | any; + title?: string | boolean; + content?: any; + onContentReady?: any; + lazyOpen?: boolean; + closeIcon?: boolean | any; + type?: string; + typeAnimated?: boolean; + icon?: string; + closeIconClass?: string; + columnClass?: string; + containerFluid?: boolean; + boxWidth?: string; + useBootstrap?: boolean; + bootstrapClasses?: any; + draggable?: boolean; + dragWindowBorder?: boolean; + dragWindowGap?: number; + contentLoaded?: () => void; + autoClose?: string; + backgroundDismiss?: boolean | any | string; + backgroundDismissAnimation?: string; + escapeKey?: string | boolean; + onOpenBefore?: () => void; + onOpen?: () => void; + onClose?: () => void; + onDestroy?: () => void; + onAction?: () => void; } interface buttonOptionss { - cancel?: Function, - confirm?: Function + cancel?: () => void; + confirm?: () => void; } - } declare namespace jconfirm { let defaults: any; - } diff --git a/types/confirmdialog/tslint.json b/types/confirmdialog/tslint.json index a41bf5d19a..3db14f85ea 100644 --- a/types/confirmdialog/tslint.json +++ b/types/confirmdialog/tslint.json @@ -1,79 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index 4c733ce0df..855b3e50b1 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -1,9 +1,8 @@ -// Type definitions for Notifier +// Type definitions for notifier 1.0 // Project: https://github.com/allipierre/jquery-notifier // Definitions by: Alli Pierre Yotti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace notifier { /** * notifier.show(title, msg, type, icon, timeout); @@ -14,6 +13,6 @@ declare namespace notifier { * @param {timeout} timeout */ function show(title: string, msg: string, type: string, icon: string, timeout?: number): string | number; - function hide(notificationId: string | number): boolean; + function hide(notificationId: string | number): boolean; } diff --git a/types/jquery-notifier/jquery-notifier-tests.ts b/types/jquery-notifier/jquery-notifier-tests.ts index 9d73bce3c5..18804758be 100644 --- a/types/jquery-notifier/jquery-notifier-tests.ts +++ b/types/jquery-notifier/jquery-notifier-tests.ts @@ -4,33 +4,28 @@ notifier.show('Well Done!', 'You just submit your resume successfuly.', '', '', notifier.show('Warning!', 'The data presented here can be change.', '', '', 0); notifier.show('Sorry!', 'Could not complete your transaction.', '', '', 0); - notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 0); notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 0); notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 0); notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 0); notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 0); - - notifier.show('Default!', 'I am a default notification.', '', 'img/clock-48.png', 4000); notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); notifier.show('Well Done!', 'You just submit your resume successfuly.', '', 'img/ok-48.png', 4000); notifier.show('Warning!', 'The data presented here can be change.', '', 'img/medium_priority-48.png', 4000); notifier.show('Sorry!', 'Could not complete your transaction.', '', 'img/high_priority-48.png', 4000); +let notificationId: string | number; +let showNotification = () => { + notificationId = notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); +}; +let hideNotification = () => { + notifier.hide(notificationId); +}; - var notificationId:string | number; +document.querySelector('#btn-nt-show').addEventListener('click', showNotification); - var showNotification = function () { - notificationId = notifier.show('Reminder!', 'You have a meeting at 10:30 AM.', '', 'img/survey-48.png', 4000); - }; - - var hideNotification = function () { - notifier.hide(notificationId); - }; - - document.querySelector('#btn-nt-show').addEventListener('click', showNotification); - document.querySelector('#btn-nt-hide').addEventListener('click', hideNotification); +document.querySelector('#btn-nt-hide').addEventListener('click', hideNotification); diff --git a/types/jquery-notifier/tslint.json b/types/jquery-notifier/tslint.json index a41bf5d19a..3db14f85ea 100644 --- a/types/jquery-notifier/tslint.json +++ b/types/jquery-notifier/tslint.json @@ -1,79 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} +{ "extends": "dtslint/dt.json" } From c9fbcc97767c5dbab555db77b712685befab0ce9 Mon Sep 17 00:00:00 2001 From: ipv4sec Date: Fri, 24 Nov 2017 15:38:09 +0800 Subject: [PATCH 138/639] feat: add mapnik d.ts --- types/mapnik/index.d.ts | 49 ++++++++++++++++++++++++++++++++++++ types/mapnik/mapnik-tests.ts | 40 +++++++++++++++++++++++++++++ types/mapnik/tsconfig.json | 23 +++++++++++++++++ types/mapnik/tslint.json | 1 + 4 files changed, 113 insertions(+) create mode 100644 types/mapnik/index.d.ts create mode 100644 types/mapnik/mapnik-tests.ts create mode 100644 types/mapnik/tsconfig.json create mode 100644 types/mapnik/tslint.json diff --git a/types/mapnik/index.d.ts b/types/mapnik/index.d.ts new file mode 100644 index 0000000000..33b455f0dd --- /dev/null +++ b/types/mapnik/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for mapnik 3.x +// Project: http://mapnik.org +// Definitions by: Loli +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +export const settings: any; +export function register_default_fonts(): void; +export function register_default_input_plugins(): void; +export function register_datasource(path: string): void; +export class VectorTile { + constructor(z: number, x: number, y: number) + addDataSync(vectorTile: any): void; +} +export class Datasource { + constructor(datasource: any) + featureset(): Featureset; +} + +export class Featureset { + constructor() + next(): FeaturesetNext; +} +export class FeaturesetNext { + constructor() + toJSON(): string; +} + +export class Image { + constructor(x: number, y: number) + encode(type: string, callback?: (err: Error, buffer: Buffer) => void): void; + getData(): Buffer; +} + +export interface Image { + // constructor(x: number, y: number) + new(x: number, y: number): () => void; + encode(type: string, callback?: (err: Error, buffer: Buffer) => void): void; + getData(): Buffer; + save(fp: string): () => void; + open(fp: string): () => void; +} + +export class Map { + constructor(x: number, y: number) + load(xml: string, callback?: (err: Error, map: Map) => void): void; + zoomAll(): void; + render(images: Image | VectorTile , callback?: (err: Error, map: Image) => void): void; +} diff --git a/types/mapnik/mapnik-tests.ts b/types/mapnik/mapnik-tests.ts new file mode 100644 index 0000000000..23e726f111 --- /dev/null +++ b/types/mapnik/mapnik-tests.ts @@ -0,0 +1,40 @@ +import * as mapnik from "mapnik"; +import * as fs from "fs"; +import * as path from "path"; + +mapnik.register_default_fonts(); +mapnik.register_default_input_plugins(); + +const map: mapnik.Map = new mapnik.Map(256, 256); +map.load('./test/stylesheet.xml', function xx(err: Error, map: mapnik.Map) { + if (err) throw err; + map.zoomAll(); + const im: mapnik.Image = new mapnik.Image(256, 256); + map.render(im, function xxx(err: Error, im: mapnik.Image) { + if (err) throw err; + im.encode('png', function xxxx(err: Error, buffer: Buffer) { + if (err) throw err; + fs.writeFile('map.png', buffer, function xxxxx(err: Error) { + if (err) throw err; + console.log('saved map image to map.png'); + }); + }); + }); +}); + +// new mapnik.Image.open("xxx").save("xx"); + +mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins, 'shape.input')); +const ds: mapnik.Datasource = new mapnik.Datasource({type: 'shape', file: 'test/data/world_merc.shp'}); +const featureset: mapnik.Featureset = ds.featureset(); +const geojson: any = { + type: "FeatureCollection", + features: [ + ] +}; +let feat: mapnik.FeaturesetNext = featureset.next(); +while (feat) { + geojson.features.push(JSON.parse(feat.toJSON())); + feat = featureset.next(); +} +fs.writeFileSync("output.geojson", JSON.stringify(geojson, null, 2)); diff --git a/types/mapnik/tsconfig.json b/types/mapnik/tsconfig.json new file mode 100644 index 0000000000..81f111a37e --- /dev/null +++ b/types/mapnik/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mapnik-tests.ts" + ] +} \ No newline at end of file diff --git a/types/mapnik/tslint.json b/types/mapnik/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/mapnik/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From 7ffa7f591a9133c11ce8e625a0f6ed4c5e5a0011 Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 08:47:03 +0100 Subject: [PATCH 139/639] remove other rules in tslint.json --- package.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/package.json b/package.json index 61b734fec2..db67595b77 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { - "@types/node": "^8.0.53", "dtslint": "github:Microsoft/dtslint#production", - "types-publisher": "Microsoft/types-publisher#production", - "typescript": "^2.6.1" - }, - "dependencies": { - "@types/jquery": "^3.2.16", - "jquery": "^3.1.1", - "typescript": "^2.6.1" + "types-publisher": "Microsoft/types-publisher#production" } } From e2fa7e85cc5af5740a22f63d1ba6037284669b38 Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 09:11:19 +0100 Subject: [PATCH 140/639] remove param in commentar --- types/confirmdialog/index.d.ts | 12 ++++++------ types/jquery-notifier/index.d.ts | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 39a507f8ac..1b7d106fac 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -9,19 +9,19 @@ interface JQueryStatic { /** * confirm Dialog - * @param {confirmOptions} pOtions + * {confirmOptions} pOtions */ confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert - * @param {any} pMessage + * {any} pMessage */ alert(pMessage?: any | string, title?: string): any; /** * confirm Dialog - * @param {any} pMessage + * {any} pMessage */ dialog(pOtions: options.confirmOptions | string): any; } @@ -29,19 +29,19 @@ interface JQuery { /** * confirm Dialog - * @param {confirmOptions} pOtions + * {confirmOptions} pOtions */ confirm(pOtions: options.confirmOptions | string, title?: string): any; /** * confirm alert - * @param {any} pMessage + * {any} pMessage */ alert(pMessage?: any, title?: string): any; /** * confirm Dialog - * @param {any} pMessage + * {any} pMessage */ dialog(pOtions: options.confirmOptions | any): any; } diff --git a/types/jquery-notifier/index.d.ts b/types/jquery-notifier/index.d.ts index 855b3e50b1..bf9d0ff93b 100644 --- a/types/jquery-notifier/index.d.ts +++ b/types/jquery-notifier/index.d.ts @@ -6,11 +6,11 @@ declare namespace notifier { /** * notifier.show(title, msg, type, icon, timeout); - * @param {title} title - * @param {msg} msg - * @param {type} type - * @param {icon} icon - * @param {timeout} timeout + * {title} title + * {msg} msg + * {type} type + * {icon} icon + * {timeout} timeout */ function show(title: string, msg: string, type: string, icon: string, timeout?: number): string | number; From 9f47e5d4c4a9f5dae9ae7816779af8110b97de2c Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 09:18:46 +0100 Subject: [PATCH 141/639] remove any union --- types/confirmdialog/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 1b7d106fac..212a3aa271 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -17,7 +17,7 @@ * confirm alert * {any} pMessage */ - alert(pMessage?: any | string, title?: string): any; + alert(pMessage?: any, title?: string): any; /** * confirm Dialog @@ -57,7 +57,7 @@ declare namespace options { content?: any; onContentReady?: any; lazyOpen?: boolean; - closeIcon?: boolean | any; + closeIcon?: any; type?: string; typeAnimated?: boolean; icon?: string; @@ -72,7 +72,7 @@ declare namespace options { dragWindowGap?: number; contentLoaded?: () => void; autoClose?: string; - backgroundDismiss?: boolean | any | string; + backgroundDismiss?: any; backgroundDismissAnimation?: string; escapeKey?: string | boolean; onOpenBefore?: () => void; From 4bc06272e9692de2ce2dde36128422fb2237071d Mon Sep 17 00:00:00 2001 From: allipierre Date: Fri, 24 Nov 2017 09:25:19 +0100 Subject: [PATCH 142/639] remove any union --- types/confirmdialog/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/confirmdialog/index.d.ts b/types/confirmdialog/index.d.ts index 212a3aa271..9b98ab2389 100644 --- a/types/confirmdialog/index.d.ts +++ b/types/confirmdialog/index.d.ts @@ -43,7 +43,7 @@ * confirm Dialog * {any} pMessage */ - dialog(pOtions: options.confirmOptions | any): any; + dialog(pOtions: options.confirmOptions): any; } interface Window { @@ -52,7 +52,7 @@ interface Window { declare namespace options { interface confirmOptions { - buttons?: buttonOptionss | any; + buttons?: any; title?: string | boolean; content?: any; onContentReady?: any; From c1aa9c5c5013f8970112c5188f5e0eab888a4bec Mon Sep 17 00:00:00 2001 From: ChenX Date: Fri, 24 Nov 2017 16:52:53 +0800 Subject: [PATCH 143/639] update Geometry functions --- types/three/three-core.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/three/three-core.d.ts b/types/three/three-core.d.ts index 5ea903080b..63a1e1cb38 100644 --- a/types/three/three-core.d.ts +++ b/types/three/three-core.d.ts @@ -1369,6 +1369,8 @@ export class Geometry extends EventDispatcher { */ mergeVertices(): number; + setFromPoints(points: Array | Array): this; + sortFacesByMaterialIndex(): void; toJSON(): any; From 9d5c2cb2e19ccbd87cfd38b972a445732ff1b6dc Mon Sep 17 00:00:00 2001 From: Ilya Petukhov Date: Fri, 24 Nov 2017 12:22:37 +0300 Subject: [PATCH 144/639] Add type definitions for the fixed-data-table-2 package --- .../fixed-data-table-2-tests.tsx | 196 +++++ types/fixed-data-table-2/index.d.ts | 677 ++++++++++++++++++ types/fixed-data-table-2/tsconfig.json | 22 + types/fixed-data-table-2/tslint.json | 3 + 4 files changed, 898 insertions(+) create mode 100644 types/fixed-data-table-2/fixed-data-table-2-tests.tsx create mode 100644 types/fixed-data-table-2/index.d.ts create mode 100644 types/fixed-data-table-2/tsconfig.json create mode 100644 types/fixed-data-table-2/tslint.json diff --git a/types/fixed-data-table-2/fixed-data-table-2-tests.tsx b/types/fixed-data-table-2/fixed-data-table-2-tests.tsx new file mode 100644 index 0000000000..3b34d6a44a --- /dev/null +++ b/types/fixed-data-table-2/fixed-data-table-2-tests.tsx @@ -0,0 +1,196 @@ +/** + * The tests are based on tests from types/fixed-data-table + */ + +import * as React from "react"; +import { Table, Cell, Column, CellProps } from "fixed-data-table-2"; + +// create your Table +class MyTable1 extends React.Component { + render() { + return ( + + // add columns +
+ ); + } +} + +// create your Columns +class MyTable2 extends React.Component { + render() { + return ( + + Basic content} + width={200} + /> +
+ ); + } +} + +// provide Custom Data +interface MyTable3State { + myTableData: Array<{ name: string }>; +} + +class MyTable3 extends React.Component<{}, MyTable3State> { + constructor(props: {}) { + super(props); + + this.state = { + myTableData: [ + { name: "Rylan" }, + { name: "Amelia" }, + { name: "Estevan" }, + { name: "Florence" }, + { name: "Tressa" }, + ] + }; + } + + render() { + return ( + + Name} + cell={(props) => ( + + {this.state.myTableData[props.rowIndex].name} + + )} + width={200} + /> +
+ ); + } +} + +// Create Reusable Cells +interface RowData { + [field: string]: string; +} + +interface MyCellProps extends CellProps { + field: string; + myData: RowData[]; +} + +class MyTextCell extends React.Component { + render() { + const { rowIndex, field, myData } = this.props; + + return ( + + {myData[rowIndex!][field]} + + ); + } +} + +class MyLinkCell extends React.Component { + render() { + const { rowIndex, field, myData } = this.props; + const link: string = myData[rowIndex!][field]; + + return ( + + {link} + + ); + } +} + +interface MyTable4State { + tableData: RowData[]; +} + +class MyTable4 extends React.Component<{}, MyTable4State> { + constructor(props: {}) { + super(props); + this.state = { + tableData: [ + { name: "Rylan", email: "Angelita_Weimann42@gmail.com" }, + { name: "Amelia", email: "Dexter.Trantow57@hotmail.com" }, + { name: "Estevan", email: "Aimee7@hotmail.com" }, + { name: "Florence", email: "Jarrod.Bernier13@yahoo.com" }, + { name: "Tressa", email: "Yadira1@hotmail.com" } + ] + }; + } + + render() { + return ( + + { + ["name", "email"].map(field => + {field}} + cell={ + + } + width={200} /> + ) + } +
+ ); + } +} + +// Listen for events +class MyTable5 extends React.Component { + render() { + return ( + { }} + onScrollEnd={(x: number, y: number) => { }} + onContentHeightChange={(newHeight: number) => { }} + onRowClick={(event: React.SyntheticEvent
, rowIndex: number) => { }} + onRowDoubleClick={(event: React.SyntheticEvent
, rowIndex: number) => { }} + onRowMouseDown={(event: React.SyntheticEvent
, rowIndex: number) => { }} + onRowMouseEnter={(event: React.SyntheticEvent
, rowIndex: number) => { }} + onRowMouseLeave={(event: React.SyntheticEvent
, rowIndex: number) => { }} + onColumnResizeEndCallback={(newColumnWidth: number, columnKey: string) => { }}> + // add columns +
+ ); + } +} diff --git a/types/fixed-data-table-2/index.d.ts b/types/fixed-data-table-2/index.d.ts new file mode 100644 index 0000000000..a39397a228 --- /dev/null +++ b/types/fixed-data-table-2/index.d.ts @@ -0,0 +1,677 @@ +// Type definitions for fixed-data-table-2 0.8 +// Project: https://github.com/schrodinger/fixed-data-table-2 +// Definitions by: Ilya Petukhov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from "react"; + +export as namespace FixedDataTable; + +export interface RowProps { + /** the row index */ + rowIndex: number; + + /** supplied from the Table or rowHeightGetter */ + height: number; + + /** supplied from the Table */ + width: number; +} + +export interface ColumnReorderEndEvent { + /** the column before the new location of this one */ + columnBefore?: string; + + /** the column after the new location of this one */ + columnAfter?: string; + + /** the column key that was just reordered */ + reorderColumn: string; +} + +export type ElementOrFunc

= string | React.ReactElement | ((props: P) => (string | React.ReactElement)); + +export type TableRowEventHandler = (event: React.SyntheticEvent, rowIndex: number) => void; + +/** + * Data grid component with fixed or scrollable header and columns. + * + * The layout of the data table is as follows: + * + * ``` + * +---------------------------------------------------+ + * | Fixed Column Group | Scrollable Column Group | + * | Header | Header | + * | | | + * +---------------------------------------------------+ + * | | | + * | Fixed Header Columns | Scrollable Header Columns | + * | | | + * +-----------------------+---------------------------+ + * | | | + * | Fixed Body Columns | Scrollable Body Columns | + * | | | + * +-----------------------+---------------------------+ + * | | | + * | Fixed Footer Columns | Scrollable Footer Columns | + * | | | + * +-----------------------+---------------------------+ + * ``` + * + * - Fixed Column Group Header: These are the headers for a group + * of columns if included in the table that do not scroll + * vertically or horizontally. + * + * - Scrollable Column Group Header: The header for a group of columns + * that do not move while scrolling vertically, but move horizontally + * with the horizontal scrolling. + * + * - Fixed Header Columns: The header columns that do not move while scrolling + * vertically or horizontally. + * + * - Scrollable Header Columns: The header columns that do not move + * while scrolling vertically, but move horizontally with the horizontal + * scrolling. + * + * - Fixed Body Columns: The body columns that do not move while scrolling + * horizontally, but move vertically with the vertical scrolling. + * + * - Scrollable Body Columns: The body columns that move while scrolling + * vertically or horizontally. + */ +export interface TableProps extends React.ClassAttributes
{ + /** + * Pixel width of table. If all columns do not fit, + * a horizontal scrollbar will appear. + */ + width: number; + + /** + * Pixel height of table. If all rows do not fit, + * a vertical scrollbar will appear. + * + * Either `height` or `maxHeight` must be specified. + */ + height?: number; + + /** + * Class name to be passed into parent container + */ + className?: string; + + /** + * Maximum pixel height of table. If all rows do not fit, + * a vertical scrollbar will appear. + * + * Either `height` or `maxHeight` must be specified. + */ + maxHeight?: number; + + /** + * Pixel height of table's owner, this is used in a managed scrolling + * situation when you want to slide the table up from below the fold + * without having to constantly update the height on every scroll tick. + * Instead, vary this property on scroll. By using `ownerHeight`, we + * over-render the table while making sure the footer and horizontal + * scrollbar of the table are visible when the current space for the table + * in view is smaller than the final, over-flowing height of table. It + * allows us to avoid resizing and reflowing table when it is moving in the + * view. + * + * This is used if `ownerHeight < height` (or `maxHeight`). + */ + ownerHeight?: number; + + overflowX?: 'hidden' | 'auto'; + overflowY?: 'hidden' | 'auto'; + + /** + * Boolean flag indicating of touch scrolling should be enabled + * This feature is current in beta and may have bugs + */ + touchScrollEnabled?: boolean; + + /** Boolean flags to control if scrolling with keys is enabled */ + keyboardScrollEnabled?: boolean; + /** Boolean flags to control if scrolling with keys is enabled */ + keyboardPageEnabled?: boolean; + + /** Hide the scrollbar but still enable scroll functionality */ + showScrollbarX?: boolean; + /** Hide the scrollbar but still enable scroll functionality */ + showScrollbarY?: boolean; + + /** + * Callback when horizontally scrolling the grid. + * + * Return false to stop propagation. + */ + onHorizontalScroll?: (scrollPos: number) => boolean; + + /** + * Callback when vertically scrolling the grid. + * + * Return false to stop propagation. + */ + onVerticalScroll?: (scrollPos: number) => boolean; + + /** + * Number of rows in the table. + */ + rowsCount: number; + + /** + * Pixel height of rows unless `rowHeightGetter` is specified and returns + * different value. + */ + rowHeight: number; + + /** + * If specified, `rowHeightGetter(index)` is called for each row and the + * returned value overrides `rowHeight` for particular row. + */ + rowHeightGetter?: (index: number) => number; + + /** + * Pixel height of sub-row unless `subRowHeightGetter` is specified and returns + * different value. Defaults to 0 and no sub-row being displayed. + */ + subRowHeight?: number; + + /** + * If specified, `subRowHeightGetter(index)` is called for each row and the + * returned value overrides `subRowHeight` for particular row. + */ + subRowHeightGetter?: (index: number) => number; + + /** + * The row expanded for table row. + * This can either be a React element, or a function that generates + * a React Element. By default, the React element passed in can expect to + * receive the following props: + * + * ``` + * props: { + * rowIndex; number // (the row index) + * height: number // (supplied from the Table or rowHeightGetter) + * width: number // (supplied from the Table) + * } + * ``` + * + * Because you are passing in your own React element, you can feel free to + * pass in whatever props you may want or need. + * + * If you pass in a function, you will receive the same props object as the + * first argument. + */ + rowExpanded?: ElementOrFunc; + + /** + * To get any additional CSS classes that should be added to a row, + * `rowClassNameGetter(index)` is called. + */ + rowClassNameGetter?: (index: number) => string; + + /** + * If specified, `rowKeyGetter(index)` is called for each row and the + * returned value overrides `key` for the particular row. + */ + rowKeyGetter?: (index: number) => string; + + /** + * Pixel height of the column group header. + */ + groupHeaderHeight?: number; + + /** + * Pixel height of header. + */ + headerHeight: number; + + /** + * Pixel height of fixedDataTableCellGroupLayout/cellGroupWrapper. + * Default is headerHeight and groupHeaderHeight. + * + * This can be used with CSS to make a header cell span both the group & normal header row. + * Setting this to a value larger than height will cause the content to + * overflow the height. This is useful when adding a 2nd table as the group + * header and vertically merging the 2 headers when a column is not part + * of a group. Here are the necessary CSS changes: + * + * Both headers: + * - cellGroupWrapper needs overflow-x: hidden and pointer-events: none + * - cellGroup needs pointer-events: auto to reenable them on child els + * Group header: + * - Layout/main needs overflow: visible and a higher z-index + * - CellLayout/main needs overflow-y: visible + * - cellGroup needs overflow: visible + */ + cellGroupWrapperHeight?: number; + + /** + * Pixel height of footer. + */ + footerHeight?: number; + + /** + * Value of horizontal scroll. + */ + scrollLeft?: number; + + /** + * Index of column to scroll to. + */ + scrollToColumn?: number; + + /** + * Value of vertical scroll. + */ + scrollTop?: number; + + /** + * Index of row to scroll to. + */ + scrollToRow?: number; + + /** + * Callback that is called when scrolling starts with current horizontal + * and vertical scroll values. + */ + onScrollStart?: (x: number, y: number) => void; + + /** + * Callback that is called when scrolling ends or stops with new horizontal + * and vertical scroll values. + */ + onScrollEnd?: (x: number, y: number) => void; + + /** + * If enabled scroll events will not be propagated outside of the table. + */ + stopScrollPropagation?: boolean; + + /** + * Callback that is called when `rowHeightGetter` returns a different height + * for a row than the `rowHeight` prop. This is necessary because initially + * table estimates heights of some parts of the content. + */ + onContentHeightChange?: (newHeight: number) => void; + + /** + * Callback that is called when a row is clicked. + */ + onRowClick?: TableRowEventHandler; + + /** + * Callback that is called when a row is double clicked. + */ + onRowDoubleClick?: TableRowEventHandler; + + /** + * Callback that is called when a mouse-down event happens on a row. + */ + onRowMouseDown?: TableRowEventHandler; + + /** + * Callback that is called when a mouse-up event happens on a row. + */ + onRowMouseUp?: TableRowEventHandler; + + /** + * Callback that is called when a mouse-enter event happens on a row. + */ + onRowMouseEnter?: TableRowEventHandler; + + /** + * Callback that is called when a mouse-leave event happens on a row. + */ + onRowMouseLeave?: TableRowEventHandler; + + /** + * Callback that is called when a touch-start event happens on a row. + */ + onRowTouchStart?: TableRowEventHandler; + + /** + * Callback that is called when a touch-end event happens on a row. + */ + onRowTouchEnd?: TableRowEventHandler; + + /** + * Callback that is called when a touch-move event happens on a row. + */ + onRowTouchMove?: TableRowEventHandler; + + /** + * Callback that is called when resizer has been released + * and column needs to be updated. + * + * Required if the isResizable property is true on any column. + * + * ``` + * function( + * newColumnWidth: number, + * columnKey: string, + * ) + * ``` + */ + onColumnResizeEndCallback?: (newColumnWidth: number, columnKey: string) => void; + + /** + * Callback that is called when reordering has been completed + * and columns need to be updated. + * + * ``` + * function( + * event { + * columnBefore: string|undefined, // the column before the new location of this one + * columnAfter: string|undefined, // the column after the new location of this one + * reorderColumn: string, // the column key that was just reordered + * } + * ) + * ``` + */ + onColumnReorderEndCallback?: (event: ColumnReorderEndEvent) => void; + + /** + * Whether a column is currently being resized. + */ + isColumnResizing?: boolean; + + /** + * Whether columns are currently being reordered. + */ + isColumnReordering?: boolean; + + /** + * The number of rows outside the viewport to prerender. Defaults to roughly + * half of the number of visible rows. + */ + bufferRowCount?: number; +} + +export class Table extends React.Component { +} + +export interface ColumnHeaderProps { + columnKey?: string; + + /** supplied from the Table or rowHeightGetter */ + height: number; + + /** supplied from the Column */ + width: number; +} + +export interface ColumnCellProps extends ColumnHeaderProps { + /** the row index of the cell */ + rowIndex: number; +} + +/** + * Component that defines the attributes of table column. + */ +export interface ColumnProps extends React.ClassAttributes { + /** + * The horizontal alignment of the table cell content. + */ + align?: 'left' | 'center' | 'right'; + + /** + * Controls if the column is fixed when scrolling in the X axis. + * + * defaultValue: false + */ + fixed?: boolean; + + /** + * Controls if the column is fixed to the right side of the table + * when scrolling in the X axis. + * + * defaultValue: false + */ + fixedRight?: boolean; + + /** + * The header cell for this column. + * This can either be a string a React element, or a function that generates + * a React Element. Passing in a string will render a default header cell + * with that string. By default, the React element passed in can expect to + * receive the following props: + * + * ``` + * props: { + * columnKey: string // (of the column, if given) + * height: number // (supplied from the Table or rowHeightGetter) + * width: number // (supplied from the Column) + * } + * ``` + * + * Because you are passing in your own React element, you can feel free to + * pass in whatever props you may want or need. + * + * If you pass in a function, you will receive the same props object as the + * first argument. + */ + header?: ElementOrFunc; + + /** + * This is the body cell that will be cloned for this column. + * This can either be a string a React element, or a function that generates + * a React Element. Passing in a string will render a default header cell + * with that string. By default, the React element passed in can expect to + * receive the following props: + * + * ``` + * props: { + * rowIndex; number // (the row index of the cell) + * columnKey: string // (of the column, if given) + * height: number // (supplied from the Table or rowHeightGetter) + * width: number // (supplied from the Column) + * } + * ``` + * + * Because you are passing in your own React element, you can feel free to + * pass in whatever props you may want or need. + * + * If you pass in a function, you will receive the same props object as the + * first argument. + */ + cell?: ElementOrFunc; + + /** + * This is the footer cell for this column. + * This can either be a string a React element, or a function that generates + * a React Element. Passing in a string will render a default header cell + * with that string. By default, the React element passed in can expect to + * receive the following props: + * + * ``` + * props: { + * columnKey: string // (of the column, if given) + * height: number // (supplied from the Table or rowHeightGetter) + * width: number // (supplied from the Column) + * } + * ``` + * + * Because you are passing in your own React element, you can feel free to + * pass in whatever props you may want or need. + * + * If you pass in a function, you will receive the same props object as the + * first argument. + */ + footer?: ElementOrFunc; + + /** + * This is used to uniquely identify the column, and is not required unless + * you a resizing columns. This will be the key given in the + * `onColumnResizeEndCallback` on the Table. + */ + columnKey?: string | number; + + /** + * The pixel width of the column. + */ + width: number; + + /** + * If this is a resizable column this is its minimum pixel width. + */ + minWidth?: number; + + /** + * If this is a resizable column this is its maximum pixel width. + */ + maxWidth?: number; + + /** + * The grow factor relative to other columns. Same as the flex-grow API + * from http://www.w3.org/TR/css3-flexbox/. Basically, take any available + * extra width and distribute it proportionally according to all columns' + * flexGrow values. Defaults to zero (no-flexing). + */ + flexGrow?: number; + + /** + * Whether the column can be resized with the + * FixedDataTableColumnResizeHandle. Please note that if a column + * has a flex grow, once you resize the column this will be set to 0. + * + * This property only provides the UI for the column resizing. If this + * is set to true, you will need to set the onColumnResizeEndCallback table + * property and render your columns appropriately. + */ + isResizable?: boolean; + + /** + * Whether the column can be dragged to reorder. + */ + isReorderable?: boolean; + + /** + * Whether cells in this column can be removed from document when outside + * of viewport as a result of horizontal scrolling. + * Setting this property to true allows the table to not render cells in + * particular column that are outside of viewport for visible rows. This + * allows to create table with many columns and not have vertical scrolling + * performance drop. + * Setting the property to false will keep previous behaviour and keep + * cell rendered if the row it belongs to is visible. + * + * defaultValue: false + */ + allowCellsRecycling?: boolean; + + /** + * Flag to enable performance check when rendering. Stops the component from + * rendering if none of it's passed in props have changed + */ + pureRendering?: boolean; +} + +export class Column extends React.Component { +} + +export interface ColumnGroupHeaderProps { + /* supplied from the groupHeaderHeight */ + height: number; + + /* supplied from the Column */ + width: number; +} + +/** + * Component that defines the attributes of a table column group. + */ +export interface ColumnGroupProps extends React.ClassAttributes { + /** + * The horizontal alignment of the table cell content. + */ + align?: 'left' | 'center' | 'right'; + + /** + * Controls if the column group is fixed when scrolling in the X axis. + * + * defaultValue: false + */ + fixed?: boolean; + + /** + * This is the header cell for this column group. + * This can either be a string or a React element. Passing in a string + * will render a default footer cell with that string. By default, the React + * element passed in can expect to receive the following props: + * + * ``` + * props: { + * height: number // (supplied from the groupHeaderHeight) + * width: number // (supplied from the Column) + * } + * ``` + * + * Because you are passing in your own React element, you can feel free to + * pass in whatever props you may want or need. + * + * You can also pass in a function that returns a react elemnt, with the + * props object above passed in as the first parameter. + */ + header?: string | React.ReactElement | ((props: ColumnGroupHeaderProps) => (string | React.ReactElement)); +} + +export class ColumnGroup extends React.Component { +} + +/** + * Component that handles default cell layout and styling. + * + * All props unless specified below will be set onto the top level `div` + * rendered by the cell. + * + * Example usage via from a `Column`: + * ``` + * const MyColumn = ( + * ( + * + * Cell number: {rowIndex} + * + * )} + * width={100} + * /> + * ); + * ``` + */ +export interface CellProps extends React.HTMLAttributes { + /** + * Outer height of the cell. + */ + height?: number; + + /** + * Outer width of the cell. + */ + width?: number; + + /** + * Optional prop that if specified on the `Column` will be passed to the + * cell. It can be used to uniquely identify which column is the cell is in. + */ + columnKey?: string | number; + + /** + * Optional prop that represents the rows index in the table. + * For the 'cell' prop of a Column, this parameter will exist for any + * cell in a row with a positive index. + * + * Below that entry point the user is welcome to consume or + * pass the prop through at their discretion. + */ + rowIndex?: number; +} + +export class Cell extends React.Component { +} diff --git a/types/fixed-data-table-2/tsconfig.json b/types/fixed-data-table-2/tsconfig.json new file mode 100644 index 0000000000..c548d5c369 --- /dev/null +++ b/types/fixed-data-table-2/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "fixed-data-table-2-tests.tsx" + ], + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx":"preserve", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/fixed-data-table-2/tslint.json b/types/fixed-data-table-2/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/fixed-data-table-2/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From 704b79a52d4024e138f49ed67e955c2b7f134d53 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 24 Nov 2017 09:37:47 +0000 Subject: [PATCH 145/639] Lodash: clamp: add overload for upper bound only --- types/lodash/index.d.ts | 10 ++++++++++ types/lodash/lodash-tests.ts | 2 ++ 2 files changed, 12 insertions(+) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index f038846d22..a21751543c 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -11535,6 +11535,10 @@ declare namespace _ { lower: number, upper: number ): number; + clamp( + number: number, + upper: number + ): number; } interface LoDashImplicitWrapper { @@ -11545,6 +11549,9 @@ declare namespace _ { lower: number, upper: number ): number; + clamp( + upper: number + ): number; } interface LoDashExplicitWrapper { @@ -11555,6 +11562,9 @@ declare namespace _ { lower: number, upper: number ): LoDashExplicitWrapper; + clamp( + upper: number + ): LoDashExplicitWrapper; } //_.inRange diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index e40569204d..4d41516307 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -9871,8 +9871,10 @@ namespace TestInClamp { let result: number; result = _.clamp(3, 2, 4); + result = _.clamp(3, 4); result = _(3).clamp(2, 4); + result = _(3).clamp(4); } { From 713261fb718e5175ad7b0fe87d98ca732057414f Mon Sep 17 00:00:00 2001 From: rbot <30998401+rk-7@users.noreply.github.com> Date: Fri, 24 Nov 2017 18:12:39 +0530 Subject: [PATCH 146/639] Fixing Travis issues. Reverting TypeScript version: 2.2. Updated Context interface. Since aws-lambda-mock-context depends on this (alexa-sdk) which has lower typescript version but alexa-sdk should ideally depend on i18next which has higher TS version. Removing i18next from "alexa-sdk" --- types/alexa-sdk/index.d.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 5f4f9cf6ff..a9c630269f 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -6,8 +6,8 @@ // Ben // rk-7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 -import { i18n } from "i18next"; +// TypeScript Version: 2.2 + export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; @@ -91,7 +91,7 @@ export interface Handler { emitWithState: any; state: any; handler: any; - i18n: i18n; + i18n: any; locale: any; event: RequestBody; attributes: any; @@ -104,8 +104,16 @@ export interface Handler { } export interface Context { - System: System; - AudioPlayer: AudioPlayer; + callbackWaitsForEmptyEventLoop: boolean; + logGroupName: string; + logStreamName: string; + functionName: string; + memoryLimitInMB: string; + functionVersion: string; + invokeid: string; + awsRequestId: string; + System?: System; + AudioPlayer?: AudioPlayer; } export interface Application { applicationId: string; From 45ff477173a281ddea1f2028f537806341850412 Mon Sep 17 00:00:00 2001 From: Neal Stewart Date: Fri, 24 Nov 2017 11:20:20 +0100 Subject: [PATCH 147/639] Extend MeasuredComponenttProps with type passed to withContentType --- types/react-measure/index.d.ts | 12 ++++--- types/react-measure/react-measure-tests.tsx | 35 ++++++++++++++++++--- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/types/react-measure/index.d.ts b/types/react-measure/index.d.ts index 6a06a04d37..945a49213a 100644 --- a/types/react-measure/index.d.ts +++ b/types/react-measure/index.d.ts @@ -6,7 +6,7 @@ import * as React from "react"; -type MeasurementType = "client" | "offset" | "scroll" | "bounds" | "margin"; +export type MeasurementType = "client" | "offset" | "scroll" | "bounds" | "margin"; interface TopLeft { readonly top: number; @@ -38,12 +38,14 @@ export interface ContentRect { entry?: any; } -export interface ChildrenOpts { +export interface MeasuredComponentProps { measureRef(ref: Element | null): void; measure(): void; contentRect: ContentRect; } +type MeasuredComponent = React.ComponentType; + export interface MeasureProps { client?: boolean; offset?: boolean; @@ -52,9 +54,11 @@ export interface MeasureProps { margin?: boolean; innerRef?(ref: Element | null): void; onResize?(contentRect: ContentRect): void; - children?(arg: ChildrenOpts): React.ReactElement; + children?: React.SFC; } -export declare function withContentRect(types: MeasurementType | MeasurementType[]): (fn: (arg: ChildrenOpts) => React.ReactElement) => React.ComponentClass; +export declare function withContentRect(types: ReadonlyArray | MeasurementType): + (fn: MeasuredComponent) => React.ComponentType; + declare class Measure extends React.Component> {} export default Measure; diff --git a/types/react-measure/react-measure-tests.tsx b/types/react-measure/react-measure-tests.tsx index b467fd8caa..1e58ecbbbe 100644 --- a/types/react-measure/react-measure-tests.tsx +++ b/types/react-measure/react-measure-tests.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import Measure, { ContentRect, withContentRect } from "react-measure"; +import Measure, { ContentRect, withContentRect, MeasuredComponentProps, MeasurementType } from "react-measure"; class Test extends React.Component { render() { @@ -63,7 +63,26 @@ class Test2 extends React.Component { } } -function testHocComponent(): React.ComponentClass { +interface Props { + a: string; +} + +const TestFunctionalComponentWithProps: React.SFC = ({a, contentRect, measureRef}) => { + return ( +
{a}
+ ); +}; + +class TestClassComponentWithProps extends React.Component { + render() { + const {a, contentRect, measureRef} = this.props; + return ( +
{a}
+ ); + } +} + +function testHocComponent() { return withContentRect('bounds')(({measureRef, measure, contentRect}) => (
Some content here @@ -74,11 +93,17 @@ function testHocComponent(): React.ComponentClass { )); } -function testHocComponent2(): React.ComponentClass { - return withContentRect(['scroll', 'margin'])(({measureRef}) => ( +function testHocComponent2() { + return withContentRect(['scroll', 'margin'] as ReadonlyArray)(({measureRef}) => (
Some content here
)); } const HocComponent = testHocComponent(); -const el = ; +const el = ; + +const MeasuredFunctionalComponent = withContentRect('bounds')(TestFunctionalComponentWithProps); +const funcEl = ; + +const MeasuredClassComponent = withContentRect('bounds')(TestClassComponentWithProps); +const classEl = ; From cf5d3756ce7479dabdab00545ae06330b88be7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Fri, 24 Nov 2017 15:46:18 +0100 Subject: [PATCH 148/639] Moved the files under types folder --- {leaflet.heat => types/leaflet.heat}/index.d.ts | 0 {leaflet.heat => types/leaflet.heat}/leaflet.heat-tests.ts | 0 {leaflet.heat => types/leaflet.heat}/tsconfig.json | 0 {leaflet.heat => types/leaflet.heat}/tslint.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {leaflet.heat => types/leaflet.heat}/index.d.ts (100%) rename {leaflet.heat => types/leaflet.heat}/leaflet.heat-tests.ts (100%) rename {leaflet.heat => types/leaflet.heat}/tsconfig.json (100%) rename {leaflet.heat => types/leaflet.heat}/tslint.json (100%) diff --git a/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts similarity index 100% rename from leaflet.heat/index.d.ts rename to types/leaflet.heat/index.d.ts diff --git a/leaflet.heat/leaflet.heat-tests.ts b/types/leaflet.heat/leaflet.heat-tests.ts similarity index 100% rename from leaflet.heat/leaflet.heat-tests.ts rename to types/leaflet.heat/leaflet.heat-tests.ts diff --git a/leaflet.heat/tsconfig.json b/types/leaflet.heat/tsconfig.json similarity index 100% rename from leaflet.heat/tsconfig.json rename to types/leaflet.heat/tsconfig.json diff --git a/leaflet.heat/tslint.json b/types/leaflet.heat/tslint.json similarity index 100% rename from leaflet.heat/tslint.json rename to types/leaflet.heat/tslint.json From 9c46bbbdb2f4808b4e6ca28f1de8acd282522b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Fri, 24 Nov 2017 18:26:14 +0100 Subject: [PATCH 149/639] Fixed references to main leaflet definition --- types/leaflet.heat/index.d.ts | 2 +- types/leaflet.heat/leaflet.heat-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index 0fdc113ee9..c58921046a 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Önder Ceylan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// declare namespace L { type HeatLatLngTuple = [number, number, number]; diff --git a/types/leaflet.heat/leaflet.heat-tests.ts b/types/leaflet.heat/leaflet.heat-tests.ts index 7007bf0227..0e7a33fa50 100644 --- a/types/leaflet.heat/leaflet.heat-tests.ts +++ b/types/leaflet.heat/leaflet.heat-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmAttrib = '© OpenStreetMap contributors', From 6c0d935374856d65c74627775e52d552a26768e8 Mon Sep 17 00:00:00 2001 From: CBoland Date: Fri, 24 Nov 2017 14:45:00 -0600 Subject: [PATCH 150/639] Updated datatables.net for 1.10.10 Release Notes: https://cdn.datatables.net/1.10.10/ * Created a type for static column render functions. * Implemented $.fn.dataTable.render.text per release notes. * Implemented language.aria.paginate per release notes. * Added test/sample for handling column-visibility event with new parameter. * Implemented order.fixed() method per release notes. --- types/datatables.net/datatables.net-tests.ts | 32 ++++++++- types/datatables.net/index.d.ts | 71 +++++++++++++++++++- 2 files changed, 100 insertions(+), 3 deletions(-) diff --git a/types/datatables.net/datatables.net-tests.ts b/types/datatables.net/datatables.net-tests.ts index af722ab74f..e5cb5184fd 100644 --- a/types/datatables.net/datatables.net-tests.ts +++ b/types/datatables.net/datatables.net-tests.ts @@ -21,7 +21,13 @@ const lang: DataTables.LanguageSettings = { }, aria: { sortAscending: ": activate to sort column ascending", - sortDescending: ": activate to sort column descending" + sortDescending: ": activate to sort column descending", + paginate: { + first: "First", + last: "Last", + next: "Next", + previous: "Previous" + } } }; @@ -98,6 +104,7 @@ let col: DataTables.ColumnSettings = { orderable: true, orderData: 10, orderDataType: "dom-checkbox", + orderFixed: [[0, 'asc'], [1, 'desc']], orderSequence: ['asc', 'desc'], render: 1, searchable: true, @@ -118,6 +125,20 @@ col = { data: colDataFunc, render: colRenderFunc, }; +col = { + data: "salary", + render: $.fn.dataTable.render.number('\'', '.', 0, '$'), +}; +col = { + data: "url", + render: $.fn.dataTable.render.text(), +}; +col = { + orderFixed: { + pre: [[0, 'asc'], [1, 'desc']], + post: [[0, 'asc'], [1, 'desc']] + } +}; //#endregion "Column" @@ -135,6 +156,7 @@ let colDef: DataTables.ColumnDefsSettings = { orderable: true, orderData: 10, orderDataType: "dom-checkbox", + orderFixed: [[0, 'asc'], [1, 'desc']], orderSequence: ['asc', 'desc'], render: 1, searchable: true, @@ -353,6 +375,9 @@ let order_set = dt.order([0, "asc"]); order_set = dt.order([0, "asc"], [1, "desc"]); // TODO: Fíx that order_set = dt.order([[0, "asc"], [1, "desc"]]); +const fixed_get: DataTables.ObjectOrderFixed = dt.order.fixed(); +const fixed_set: DataTables.Api = dt.order.fixed({pre: [0, "asc"], post: [1, "desc"]}); + const orderListerner = order_set.order.listener("node", 1, () => { }); const page_get = dt.page(); @@ -791,6 +816,11 @@ dt.columns.adjust().draw(false); // adjust column sizing and redraw dt.columns().every(() => { }); dt.columns().every((colIdx, tableLoop, colLoop) => { }); +$('#example').on('column-visibility.dt', (e: object, settings: DataTables.Settings, column: number, state: boolean, recalc: boolean | undefined) => { + const widthRecalced = (recalc || recalc === undefined); + console.log(`Column ${column} has changed to ${(state ? 'visible' : 'hidden')} and width ${(widthRecalced) ? 'was' : 'was not'} recalculated.`); +}); + //#endregion "Methods-Column" //#region "Methods-Row" diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index 7cd4b8589b..cdddc98789 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for JQuery DataTables 1.10 // Project: http://www.datatables.net -// Definitions by: Kiarash Ghiaseddin , Omid Rad , Armin Sander +// Definitions by: Kiarash Ghiaseddin +// Omid Rad +// Armin Sander +// Craig Boland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -329,6 +332,16 @@ declare namespace DataTables { (order?: Array<(string | number)> | Array>): Api; (order: Array<(string | number)>, ...args: any[]): Api; + /** + * Get the fixed ordering that is applied to the table. If there is more than one table in the API's context, + * the ordering of the first table will be returned only (use table() if you require the ordering of a different table in the API's context). + */ + fixed(): ObjectOrderFixed; + /** + * Set the table's fixed ordering. Note this doesn't actually perform the order, but rather queues it up - use draw() to perform the ordering. + */ + fixed(order: ObjectOrderFixed): Api; + /** * Add an ordering listener to an element, for a given column. * @@ -1085,6 +1098,14 @@ declare namespace DataTables { */ isDataTable(table: string): boolean; + /** + * Helpers for `columns.render`. + * + * The options defined here can be used with the `columns.render` initialisation + * option to provide a display renderer. + */ + render: StaticRenderFunctions; + /** * Get all DataTable tables that have been initialised - optionally you can select to get only currently visible tables and / or retrieve the tables as API instances. * @@ -1125,6 +1146,42 @@ declare namespace DataTables { ext: ExtSettings; } + interface ObjectColumnRender { + display(d?: number | string | object): string | object; + } + + interface ObjectOrderFixed { + /** + * Two-element array: + * 0: Column index to order upon. + * 1: Direction so order to apply ("asc" for ascending order or "desc" for descending order). + */ + pre?: any[]; + /** + * Two-element array: + * 0: Column index to order upon. + * 1: Direction so order to apply ("asc" for ascending order or "desc" for descending order). + */ + post?: any[]; + } + + interface StaticRenderFunctions { + /** + * Will format numeric data (defined by `columns.data`) for display, retaining the original unformatted data for sorting and filtering. + * + * @param thousands Thousands grouping separator. + * @param decimal Decimal point indicator. + * @param precision Integer number of decimal points to show. + * @param prefix Prefix (optional). + * @param postfix Postfix (/suffix) (optional). + */ + number(thousands: string, decimal: string, precision: number, prefix?: string, postfix?: string): ObjectColumnRender; + /** + * Escape HTML to help prevent XSS attacks. It has no optional parameters. + */ + text(): ObjectColumnRender; + } + interface StaticUtilFunctions { /** * Escape special characters in a regular expression string. Since: 1.10.4 @@ -1563,6 +1620,15 @@ declare namespace DataTables { */ orderDataType?: string; + /** + * Ordering to always be applied to the table. Since 1.10 + * + * Array type is prefix ordering only and is a two-element array: + * 0: Column index to order upon. + * 1: Direction so order to apply ("asc" for ascending order or "desc" for descending order). + */ + orderFixed?: any[] | ObjectOrderFixed; + /** * Order direction application sequence. Since: 1.10 */ @@ -1571,7 +1637,7 @@ declare namespace DataTables { /** * Render (process) the data for use in the table. Since: 1.10 */ - render?: number | string | ObjectColumnData | FunctionColumnRender; + render?: number | string | ObjectColumnData | FunctionColumnRender | ObjectColumnRender; /** * Enable or disable filtering on the data in this column. Since: 1.10 @@ -1727,6 +1793,7 @@ declare namespace DataTables { interface LanguageAriaSettings { sortAscending: string; sortDescending: string; + paginate?: LanguagePaginateSettings; } //#endregion "language-settings" From 2165db7ccda31ac29f79b330d3747a412afb5457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 10:18:08 +0100 Subject: [PATCH 151/639] Set references to global leaflet definition Added package.json Removed optional flags from methods --- types/leaflet.heat/index.d.ts | 8 ++++---- types/leaflet.heat/leaflet.heat-tests.ts | 2 -- types/leaflet.heat/package.json | 5 +++++ types/leaflet.heat/tslint.json | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 types/leaflet.heat/package.json diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index c58921046a..787d15fa58 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Önder Ceylan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// declare namespace L { type HeatLatLngTuple = [number, number, number]; @@ -22,9 +22,9 @@ declare namespace L { } interface HeatLayer extends TileLayer { - setOptions?(options: HeatMapOptions): HeatLayer; - addLatLng?(latlng: LatLng | HeatLatLngTuple): HeatLayer; - setLatLngs?(latlngs: Array): HeatLayer; + setOptions(options: HeatMapOptions): HeatLayer; + addLatLng(latlng: LatLng | HeatLatLngTuple): HeatLayer; + setLatLngs(latlngs: Array): HeatLayer; } function heatLayer(latlngs: Array, options: HeatMapOptions): HeatLayer; diff --git a/types/leaflet.heat/leaflet.heat-tests.ts b/types/leaflet.heat/leaflet.heat-tests.ts index 0e7a33fa50..aead8f1960 100644 --- a/types/leaflet.heat/leaflet.heat-tests.ts +++ b/types/leaflet.heat/leaflet.heat-tests.ts @@ -1,5 +1,3 @@ -/// -/// const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmAttrib = '© OpenStreetMap contributors', osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), diff --git a/types/leaflet.heat/package.json b/types/leaflet.heat/package.json new file mode 100644 index 0000000000..1931c5cea0 --- /dev/null +++ b/types/leaflet.heat/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@types/leaflet": "^1.2.2" + } +} diff --git a/types/leaflet.heat/tslint.json b/types/leaflet.heat/tslint.json index 3db14f85ea..f93cf8562a 100644 --- a/types/leaflet.heat/tslint.json +++ b/types/leaflet.heat/tslint.json @@ -1 +1,3 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json" +} From 6022290bae8e809cac42688211cbece29e5c2e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 10:22:35 +0100 Subject: [PATCH 152/639] Updated package.json --- types/leaflet.heat/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/leaflet.heat/package.json b/types/leaflet.heat/package.json index 1931c5cea0..62b4195c6f 100644 --- a/types/leaflet.heat/package.json +++ b/types/leaflet.heat/package.json @@ -1,5 +1,6 @@ { "dependencies": { - "@types/leaflet": "^1.2.2" + "leaflet": "^1.2.0", + "leaflet.heat": "^0.2.0" } } From 601baf65a56ec1b00b6bbf1687b5797ad52d7403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 10:29:07 +0100 Subject: [PATCH 153/639] Removed package.json --- types/leaflet.heat/package.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 types/leaflet.heat/package.json diff --git a/types/leaflet.heat/package.json b/types/leaflet.heat/package.json deleted file mode 100644 index 62b4195c6f..0000000000 --- a/types/leaflet.heat/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dependencies": { - "leaflet": "^1.2.0", - "leaflet.heat": "^0.2.0" - } -} From 8c9eee81fd9e88aa54ede70628c5c15c90a1b1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 10:43:07 +0100 Subject: [PATCH 154/639] Removed comment for the package name --- types/leaflet.heat/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index 787d15fa58..672ad41760 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -1,4 +1,3 @@ -// Type definitions for Leaflet.heat v0.2.0 // Project: https://github.com/Leaflet/Leaflet.heat // Definitions by: Önder Ceylan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 33996a0dc0586258c72e3057a0918856908e04c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 10:47:11 +0100 Subject: [PATCH 155/639] Changed comment for the package name --- types/leaflet.heat/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index 672ad41760..eafcb00e6f 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -1,3 +1,4 @@ +// Type definitions for Leaflet.heat // Project: https://github.com/Leaflet/Leaflet.heat // Definitions by: Önder Ceylan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 10dbe17f78505e574f5a554317ee4ee6b135d12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 10:50:57 +0100 Subject: [PATCH 156/639] Added dependent TypeScript version --- types/leaflet.heat/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index eafcb00e6f..66464fcb08 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Leaflet.heat +// Type definitions for Leaflet.heat v0.2.0 // Project: https://github.com/Leaflet/Leaflet.heat // Definitions by: Önder Ceylan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// From 693a778e7ed5b98627c1884c6cc9a888ecedd8c6 Mon Sep 17 00:00:00 2001 From: Ben Stevens Date: Sat, 25 Nov 2017 12:06:31 +0000 Subject: [PATCH 157/639] add element.destroy to stripe-v3 --- types/stripe-v3/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/stripe-v3/index.d.ts b/types/stripe-v3/index.d.ts index db8257401c..6d499a73d8 100644 --- a/types/stripe-v3/index.d.ts +++ b/types/stripe-v3/index.d.ts @@ -185,6 +185,7 @@ declare namespace stripe { blur(): void; clear(): void; unmount(): void; + destroy(): void; update(options: ElementsOptions): void; } From f0795a3470f96fe20ed3bde5a05f1048f7337601 Mon Sep 17 00:00:00 2001 From: Abdessamad MOUHASSINE Date: Sat, 25 Nov 2017 12:22:20 +0000 Subject: [PATCH 158/639] Add missing exports Add `normalize` and `match` functions --- types/type-is/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/type-is/index.d.ts b/types/type-is/index.d.ts index 93c70aa4a3..e3dd9da1fc 100644 --- a/types/type-is/index.d.ts +++ b/types/type-is/index.d.ts @@ -13,7 +13,9 @@ declare function typeIs(request: IncomingMessage, types: string[]): string | fal declare function typeIs(request: IncomingMessage, ...types: string[]): string | false | null; declare namespace typeIs { + function normalize (type: string): string | false; function hasBody(request: IncomingMessage): boolean; function is(mediaType: string, types: string[]): string | false; function is(mediaType: string, ...types: string[]): string | false; + function mimeMatch (expected: false | string, actual: string): boolean; } From e6862574f957bd1e5400f670d41db011bf0ce8f8 Mon Sep 17 00:00:00 2001 From: Abdessamad MOUHASSINE Date: Sat, 25 Nov 2017 13:07:40 +0000 Subject: [PATCH 159/639] Fix tslint issue --- types/type-is/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/type-is/index.d.ts b/types/type-is/index.d.ts index e3dd9da1fc..9fffd0bb9a 100644 --- a/types/type-is/index.d.ts +++ b/types/type-is/index.d.ts @@ -13,9 +13,9 @@ declare function typeIs(request: IncomingMessage, types: string[]): string | fal declare function typeIs(request: IncomingMessage, ...types: string[]): string | false | null; declare namespace typeIs { - function normalize (type: string): string | false; + function normalize(type: string): string | false; function hasBody(request: IncomingMessage): boolean; function is(mediaType: string, types: string[]): string | false; function is(mediaType: string, ...types: string[]): string | false; - function mimeMatch (expected: false | string, actual: string): boolean; + function mimeMatch(expected: false | string, actual: string): boolean; } From 90e335c7e86629de863f8ac172cf188fb728f4f9 Mon Sep 17 00:00:00 2001 From: rk-7 <30998401+rk-7@users.noreply.github.com> Date: Sat, 25 Nov 2017 19:44:54 +0530 Subject: [PATCH 160/639] alexa-sdk: Reverted the ConfirmationStatuses and DialogStates enum values to types. Added more types. --- types/alexa-sdk/index.d.ts | 116 +++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 64 deletions(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index a9c630269f..33fdc6dd7b 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -11,6 +11,18 @@ export function handler(event: RequestBody, context: Context, callback?: (err: any, response: any) => void): AlexaObject; export function CreateStateHandler(state: string, obj: any): any; export let StateString: string; +export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED"; +export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED"; +export type ListItemObjectStatus = "active" | "completed"; +export type ListObjectState = "active" | "archived"; +export type ImageSourceSize = "X_SMALL" | "SMALL" | "MEDIUM" | "LARGE" | "X_LARGE"; +export type TemplateBackButtonVisibility = "HIDDEN" | "VISIBLE"; +export type TemplateType = "BodyTemplate1" | "BodyTemplate2" | "BodyTemplate3" | "BodyTemplate6" | "BodyTemplate6" | "ListTemplate1" | "ListTemplate2"; +export type AudioPlayerActivity = "IDLE" | "PAUSED" | "PLAYING" | "BUFFER_UNDERRUN" | "FINISHED" | "STOPPED"; +export type CardType = "Standard" | "Simple" | "LinkAccount" | "AskForPermissionsConsent"; +export type HintType = "PlainText"; +export type DirectiveTypes = "AudioPlayer.Play" | "AudioPlayer.Stop" | "AudioPlayer.ClearQueue" | "Display.RenderTemplate" | "Hint" | "VideoApp.Launch"; +export type TextContentType = "PlainText" | "RichText"; //#region Types export interface CardImage { @@ -28,10 +40,14 @@ export interface ImageSource { widthPixels?: number; heightPixels?: number; /** - * Possible values: 'X_SMALL' | 'SMALL' | 'MEDIUM' | 'LARGE' | 'X_LARGE' - * Recommended size respectively (in px): 480 x 320 | 720 x 480 | 960 x 640 | 1200 x 800 | 1920 x 1280 + * Recommended sizes for the following dimensions (in px): + * 480 x 320 for X_SMALL, + * 720 x 480 for SMALL, + * 960 x 640 for MEDIUM, + * 1200 x 800 for LARGE, + * 1920 x 1280 for X_LARGE */ - size?: string; + size?: ImageSourceSize; } export interface Image { contentDescription: string; @@ -51,18 +67,19 @@ export interface ListItem { token: string; textContent?: TextContent; } + export interface Template { title?: string; token: string; backgroundImage?: Image; /** - * Possible values 'HIDDEN' | 'VISIBLE' + * Visibility of the back button. */ - backButton?: string; + backButton?: TemplateBackButtonVisibility; /** - * Possible values 'BodyTemplate1' | 'BodyTemplate2'| 'BodyTemplate3'| 'BodyTemplate6'| 'ListTemplate1'| 'ListTemplate2' + * Template type. */ - type: string; + type: TemplateType; image?: Image; listItems?: ListItem[]; } @@ -130,9 +147,9 @@ export interface AudioPlayer { token: string; offsetInMilliseconds: number; /** - * Possible values: 'IDLE'|'PAUSED'|'PLAYING'|'BUFFER_UNDERRUN'|'FINISHED'|'STOPPED' + * Player activity */ - playerActivity: string; + playerActivity: AudioPlayerActivity; } export interface RequestBody { version: string; @@ -162,10 +179,7 @@ export interface Permissions { export interface LaunchRequest extends Request { } export interface IntentRequest extends Request { - /** - * Possible values: 'STARTED'| 'IN_PROGRESS'| 'COMPLETED' - */ - dialogState?: string; + dialogState?: DialogStates; intent?: Intent; } @@ -204,20 +218,14 @@ export interface Resolutions { } export interface SlotValue { - /** - * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' - */ - confirmationStatus?: string; + confirmationStatus?: ConfirmationStatuses; name: string; value?: any; resolutions?: Resolutions; } export interface Intent { - /** - * Possible values: 'NONE'| 'DENIED'| 'CONFIRMED' - */ - confirmationStatus?: string; + confirmationStatus?: ConfirmationStatuses; name: string; slots: Record; } @@ -243,7 +251,7 @@ export interface OutputSpeech { } export interface Card { - type: "Simple" | "Standard" | "LinkAccount"; + type: CardType; title?: string; content?: string; text?: string; @@ -253,31 +261,7 @@ export interface Card { export interface Reprompt { outputSpeech: OutputSpeech; } -export const CARD_TYPES: { - STANDARD: 'Standard', - SIMPLE: 'Simple', - LINK_ACCOUNT: 'LinkAccount', - ASK_FOR_PERMISSIONS_CONSENT: 'AskForPermissionsConsent' -}; -export const HINT_TYPES: { - PLAIN_TEXT: 'PlainText' -}; - -export const DIRECTIVE_TYPES: { - AUDIOPLAYER: { - PLAY: 'AudioPlayer.Play', - STOP: 'AudioPlayer.Stop', - CLEAR_QUEUE: 'AudioPlayer.ClearQueue' - }, - DISPLAY: { - RENDER_TEMPLATE: 'Display.RenderTemplate' - }, - HINT: 'Hint', - VIDEOAPP: { - LAUNCH: 'VideoApp.Launch' - } -}; export interface ApiClientOptions { hostname: string; port: string; @@ -307,9 +291,8 @@ export interface ListItemObject { value: string; /** * item status - * Possible values: "active" or "completed" */ - status?: string; + status?: ListItemObjectStatus; /** * item version (Positive integer | string) */ @@ -341,9 +324,10 @@ export interface ListObject { */ name: string; /** + * state * "active" or "archived" (Enum) */ - state?: string; + state?: ListObjectState; /** * Possibly status of the list (or state?) * Fetched from commit eebba0d at https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/ @@ -359,15 +343,15 @@ export interface ListObject { * href is lint to the items having certain status. * The status can be "active" or "completed". */ - statusMap: { href: string; status: string; }; + statusMap: { href: string; status: ListItemObjectStatus; }; /** * Items that belong to this list. */ items: ListItemObject[]; } //#endregion -//#region templateBuilders +//#region templateBuilders /** * Generates templates for Echo Show device. */ @@ -408,7 +392,7 @@ export namespace templateBuilders { /** * Sets the backButton behavior - * @param backButtonBehavior 'VISIBLE' or 'HIDDEN' + * @param backButtonBehavior "VISIBLE" or "HIDDEN" * @returns TemplateBuilder */ setBackButtonBehavior(backButtonBehavior: string): T; @@ -558,6 +542,7 @@ export namespace templateBuilders { } } //#endregion + //#region services export namespace services { interface ApiClient { @@ -642,7 +627,7 @@ export namespace services { constructor(apiClient: ApiClient); /** - * Set apiEndpoint address, default is 'https://api.amazonalexa.com' + * Set apiEndpoint address, default is "https://api.amazonalexa.com" * @param apiEndpoint apiEndpoint * @returns void */ @@ -672,11 +657,11 @@ export namespace services { /** * Retrieve list metadata including the items in the list with requested status * @param listId unique Id associated with the list - * @param itemStatus itemsStatus can be either 'active' or 'completed' + * @param itemStatus itemsStatus can be either "active" or "completed" * @param token bearer token for list management permission * @returns Promise */ - getList(listId: string, itemStatus: string, token: string): Promise; + getList(listId: string, itemStatus: ListItemObjectStatus, token: string): Promise; /** * Update a custom list. Only the list name or state can be updated @@ -734,6 +719,7 @@ export namespace services { } } //#endregion + //#region ResponseBuilder /** * Responsible for building JSON responses as per the Alexa skills kit interface @@ -842,7 +828,7 @@ export class ResponseBuilder { * @param hintType (optional) Default value : PlainText * @returns ResponseBuilder */ - hint(hintText: string, hintType: string): ResponseBuilder; + hint(hintText: string, hintType: HintType): ResponseBuilder; /** * Creates a VideoApp play directive to play a video @@ -855,6 +841,7 @@ export class ResponseBuilder { playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; } //#endregion + //#region directives export namespace directives { class VoicePlayerSpeakDirective { @@ -869,6 +856,7 @@ export namespace directives { } } //#endregion + //#region utils export namespace utils { namespace ImageUtils { @@ -881,7 +869,7 @@ export namespace utils { * By default, for Echo Show, size takes the value X_SMALL. If the other size values are included, * then the order of precedence for displaying images begins with X_LARGE and proceeds downward, * which means that larger images will be downscaled for display on Echo Show if provided. - * example : ImageUtils.makeImage('https://url/to/my/img.png', 300, 400, 'SMALL', 'image description') + * example : ImageUtils.makeImage("https://url/to/my/img.png", 300, 400, "SMALL", "image description") * @param url url of the image * @param widthPixels (optional) width of the image in pixels * @param heightPixels (optional) height of the image in pixels @@ -889,7 +877,7 @@ export namespace utils { * @param description text used to describe the image in a screen reader * @returns Image */ - function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: string, description?: string): Image; + function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: ImageSourceSize, description?: string): Image; /** * Creates an image object with a multiple sources, source images are provided as an array of image objects * These images may be in either JPEG or PNG formats, with the appropriate file extensions. @@ -901,16 +889,16 @@ export namespace utils { * which means that larger images will be downscaled for display on Echo Show if provided. * example : * let imgArr = [ - * { 'https://url/to/my/small.png', 300, 400, 'SMALL' }, - * { 'https://url/to/my/large.png', 900, 1200, 'LARGE' }, + * { "https://url/to/my/small.png", 300, 400, "SMALL" }, + * { "https://url/to/my/large.png", 900, 1200, "LARGE" }, * ] - * ImageUtils.makeImage(imgArr, 'image description') + * ImageUtils.makeImage(imgArr, "image description") * * @param imgArr Array of Image * @param description text used to describe the image in a screen reader * @returns Image */ - function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: string }>, description: string): Image; + function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: ImageSourceSize }>, description: string): Image; } /** * Utility methods for building TextField objects @@ -937,8 +925,8 @@ export namespace utils { * @param tertiaryText tertiary Text * @returns TextContent */ - function makeTextContent(primaryText: { type: string, text: string }, - secondaryText: { type: string, text: string }, tertiaryText: { type: string, text: string }): TextContent; + function makeTextContent(primaryText: { type: TextContentType, text: string }, + secondaryText: { type: TextContentType, text: string }, tertiaryText: { type: TextContentType, text: string }): TextContent; } } //#endregion From b5bec704d9c2dcb0f513fbb23fac2423405aafc1 Mon Sep 17 00:00:00 2001 From: tai2 Date: Sun, 26 Nov 2017 00:29:21 +0900 Subject: [PATCH 161/639] [ignore-styles] new package --- types/ignore-styles/ignore-styles-tests.ts | 15 ++++++++++++++ types/ignore-styles/index.d.ts | 24 ++++++++++++++++++++++ types/ignore-styles/tsconfig.json | 23 +++++++++++++++++++++ types/ignore-styles/tslint.json | 1 + 4 files changed, 63 insertions(+) create mode 100644 types/ignore-styles/ignore-styles-tests.ts create mode 100644 types/ignore-styles/index.d.ts create mode 100644 types/ignore-styles/tsconfig.json create mode 100644 types/ignore-styles/tslint.json diff --git a/types/ignore-styles/ignore-styles-tests.ts b/types/ignore-styles/ignore-styles-tests.ts new file mode 100644 index 0000000000..1a7dbc74c1 --- /dev/null +++ b/types/ignore-styles/ignore-styles-tests.ts @@ -0,0 +1,15 @@ +import register, { DEFAULT_EXTENSIONS, oldHandlers, noOp, restore } from 'ignore-styles'; + +register(['.css'], (module, filename) => {}); // $ExpectType void +register(['.css']); // $ExpectType void +register(undefined, (module, filename) => {}); // $ExpectType void +register([1], (module, filename) => {}); // $ExpectError +register(['.css'], 1); // $ExpectError + +DEFAULT_EXTENSIONS[0]; // $ExpectType string + +oldHandlers['.css']; // $ExpectType Handler + +noOp(); // $ExpectType void + +restore(); // $ExpectType void diff --git a/types/ignore-styles/index.d.ts b/types/ignore-styles/index.d.ts new file mode 100644 index 0000000000..2eab90b591 --- /dev/null +++ b/types/ignore-styles/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for ignore-styles 5.0 +// Project: https://github.com/bkonkle/ignore-styles +// Definitions by: Taiju Muto +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// + +export type Handler = (m: NodeModule, filename: string) => any; + +export const DEFAULT_EXTENSIONS: string[]; + +export let oldHandlers: { + [ext: string]: Handler +}; + +export function noOp(): void; + +export function restore(): void; + +export default function register( + extensions?: string[], + handler?: Handler +): void; diff --git a/types/ignore-styles/tsconfig.json b/types/ignore-styles/tsconfig.json new file mode 100644 index 0000000000..aed3487cf4 --- /dev/null +++ b/types/ignore-styles/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ignore-styles-tests.ts" + ] +} diff --git a/types/ignore-styles/tslint.json b/types/ignore-styles/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ignore-styles/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 604e6a343e6881536ad7a7d855a0a42e06d19354 Mon Sep 17 00:00:00 2001 From: Soner Koksal Date: Sat, 25 Nov 2017 19:08:27 +0300 Subject: [PATCH 162/639] removed socket interface as it's already part of es6 type definitions --- types/sockjs-client/index.d.ts | 17 +++-------------- types/sockjs-client/sockjs-client-tests.ts | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/types/sockjs-client/index.d.ts b/types/sockjs-client/index.d.ts index 96d783aa98..8768e3755a 100644 --- a/types/sockjs-client/index.d.ts +++ b/types/sockjs-client/index.d.ts @@ -9,9 +9,9 @@ export = SockJS; export as namespace SockJS; declare const SockJS: { - new (url: string, _reserved?: any, options?: SockJS.Options): SockJS.Socket; - (url: string, _reserved?: any, options?: SockJS.Options): SockJS.Socket; - prototype: SockJS.Socket; + new (url: string, _reserved?: any, options?: SockJS.Options): WebSocket; + (url: string, _reserved?: any, options?: SockJS.Options): WebSocket; + prototype: WebSocket; CONNECTING: SockJS.CONNECTING; OPEN: SockJS.OPEN; CLOSING: SockJS.CLOSING; @@ -49,15 +49,4 @@ declare namespace SockJS { sessionId?: number | SessionGenerator; transports?: string | string[]; } - - interface Socket extends EventTarget { - readyState: State; - protocol: string; - url: string; - onopen(e: OpenEvent): any; - onclose(e: CloseEvent): any; - onmessage(e: MessageEvent): any; - send(data: any): void; - close(code?: number, reason?: string): void; - } } diff --git a/types/sockjs-client/sockjs-client-tests.ts b/types/sockjs-client/sockjs-client-tests.ts index c7c4ae1daa..591cd98603 100644 --- a/types/sockjs-client/sockjs-client-tests.ts +++ b/types/sockjs-client/sockjs-client-tests.ts @@ -43,5 +43,4 @@ sockJs.close(100, 'reason'); sockJs.close(200); sockJs.close(); -type MySocket = SockJS.Socket; type MessageEvent = SockJS.MessageEvent; From adf67a1d500d1b0f2a38b3bc2a855170358ffc0b Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 25 Nov 2017 17:13:01 +0000 Subject: [PATCH 163/639] Updates for Apple Pay JS version 3 Update the type definitions for Apple Pay JS version 3. --- types/applepayjs/applepayjs-tests.ts | 122 ++++++++- types/applepayjs/index.d.ts | 361 ++++++++++++++++++++++++--- 2 files changed, 436 insertions(+), 47 deletions(-) diff --git a/types/applepayjs/applepayjs-tests.ts b/types/applepayjs/applepayjs-tests.ts index 505dbd2daf..de58dd30cd 100644 --- a/types/applepayjs/applepayjs-tests.ts +++ b/types/applepayjs/applepayjs-tests.ts @@ -20,6 +20,70 @@ describe("ApplePaySession", () => { break; } }); + it("the contact fields are defined", () => { + const contacts = [ + ApplePayJS.ApplePayContactField.email, + ApplePayJS.ApplePayContactField.name, + ApplePayJS.ApplePayContactField.phone, + ApplePayJS.ApplePayContactField.phoneticName, + ApplePayJS.ApplePayContactField.postalAddress + ]; + }); + it("the error codes are defined", () => { + const errorCodes = [ + ApplePayJS.ApplePayErrorCode.addressUnserviceable, + ApplePayJS.ApplePayErrorCode.billingContactInvalid, + ApplePayJS.ApplePayErrorCode.shippingContactInvalid, + ApplePayJS.ApplePayErrorCode.unknown + ]; + }); + it("the error contact fields are defined", () => { + const contacts = [ + ApplePayJS.ApplePayErrorContactField.addressLines, + ApplePayJS.ApplePayErrorContactField.administrativeArea, + ApplePayJS.ApplePayErrorContactField.country, + ApplePayJS.ApplePayErrorContactField.countryCode, + ApplePayJS.ApplePayErrorContactField.emailAddress, + ApplePayJS.ApplePayErrorContactField.locality, + ApplePayJS.ApplePayErrorContactField.name, + ApplePayJS.ApplePayErrorContactField.phoneNumber, + ApplePayJS.ApplePayErrorContactField.phoneticName, + ApplePayJS.ApplePayErrorContactField.postalAddress, + ApplePayJS.ApplePayErrorContactField.postalCode, + ApplePayJS.ApplePayErrorContactField.subAdministrativeArea, + ApplePayJS.ApplePayErrorContactField.subLocality + ]; + }); + it("the line item types are defined", () => { + const errorCodes = [ + ApplePayJS.ApplePayLineItemType.final, + ApplePayJS.ApplePayLineItemType.pending + ]; + }); + it("the merchant capabilities are defined", () => { + const errorCodes = [ + ApplePayJS.ApplePayMerchantCapability.supports3DS, + ApplePayJS.ApplePayMerchantCapability.supportsCredit, + ApplePayJS.ApplePayMerchantCapability.supportsDebit, + ApplePayJS.ApplePayMerchantCapability.supportsEMV + ]; + }); + it("the payment method types are defined", () => { + const errorCodes = [ + ApplePayJS.ApplePayPaymentMethodType.credit, + ApplePayJS.ApplePayPaymentMethodType.debit, + ApplePayJS.ApplePayPaymentMethodType.prepaid, + ApplePayJS.ApplePayPaymentMethodType.store + ]; + }); + it("the shipping types are defined", () => { + const errorCodes = [ + ApplePayJS.ApplePayShippingType.delivery, + ApplePayJS.ApplePayShippingType.servicePickup, + ApplePayJS.ApplePayShippingType.shipping, + ApplePayJS.ApplePayShippingType.storePickup + ]; + }); it("can create a new instance", () => { const version = 1; const paymentRequest = { @@ -57,7 +121,7 @@ describe("ApplePaySession", () => { }); }); it("can call instance methods", () => { - const version = 1; + const version = 3; const paymentRequest = { countryCode: "US", currencyCode: "USD", @@ -66,7 +130,9 @@ describe("ApplePaySession", () => { "visa" ], merchantCapabilities: [ - "supports3DS" + "supports3DS", + ApplePayJS.ApplePayMerchantCapability.supportsCredit, + ApplePayJS.ApplePayMerchantCapability.supportsDebit ], total: { label: "My Store", @@ -80,8 +146,22 @@ describe("ApplePaySession", () => { session.completeMerchantValidation({ foo: "bar" }); + session.completePayment(ApplePaySession.STATUS_SUCCESS); + const authorizationResult = { + status: ApplePaySession.STATUS_FAILURE, + errors: [ + { + code: ApplePayJS.ApplePayErrorCode.addressUnserviceable, + contactField: ApplePayJS.ApplePayErrorContactField.postalCode, + message: "The specified postal code cannot be delivered to." + } + ] + }; + + session.completePayment(authorizationResult); + const total = { label: "Subtotal", type: "final", @@ -97,11 +177,12 @@ describe("ApplePaySession", () => { { label: "Free Shipping", amount: "0.00", - type: "pending" + type: ApplePayJS.ApplePayLineItemType.final }, { label: "Estimated Tax", - amount: "3.06" + amount: "3.06", + type: ApplePayJS.ApplePayLineItemType.pending } ]; @@ -120,17 +201,35 @@ describe("ApplePaySession", () => { session.completePaymentMethodSelection(total, lineItems); + const paymentUpdate = { + newTotal: total + }; + + session.completePaymentMethodSelection(paymentUpdate); + session.completeShippingContactSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, shippingMethods, total, lineItems); + const contactUpdate = { + newTotal: total + }; + + session.completeShippingContactSelection(contactUpdate); + session.completeShippingMethodSelection( ApplePaySession.STATUS_SUCCESS, total, lineItems); + const shippingUpdate = { + newTotal: total + }; + + session.completeShippingMethodSelection(shippingUpdate); + session.oncancel = (event: ApplePayJS.Event): void => { event.cancelBubble = true; }; @@ -175,7 +274,7 @@ describe("ApplePayPaymentRequest", () => { merchantCapabilities: [ "supports3DS", "supportsCredit", - "supportsDebit" + ApplePayJS.ApplePayMerchantCapability.supportsDebit ], supportedNetworks: [ "amex", @@ -197,11 +296,15 @@ describe("ApplePayPaymentRequest", () => { familyName: "Patel", givenName: "Ravi", phoneNumber: "(408) 555-5555", + phoneticFamilyName: "Patel", + phoneticGivenName: "Ravi", addressLines: [ "1 Infinite Loop" ], locality: "Cupertino", + subLocality: "", administrativeArea: "CA", + subAdministrativeArea: "", postalCode: "95014", country: "United States", countryCode: "US" @@ -226,14 +329,14 @@ describe("ApplePayPaymentRequest", () => { paymentRequest.requiredBillingContactFields = [ "postalAddress", - "name" + ApplePayJS.ApplePayContactField.name ]; paymentRequest.requiredShippingContactFields = [ "postalAddress", "name", "phone", - "email" + ApplePayJS.ApplePayContactField.name ]; paymentRequest.shippingContact = { @@ -241,11 +344,15 @@ describe("ApplePayPaymentRequest", () => { familyName: "Patel", givenName: "Ravi", phoneNumber: "(408) 555-5555", + phoneticFamilyName: "Patel", + phoneticGivenName: "Ravi", addressLines: [ "1 Infinite Loop" ], locality: "Cupertino", + subLocality: "", administrativeArea: "CA", + subAdministrativeArea: "", postalCode: "95014", country: "United States", countryCode: "US" @@ -265,5 +372,6 @@ describe("ApplePayPaymentRequest", () => { ]; paymentRequest.shippingType = "storePickup"; + paymentRequest.shippingType = ApplePayJS.ApplePayShippingType.delivery; }); }); diff --git a/types/applepayjs/index.d.ts b/types/applepayjs/index.d.ts index f705a4fad2..112fb569ba 100644 --- a/types/applepayjs/index.d.ts +++ b/types/applepayjs/index.d.ts @@ -4,23 +4,23 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** - * A session object for managing the payment process on the web. + * ApplePaySession is the entry point for Apple Pay on the web. */ declare class ApplePaySession extends EventTarget { /** - * Creates a new instance of the ApplePaySession class. - * @param version - The version of the ApplePay JS API you are using. - * @param paymentRequest - An ApplePayPaymentRequest object that contains the information that is displayed on the Apple Pay payment sheet. + * The entry point for Apple Pay on the web. + * @param version - The version number of the ApplePay JS API you are using. The current API version number is 3. + * @param paymentRequest - An ApplePayPaymentRequest object that contains the information to be displayed on the Apple Pay payment sheet. */ constructor(version: number, paymentRequest: ApplePayJS.ApplePayPaymentRequest); /** - * A callback function that is automatically called when the payment UI is dismissed with an error. + * A callback function that is automatically called when the payment UI is dismissed. */ oncancel: (event: ApplePayJS.Event) => void; /** - * A callback function that is automatically called when the user has authorized the Apple Pay payment, typically via TouchID. + * A callback function that is automatically called when the user has authorized the Apple Pay payment with Touch ID, Face ID, or passcode. */ onpaymentauthorized: (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => void; @@ -45,28 +45,28 @@ declare class ApplePaySession extends EventTarget { onvalidatemerchant: (event: ApplePayJS.ApplePayValidateMerchantEvent) => void; /** - * Indicates whether or not the device supports Apple Pay. + * Indicates whether the device supports Apple Pay. * @returns true if the device supports making payments with Apple Pay; otherwise, false. */ static canMakePayments(): boolean; /** - * Indicates whether or not the device supports Apple Pay and if the user has an active card in Wallet. - * @param merchantIdentifier - The merchant ID received when the merchant enrolled in Apple Pay. - * @returns true if the device supports Apple Pay and there is at least one active card in Wallet; otherwise, false. + * Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet. + * @param merchantIdentifier - The merchant ID created when the merchant enrolled in Apple Pay. + * @returns true if the device supports Apple Pay and there is at least one active card in Wallet that is qualified for payments on the web; otherwise, false. */ static canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise; /** * Displays the Set up Apple Pay button. - * @param merchantIdentifier - The merchant ID received when the merchant enrolled in Apple Pay. + * @param merchantIdentifier - The merchant ID created when the merchant enrolled in Apple Pay. * @returns A boolean value indicating whether setup was successful. */ static openPaymentSetup(merchantIdentifier: string): Promise; /** - * Verifies if a web browser supports a given Apple Pay JS API version. - * @param version - A number representing the Apple Pay JS API version being checked. The initial version is 1. + * Verifies whether a web browser supports a given Apple Pay JS API version. + * @param version - A number representing the Apple Pay JS API version being checked. The initial version is 1. The latest version is 3. * @returns A boolean value indicating whether the web browser supports the given API version. Returns false if the web browser does not support the specified version. */ static supportsVersion(version: number): boolean; @@ -82,26 +82,38 @@ declare class ApplePaySession extends EventTarget { begin(): void; /** - * Call after the merchant has been validated. + * Completes the validation for a merchant session. * @param merchantSession - An opaque message session object. */ - completeMerchantValidation(merchantSession: any): void; + completeMerchantValidation(merchantSession: object): void; /** - * Call when a payment has been authorized. - * @param status - The status of the payment. + * Completes the payment authorization with a result for Apple Pay JS versions 1 and 2. + * @param status - The status of the payment, whether it succeeded or failed. */ completePayment(status: number): void; /** - * Call after a payment method has been selected. + * Completes the payment authorization with a result for Apple Pay JS version 3. + * @param result - The result of the payment authorization, including its status and list of errors. + */ + completePayment(result: ApplePayJS.ApplePayPaymentAuthorizationResult): void; + + /** + * Call after a payment method has been selected for Apple Pay JS versions 1 and 2. * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. * @param newLineItems - A sequence of ApplePayLineItem dictionaries. */ completePaymentMethodSelection(newTotal: ApplePayJS.ApplePayLineItem, newLineItems: ApplePayJS.ApplePayLineItem[]): void; /** - * Call after a shipping contact has been selected. + * Completes the selection of a payment method with an update for Apple Pay JS version 3. + * @param update - The updated payment method. + */ + completePaymentMethodSelection(update: ApplePayJS.ApplePayPaymentMethodUpdate): void; + + /** + * Completes the selection of a shipping contact with an update for Apple Pay JS versions 1 and 2. * @param status - The status of the shipping contact update. * @param newShippingMethods - A sequence of ApplePayShippingMethod dictionaries. * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. @@ -114,13 +126,25 @@ declare class ApplePaySession extends EventTarget { newLineItems: ApplePayJS.ApplePayLineItem[]): void; /** - * Call after the shipping method has been selected. + * Completes the selection of a shipping contact with an update for Apple Pay JS version 3. + * @param update - The updated shipping contact. + */ + completeShippingContactSelection(update: ApplePayJS.ApplePayShippingContactUpdate): void; + + /** + * Call after the shipping method has been selected for Apple Pay JS versions 1 and 2. * @param status - The status of the shipping method update. * @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase. * @param newLineItems - A sequence of ApplePayLineItem dictionaries. */ completeShippingMethodSelection(status: number, newTotal: ApplePayJS.ApplePayLineItem, newLineItems: ApplePayJS.ApplePayLineItem[]): void; + /** + * Completes the selection of a shipping method with an update for Apple Pay JS version 3. + * @param update - The updated shipping method. + */ + completeShippingMethodSelection(update: ApplePayJS.ApplePayShippingMethodUpdate): void + /** * The requested action succeeded. */ @@ -163,6 +187,79 @@ declare class ApplePaySession extends EventTarget { } declare namespace ApplePayJS { + + /** + * Field names used for requesting contact information in a payment request. + */ + enum ApplePayContactField { + email = 'email', + name = 'name', + phone = 'phone', + postalAddress = 'postalAddress', + phoneticName = 'phoneticName', + } + + /** + * A customizable error type that you create to indicate problems with the address or contact information on an Apple Pay sheet. + */ + interface ApplePayError { + /** + * The error code for this instance. + */ + code: ApplePayErrorCode; + + /** + * The name of the field that contains the error. + */ + contactField?: ApplePayErrorContactField; + + /** + * A localized, user-facing string that describes the error. + */ + message: string; + } + + /** + * The error code that indicates whether an error on the payment sheet is for shipping or billing information, or for another kind of error. + */ + enum ApplePayErrorCode { + /** + * Shipping address or contact information is invalid or missing. + */ + shippingContactInvalid = 'shippingContactInvalid', + /** + * Billing address information is invalid or missing. + */ + billingContactInvalid = 'billingContactInvalid', + /** + * The merchant cannot provide service to the shipping address (for example, can't deliver to a P.O. Box). + */ + addressUnserviceable = 'addressUnserviceable', + /** + * An unknown but nonfatal error occurred during payment processing. The user can attempt authorization again. + */ + unknown = 'unknown', + } + + /** + * Names of the fields in the shipping or billing contact information, used to locate errors in the payment sheet. + */ + enum ApplePayErrorContactField { + phoneNumber = 'phoneNumber', + emailAddress = 'emailAddress', + name = 'name', + phoneticName = 'phoneticName', + postalAddress = 'postalAddress', + addressLines = 'addressLines', + locality = 'locality', + subLocality = 'subLocality', + postalCode = 'postalCode', + administrativeArea = 'administrativeArea', + subAdministrativeArea = 'subAdministrativeArea', + country = 'country', + countryCode = 'countryCode', + } + /** * Defines a line item in a payment request - for example, total, tax, discount, or grand total. */ @@ -180,7 +277,47 @@ declare namespace ApplePayJS { /** * A value that indicates if the line item is final or pending. */ - type?: string; + type?: string | ApplePayLineItemType; + } + + /** + * A type that indicates whether a line item is final or pending. + */ + enum ApplePayLineItemType { + /** + * A line item representing the known, final cost. + */ + final = 'final', + + /** + * A line item representing an estimated or unknown cost. + */ + pending = 'pending', + } + + /** + * The payment capabilities supported by the merchant. + */ + enum ApplePayMerchantCapability { + /** + * Required. This value must be supplied. + */ + supports3DS = 'supports3DS', + + /** + * Include this value only if you support China Union Pay transactions. + */ + supportsEMV = 'supportsEMV', + + /** + * Optional. If present, only transactions that are categorized as credit cards are allowed. + */ + supportsCredit = 'supportsCredit', + + /** + * Optional. If present, only transactions that are categorized as debit cards are allowed. + */ + supportsDebit = 'supportsDebit', } /** @@ -188,7 +325,7 @@ declare namespace ApplePayJS { */ interface ApplePayPayment { /** - * The encrypted token for an authorized payment. + * The encrypted information for an authorized payment. */ token: ApplePayPaymentToken; @@ -208,11 +345,26 @@ declare namespace ApplePayJS { */ abstract class ApplePayPaymentAuthorizedEvent extends Event { /** - * The payment token used to authorize a payment. + * The authorized payment information for this transaction. */ readonly payment: ApplePayPayment; } + /** + * The result of payment authorization, including status and errors. + */ + interface ApplePayPaymentAuthorizationResult { + /** + * The status code for the authorization result. + */ + status: number; + + /** + * A list of custom errors to display on the payment sheet. + */ + errors?: ApplePayError[]; + } + /** * Encapsulates contact information needed for billing and shipping. */ @@ -238,7 +390,17 @@ declare namespace ApplePayJS { phoneNumber: string; /** - * The address for the contact. + * The phonetic spelling of the contact's family name. + */ + phoneticFamilyName: string; + + /** + * The phonetic spelling of the contact's given name. + */ + phoneticGivenName: string; + + /** + * The street portion of the address for the contact. */ addressLines: string[]; @@ -247,29 +409,39 @@ declare namespace ApplePayJS { */ locality: string; + /** + * Additional information associated with the location, typically defined at the city or town level (such as district or neighborhood), in a postal address. + */ + subLocality: string; + /** * The state for the contact. */ administrativeArea: string; /** - * The zip code, where applicable, for the contact. + * The subadministrative area (such as a county or other region) in a postal address. + */ + subAdministrativeArea: string; + + /** + * The zip code or postal code, where applicable, for the contact. */ postalCode: string; /** - * The colloquial country name for the contact. + * The name of the country for the contact. */ country: string; /** - * The contact's ISO country code. + * The contact’s two-letter ISO 3166 country code. */ countryCode: string; } /** - * Contains information about an Apple Pay payment card. + * A dictionary that describes an Apple Pay payment card. */ interface ApplePayPaymentMethod { /** @@ -279,21 +451,30 @@ declare namespace ApplePayJS { /** * A string, suitable for display, that is the name of the payment network backing the card. - * The value is one of the supported networks specified in the supportedNetworks property of the ApplePayPaymentRequest. */ network: string; /** * A value representing the card's type of payment. */ - type: string; + type: string | ApplePayPaymentMethodType; /** - * The payment pass object associated with the payment. + * The payment pass object currently selected to complete the payment. */ paymentPass: ApplePayPaymentPass; } + /** + * A payment card's type of payment. + */ + enum ApplePayPaymentMethodType { + debit = 'debit', + credit = 'credit', + prepaid = 'prepaid', + store = 'store' + } + /** * The ApplePayPaymentMethodSelectedEvent class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function. */ @@ -304,6 +485,21 @@ declare namespace ApplePayJS { readonly paymentMethod: ApplePayPaymentMethod; } + /** + * Updated transaction details resulting from a change in payment method. + */ + interface ApplePayPaymentMethodUpdate { + /** + * An optional list of line items. + */ + newLineItems?: ApplePayLineItem[]; + + /** + * The new total resulting from a change in the payment method. + */ + newTotal: ApplePayLineItem; + } + /** * Represents a provisioned payment card for Apple Pay payments. */ @@ -331,7 +527,37 @@ declare namespace ApplePayJS { /** * The activation state of the pass. */ - activationState: string; + activationState: string | ApplePayPaymentPassActivationState; + } + + /** + * Payment pass activation states. + */ + enum ApplePayPaymentPassActivationState { + /** + * Active and ready to be used for payment. + */ + activated = 'activated', + + /** + * Not active but may be activated by the issuer. + */ + requiresActivation = 'requiresActivation', + + /** + * Not ready for use but activation is in progress. + */ + activating = 'activating', + + /** + * Not active and can't be activated. + */ + suspended = 'suspended', + + /** + * Not active because the issuer has disabled the account associated with the device. + */ + deactivated = 'deactivated', } /** @@ -357,7 +583,7 @@ declare namespace ApplePayJS { * The payment capabilities supported by the merchant. * The value must at least contain ApplePayMerchantCapability.supports3DS. */ - merchantCapabilities: string[]; + merchantCapabilities: string[] | ApplePayMerchantCapability[]; /** * The payment networks supported by the merchant. @@ -377,12 +603,12 @@ declare namespace ApplePayJS { /** * The billing information that you require from the user in order to process the transaction. */ - requiredBillingContactFields?: string[]; + requiredBillingContactFields?: string[] | ApplePayContactField[]; /** * The shipping information that you require from the user in order to fulfill the order. */ - requiredShippingContactFields?: string[]; + requiredShippingContactFields?: string[] | ApplePayContactField[]; /** * Shipping contact information for the user. @@ -397,7 +623,12 @@ declare namespace ApplePayJS { /** * How the items are to be shipped. */ - shippingType?: string; + shippingType?: string | ApplePayShippingType; + + /** + * A list of ISO 3166 country codes for limiting payments to cards from specific countries. + */ + supportedCountries?: string[]; /** * Optional user-defined data. @@ -406,7 +637,7 @@ declare namespace ApplePayJS { } /** - * Contains the user's payment credentials. + * An object that contains the user's payment credentials. */ interface ApplePayPaymentToken { /** @@ -426,7 +657,7 @@ declare namespace ApplePayJS { } /** - * The ApplePayShippingContactSelectedEvent class defines the attributes contained by the ApplePaySession.onshippingcontactselected callback function. + * Encapsulates the attributes contained by the onshippingcontactselected callback function. */ abstract class ApplePayShippingContactSelectedEvent extends Event { /** @@ -435,6 +666,31 @@ declare namespace ApplePayJS { readonly shippingContact: ApplePayPaymentContact; } + /** + * Updated transaction details resulting from a change in shipping contact, including any errors. + */ + class ApplePayShippingContactUpdate { + /** + * List of custom errors to display on the payment sheet. + */ + errors?: ApplePayError[]; + + /** + * An optional list of updated line items. + */ + newLineItems?: ApplePayLineItem[]; + + /** + * A list of shipping methods that are available to the updated shipping contact. + */ + newShippingMethods?: ApplePayShippingMethod[]; + + /** + * The new total resulting from a change in the shipping contact. + */ + newTotal: ApplePayLineItem; + } + /** * Defines a shipping method for delivering physical goods. */ @@ -471,11 +727,36 @@ declare namespace ApplePayJS { } /** - * The ApplePayValidateMerchantEvent class defines the attributes contained by the ApplePaySession.onvalidatemerchant callback function. + * Updated transaction details resulting from a change in shipping method. + */ + interface ApplePayShippingMethodUpdate { + /** + * An optional list of updated line items. + */ + newLineItems?: ApplePayLineItem[]; + + /** + * The new total resulting from a change in the shipping method. + */ + newTotal: ApplePayLineItem; + } + + /** + * A type that indicates how purchased items are to be shipped. + */ + enum ApplePayShippingType { + shipping = 'shipping', + delivery = 'delivery', + storePickup = 'storePickup', + servicePickup = 'servicePickup', + } + + /** + * The attributes contained by the onvalidatemerchant callback function. */ abstract class ApplePayValidateMerchantEvent extends Event { /** - * The URL used to validate the merchant server. + * The URL your server must use to validate itself and obtain a merchant session object. */ readonly validationURL: string; } From c4de1120548f7b57c216a479cdfe5b4139aff24a Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 25 Nov 2017 17:18:16 +0000 Subject: [PATCH 164/639] Update header Update the version to 3. Change author URL to my GitHub profile URL. --- types/applepayjs/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/applepayjs/index.d.ts b/types/applepayjs/index.d.ts index 112fb569ba..203d75d06c 100644 --- a/types/applepayjs/index.d.ts +++ b/types/applepayjs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Apple Pay JS 1.0 +// Type definitions for Apple Pay JS 3.0 // Project: https://developer.apple.com/reference/applepayjs -// Definitions by: Martin Costello +// Definitions by: Martin Costello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** From 0d5a690b400db139c05a90c17bc7ce506343710c Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 25 Nov 2017 17:38:38 +0000 Subject: [PATCH 165/639] Fix variable names Fix copy-pasted variable names in tests. --- types/applepayjs/applepayjs-tests.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/applepayjs/applepayjs-tests.ts b/types/applepayjs/applepayjs-tests.ts index de58dd30cd..f2a6548128 100644 --- a/types/applepayjs/applepayjs-tests.ts +++ b/types/applepayjs/applepayjs-tests.ts @@ -21,7 +21,7 @@ describe("ApplePaySession", () => { } }); it("the contact fields are defined", () => { - const contacts = [ + const contactFields = [ ApplePayJS.ApplePayContactField.email, ApplePayJS.ApplePayContactField.name, ApplePayJS.ApplePayContactField.phone, @@ -38,7 +38,7 @@ describe("ApplePaySession", () => { ]; }); it("the error contact fields are defined", () => { - const contacts = [ + const errorContacts = [ ApplePayJS.ApplePayErrorContactField.addressLines, ApplePayJS.ApplePayErrorContactField.administrativeArea, ApplePayJS.ApplePayErrorContactField.country, @@ -55,13 +55,13 @@ describe("ApplePaySession", () => { ]; }); it("the line item types are defined", () => { - const errorCodes = [ + const lineItemTypes = [ ApplePayJS.ApplePayLineItemType.final, ApplePayJS.ApplePayLineItemType.pending ]; }); it("the merchant capabilities are defined", () => { - const errorCodes = [ + const capabilities = [ ApplePayJS.ApplePayMerchantCapability.supports3DS, ApplePayJS.ApplePayMerchantCapability.supportsCredit, ApplePayJS.ApplePayMerchantCapability.supportsDebit, @@ -69,7 +69,7 @@ describe("ApplePaySession", () => { ]; }); it("the payment method types are defined", () => { - const errorCodes = [ + const paymentMethods = [ ApplePayJS.ApplePayPaymentMethodType.credit, ApplePayJS.ApplePayPaymentMethodType.debit, ApplePayJS.ApplePayPaymentMethodType.prepaid, @@ -77,7 +77,7 @@ describe("ApplePaySession", () => { ]; }); it("the shipping types are defined", () => { - const errorCodes = [ + const shippingTypes = [ ApplePayJS.ApplePayShippingType.delivery, ApplePayJS.ApplePayShippingType.servicePickup, ApplePayJS.ApplePayShippingType.shipping, From 29ba5a506ac3582d12a9cc505450f6970214373c Mon Sep 17 00:00:00 2001 From: rk-7 <30998401+rk-7@users.noreply.github.com> Date: Sat, 25 Nov 2017 23:35:50 +0530 Subject: [PATCH 166/639] Fixed minor type annotion issues. --- types/alexa-sdk/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/types/alexa-sdk/index.d.ts b/types/alexa-sdk/index.d.ts index 33fdc6dd7b..02def0b4d6 100644 --- a/types/alexa-sdk/index.d.ts +++ b/types/alexa-sdk/index.d.ts @@ -294,9 +294,9 @@ export interface ListItemObject { */ status?: ListItemObjectStatus; /** - * item version (Positive integer | string) + * item version (Positive integer) */ - version?: any; + version?: number | string; /** * created time (ISO 8601 time format with time zone) */ @@ -335,9 +335,9 @@ export interface ListObject { */ status?: string; /** - * list version (long | string) + * list version (Positive integer) */ - version?: any; + version?: number; /** * Urls to active and completed items * href is lint to the items having certain status. @@ -468,7 +468,7 @@ export namespace templateBuilders { * @param image image * @returns BodyTemplate3Builder */ - setImage(image: any): BodyTemplate3Builder; + setImage(image: Image): BodyTemplate3Builder; /** * Sets the text content for the template @@ -490,7 +490,7 @@ export namespace templateBuilders { * @param image image * @returns BodyTemplate6Builder */ - setImage(image: any): BodyTemplate6Builder; + setImage(image: Image): BodyTemplate6Builder; /** * Sets the text content for the template @@ -828,7 +828,7 @@ export class ResponseBuilder { * @param hintType (optional) Default value : PlainText * @returns ResponseBuilder */ - hint(hintText: string, hintType: HintType): ResponseBuilder; + hint(hintText: string, hintType?: HintType): ResponseBuilder; /** * Creates a VideoApp play directive to play a video @@ -838,7 +838,7 @@ export class ResponseBuilder { * information that can be displayed on VideoApp. * @returns ResponseBuilder */ - playVideo(source: string, metadata: { title: string, subtitle: string }): ResponseBuilder; + playVideo(source: string, metadata?: { title: string, subtitle: string }): ResponseBuilder; } //#endregion @@ -898,7 +898,7 @@ export namespace utils { * @param description text used to describe the image in a screen reader * @returns Image */ - function makeImages(imgArr: Array<{ url: string, widthPixels: number, heightPixels: number, size: ImageSourceSize }>, description: string): Image; + function makeImages(imgArr: Array<{ url: string, widthPixels?: number, heightPixels?: number, size: ImageSourceSize }>, description: string): Image; } /** * Utility methods for building TextField objects From 3c79b74f9c37eda6e7ee63dbcd0dee9160cd33e2 Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 25 Nov 2017 19:00:51 +0000 Subject: [PATCH 167/639] Improve type definitions Change enums to types. Make the properties on the ApplePayPaymentContact interface optional to make it easier to provide minimal information to an ApplePayPaymentRequest. --- types/applepayjs/applepayjs-tests.ts | 96 +++-------------- types/applepayjs/index.d.ts | 151 +++++++++++++-------------- 2 files changed, 88 insertions(+), 159 deletions(-) diff --git a/types/applepayjs/applepayjs-tests.ts b/types/applepayjs/applepayjs-tests.ts index f2a6548128..99b323453b 100644 --- a/types/applepayjs/applepayjs-tests.ts +++ b/types/applepayjs/applepayjs-tests.ts @@ -20,73 +20,9 @@ describe("ApplePaySession", () => { break; } }); - it("the contact fields are defined", () => { - const contactFields = [ - ApplePayJS.ApplePayContactField.email, - ApplePayJS.ApplePayContactField.name, - ApplePayJS.ApplePayContactField.phone, - ApplePayJS.ApplePayContactField.phoneticName, - ApplePayJS.ApplePayContactField.postalAddress - ]; - }); - it("the error codes are defined", () => { - const errorCodes = [ - ApplePayJS.ApplePayErrorCode.addressUnserviceable, - ApplePayJS.ApplePayErrorCode.billingContactInvalid, - ApplePayJS.ApplePayErrorCode.shippingContactInvalid, - ApplePayJS.ApplePayErrorCode.unknown - ]; - }); - it("the error contact fields are defined", () => { - const errorContacts = [ - ApplePayJS.ApplePayErrorContactField.addressLines, - ApplePayJS.ApplePayErrorContactField.administrativeArea, - ApplePayJS.ApplePayErrorContactField.country, - ApplePayJS.ApplePayErrorContactField.countryCode, - ApplePayJS.ApplePayErrorContactField.emailAddress, - ApplePayJS.ApplePayErrorContactField.locality, - ApplePayJS.ApplePayErrorContactField.name, - ApplePayJS.ApplePayErrorContactField.phoneNumber, - ApplePayJS.ApplePayErrorContactField.phoneticName, - ApplePayJS.ApplePayErrorContactField.postalAddress, - ApplePayJS.ApplePayErrorContactField.postalCode, - ApplePayJS.ApplePayErrorContactField.subAdministrativeArea, - ApplePayJS.ApplePayErrorContactField.subLocality - ]; - }); - it("the line item types are defined", () => { - const lineItemTypes = [ - ApplePayJS.ApplePayLineItemType.final, - ApplePayJS.ApplePayLineItemType.pending - ]; - }); - it("the merchant capabilities are defined", () => { - const capabilities = [ - ApplePayJS.ApplePayMerchantCapability.supports3DS, - ApplePayJS.ApplePayMerchantCapability.supportsCredit, - ApplePayJS.ApplePayMerchantCapability.supportsDebit, - ApplePayJS.ApplePayMerchantCapability.supportsEMV - ]; - }); - it("the payment method types are defined", () => { - const paymentMethods = [ - ApplePayJS.ApplePayPaymentMethodType.credit, - ApplePayJS.ApplePayPaymentMethodType.debit, - ApplePayJS.ApplePayPaymentMethodType.prepaid, - ApplePayJS.ApplePayPaymentMethodType.store - ]; - }); - it("the shipping types are defined", () => { - const shippingTypes = [ - ApplePayJS.ApplePayShippingType.delivery, - ApplePayJS.ApplePayShippingType.servicePickup, - ApplePayJS.ApplePayShippingType.shipping, - ApplePayJS.ApplePayShippingType.storePickup - ]; - }); it("can create a new instance", () => { const version = 1; - const paymentRequest = { + const paymentRequest: ApplePayJS.ApplePayPaymentRequest = { countryCode: "US", currencyCode: "USD", supportedNetworks: [ @@ -122,7 +58,7 @@ describe("ApplePaySession", () => { }); it("can call instance methods", () => { const version = 3; - const paymentRequest = { + const paymentRequest: ApplePayJS.ApplePayPaymentRequest = { countryCode: "US", currencyCode: "USD", supportedNetworks: [ @@ -131,8 +67,8 @@ describe("ApplePaySession", () => { ], merchantCapabilities: [ "supports3DS", - ApplePayJS.ApplePayMerchantCapability.supportsCredit, - ApplePayJS.ApplePayMerchantCapability.supportsDebit + "supportsCredit", + "supportsDebit" ], total: { label: "My Store", @@ -149,12 +85,12 @@ describe("ApplePaySession", () => { session.completePayment(ApplePaySession.STATUS_SUCCESS); - const authorizationResult = { + const authorizationResult: ApplePayJS.ApplePayPaymentAuthorizationResult = { status: ApplePaySession.STATUS_FAILURE, errors: [ { - code: ApplePayJS.ApplePayErrorCode.addressUnserviceable, - contactField: ApplePayJS.ApplePayErrorContactField.postalCode, + code: "addressUnserviceable", + contactField: "postalCode", message: "The specified postal code cannot be delivered to." } ] @@ -162,13 +98,13 @@ describe("ApplePaySession", () => { session.completePayment(authorizationResult); - const total = { + const total: ApplePayJS.ApplePayLineItem = { label: "Subtotal", type: "final", amount: "35.00" }; - const lineItems = [ + const lineItems: ApplePayJS.ApplePayLineItem[] = [ { label: "Subtotal", type: "final", @@ -177,12 +113,12 @@ describe("ApplePaySession", () => { { label: "Free Shipping", amount: "0.00", - type: ApplePayJS.ApplePayLineItemType.final + type: "final" }, { label: "Estimated Tax", amount: "3.06", - type: ApplePayJS.ApplePayLineItemType.pending + type: "pending" } ]; @@ -274,7 +210,7 @@ describe("ApplePayPaymentRequest", () => { merchantCapabilities: [ "supports3DS", "supportsCredit", - ApplePayJS.ApplePayMerchantCapability.supportsDebit + "supportsDebit" ], supportedNetworks: [ "amex", @@ -296,8 +232,6 @@ describe("ApplePayPaymentRequest", () => { familyName: "Patel", givenName: "Ravi", phoneNumber: "(408) 555-5555", - phoneticFamilyName: "Patel", - phoneticGivenName: "Ravi", addressLines: [ "1 Infinite Loop" ], @@ -329,14 +263,14 @@ describe("ApplePayPaymentRequest", () => { paymentRequest.requiredBillingContactFields = [ "postalAddress", - ApplePayJS.ApplePayContactField.name + "name" ]; paymentRequest.requiredShippingContactFields = [ "postalAddress", "name", "phone", - ApplePayJS.ApplePayContactField.name + "name" ]; paymentRequest.shippingContact = { @@ -372,6 +306,6 @@ describe("ApplePayPaymentRequest", () => { ]; paymentRequest.shippingType = "storePickup"; - paymentRequest.shippingType = ApplePayJS.ApplePayShippingType.delivery; + paymentRequest.shippingType = "delivery"; }); }); diff --git a/types/applepayjs/index.d.ts b/types/applepayjs/index.d.ts index 203d75d06c..20b7dcf07d 100644 --- a/types/applepayjs/index.d.ts +++ b/types/applepayjs/index.d.ts @@ -191,13 +191,12 @@ declare namespace ApplePayJS { /** * Field names used for requesting contact information in a payment request. */ - enum ApplePayContactField { - email = 'email', - name = 'name', - phone = 'phone', - postalAddress = 'postalAddress', - phoneticName = 'phoneticName', - } + type ApplePayContactField = + 'email' | + 'name' | + 'phone' | + 'postalAddress' | + 'phoneticName'; /** * A customizable error type that you create to indicate problems with the address or contact information on an Apple Pay sheet. @@ -222,43 +221,44 @@ declare namespace ApplePayJS { /** * The error code that indicates whether an error on the payment sheet is for shipping or billing information, or for another kind of error. */ - enum ApplePayErrorCode { + type ApplePayErrorCode = /** * Shipping address or contact information is invalid or missing. */ - shippingContactInvalid = 'shippingContactInvalid', + 'shippingContactInvalid' | + /** * Billing address information is invalid or missing. */ - billingContactInvalid = 'billingContactInvalid', + 'billingContactInvalid' | + /** * The merchant cannot provide service to the shipping address (for example, can't deliver to a P.O. Box). */ - addressUnserviceable = 'addressUnserviceable', + 'addressUnserviceable' | + /** * An unknown but nonfatal error occurred during payment processing. The user can attempt authorization again. */ - unknown = 'unknown', - } + 'unknown'; /** * Names of the fields in the shipping or billing contact information, used to locate errors in the payment sheet. */ - enum ApplePayErrorContactField { - phoneNumber = 'phoneNumber', - emailAddress = 'emailAddress', - name = 'name', - phoneticName = 'phoneticName', - postalAddress = 'postalAddress', - addressLines = 'addressLines', - locality = 'locality', - subLocality = 'subLocality', - postalCode = 'postalCode', - administrativeArea = 'administrativeArea', - subAdministrativeArea = 'subAdministrativeArea', - country = 'country', - countryCode = 'countryCode', - } + type ApplePayErrorContactField = + 'phoneNumber' | + 'emailAddress' | + 'name' | + 'phoneticName' | + 'postalAddress' | + 'addressLines' | + 'locality' | + 'subLocality' | + 'postalCode' | + 'administrativeArea' | + 'subAdministrativeArea' | + 'country' | + 'countryCode'; /** * Defines a line item in a payment request - for example, total, tax, discount, or grand total. @@ -277,48 +277,46 @@ declare namespace ApplePayJS { /** * A value that indicates if the line item is final or pending. */ - type?: string | ApplePayLineItemType; + type?: ApplePayLineItemType; } /** * A type that indicates whether a line item is final or pending. */ - enum ApplePayLineItemType { + type ApplePayLineItemType = /** * A line item representing the known, final cost. */ - final = 'final', + 'final' | /** * A line item representing an estimated or unknown cost. */ - pending = 'pending', - } + 'pending'; /** * The payment capabilities supported by the merchant. */ - enum ApplePayMerchantCapability { + type ApplePayMerchantCapability = /** * Required. This value must be supplied. */ - supports3DS = 'supports3DS', + 'supports3DS' | /** * Include this value only if you support China Union Pay transactions. */ - supportsEMV = 'supportsEMV', + 'supportsEMV' | /** * Optional. If present, only transactions that are categorized as credit cards are allowed. */ - supportsCredit = 'supportsCredit', + 'supportsCredit' | /** * Optional. If present, only transactions that are categorized as debit cards are allowed. */ - supportsDebit = 'supportsDebit', - } + 'supportsDebit'; /** * Represents the result of authorizing a payment request and contains encrypted payment information. @@ -372,72 +370,72 @@ declare namespace ApplePayJS { /** * An email address for the contact. */ - emailAddress: string; + emailAddress?: string; /** * The contact's family name. */ - familyName: string; + familyName?: string; /** * The contact's given name. */ - givenName: string; + givenName?: string; /** * A phone number for the contact. */ - phoneNumber: string; + phoneNumber?: string; /** * The phonetic spelling of the contact's family name. */ - phoneticFamilyName: string; + phoneticFamilyName?: string; /** * The phonetic spelling of the contact's given name. */ - phoneticGivenName: string; + phoneticGivenName?: string; /** * The street portion of the address for the contact. */ - addressLines: string[]; + addressLines?: string[]; /** * The city for the contact. */ - locality: string; + locality?: string; /** * Additional information associated with the location, typically defined at the city or town level (such as district or neighborhood), in a postal address. */ - subLocality: string; + subLocality?: string; /** * The state for the contact. */ - administrativeArea: string; + administrativeArea?: string; /** * The subadministrative area (such as a county or other region) in a postal address. */ - subAdministrativeArea: string; + subAdministrativeArea?: string; /** * The zip code or postal code, where applicable, for the contact. */ - postalCode: string; + postalCode?: string; /** * The name of the country for the contact. */ - country: string; + country?: string; /** * The contact’s two-letter ISO 3166 country code. */ - countryCode: string; + countryCode?: string; } /** @@ -457,7 +455,7 @@ declare namespace ApplePayJS { /** * A value representing the card's type of payment. */ - type: string | ApplePayPaymentMethodType; + type: ApplePayPaymentMethodType; /** * The payment pass object currently selected to complete the payment. @@ -468,12 +466,11 @@ declare namespace ApplePayJS { /** * A payment card's type of payment. */ - enum ApplePayPaymentMethodType { - debit = 'debit', - credit = 'credit', - prepaid = 'prepaid', - store = 'store' - } + type ApplePayPaymentMethodType = + 'debit' | + 'credit' | + 'prepaid' | + 'store'; /** * The ApplePayPaymentMethodSelectedEvent class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function. @@ -527,38 +524,37 @@ declare namespace ApplePayJS { /** * The activation state of the pass. */ - activationState: string | ApplePayPaymentPassActivationState; + activationState: ApplePayPaymentPassActivationState; } /** * Payment pass activation states. */ - enum ApplePayPaymentPassActivationState { + type ApplePayPaymentPassActivationState = /** * Active and ready to be used for payment. */ - activated = 'activated', + 'activated' | /** * Not active but may be activated by the issuer. */ - requiresActivation = 'requiresActivation', + 'requiresActivation' | /** * Not ready for use but activation is in progress. */ - activating = 'activating', + 'activating' | /** * Not active and can't be activated. */ - suspended = 'suspended', + 'suspended' | /** * Not active because the issuer has disabled the account associated with the device. */ - deactivated = 'deactivated', - } + 'deactivated'; /** * Encapsulates a request for payment, including information about payment processing capabilities, the payment amount, and shipping information. @@ -583,7 +579,7 @@ declare namespace ApplePayJS { * The payment capabilities supported by the merchant. * The value must at least contain ApplePayMerchantCapability.supports3DS. */ - merchantCapabilities: string[] | ApplePayMerchantCapability[]; + merchantCapabilities: ApplePayMerchantCapability[]; /** * The payment networks supported by the merchant. @@ -603,12 +599,12 @@ declare namespace ApplePayJS { /** * The billing information that you require from the user in order to process the transaction. */ - requiredBillingContactFields?: string[] | ApplePayContactField[]; + requiredBillingContactFields?: ApplePayContactField[]; /** * The shipping information that you require from the user in order to fulfill the order. */ - requiredShippingContactFields?: string[] | ApplePayContactField[]; + requiredShippingContactFields?: ApplePayContactField[]; /** * Shipping contact information for the user. @@ -623,7 +619,7 @@ declare namespace ApplePayJS { /** * How the items are to be shipped. */ - shippingType?: string | ApplePayShippingType; + shippingType?: ApplePayShippingType; /** * A list of ISO 3166 country codes for limiting payments to cards from specific countries. @@ -744,12 +740,11 @@ declare namespace ApplePayJS { /** * A type that indicates how purchased items are to be shipped. */ - enum ApplePayShippingType { - shipping = 'shipping', - delivery = 'delivery', - storePickup = 'storePickup', - servicePickup = 'servicePickup', - } + type ApplePayShippingType = + 'shipping' | + 'delivery' | + 'storePickup' | + 'servicePickup'; /** * The attributes contained by the onvalidatemerchant callback function. From 6c34866d89a98441740c7f7373c3004c2e32944f Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 25 Nov 2017 19:43:10 +0000 Subject: [PATCH 168/639] Fix tslint errors Fix tslint errors. --- types/applepayjs/index.d.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/types/applepayjs/index.d.ts b/types/applepayjs/index.d.ts index 20b7dcf07d..39d4463daf 100644 --- a/types/applepayjs/index.d.ts +++ b/types/applepayjs/index.d.ts @@ -85,19 +85,13 @@ declare class ApplePaySession extends EventTarget { * Completes the validation for a merchant session. * @param merchantSession - An opaque message session object. */ - completeMerchantValidation(merchantSession: object): void; + completeMerchantValidation(merchantSession: any): void; /** - * Completes the payment authorization with a result for Apple Pay JS versions 1 and 2. - * @param status - The status of the payment, whether it succeeded or failed. + * Completes the payment authorization with a result. + * @param result - The status of the payment, whether it succeeded or failed for Apple Pay JS versions 1 and 2, or the result of the payment authorization, including its status and list of errors for Apple Pay JS version 3. */ - completePayment(status: number): void; - - /** - * Completes the payment authorization with a result for Apple Pay JS version 3. - * @param result - The result of the payment authorization, including its status and list of errors. - */ - completePayment(result: ApplePayJS.ApplePayPaymentAuthorizationResult): void; + completePayment(result: number | ApplePayJS.ApplePayPaymentAuthorizationResult): void; /** * Call after a payment method has been selected for Apple Pay JS versions 1 and 2. @@ -143,7 +137,7 @@ declare class ApplePaySession extends EventTarget { * Completes the selection of a shipping method with an update for Apple Pay JS version 3. * @param update - The updated shipping method. */ - completeShippingMethodSelection(update: ApplePayJS.ApplePayShippingMethodUpdate): void + completeShippingMethodSelection(update: ApplePayJS.ApplePayShippingMethodUpdate): void; /** * The requested action succeeded. @@ -187,7 +181,6 @@ declare class ApplePaySession extends EventTarget { } declare namespace ApplePayJS { - /** * Field names used for requesting contact information in a payment request. */ From e0623b5cf3432f627c8826a657bf36cd1af1771b Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 25 Nov 2017 19:47:36 +0000 Subject: [PATCH 169/639] Fix comment line that is too long Fix a line of comment that is too long. --- types/applepayjs/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/applepayjs/index.d.ts b/types/applepayjs/index.d.ts index 39d4463daf..a37f60b6fd 100644 --- a/types/applepayjs/index.d.ts +++ b/types/applepayjs/index.d.ts @@ -89,7 +89,8 @@ declare class ApplePaySession extends EventTarget { /** * Completes the payment authorization with a result. - * @param result - The status of the payment, whether it succeeded or failed for Apple Pay JS versions 1 and 2, or the result of the payment authorization, including its status and list of errors for Apple Pay JS version 3. + * @param result - The status of the payment, whether it succeeded or failed for Apple Pay JS versions 1 and 2, + * or the result of the payment authorization, including its status and list of errors for Apple Pay JS version 3. */ completePayment(result: number | ApplePayJS.ApplePayPaymentAuthorizationResult): void; From 36b6f554a7f861046d2a82b46f55b40702215534 Mon Sep 17 00:00:00 2001 From: TeamworkGuy2 Date: Sat, 25 Nov 2017 21:18:28 +0000 Subject: [PATCH 170/639] [lokijs] update definition to lokijs@1.5.1 --- types/lokijs/index.d.ts | 2825 ++++++++++++++++++++-------------- types/lokijs/lokijs-tests.ts | 6 +- types/lokijs/tsconfig.json | 2 +- 3 files changed, 1637 insertions(+), 1196 deletions(-) diff --git a/types/lokijs/index.d.ts b/types/lokijs/index.d.ts index f250786778..74f1b6f09e 100644 --- a/types/lokijs/index.d.ts +++ b/types/lokijs/index.d.ts @@ -1,854 +1,1431 @@ -// Type definitions for lokijs v1.2.5 +// Type definitions for lokijs v1.5.1 // Project: https://github.com/techfort/LokiJS // Definitions by: TeamworkGuy2 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -// NOTE: definition last updated (2016-3-13) based on latest code as of https://github.com/techfort/LokiJS/commit/3d2cf9546cd22556444deeabc4df314f227ecf5c +// NOTE: definition last updated (2017-11-25) based on latest code as of https://github.com/techfort/LokiJS/commit/f6c8f1c362cfc9ed63d93cd165ef0ac3bad131bf -/** LokiJS +/** + * LokiJS * A lightweight document oriented javascript database * @author Joe Minichino */ - -/** Loki: The main database class - * @constructor - * @param {string} filename - name of the file to be saved to - * @param {object} options - config object +/** comparison operators + * a is the value in the collection + * b is the query value */ -interface Loki extends LokiEventEmitter { - // autosave support (disabled by default) - autosave: boolean; - autosaveInterval: number; // milliseconds between auto-saves - autosaveHandle: number; // ID from setInterval(...) - collections: LokiCollection[]; - databaseVersion: number; - engineVersion: number; - ENV: string;/*NODEJS, CORDOVA, BROWSER*/ - events: { [id: string]: ((...args: any[]) => void)[] }; /*{ - 'init': ((...args) => void)[]; - 'loaded': ((...args) => void)[]; - 'flushChanges': ((...args) => void)[]; - 'close': ((...args) => void)[]; - 'changes': ((...args) => void)[]; - 'warning': ((...args) => void)[]; - };*/ - filename: string; - options: LokiConfigureOptions; - persistenceAdapter: LokiPersistenceInterface; - // persistenceMethod could be 'fs', 'localStorage', or 'adapter' - // this is optional option param, otherwise environment detection will be used - // if user passes their own adapter we will force this method to 'adapter' later, so no need to pass method option. - persistenceMethod: string; /*'fs', 'localStorage', 'adapter'*/ - verbose: boolean; +declare var LokiOps: { + $eq(a: any, b: any): boolean; + // abstract/loose equality + $aeq(a: any, b: any): boolean; + $ne(a: any, b: any): boolean; + // date equality / loki abstract equality test + $dteq(a: any, b: any): boolean; + $gt(a: any, b: any): boolean; + $gte(a: any, b: any): boolean; + $lt(a: any, b: any): boolean; + $lte(a: any, b: any): boolean; + /** ex : coll.find({'orderCount': {$between: [10, 50]}}); */ + $between(a: any, vals: any/*[any, any]*/): boolean; + $in(a: any, b: any): boolean; + $nin(a: any, b: any): boolean; + $keyin(a: any, b: any): boolean; + $nkeyin(a: any, b: any): boolean; + $definedin(a: any, b: any): boolean; + $undefinedin(a: any, b: any): boolean; + $regex(a: any, b: any): boolean; + $containsString(a: any, b: any): boolean; + $containsNone(a: any, b: any): boolean; + $containsAny(a: any, b: any): boolean; + $contains(a: any, b: any): boolean; + $type(a: any, b: any): boolean; + $finite(a: any, b: any): boolean; + $size(a: any, b: any): boolean; + $len(a: any, b: any): boolean; + $where(a: any, b: any): boolean; + // field-level logical operators + // a is the value in the collection + // b is the nested query operation (for '$not') + // or an array of nested query operations (for '$and' and '$or') + $not(a: any, b: any): boolean; + $and(a: any, b: any): boolean; + $or(a: any, b: any): boolean; +}; +declare type LokiOps = typeof LokiOps; - new (filename: string, options: LokiConfigureOptions): Loki; - - // experimental support for browserify's abstract syntax scan to pick up dependency of indexed adapter. - // Hopefully, once this hits npm a browserify require of lokijs should scan the main file and detect this indexed adapter reference. - getIndexedAdapter(): LokiPersistenceInterface; // require("./loki-indexed-adapter.js") +/** if an op is registered in this object, our 'calculateRange' can use it with our binary indices. + * if the op is registered to a function, we will run that function/op as a 2nd pass filter on results. + * those 2nd pass filter functions should be similar to LokiOps functions, accepting 2 vals to compare. + */ +declare var indexedOps: { + $eq: LokiOps["$eq"], + $aeq: true, + $dteq: true, + $gt: true, + $gte: true, + $lt: true, + $lte: true, + $in: true, + $between: true +}; - /** configureOptions - allows reconfiguring database options - * - * @param {object} options - configuration options to apply to loki db object - * @param {boolean} initialConfig - (optional) if this is a reconfig, don't pass this - */ - configureOptions(options: LokiConfigureOptions, initialConfig?: boolean): void; +type PartialModel = { [P in keyof E]?: T | E[P] }; - /** anonym() - shorthand method for quickly creating and populating an anonymous collection. - * This collection is not referenced internally so upon losing scope it will be garbage collected. - * - * Example : var results = new loki().anonym(myDocArray).find({'age': {'$gt': 30} }); - * - * @param {Array} docs - document array to initialize the anonymous collection with - * @param {Array} indexesArray - (Optional) array of property names to index - * @returns {Collection} New collection which you can query or chain - */ - anonym(docs: T | T[], indexesArray?: LokiCollectionOptions): LokiCollection; +type LokiQuery = PartialModel; - addCollection(name: string, options?: LokiCollectionOptions): LokiCollection; - - loadCollection(collection: LokiCollection): void; - - getCollection(collectionName: string): LokiCollection; - - listCollections(): { name: string; type: string; count: number }[]; - - removeCollection(collectionName: string): void; - - getName(): string; - - /** serializeReplacer - used to prevent certain properties from being serialized - */ - serializeReplacer(key: "autosaveHandle", value: T): T; - serializeReplacer(key: "persistenceAdapter", value: T): T; - serializeReplacer(key: "constraints", value: T): T; - serializeReplacer(key: string, value: T): T; - - // toJson - serialize(): string; - - // alias of serialize - toJson(): string; - - /** loadJSON - inflates a loki database from a serialized JSON string - * - * @param {string} serializedDb - a serialized loki database string - * @param {object} options - apply or override collection level settings - */ - loadJSON(serializedDb: string, options?: { [collectionName: string]: { inflate?: (src: any, dst: any) => void; proto: any; } }): void; - - /** loadJSONObject - inflates a loki database from a JS object - * - * @param {object} dbObject - a serialized loki database string - * @param {object} options - apply or override collection level settings - */ - loadJSONObject(dbObject: Loki, options?: { [collectionName: string]: { inflate?: (src: any, dst: any) => void; proto: any; } }): void; - - /** close(callback) - emits the close event with an optional callback. Does not actually destroy the db - * but useful from an API perspective - */ - close(callback?: (...args: any[]) => void): void; - - /**-------------------------+ - | Changes API | - +--------------------------*/ - - /** The Changes API enables the tracking the changes occurred in the collections since the beginning of the session, - * so it's possible to create a differential dataset for synchronization purposes (possibly to a remote db) - */ - - /** generateChangesNotification() - takes all the changes stored in each - * collection and creates a single array for the entire database. If an array of names - * of collections is passed then only the included collections will be tracked. - * - * @param {array} optional array of collection names. No arg means all collections are processed. - * @returns {array} array of changes - * @see private method createChange() in Collection - */ - generateChangesNotification(arrayOfCollectionNames?: string[]): LokiCollectionChange[]; - - /** serializeChanges() - stringify changes for network transmission - * @returns {string} string representation of the changes - */ - serializeChanges(collectionNamesArray?: string[]): string; - - /** clearChanges() - clears all the changes in all collections. - */ - clearChanges(): void; - - /** loadDatabase - Handles loading from file system, local storage, or adapter (indexeddb) - * This method utilizes loki configuration options (if provided) to determine which - * persistence method to use, or environment detection (if configuration was not provided). - * - * @param {object} options - not currently used (remove or allow overrides?) - * @param {function} callback - (Optional) user supplied async callback / error handler - */ - loadDatabase(options: { [collectionName: string]: { inflate?: (src: any, dst: any) => void; proto: any; } }, callback?: (err: any, data: any) => void): void; - - /** saveDatabase - Handles saving to file system, local storage, or adapter (indexeddb) - * This method utilizes loki configuration options (if provided) to determine which - * persistence method to use, or environment detection (if configuration was not provided). - * - * @param {object} options - not currently used (remove or allow overrides?) - * @param {function} callback - (Optional) user supplied async callback / error handler - */ - saveDatabase(callback?: (err: any) => void): void; - - // alias for saveDatabase - save(callback ?: (err: any) => void): void; - - /** deleteDatabase - Handles deleting a database from file system, local - * storage, or adapter (indexeddb) - * This method utilizes loki configuration options (if provided) to determine which - * persistence method to use, or environment detection (if configuration was not provided). - * - * @param {object} options - not currently used (remove or allow overrides?) - * @param {function} callback - user supplied async callback / error handler - */ - deleteDatabase(options: any, callback: (err: any, data: any) => void): void; - - /** autosaveDirty - check whether any collections are 'dirty' meaning we need to save (entire) database - * @returns {boolean} - true if database has changed since last autosave, false if not. - */ - autosaveDirty(): boolean; - - /** autosaveClearFlags - resets dirty flags on all collections. - * Called from saveDatabase() after db is saved. - */ - autosaveClearFlags(): void; - - /** autosaveEnable - begin a javascript interval to periodically save the database. - * - * @param {object} options - not currently used (remove or allow overrides?) - * @param {function} callback - (Optional) user supplied async callback - */ - autosaveEnable(options?: LokiConfigureOptions, callback?: (err: any) => void): void; - - /** autosaveDisable - stop the autosave interval timer. - */ - autosaveDisable(): void; +interface LokiObj { + $loki: number; + meta: { + created: number; // Date().getTime() + revision: number; + updated: number; // Date().getTime() + version: number; + }; } - /** * LokiEventEmitter is a minimalist version of EventEmitter. It enables any * constructor that inherits EventEmitter to emit events and trigger * listeners that have been added to the event through the on(event, callback) method + * + * @constructor LokiEventEmitter */ -interface LokiEventEmitter { - /** - * @prop Events property is a hashmap, with each property being an array of callbacks - */ - events: { [eventName: string]: ((...args: any[]) => void)[] }; +declare class LokiEventEmitter { - new (): LokiEventEmitter; + /** + * @prop events - a hashmap, with each property being an array of callbacks + */ + public events: { [eventName: string]: ((...args: any[]) => any)[] }; /** * @prop asyncListeners - boolean determines whether or not the callbacks associated with each event * should happen in an async fashion or not * Default is false, which means events are synchronous */ - asyncListeners: boolean; + public asyncListeners: boolean; /** - * @prop on(eventName, listener) - adds a listener to the queue of callbacks associated to an event - * @returns {int} the index of the callback in the array of listeners for a particular event + * on(eventName, listener) - adds a listener to the queue of callbacks associated to an event + * @param eventName - the name(s) of the event(s) to listen to + * @param listener - callback function of listener to attach + * @returns the index of the callback in the array of listeners for a particular event */ - on void>(eventName: string, listener: U): U; + on any>(eventName: string | string[], listener: F): F; /** - * @propt emit(eventName, data) - emits a particular event + * emit(eventName, data) - emits a particular event * with the option of passing optional parameters which are going to be processed by the callback * provided signatures match (i.e. if passing emit(event, arg0, arg1) the listener should take two parameters) - * @param {string} eventName - the name of the event - * @param {object} data - optional object passed with the event + * @param eventName - the name of the event + * @param data - optional object passed with the event */ - emit(eventName: string, data?: any): void; + emit(eventName: string, data?: any, arg?: any): void; /** - * @prop remove() - removes the listener at position 'index' from the event 'eventName' + * Alias of LokiEventEmitter.prototype.on + * addListener(eventName, listener) - adds a listener to the queue of callbacks associated to an event + * @param eventName - the name(s) of the event(s) to listen to + * @param listener - callback function of listener to attach + * @returns the event listener added */ - removeListener(eventName: string, listener: (...args: any[]) => void): void; + public addListener: LokiEventEmitter["on"]; + + /** + * removeListener() - removes the listener at position 'index' from the event 'eventName' + * @param eventName - the name(s) of the event(s) which the listener is attached to + * @param listener - the listener callback function to remove from emitter + */ + public removeListener(eventName: string | string[], listener: (...args: any[]) => any): void; } +interface LokiConstructorOptions { + verbose: boolean; + env: "NATIVESCRIPT" | "NODEJS" | "CORDOVA" | "BROWSER" | "NA"; +} + + +interface LokiConfigOptions { + adapter: LokiPersistenceAdapter | null; + autoload: boolean; + autoloadCallback: (err: any) => void; + autosave: boolean; + autosaveCallback: (err?: any) => void; + autosaveInterval: string | number; + persistenceMethod: "fs" | "localStorage" | "memory" | null; + destructureDelimiter: string; + serializationMethod: "normal" | "pretty" | "destructured" | null; + throttledSaves: boolean; +} + + +type DeserializeOptions = { partitioned?: boolean; delimited: false; delimiter?: string; partition?: number } | { partitioned?: boolean; delimited?: true; delimiter: string; partition?: number }; + + +interface ThrottledSaveDrainOptions { + recursiveWait: boolean; + recursiveWaitLimit: boolean; + recursiveWaitLimitDuration: number; + started: number; +} + + +interface Transform { + type: "find" | "where" | "simplesort" | "compoundsort" | "sort" | "limit" | "offset" | "map" | "eqJoin" | "mapReduce" | "update" | "remove"; + value?: any; + property?: string; + desc?: boolean; + dataOptions?: any; + joinData?: any; + leftJoinKey?: any; + rightJoinKey?: any; + mapFun?: any; + mapFunction?: any; + reduceFunction?: any; +} + + +/** + * Loki: The main database class + * @implements LokiEventEmitter + */ +declare class Loki extends LokiEventEmitter { + collections: Collection[]; + options: Partial & LokiConfigOptions & Partial; + filename: string; + name?: string; + databaseVersion: number; + engineVersion: number; + autosave: boolean; + autosaveInterval: number; + autosaveHandle: number | null; + persistenceAdapter: LokiPersistenceAdapter | null | undefined; + persistenceMethod: "fs" | "localStorage" | "memory" | "adapter" | null | undefined; + throttledCallbacks: ((err?: any) => void)[]; + throttledSavePending: boolean; + throttledSaves: boolean; + verbose: boolean; + ENV: "NATIVESCRIPT" | "NODEJS" | "CORDOVA" | "BROWSER" | "NA"; + + /** + * @param filename - name of the file to be saved to + * @param options - (Optional) config options object + * @param options.env - override environment detection as 'NODEJS', 'BROWSER', 'CORDOVA' + * @param [options.verbose=false] - enable console output + * @param [options.autosave=false] - enables autosave + * @param [options.autosaveInterval=5000] - time interval (in milliseconds) between saves (if dirty) + * @param [options.autoload=false] - enables autoload on loki instantiation + * @param options.autoloadCallback - user callback called after database load + * @param options.adapter - an instance of a loki persistence adapter + * @param [options.serializationMethod='normal'] - ['normal', 'pretty', 'destructured'] + * @param options.destructureDelimiter - string delimiter used for destructured serialization + * @param [options.throttledSaves=true] - debounces multiple calls to to saveDatabase reducing number of disk I/O operations + and guaranteeing proper serialization of the calls. + */ + constructor(filename: string, options?: Partial & Partial & Partial); + + // experimental support for browserify's abstract syntax scan to pick up dependency of indexed adapter. + // Hopefully, once this hits npm a browserify require of lokijs should scan the main file and detect this indexed adapter reference. + public getIndexedAdapter(): any; + + /** + * Allows reconfiguring database options + * + * @param options - configuration options to apply to loki db object + * @param options.env - override environment detection as 'NODEJS', 'BROWSER', 'CORDOVA' + * @param options.verbose - enable console output (default is 'false') + * @param options.autosave - enables autosave + * @param options.autosaveInterval - time interval (in milliseconds) between saves (if dirty) + * @param options.autoload - enables autoload on loki instantiation + * @param options.autoloadCallback - user callback called after database load + * @param options.adapter - an instance of a loki persistence adapter + * @param options.serializationMethod - ['normal', 'pretty', 'destructured'] + * @param options.destructureDelimiter - string delimiter used for destructured serialization + * @param initialConfig - (internal) true is passed when loki ctor is invoking + */ + public configureOptions(options?: Partial & Partial, initialConfig?: boolean): void; + + /** + * Copies 'this' database into a new Loki instance. Object references are shared to make lightweight. + * + * @param options - apply or override collection level settings + * @param options.removeNonSerializable - nulls properties not safe for serialization. + */ + public copy(options?: { removeNonSerializable?: boolean }): Loki; + + /** + * Adds a collection to the database. + * @param name - name of collection to add + * @param options - (optional) options to configure collection with. + * @param [options.unique=[]] - array of property names to define unique constraints for + * @param [options.exact=[]] - array of property names to define exact constraints for + * @param [options.indices=[]] - array property names to define binary indexes for + * @param [options.asyncListeners=false] - whether listeners are called asynchronously + * @param [options.disableChangesApi=true] - set to false to enable Changes Api + * @param [options.autoupdate=false] - use Object.observe to update objects automatically + * @param [options.clone=false] - specify whether inserts and queries clone to/from user + * @param [options.cloneMethod='parse-stringify'] - 'parse-stringify', 'jquery-extend-deep', 'shallow, 'shallow-assign' + * @param options.ttlInterval - time interval for clearing out 'aged' documents; not set by default. + * @returns a reference to the collection which was just added + */ + public addCollection(name: string, options?: Partial>): Collection; + + public loadCollection(collection: Collection): void; + + /** + * Retrieves reference to a collection by name. + * @param collectionName - name of collection to look up + * @returns Reference to collection in database by that name, or null if not found + */ + public getCollection(collectionName: string): Collection; + + /** + * Renames an existing loki collection + * @param oldName - name of collection to rename + * @param newName - new name of collection + * @returns reference to the newly renamed collection + */ + public renameCollection(oldName: string, newName: string): Collection; + + public listCollections(): Collection[]; + + /** + * Removes a collection from the database. + * @param collectionName - name of collection to remove + */ + public removeCollection(collectionName: string): void; + + public getName(): string; + + /** + * serializeReplacer - used to prevent certain properties from being serialized + */ + public serializeReplacer(key: "autosaveHandle" | "persistenceAdapter" | "constraints" | "ttl" | "throttledSavePending" | "throttledCallbacks" | string, value: any): any; + + /** + * Serialize database to a string which can be loaded via {@link Loki#loadJSON} + * + * @returns Stringified representation of the loki database. + */ + public serialize(): string; + public serialize(options: { serializationMethod?: "normal" | "pretty" }): string; + public serialize(options: { serializationMethod: "destructured" }): string[]; + public serialize(options?: { serializationMethod?: string | null }): string | string[]; + public serialize(options?: { serializationMethod?: string | null }): string | string[]; + + // alias of serialize + public toJson: Loki["serialize"]; + + /** + * Database level destructured JSON serialization routine to allow alternate serialization methods. + * Internally, Loki supports destructuring via loki "serializationMethod' option and + * the optional LokiPartitioningAdapter class. It is also available if you wish to do + * your own structured persistence or data exchange. + * + * @param options - output format options for use externally to loki + * @param options.partitioned - (default: false) whether db and each collection are separate + * @param options.partition - can be used to only output an individual collection or db (-1) + * @param options.delimited - (default: true) whether subitems are delimited or subarrays + * @param options.delimiter - override default delimiter + * + * @returns A custom, restructured aggregation of independent serializations. + */ + public serializeDestructured(options?: { delimited?: boolean; delimiter?: string; partitioned?: boolean; partition?: number; }): string | string[]; + + /** + * Collection level utility method to serialize a collection in a 'destructured' format + * + * @param [options] - used to determine output of method + * @param [options.delimited] - whether to return single delimited string or an array + * @param [options.delimiter] - (optional) if delimited, this is delimiter to use + * @param [options.collectionIndex] - specify which collection to serialize data for + * + * @returns A custom, restructured aggregation of independent serializations for a single collection. + */ + public serializeCollection(options?: { delimited?: boolean; collectionIndex?: number; delimiter?: string }): string | string[]; + + /** + * Database level destructured JSON deserialization routine to minimize memory overhead. + * Internally, Loki supports destructuring via loki "serializationMethod' option and + * the optional LokiPartitioningAdapter class. It is also available if you wish to do + * your own structured persistence or data exchange. + * + * @param destructuredSource - destructured json or array to deserialize from + * @param [options] - source format options + * @param [options.partitioned=false] - whether db and each collection are separate + * @param [options.partition] - can be used to deserialize only a single partition + * @param [options.delimited=true] - whether subitems are delimited or subarrays + * @param [options.delimiter] - override default delimiter + * + * @returns An object representation of the deserialized database, not yet applied to 'this' db or document array + */ + public deserializeDestructured(destructuredSource: string | string[] | null, options?: DeserializeOptions): any; + + /** + * Collection level utility function to deserializes a destructured collection. + * + * @param destructuredSource - destructured representation of collection to inflate + * @param [options] - used to describe format of destructuredSource input + * @param [options.delimited=false] - whether source is delimited string or an array + * @param [options.delimiter] - if delimited, this is delimiter to use (if other than default) + * + * @returns an array of documents to attach to collection.data. + */ + public deserializeCollection(destructuredSource: string | string[], options?: { partitioned?: boolean; delimited?: boolean; delimiter?: string; }): any[]; + + /** + * Inflates a loki database from a serialized JSON string + * + * @param serializedDb - a serialized loki database string + * @param [options] - apply or override collection level settings + * @param [options.serializationMethod] - the serialization format to deserialize + */ + public loadJSON(serializedDb: string, options?: { serializationMethod?: "normal" | "pretty" | "destructured" | null } & { retainDirtyFlags?: boolean; throttledSaves?: boolean;[collName: string]: any | { proto?: any; inflate?: (src: object, dest?: object) => void } }): void; + + /** + * Inflates a loki database from a JS object + * + * @param dbObject - a serialized loki database string + * @param options - apply or override collection level settings + * @param options.retainDirtyFlags - whether collection dirty flags will be preserved + */ + public loadJSONObject(dbObject: { name?: string; throttledSaves: boolean; collections: Collection[]; databaseVersion: number }, + options?: { retainDirtyFlags?: boolean; throttledSaves?: boolean;[collName: string]: any | { proto?: any; inflate?: (src: object, dest?: object) => void } }): void; + + /** + * Emits the close event. In autosave scenarios, if the database is dirty, this will save and disable timer. + * Does not actually destroy the db. + * + * @param callback - (Optional) if supplied will be registered with close event before emitting. + */ + public close(callback?: (err?: any) => void): void; + + /**-------------------------+ + | Changes API | + +--------------------------*/ + + /** + * The Changes API enables the tracking the changes occurred in the collections since the beginning of the session, + * so it's possible to create a differential dataset for synchronization purposes (possibly to a remote db) + */ + + /** + * (Changes API) : takes all the changes stored in each + * collection and creates a single array for the entire database. If an array of names + * of collections is passed then only the included collections will be tracked. + * + * @param optional array of collection names. No arg means all collections are processed. + * @returns array of changes + * @see private method createChange() in Collection + */ + public generateChangesNotification(arrayOfCollectionNames?: string[] | null): CollectionChange[]; + + /** + * (Changes API) - stringify changes for network transmission + * @returns string representation of the changes + */ + public serializeChanges(collectionNamesArray?: string[]): string; + + /** + * (Changes API) : clears all the changes in all collections. + */ + public clearChanges(): void; + + /** + * Wait for throttledSaves to complete and invoke your callback when drained or duration is met. + * + * @param callback - callback to fire when save queue is drained, it is passed a sucess parameter value + * @param [options] - configuration options + * @param [options.recursiveWait] - (default: true) if after queue is drained, another save was kicked off, wait for it + * @param [options.recursiveWaitLimit] - (default: false) limit our recursive waiting to a duration + * @param [options.recursiveWaitLimitDelay] - (default: 2000) cutoff in ms to stop recursively re-draining + */ + public throttledSaveDrain(callback: (result?: boolean) => void, options?: Partial): void; + + /** + * Internal load logic, decoupled from throttling/contention logic + * + * @param [options] - not currently used (remove or allow overrides?) + * @param [callback] - (Optional) user supplied async callback / error handler + */ + public loadDatabaseInternal(options?: any, callback?: (err?: any, data?: any) => void): void; + + /** + * Handles manually loading from file system, local storage, or adapter (such as indexeddb) + * This method utilizes loki configuration options (if provided) to determine which + * persistence method to use, or environment detection (if configuration was not provided). + * To avoid contention with any throttledSaves, we will drain the save queue first. + * + * If you are configured with autosave, you do not need to call this method yourself. + * + * @param [options] - if throttling saves and loads, this controls how we drain save queue before loading + * @param [options.recursiveWait] - (default: true) wait recursively until no saves are queued + * @param [options.recursiveWaitLimit] - (default: false) limit our recursive waiting to a duration + * @param [options.recursiveWaitLimitDelay] - (default: 2000) cutoff in ms to stop recursively re-draining + * @param [callback] - (Optional) user supplied async callback / error handler + * @example + * db.loadDatabase({}, function(err) { + * if (err) { + * console.log("error : " + err); + * } + * else { + * console.log("database loaded."); + * } + * }); + */ + public loadDatabase(options?: Partial, callback?: (err: any) => void): void; + + /** + * Internal save logic, decoupled from save throttling logic + */ + public saveDatabaseInternal(callback?: (err: any) => void): void; + + /** + * Handles manually saving to file system, local storage, or adapter (such as indexeddb) + * This method utilizes loki configuration options (if provided) to determine which + * persistence method to use, or environment detection (if configuration was not provided). + * + * If you are configured with autosave, you do not need to call this method yourself. + * + * @param [callback] - (Optional) user supplied async callback / error handler + * @example + * db.saveDatabase(function(err) { + * if (err) { + * console.log("error : " + err); + * } + * else { + * console.log("database saved."); + * } + * }); + */ + public saveDatabase(callback?: (err?: any) => void): void; + + // alias + public save: Loki["saveDatabase"]; + + /** + * Handles deleting a database from file system, local + * storage, or adapter (indexeddb) + * This method utilizes loki configuration options (if provided) to determine which + * persistence method to use, or environment detection (if configuration was not provided). + * + * @param callback - (Optional) user supplied async callback / error handler + */ + public deleteDatabase(callback: (err?: any, data?: any) => void): void; + public deleteDatabase(options?: null, callback?: (err?: any, data?: any) => void): void; + public deleteDatabase(options?: ((err?: any, data?: any) => void) | null, callback?: (err?: any, data?: any) => void): void; + + /** + * autosaveDirty - check whether any collections are 'dirty' meaning we need to save (entire) database + * + * @returns true if database has changed since last autosave, false if not. + */ + public autosaveDirty(): boolean; + + /** + * autosaveClearFlags - resets dirty flags on all collections. + * Called from saveDatabase() after db is saved. + * + */ + public autosaveClearFlags(): void; + + /** + * autosaveEnable - begin a javascript interval to periodically save the database. + * + * @param [options] - not currently used (remove or allow overrides?) + * @param [callback] - (Optional) user supplied async callback + */ + public autosaveEnable(options?: any, callback?: (err?: any) => void): void; + + /** + * autosaveDisable - stop the autosave interval timer. + */ + public autosaveDisable(): void; +} + + /*------------------+ | PERSISTENCE | -------------------*/ /** there are two build in persistence adapters for internal use - * fs for use in Nodejs type environments - * localStorage for use in browser environment - * defined as helper classes here so its easy and clean to use - */ + * fs for use in Nodejs type environments + * localStorage for use in browser environment + * defined as helper classes here so its easy and clean to use + */ -interface LokiPersistenceInterface { - loadDatabase(dbname: string, callback: (dataOrErr: string | Error) => void): void; - saveDatabase(dbname: string, dbstring: string, callback: (resOrErr: void | Error) => void): void; - deleteDatabase(dbname: string, callback?: (resOrErr: void | Error) => void): void; - // optional - mode?: string; // 'reference' - // filename may seem redundant but loadDatabase will need to expect this same filename - exportDatabase?(filename: string, param: any, callback?: (err: any) => void): void; +interface LokiPersistenceAdapter { + mode?: string; + loadDatabase(dbname: string, callback: (value: any) => void): void; + deleteDatabase?(dbnameOrOptions: any, callback: (err?: Error | null, data?: any) => void): void; + exportDatabase?(dbname: string, dbref: Loki, callback: (err: Error | null) => void): void; + saveDatabase?(dbname: string, dbstring: any, callback: (err?: Error | null) => void): void; } -/** constructor for fs +/** + * In in-memory persistence adapter for an in-memory database. + * This simple 'key/value' adapter is intended for unit testing and diagnostics. + * + * @param [options] - memory adapter options + * @param [options.asyncResponses=false] - whether callbacks are invoked asynchronously + * @param [options.asyncTimeout=50] - timeout in ms to queue callbacks + * @constructor LokiMemoryAdapter */ -interface LokiFsAdapter extends LokiPersistenceInterface { - fs: any; //require('fs'); +declare class LokiMemoryAdapter implements LokiPersistenceAdapter { + hashStore: { [name: string]: { savecount: number; lastsave: Date; value: string } }; + options: { asyncResponses?: boolean; asyncTimeout?: number }; - /** loadDatabase() - Load data from file, will throw an error if the file does not exist - * @param {string} dbname - the filename of the database to load - * @param {function} callback - the callback to handle the result + constructor(options?: { asyncResponses?: boolean; asyncTimeout?: number }); + + /** + * Loads a serialized database from its in-memory store. + * (Loki persistence adapter interface function) + * + * @param dbname - name of the database (filename/keyname) + * @param callback - adapter callback to return load result to caller */ - loadDatabase(dbname: string, callback: (err: Error, data: string) => void): void; + public loadDatabase(dbname: string, callback: (value: any) => void): void; - /** saveDatabase() - save data to file, will throw an error if the file can't be saved + /** + * Saves a serialized database to its in-memory store. + * (Loki persistence adapter interface function) + * + * @param dbname - name of the database (filename/keyname) + * @param callback - adapter callback to return load result to caller + */ + public saveDatabase(dbname: string, dbstring: any, callback: (err?: Error | null) => void): void; + + /** + * Deletes a database from its in-memory store. + * + * @param dbname - name of the database (filename/keyname) + * @param callback - function to call when done + */ + public deleteDatabase(dbname: string, callback: (err?: Error | null) => void): void; +} + + + +interface PageIterator { + collection: number; + pageIndex: number; + docIndex: number; +} + + +/** + * An adapter for adapters. Converts a non reference mode adapter into a reference mode adapter + * which can perform destructuring and partioning. Each collection will be stored in its own key/save and + * only dirty collections will be saved. If you turn on paging with default page size of 25megs and save + * a 75 meg collection it should use up roughly 3 save slots (key/value pairs sent to inner adapter). + * A dirty collection that spans three pages will save all three pages again + * Paging mode was added mainly because Chrome has issues saving 'too large' of a string within a + * single indexeddb row. If a single document update causes the collection to be flagged as dirty, all + * of that collection's pages will be written on next save. + * + * @param adapter - reference to a 'non-reference' mode loki adapter instance. + * @param options - configuration options for partitioning and paging + * @param [options.paging] - (default: false) set to true to enable paging collection data. + * @param [options.pageSize] - (default : 25MB) you can use this to limit size of strings passed to inner adapter. + * @param [options.delimiter] - allows you to override the default delimeter + * @constructor LokiPartitioningAdapter + */ +declare class LokiPartitioningAdapter implements LokiPersistenceAdapter { + mode: string; + dbref: Loki | null; + dbname: string + adapter: LokiPersistenceAdapter | null; + options: { paging?: boolean; pageSize?: number; delimiter?: string }; + pageIterator: PageIterator | {}; + dirtyPartitions: number[] | undefined; + + constructor(adapter: LokiPersistenceAdapter, options?: { paging?: boolean; pageSize?: number; delimiter?: string }); + + /** + * Loads a database which was partitioned into several key/value saves. + * (Loki persistence adapter interface function) + * + * @param dbname - name of the database (filename/keyname) + * @param callback - adapter callback to return load result to caller + */ + public loadDatabase(dbname: string, callback: (dbOrErr: Loki | null | Error) => void): void; + + /** + * Used to sequentially load each collection partition, one at a time. + * + * @param partition - ordinal collection position to load next + * @param callback - adapter callback to return load result to caller + */ + public loadNextPartition(partition: number, callback: () => void): void; + + /** + * Used to sequentially load the next page of collection partition, one at a time. + * + * @param callback - adapter callback to return load result to caller + */ + public loadNextPage(callback: () => void): void; + + /** + * Saves a database by partioning into separate key/value saves. + * (Loki 'reference mode' persistence adapter interface function) + * + * @param dbname - name of the database (filename/keyname) + * @param dbref - reference to database which we will partition and save. + * @param callback - adapter callback to return load result to caller + */ + public exportDatabase(dbname: string, dbref: Loki, callback: (err: Error | null) => void): void; + + /** + * Helper method used internally to save each dirty collection, one at a time. + * + * @param callback - adapter callback to return load result to caller + */ + public saveNextPartition(callback: (err: Error | null) => void): void; + + /** + * Helper method used internally to generate and save the next page of the current (dirty) partition. + * + * @param callback - adapter callback to return load result to caller + */ + public saveNextPage(callback: (err: Error | null) => void): void; +} + + + +/** + * A loki persistence adapter which persists using node fs module + * @constructor LokiFsAdapter + */ +declare class LokiFsAdapter implements LokiPersistenceAdapter { + + constructor(); + + /** + * loadDatabase() - Load data from file, will throw an error if the file does not exist + * @param dbname - the filename of the database to load + * @param callback - the callback to handle the result + */ + public loadDatabase(dbname: string, callback: (data: any | Error) => void): void; + + /** + * saveDatabase() - save data to file, will throw an error if the file can't be saved * might want to expand this to avoid dataloss on partial save - * @param {string} dbname - the filename of the database to load - * @param {function} callback - the callback to handle the result + * @param dbname - the filename of the database to load + * @param callback - the callback to handle the result */ - saveDatabase(dbname: string, dbstring: string, callback: (err: any) => void): void; + public saveDatabase(dbname: string, dbstring: string | Uint8Array, callback: (err?: Error | null) => void): void; - /** deleteDatabase() - delete the database file, will throw an error if the + /** + * deleteDatabase() - delete the database file, will throw an error if the * file can't be deleted - * @param {string} dbname - the filename of the database to delete - * @param {function} callback - the callback to handle the result + * @param dbname - the filename of the database to delete + * @param callback - the callback to handle the result */ - deleteDatabase(dbname: string, callback: (resOrErr: void | Error) => void): void; + public deleteDatabase(dbname: string, callback: (err?: Error | null) => void): void; } -/** constructor for local storage + +/** + * A loki persistence adapter which persists to web browser's local storage object + * @constructor LokiLocalStorageAdapter */ -interface LokiLocalStorageAdapter extends LokiPersistenceInterface { +declare class LokiLocalStorageAdapter { - /** loadDatabase() - Load data from localstorage - * @param {string} dbname - the name of the database to load - * @param {function} callback - the callback to handle the result + /** + * loadDatabase() - Load data from localstorage + * @param dbname - the name of the database to load + * @param callback - the callback to handle the result */ - loadDatabase(dbname: string, callback: (dataOrErr: string | Error) => void): void; + public loadDatabase(dbname: string, callback: (dataOrError: any | Error) => void): void; - /** saveDatabase() - save data to localstorage, will throw an error if the file can't be saved + /** + * saveDatabase() - save data to localstorage, will throw an error if the file can't be saved * might want to expand this to avoid dataloss on partial save - * @param {string} dbname - the filename of the database to load - * @param {function} callback - the callback to handle the result + * @param dbname - the filename of the database to load + * @param callback - the callback to handle the result */ - saveDatabase(dbname: string, dbstring: string, callback: (resOrErr: void | Error) => void): void; + public saveDatabase(dbname: string, dbstring: string, callback: (err?: Error | null) => void): void; - /** deleteDatabase() - delete the database from localstorage, will throw an error if it + /** + * deleteDatabase() - delete the database from localstorage, will throw an error if it * can't be deleted - * @param {string} dbname - the filename of the database to delete - * @param {function} callback - the callback to handle the result + * @param dbname - the filename of the database to delete + * @param callback - the callback to handle the result */ - deleteDatabase(dbname: string, callback: (resOrErr: void | Error) => void): void; + public deleteDatabase(dbname: string, callback: (err?: Error | null) => void): void; } +interface GetDataOptions { + forceClones: boolean; + forceCloneMethod: ("parse-stringify" | "jquery-extend-deep" | "shallow" | "shallow-assign" | "shallow-recurse-objects") | null; + removeMeta: boolean; +} -/** Resultset class allowing chainable queries. Intended to be instanced internally. + +/** + * Resultset class allowing chainable queries. Intended to be instanced internally. * Collection.find(), Collection.where(), and Collection.chain() instantiate this. * - * Example: + * @example * mycollection.chain() * .find({ 'doors' : 4 }) * .where(function(obj) { return obj.name === 'Toyota' }) * .data(); */ -interface LokiResultset { - // retain reference to collection we are querying against - collection: LokiCollection; +declare class Resultset { + collection: Collection; + filteredrows: number[]; filterInitialized: boolean; - filteredrows: string[]; // technically number[] (e.g. = Object.keys(this.collection.data)) - options: LokiResultsetOptions; - searchIsChained: boolean; - /** - * @constructor - * @param {Collection} collection - The collection which this Resultset will query against. - * @param {Object} options - Object containing one or more options. - * @param {string} options.queryObj - Optional mongo-style query object to initialize resultset with. - * @param {function} options.queryFunc - Optional javascript filter function to initialize resultset with. - * @param {bool} options.firstOnly - Optional boolean used by collection.findOne(). + * @param collection - The collection which this Resultset will query against. + * @param options */ - new (collection: LokiCollection, options: LokiResultsetOptions): LokiResultset | E[]; + constructor(collection: Collection, options?: any); - /** reset() - Reset the resultset to its initial state. + /** + * reset() - Reset the resultset to its initial state. * - * @returns {Resultset} Reference to this resultset, for future chain operations. + * @returns Reference to this resultset, for future chain operations. */ - reset(): LokiResultset; + public reset(): this; - /** toJSON() - Override of toJSON to avoid circular references + /** + * toJSON() - Override of toJSON to avoid circular references */ - toJSON(): LokiResultset; + public toJSON(): Resultset; - /** limit() - Allows you to limit the number of documents passed to next chain operation. + /** + * Allows you to limit the number of documents passed to next chain operation. * A resultset copy() is made to avoid altering original resultset. * - * @param {int} qty - The number of documents to return. - * @returns {Resultset} Returns a copy of the resultset, limited by qty, for subsequent chain ops. + * @param qty - The number of documents to return. + * @returns Returns a copy of the resultset, limited by qty, for subsequent chain ops. */ - limit(qty: number): LokiResultset; + public limit(qty: number): Resultset; - /** offset() - Used for skipping 'pos' number of documents in the resultset. + /** + * Used for skipping 'pos' number of documents in the resultset. * - * @param {int} pos - Number of documents to skip; all preceding documents are filtered out. - * @returns {Resultset} Returns a copy of the resultset, containing docs starting at 'pos' for subsequent chain ops. + * @param pos - Number of documents to skip; all preceding documents are filtered out. + * @returns Returns a copy of the resultset, containing docs starting at 'pos' for subsequent chain ops. */ - offset(pos: number): LokiResultset; + public offset(pos: number): Resultset; - /** copy() - To support reuse of resultset in branched query situations. + /** + * copy() - To support reuse of resultset in branched query situations. * - * @returns {Resultset} Returns a copy of the resultset (set) but the underlying document references will be the same. + * @returns Returns a copy of the resultset (set) but the underlying document references will be the same. */ - copy(): LokiResultset; - // alias of copy() - branch(): LokiResultset; + public copy(): Resultset; + + /** + * Alias of copy() + */ + public branch: Resultset["copy"]; /** * transform() - executes a named collection transform or raw array of transform steps against the resultset. * - * @param transform {string|array} : (Optional) name of collection transform or raw transform array - * @param parameters {object} : (Optional) object property hash of parameters, if the transform requires them. - * @returns {Resultset} : either (this) resultset or a clone of of this resultset (depending on steps) + * @param transform - name of collection transform or raw transform array + * @param parameters - (Optional) object property hash of parameters, if the transform requires them. + * @returns either (this) resultset or a clone of of this resultset (depending on steps) */ - transform(transform?: string | any[], parameters?: any): LokiResultset; + public transform(transform: string | string[] | Transform[], parameters?: object): Resultset; - /** sort() - User supplied compare function is provided two documents to compare. (chainable) - * Example: + /** + * User supplied compare function is provided two documents to compare. (chainable) + * @example * rslt.sort(function(obj1, obj2) { * if (obj1.name === obj2.name) return 0; * if (obj1.name > obj2.name) return 1; * if (obj1.name < obj2.name) return -1; * }); * - * @param {function} comparefun - A javascript compare function used for sorting. - * @returns {Resultset} Reference to this resultset, sorted, for future chain operations. + * @param comparefun - A javascript compare function used for sorting. + * @returns Reference to this resultset, sorted, for future chain operations. */ - sort(comparefun: (a: E, b: E) => number): LokiResultset; + public sort(comparefun: (a: E & LokiObj, b: E & LokiObj) => number): this; - /** simplesort() - Simpler, loose evaluation for user to sort based on a property name. (chainable) + /** + * Simpler, loose evaluation for user to sort based on a property name. (chainable). + * Sorting based on the same lt/gt helper functions used for binary indices. * - * @param {string} propname - name of property to sort by. - * @param {bool} isdesc - (Optional) If true, the property will be sorted in descending order - * @returns {Resultset} Reference to this resultset, sorted, for future chain operations. + * @param propname - name of property to sort by. + * @param isdesc - (Optional) If true, the property will be sorted in descending order + * @returns Reference to this resultset, sorted, for future chain operations. */ - simplesort(propname: string, isdesc?: boolean): LokiResultset; + public simplesort(propname: keyof E, isdesc?: boolean): this; - /** compoundsort() - Allows sorting a resultset based on multiple columns. - * Example : rs.compoundsort(['age', 'name']); to sort by age and then name (both ascending) - * Example : rs.compoundsort(['age', ['name', true]); to sort by age (ascending) and then by name (descending) + /** + * Allows sorting a resultset based on multiple columns. + * @example + * // to sort by age and then name (both ascending) + * rs.compoundsort(['age', 'name']); + * // to sort by age (ascending) and then by name (descending) + * rs.compoundsort(['age', ['name', true]); * - * @param {array} properties - array of property names or subarray of [propertyname, isdesc] used evaluate sort order - * @returns {Resultset} Reference to this resultset, sorted, for future chain operations. + * @param properties - array of property names or subarray of [propertyname, isdesc] used evaluate sort order + * @returns Reference to this resultset, sorted, for future chain operations. */ - compoundsort(properties: ([string, boolean] | [string])[]): LokiResultset; + public compoundsort(properties: [keyof E, boolean][]): this; - /** calculateRange() - Binary Search utility method to find range/segment of values matching criteria. - * this is used for collection.find() and first find filter of resultset/dynview - * slightly different than get() binary search in that get() hones in on 1 value, - * but we have to hone in on many (range) - * @param {string} op - operation, such as $eq - * @param {string} prop - name of property to calculate range for - * @param {object} val - value to use for range calculation. - * @returns {array} [start, end] index array positions - */ - calculateRange(op: "$eq", prop: string, val: any): [number/*start*/, number/*end*/]; - calculateRange(op: "$dteq", prop: string, val: any): [number/*start*/, number/*end*/]; - calculateRange(op: "$gt", prop: string, val: any): [number/*start*/, number/*end*/]; - calculateRange(op: "$gte", prop: string, val: any): [number/*start*/, number/*end*/]; - calculateRange(op: "$lt", prop: string, val: any): [number/*start*/, number/*end*/]; - calculateRange(op: "$lte", prop: string, val: any): [number/*start*/, number/*end*/]; - calculateRange(op: string, prop: string, val: any): [number/*start*/, number/*end*/]; - - /** findOr() - oversee the operation of OR'ed query expressions. + /** + * findOr() - oversee the operation of OR'ed query expressions. * OR'ed expression evaluation runs each expression individually against the full collection, * and finally does a set OR on each expression's results. * Each evaluation can utilize a binary index to prevent multiple linear array scans. * - * @param {array} expressionArray - array of expressions - * @returns {Resultset} this resultset for further chain ops. + * @param expressionArray - array of expressions + * @returns this resultset for further chain ops. */ - findOr(expressionArray: LokiQuery[]): LokiResultset; - $or(expressionArray: LokiQuery[]): LokiResultset; + public findOr(expressionArray: LokiQuery[]): this; - /** findAnd() - oversee the operation of AND'ed query expressions. + public $or: Resultset["findOr"]; + + /** + * findAnd() - oversee the operation of AND'ed query expressions. * AND'ed expression evaluation runs each expression progressively against the full collection, * internally utilizing existing chained resultset functionality. * Only the first filter can utilize a binary index. * - * @param {array} expressionArray - array of expressions - * @returns {Resultset} this resultset for further chain ops. + * @param expressionArray - array of expressions + * @returns this resultset for further chain ops. */ - findAnd(expressionArray: LokiQuery[]): LokiResultset; - $and(expressionArray: LokiQuery[]): LokiResultset; + public findAnd(expressionArray: LokiQuery[]): this; - /** find() - Used for querying via a mongo-style query object. + public $and: Resultset["findAnd"]; + + /** + * Used for querying via a mongo-style query object. * - * @param {object} query - A mongo-style query object used for filtering current results. - * @param {boolean} firstOnly - (Optional) Used by collection.findOne() - * @returns {Resultset} this resultset for further chain ops. + * @param query - A mongo-style query object used for filtering current results. + * @param firstOnly - (Optional) Used by collection.findOne() + * @returns this resultset for further chain ops. */ - //find(query: LokiQuery, firstOnly: boolean): E; - //find(query?: any, firstOnly?: boolean): E[]; - find(query: LokiQuery, firstOnly?: boolean): LokiResultset; + public find(query?: LokiQuery, firstOnly?: boolean): this; - /** where() - Used for filtering via a javascript filter function. + /** + * where() - Used for filtering via a javascript filter function. * - * @param {function} fun - A javascript function used for filtering current results by. - * @returns {Resultset} this resultset for further chain ops. + * @param fun - A javascript function used for filtering current results by. + * @returns this resultset for further chain ops. */ - where(fun: (obj: E) => boolean): LokiResultset; + public where(fun: (data: E & LokiObj) => boolean): this; - /** count() - returns the number of documents in the resultset. + /** + * count() - returns the number of documents in the resultset. * - * @returns {number} The number of documents in the resultset. + * @returns The number of documents in the resultset. */ - count(): number; + public count(): number; - /** data() - Terminates the chain and returns array of filtered documents + /** + * Terminates the chain and returns array of filtered documents * - * @param options {object} : allows specifying 'forceClones' and 'forceCloneMethod' options. - * options : - * forceClones {boolean} : Allows forcing the return of cloned objects even when + * @param [options] - allows specifying 'forceClones' and 'forceCloneMethod' options. + * @param [options.forceClones] - Allows forcing the return of cloned objects even when * the collection is not configured for clone object. - * forceCloneMethod {string} : Allows overriding the default or collection specified cloning method. - * Possible values include 'parse-stringify', 'jquery-extend-deep', and 'shallow' + * @param [options.forceCloneMethod] - Allows overriding the default or collection specified cloning method. + * Possible values include 'parse-stringify', 'jquery-extend-deep', 'shallow', 'shallow-assign' + * @param [options.removeMeta] - Will force clones and strip $loki and meta properties from documents * - * @returns {array} Array of documents in the resultset + * @returns Array of documents in the resultset */ - data(options?: { forceClones?: string; forceCloneMethod?: string; }): E[]; + public data(options?: Partial): (E & LokiObj)[]; - /** update() - used to run an update operation on all documents currently in the resultset. + /** + * Used to run an update operation on all documents currently in the resultset. * - * @param {function} updateFunction - User supplied updateFunction(obj) will be executed for each document object. - * @returns {Resultset} this resultset for further chain ops. + * @param updateFunction - User supplied updateFunction(obj) will be executed for each document object. + * @returns this resultset for further chain ops. */ - update(updateFunction: (obj: E) => void): LokiResultset; + public update(updateFunction: (obj: E) => void): this; - /** remove() - removes all document objects which are currently in resultset from collection (as well as resultset) + /** + * Removes all document objects which are currently in resultset from collection (as well as resultset) * - * @returns {Resultset} this (empty) resultset for further chain ops. + * @returns this (empty) resultset for further chain ops. */ - remove(): LokiResultset; + public remove(): this; - /** mapReduce() - data transformation via user supplied functions + /** + * data transformation via user supplied functions * - * @param {function} mapFunction - this function accepts a single document for you to transform and return - * @param {function} reduceFunction - this function accepts many (array of map outputs) and returns single value + * @param mapFunction - this function accepts a single document for you to transform and return + * @param reduceFunction - this function accepts many (array of map outputs) and returns single value * @returns The output of your reduceFunction */ - mapReduce(mapFunction: (value: E, index: number, array: E[]) => T, reduceFunction: (array: T[]) => U): U; + public mapReduce(mapFunction: (value: E, index: number, array: E[]) => U, reduceFunction: (ary: U[]) => R): R; - /** eqJoin() - Left joining two sets of data. Join keys can be defined or calculated properties + /** + * eqJoin() - Left joining two sets of data. Join keys can be defined or calculated properties * eqJoin expects the right join key values to be unique. Otherwise left data will be joined on the last joinData object with that key - * @param {Array} joinData - Data array to join to. - * @param {String,function} leftJoinKey - Property name in this result set to join on or a function to produce a value to join on - * @param {String,function} rightJoinKey - Property name in the joinData to join on or a function to produce a value to join on - * @param {function} (optional) mapFun - A function that receives each matching pair and maps them into output objects - function(left,right){return joinedObject} - * @returns {Resultset} A resultset with data in the format [{left: leftObj, right: rightObj}] + * @param joinData - Data array to join to. + * @param leftJoinKey - Property name in this result set to join on or a function to produce a value to join on + * @param rightJoinKey - Property name in the joinData to join on or a function to produce a value to join on + * @param [mapFun] - (Optional) A function that receives each matching pair and maps them into output objects - function(left,right){return joinedObject} + * @param [dataOptions] - options to data() before input to your map function + * @param [dataOptions.removeMeta] - allows removing meta before calling mapFun + * @param [dataOptions.forceClones] - forcing the return of cloned objects to your map object + * @param [dataOptions.forceCloneMethod] - Allows overriding the default or collection specified cloning method. + * @returns A resultset with data in the format [{left: leftObj, right: rightObj}] */ - eqJoin(joinData: T[] | LokiResultset, leftJoinKey: string | ((obj: E) => string), rightJoinKey: string | ((obj: T) => string)): LokiResultset<{ left: E; right: T; }>; - eqJoin(joinData: T[] | LokiResultset, leftJoinKey: string | ((obj: E) => string), rightJoinKey: string | ((obj: T) => string), mapFun?: (a: E, b: T) => U): LokiResultset; + public eqJoin( + joinData: Collection | Resultset | any[], + leftJoinKey: string | ((obj: any) => string), + rightJoinKey: string | ((obj: any) => string), + mapFun?: (left: any, right: any) => any, + dataOptions?: Partial + ): Resultset; - map(mapFun: (currentValue: E, index: number, array: E[]) => T): LokiResultset; + /** + * Applies a map function into a new collection for further chaining. + * @param mapFun - javascript map function + * @param [dataOptions] - options to data() before input to your map function + * @param [dataOptions.removeMeta] - allows removing meta before calling mapFun + * @param [dataOptions.forceClones] - forcing the return of cloned objects to your map object + * @param [dataOptions.forceCloneMethod] - Allows overriding the default or collection specified cloning method. + */ + public map(mapFun: (value: E, index: number, array: E[]) => U, dataOptions?: Partial): Resultset; } +interface DynamicViewOptions { + persistent: boolean; + sortPriority: "active" | "passive"; + minRebuildInterval: number; +} -/** DynamicView class is a versatile 'live' view class which can have filters and sorts applied. + +/** + * DynamicView class is a versatile 'live' view class which can have filters and sorts applied. * Collection.addDynamicView(name) instantiates this DynamicView object and notifies it * whenever documents are add/updated/removed so it can remain up-to-date. (chainable) * - * Examples: - * var mydv = mycollection.addDynamicView('test'); // default is non-persistent - * mydv.applyWhere(function(obj) { return obj.name === 'Toyota'; }); - * mydv.applyFind({ 'doors' : 4 }); - * var results = mydv.data(); + * @example + * var mydv = mycollection.addDynamicView('test'); // default is non-persistent + * mydv.applyFind({ 'doors' : 4 }); + * mydv.applyWhere(function(obj) { return obj.name === 'Toyota'; }); + * var results = mydv.data(); * + * @implements LokiEventEmitter */ -interface LokiDynamicView extends LokiEventEmitter { - cachedresultset: LokiResultset; - collection: LokiCollection; - events: { [id: string]: ((...args: any[]) => void)[] }; /*{ - 'rebuild': ((...args) => void)[]; - };*/ - // keep ordered filter pipeline - filterPipeline: LokiFilter[]; - minRebuildInterval: number; +declare class DynamicView extends LokiEventEmitter { name: string; - options: LokiDynamicViewOptions; - persistent: boolean; + collection: Collection; rebuildPending: boolean; - resultset: LokiResultset; - resultdata: E[]; + resultset: Resultset; + resultdata: (E & LokiObj)[]; resultsdirty: boolean; - // sorting member variables, we only support one active search, applied using applySort() or applySimpleSort() - sortFunction: (a: E, b: E) => number; - sortCriteria: ([string, boolean] | [string])[]; + cachedresultset: Resultset | null; + filterPipeline: { type: "find" | "where", val: any; uid?: string | number }[]; + sortFunction: ((a: E & LokiObj, b: E & LokiObj) => number) | null; + sortCriteria: [keyof E, boolean][] | null; sortDirty: boolean; - sortPriority: string; // 'persistentSortPriority', 'passive' (will defer the sort phase until they call data(). most efficient overall), 'active' (will sort async whenever next idle. prioritizes read speeds) + options: Partial; /** - * @constructor - * @param {Collection} collection - A reference to the collection to work against - * @param {string} name - The name of this dynamic view - * @param {object} options - (Optional) Pass in object with 'persistent' and/or 'sortPriority' options. + * @param collection - A reference to the collection to work against + * @param name - The name of this dynamic view + * @param [options] - (Optional) Pass in object with 'persistent' and/or 'sortPriority' options. + * @param [options.persistent=false] - indicates if view is to main internal results array in 'resultdata' + * @param [options.sortPriority='passive'] - 'passive' (sorts performed on call to data) or 'active' (after updates) + * @param [options.minRebuildInterval] - minimum rebuild interval (need clarification to docs here) + * @see {@link Collection#addDynamicView} to construct instances of DynamicView */ - new (collection: LokiCollection, name: string, options?: LokiDynamicViewOptions): LokiDynamicView; + constructor(collection: Collection, name: string, options?: Partial); - /** rematerialize() - intended for use immediately after deserialization (loading) + /** + * rematerialize() - internally used immediately after deserialization (loading) * This will clear out and reapply filterPipeline ops, recreating the view. * Since where filters do not persist correctly, this method allows * restoring the view to state where user can re-apply those where filters. * - * @param {Object} options - (Optional) allows specification of 'removeWhereFilters' option - * @returns {DynamicView} This dynamic view for further chained ops. + * @param [options] - (Optional) allows specification of 'removeWhereFilters' option + * @returns This dynamic view for further chained ops. + * @fires DynamicView.rebuild */ - rematerialize(options?: { removeWhereFilters?: boolean; }): LokiDynamicView; + public rematerialize(options?: { removeWhereFilters?: boolean }): this; - /** branchResultset() - Makes a copy of the internal resultset for branched queries. + /** + * branchResultset() - Makes a copy of the internal resultset for branched queries. * Unlike this dynamic view, the branched resultset will not be 'live' updated, * so your branched query should be immediately resolved and not held for future evaluation. * - * @param {string|array} transform: Optional name of collection transform, or an array of transform steps - * @param {object} parameters: optional parameters (if optional transform requires them) - * @returns {Resultset} A copy of the internal resultset for branched queries. + * @param transform - Optional name of collection transform, or an array of transform steps + * @param [parameters] - optional parameters (if optional transform requires them) + * @returns A copy of the internal resultset for branched queries. */ - branchResultset(transform?: string | any[], parameters?: any): LokiResultset; + public branchResultset(transform: string | string[] | Transform[], parameters?: object): Resultset; - /** toJSON() - Override of toJSON to avoid circular references + /** + * toJSON() - Override of toJSON to avoid circular references */ - toJSON(): LokiDynamicView; + public toJSON(): DynamicView; - /** removeFilters() - Used to clear pipeline and reset dynamic view to initial state. + /** + * removeFilters() - Used to clear pipeline and reset dynamic view to initial state. * Existing options should be retained. + * @param [options] - configure removeFilter behavior + * @param [options.queueSortPhase] - (default: false) if true we will async rebuild view (maybe set default to true in future?) */ - removeFilters(): void; + public removeFilters(options?: { queueSortPhase?: boolean }): void; - /** applySort() - Used to apply a sort to the dynamic view + /** + * applySort() - Used to apply a sort to the dynamic view + * @example + * dv.applySort(function(obj1, obj2) { + * if (obj1.name === obj2.name) return 0; + * if (obj1.name > obj2.name) return 1; + * if (obj1.name < obj2.name) return -1; + * }); * - * @param {function} comparefun - a javascript compare function used for sorting - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @param comparefun - a javascript compare function used for sorting + * @returns this DynamicView object, for further chain ops. */ - applySort(comparefun: (a: E, b: E) => number): LokiDynamicView; + public applySort(comparefun: (a: E & LokiObj, b: E & LokiObj) => number): this; - /** applySimpleSort() - Used to specify a property used for view translation. + /** + * applySimpleSort() - Used to specify a property used for view translation. + * @example + * dv.applySimpleSort("name"); * - * @param {string} propname - Name of property by which to sort. - * @param {boolean} isdesc - (Optional) If true, the sort will be in descending order. - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @param propname - Name of property by which to sort. + * @param [isdesc] - (Optional) If true, the sort will be in descending order. + * @returns this DynamicView object, for further chain ops. */ - applySimpleSort(propname: string, isdesc?: boolean): LokiDynamicView; + public applySimpleSort(propname: keyof E, isdesc?: boolean): this; - /** applySortCriteria() - Allows sorting a resultset based on multiple columns. - * Example : dv.applySortCriteria(['age', 'name']); to sort by age and then name (both ascending) - * Example : dv.applySortCriteria(['age', ['name', true]); to sort by age (ascending) and then by name (descending) - * Example : dv.applySortCriteria(['age', true], ['name', true]); to sort by age (descending) and then by name (descending) + /** + * applySortCriteria() - Allows sorting a resultset based on multiple columns. + * @example + * // to sort by age and then name (both ascending) + * dv.applySortCriteria(['age', 'name']); + * // to sort by age (ascending) and then by name (descending) + * dv.applySortCriteria(['age', ['name', true]); + * // to sort by age (descending) and then by name (descending) + * dv.applySortCriteria(['age', true], ['name', true]); * - * @param {array} properties - array of property names or subarray of [propertyname, isdesc] used evaluate sort order - * @returns {DynamicView} Reference to this DynamicView, sorted, for future chain operations. + * @param criteria - array of property names or subarray of [propertyname, isdesc] used evaluate sort order + * @returns Reference to this DynamicView, sorted, for future chain operations. */ - applySortCriteria(criteria: ([string, boolean] | [string])[]): LokiDynamicView; + public applySortCriteria(criteria: [keyof E, boolean][]): this; - /** startTransaction() - marks the beginning of a transaction. + /** + * startTransaction() - marks the beginning of a transaction. * - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @returns this DynamicView object, for further chain ops. */ - startTransaction(): LokiDynamicView; + public startTransaction(): this; - /** commit() - commits a transaction. + /** + * commit() - commits a transaction. * - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @returns this DynamicView object, for further chain ops. */ - commit(): LokiDynamicView; + public commit(): this; - /** rollback() - rolls back a transaction. + /** + * rollback() - rolls back a transaction. * - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @returns this DynamicView object, for further chain ops. */ - rollback(): LokiDynamicView; + public rollback(): this; - /** Implementation detail. + /** + * Implementation detail. * _indexOfFilterWithId() - Find the index of a filter in the pipeline, by that filter's ID. * - * @param {string|number} uid - The unique ID of the filter. - * @returns {number}: index of the referenced filter in the pipeline; -1 if not found. + * @param [uid] - The unique ID of the filter. + * @returns index of the referenced filter in the pipeline; -1 if not found. */ - _indexOfFilterWithId(uid: string | number): number; + public _indexOfFilterWithId(uid?: string | number): number; - /** Implementation detail. + /** + * Implementation detail. * _addFilter() - Add the filter object to the end of view's filter pipeline and apply the filter to the resultset. * - * @param {object} filter - The filter object. Refer to applyFilter() for extra details. + * @param filter - The filter object. Refer to applyFilter() for extra details. */ - _addFilter(filter: LokiFilter): void; + public _addFilter(filter: { type: "find" | "where", val: any; uid?: string | number }): void; - /** reapplyFilters() - Reapply all the filters in the current pipeline. + /** + * reapplyFilters() - Reapply all the filters in the current pipeline. * - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @returns this DynamicView object, for further chain ops. */ - reapplyFilters(): LokiDynamicView; + public reapplyFilters(): this; - /** applyFilter() - Adds or updates a filter in the DynamicView filter pipeline + /** + * applyFilter() - Adds or updates a filter in the DynamicView filter pipeline * - * @param {object} filter - A filter object to add to the pipeline. + * @param filter - A filter object to add to the pipeline. * The object is in the format { 'type': filter_type, 'val', filter_param, 'uid', optional_filter_id } - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @returns this DynamicView object, for further chain ops. */ - applyFilter(filter: LokiFilter): LokiDynamicView; + public applyFilter(filter: { type: "find" | "where", val: any; uid?: string | number }): this; - /** applyFind() - Adds or updates a mongo-style query option in the DynamicView filter pipeline + /** + * applyFind() - Adds or updates a mongo-style query option in the DynamicView filter pipeline * - * @param {object} query - A mongo-style query object to apply to pipeline - * @param {string|number} uid - Optional: The unique ID of this filter, to reference it in the future. - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @param query - A mongo-style query object to apply to pipeline + * @param [uid] - Optional: The unique ID of this filter, to reference it in the future. + * @returns this DynamicView object, for further chain ops. */ - applyFind(query: LokiQuery, uid?: string | number): LokiDynamicView; + public applyFind(query: any, uid?: string | number): this; - /** applyWhere() - Adds or updates a javascript filter function in the DynamicView filter pipeline + /** + * applyWhere() - Adds or updates a javascript filter function in the DynamicView filter pipeline * - * @param {function} fun - A javascript filter function to apply to pipeline - * @param {string|number} uid - Optional: The unique ID of this filter, to reference it in the future. - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @param fun - A javascript filter function to apply to pipeline + * @param [uid] - Optional: The unique ID of this filter, to reference it in the future. + * @returns this DynamicView object, for further chain ops. */ - applyWhere(fun: (obj: E) => boolean, uid?: string | number): LokiDynamicView; + public applyWhere(fun: (obj: any) => boolean, uid?: string | number): this; - /** removeFilter() - Remove the specified filter from the DynamicView filter pipeline + /** + * removeFilter() - Remove the specified filter from the DynamicView filter pipeline * - * @param {string|number} uid - The unique ID of the filter to be removed. - * @returns {DynamicView} this DynamicView object, for further chain ops. + * @param uid - The unique ID of the filter to be removed. + * @returns this DynamicView object, for further chain ops. */ - removeFilter(uid: string | number): LokiDynamicView; + public removeFilter(uid: string | number): this; - /** count() - returns the number of documents representing the current DynamicView contents. + /** + * count() - returns the number of documents representing the current DynamicView contents. * - * @returns {number} The number of documents representing the current DynamicView contents. + * @returns The number of documents representing the current DynamicView contents. */ - count(): number; + public count(): number; - /** data() - resolves and pending filtering and sorting, then returns document array as result. + /** + * data() - resolves and pending filtering and sorting, then returns document array as result. * - * @returns {array} An array of documents representing the current DynamicView contents. + * @param [options] - optional parameters to pass to resultset.data() if non-persistent + * @param [options.forceClones] - Allows forcing the return of cloned objects even when + * the collection is not configured for clone object. + * @param [options.forceCloneMethod] - Allows overriding the default or collection specified cloning method. + * Possible values include 'parse-stringify', 'jquery-extend-deep', 'shallow', 'shallow-assign' + * @param [options.removeMeta] - Will force clones and strip $loki and meta properties from documents + * @returns An array of documents representing the current DynamicView contents. */ - data(): E[]; + public data(options?: Partial): (E & LokiObj)[]; - /** queueRebuildEvent() - When the view is not sorted we may still wish to be notified of rebuild events. + /** + * queueRebuildEvent() - When the view is not sorted we may still wish to be notified of rebuild events. * This event will throttle and queue a single rebuild event when batches of updates affect the view. */ - queueRebuildEvent(): void; + public queueRebuildEvent(): void; - /** queueSortPhase : If the view is sorted we will throttle sorting to either : + /** + * queueSortPhase : If the view is sorted we will throttle sorting to either : * (1) passive - when the user calls data(), or * (2) active - once they stop updating and yield js thread control */ - queueSortPhase(): void; + public queueSortPhase(): void; - /** performSortPhase() - invoked synchronously or asynchronously to perform final sort phase (if needed) + /** + * performSortPhase() - invoked synchronously or asynchronously to perform final sort phase (if needed) */ - performSortPhase(options?: { suppressRebuildEvent?: boolean; }): void; + public performSortPhase(options?: { persistent?: boolean; suppressRebuildEvent?: boolean }): void; - /** evaluateDocument() - internal method for (re)evaluating document inclusion. + /** + * evaluateDocument() - internal method for (re)evaluating document inclusion. * Called by : collection.insert() and collection.update(). * - * @param {int} objIndex - index of document to (re)run through filter pipeline. - * @param {bool} isNew - true if the document was just added to the collection. + * @param objIndex - index of document to (re)run through filter pipeline. + * @param [isNew] - true if the document was just added to the collection. */ - evaluateDocument(objIndex: number, isNew?: boolean): void; + public evaluateDocument(objIndex: number | string, isNew?: boolean): void; - /** removeDocument() - internal function called on collection.delete() + + /** + * removeDocument() - internal function called on collection.delete() */ - removeDocument(objIndex: number): void; + public removeDocument(objIndex: number | string): void; - /** mapReduce() - data transformation via user supplied functions + /** + * mapReduce() - data transformation via user supplied functions * - * @param {function} mapFunction - this function accepts a single document for you to transform and return - * @param {function} reduceFunction - this function accepts many (array of map outputs) and returns single value + * @param mapFunction - this function accepts a single document for you to transform and return + * @param reduceFunction - this function accepts many (array of map outputs) and returns single value * @returns The output of your reduceFunction */ - mapReduce(mapFunction: (item: E, index: number, array: E[]) => T, reduceFunction: (array: T[]) => U): U; + public mapReduce(mapFunction: (value: E, index: number, array: E[]) => U, reduceFunction: (ary: U[]) => R): R; } - -/** Collection class that handles documents of same type - */ -interface LokiCollection extends LokiEventEmitter { - // option to observe objects and update them automatically, ignored if Object.observe is not supported - autoupdate: boolean; - // option to make event listeners async, default is sync - asyncListeners: boolean; - binaryIndices: { [id: string]: { name: string; dirty: boolean; values: number[] } }; - - cachedIndex: number[]; - cachedBinaryIndex: { [id: string]: { name: string; dirty: boolean; values: number[] } }; - cachedData: E[]; - // changes are tracked by collection and aggregated by the db - changes: LokiCollectionChange[]; - // default clone method (if enabled) is parse-stringify - cloneMethod: string; // 'parse-stringify' - // options to clone objects when inserting them - cloneObjects: boolean; - console: { - log: () => void; - warn: () => void; - error: () => void; - }; - constraints: { - unique: { [id: string]: LokiUniqueIndex }; - exact: { [id: string]: LokiExactIndex }; - }; - data: E[]; - // in autosave scenarios we will use collection level dirty flags to determine whether save is needed. - // currently, if any collection is dirty we will autosave the whole database if autosave is configured. - // defaulting to true since this is called from addCollection and adding a collection should trigger save - dirty: boolean; - // disable track changes - disableChangesApi: boolean; - DynamicViews: LokiDynamicView[]; - events: { [id: string]: ((...args: any[]) => void)[] }; /*{ - 'insert': ((...args) => void)[]; - 'update': ((...args) => void)[]; - 'pre-insert': ((...args) => void)[]; - 'pre-update': ((...args) => void)[]; - 'close': ((...args) => void)[]; - 'flushbuffer': ((...args) => void)[]; - 'error': ((...args) => void)[]; - 'delete': ((...args) => void)[]; - 'warning': ((...args) => void)[]; - };*/ - idIndex: number[]; - maxId: number; // currentMaxId - change manually at your own peril! +interface BinaryIndex { name: string; - // is collection transactional + dirty: boolean; + values: number[]; +} + + +interface CollectionOptions { + disableChangesApi: boolean; + disableDeltaChangesApi: boolean; + adaptiveBinaryIndices: boolean; + asyncListeners: boolean; + autoupdate: boolean; + clone: boolean; + cloneMethod: ("parse-stringify" | "jquery-extend-deep" | "shallow" | "shallow-assign" | "shallow-recurse-objects"); + serializableIndices: boolean; transactional: boolean; + ttl: number; + ttlInterval: number; + exact: (keyof E)[]; + unique: (keyof E)[]; + indices: (keyof E) | (keyof E)[]; +} + + +interface CollectionChange { + name: string; + operation: string; + obj: any; +} + + +/** + * Collection class that handles documents of same type + * @implements LokiEventEmitter + * @see {@link Loki#addCollection} for normal creation of collections + */ +declare class Collection extends LokiEventEmitter { + name: string; objType: string; - // transforms will be used to store frequently used query chains as a series of steps - // which itself can be stored along with the database. - transforms: { [id: string]: any }; - // unique contraints contain duplicate object references, so they are not persisted. - // we will keep track of properties which have unique contraint applied here, and regenerate on load - uniqueNames: string[]; + data: E[]; + adaptiveBinaryIndices: boolean; + asyncListeners: boolean; + autoupdate: boolean; + dirty: boolean; + binaryIndices: { [P in keyof E]: BinaryIndex }; + cachedIndex: number[] | null; + cachedBinaryIndex: { [P in keyof E]: BinaryIndex } | null; + cachedData: E[] | null; + changes: CollectionChange[]; + cloneMethod: ("parse-stringify" | "jquery-extend-deep" | "shallow" | "shallow-assign" | "shallow-recurse-objects") | null; + cloneObjects: boolean; + constraints: { + unique: { [P in keyof E]: UniqueIndex }; + exact: { [P in keyof E]: ExactIndex } + }; + disableChangesApi: boolean; + disableDeltaChangesApi: boolean; + DynamicViews: DynamicView[]; + idIndex: number[]; + ttl: { age: any; ttlInterval: any; daemon: any; }; + maxId: number; + uniqueNames: (keyof E)[]; + transforms: { [name: string]: Transform[] }; + serializableIndices: boolean; + transactional: boolean; + observerCallback: (changes: { object: any }[]) => void; + getChanges: () => CollectionChange[]; + flushChanges: () => void; + getChangeDelta: (obj: any, old?: any) => any; + getObjectDelta: (oldObject: any, newObject?: any) => any; + setChangesApi: (enabled?: boolean) => void; - options: LokiCollectionOptions; - // option to activate a cleaner daemon - clears "aged" documents at set intervals. - ttl: { - age: number; - ttlInterval: number; - daemon: number; + /** + * @param name - collection name + * @param [options] - (optional) configuration object + * @param [options.unique=[]] - array of property names to define unique constraints for + * @param [options.exact=[]] - array of property names to define exact constraints for + * @param [options.indices=[]] - array property names to define binary indexes for + * @param [options.adaptiveBinaryIndices=true] - collection indices will be actively rebuilt rather than lazily + * @param [options.asyncListeners=false] - whether listeners are invoked asynchronously + * @param [options.disableChangesApi=true] - set to false to enable Changes API + * @param [options.disableDeltaChangesApi=true] - set to false to enable Delta Changes API (requires Changes API, forces cloning) + * @param [options.autoupdate=false] - use Object.observe to update objects automatically + * @param [options.clone=false] - specify whether inserts and queries clone to/from user + * @param [options.serializableIndices=true[]] - converts date values on binary indexed properties to epoch time + * @param [options.cloneMethod='parse-stringify'] - 'parse-stringify', 'jquery-extend-deep', 'shallow', 'shallow-assign' + * @param options.ttlInterval - time interval for clearing out 'aged' documents; not set by default. + * @see {@link Loki#addCollection} for normal creation of collections + */ + constructor(name: string, options?: Partial>); + + public console: { + log(...args: any[]): void; + warn(...args: any[]): void; + error(...args: any[]): void; }; - /** Collection class that handles documents of same type - * @constructor - * @param {string} collection name - * @param {array} array of property names to be indicized - * @param {object} configuration object + public addAutoUpdateObserver(obj: any): void; + + public removeAutoUpdateObserver(obj: any): void; + + /** + * Adds a named collection transform to the collection + * @param name - name to associate with transform + * @param transform - an array of transformation 'step' objects to save into the collection + * @example + * users.addTransform('progeny', [ + * { + * type: 'find', + * value: { + * 'age': {'$lte': 40} + * } + * } + * ]); + * + * var results = users.chain('progeny').data(); */ - new (name: string, options?: LokiCollectionOptions): LokiCollection; + public addTransform(name: string, transform: Transform[]): void; - getChanges(): LokiCollectionChange[]; + /** + * Retrieves a named transform from the collection. + * @param name - name of the transform to lookup. + */ + public getTransform(name: string): Transform[]; - setChangesApi(enabled: boolean): void; + /** + * Updates a named collection transform to the collection + * @param name - name to associate with transform + * @param transform - a transformation object to save into collection + */ + public setTransform(name: string, transform: Transform[]): void; - flushChanges(): void; + /** + * Removes a named collection transform from the collection + * @param name - name of collection transform to remove + */ + public removeTransform(name: string): void; - observerCallback: (changes: { object: any }[]) => void; + public byExample(template: object): { $and: any[] }; - addAutoUpdateObserver(object: any): void; + public findObject(template: object): E | null; - removeAutoUpdateObserver(object: any): void; - - addTransform(name: string, transform: any): void; - - setTransform(name: string, transform: any): void; - - removeTransform(name: string): void; - - byExample(template: any): { '$and': any[] }; - - findObject(template: any): E; - - findObjects(template: any): E[]; + public findObjects(template: object): E[]; /*----------------------------+ | TTL daemon | +----------------------------*/ - ttlDaemonFuncGen(): () => void; + public ttlDaemonFuncGen(): () => void; - setTTL(age: number, interval: number): void; + /** + * Updates or applies collection TTL settings. + * @param age - age (in ms) to expire document from collection + * @param interval - time (in ms) to clear collection of aged documents. + */ + public setTTL(age: number, interval: number): void; /*----------------------------+ | INDEXING | @@ -857,711 +1434,575 @@ interface LokiCollection extends LokiEventEmitter { /** * create a row filter that covers all documents in the collection */ - prepareFullDocIndex(): number[]; + public prepareFullDocIndex(): number[]; - /** Ensure binary index on a certain field + /** + * Will allow reconfiguring certain collection options. + * @param [options.adaptiveBinaryIndices] - collection indices will be actively rebuilt rather than lazily */ - ensureIndex(property: string, force?: boolean): void; + public configureOptions(options?: { adaptiveBinaryIndices?: boolean }): void; - ensureUniqueIndex(field: string): LokiUniqueIndex; - - /** Ensure all binary indices + /** + * Ensure binary index on a certain field + * @param property - name of property to create binary index on + * @param [force] - (Optional) flag indicating whether to construct index immediately */ - ensureAllIndexes(force?: boolean): void; + public ensureIndex(property: keyof E, force?: boolean): void; - flagBinaryIndexesDirty(): void; + public getSequencedIndexValues(property: string): string; - flagBinaryIndexDirty(index: string): void; + public ensureUniqueIndex(field: keyof E): UniqueIndex; - count(query?: LokiQuery): number; - - /** Rebuild idIndex + /** + * Ensure all binary indices */ - ensureId(): void; + public ensureAllIndexes(force?: boolean): void; - /** Rebuild idIndex async with callback - useful for background syncing with a remote server + public flagBinaryIndexesDirty(): void; + + public flagBinaryIndexDirty(index: string): void; + + /** + * Quickly determine number of documents in collection (or query) + * @param [query] - (optional) query object to count results of + * @returns number of documents in the collection */ - ensureIdAsync(callback: () => void): void; + public count(query?: LokiQuery): number; - /** Each collection maintains a list of DynamicViews associated with it + /** + * Rebuild idIndex + */ + public ensureId(): void; + + /** + * Rebuild idIndex async with callback - useful for background syncing with a remote server + */ + public ensureIdAsync(callback: () => void): void; + + /** + * Add a dynamic view to the collection + * @param name - name of dynamic view to add + * @param [options] - options to configure dynamic view with + * @param [options.persistent=false] - indicates if view is to main internal results array in 'resultdata' + * @param [options.sortPriority='passive'] - 'passive' (sorts performed on call to data) or 'active' (after updates) + * @param options.minRebuildInterval - minimum rebuild interval (need clarification to docs here) + * @returns reference to the dynamic view added + * @example + * var pview = users.addDynamicView('progeny'); + * pview.applyFind({'age': {'$lte': 40}}); + * pview.applySimpleSort('name'); + * + * var results = pview.data(); + */ + public addDynamicView(name: string, options?: Partial): DynamicView; + + /** + * Remove a dynamic view from the collection + * @param name - name of dynamic view to remove **/ - addDynamicView(name: string, options?: LokiDynamicViewOptions): LokiDynamicView; + public removeDynamicView(name: string): void; - removeDynamicView(name: string): void; + /** + * Look up dynamic view reference from within the collection + * @param name - name of dynamic view to retrieve reference of + * @returns A reference to the dynamic view with that name + **/ + public getDynamicView(name: string): DynamicView | null; - getDynamicView(name: string): LokiDynamicView; - - /** find and update: pass a filtering function to select elements to be updated - * and apply the updatefunctino to those elements iteratively + /** + * Applies a 'mongo-like' find query object and passes all results to an update function. + * For filter function querying you should migrate to [updateWhere()]{@link Collection#updateWhere}. + * + * @param filterObject - 'mongo-like' query object (or deprecated filterFunction mode) + * @param updateFunction - update function to run against filtered documents */ - findAndUpdate(filterFunction: (obj: E) => boolean, updateFunction: (obj: E) => E): void; + public findAndUpdate(filterObject: ((data: E) => boolean) | LokiQuery, updateFunction: (obj: E & LokiObj) => any): void; - /** generate document method - ensure object(s) have meta properties, clone it if necessary, etc. - * @param {object} doc: the document to be inserted (or an array of objects) - * @returns document or documents (if passed an array of objects) + /** + * Applies a 'mongo-like' find query object removes all documents which match that filter. + * + * @param filterObject - 'mongo-like' query object */ - insert(doc: E): E; - insert(doc: E[]): E[]; + public findAndRemove(filterObject?: LokiQuery): void; - /** generate document method - ensure object has meta properties, clone it if necessary, etc. - * @param {object} the document to be inserted + /** + * Adds object(s) to collection, ensure object(s) have meta properties, clone it if necessary, etc. + * @param doc - the document (or array of documents) to be inserted + * @returns document or documents inserted + * @example + * users.insert({ + * name: 'Odin', + * age: 50, + * address: 'Asgard' + * }); + * + * // alternatively, insert array of documents + * users.insert([{ name: 'Thor', age: 35}, { name: 'Loki', age: 30}]); + */ + public insert(doc: E): E | undefined; + public insert(doc: E[]): E[] | undefined; + public insert(doc: E | E[]): E | E[] | undefined; + public insert(doc: E | E[]): E | E[] | undefined; + + /** + * Adds a single object, ensures it has meta properties, clone it if necessary, etc. + * @param doc - the document to be inserted + * @param [bulkInsert] - quiet pre-insert and insert event emits * @returns document or 'undefined' if there was a problem inserting it */ - insertOne(doc: E): E; + public insertOne(doc: E, bulkInsert?: boolean): (E & LokiObj) | undefined; - clear(): void; - - /** Update method + /** + * Empties the collection. + * @param [options] - configure clear behavior + * @param [options.removeIndices] - (default: false) */ - update(doc: E): E; - update(doc: E[]): void; + public clear(options?: { removeIndices?: boolean }): void; - /** Add object to collection + /** + * Updates an object and notifies collection that the document has changed. + * @param doc - document to update within the collection */ - add(obj: E): E; + public update(doc: E): E; + public update(doc: E[]): void; + public update(doc: E | E[]): E | void; + public update(doc: E | E[]): E | void; - removeWhere(query: ((obj: E) => boolean) | LokiQuery): void; - - removeDataOnly(): void; - - /** delete wrapped + /** + * Add object to collection */ - remove(doc: E): E; - remove(doc: number): E; - remove(doc: number[]): void; - remove(doc: E[]): void; + public add(obj: E): E & LokiObj; + public add(obj: E & LokiObj): E & LokiObj; + + /** + * Applies a filter function and passes all results to an update function. + * + * @param filterFunction - filter function whose results will execute update + * @param updateFunction - update function to run against filtered documents + */ + public updateWhere(filterFunction: (data: E) => boolean, updateFunction: (obj: E & LokiObj) => any): void; + + /** + * Remove all documents matching supplied filter function. + * For 'mongo-like' querying you should migrate to [findAndRemove()]{@link Collection#findAndRemove}. + * @param query - query object to filter on + */ + public removeWhere(query: ((value: E, index: number, array: E[]) => boolean) | LokiQuery): void; + + public removeDataOnly(): void; + + /** + * Remove a document from the collection + * @param doc - document to remove from collection + */ + public remove(doc: number | E): E | null; + public remove(doc: number[] | E[]): void; + public remove(doc: number | E | number[] | E[]): E | null | void; + public remove(doc: number | E | number[] | E[]): E | null | void; /*---------------------+ | Finding methods | +----------------------*/ - /** Get by Id - faster than other methods because of the searching algorithm + /** + * Get by Id - faster than other methods because of the searching algorithm + * @param id - $loki id of document you want to retrieve + * @param returnPosition - if 'true' we will return [object, position] + * @returns Object reference if document was found, null if not, + * or an array if 'returnPosition' was passed. */ - get(id: number | string): E; - get(id: number | string, returnPosition?: boolean): E | [E, number]; + public get(id: number): E & LokiObj; + public get(id: number, returnPosition: true): [E & LokiObj, number]; + public get(id: number, returnPosition?: boolean): (E & LokiObj) | [E & LokiObj, number] | null; - by(field: string): (value: any) => E; - by(field: string, value: string): E; - - /** Find one object by index property, by property equal to value + /** + * Perform binary range lookup for the data[dataPosition][binaryIndexName] property value + * Since multiple documents may contain the same value (which the index is sorted on), + * we hone in on range and then linear scan range to find exact index array position. + * @param dataPosition : coll.data array index/position + * @param binaryIndexName : index to search for dataPosition in */ - findOne(query: LokiQuery): E; + public getBinaryIndexPosition(dataPosition: number, binaryIndexName: keyof E): number | null; - /** Chain method, used for beginning a series of chained find() and/or view() operations + /** + * Adaptively insert a selected item to the index. + * @param dataPosition : coll.data array index/position + * @param binaryIndexName : index to search for dataPosition in + */ + public adaptiveBinaryIndexInsert(dataPosition: number, binaryIndexName: keyof E): void; + + /** + * Adaptively update a selected item within an index. + * @param dataPosition : coll.data array index/position + * @param binaryIndexName : index to search for dataPosition in + */ + public adaptiveBinaryIndexUpdate(dataPosition: number, binaryIndexName: keyof E): void; + + /** + * Adaptively remove a selected item from the index. + * @param dataPosition : coll.data array index/position + * @param binaryIndexName : index to search for dataPosition in + */ + public adaptiveBinaryIndexRemove(dataPosition: number, binaryIndexName: keyof E, removedFromIndexOnly?: boolean): void; + + /** + * Internal method used for index maintenance and indexed searching. + * Calculates the beginning of an index range for a given value. + * For index maintainance (adaptive:true), we will return a valid index position to insert to. + * For querying (adaptive:false/undefined), we will : + * return lower bound/index of range of that value (if found) + * return next lower index position if not found (hole) + * If index is empty it is assumed to be handled at higher level, so + * this method assumes there is at least 1 document in index. + * + * @param prop - name of property which has binary index + * @param val - value to find within index + * @param [adaptive] - if true, we will return insert position + */ + public calculateRangeStart(prop: keyof E, val: any, adaptive?: boolean): number; + + /** + * Internal method used for indexed $between. Given a prop (index name), and a value + * (which may or may not yet exist) this will find the final position of that upper range value. + */ + public calculateRangeEnd(prop: keyof E, val: any): number; + + /** + * calculateRange() - Binary Search utility method to find range/segment of values matching criteria. + * this is used for collection.find() and first find filter of resultset/dynview + * slightly different than get() binary search in that get() hones in on 1 value, + * but we have to hone in on many (range) + * @param op - operation, such as $eq + * @param prop - name of property to calculate range for + * @param val - value to use for range calculation. + * @returns [start, end] index array positions + */ + public calculateRange(op: ("$eq" | "$aeq" | "$dteq" | "$gt" | "$gte" | "$lt" | "$lte" | "$between" | "$in"), prop: keyof E, val: any): number[]; + + /** + * Retrieve doc by Unique index + * @param field - name of uniquely indexed property to use when doing lookup + * @param value - unique value to search for + * @returns document matching the value passed + */ + public by(field: keyof E): (value: any) => E | undefined; + public by(field: keyof E, value: any): E | undefined; + public by(field: keyof E, value?: any): E | ((value: any) => E | undefined) | undefined; + public by(field: keyof E, value?: any): E | ((value: any) => E | undefined) | undefined; + + /** + * Find one object by index property, by property equal to value + * @param query - query object used to perform search with + * @returns First matching document, or null if none + */ + public findOne(query?: LokiQuery): (E & LokiObj) | null; + + /** + * Chain method, used for beginning a series of chained find() and/or view() operations * on a collection. * - * @param {array} transform : Ordered array of transform step objects similar to chain - * @param {object} parameters: Object containing properties representing parameters to substitute - * @returns {Resultset} : (or data array if any map or join functions where called) + * @param [transform] - Ordered array of transform step objects similar to chain + * @param [parameters] - Object containing properties representing parameters to substitute + * @returns (this) resultset, or data array if any map or join functions where called */ - chain(transform?: string | any[], parameters?: any): LokiResultset; + public chain(): Resultset; + public chain(transform?: string | string[] | Transform[], parameters?: object): Resultset; /** - * Find method, api is similar to mongodb except for now it only supports one search parameter. - * for more complex queries use view() and storeView() + * Find method, api is similar to mongodb. + * for more complex queries use [chain()]{@link Collection#chain} or [where()]{@link Collection#where}. + * @example {@tutorial Query Examples} + * @param query - 'mongo-like' query object + * @returns Array of matching documents */ - find(): E[]; - find(query: LokiQuery): LokiResultset; + public find(query?: LokiQuery): (E & LokiObj)[]; - /** Find object by unindexed field by property equal to value, + /** + * Find object by unindexed field by property equal to value, * simply iterates and returns the first element matching the query */ - findOneUnindexed(prop: string, value: any): E; - - /** Transaction methods */ - - /** start the transation */ - startTransaction(): void; - - /** commit the transation */ - commit(): void; - - /** roll back the transation */ - rollback(): void; - - // async executor. This is only to enable callbacks at the end of the execution. - async(fun: () => void, callback: () => void): void; - - /** Create view function - filter - */ - where(fun: (obj: E) => boolean): LokiResultset; - - /** Map Reduce - */ - mapReduce(mapFunction: (item: E, index: number, array: E[]) => U, reduceFunction: (array: U[]) => V): V; - - /** eqJoin - Join two collections on specified properties - */ - eqJoin(joinData: T[] | LokiResultset, leftJoinProp: string | ((obj: E) => string), rightJoinProp: string | ((obj: T) => string)): LokiResultset<{ left: E; right: T; }>; - eqJoin(joinData: T[] | LokiResultset, leftJoinProp: string | ((obj: E) => string), rightJoinProp: string | ((obj: T) => string), mapFun?: (a: E, b: T) => U): LokiResultset; - - /* ------ STAGING API -------- */ - /** stages: a map of uniquely identified 'stages', which hold copies of objects to be - * manipulated without affecting the data in the original collection - */ - stages: { [id: string]: any }; - - /** create a stage and/or retrieve it - */ - getStage(name: string): E[]; - - /** a collection of objects recording the changes applied through a commmitStage - */ - commitLog: { - timestamp: number; // timestamp (i.e. new Date().getTime()) - message: any; - data: E; - }[]; - - /** create a copy of an object and insert it into a stage - */ - stage(stageName: string, obj: E): E; - - /** re-attach all objects to the original collection, so indexes and views can be rebuilt - * then create a message to be inserted in the commitlog - */ - commitStage(stageName: string, message: any): void; - - no_op(): void; - - extract(field: string): any[]; - - max(field: string): number; - - min(field: string): number; - - maxRecord(field: string): { index: number; value: any; }; - - minRecord(field: string): { index: number; value: any; }; - - extractNumerical(field: string): number[]; - - avg(field: string): number; - - stdDev(field: string): number; - - mode(field: string): string | number; - - median(field: string): number; -} - - - - -/** comparison operators - * a is the value in the collection - * b is the query value - */ -interface LokiOps { - $eq(a: any, b: any): boolean; - $ne(a: any, b: any): boolean; - $dteq(a: any, b: any): boolean; - $gt(a: any, b: any): boolean; - $gte(a: any, b: any): boolean; - $lt(a: any, b: any): boolean; - $lte(a: any, b: any): boolean; - $in(a: any, b: { indexOf: (value: any) => boolean }): boolean; - $nin(a: any, b: { indexOf: (value: any) => boolean }): boolean; - $keyin(a: string, b: any): boolean; - $nkeyin(a: string, b: any): boolean; - $definedin(a: any, b: any): boolean; - $undefinedin(a: any, b: any): boolean; - $regex(a: any, b: RegExp | { test: (str: string) => boolean }): boolean; - $containsString(a: string | any, b: string): boolean; - $containsNone(a: any, b: any): boolean; - $containsAny(a: any, b: any | any[]): boolean; - $contains(a: any, b: any | any[]): boolean; - $type(a: any, b: any): boolean; - $size(a: any, b: any): boolean; - $len(a: any, b: any): boolean; - // field-level logical operators - // a is the value in the collection - // b is the nested query operation (for '$not') - // or an array of nested query operations (for '$and' and '$or') - $not(a: any, b: any): boolean; - $and(a: any, b: any[]): boolean; - $or(a: any, b: any[]): boolean; -} - - -interface LokiKeyValueStore { - keys: K[]; - values: V[]; - - sort(a: any, b: any): number; - setSort(fun: (a: K, b: K) => number): void; - bs(): LokiBSonSort; - set(key: K, value: V): void; - get(key: K): V; -} - - -interface LokiUniqueIndex { - field: string; - keyMap: { [id: string]: E }; - lokiMap: { [id: number]: any }; - - new (uniqueField: string): LokiUniqueIndex; - - set(obj: E): void; - get(key: string): E; - byId(id: number): E; - update(obj: E): void; - remove(key: string): void; - clear(): void; -} - - -interface LokiExactIndex { - index: { [id: string]: E[] }; - field: string; - - new (exactField: string): LokiExactIndex - - /** add the value you want returned to the key in the index */ - set(key: string, val: E): void; - /** remove the value from the index, if the value was the last one, remove the key */ - remove(key: string, val: E): void; - /** get the values related to the key, could be more than one */ - get(key: string): E[]; - /** clear will zap the index */ - clear(key?: any): void; -} - - -interface LokiSortedIndex { - field: string; - keys: K[]; - values: V[][]; - - new (sortedField: string): LokiSortedIndex; - - // set the default sort - sort(a: any, b: any): number; - bs(): LokiBSonSort; - // and allow override of the default sort - setSort(fun: (a: any, b: any) => number): void; - // add the value you want returned to the key in the index - set(key: K, value: V): void; - // get all values which have a key == the given key - get(key: K): V[]; - // get all values which have a key < the given key - getLt(key: K): V[]; - // get all values which have a key > the given key - getGt(key: K): V[]; - // get all vals from start to end - getAll(key: K, start: number, end: number): V[]; - // just in case someone wants to do something smart with ranges - getPos(key: K): { found: boolean; index: number; }; - // remove the value from the index, if the value was the last one, remove the key - remove(key: K, value: V): void; - // clear will zap the index - clear(): void; -} - - -interface LokiConfigureOptions { - adapter?: LokiPersistenceInterface; - autoload?: boolean; - autoloadCallback?: (dataOrErr: any | Error) => void; - autosave?: boolean; - autosaveCallback?: (err: any) => void; - autosaveInterval?: number; // milliseconds between auto-saves - env?: string; /*'NODEJS', 'BROWSER', 'CORDOVA'*/ - persistenceMethod?: string; /*'fs', 'localStorage', 'adapter'*/ - verbose?: boolean; -} - - -interface LokiCollectionOptions { - asyncListeners?: boolean; - autoupdate?: boolean; - clone?: boolean; - cloneMethod?: string; - disableChangesApi?: boolean; - exact?: string[]; - indices?: string | string[]; - transactional?: boolean; - unique?: string | string[]; -} - - -interface LokiDynamicViewOptions { - minRebuildInterval?: number; - persistent?: boolean; - sortPriority: string; /*'active', 'passive'*/ -} - - -interface LokiResultsetOptions { - firstOnly?: boolean; - queryObj?: LokiQuery; - queryFunc?: (item: E) => boolean; -} - - -interface LokiQuery { -} - - -interface LokiFilter { - type: string; /*'find', 'where'*/ - val: LokiQuery | ((obj: E, index: number, array: E[]) => boolean); - uid: number | string; -} - - -interface LokiElementMetaData { - created: number; // unix style timestamp (i.e. new Date().getTime()) - revision: number; -} - - -interface LokiCollectionChange { - name: string; - operation: string;/*'I', 'R', 'U'*/ - obj: any; -} - - -interface LokiBSonSort { - (fun: (a: T, b: T) => number): (array: T[], item: T) => { found: boolean; index: number; }; -} - - -/* -interface LokiUtils { - copyProperties(src: any, dest: any): void; - - // used to recursively scan hierarchical transform step object for param substitution - resolveTransformObject(subObj: U, params: any, depth?: number): U; - - // top level utility to resolve an entire (single) transform (array of steps) for parameter substitution - resolveTransformParams(transform: U[], params: any): U[]; -} - -// Sort helper that support null and undefined -declare function ltHelper(prop1: any, prop2: any, equal?: boolean): boolean; - -declare function gtHelper(prop1: any, prop2: any, equal?: boolean): boolean; - -declare function sortHelper(prop1: any, prop2: any, desc?: boolean): number; - -declare function doQueryOp(val: any, op: any): boolean; - -declare function containsCheckFn(a: T[], b): (curr: T) => boolean; -declare function containsCheckFn(a: string, b): (curr: string) => boolean; -declare function containsCheckFn(a: T, b): (curr: string) => boolean; -*/ - -/** General utils, including statistical functions - */ -/* -declare function isDeepProperty(field: string): boolean; - -declare function parseBase10(num: string | number): number; - -declare function isNotUndefined(obj: any): boolean; - -declare function add(a: string | number, b: string | number): number; - -declare function sub(a: string | number, b: string | number): number; - -declare function median(values: number[]): number; - -declare function average(array: (string | number)[]); - -declare function standardDeviation(values: (string | number)[]): number; - -declare function deepProperty(obj: any, property: string, isDeep?: boolean): any; - -declare function binarySearch(array: U[], item: U, fun: (a: U, b: U) => number): { found: boolean; index: number; }; - -// compoundeval() - helper function for compoundsort(), performing individual object comparisons -// -// @param {array} properties - array of property names, in order, by which to evaluate sort order -// @param {object} obj1 - first object to compare -// @param {object} obj2 - second object to compare -// @returns {integer} 0, -1, or 1 to designate if identical (sortwise) or which should be first -declare function compoundeval(properties: ([string, boolean] | [string])[], obj1: any, obj2: any): number; - -// dotSubScan - helper function used for dot notation queries. -declare function dotSubScan(root: any | any[], propPath: string[], fun: (root, value: V) => boolean, value: V): boolean; - -// making indexing opt-in... our range function knows how to deal with these ops : -//var indexedOpsList = ['$eq', '$dteq', '$gt', '$gte', '$lt', '$lte']; - -declare function clone(data: U, method?: string): U; // stage: 'parse-stringify', 'jquery-extend-deep', 'shallow' - -declare function cloneObjectArray(objarray: U[], method?: string): U; // stage: 'parse-stringify', 'jquery-extend-deep', 'shallow' - -declare function localStorageAvailable(): boolean; -*/ - - - - -/* ======== loki-indexed-adapter.js ======== */ -interface LokiIndexedAdapter { - app: string; - catalog: LokiCatalog; - - /** IndexedAdapter - Loki persistence adapter class for indexedDb. - * This class fulfills abstract adapter interface which can be applied to other storage methods - * Utilizes the included LokiCatalog app/key/value database for actual database persistence. - * @param {string} appname - Application name context can be used to distinguish subdomains or just 'loki' - */ - new (appname: string): LokiIndexedAdapter; - - /** checkAvailability - used to check if adapter is available - * @returns {boolean} true if indexeddb is available, false if not. - */ - checkAvailability(): boolean; - - /** loadDatabase() - Retrieves a serialized db string from the catalog. - * @param {string} dbname - the name of the database to retrieve. - * @param {function} callback - callback should accept string param containing serialized db string. - */ - loadDatabase(dbname: string, callback?: (data: any) => void): void; - - // alias for loadDatabase - loadKey(dbname: string, callback?: (data: any) => void): void; - - /** saveDatabase() - Saves a serialized db to the catalog. - * @param {string} dbname - the name to give the serialized database within the catalog. - * @param {string} dbstring - the serialized db string to save. - * @param {function} callback - (Optional) callback passed obj.success with true or false - */ - saveDatabase(dbname: string, dbstring: string, callback?: (err: Error | void) => void): void; - - // alias for saveDatabase - saveKey(dbname: string, dbstring: string, callback?: (err: Error | void) => void): void; - - /** deleteDatabase() - Deletes a serialized db from the catalog. - * @param {string} dbname - the name of the database to delete from the catalog. - */ - deleteDatabase(dbname: string): void; - - // alias for deleteDatabase - deleteKey(dbname: string): void; - - /** getDatabaseList() - Retrieves object array of catalog entries for current app. - * @param {function} callback - should accept array of database names in the catalog for current app. - */ - getDatabaseList(callback: (names: string[]) => void): void; - - // alias for getDatabaseList - getKeyList(callback: (names: string[]) => void): void; - - /** getCatalogSummary - allows retrieval of list of all keys in catalog along with size - * @param {function} callback - (Optional) callback to accept result array. - */ - getCatalogSummary(callback: (entries: { app: string; key: string; size: number; }) => void): void; -} - - -/** LokiCatalog - underlying App/Key/Value catalog persistence - * This non-interface class implements the actual persistence. - * Used by the IndexedAdapter class. - */ -interface LokiCatalog { - db: IDBDatabase; - - new (callback: (cat: LokiCatalog) => void): LokiCatalog; - - initializeLokiCatalog(callback: (cat: LokiCatalog) => void): void; - - getAppKey(app: string, key: string, callback: (resObj: any) => void): void; - - getAppKeyById(id: any, callback: (result: any, data: T) => void, data: T): void; - - setAppKey(app: string, key: string, val: any, callback: (res: { success: boolean }) => void): void; - - deleteAppKey(id: any, callback: (res: { success: boolean; }) => void): void; - - getAppKeys(app: string, callback: (data: any[]) => void): void; - - // Hide 'cursoring' and return array of { id: id, key: key } - getAllKeys(callback: (data: any[]) => void): void; -} -/* ======== END loki-indexed-adapter.js ======== */ - - - -/* ======== loki-crypted-file-adapter.js ======== */ -/** - * @file lokiCryptedFileAdapter.js - * @author Hans Klunder - */ - -/** require libs */ -//var fs = require('fs'); -//var cryptoLib = require('crypto'); -//var isError = require('util').isError; - -/* The default Loki File adapter uses plain text JSON files. This adapter crypts the database string and wraps the result -* in a JSON including enough info to be able to decrypt it (except for the 'secret' of course !) -* -* The idea is that the 'secret' does not reside in your source code but is supplied by some other source (e.g. the user in node-webkit) -* -* The idea + encrypt/decrypt routines are borrowed from https://github.com/mmoulton/krypt/blob/develop/lib/krypt.js -* not using the krypt module to avoid third party dependencies -*/ -interface LokiCryptedFileAdapter { - secret: string; - - /** The constructor is automatically called on `require` , see examples below - * @constructor - */ - new (): LokiCryptedFileAdapter; - - /** setSecret() - set the secret to be used during encryption and decryption - * - * @param {string} secret - the secret to be used - */ - setSecret(secret: string): void; - - /** loadDatabase() - Retrieves a serialized db string from the catalog. - * - * @example - // LOAD - var cryptedFileAdapter = require('./lokiCryptedFileAdapter'); - cryptedFileAdapter.setSecret('mySecret'); // you should change 'mySecret' to something supplied by the user - var db = new loki('test.crypted', { adapter: cryptedFileAdapter }); //you can use any name, not just '*.crypted' - db.loadDatabase(function(result) { - console.log('done'); - }); - * - * @param {string} dbname - the name of the database to retrieve. - * @param {function} callback - callback should accept string param containing serialized db string. - */ - loadDatabase(dbname: string, callback: (decryptedDataOrErr: string | any) => void): void; + public findOneUnindexed(prop: keyof E, value: any): (E & LokiObj) | null; /** - * - @example - // SAVE : will save database in 'test.crypted' - var cryptedFileAdapter = require('./lokiCryptedFileAdapter'); - cryptedFileAdapter.setSecret('mySecret'); // you should change 'mySecret' to something supplied by the user - var loki=require('lokijs'); - var db = new loki('test.crypted',{ adapter: cryptedFileAdapter }); //you can use any name, not just '*.crypted' - var coll = db.addCollection('testColl'); - coll.insert({test: 'val'}); - db.saveDatabase(); // could pass callback if needed for async complete - - @example - // if you have the krypt module installed you can use: - krypt --decrypt test.crypted --secret mySecret - to view the contents of the database - - * saveDatabase() - Saves a serialized db to the catalog. - * - * @param {string} dbname - the name to give the serialized database within the catalog. - * @param {string} dbstring - the serialized db string to save. - * @param {function} callback - (Optional) callback passed obj.success with true or false + * Transaction methods */ - saveDatabase(dbname: string, dbstring: string, callback: (err: any) => void): void; + + /** start the transation */ + public startTransaction(): void; + + /** commit the transation */ + public commit(): void; + + /** roll back the transation */ + public rollback(): void; + + // async executor. This is only to enable callbacks at the end of the execution. + public async(fun: () => void, callback: () => void): void; + + /** + * Query the collection by supplying a javascript filter function. + * @example + * var results = coll.where(function(obj) { + * return obj.legs === 8; + * }); + * + * @param fun - filter function to run against all collection docs + * @returns all documents which pass your filter function + */ + public where(fun: (data: E) => boolean): (E & LokiObj)[]; + + /** + * Map Reduce operation + * + * @param mapFunction - function to use as map function + * @param reduceFunction - function to use as reduce function + * @returns The result of your mapReduce operation + */ + public mapReduce(mapFunction: (value: E, index: number, array: E[]) => U, reduceFunction: (ary: U[]) => R): R; + + /** + * Join two collections on specified properties + * + * @param joinData - array of documents to 'join' to this collection + * @param leftJoinProp - property name in collection + * @param rightJoinProp - property name in joinData + * @param mapFun - (Optional) map function to use + * @param dataOptions - options to data() before input to your map function + * @param [dataOptions.removeMeta] - allows removing meta before calling mapFun + * @param [dataOptions.forceClones] - forcing the return of cloned objects to your map object + * @param [dataOptions.forceCloneMethod] - Allows overriding the default or collection specified cloning method. + * @returns Result of the mapping operation + */ + public eqJoin( + joinData: Collection | Resultset | any[], + leftJoinProp: string | ((obj: any) => string), + rightJoinProp: string | ((obj: any) => string), + mapFun?: (left: any, right: any) => any, + dataOptions?: Partial + ): Resultset; + + /* ------ STAGING API -------- */ + /** + * stages: a map of uniquely identified 'stages', which hold copies of objects to be + * manipulated without affecting the data in the original collection + */ + public stages: { [name: string]: any }; + + /** + * (Staging API) create a stage and/or retrieve it + */ + public getStage(name: string): any; + + /** + * a collection of objects recording the changes applied through a commmitStage + */ + public commitLog: { timestamp: number; message: string; data: any }[]; + + + /** + * (Staging API) create a copy of an object and insert it into a stage + */ + public stage(stageName: string, obj: F): F; + + /** + * (Staging API) re-attach all objects to the original collection, so indexes and views can be rebuilt + * then create a message to be inserted in the commitlog + * @param stageName - name of stage + * @param message + */ + public commitStage(stageName: string, message: string): void; + + public no_op: () => void; + + public extract(field: string): any[]; + + public max(field: string): number; + + public min(field: string): number; + + public maxRecord(field: string): { index: number; value: any }; + + public minRecord(field: string): { index: number; value: any }; + + public extractNumerical(field: string): number[]; + + /** + * Calculates the average numerical value of a property + * + * @param field - name of property in docs to average + * @returns average of property in all docs in the collection + */ + public avg(field: string): number; + + /** + * Calculate standard deviation of a field + * @param field + */ + public stdDev(field: string): number; + + /** + * @param field + */ + public mode(field: string): string | undefined; + + /** + * @param field - property name + */ + public median(field: string): number; } -interface LokiCryptedFileAdapterEncryptResult { - cipher: string; - keyDerivation: string; - keyLength: number; - iterations: number; - iv: string; - salt: string; - value: string; + +declare class KeyValueStore { + keys: any[]; + values: any[]; + + constructor(); + + public sort(a: any, b: any): -1 | 0 | 1; + + public setSort(fun: (target: any, test: any) => any): void; + + public bs(): (array: any[], item: any) => { found: boolean; index: number }; + + public set(key: any, value: any): void; + + public get(key: any): any[]; } -/* ======== END loki-crypted-file-adapter.js ======== */ +declare class UniqueIndex { + field: keyof E; + keyMap: { [fieldValue: string]: E/*{ $loki: number }*/ | undefined }; + lokiMap: { [$loki: number]: string | number | undefined }; -/* ======== loki-angular.js ======== */ -/* introduces a angular module named lokijs that returns the 'lokijs' module - var module = angular.module('lokijs', []) - .factory('Loki', function Loki() { - return lokijs; - }); - return module; -*/ -/* ======== END loki-angular.js ======== */ + constructor(uniqueField: keyof E); + + public set(obj: E/*{ $loki: number }*/): void; + + public get(key: string | number): E | undefined; + + public byId(id: number): E | undefined; + + /** + * Updates a document's unique index given an updated object. + * @param {Object} obj Original document object + * @param {Object} doc New document object (likely the same as obj) + */ + public update(obj: E/*{ $loki: number }*/, doc: any): void; + + public remove(key: string): void; + + public clear(): void; +} +declare class ExactIndex { + field: keyof E; + index: { [key: string]: E[] | undefined }; -/* ======== jquery-sync-adapter.js ======== */ + constructor(exactField: keyof E); -/** LokiJS JquerySyncAdapter - * A remote sync adapter example for LokiJS + // add the value you want returned to the key in the index + public set(key: string | number, val: E): void; + + // remove the value from the index, if the value was the last one, remove the key + public remove(key: string | number, val: E): void; + + // get the values related to the key, could be more than one + public get(key: string | number): E[] | undefined; + + // clear will zap the index + public clear(key?: null): void; +} + + + +declare class SortedIndex { + field: string; + keys: any[]; + values: any[]; + + constructor(sortedField: string); + + // set the default sort + public sort(a: any, b: any): -1 | 0 | 1; + + public bs(): (array: any[], item: any) => { found: boolean; index: number }; + + // and allow override of the default sort + public setSort(fun: (target: any, test: any) => number): void; + + // add the value you want returned to the key in the index + public set(key: any, value: any): void; + + // get all values which have a key == the given key + public get(key: any): any[]; + + // get all values which have a key < the given key + public getLt(key: any): any[]; + + // get all values which have a key > the given key + public getGt(key: any): any[]; + + // get all vals from start to end + public getAll(key: any, start: number, end: number): any[]; + + // just in case someone wants to do something smart with ranges + public getPos(key: any): { found: boolean; index: number }; + + // remove the value from the index, if the value was the last one, remove the key + public remove(key: any, value: any): void; + + // clear will zap the index + public clear(): void; +} + + +// type aliases to allow the nested classes inside LokiConstructor to extend classes sharing them same name(s) as themselves +declare class _Collection extends Collection { } +declare class _KeyValueStore extends KeyValueStore { } +declare class _LokiMemoryAdapter extends LokiMemoryAdapter { } +declare class _LokiPartitioningAdapter extends LokiPartitioningAdapter { } +declare class _LokiLocalStorageAdapter extends LokiLocalStorageAdapter { } +declare class _LokiFsAdapter extends LokiFsAdapter { } + + +/** + * LokiJS + * A lightweight document oriented javascript database * @author Joe Minichino */ - -/** this adapter assumes an object options is passed, - * containing the following properties: - * ajaxLib: jquery or compatible ajax library - * save: { url: the url to save to, dataType [optional]: json|xml|etc., type [optional]: POST|GET|PUT} - * load: { url: the url to load from, dataType [optional]: json|xml| etc., type [optional]: POST|GET|PUT } - */ -interface LokiJquerySyncAdapter { - options: LokiJquerySyncAdapterOptions - - new (options: LokiJquerySyncAdapterOptions): LokiJquerySyncAdapter; - - saveDatabase(name: string, data: any, callback?: (data: any, textStatus: string, xhr: XMLHttpRequest) => any): void; - - loadDatabase(name: string, callback?: (data: any, textStatus: string, xhr: XMLHttpRequest) => any): void; +declare class LokiConstructor extends Loki { + constructor(filename: string, options?: Partial & Partial & Partial); } - - -interface LokiJquerySyncAdapterOptions { - ajaxLib: { ajax(options: any): any; }; - save: { - url: any; - type?: string; /*'GET', 'POST, 'DELETE', etc.*/ - dataType?: string; /*'json', 'xml', etc.*/ +declare module LokiConstructor { + export var persistenceAdapters: { + fs: _LokiFsAdapter, + localStorage: _LokiLocalStorageAdapter }; - load: { - url: any; - type?: string; /*'GET', 'POST, 'DELETE', etc.*/ - dataType?: string; /*'json', 'xml', etc.*/ - }; -} + export function aeq(prop1: any, prop2: any): boolean; -interface LokiJquerySyncAdapterError extends Error { - name: string; // "JquerySyncAdapterError" - message: any; + function lt(prop1: any, prop2: any, equal?: boolean): boolean; - new (message: any): LokiJquerySyncAdapterError; -} -/* ======== END jquery-sync-adapter.js ======== */ + function gt(prop1: any, prop2: any, equal?: boolean): boolean; + export var LokiOps: LokiOps; -declare var LokiCryptedFileAdapterConstructor: { - new (): LokiCryptedFileAdapter; -} + export class Collection extends _Collection { } -declare module "lokiCryptedFileAdapter" { - export = LokiCryptedFileAdapterConstructor; -} + export class KeyValueStore extends _KeyValueStore { } + export class LokiMemoryAdapter extends _LokiMemoryAdapter { } -declare var LokiIndexedAdapterConstructor: { - new (filename: string): LokiIndexedAdapter; -} + export class LokiPartitioningAdapter extends _LokiPartitioningAdapter { } -declare module "loki-indexed-adapter" { - export = LokiIndexedAdapterConstructor; -} + export class LokiLocalStorageAdapter extends _LokiLocalStorageAdapter { } - -declare var LokiConstructor: { - new (filename: string, options?: LokiConfigureOptions): Loki; - LokiOps: LokiOps; - Collection: LokiCollection; - KeyValueStore: LokiKeyValueStore; + export class LokiFsAdapter extends _LokiFsAdapter { } } declare module "lokijs" { diff --git a/types/lokijs/lokijs-tests.ts b/types/lokijs/lokijs-tests.ts index 2e08370c02..167adba4ad 100644 --- a/types/lokijs/lokijs-tests.ts +++ b/types/lokijs/lokijs-tests.ts @@ -37,10 +37,10 @@ class QueenAnt extends Ant { class AntColony { - ants: LokiCollection; - queens: LokiCollection; + ants: Loki.Collection; + queens: Loki.Collection; - constructor(ants?: LokiCollection, queens?: LokiCollection) { + constructor(ants: Loki.Collection, queens: Loki.Collection) { this.ants = ants; this.queens = queens; } diff --git a/types/lokijs/tsconfig.json b/types/lokijs/tsconfig.json index bd01821699..96175c28a4 100644 --- a/types/lokijs/tsconfig.json +++ b/types/lokijs/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From 1dc398652e4947d5202be6d03d6cb23bf5cd16d2 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Sat, 25 Nov 2017 23:52:39 +0100 Subject: [PATCH 171/639] Add firefox-webext-browser types for FireFox WebExtension Development --- .../firefox-webext-browser-tests.ts | 2 + types/firefox-webext-browser/index.d.ts | 3123 +++++++++++++++++ types/firefox-webext-browser/tsconfig.json | 23 + types/firefox-webext-browser/tslint.json | 8 + 4 files changed, 3156 insertions(+) create mode 100644 types/firefox-webext-browser/firefox-webext-browser-tests.ts create mode 100644 types/firefox-webext-browser/index.d.ts create mode 100644 types/firefox-webext-browser/tsconfig.json create mode 100644 types/firefox-webext-browser/tslint.json diff --git a/types/firefox-webext-browser/firefox-webext-browser-tests.ts b/types/firefox-webext-browser/firefox-webext-browser-tests.ts new file mode 100644 index 0000000000..879b8af0bb --- /dev/null +++ b/types/firefox-webext-browser/firefox-webext-browser-tests.ts @@ -0,0 +1,2 @@ +// No tests yet +true; diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts new file mode 100644 index 0000000000..2063abc93e --- /dev/null +++ b/types/firefox-webext-browser/index.d.ts @@ -0,0 +1,3123 @@ +// Type definitions for WebExtension Development in FireFox 58.0 +// Project: https://developer.mozilla.org/en-US/Add-ons/WebExtensions +// Definitions by: Jacob Bom +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +interface EventListener any> { + addListener: (callback: T) => void; + removeListener: (listener: T) => void; + hasListener: (listener: T) => boolean; +} + +declare namespace browser.alarms { + /* alarms types */ + interface Alarm { + name: string; + scheduledTime: number; + periodInMinutes?: number; + } + + /* alarms functions */ + function create(alarmInfo: { + when?: number; + delayInMinutes?: number; + periodInMinutes?: number; + }): void; + function create(name: string, alarmInfo: { + when?: number; + delayInMinutes?: number; + periodInMinutes?: number; + }): void; + + function get(name?: string): Promise; + + function getAll(): Promise; + + function clear(name?: string): Promise; + + function clearAll(): Promise; + + /* alarms events */ + const onAlarm: EventListener<(name: Alarm) => void>; +} + +declare namespace browser.manifest { + /* manifest types */ + type OptionalPermission = OptionalPermissionEnum; + + type Permission = string | OptionalPermission | PermissionEnum; + + interface ProtocolHandler { + name: string; + protocol: string | ProtocolHandlerProtocolEnum; + uriTemplate: ExtensionURL | HttpURL; + } + + interface WebExtensionManifest { + protocol_handlers?: ProtocolHandler[]; + default_locale?: string; + manifest_version: number; + minimum_chrome_version?: string; + minimum_opera_version?: string; + applications?: { + gecko?: FirefoxSpecificProperties; + }; + browser_specific_settings?: { + gecko?: FirefoxSpecificProperties; + }; + name: string; + short_name?: string; + description?: string; + author?: string; + version: string; + homepage_url?: string; + icons?: { + [key: number]: string; + }; + incognito?: WebExtensionManifestIncognitoEnum; + background?: { + page: ExtensionURL; + persistent?: PersistentBackgroundProperty; + } | { + scripts: ExtensionURL[]; + persistent?: PersistentBackgroundProperty; + }; + options_ui?: { + page: ExtensionURL; + browser_style?: boolean; + chrome_style?: boolean; + open_in_tab?: boolean; + }; + content_scripts?: ContentScript[]; + content_security_policy?: string; + permissions?: PermissionOrOrigin[]; + optional_permissions?: OptionalPermissionOrOrigin[]; + web_accessible_resources?: string[]; + developer?: { + name?: string; + url?: string; + }; + theme?: ThemeType; + browser_action?: { + default_title?: string; + default_icon?: IconPath; + theme_icons?: ThemeIcons[]; + default_popup?: string; + browser_style?: boolean; + default_area?: WebExtensionManifestBrowserActionDefaultAreaEnum; + }; + chrome_settings_overrides?: { + homepage?: string; + search_provider?: { + name: string; + keyword?: string; + search_url: string; + favicon_url?: string; + suggest_url?: string; + instant_url?: string; + image_url?: string; + search_url_post_params?: string; + instant_url_post_params?: string; + image_url_post_params?: string; + alternate_urls?: string[]; + prepopulated_id?: number; + is_default?: boolean; + }; + }; + commands?: { + suggested_key?: { + default?: KeyName; + mac?: KeyName; + linux?: KeyName; + windows?: KeyName; + chromeos?: string; + android?: string; + ios?: string; + additionalProperties?: string; + }; + description?: string; + }; + devtools_page?: ExtensionURL; + omnibox?: { + keyword: string; + }; + page_action?: { + default_title?: string; + default_icon?: IconPath; + default_popup?: string; + browser_style?: boolean; + }; + sidebar_action?: { + default_title?: string; + default_icon?: IconPath; + browser_style?: boolean; + default_panel: string; + }; + chrome_url_overrides?: { + newtab?: ExtensionURL; + bookmarks?: ExtensionURL; + history?: ExtensionURL; + }; + } + + interface WebExtensionLangpackManifest { + manifest_version: number; + applications?: { + gecko?: FirefoxSpecificProperties; + }; + browser_specific_settings?: { + gecko?: FirefoxSpecificProperties; + }; + name: string; + short_name?: string; + description?: string; + author?: string; + version: string; + homepage_url?: string; + langpack_id: string; + languages: { + [key: string]: { + chrome_resources: { + [key: string]: ExtensionURL | { + [key: string]: ExtensionURL; + }; + }; + version: string; + }; + }; + sources?: { + [key: string]: { + base_path: ExtensionURL; + paths?: string[]; + }; + }; + } + + interface ThemeIcons { + light: ExtensionURL; + dark: ExtensionURL; + size: number; + } + + type OptionalPermissionOrOrigin = OptionalPermission | MatchPattern; + + type PermissionOrOrigin = Permission | MatchPattern; + + type HttpURL = string; + + type ExtensionURL = string; + + type ImageDataOrExtensionURL = string; + + type ExtensionID = string | string; + + interface FirefoxSpecificProperties { + id?: ExtensionID; + update_url?: string; + strict_min_version?: string; + strict_max_version?: string; + } + + type MatchPattern = string | string | MatchPatternEnum; + + type MatchPatternInternal = string | string | MatchPatternInternalEnum; + + interface ContentScript { + matches: MatchPattern[]; + exclude_matches?: MatchPattern[]; + include_globs?: string[]; + exclude_globs?: string[]; + css?: ExtensionURL[]; + js?: ExtensionURL[]; + all_frames?: boolean; + match_about_blank?: boolean; + run_at?: extensionTypes.RunAt; + } + + type IconPath = { + [key: number]: ExtensionURL; + } | ExtensionURL; + + type IconImageData = { + [key: number]: ImageData; + } | ImageData; + + type ImageData = any; + + type UnrecognizedProperty = any; + + type PersistentBackgroundProperty = boolean; + + type NativeManifest = { + name: string; + description: string; + path: string; + type: NativeManifestTypeEnum; + allowed_extensions: ExtensionID[]; + } | { + name: ExtensionID; + description: string; + data: any; + type: NativeManifestTypeEnum; + }; + + interface ThemeType { + images?: { + additional_backgrounds?: ImageDataOrExtensionURL[]; + headerURL?: ImageDataOrExtensionURL; + theme_frame?: ImageDataOrExtensionURL; + }; + colors?: { + accentcolor?: string; + frame?: number[]; + tab_text?: number[]; + textcolor?: string; + toolbar?: string; + toolbar_text?: string; + bookmark_text?: string; + toolbar_field?: string; + toolbar_field_text?: string; + toolbar_top_separator?: string; + toolbar_bottom_separator?: string; + toolbar_vertical_separator?: string; + }; + icons?: { + back?: ExtensionURL; + forward?: ExtensionURL; + reload?: ExtensionURL; + stop?: ExtensionURL; + bookmark_star?: ExtensionURL; + bookmark_menu?: ExtensionURL; + downloads?: ExtensionURL; + home?: ExtensionURL; + app_menu?: ExtensionURL; + cut?: ExtensionURL; + copy?: ExtensionURL; + paste?: ExtensionURL; + new_window?: ExtensionURL; + new_private_window?: ExtensionURL; + save_page?: ExtensionURL; + print?: ExtensionURL; + history?: ExtensionURL; + full_screen?: ExtensionURL; + find?: ExtensionURL; + options?: ExtensionURL; + addons?: ExtensionURL; + developer?: ExtensionURL; + synced_tabs?: ExtensionURL; + open_file?: ExtensionURL; + sidebars?: ExtensionURL; + subscribe?: ExtensionURL; + text_encoding?: ExtensionURL; + email_link?: ExtensionURL; + forget?: ExtensionURL; + pocket?: ExtensionURL; + getmsg?: ExtensionURL; + newmsg?: ExtensionURL; + address?: ExtensionURL; + reply?: ExtensionURL; + replyall?: ExtensionURL; + replylist?: ExtensionURL; + forwarding?: ExtensionURL; + delete?: ExtensionURL; + junk?: ExtensionURL; + file?: ExtensionURL; + nextUnread?: ExtensionURL; + prevUnread?: ExtensionURL; + mark?: ExtensionURL; + tag?: ExtensionURL; + compact?: ExtensionURL; + archive?: ExtensionURL; + chat?: ExtensionURL; + nextMsg?: ExtensionURL; + prevMsg?: ExtensionURL; + QFB?: ExtensionURL; + conversation?: ExtensionURL; + newcard?: ExtensionURL; + newlist?: ExtensionURL; + editcard?: ExtensionURL; + newim?: ExtensionURL; + send?: ExtensionURL; + spelling?: ExtensionURL; + attach?: ExtensionURL; + security?: ExtensionURL; + save?: ExtensionURL; + quote?: ExtensionURL; + buddy?: ExtensionURL; + join_chat?: ExtensionURL; + chat_accounts?: ExtensionURL; + calendar?: ExtensionURL; + tasks?: ExtensionURL; + synchronize?: ExtensionURL; + newevent?: ExtensionURL; + newtask?: ExtensionURL; + editevent?: ExtensionURL; + today?: ExtensionURL; + category?: ExtensionURL; + complete?: ExtensionURL; + priority?: ExtensionURL; + saveandclose?: ExtensionURL; + attendees?: ExtensionURL; + privacy?: ExtensionURL; + status?: ExtensionURL; + freebusy?: ExtensionURL; + timezones?: ExtensionURL; + }; + properties?: { + additional_backgrounds_alignment?: ThemeTypeAdditionalBackgroundsAlignmentEnum[]; + additional_backgrounds_tiling?: ThemeTypeAdditionalBackgroundsTilingEnum[]; + }; + } + + type KeyName = string | string | string; + + enum OptionalPermissionEnum { + browserSettings = "browserSettings", + cookies = "cookies", + clipboardRead = "clipboardRead", + clipboardWrite = "clipboardWrite", + geolocation = "geolocation", + idle = "idle", + notifications = "notifications", + topSites = "topSites", + webNavigation = "webNavigation", + webRequest = "webRequest", + webRequestBlocking = "webRequestBlocking", + bookmarks = "bookmarks", + find = "find", + history = "history", + activeTab = "activeTab", + tabs = "tabs" + } + + enum PermissionEnum { + contextualIdentities = "contextualIdentities", + downloads = "downloads", + downloadsopen = "downloads.open", + identity = "identity", + management = "management", + alarms = "alarms", + mozillaAddons = "mozillaAddons", + storage = "storage", + unlimitedStorage = "unlimitedStorage", + privacy = "privacy", + proxy = "proxy", + nativeMessaging = "nativeMessaging", + theme = "theme", + browsingData = "browsingData", + devtools = "devtools", + geckoProfiler = "geckoProfiler", + menus = "menus", + contextMenus = "contextMenus", + pkcs11 = "pkcs11", + sessions = "sessions" + } + + enum ProtocolHandlerProtocolEnum { + bitcoin = "bitcoin", + geo = "geo", + gopher = "gopher", + im = "im", + irc = "irc", + ircs = "ircs", + magnet = "magnet", + mailto = "mailto", + mms = "mms", + news = "news", + nntp = "nntp", + sip = "sip", + sms = "sms", + smsto = "smsto", + ssh = "ssh", + tel = "tel", + urn = "urn", + webcal = "webcal", + wtai = "wtai", + xmpp = "xmpp" + } + + enum WebExtensionManifestIncognitoEnum { + spanning = "spanning" + } + + enum WebExtensionManifestBrowserActionDefaultAreaEnum { + navbar = "navbar", + menupanel = "menupanel", + tabstrip = "tabstrip", + personaltoolbar = "personaltoolbar" + } + + enum MatchPatternEnum { + all_urls = "" + } + + enum MatchPatternInternalEnum { + all_urls = "" + } + + enum NativeManifestTypeEnum { + pkcs11 = "pkcs11", + stdio = "stdio" + } + + enum NativeManifestTypeEnum { + storage = "storage" + } + + enum ThemeTypeAdditionalBackgroundsAlignmentEnum { + bottom = "bottom", + center = "center", + left = "left", + right = "right", + top = "top", + centerbottom = "center bottom", + centercenter = "center center", + centertop = "center top", + leftbottom = "left bottom", + leftcenter = "left center", + lefttop = "left top", + rightbottom = "right bottom", + rightcenter = "right center", + righttop = "right top" + } + + enum ThemeTypeAdditionalBackgroundsTilingEnum { + norepeat = "no-repeat", + repeat = "repeat", + repeatx = "repeat-x", + repeaty = "repeat-y" + } +} + +declare namespace browser.browserSettings { + /* browserSettings types */ + enum ImageAnimationBehavior { + normal = "normal", + none = "none", + once = "once" + } + + /* browserSettings properties */ + const allowPopupsForUserEvents: types.Setting; + + const cacheEnabled: types.Setting; + + const homepageOverride: types.Setting; + + const imageAnimationBehavior: types.Setting; + + const newTabPageOverride: types.Setting; + + const webNotificationsDisabled: types.Setting; +} + +declare namespace browser.clipboard { + type ArrayBuffer = any; + + enum SetImageDataEnum { + jpeg = "jpeg", + png = "png" + } + + /* clipboard functions */ + function setImageData(imageData: ArrayBuffer, imageType: SetImageDataEnum): void; +} + +declare namespace browser.contextualIdentities { + /* contextualIdentities types */ + interface ContextualIdentity { + name: string; + icon: string; + iconUrl: string; + color: string; + colorCode: string; + cookieStoreId: string; + } + + /* contextualIdentities functions */ + function get(cookieStoreId: string): void; + + function query(details: { + name?: string; + }): void; + + function create(details: { + name: string; + color: string; + icon: string; + }): void; + + function update(cookieStoreId: string, details: { + name?: string; + color?: string; + icon?: string; + }): void; + + function remove(cookieStoreId: string): void; + + /* contextualIdentities events */ + const onUpdated: EventListener<(changeInfo: { + contextualIdentity: ContextualIdentity; + }) => void>; + + const onCreated: EventListener<(changeInfo: { + contextualIdentity: ContextualIdentity; + }) => void>; + + const onRemoved: EventListener<(changeInfo: { + contextualIdentity: ContextualIdentity; + }) => void>; +} + +declare namespace browser.cookies { + /* cookies types */ + interface Cookie { + name: string; + value: string; + domain: string; + hostOnly: boolean; + path: string; + secure: boolean; + httpOnly: boolean; + session: boolean; + expirationDate?: number; + storeId: string; + } + + interface CookieStore { + id: string; + tabIds: number[]; + incognito: boolean; + } + + enum OnChangedCause { + evicted = "evicted", + expired = "expired", + explicit = "explicit", + expired_overwrite = "expired_overwrite", + overwrite = "overwrite" + } + + /* cookies functions */ + function get(details: { + url: string; + name: string; + storeId?: string; + }): Promise; + + function getAll(details: { + url?: string; + name?: string; + domain?: string; + path?: string; + secure?: boolean; + session?: boolean; + storeId?: string; + }): Promise; + + function set(details: { + url: string; + name?: string; + value?: string; + domain?: string; + path?: string; + secure?: boolean; + httpOnly?: boolean; + expirationDate?: number; + storeId?: string; + }): Promise; + + function remove(details: { + url: string; + name: string; + storeId?: string; + }): Promise<{ + url: string; + name: string; + storeId: string; + }>; + + function getAllCookieStores(): Promise; + + /* cookies events */ + const onChanged: EventListener<(changeInfo: { + removed: boolean; + cookie: Cookie; + cause: OnChangedCause; + }) => void>; +} + +declare namespace browser.downloads { + /* downloads types */ + enum FilenameConflictAction { + uniquify = "uniquify", + overwrite = "overwrite", + prompt = "prompt" + } + + enum InterruptReason { + FILE_FAILED = "FILE_FAILED", + FILE_ACCESS_DENIED = "FILE_ACCESS_DENIED", + FILE_NO_SPACE = "FILE_NO_SPACE", + FILE_NAME_TOO_LONG = "FILE_NAME_TOO_LONG", + FILE_TOO_LARGE = "FILE_TOO_LARGE", + FILE_VIRUS_INFECTED = "FILE_VIRUS_INFECTED", + FILE_TRANSIENT_ERROR = "FILE_TRANSIENT_ERROR", + FILE_BLOCKED = "FILE_BLOCKED", + FILE_SECURITY_CHECK_FAILED = "FILE_SECURITY_CHECK_FAILED", + FILE_TOO_SHORT = "FILE_TOO_SHORT", + NETWORK_FAILED = "NETWORK_FAILED", + NETWORK_TIMEOUT = "NETWORK_TIMEOUT", + NETWORK_DISCONNECTED = "NETWORK_DISCONNECTED", + NETWORK_SERVER_DOWN = "NETWORK_SERVER_DOWN", + NETWORK_INVALID_REQUEST = "NETWORK_INVALID_REQUEST", + SERVER_FAILED = "SERVER_FAILED", + SERVER_NO_RANGE = "SERVER_NO_RANGE", + SERVER_BAD_CONTENT = "SERVER_BAD_CONTENT", + SERVER_UNAUTHORIZED = "SERVER_UNAUTHORIZED", + SERVER_CERT_PROBLEM = "SERVER_CERT_PROBLEM", + SERVER_FORBIDDEN = "SERVER_FORBIDDEN", + USER_CANCELED = "USER_CANCELED", + USER_SHUTDOWN = "USER_SHUTDOWN", + CRASH = "CRASH" + } + + enum DangerType { + file = "file", + url = "url", + content = "content", + uncommon = "uncommon", + host = "host", + unwanted = "unwanted", + safe = "safe", + accepted = "accepted" + } + + enum State { + in_progress = "in_progress", + interrupted = "interrupted", + complete = "complete" + } + + interface DownloadItem { + id: number; + url: string; + referrer?: string; + filename: string; + incognito: boolean; + danger: DangerType; + mime: string; + startTime: string; + endTime?: string; + estimatedEndTime?: string; + state: State; + paused: boolean; + canResume: boolean; + error?: InterruptReason; + bytesReceived: number; + totalBytes: number; + fileSize: number; + exists: boolean; + byExtensionId?: string; + byExtensionName?: string; + } + + interface StringDelta { + current?: string; + previous?: string; + } + + interface DoubleDelta { + current?: number; + previous?: number; + } + + interface BooleanDelta { + current?: boolean; + previous?: boolean; + } + + type DownloadTime = string | extensionTypes.Date; + + interface DownloadQuery { + query?: string[]; + startedBefore?: DownloadTime; + startedAfter?: DownloadTime; + endedBefore?: DownloadTime; + endedAfter?: DownloadTime; + totalBytesGreater?: number; + totalBytesLess?: number; + filenameRegex?: string; + urlRegex?: string; + limit?: number; + orderBy?: string[]; + id?: number; + url?: string; + filename?: string; + danger?: DangerType; + mime?: string; + startTime?: string; + endTime?: string; + state?: State; + paused?: boolean; + error?: InterruptReason; + bytesReceived?: number; + totalBytes?: number; + fileSize?: number; + exists?: boolean; + } + + enum DownloadMethodEnum { + GET = "GET", + POST = "POST" + } + + /* downloads functions */ + function download(options: { + url: string; + filename?: string; + incognito?: boolean; + conflictAction?: FilenameConflictAction; + saveAs?: boolean; + method?: DownloadMethodEnum; + headers?: Array<{ + name: string; + value: string; + }>; + body?: string; + }): Promise; + + function search(query: DownloadQuery): Promise; + + function pause(downloadId: number): Promise; + + function resume(downloadId: number): Promise; + + function cancel(downloadId: number): Promise; + + function getFileIcon(downloadId: number, options?: { + size?: number; + }): Promise; + + function open(downloadId: number): Promise; + + function show(downloadId: number): Promise; + + function showDefaultFolder(): void; + + function erase(query: DownloadQuery): Promise; + + function removeFile(downloadId: number): Promise; + + function acceptDanger(downloadId: number): void; + + function drag(downloadId: number): void; + + function setShelfEnabled(enabled: boolean): void; + + /* downloads events */ + const onCreated: EventListener<(downloadItem: DownloadItem) => void>; + + const onErased: EventListener<(downloadId: number) => void>; + + const onChanged: EventListener<(downloadDelta: { + id: number; + url?: StringDelta; + filename?: StringDelta; + danger?: StringDelta; + mime?: StringDelta; + startTime?: StringDelta; + endTime?: StringDelta; + state?: StringDelta; + canResume?: BooleanDelta; + paused?: BooleanDelta; + error?: StringDelta; + totalBytes?: DoubleDelta; + fileSize?: DoubleDelta; + exists?: BooleanDelta; + }) => void>; +} + +declare namespace browser.events { + /* events types */ + interface Rule { + id?: string; + tags?: string[]; + conditions: any[]; + actions: any[]; + priority?: number; + } + + class Event { + addListener(): void; + + removeListener(): void; + + hasListener(): boolean; + + hasListeners(): boolean; + + addRules(eventName: string, webViewInstanceId: number, rules: Rule[]): void; + + getRules(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): void; + + removeRules(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): void; + } + + interface UrlFilter { + hostContains?: string; + hostEquals?: string; + hostPrefix?: string; + hostSuffix?: string; + pathContains?: string; + pathEquals?: string; + pathPrefix?: string; + pathSuffix?: string; + queryContains?: string; + queryEquals?: string; + queryPrefix?: string; + querySuffix?: string; + urlContains?: string; + urlEquals?: string; + urlMatches?: string; + originAndPathMatches?: string; + urlPrefix?: string; + urlSuffix?: string; + schemes?: string[]; + ports?: Array; + } +} + +declare namespace browser.extension { + /* extension types */ + enum ViewType { + tab = "tab", + popup = "popup", + sidebar = "sidebar" + } + + /* extension properties */ + const lastError: { + message: string; + } | undefined; + + const inIncognitoContext: boolean | undefined; + + /* extension functions */ + function getURL(path: string): string; + + function getViews(fetchProperties?: { + type?: ViewType; + windowId?: number; + tabId?: number; + }): object/*Window*/[]; + + function getBackgroundPage(): object/*Window*/; + + function isAllowedIncognitoAccess(): Promise; + + function isAllowedFileSchemeAccess(): Promise; + + function setUpdateUrlData(data: string): void; + + /* extension events */ + const onRequest: EventListener<(request: any, sender: runtime.MessageSender, sendResponse: () => void) => void> + | EventListener<(sender: runtime.MessageSender, sendResponse: () => void) => void>; + + const onRequestExternal: EventListener<(request: any, sender: runtime.MessageSender, sendResponse: () => void) => void> + | EventListener<(sender: runtime.MessageSender, sendResponse: () => void) => void>; +} + +declare namespace browser.extensionTypes { + /* extensionTypes types */ + enum ImageFormat { + jpeg = "jpeg", + png = "png" + } + + interface ImageDetails { + format?: ImageFormat; + quality?: number; + } + + enum RunAt { + document_start = "document_start", + document_end = "document_end", + document_idle = "document_idle" + } + + enum CSSOrigin { + user = "user", + author = "author" + } + + interface InjectDetails { + code?: string; + file?: string; + allFrames?: boolean; + matchAboutBlank?: boolean; + frameId?: number; + runAt?: RunAt; + cssOrigin?: CSSOrigin; + } + + type Date = string | number | object/*Date*/; +} + +declare namespace browser.i18n { + /* i18n types */ + type LanguageCode = string; + + /* i18n functions */ + function getAcceptLanguages(): Promise; + + function getMessage(messageName: string, substitutions?: any): string; + + function getUILanguage(): string; + + function detectLanguage(text: string): Promise<{ + isReliable: boolean; + languages: Array<{ + language: LanguageCode; + percentage: number; + }>; + }>; +} + +declare namespace browser.identity { + /* identity types */ + interface AccountInfo { + id: string; + } + + /* identity functions */ + function getAccounts(): Promise; + + function getAuthToken(details?: { + interactive?: boolean; + account?: AccountInfo; + scopes?: string[]; + }): Promise; + + function getProfileUserInfo(): Promise<{ + email: string; + id: string; + }>; + + function removeCachedAuthToken(details: { + token: string; + }): Promise<{ + email: string; + id: string; + }>; + + function launchWebAuthFlow(details: { + url: string; + interactive?: boolean; + }): Promise; + + function getRedirectURL(path?: string): string; + + /* identity events */ + const onSignInChanged: EventListener<(account: AccountInfo, signedIn: boolean) => void>; +} + +declare namespace browser.idle { + /* idle types */ + enum IdleState { + active = "active", + idle = "idle" + } + + /* idle functions */ + function queryState(detectionIntervalInSeconds: number): Promise; + + function setDetectionInterval(intervalInSeconds: number): void; + + /* idle events */ + const onStateChanged: EventListener<(newState: IdleState) => void>; +} + +declare namespace browser.management { + /* management types */ + interface IconInfo { + size: number; + url: string; + } + + enum ExtensionDisabledReason { + unknown = "unknown", + permissions_increase = "permissions_increase" + } + + enum ExtensionType { + extension = "extension", + theme = "theme" + } + + enum ExtensionInstallType { + development = "development", + normal = "normal", + sideload = "sideload", + other = "other" + } + + interface ExtensionInfo { + id: string; + name: string; + shortName?: string; + description: string; + version: string; + versionName?: string; + mayDisable: boolean; + enabled: boolean; + disabledReason?: ExtensionDisabledReason; + type: ExtensionType; + homepageUrl?: string; + updateUrl?: string; + optionsUrl: string; + icons?: IconInfo[]; + permissions?: string[]; + hostPermissions?: string[]; + installType: ExtensionInstallType; + } + + /* management functions */ + function getAll(): Promise; + + function get(id: manifest.ExtensionID): Promise; + + function getSelf(): Promise; + + function uninstallSelf(options?: { + showConfirmDialog?: boolean; + dialogMessage?: string; + }): Promise; + + function setEnabled(id: string, enabled: boolean): Promise; + + /* management events */ + const onDisabled: EventListener<(info: ExtensionInfo) => void>; + + const onEnabled: EventListener<(info: ExtensionInfo) => void>; + + const onInstalled: EventListener<(info: ExtensionInfo) => void>; + + const onUninstalled: EventListener<(info: ExtensionInfo) => void>; +} + +declare namespace browser.notifications { + /* notifications types */ + enum TemplateType { + basic = "basic", + image = "image", + list = "list", + progress = "progress" + } + + enum PermissionLevel { + granted = "granted", + denied = "denied" + } + + interface NotificationItem { + title: string; + message: string; + } + + interface CreateNotificationOptions { + type: TemplateType; + iconUrl?: string; + appIconMaskUrl?: string; + title: string; + message: string; + contextMessage?: string; + priority?: number; + eventTime?: number; + buttons?: Array<{ + title: string; + iconUrl?: string; + }>; + imageUrl?: string; + items?: NotificationItem[]; + progress?: number; + isClickable?: boolean; + } + + interface UpdateNotificationOptions { + type?: TemplateType; + iconUrl?: string; + appIconMaskUrl?: string; + title?: string; + message?: string; + contextMessage?: string; + priority?: number; + eventTime?: number; + buttons?: Array<{ + title: string; + iconUrl?: string; + }>; + imageUrl?: string; + items?: NotificationItem[]; + progress?: number; + isClickable?: boolean; + } + + /* notifications functions */ + function create(options: CreateNotificationOptions): Promise; + function create(notificationId: string, options: CreateNotificationOptions): Promise; + + function update(notificationId: string, options: UpdateNotificationOptions): Promise; + + function clear(notificationId: string): Promise; + + function getAll(): Promise; + + function getPermissionLevel(): Promise; + + /* notifications events */ + const onClosed: EventListener<(notificationId: string, byUser: boolean) => void>; + + const onClicked: EventListener<(notificationId: string) => void>; + + const onButtonClicked: EventListener<(notificationId: string, buttonIndex: number) => void>; + + const onPermissionLevelChanged: EventListener<(level: PermissionLevel) => void>; + + const onShowSettings: EventListener<() => void>; + + const onShown: EventListener<(notificationId: string) => void>; +} + +declare namespace browser.permissions { + /* permissions types */ + interface Permissions { + permissions?: manifest.OptionalPermission[]; + origins?: manifest.MatchPattern[]; + } + + interface AnyPermissions { + permissions?: manifest.Permission[]; + origins?: manifest.MatchPatternInternal[]; + } + + /* permissions functions */ + function getAll(): Promise; + + function contains(permissions: AnyPermissions): Promise; + + function request(permissions: Permissions): Promise; + + function remove(permissions: Permissions): Promise; + + /* permissions events */ + const onAdded: EventListener<(permissions: Permissions) => void>; + + const onRemoved: EventListener<(permissions: Permissions) => void>; +} + +declare namespace browser.privacy { +} + +declare namespace browser.privacy.network { + /* privacy.network types */ + enum IPHandlingPolicy { + default = "default", + default_public_and_private_interfaces = "default_public_and_private_interfaces", + default_public_interface_only = "default_public_interface_only", + disable_non_proxied_udp = "disable_non_proxied_udp" + } + + /* privacy.network properties */ + const networkPredictionEnabled: types.Setting; + + const peerConnectionEnabled: types.Setting; + + const webRTCIPHandlingPolicy: types.Setting; +} + +declare namespace browser.privacy.services { + /* privacy.services properties */ + const passwordSavingEnabled: types.Setting; +} + +declare namespace browser.privacy.websites { + /* privacy.websites types */ + enum TrackingProtectionModeOption { + always = "always", + never = "never", + private_browsing = "private_browsing" + } + + /* privacy.websites properties */ + const thirdPartyCookiesAllowed: types.Setting; + + const hyperlinkAuditingEnabled: types.Setting; + + const referrersEnabled: types.Setting; + + const resistFingerprinting: types.Setting; + + const firstPartyIsolate: types.Setting; + + const protectedContentEnabled: types.Setting; + + const trackingProtectionMode: types.Setting; +} + +declare namespace browser.proxy { + /* proxy functions */ + function register(url: string): void; + + function unregister(): void; + + function registerProxyScript(url: string): void; + + /* proxy events */ + const onProxyError: EventListener<(error: object) => void>; +} + +declare namespace browser.runtime { + /* runtime types */ + interface Port { + name: string; + disconnect: () => void; + onDisconnect: events.Event; + onMessage: events.Event; + postMessage: () => void; + sender?: MessageSender; + } + + interface MessageSender { + tab?: tabs.Tab; + frameId?: number; + id?: string; + url?: string; + tlsChannelId?: string; + } + + enum PlatformOs { + mac = "mac", + win = "win", + android = "android", + cros = "cros", + linux = "linux", + openbsd = "openbsd" + } + + enum PlatformArch { + arm = "arm", + x8632 = "x86-32", + x8664 = "x86-64" + } + + interface PlatformInfo { + os: PlatformOs; + arch: PlatformArch; + nacl_arch: PlatformNaclArch; + } + + interface BrowserInfo { + name: string; + vendor: string; + version: string; + buildID: string; + } + + enum RequestUpdateCheckStatus { + throttled = "throttled", + no_update = "no_update", + update_available = "update_available" + } + + enum OnInstalledReason { + install = "install", + update = "update", + browser_update = "browser_update" + } + + enum OnRestartRequiredReason { + app_update = "app_update", + os_update = "os_update", + periodic = "periodic" + } + + type PlatformNaclArch = any; + + /* runtime properties */ + const lastError: { + message?: string; + } | undefined; + + const id: string; + + /* runtime functions */ + function getBackgroundPage(): Promise; + + function openOptionsPage(): Promise; + + function getManifest(): object; + + function getURL(path: string): string; + + function setUninstallURL(url: string): Promise; + + function reload(): void; + + function requestUpdateCheck(): Promise; + + function restart(): void; + + function connect(connectInfo?: { + name?: string; + includeTlsChannelId?: boolean; + }): Port; + function connect(extensionId: string, connectInfo?: { + name?: string; + includeTlsChannelId?: boolean; + }): Port; + + function connectNative(application: string): Port; + + function sendMessage(message: any, options?: { + includeTlsChannelId?: boolean; + toProxyScript?: boolean; + }, responseCallback?: (response: any) => void): void; + function sendMessage(extensionId: string, message: any, options: { + includeTlsChannelId?: boolean; + toProxyScript?: boolean; + }, responseCallback?: (response: any) => void): void; + + function sendNativeMessage(application: string, message: any, responseCallback?: (response: any) => void): void; + + function getBrowserInfo(): Promise; + + function getPlatformInfo(): Promise; + + function getPackageDirectoryEntry(): Promise; + + /* runtime events */ + const onStartup: EventListener<() => void>; + + const onInstalled: EventListener<(details: { + reason: OnInstalledReason; + previousVersion?: string; + temporary: boolean; + id?: string; + }) => void>; + + const onSuspend: EventListener<() => void>; + + const onSuspendCanceled: EventListener<() => void>; + + const onUpdateAvailable: EventListener<(details: { + version: string; + }) => void>; + + const onBrowserUpdateAvailable: EventListener<() => void>; + + const onConnect: EventListener<(port: Port) => void>; + + const onConnectExternal: EventListener<(port: Port) => void>; + + const onMessage: EventListener<(message: any, sender: MessageSender, sendResponse: () => void) => boolean> + | EventListener<(sender: MessageSender, sendResponse: () => void) => boolean>; + + const onMessageExternal: EventListener<(message: any, sender: MessageSender, sendResponse: () => void) => boolean> + | EventListener<(sender: MessageSender, sendResponse: () => void) => boolean>; + + const onRestartRequired: EventListener<(reason: OnRestartRequiredReason) => void>; +} + +declare namespace browser.storage { + /* storage types */ + interface StorageChange { + oldValue?: any; + newValue?: any; + } + + class StorageArea { + get(keys?: string | string[] | object): Promise; + + getBytesInUse(keys?: string | string[]): Promise; + + set(items: any): Promise; + + remove(keys: string | string[]): Promise; + + clear(): Promise; + } + + /* storage properties */ + const sync: StorageArea; + + const local: StorageArea; + + const managed: StorageArea; + + /* storage events */ + const onChanged: EventListener<(changes: StorageChange, areaName: string) => void>; +} + +declare namespace browser.theme { + /* theme types */ + interface ThemeUpdateInfo { + theme: object; + windowId?: number; + } + + /* theme functions */ + function getCurrent(windowId?: number): void; + + function update(details: manifest.ThemeType): void; + function update(windowId: number, details: manifest.ThemeType): void; + + function reset(windowId?: number): void; + + /* theme events */ + const onUpdated: EventListener<(updateInfo: ThemeUpdateInfo) => void>; +} + +declare namespace browser.topSites { + /* topSites types */ + interface MostVisitedURL { + url: string; + title?: string; + } + + /* topSites functions */ + function get(options?: { + providers?: string[]; + }): Promise; +} + +declare namespace browser.types { + /* types types */ + enum SettingScope { + regular = "regular", + regular_only = "regular_only", + incognito_persistent = "incognito_persistent", + incognito_session_only = "incognito_session_only" + } + + enum LevelOfControl { + not_controllable = "not_controllable", + controlled_by_other_extensions = "controlled_by_other_extensions", + controllable_by_this_extension = "controllable_by_this_extension", + controlled_by_this_extension = "controlled_by_this_extension" + } + + class Setting { + get(details: { + incognito?: boolean; + }): Promise<{ + value: any; + levelOfControl: LevelOfControl; + incognitoSpecific?: boolean; + }>; + + set(details: { + value: any; + scope?: SettingScope; + }): Promise; + + clear(details: { + scope?: SettingScope; + }): Promise; + + onChange: EventListener<(details: { + value: any; + levelOfControl: LevelOfControl; + incognitoSpecific?: boolean; + }) => void>; + } +} + +declare namespace browser.webNavigation { + /* webNavigation types */ + enum TransitionType { + link = "link", + typed = "typed", + auto_bookmark = "auto_bookmark", + auto_subframe = "auto_subframe", + manual_subframe = "manual_subframe", + generated = "generated", + start_page = "start_page", + form_submit = "form_submit", + reload = "reload", + keyword = "keyword", + keyword_generated = "keyword_generated" + } + + enum TransitionQualifier { + client_redirect = "client_redirect", + server_redirect = "server_redirect", + forward_back = "forward_back", + from_address_bar = "from_address_bar" + } + + interface EventUrlFilters { + url: events.UrlFilter[]; + } + + /* webNavigation functions */ + function getFrame(details: { + tabId: number; + processId?: number; + frameId: number; + }): Promise<{ + errorOccurred?: boolean; + url: string; + tabId: number; + frameId: number; + parentFrameId: number; + }>; + + function getAllFrames(details: { + tabId: number; + }): Promise>; + + /* webNavigation events */ + const onBeforeNavigate: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + parentFrameId: number; + timeStamp: number; + }) => void>; + + const onCommitted: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + transitionType: TransitionType; + transitionQualifiers: TransitionQualifier[]; + timeStamp: number; + }) => void>; + + const onDOMContentLoaded: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + timeStamp: number; + }) => void>; + + const onCompleted: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + timeStamp: number; + }) => void>; + + const onErrorOccurred: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + error: string; + timeStamp: number; + }) => void>; + + const onCreatedNavigationTarget: EventListener<(details: { + sourceTabId: number; + sourceProcessId: number; + sourceFrameId: number; + url: string; + tabId: number; + timeStamp: number; + }) => void>; + + const onReferenceFragmentUpdated: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + transitionType: TransitionType; + transitionQualifiers: TransitionQualifier[]; + timeStamp: number; + }) => void>; + + const onTabReplaced: EventListener<(details: { + replacedTabId: number; + tabId: number; + timeStamp: number; + }) => void>; + + const onHistoryStateUpdated: EventListener<(details: { + tabId: number; + url: string; + processId: number; + frameId: number; + transitionType: TransitionType; + transitionQualifiers: TransitionQualifier[]; + timeStamp: number; + }) => void>; +} + +declare namespace browser.webRequest { + /* webRequest types */ + enum ResourceType { + main_frame = "main_frame", + sub_frame = "sub_frame", + stylesheet = "stylesheet", + script = "script", + image = "image", + object = "object", + object_subrequest = "object_subrequest", + xmlhttprequest = "xmlhttprequest", + xbl = "xbl", + xslt = "xslt", + ping = "ping", + beacon = "beacon", + xml_dtd = "xml_dtd", + font = "font", + media = "media", + websocket = "websocket", + csp_report = "csp_report", + imageset = "imageset", + web_manifest = "web_manifest", + other = "other" + } + + enum OnBeforeRequestOptions { + blocking = "blocking", + requestBody = "requestBody" + } + + enum OnBeforeSendHeadersOptions { + requestHeaders = "requestHeaders", + blocking = "blocking" + } + + enum OnSendHeadersOptions { + requestHeaders = "requestHeaders" + } + + enum OnHeadersReceivedOptions { + blocking = "blocking", + responseHeaders = "responseHeaders" + } + + enum OnAuthRequiredOptions { + responseHeaders = "responseHeaders", + blocking = "blocking", + asyncBlocking = "asyncBlocking" + } + + enum OnResponseStartedOptions { + responseHeaders = "responseHeaders" + } + + enum OnBeforeRedirectOptions { + responseHeaders = "responseHeaders" + } + + enum OnCompletedOptions { + responseHeaders = "responseHeaders" + } + + interface RequestFilter { + urls: string[]; + types?: ResourceType[]; + tabId?: number; + windowId?: number; + } + + type HttpHeaders = Array<{ + name: string; + value?: string; + binaryValue?: number[]; + }>; + + interface BlockingResponse { + cancel?: boolean; + redirectUrl?: string; + requestHeaders?: HttpHeaders; + responseHeaders?: HttpHeaders; + authCredentials?: { + username: string; + password: string; + }; + } + + interface UploadData { + bytes?: any; + file?: string; + } + + /* webRequest properties */ + const MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number; + + /* webRequest functions */ + function handlerBehaviorChanged(): Promise; + + function filterResponseData(requestId: string): object/*StreamFilter*/; + + /* webRequest events */ + const onBeforeRequest: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + requestBody?: { + error?: string; + formData?: object; + raw?: UploadData[]; + }; + tabId: number; + type: ResourceType; + timeStamp: number; + }) => BlockingResponse>; + + const onBeforeSendHeaders: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + requestHeaders?: HttpHeaders; + }) => BlockingResponse>; + + const onSendHeaders: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + requestHeaders?: HttpHeaders; + }) => void>; + + const onHeadersReceived: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + statusLine: string; + responseHeaders?: HttpHeaders; + statusCode: number; + }) => BlockingResponse>; + + const onAuthRequired: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + scheme: string; + realm?: string; + challenger: { + host: string; + port: number; + }; + isProxy: boolean; + responseHeaders?: HttpHeaders; + statusLine: string; + statusCode: number; + }) => BlockingResponse>; + + const onResponseStarted: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + ip?: string; + fromCache: boolean; + statusCode: number; + responseHeaders?: HttpHeaders; + statusLine: string; + }) => void>; + + const onBeforeRedirect: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + ip?: string; + fromCache: boolean; + statusCode: number; + redirectUrl: string; + responseHeaders?: HttpHeaders; + statusLine: string; + }) => void>; + + const onCompleted: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + ip?: string; + fromCache: boolean; + statusCode: number; + responseHeaders?: HttpHeaders; + statusLine: string; + }) => void>; + + const onErrorOccurred: EventListener<(details: { + requestId: string; + url: string; + method: string; + frameId: number; + parentFrameId: number; + originUrl?: string; + documentUrl?: string; + tabId: number; + type: ResourceType; + timeStamp: number; + ip?: string; + fromCache: boolean; + error: string; + }) => void>; +} + +declare namespace browser.bookmarks { + /* bookmarks types */ + enum BookmarkTreeNodeUnmodifiable { + managed = "managed" + } + + enum BookmarkTreeNodeType { + bookmark = "bookmark", + folder = "folder", + separator = "separator" + } + + interface BookmarkTreeNode { + id: string; + parentId?: string; + index?: number; + url?: string; + title: string; + dateAdded?: number; + dateGroupModified?: number; + unmodifiable?: BookmarkTreeNodeUnmodifiable; + type?: BookmarkTreeNodeType; + children?: BookmarkTreeNode[]; + } + + interface CreateDetails { + parentId?: string; + index?: number; + title?: string; + url?: string; + type?: BookmarkTreeNodeType; + } + + /* bookmarks functions */ + function get(idOrIdList: string | string[]): Promise; + + function getChildren(id: string): Promise; + + function getRecent(numberOfItems: number): Promise; + + function getTree(): Promise; + + function getSubTree(id: string): Promise; + + function search(query: string | { + query?: string; + url?: string; + title?: string; + }): Promise; + + function create(bookmark: CreateDetails): Promise; + + function move(id: string, destination: { + parentId?: string; + index?: number; + }): Promise; + + function update(id: string, changes: { + title?: string; + url?: string; + }): Promise; + + function remove(id: string): Promise; + + function removeTree(id: string): Promise; + + function import_(): Promise; + + function export_(): Promise; + + /* bookmarks events */ + const onCreated: EventListener<(id: string, bookmark: BookmarkTreeNode) => void>; + + const onRemoved: EventListener<(id: string, removeInfo: { + parentId: string; + index: number; + node: BookmarkTreeNode; + }) => void>; + + const onChanged: EventListener<(id: string, changeInfo: { + title: string; + url?: string; + }) => void>; + + const onMoved: EventListener<(id: string, moveInfo: { + parentId: string; + index: number; + oldParentId: string; + oldIndex: number; + }) => void>; + + const onChildrenReordered: EventListener<(id: string, reorderInfo: { + childIds: string[]; + }) => void>; + + const onImportBegan: EventListener<() => void>; + + const onImportEnded: EventListener<() => void>; +} + +declare namespace browser.browserAction { + /* browserAction types */ + type ColorArray = [number, number, number, number]; + + type ImageDataType = object/*ImageData*/; + + /* browserAction functions */ + function setTitle(details: { + title: string; + tabId?: number; + }): Promise; + + function getTitle(details: { + tabId?: number; + }): Promise; + + function setIcon(details: { + imageData?: ImageDataType | { + [key: number]: ImageDataType; + }; + path?: string | { + [key: number]: string; + }; + tabId?: number; + }): Promise; + + function setPopup(details: { + tabId?: number; + popup: string; + }): Promise; + + function getPopup(details: { + tabId?: number; + }): Promise; + + function setBadgeText(details: { + text: string; + tabId?: number; + }): Promise; + + function getBadgeText(details: { + tabId?: number; + }): Promise; + + function setBadgeBackgroundColor(details: { + color: string | ColorArray; + tabId?: number; + }): Promise; + + function getBadgeBackgroundColor(details: { + tabId?: number; + }): Promise; + + function enable(tabId?: number): Promise; + + function disable(tabId?: number): Promise; + + function openPopup(): void; + + /* browserAction events */ + const onClicked: EventListener<(tab: tabs.Tab) => void>; +} + +declare namespace browser.browsingData { + /* browsingData types */ + interface RemovalOptions { + since?: extensionTypes.Date; + hostnames?: string[]; + originTypes?: { + unprotectedWeb?: boolean; + protectedWeb?: boolean; + extension?: boolean; + }; + } + + interface DataTypeSet { + cache?: boolean; + cookies?: boolean; + downloads?: boolean; + formData?: boolean; + history?: boolean; + indexedDB?: boolean; + localStorage?: boolean; + serverBoundCertificates?: boolean; + passwords?: boolean; + pluginData?: boolean; + serviceWorkers?: boolean; + } + + /* browsingData functions */ + function settings(): Promise<{ + options: RemovalOptions; + dataToRemove: DataTypeSet; + dataRemovalPermitted: DataTypeSet; + }>; + + function remove(options: RemovalOptions, dataToRemove: DataTypeSet): Promise; + + function removeAppcache(options: RemovalOptions): Promise; + + function removeCache(options: RemovalOptions): Promise; + + function removeCookies(options: RemovalOptions): Promise; + + function removeDownloads(options: RemovalOptions): Promise; + + function removeFileSystems(options: RemovalOptions): Promise; + + function removeFormData(options: RemovalOptions): Promise; + + function removeHistory(options: RemovalOptions): Promise; + + function removeIndexedDB(options: RemovalOptions): Promise; + + function removeLocalStorage(options: RemovalOptions): Promise; + + function removePluginData(options: RemovalOptions): Promise; + + function removePasswords(options: RemovalOptions): Promise; + + function removeWebSQL(options: RemovalOptions): Promise; +} + +declare namespace browser.commands { + /* commands types */ + interface Command { + name?: string; + description?: string; + shortcut?: string; + } + + /* commands functions */ + function getAll(): Promise; + + /* commands events */ + const onCommand: EventListener<(command: string) => void>; +} + +declare namespace browser.devtools { +} + +declare namespace browser.devtools.inspectedWindow { + /* devtools.inspectedWindow types */ + class Resource { + url: string; + + getContent(): Promise; + + setContent(content: string, commit: boolean): Promise; + } + + /* devtools.inspectedWindow properties */ + const tabId: number; + + /* devtools.inspectedWindow functions */ + function eval(expression: string, options?: { + frameURL?: string; + useContentScriptContext?: boolean; + contextSecurityOrigin?: string; + }): Promise; + + function reload(reloadOptions?: { + ignoreCache?: boolean; + userAgent?: string; + injectedScript?: string; + preprocessorScript?: string; + }): void; + + function getResources(): Promise; + + /* devtools.inspectedWindow events */ + const onResourceAdded: EventListener<(resource: Resource) => void>; + + const onResourceContentCommitted: EventListener<(resource: Resource, content: string) => void>; +} + +declare namespace browser.devtools.network { + /* devtools.network types */ + class Request { + getContent(): Promise; + } + + /* devtools.network functions */ + function getHAR(): Promise; + + /* devtools.network events */ + const onRequestFinished: EventListener<(request: Request) => void>; + + const onNavigated: EventListener<(url: string) => void>; +} + +declare namespace browser.devtools.panels { + /* devtools.panels types */ + class ElementsPanel { + createSidebarPane(title: string): Promise; + + onSelectionChanged: EventListener<() => void>; + } + + class SourcesPanel { + createSidebarPane(title: string): void; + + onSelectionChanged: EventListener<() => void>; + } + + class ExtensionPanel { + createStatusBarButton(iconPath: string, tooltipText: string, disabled: boolean): Button; + + onSearch: EventListener<(action: string, queryString?: string) => void>; + onShown: EventListener<(window: object/*global*/) => void>; + onHidden: EventListener<() => void>; + } + + class ExtensionSidebarPane { + setHeight(height: string): void; + + setExpression(expression: string, rootTitle?: string): Promise; + + setObject(jsonObject: string, rootTitle?: string): Promise; + + setPage(path: string): void; + + onShown: EventListener<(window: object/*global*/) => void>; + onHidden: EventListener<() => void>; + } + + class Button { + update(tooltipText?: string, disabled?: boolean): void; + update(disabled?: boolean): void; + update(iconPath: string, tooltipText: string, disabled?: boolean): void; + + onClicked: EventListener<() => void>; + } + + /* devtools.panels properties */ + const elements: ElementsPanel; + + const sources: SourcesPanel; + + const themeName: string; + + /* devtools.panels functions */ + function create(title: string, iconPath: string, pagePath: string): Promise; + + function setOpenResourceHandler(): Promise; + + function openResource(url: string, lineNumber: number): Promise; + + /* devtools.panels events */ + const onThemeChanged: EventListener<(themeName: string) => void>; +} + +declare namespace browser.find { + /* find functions */ + function find(queryphrase: string, params?: { + tabId?: number; + caseSensitive?: boolean; + entireWord?: boolean; + includeRectData?: boolean; + includeRangeData?: boolean; + }): void; + + function highlightResults(params?: { + rangeIndex?: number; + tabId?: number; + noScroll?: boolean; + }): void; + + function removeHighlighting(tabId?: number): void; +} + +declare namespace browser.geckoProfiler { + /* geckoProfiler types */ + enum ProfilerFeature { + java = "java", + js = "js", + leaf = "leaf", + mainthreadio = "mainthreadio", + memory = "memory", + privacy = "privacy", + restyle = "restyle", + stackwalk = "stackwalk", + tasktracer = "tasktracer", + threads = "threads" + } + + /* geckoProfiler functions */ + function start(settings: { + bufferSize: number; + interval: number; + features: ProfilerFeature[]; + threads?: string[]; + }): void; + + function stop(): void; + + function pause(): void; + + function resume(): void; + + function getProfile(): void; + + function getProfileAsArrayBuffer(): void; + + function getSymbols(debugName: string, breakpadId: string): void; + + /* geckoProfiler events */ + const onRunning: EventListener<(isRunning: boolean) => void>; +} + +declare namespace browser.history { + /* history types */ + enum TransitionType { + link = "link", + typed = "typed", + auto_bookmark = "auto_bookmark", + auto_subframe = "auto_subframe", + manual_subframe = "manual_subframe", + generated = "generated", + auto_toplevel = "auto_toplevel", + form_submit = "form_submit", + reload = "reload", + keyword = "keyword", + keyword_generated = "keyword_generated" + } + + interface HistoryItem { + id: string; + url?: string; + title?: string; + lastVisitTime?: number; + visitCount?: number; + typedCount?: number; + } + + interface VisitItem { + id: string; + visitId: string; + visitTime?: number; + referringVisitId: string; + transition: TransitionType; + } + + /* history functions */ + function search(query: { + text: string; + startTime?: extensionTypes.Date; + endTime?: extensionTypes.Date; + maxResults?: number; + }): Promise; + + function getVisits(details: { + url: string; + }): Promise; + + function addUrl(details: { + url: string; + title?: string; + transition?: TransitionType; + visitTime?: extensionTypes.Date; + }): Promise; + + function deleteUrl(details: { + url: string; + }): Promise; + + function deleteRange(range: { + startTime: extensionTypes.Date; + endTime: extensionTypes.Date; + }): Promise; + + function deleteAll(): Promise; + + /* history events */ + const onVisited: EventListener<(result: HistoryItem) => void>; + + const onVisitRemoved: EventListener<(removed: { + allHistory: boolean; + urls: string[]; + }) => void>; + + const onTitleChanged: EventListener<(changed: { + url: string; + title: string; + }) => void>; +} + +declare namespace browser.contextMenus { + /* contextMenus types */ + enum ContextType { + all = "all", + page = "page", + frame = "frame", + selection = "selection", + link = "link", + editable = "editable", + password = "password", + image = "image", + video = "video", + audio = "audio", + launcher = "launcher", + browser_action = "browser_action", + page_action = "page_action", + tab = "tab" + } +} + +declare namespace browser.menus { + /* menus types */ + enum ContextType { + all = "all", + page = "page", + frame = "frame", + selection = "selection", + link = "link", + editable = "editable", + password = "password", + image = "image", + video = "video", + audio = "audio", + launcher = "launcher", + browser_action = "browser_action", + page_action = "page_action", + tab = "tab", + tools_menu = "tools_menu" + } + + enum ItemType { + normal = "normal", + checkbox = "checkbox", + radio = "radio", + separator = "separator" + } + + interface OnClickData { + menuItemId: number | string; + parentMenuItemId?: number | string; + mediaType?: string; + linkText?: string; + linkUrl?: string; + srcUrl?: string; + pageUrl?: string; + frameUrl?: string; + selectionText?: string; + editable: boolean; + wasChecked?: boolean; + checked?: boolean; + modifiers: OnClickDataModifiersEnum[]; + } + + enum OnClickDataModifiersEnum { + Shift = "Shift", + Alt = "Alt", + Command = "Command", + Ctrl = "Ctrl", + MacCtrl = "MacCtrl" + } + + /* menus properties */ + const ACTION_MENU_TOP_LEVEL_LIMIT: number; + + /* menus functions */ + function create(createProperties: { + type?: ItemType; + id?: string; + icons?: { + [key: number]: string; + }; + title?: string; + checked?: boolean; + contexts?: ContextType[]; + onclick?: (info: menusInternal.OnClickData, tab: tabs.Tab) => void; + parentId?: number | string; + documentUrlPatterns?: string[]; + targetUrlPatterns?: string[]; + enabled?: boolean; + command?: string; + }): number | string; + + function update(id: number | string, updateProperties: { + type?: ItemType; + title?: string; + checked?: boolean; + contexts?: ContextType[]; + onclick?: (info: menusInternal.OnClickData, tab: tabs.Tab) => void; + parentId?: number | string; + documentUrlPatterns?: string[]; + targetUrlPatterns?: string[]; + enabled?: boolean; + }): Promise; + + function remove(menuItemId: number | string): Promise; + + function removeAll(): Promise; + + /* menus events */ + const onClicked: EventListener<(info: OnClickData, tab?: tabs.Tab) => void>; +} + +declare namespace browser.menusInternal { + /* menusInternal types */ + interface OnClickData { + menuItemId: number | string; + parentMenuItemId?: number | string; + mediaType?: string; + linkUrl?: string; + srcUrl?: string; + pageUrl?: string; + frameUrl?: string; + selectionText?: string; + editable: boolean; + wasChecked?: boolean; + checked?: boolean; + } +} + +declare namespace browser.omnibox { + /* omnibox types */ + enum DescriptionStyleType { + url = "url", + match = "match", + dim = "dim" + } + + enum OnInputEnteredDisposition { + currentTab = "currentTab", + newForegroundTab = "newForegroundTab", + newBackgroundTab = "newBackgroundTab" + } + + interface SuggestResult { + content: string; + description: string; + descriptionStyles?: Array<{ + offset: number; + type: DescriptionStyleType; + length?: number; + }>; + descriptionStylesRaw?: Array<{ + offset: number; + type: number; + }>; + } + + interface DefaultSuggestResult { + description: string; + descriptionStyles?: Array<{ + offset: number; + type: DescriptionStyleType; + length?: number; + }>; + descriptionStylesRaw?: Array<{ + offset: number; + type: number; + }>; + } + + /* omnibox functions */ + function setDefaultSuggestion(suggestion: DefaultSuggestResult): void; + + /* omnibox events */ + const onInputStarted: EventListener<() => void>; + + const onInputChanged: EventListener<(text: string, suggest: (suggestResults: SuggestResult[]) => void) => void>; + + const onInputEntered: EventListener<(text: string, disposition: OnInputEnteredDisposition) => void>; + + const onInputCancelled: EventListener<() => void>; +} + +declare namespace browser.pageAction { + /* pageAction types */ + type ImageDataType = object/*ImageData*/; + + /* pageAction functions */ + function show(tabId: number): Promise; + + function hide(tabId: number): Promise; + + function setTitle(details: { + tabId: number; + title: string; + }): void; + + function getTitle(details: { + tabId: number; + }): Promise; + + function setIcon(details: { + tabId: number; + imageData?: ImageDataType | { + [key: number]: ImageDataType; + }; + path?: string | { + [key: number]: string; + }; + }): Promise; + + function setPopup(details: { + tabId: number; + popup: string; + }): void; + + function getPopup(details: { + tabId: number; + }): Promise; + + function openPopup(): void; + + /* pageAction events */ + const onClicked: EventListener<(tab: tabs.Tab) => void>; +} + +declare namespace browser.pkcs11 { + /* pkcs11 functions */ + function isModuleInstalled(name: string): void; + + function installModule(name: string, flags?: number): void; + + function uninstallModule(name: string): void; + + function getModuleSlots(name: string): void; +} + +declare namespace browser.sessions { + /* sessions types */ + interface Filter { + maxResults?: number; + } + + interface Session { + lastModified: number; + tab?: tabs.Tab; + window?: windows.Window; + } + + interface Device { + info: string; + deviceName: string; + sessions: Session[]; + } + + /* sessions properties */ + const MAX_SESSION_RESULTS: number; + + /* sessions functions */ + function forgetClosedTab(windowId: number, sessionId: string): void; + + function forgetClosedWindow(sessionId: string): void; + + function getRecentlyClosed(filter?: Filter): Promise; + + function getDevices(filter?: Filter): Promise; + + function restore(sessionId?: string): Promise; + + function setTabValue(tabId: number, key: string, value: any): void; + + function getTabValue(tabId: number, key: string): void; + + function removeTabValue(tabId: number, key: string): void; + + function setWindowValue(windowId: number, key: string, value: any): void; + + function getWindowValue(windowId: number, key: string): void; + + function removeWindowValue(windowId: number, key: string): void; + + /* sessions events */ + const onChanged: EventListener<() => void>; +} + +declare namespace browser.sidebarAction { + /* sidebarAction types */ + type ImageDataType = object/*ImageData*/; + + /* sidebarAction functions */ + function setTitle(details: { + title: string; + tabId?: number; + }): void; + + function getTitle(details: { + tabId?: number; + }): void; + + function setIcon(details: { + imageData?: ImageDataType | { + [key: number]: ImageDataType; + }; + path?: string | string; + tabId?: number; + }): void; + + function setPanel(details: { + tabId?: number; + panel: string; + }): void; + + function getPanel(details: { + tabId?: number; + }): void; + + function open(): void; + + function close(): void; +} + +declare namespace browser.tabs { + /* tabs types */ + enum MutedInfoReason { + user = "user", + capture = "capture", + extension = "extension" + } + + interface MutedInfo { + muted: boolean; + reason?: MutedInfoReason; + extensionId?: string; + } + + interface Tab { + id?: number; + index: number; + windowId?: number; + openerTabId?: number; + selected: boolean; + highlighted: boolean; + active: boolean; + pinned: boolean; + lastAccessed?: number; + audible?: boolean; + mutedInfo?: MutedInfo; + url?: string; + title?: string; + favIconUrl?: string; + status?: string; + discarded?: boolean; + incognito: boolean; + width?: number; + height?: number; + sessionId?: string; + cookieStoreId?: string; + isArticle?: boolean; + isInReaderMode?: boolean; + } + + enum ZoomSettingsMode { + automatic = "automatic", + manual = "manual", + disabled = "disabled" + } + + enum ZoomSettingsScope { + perorigin = "per-origin", + pertab = "per-tab" + } + + interface ZoomSettings { + mode?: ZoomSettingsMode; + scope?: ZoomSettingsScope; + defaultZoomFactor?: number; + } + + interface PageSettings { + orientation?: number; + scaling?: number; + shrinkToFit?: boolean; + showBackgroundColors?: boolean; + showBackgroundImages?: boolean; + paperSizeUnit?: number; + paperWidth?: number; + paperHeight?: number; + headerLeft?: string; + headerCenter?: string; + headerRight?: string; + footerLeft?: string; + footerCenter?: string; + footerRight?: string; + marginLeft?: number; + marginRight?: number; + marginTop?: number; + marginBottom?: number; + } + + enum TabStatus { + loading = "loading", + complete = "complete" + } + + enum WindowType { + normal = "normal", + popup = "popup", + panel = "panel", + app = "app", + devtools = "devtools" + } + + /* tabs properties */ + const TAB_ID_NONE: number; + + /* tabs functions */ + function get(tabId: number): Promise; + + function getCurrent(): Promise; + + function connect(tabId: number, connectInfo?: { + name?: string; + frameId?: number; + }): runtime.Port; + + function sendRequest(tabId: number, request: any, responseCallback?: (response: any) => void): void; + + function sendMessage(tabId: number, message: any, options: { + frameId?: number; + }, responseCallback?: (response: any) => void): void; + + function getSelected(windowId?: number): Promise; + + function getAllInWindow(windowId?: number): Promise; + + function create(createProperties: { + windowId?: number; + index?: number; + url?: string; + active?: boolean; + selected?: boolean; + pinned?: boolean; + openerTabId?: number; + cookieStoreId?: string; + openInReaderMode?: boolean; + }): Promise; + + function duplicate(tabId: number): Promise; + + function query(queryInfo: { + active?: boolean; + pinned?: boolean; + audible?: boolean; + muted?: boolean; + highlighted?: boolean; + currentWindow?: boolean; + lastFocusedWindow?: boolean; + status?: TabStatus; + discarded?: boolean; + title?: string; + url?: string | string[]; + windowId?: number; + windowType?: WindowType; + index?: number; + cookieStoreId?: string; + openerTabId?: number; + }): Promise; + + function highlight(highlightInfo: { + windowId?: number; + tabs: number[] | number; + }): Promise; + + function update(updateProperties: { + url?: string; + active?: boolean; + highlighted?: boolean; + selected?: boolean; + pinned?: boolean; + muted?: boolean; + openerTabId?: number; + loadReplace?: boolean; + }): Promise; + function update(tabId: number, updateProperties: { + url?: string; + active?: boolean; + highlighted?: boolean; + selected?: boolean; + pinned?: boolean; + muted?: boolean; + openerTabId?: number; + loadReplace?: boolean; + }): Promise; + + function move(tabIds: number | number[], moveProperties: { + windowId?: number; + index: number; + }): Promise; + + function reload(reloadProperties?: { + bypassCache?: boolean; + }): Promise; + function reload(tabId: number, reloadProperties?: { + bypassCache?: boolean; + }): Promise; + + function remove(tabIds: number | number[]): Promise; + + function discard(tabIds: number | number[]): void; + + function detectLanguage(tabId?: number): Promise; + + function toggleReaderMode(tabId?: number): void; + + function captureVisibleTab(options?: extensionTypes.ImageDetails): Promise; + function captureVisibleTab(windowId: number, options?: extensionTypes.ImageDetails): Promise; + + function executeScript(details: extensionTypes.InjectDetails): Promise; + function executeScript(tabId: number, details: extensionTypes.InjectDetails): Promise; + + function insertCSS(details: extensionTypes.InjectDetails): Promise; + function insertCSS(tabId: number, details: extensionTypes.InjectDetails): Promise; + + function removeCSS(details: extensionTypes.InjectDetails): Promise; + function removeCSS(tabId: number, details: extensionTypes.InjectDetails): Promise; + + function setZoom(zoomFactor: number): Promise; + function setZoom(tabId: number, zoomFactor: number): Promise; + + function getZoom(tabId?: number): Promise; + + function setZoomSettings(zoomSettings: ZoomSettings): Promise; + function setZoomSettings(tabId: number, zoomSettings: ZoomSettings): Promise; + + function getZoomSettings(tabId?: number): Promise; + + function print(): void; + + function printPreview(): Promise; + + function saveAsPDF(pageSettings: PageSettings): Promise; + + /* tabs events */ + const onCreated: EventListener<(tab: Tab) => void>; + + const onUpdated: EventListener<(tabId: number, changeInfo: { + status: string; + discarded?: boolean; + url?: string; + pinned?: boolean; + audible?: boolean; + mutedInfo?: MutedInfo; + favIconUrl?: string; + }, tab: Tab) => void>; + + const onMoved: EventListener<(tabId: number, moveInfo: { + windowId: number; + fromIndex: number; + toIndex: number; + }) => void>; + + const onSelectionChanged: EventListener<(tabId: number, selectInfo: { + windowId: number; + }) => void>; + + const onActiveChanged: EventListener<(tabId: number, selectInfo: { + windowId: number; + }) => void>; + + const onActivated: EventListener<(activeInfo: { + tabId: number; + windowId: number; + }) => void>; + + const onHighlightChanged: EventListener<(selectInfo: { + windowId: number; + tabIds: number[]; + }) => void>; + + const onHighlighted: EventListener<(highlightInfo: { + windowId: number; + tabIds: number[]; + }) => void>; + + const onDetached: EventListener<(tabId: number, detachInfo: { + oldWindowId: number; + oldPosition: number; + }) => void>; + + const onAttached: EventListener<(tabId: number, attachInfo: { + newWindowId: number; + newPosition: number; + }) => void>; + + const onRemoved: EventListener<(tabId: number, removeInfo: { + windowId: number; + isWindowClosing: boolean; + }) => void>; + + const onReplaced: EventListener<(addedTabId: number, removedTabId: number) => void>; + + const onZoomChange: EventListener<(ZoomChangeInfo: { + tabId: number; + oldZoomFactor: number; + newZoomFactor: number; + zoomSettings: ZoomSettings; + }) => void>; +} + +declare namespace browser.windows { + /* windows types */ + enum WindowType { + normal = "normal", + popup = "popup", + panel = "panel", + app = "app", + devtools = "devtools" + } + + enum WindowState { + normal = "normal", + minimized = "minimized", + maximized = "maximized", + fullscreen = "fullscreen", + docked = "docked" + } + + interface Window { + id?: number; + focused: boolean; + top?: number; + left?: number; + width?: number; + height?: number; + tabs?: tabs.Tab[]; + incognito: boolean; + type?: WindowType; + state?: WindowState; + alwaysOnTop: boolean; + sessionId?: string; + title?: string; + } + + enum CreateType { + normal = "normal", + popup = "popup", + panel = "panel", + detached_panel = "detached_panel" + } + + /* windows properties */ + const WINDOW_ID_NONE: number; + + const WINDOW_ID_CURRENT: number; + + /* windows functions */ + function get(windowId: number, getInfo?: { + populate?: boolean; + windowTypes?: WindowType[]; + }): Promise; + + function getCurrent(getInfo?: { + populate?: boolean; + windowTypes?: WindowType[]; + }): Promise; + + function getLastFocused(getInfo?: { + populate?: boolean; + windowTypes?: WindowType[]; + }): Promise; + + function getAll(getInfo?: { + populate?: boolean; + windowTypes?: WindowType[]; + }): Promise; + + function create(createData?: { + url?: string | string[]; + tabId?: number; + left?: number; + top?: number; + width?: number; + height?: number; + focused?: boolean; + incognito?: boolean; + type?: CreateType; + state?: WindowState; + allowScriptsToClose?: boolean; + titlePreface?: string; + }): Promise; + + function update(windowId: number, updateInfo: { + left?: number; + top?: number; + width?: number; + height?: number; + focused?: boolean; + drawAttention?: boolean; + state?: WindowState; + titlePreface?: string; + }): Promise; + + function remove(windowId: number): Promise; + + /* windows events */ + const onCreated: EventListener<(window: Window) => void>; + + const onRemoved: EventListener<(windowId: number) => void>; + + const onFocusChanged: EventListener<(windowId: number) => void>; +} diff --git a/types/firefox-webext-browser/tsconfig.json b/types/firefox-webext-browser/tsconfig.json new file mode 100644 index 0000000000..316317e305 --- /dev/null +++ b/types/firefox-webext-browser/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "firefox-webext-browser-tests.ts" + ] +} diff --git a/types/firefox-webext-browser/tslint.json b/types/firefox-webext-browser/tslint.json new file mode 100644 index 0000000000..c94feb08d9 --- /dev/null +++ b/types/firefox-webext-browser/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-mergeable-namespace": false, + "unified-signatures": false, + "no-unnecessary-qualifier": false + } +} From af67c5568da60edc26bd989cfb29a00a41253aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 23:54:25 +0100 Subject: [PATCH 172/639] Changing leaflet dependency handling --- types/leaflet.heat/index.d.ts | 7 ++++--- types/leaflet.heat/leaflet.heat-tests.ts | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index 66464fcb08..f294080691 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -1,12 +1,12 @@ -// Type definitions for Leaflet.heat v0.2.0 +// Type definitions for Leaflet.heat 0.2 // Project: https://github.com/Leaflet/Leaflet.heat // Definitions by: Önder Ceylan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { type HeatLatLngTuple = [number, number, number]; interface ColorGradientConfig { @@ -26,6 +26,7 @@ declare namespace L { setOptions(options: HeatMapOptions): HeatLayer; addLatLng(latlng: LatLng | HeatLatLngTuple): HeatLayer; setLatLngs(latlngs: Array): HeatLayer; + redraw(): TileLayer; } function heatLayer(latlngs: Array, options: HeatMapOptions): HeatLayer; diff --git a/types/leaflet.heat/leaflet.heat-tests.ts b/types/leaflet.heat/leaflet.heat-tests.ts index aead8f1960..cbad005d8d 100644 --- a/types/leaflet.heat/leaflet.heat-tests.ts +++ b/types/leaflet.heat/leaflet.heat-tests.ts @@ -1,11 +1,14 @@ -const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - osmAttrib = '© OpenStreetMap contributors', - osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), - map = new L.Map('map', { - layers: [osm], - center: new L.LatLng(50.5, 30.5), - zoom: 15, - }); +import * as L from 'leaflet'; +import 'leaflet.heat'; + +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +const osmAttrib = '© OpenStreetMap contributors'; +const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); +const map = new L.Map('map', { + layers: [osm], + center: new L.LatLng(50.5, 30.5), + zoom: 15, +}); // Each point in the input array can be either an array like [50.5, 30.5, 0.5], or a Leaflet LatLng object. const heat: L.HeatLayer = L.heatLayer([ From 13891ce131f28462078c4f16aed3e1370c0ff241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96nder=20Ceylan?= Date: Sat, 25 Nov 2017 23:59:34 +0100 Subject: [PATCH 173/639] Fixed failing tests --- types/leaflet.heat/index.d.ts | 1 - types/leaflet.heat/leaflet.heat-tests.ts | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/leaflet.heat/index.d.ts b/types/leaflet.heat/index.d.ts index f294080691..224b6f7c35 100644 --- a/types/leaflet.heat/index.d.ts +++ b/types/leaflet.heat/index.d.ts @@ -26,7 +26,6 @@ declare module 'leaflet' { setOptions(options: HeatMapOptions): HeatLayer; addLatLng(latlng: LatLng | HeatLatLngTuple): HeatLayer; setLatLngs(latlngs: Array): HeatLayer; - redraw(): TileLayer; } function heatLayer(latlngs: Array, options: HeatMapOptions): HeatLayer; diff --git a/types/leaflet.heat/leaflet.heat-tests.ts b/types/leaflet.heat/leaflet.heat-tests.ts index cbad005d8d..b715255e78 100644 --- a/types/leaflet.heat/leaflet.heat-tests.ts +++ b/types/leaflet.heat/leaflet.heat-tests.ts @@ -32,7 +32,12 @@ const newLatLng = new L.LatLng(50.8, 30.2); heat.addLatLng(newLatLng); // Set new latLng list to the heat layer -heat.setLatLngs([newLatLng, newLatLng, newLatLng, [50.6, 30.4, 0.5],]); +heat.setLatLngs([ + newLatLng, + newLatLng, + newLatLng, + [50.6, 30.4, 0.5], +]); // Redraw the heat layer heat.redraw(); From f46fe2c18b0d5e5c7a0d62ca6ba8ba7452239b51 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sun, 26 Nov 2017 07:38:07 +0100 Subject: [PATCH 174/639] feat(commander): remove types --- notNeededPackages.json | 6 + types/commander/commander-tests.ts | 99 ---------- types/commander/index.d.ts | 299 ----------------------------- types/commander/tsconfig.json | 23 --- types/commander/tslint.json | 79 -------- 5 files changed, 6 insertions(+), 500 deletions(-) delete mode 100644 types/commander/commander-tests.ts delete mode 100644 types/commander/index.d.ts delete mode 100644 types/commander/tsconfig.json delete mode 100644 types/commander/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 306865851b..671f8d9d65 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -132,6 +132,12 @@ "sourceRepoURL": "https://github.com/mapbox/cheap-ruler", "asOfVersion": "2.5.0" }, + { + "libraryName": "commander", + "typingsPackageName": "commander", + "sourceRepoURL": "https://github.com/tj/commander.js", + "asOfVersion": "2.12.0" + }, { "libraryName": "constant-case", "typingsPackageName": "constant-case", diff --git a/types/commander/commander-tests.ts b/types/commander/commander-tests.ts deleted file mode 100644 index 46aa77d92c..0000000000 --- a/types/commander/commander-tests.ts +++ /dev/null @@ -1,99 +0,0 @@ -import * as program from 'commander'; - -interface ExtendedOptions extends program.CommandOptions { - isNew: any; -} - -const commandInstance = new program.Command('-f'); -const optionsInstance = new program.Option('-f'); - -const name = program.name(); - -program - .name('set name') - .version('0.0.1') - .option('-p, --peppers', 'Add peppers') - .option('-P, --pineapple', 'Add pineapple') - .option('-b, --bbq', 'Add bbq sauce') - .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble') - .parse(process.argv); - -console.log('you ordered a pizza with:'); -if (program['peppers']) console.log(' - peppers'); -if (program['pineapple']) console.log(' - pineapple'); -if (program['bbq']) console.log(' - bbq'); -console.log(' - %s cheese', program['cheese']); - -function range(val: string) { - return val.split('..').map(Number); -} - -function list(val: string) { - return val.split(','); -} - -function collect(val: string, memo: string[]) { - memo.push(val); - return memo; -} - -function increaseVerbosity(v: any, total: number) { - return total + 1; -} - -program - .version('0.0.1') - .usage('[options] ') - .option('-i, --integer ', 'An integer argument', parseInt) - .option('-f, --float ', 'A float argument', parseFloat) - .option('-r, --range ..', 'A range', range) - .option('-l, --list ', 'A list', list) - .option('-o, --optional [value]', 'An optional value') - .option('-c, --collect [value]', 'A repeatable value', collect, []) - .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0) - .parse(process.argv); - -console.log(' int: %j', program['integer']); -console.log(' float: %j', program['float']); -console.log(' optional: %j', program['optional']); -program['range'] = program['range'] || []; -console.log(' range: %j..%j', program['range'][0], program['range'][1]); -console.log(' list: %j', program['list']); -console.log(' collect: %j', program['collect']); -console.log(' verbosity: %j', program['verbose']); -console.log(' args: %j', program['args']); - -program - .version('0.0.1') - .option('-f, --foo', 'enable some foo') - .option('-b, --bar', 'enable some bar') - .option('-B, --baz', 'enable some baz'); - -// must be before .parse() since -// node's emit() is immediate - -program.on('--help', () => { - console.log(' Examples:'); - console.log(''); - console.log(' $ custom-help --help'); - console.log(' $ custom-help -h'); - console.log(''); -}); - -program - .command('allow-unknown-option') - .allowUnknownOption() - .action(() => { - console.log('unknown option is allowed'); - }); - -program - .version('0.0.1') - .arguments(' [env]') - .action((cmd, env) => { - console.log(cmd, env); - }); - -program.parse(process.argv); - -console.log('stuff'); diff --git a/types/commander/index.d.ts b/types/commander/index.d.ts deleted file mode 100644 index c732d43c7c..0000000000 --- a/types/commander/index.d.ts +++ /dev/null @@ -1,299 +0,0 @@ -// Type definitions for commander 2.11 -// Project: https://github.com/visionmedia/commander.js -// Definitions by: Alan Agius , Marcelo Dezem , vvakame -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare class Option { - flags: string; - required: boolean; - optional: boolean; - bool: boolean; - short?: string; - long: string; - description: string; - - /** - * Initialize a new `Option` with the given `flags` and `description`. - * - * @param {string} flags - * @param {string} [description] - */ - constructor(flags: string, description?: string); -} - -declare class Command extends NodeJS.EventEmitter { - [key: string]: any; - - args: string[]; - - /** - * Initialize a new `Command`. - * - * @param {string} [name] - */ - constructor(name?: string); - - /** - * Set the program version to `str`. - * - * This method auto-registers the "-V, --version" flag - * which will print the version number when passed. - * - * @param {string} str - * @param {string} [flags] - * @returns {Command} for chaining - */ - version(str: string, flags?: string): Command; - - /** - * Add command `name`. - * - * The `.action()` callback is invoked when the - * command `name` is specified via __ARGV__, - * and the remaining arguments are applied to the - * function for access. - * - * When the `name` is "*" an un-matched command - * will be passed as the first arg, followed by - * the rest of __ARGV__ remaining. - * - * @example - * program - * .version('0.0.1') - * .option('-C, --chdir ', 'change the working directory') - * .option('-c, --config ', 'set config path. defaults to ./deploy.conf') - * .option('-T, --no-tests', 'ignore test hook') - * - * program - * .command('setup') - * .description('run remote setup commands') - * .action(function() { - * console.log('setup'); - * }); - * - * program - * .command('exec ') - * .description('run the given remote command') - * .action(function(cmd) { - * console.log('exec "%s"', cmd); - * }); - * - * program - * .command('teardown [otherDirs...]') - * .description('run teardown commands') - * .action(function(dir, otherDirs) { - * console.log('dir "%s"', dir); - * if (otherDirs) { - * otherDirs.forEach(function (oDir) { - * console.log('dir "%s"', oDir); - * }); - * } - * }); - * - * program - * .command('*') - * .description('deploy the given env') - * .action(function(env) { - * console.log('deploying "%s"', env); - * }); - * - * program.parse(process.argv); - * - * @param {string} name - * @param {string} [desc] for git-style sub-commands - * @param {CommandOptions} [opts] command options - * @returns {Command} the new command - */ - command(name: string, desc?: string, opts?: commander.CommandOptions): Command; - - /** - * Define argument syntax for the top-level command. - * - * @param {string} desc - * @returns {Command} for chaining - */ - arguments(desc: string): Command; - - /** - * Parse expected `args`. - * - * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`. - * - * @param {string[]} args - * @returns {Command} for chaining - */ - parseExpectedArgs(args: string[]): Command; - /** - * Register callback `fn` for the command. - * - * @example - * program - * .command('help') - * .description('display verbose help') - * .action(function() { - * // output help here - * }); - * - * @param {(...args: any[]) => void} fn - * @returns {Command} for chaining - */ - action(fn: (...args: any[]) => void): Command; - - /** - * Define option with `flags`, `description` and optional - * coercion `fn`. - * - * The `flags` string should contain both the short and long flags, - * separated by comma, a pipe or space. The following are all valid - * all will output this way when `--help` is used. - * - * "-p, --pepper" - * "-p|--pepper" - * "-p --pepper" - * - * @example - * // simple boolean defaulting to false - * program.option('-p, --pepper', 'add pepper'); - * - * --pepper - * program.pepper - * // => Boolean - * - * // simple boolean defaulting to true - * program.option('-C, --no-cheese', 'remove cheese'); - * - * program.cheese - * // => true - * - * --no-cheese - * program.cheese - * // => false - * - * // required argument - * program.option('-C, --chdir ', 'change the working directory'); - * - * --chdir /tmp - * program.chdir - * // => "/tmp" - * - * // optional argument - * program.option('-c, --cheese [type]', 'add cheese [marble]'); - * - * @param {string} flags - * @param {string} [description] - * @param {((arg1: any, arg2: any) => void) | RegExp} [fn] function or default - * @param {*} [defaultValue] - * @returns {Command} for chaining - */ - option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command; - option(flags: string, description?: string, defaultValue?: any): Command; - - /** - * Allow unknown options on the command line. - * - * @param {boolean} [arg] if `true` or omitted, no error will be thrown for unknown options. - * @returns {Command} for chaining - */ - allowUnknownOption(arg?: boolean): Command; - - /** - * Parse `argv`, settings options and invoking commands when defined. - * - * @param {string[]} argv - * @returns {Command} for chaining - */ - parse(argv: string[]): Command; - - /** - * Parse options from `argv` returning `argv` void of these options. - * - * @param {string[]} argv - * @returns {ParseOptionsResult} - */ - parseOptions(argv: string[]): commander.ParseOptionsResult; - - /** - * Return an object containing options as key-value pairs - * - * @returns {{[key: string]: string}} - */ - opts(): { [key: string]: string }; - - /** - * Set the description to `str`. - * - * @param {string} str - * @return {(Command | string)} - */ - description(str: string): Command; - description(): string; - - /** - * Set an alias for the command. - * - * @param {string} alias - * @return {(Command | string)} - */ - alias(alias: string): Command; - alias(): string; - - /** - * Set or get the command usage. - * - * @param {string} str - * @return {(Command | string)} - */ - usage(str: string): Command; - usage(): string; - - /** - * Set the name of the command. - * - * @param {string} str - * @return {Command} - */ - name(str: string): Command; - - /** - * Get the name of the command. - * - * @return {string} - */ - name(): string; - - /** - * Output help information for this command. - * - * @param {(str: string) => string} [cb] - */ - outputHelp(cb?: (str: string) => string): void; - - /** Output help information and exit. */ - help(): void; -} - -declare namespace commander { - - interface CommandOptions { - noHelp?: boolean; - isDefault?: boolean; - } - - interface ParseOptionsResult { - args: string[]; - unknown: string[]; - } - - interface CommanderStatic extends Command { - Command: typeof Command; - Option: typeof Option; - CommandOptions: CommandOptions; - ParseOptionsResult: ParseOptionsResult; - } - -} - -declare const commander: commander.CommanderStatic; -export = commander; diff --git a/types/commander/tsconfig.json b/types/commander/tsconfig.json deleted file mode 100644 index dcb92cc920..0000000000 --- a/types/commander/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "commander-tests.ts" - ] -} \ No newline at end of file diff --git a/types/commander/tslint.json b/types/commander/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/commander/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 0bd13cce3f66140ffba1e01f541780549b35ba3d Mon Sep 17 00:00:00 2001 From: izackhub Date: Sun, 26 Nov 2017 14:23:04 +0100 Subject: [PATCH 175/639] [index.d.ts]: added new declaration Since the library itself is titled 'is_js' on npm, this would solve the problem of the definitions not being found or having to rename the package folder. --- types/is/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/is/index.d.ts b/types/is/index.d.ts index 3c0e279eea..b61bd6deee 100644 --- a/types/is/index.d.ts +++ b/types/is/index.d.ts @@ -1320,4 +1320,8 @@ declare var is: Is; declare module 'is' { export = is; -} \ No newline at end of file +} + +declare module 'is_js' { + export = is; +} From 044be28abb22b0e3a4814db7a6000822f24966e7 Mon Sep 17 00:00:00 2001 From: kennethanCeyer Date: Sun, 26 Nov 2017 22:28:04 +0900 Subject: [PATCH 176/639] fix the wrong type of owl.carousel --- types/owl.carousel/index.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types/owl.carousel/index.d.ts b/types/owl.carousel/index.d.ts index 21a4dcee71..4d0548fc66 100644 --- a/types/owl.carousel/index.d.ts +++ b/types/owl.carousel/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for owl.carousel 2.2 +// Type definitions for owl.carousel 2.2.1 // Project: https://github.com/OwlCarousel2/OwlCarousel2 // Definitions by: Ismael Gorissen +// Updated by: Kenneth Ceyer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -36,8 +37,8 @@ declare namespace OwlCarousel { autoplay?: boolean; autoplayTimeout?: number; autoplayHoverPause?: boolean; - smartSpeed?: boolean; - fluidSpeed?: boolean; + smartSpeed?: number | boolean; + fluidSpeed?: number | boolean; autoplaySpeed?: number | boolean; navSpeed?: number | boolean; dotsSpeed?: number | boolean; From a49da75063a2e83f9d826e9237839cf65795103b Mon Sep 17 00:00:00 2001 From: kennethanCeyer Date: Sun, 26 Nov 2017 22:38:53 +0900 Subject: [PATCH 177/639] fix dts header, append pr to #21752 --- types/owl.carousel/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/owl.carousel/index.d.ts b/types/owl.carousel/index.d.ts index 4d0548fc66..0295b3fe5b 100644 --- a/types/owl.carousel/index.d.ts +++ b/types/owl.carousel/index.d.ts @@ -1,7 +1,7 @@ -// Type definitions for owl.carousel 2.2.1 +// Type definitions for owl.carousel 2.2 // Project: https://github.com/OwlCarousel2/OwlCarousel2 // Definitions by: Ismael Gorissen -// Updated by: Kenneth Ceyer +// Kenneth Ceyer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 4148e8567522a6988271eee41a22c5423574157b Mon Sep 17 00:00:00 2001 From: Gordon Burgett Date: Sun, 26 Nov 2017 08:46:44 -0700 Subject: [PATCH 178/639] [JSONStream] add stringify(false) overload Package docs allow `false` as a parameter to `stringify`, in addition to `stringify(open, sep, close)`. This is useful for dumping a stream of objects separated by newlines, rather than creating a JSON array of the objects. from https://www.npmjs.com/package/JSONStream > If you call JSONStream.stringify(false) the elements will only be > seperated by a newline. --- types/jsonstream/index.d.ts | 18 ++++++++++++++++++ types/jsonstream/jsonstream-tests.ts | 1 + 2 files changed, 19 insertions(+) diff --git a/types/jsonstream/index.d.ts b/types/jsonstream/index.d.ts index cf0f0fdd43..3e9bdd4b12 100644 --- a/types/jsonstream/index.d.ts +++ b/types/jsonstream/index.d.ts @@ -14,7 +14,25 @@ export interface Options { export declare function parse(pattern: any): NodeJS.ReadWriteStream; export declare function parse(patterns: any[]): NodeJS.ReadWriteStream; + +/** + * Create a writable stream. + * you may pass in custom open, close, and seperator strings. But, by default, + * JSONStream.stringify() will create an array, + * (with default options open='[\n', sep='\n,\n', close='\n]\n') + */ export declare function stringify(): NodeJS.ReadWriteStream; + +/** If you call JSONStream.stringify(false) the elements will only be seperated by a newline. */ +export declare function stringify(newlineOnly: NewlineOnlyIndicator): NodeJS.ReadWriteStream; +type NewlineOnlyIndicator = false + +/** + * Create a writable stream. + * you may pass in custom open, close, and seperator strings. But, by default, + * JSONStream.stringify() will create an array, + * (with default options open='[\n', sep='\n,\n', close='\n]\n') + */ export declare function stringify(open: string, sep: string, close: string): NodeJS.ReadWriteStream; export declare function stringifyObject(): NodeJS.ReadWriteStream; diff --git a/types/jsonstream/jsonstream-tests.ts b/types/jsonstream/jsonstream-tests.ts index d42ab0d845..68c8e858ac 100644 --- a/types/jsonstream/jsonstream-tests.ts +++ b/types/jsonstream/jsonstream-tests.ts @@ -8,6 +8,7 @@ read = read.pipe(json.parse('*')); read = read.pipe(json.parse(['foo/*', 'bar/*'])); read = json.stringify(); +read = json.stringify(false); read = json.stringify('{', ',', '}'); read = json.stringifyObject(); From 65c7acb1c03d3c40183705a0b9a7201c1aeb3595 Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Sun, 26 Nov 2017 18:35:40 -0500 Subject: [PATCH 179/639] Add initial typings for react-toastr --- types/react-toastr/index.d.ts | 20 ++++++++++++++++++ types/react-toastr/react-toastr-tests.tsx | 22 ++++++++++++++++++++ types/react-toastr/tsconfig.json | 25 +++++++++++++++++++++++ types/react-toastr/tslint.json | 1 + 4 files changed, 68 insertions(+) create mode 100644 types/react-toastr/index.d.ts create mode 100644 types/react-toastr/react-toastr-tests.tsx create mode 100644 types/react-toastr/tsconfig.json create mode 100644 types/react-toastr/tslint.json diff --git a/types/react-toastr/index.d.ts b/types/react-toastr/index.d.ts new file mode 100644 index 0000000000..2de77a6d7e --- /dev/null +++ b/types/react-toastr/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for react-toastr 3.0 +// Project: https://github.com/tomchentw/react-toastr +// Definitions by: Josh Holmer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Component, ReactHTML } from 'react'; + +export class ToastContainer extends Component<{ + toastMessageFactory: any; + className?: string; +}> { + error: (message: string, title: string, optionsOverride?: {}) => void; + info: (message: string, title: string, optionsOverride?: {}) => void; + success: (message: string, title: string, optionsOverride?: {}) => void; + warning: (message: string, title: string, optionsOverride?: {}) => void; + clear: () => void; +} +export const ToastMessageAnimated: keyof ReactHTML; +export const ToastMessagejQuery: keyof ReactHTML; diff --git a/types/react-toastr/react-toastr-tests.tsx b/types/react-toastr/react-toastr-tests.tsx new file mode 100644 index 0000000000..75d6527730 --- /dev/null +++ b/types/react-toastr/react-toastr-tests.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; +import { ToastContainer, ToastMessageAnimated } from 'react-toastr'; + +const toastMessageFactory = React.createFactory(ToastMessageAnimated); + +class Test extends React.Component { + ref: ToastContainer; + + toastRef = (ref: ToastContainer) => { + this.ref = ref; + } + + render() { + return ( + + ); + } +} diff --git a/types/react-toastr/tsconfig.json b/types/react-toastr/tsconfig.json new file mode 100644 index 0000000000..1fbbfde4af --- /dev/null +++ b/types/react-toastr/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-toastr-tests.tsx" + ] +} diff --git a/types/react-toastr/tslint.json b/types/react-toastr/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-toastr/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From c4df40988192332549420d7d700179873cec5ab4 Mon Sep 17 00:00:00 2001 From: Rodrigo Saboya Date: Sun, 26 Nov 2017 17:21:45 -0200 Subject: [PATCH 180/639] Updating definitions for Nes>=7.0.0. --- types/nes/client.d.ts | 17 ++-- types/nes/index.d.ts | 19 ++-- types/nes/test/broadcast-client.ts | 4 +- types/nes/test/broadcast-server.ts | 5 +- types/nes/test/nes-tests.ts | 99 +++++++++---------- types/nes/test/route-authentication-client.ts | 14 +-- types/nes/test/route-authentication-server.ts | 20 ++-- types/nes/test/route-invocation-client.ts | 14 +-- types/nes/test/route-invocation-server.ts | 9 +- types/nes/test/socket.ts | 10 +- types/nes/test/subscription-filter-client.ts | 12 +-- types/nes/test/subscription-filter-server.ts | 21 ++-- types/nes/test/subscriptions-client.ts | 12 +-- types/nes/test/subscriptions-server.ts | 11 +-- 14 files changed, 120 insertions(+), 147 deletions(-) diff --git a/types/nes/client.d.ts b/types/nes/client.d.ts index 8314894683..5d348b267e 100644 --- a/types/nes/client.d.ts +++ b/types/nes/client.d.ts @@ -1,6 +1,7 @@ -// Type definitions for nes 6.4.2 +// Type definitions for nes 7.0.0 // Project: https://github.com/hapijs/nes // Definitions by: Ivo Stratev +// Rodrigo Saboya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Client { @@ -9,14 +10,14 @@ declare class Client { onConnect: () => void; onDisconnect: () => void; onUpdate: (message: any) => void; - connect(options: Client.ClientConnectOptions, callback: (err?: any) => void): void; - connect(callback: (err?: any) => void): void; - disconnect(): void; + connect(options: Client.ClientConnectOptions): Promise; + connect(): Promise; + disconnect(): Promise; id: any; // can be `null | number` but also the "socket" value from websocket message data. - request(options: string | Client.ClientRequestOptions, callback: (err: any, payload: any, statusCode?: number, headers?: Object) => void): void; - message(message: any, callback: (err: any, message: any) => void): void; - subscribe(path: string, handler: Client.Handler, callback: (err?: any) => void): void; - unsubscribe(path: string, handler: Client.Handler, callback: (err?: any) => void): void; + request(options: string | Client.ClientRequestOptions): Promise; + message(message: any): Promise; + subscribe(path: string, handler: Client.Handler): Promise; + unsubscribe(path: string, handler: Client.Handler): Promise; subscriptions(): string[]; overrideReconnectionAuth(auth: any): void; } diff --git a/types/nes/index.d.ts b/types/nes/index.d.ts index a6ed90a7b7..c4d26ecda0 100644 --- a/types/nes/index.d.ts +++ b/types/nes/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for nes 6.2.1 +// Type definitions for nes 7.0.0 // Project: https://github.com/hapijs/nes // Definitions by: Ivo Stratev +// Rodrigo Saboya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -62,12 +63,12 @@ declare module nes { index?: boolean; } - export type ServerOnSubscribeWithParams = (socket: Socket, path: string, params: any, next: (err?: any) => void) => void; - export type ServerOnSubscribeWithoutParams = (socket: Socket, path: string, next: (err?: any) => void) => void; + export type ServerOnSubscribeWithParams = (socket: Socket, path: string, params: any) => Promise; + export type ServerOnSubscribeWithoutParams = (socket: Socket, path: string) => Promise; export type ServerOnSubscribe = ServerOnSubscribeWithParams | ServerOnSubscribeWithoutParams; - export type ServerOnUnSubscribeWithParams = (socket: Socket, path: string, params: any, next: () => void) => void; - export type ServerOnUnSubscribeWithoutParams = (socket: Socket, path: string, next: () => void) => void; + export type ServerOnUnSubscribeWithParams = (socket: Socket, path: string, params: any) => void; + export type ServerOnUnSubscribeWithoutParams = (socket: Socket, path: string) => void; export type ServerOnUnSubscribe = ServerOnUnSubscribeWithParams | ServerOnUnSubscribeWithoutParams; interface ServerSubscriptionOptions { @@ -91,10 +92,10 @@ declare module nes { id: string; app: Object; auth: nes.SocketAuthObject; - disconnect(callback?: () => void): void; - send(message: any, callback?: (err?: any) => void): void; - publish(path: string, message: any, callback?: (err?: any) => void): void; - revoke(path: string, message: any, callback?: (err?: any) => void): void; + disconnect(): Promise; + send(message: any): Promise; + publish(path: string, message: any): Promise; + revoke(path: string, message: any): Promise; } /** diff --git a/types/nes/test/broadcast-client.ts b/types/nes/test/broadcast-client.ts index 4c94b8c575..5563a202d3 100644 --- a/types/nes/test/broadcast-client.ts +++ b/types/nes/test/broadcast-client.ts @@ -3,7 +3,7 @@ import Nes = require('nes'); var client = new Nes.Client('ws://localhost'); -client.connect(function (err) { +client.connect().then(() => { client.onUpdate = function (update) { @@ -16,7 +16,7 @@ client.connect(function (err) { import NesClient = require('nes/client'); var client = new NesClient('ws://localhost'); -client.connect(function (err) { +client.connect().then(() => { client.onUpdate = function (update) { diff --git a/types/nes/test/broadcast-server.ts b/types/nes/test/broadcast-server.ts index dcfcb3400e..6ef8f7aafa 100644 --- a/types/nes/test/broadcast-server.ts +++ b/types/nes/test/broadcast-server.ts @@ -4,11 +4,10 @@ import Hapi = require('hapi'); import Nes = require('nes'); var server = new Hapi.Server(); -server.connection(); -server.register(Nes, function (err) { +server.register(Nes).then(() => { - server.start(function (err) { + return server.start().then(() => { server.broadcast('welcome!'); }); diff --git a/types/nes/test/nes-tests.ts b/types/nes/test/nes-tests.ts index 90afe68f3e..85cff1e208 100644 --- a/types/nes/test/nes-tests.ts +++ b/types/nes/test/nes-tests.ts @@ -2,66 +2,55 @@ import Hapi = require('hapi'); import Nes = require('nes'); var server: Hapi.Server = new Hapi.Server(); -server.connection({port: 8080}); -server.register(Nes, (regErr) => { - if(regErr) { - console.log('register err'); - console.log(regErr); - } else { - // No longer need to cast to Nes.Server as Hapi.Server has been modified directly. - // let wsServer: Nes.Server = server as Nes.Server; - let wsServer: Hapi.Server = server; - wsServer.subscription('/item/{id}'); - wsServer.route( { - method: 'GET', - path: '/test', - config: { - handler: (request, reply) => { - reply({test: 'passes ' + request.socket.id}); - } +server.register(Nes).then(() => { + // No longer need to cast to Nes.Server as Hapi.Server has been modified directly. + // let wsServer: Nes.Server = server as Nes.Server; + let wsServer: Hapi.Server = server; + wsServer.subscription('/item/{id}'); + wsServer.route( { + method: 'GET', + path: '/test', + config: { + handler: (request, h) => { + return {test: 'passes ' + request.socket.id}; } - }); - wsServer.start((err: any) => { - if(err) { - console.log('start err'); - console.log(err); - } else { - setTimeout(() => { - wsServer.publish('/item/5', { id: 5, status: 'complete' }); - wsServer.publish('/item/6', { id: 6, status: 'initial' }); - }, 100); - } - }); - } + } + }); + wsServer.start().then(() => { + setTimeout(() => { + wsServer.publish('/item/5', { id: 5, status: 'complete' }); + wsServer.publish('/item/6', { id: 6, status: 'initial' }); + }, 100); + }).catch((err) => { + console.log('start err'); + console.log(err); + }); +}).catch((regErr: any) => { + console.log('register err'); + console.log(regErr); }); let options: Nes.ClientConnectOptions = {delay: 3}; -let wsClient: Nes.Client = new Nes.Client('ws://localhost:8080', options); -wsClient.connect((err: any) => { - if(err) { - console.log('start err'); - console.log(err); - } else { - wsClient.subscribe('/item/5', (update) => { - wsClient.request('/test', (reqErr, payload, statusCode) => { - if(reqErr) { - console.log('request err'); - console.log(reqErr); - } else { - console.log(update); - console.log(payload); - if(payload.test === 'passes') { - process.exit(0); - } - } - }) - }, (subErr) => { - if(subErr) { - console.log('subscribe err'); - console.log(subErr); +let wsClient: Nes.Client = new Nes.Client('ws://localhost', options); +wsClient.connect().then(() => { + wsClient.subscribe('/item/5', (update) => { + wsClient.request('/test').then(({ payload, statusCode }) => { + console.log(update); + console.log(payload); + if(payload.test === 'passes') { + process.exit(0); } - }); - } + }).catch((reqErr: any) => { + console.log('request err'); + console.log(reqErr); + }) + }).catch((subErr: any) => { + console.log('subscribe err'); + console.log(subErr); + }); +}).catch((err: any) => { + console.log('start err'); + console.log(err); }); diff --git a/types/nes/test/route-authentication-client.ts b/types/nes/test/route-authentication-client.ts index fe57eb8d56..f1eb8b9659 100644 --- a/types/nes/test/route-authentication-client.ts +++ b/types/nes/test/route-authentication-client.ts @@ -3,12 +3,9 @@ import Nes = require('nes'); var client = new Nes.Client('ws://localhost'); -client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }, function (err) { +client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }).then(() => { - client.request('hello', function (err, payload) { // Can also request '/h' - - // payload -> 'Hello John Doe' - }); + client.request('hello'); }); // Added in addition to nes doc example code @@ -16,10 +13,7 @@ client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } import NesClient = require('nes/client'); var client = new NesClient('ws://localhost'); -client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }, function (err) { +client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }).then(() => { - client.request('hello', function (err, payload) { // Can also request '/h' - - // payload -> 'Hello John Doe' - }); + return client.request('hello'); }); diff --git a/types/nes/test/route-authentication-server.ts b/types/nes/test/route-authentication-server.ts index 5b4634d77d..2080f04ef4 100644 --- a/types/nes/test/route-authentication-server.ts +++ b/types/nes/test/route-authentication-server.ts @@ -8,7 +8,7 @@ import Nes = require('nes'); var server = new Hapi.Server(); server.connection(); -server.register([Basic, Nes], function (err) { +server.register([Basic, Nes]).then(() => { // Set up HTTP Basic authentication @@ -28,20 +28,20 @@ server.register([Basic, Nes], function (err) { } }; - var validate: Basic.ValidateFunc = function (request, username, password, callback) { + var validate: Basic.Validate = async (request, username, password, h) => { var user = users[username]; if (!user) { - return callback(null, false); + return { credentials: null, isValid: false }; } - Bcrypt.compare(password, user.password, function (err, isValid) { + let isValid = await Bcrypt.compare(password, user.password) - callback(err, isValid, { id: user.id, name: user.name }); - }); + return { isValid, credentials: { id: user.id, name: user.name } }; }; - server.auth.strategy('simple', 'basic', 'required', { validateFunc: validate }); + server.auth.strategy('simple', 'basic', { validateFunc: validate }); + server.auth.default('simple'); // Configure route with authentication @@ -50,12 +50,12 @@ server.register([Basic, Nes], function (err) { path: '/h', config: { id: 'hello', - handler: function (request, reply) { + handler: function (request, h) { - return reply('Hello ' + request.auth.credentials.name); + return 'Hello ' + request.auth.credentials.name; } } }); - server.start(function (err) { /* ... */ }); + return server.start(); }); diff --git a/types/nes/test/route-invocation-client.ts b/types/nes/test/route-invocation-client.ts index 7b144e3a9c..34c40fe151 100644 --- a/types/nes/test/route-invocation-client.ts +++ b/types/nes/test/route-invocation-client.ts @@ -3,12 +3,9 @@ import Nes = require('nes'); var client = new Nes.Client('ws://localhost'); -client.connect(function (err) { +client.connect().then(() => { - client.request('hello', function (err, payload) { // Can also request '/h' - - // payload -> 'world!' - }); + return client.request('hello'); }); // Added in addition to nes doc example code @@ -16,10 +13,7 @@ client.connect(function (err) { import NesClient = require('nes/client'); var client = new NesClient('ws://localhost'); -client.connect(function (err) { +client.connect().then(() => { - client.request('hello', function (err, payload) { // Can also request '/h' - - // payload -> 'world!' - }); + return client.request('hello'); }); diff --git a/types/nes/test/route-invocation-server.ts b/types/nes/test/route-invocation-server.ts index c32780baa9..d6893495c9 100644 --- a/types/nes/test/route-invocation-server.ts +++ b/types/nes/test/route-invocation-server.ts @@ -4,21 +4,20 @@ import Hapi = require('hapi'); import Nes = require('nes'); var server = new Hapi.Server(); -server.connection(); -server.register(Nes, function (err) { +server.register(Nes).then(() => { server.route({ method: 'GET', path: '/h', config: { id: 'hello', - handler: function (request, reply) { + handler: (request, h) => { - return reply('world!'); + return 'world!'; } } }); - server.start(function (err) { /* ... */ }); + return server.start(); }); diff --git a/types/nes/test/socket.ts b/types/nes/test/socket.ts index 7f7617d462..029dbb1d2f 100644 --- a/types/nes/test/socket.ts +++ b/types/nes/test/socket.ts @@ -4,13 +4,11 @@ import Nes = require('nes'); const socket: Nes.Socket = undefined; -const cb = () => { }; -socket.disconnect(cb); +socket.disconnect(); const s: string = socket.id; const o: Object = socket.app; const auth: Nes.SocketAuthObject = socket.auth; -const cb2 = (err?: any) => { }; -socket.send('message', (err?: any) => { }); -socket.publish('path', 'message', cb2); -socket.revoke('path', 'message', cb2); +socket.send('message'); +socket.publish('path', 'message'); +socket.revoke('path', 'message'); diff --git a/types/nes/test/subscription-filter-client.ts b/types/nes/test/subscription-filter-client.ts index 3f8d3ffb8b..05253539a4 100644 --- a/types/nes/test/subscription-filter-client.ts +++ b/types/nes/test/subscription-filter-client.ts @@ -6,15 +6,15 @@ var client = new Nes.Client('ws://localhost'); // Authenticate as 'john' -client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }, function (err) { +client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }).then(() => { - var handler: Nes.Handler = function (err, update) { + var handler: Nes.Handler = (update) => { // First publish is not received (filtered due to updater key) // update -> { id: 6, status: 'initial', updater: 'steve' } }; - client.subscribe('/items', handler, function (err) { }); + return client.subscribe('/items', handler); }); // Added in addition to nes doc example code @@ -25,13 +25,13 @@ var client = new NesClient('ws://localhost'); // Authenticate as 'john' -client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }, function (err) { +client.connect({ auth: { headers: { authorization: 'Basic am9objpzZWNyZXQ=' } } }).then(() => { - var handler: NesClient.Handler = function (err, update) { + var handler: NesClient.Handler = (update) => { // First publish is not received (filtered due to updater key) // update -> { id: 6, status: 'initial', updater: 'steve' } }; - client.subscribe('/items', handler, function (err) { }); + return client.subscribe('/items', handler); }); diff --git a/types/nes/test/subscription-filter-server.ts b/types/nes/test/subscription-filter-server.ts index be2dda8d7f..7a63abf151 100644 --- a/types/nes/test/subscription-filter-server.ts +++ b/types/nes/test/subscription-filter-server.ts @@ -6,9 +6,8 @@ import Bcrypt = require('bcrypt'); import Nes = require('nes'); var server = new Hapi.Server(); -server.connection(); -server.register([Basic, Nes], function (err) { +server.register([Basic, Nes]).then(() => { // Set up HTTP Basic authentication @@ -28,31 +27,31 @@ server.register([Basic, Nes], function (err) { } }; - var validate: Basic.ValidateFunc = function (request, username, password, callback) { + var validate: Basic.Validate = async (request, username, password, h) => { var user = users[username]; if (!user) { - return callback(null, false); + return { credentials: null, isValid: false }; } - Bcrypt.compare(password, user.password, function (err, isValid) { + let isValid = await Bcrypt.compare(password, user.password) - callback(err, isValid, { id: user.id, name: user.name, username: user.username }); - }); + return { isValid, credentials: { id: user.id, name: user.name, username: user.username } }; }; - server.auth.strategy('simple', 'basic', 'required', { validateFunc: validate }); + server.auth.strategy('simple', 'basic', { validate }); + server.auth.default('simple') // Set up subscription server.subscription('/items', { - filter: function (path, message, options, next) { + filter: (path, message, options) => { - return next(message.updater !== options.credentials.username); + return message.updater !== options.credentials.username; } }); - server.start(function (err) { + server.start().then(() => { server.publish('/items', { id: 5, status: 'complete', updater: 'john' }); server.publish('/items', { id: 6, status: 'initial', updater: 'steve' }); diff --git a/types/nes/test/subscriptions-client.ts b/types/nes/test/subscriptions-client.ts index a9ac55fc6d..9f6150f90c 100644 --- a/types/nes/test/subscriptions-client.ts +++ b/types/nes/test/subscriptions-client.ts @@ -3,15 +3,15 @@ import Nes = require('nes'); var client = new Nes.Client('ws://localhost'); -client.connect(function (err) { + client.connect().then(() => {; - var handler: Nes.Handler = function (update, flags) { + var handler: Nes.Handler = (update, flags) => { // update -> { id: 5, status: 'complete' } // Second publish is not received (doesn't match) }; - client.subscribe('/item/5', handler, function (err) { }); + return client.subscribe('/item/5', handler); }); // Added in addition to nes doc example code @@ -19,13 +19,13 @@ client.connect(function (err) { import NesClient = require('nes/client'); var client = new NesClient('ws://localhost'); -client.connect(function (err) { +client.connect().then(() => { - var handler: NesClient.Handler = function (update, flags) { + var handler: NesClient.Handler = (update, flags) => { // update -> { id: 5, status: 'complete' } // Second publish is not received (doesn't match) }; - client.subscribe('/item/5', handler, function (err) { }); + return client.subscribe('/item/5', handler); }); diff --git a/types/nes/test/subscriptions-server.ts b/types/nes/test/subscriptions-server.ts index 23212f21ea..1280f2afd1 100644 --- a/types/nes/test/subscriptions-server.ts +++ b/types/nes/test/subscriptions-server.ts @@ -4,15 +4,14 @@ import Hapi = require('hapi'); import Nes = require('nes'); var server = new Hapi.Server(); -server.connection(); -server.register(Nes, function (err) { +server.register(Nes).then(() =>{; server.subscription('/item/{id}'); - server.start(function (err) { + return server.start().then(() => { - server.publish('/item/5', { id: 5, status: 'complete' }); - server.publish('/item/6', { id: 6, status: 'initial' }); + server.publish('/item/5', {id: 5, status: 'complete'}); + server.publish('/item/6', {id: 6, status: 'initial'}); }); -}); +}) From e8e3c6a23bdff84aa488a3e0d1ca30a45267c137 Mon Sep 17 00:00:00 2001 From: Rodrigo Saboya Date: Sun, 26 Nov 2017 22:25:04 -0200 Subject: [PATCH 181/639] Updating type definitions for hapi-auth-basic >= 5.0.0. --- types/hapi-auth-basic/hapi-auth-basic-tests.ts | 15 ++++++++------- types/hapi-auth-basic/index.d.ts | 16 +++++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/types/hapi-auth-basic/hapi-auth-basic-tests.ts b/types/hapi-auth-basic/hapi-auth-basic-tests.ts index 7f78fe9f65..1a7192af6f 100644 --- a/types/hapi-auth-basic/hapi-auth-basic-tests.ts +++ b/types/hapi-auth-basic/hapi-auth-basic-tests.ts @@ -22,21 +22,22 @@ const users: {[index: string]: User} = { } }; -const validate: Basic.ValidateFunc = function (request, username, password, callback) { +const validate: Basic.Validate = async (request, username, password, h) => { const user = users[username]; if (!user) { - return callback(null, false); + return { isValid: false, credentials: null }; } - Bcrypt.compare(password, user.password, (err, isValid) => { + let isValid = await Bcrypt.compare(password, user.password) - callback(err, isValid, { id: user.id, name: user.name }); - }); + return { isValid, credentials: { id: user.id, name: user.name } }; }; -server.register(Basic, (err) => { +server.register(Basic).then(() => { + + server.auth.strategy('simple', 'basic', { validate }); + server.auth.default('simple'); - server.auth.strategy('simple', 'basic', { validateFunc: validate }); server.route({ method: 'GET', path: '/', config: { auth: 'simple' } }); }); diff --git a/types/hapi-auth-basic/index.d.ts b/types/hapi-auth-basic/index.d.ts index 54d463c2b3..ddf05c348a 100644 --- a/types/hapi-auth-basic/index.d.ts +++ b/types/hapi-auth-basic/index.d.ts @@ -1,18 +1,24 @@ -// Type definitions for hapi 4.2 +// Type definitions for hapi-bauth-basic 5.0.0 // Project: https://github.com/hapijs/hapi-auth-basic // Definitions by: AJP +// Rodrigo Saboya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 import * as Hapi from 'hapi'; declare namespace Basic { - interface ValidateFuncCallback { - (err: Error | null, isValid: boolean, userCredentials?: any): void; + interface ValidateCustomResponse { + response: any, } - interface ValidateFunc { - (request: Hapi.Request, username: string, password: string, callback: ValidateFuncCallback): void; + interface ValidateResponse { + isValid: boolean, + credentials?: any, + } + + interface Validate { + (request: Hapi.Request, username: string, password: string, h: object): Promise; } } From b0a69006ffae6cebe827913432d9b6ac9f5c691c Mon Sep 17 00:00:00 2001 From: Rico Kahler Date: Sun, 26 Nov 2017 20:14:20 -0500 Subject: [PATCH 182/639] Change `SketchDocument.currentPage` to a getter --- types/react-sketchapp/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-sketchapp/index.d.ts b/types/react-sketchapp/index.d.ts index f340e19232..ee7ad6de8d 100644 --- a/types/react-sketchapp/index.d.ts +++ b/types/react-sketchapp/index.d.ts @@ -31,7 +31,7 @@ export interface SketchDocument { documentData: () => SketchDocumentData; pages: () => SketchPage[]; addBlankPage: () => SketchPage; - currentPage: SketchPage; + currentPage: () => SketchPage; } export interface SketchContext { document: SketchDocument; } From a59ba0346c29f218506830163f250870ae84a1a9 Mon Sep 17 00:00:00 2001 From: Cameron Taggart Date: Sun, 26 Nov 2017 22:25:40 -0300 Subject: [PATCH 183/639] export http2 constants in standard way --- types/node/index.d.ts | 420 +++++++++++++++++++++--------------------- 1 file changed, 210 insertions(+), 210 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 0052b8256e..9707cafa78 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6704,216 +6704,216 @@ declare module "http2" { // Public API - export const constants: { - NGHTTP2_SESSION_SERVER: number; - NGHTTP2_SESSION_CLIENT: number; - NGHTTP2_STREAM_STATE_IDLE: number; - NGHTTP2_STREAM_STATE_OPEN: number; - NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number; - NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number; - NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number; - NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number; - NGHTTP2_STREAM_STATE_CLOSED: number; - NGHTTP2_NO_ERROR: number; - NGHTTP2_PROTOCOL_ERROR: number; - NGHTTP2_INTERNAL_ERROR: number; - NGHTTP2_FLOW_CONTROL_ERROR: number; - NGHTTP2_SETTINGS_TIMEOUT: number; - NGHTTP2_STREAM_CLOSED: number; - NGHTTP2_FRAME_SIZE_ERROR: number; - NGHTTP2_REFUSED_STREAM: number; - NGHTTP2_CANCEL: number; - NGHTTP2_COMPRESSION_ERROR: number; - NGHTTP2_CONNECT_ERROR: number; - NGHTTP2_ENHANCE_YOUR_CALM: number; - NGHTTP2_INADEQUATE_SECURITY: number; - NGHTTP2_HTTP_1_1_REQUIRED: number; - NGHTTP2_ERR_FRAME_SIZE_ERROR: number; - NGHTTP2_FLAG_NONE: number; - NGHTTP2_FLAG_END_STREAM: number; - NGHTTP2_FLAG_END_HEADERS: number; - NGHTTP2_FLAG_ACK: number; - NGHTTP2_FLAG_PADDED: number; - NGHTTP2_FLAG_PRIORITY: number; - DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number; - DEFAULT_SETTINGS_ENABLE_PUSH: number; - DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number; - DEFAULT_SETTINGS_MAX_FRAME_SIZE: number; - MAX_MAX_FRAME_SIZE: number; - MIN_MAX_FRAME_SIZE: number; - MAX_INITIAL_WINDOW_SIZE: number; - NGHTTP2_DEFAULT_WEIGHT: number; - NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number; - NGHTTP2_SETTINGS_ENABLE_PUSH: number; - NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number; - NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number; - NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number; - NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number; - PADDING_STRATEGY_NONE: number; - PADDING_STRATEGY_MAX: number; - PADDING_STRATEGY_CALLBACK: number; - HTTP2_HEADER_STATUS: string; - HTTP2_HEADER_METHOD: string; - HTTP2_HEADER_AUTHORITY: string; - HTTP2_HEADER_SCHEME: string; - HTTP2_HEADER_PATH: string; - HTTP2_HEADER_ACCEPT_CHARSET: string; - HTTP2_HEADER_ACCEPT_ENCODING: string; - HTTP2_HEADER_ACCEPT_LANGUAGE: string; - HTTP2_HEADER_ACCEPT_RANGES: string; - HTTP2_HEADER_ACCEPT: string; - HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string; - HTTP2_HEADER_AGE: string; - HTTP2_HEADER_ALLOW: string; - HTTP2_HEADER_AUTHORIZATION: string; - HTTP2_HEADER_CACHE_CONTROL: string; - HTTP2_HEADER_CONNECTION: string; - HTTP2_HEADER_CONTENT_DISPOSITION: string; - HTTP2_HEADER_CONTENT_ENCODING: string; - HTTP2_HEADER_CONTENT_LANGUAGE: string; - HTTP2_HEADER_CONTENT_LENGTH: string; - HTTP2_HEADER_CONTENT_LOCATION: string; - HTTP2_HEADER_CONTENT_MD5: string; - HTTP2_HEADER_CONTENT_RANGE: string; - HTTP2_HEADER_CONTENT_TYPE: string; - HTTP2_HEADER_COOKIE: string; - HTTP2_HEADER_DATE: string; - HTTP2_HEADER_ETAG: string; - HTTP2_HEADER_EXPECT: string; - HTTP2_HEADER_EXPIRES: string; - HTTP2_HEADER_FROM: string; - HTTP2_HEADER_HOST: string; - HTTP2_HEADER_IF_MATCH: string; - HTTP2_HEADER_IF_MODIFIED_SINCE: string; - HTTP2_HEADER_IF_NONE_MATCH: string; - HTTP2_HEADER_IF_RANGE: string; - HTTP2_HEADER_IF_UNMODIFIED_SINCE: string; - HTTP2_HEADER_LAST_MODIFIED: string; - HTTP2_HEADER_LINK: string; - HTTP2_HEADER_LOCATION: string; - HTTP2_HEADER_MAX_FORWARDS: string; - HTTP2_HEADER_PREFER: string; - HTTP2_HEADER_PROXY_AUTHENTICATE: string; - HTTP2_HEADER_PROXY_AUTHORIZATION: string; - HTTP2_HEADER_RANGE: string; - HTTP2_HEADER_REFERER: string; - HTTP2_HEADER_REFRESH: string; - HTTP2_HEADER_RETRY_AFTER: string; - HTTP2_HEADER_SERVER: string; - HTTP2_HEADER_SET_COOKIE: string; - HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string; - HTTP2_HEADER_TRANSFER_ENCODING: string; - HTTP2_HEADER_TE: string; - HTTP2_HEADER_UPGRADE: string; - HTTP2_HEADER_USER_AGENT: string; - HTTP2_HEADER_VARY: string; - HTTP2_HEADER_VIA: string; - HTTP2_HEADER_WWW_AUTHENTICATE: string; - HTTP2_HEADER_HTTP2_SETTINGS: string; - HTTP2_HEADER_KEEP_ALIVE: string; - HTTP2_HEADER_PROXY_CONNECTION: string; - HTTP2_METHOD_ACL: string; - HTTP2_METHOD_BASELINE_CONTROL: string; - HTTP2_METHOD_BIND: string; - HTTP2_METHOD_CHECKIN: string; - HTTP2_METHOD_CHECKOUT: string; - HTTP2_METHOD_CONNECT: string; - HTTP2_METHOD_COPY: string; - HTTP2_METHOD_DELETE: string; - HTTP2_METHOD_GET: string; - HTTP2_METHOD_HEAD: string; - HTTP2_METHOD_LABEL: string; - HTTP2_METHOD_LINK: string; - HTTP2_METHOD_LOCK: string; - HTTP2_METHOD_MERGE: string; - HTTP2_METHOD_MKACTIVITY: string; - HTTP2_METHOD_MKCALENDAR: string; - HTTP2_METHOD_MKCOL: string; - HTTP2_METHOD_MKREDIRECTREF: string; - HTTP2_METHOD_MKWORKSPACE: string; - HTTP2_METHOD_MOVE: string; - HTTP2_METHOD_OPTIONS: string; - HTTP2_METHOD_ORDERPATCH: string; - HTTP2_METHOD_PATCH: string; - HTTP2_METHOD_POST: string; - HTTP2_METHOD_PRI: string; - HTTP2_METHOD_PROPFIND: string; - HTTP2_METHOD_PROPPATCH: string; - HTTP2_METHOD_PUT: string; - HTTP2_METHOD_REBIND: string; - HTTP2_METHOD_REPORT: string; - HTTP2_METHOD_SEARCH: string; - HTTP2_METHOD_TRACE: string; - HTTP2_METHOD_UNBIND: string; - HTTP2_METHOD_UNCHECKOUT: string; - HTTP2_METHOD_UNLINK: string; - HTTP2_METHOD_UNLOCK: string; - HTTP2_METHOD_UPDATE: string; - HTTP2_METHOD_UPDATEREDIRECTREF: string; - HTTP2_METHOD_VERSION_CONTROL: string; - HTTP_STATUS_CONTINUE: number; - HTTP_STATUS_SWITCHING_PROTOCOLS: number; - HTTP_STATUS_PROCESSING: number; - HTTP_STATUS_OK: number; - HTTP_STATUS_CREATED: number; - HTTP_STATUS_ACCEPTED: number; - HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number; - HTTP_STATUS_NO_CONTENT: number; - HTTP_STATUS_RESET_CONTENT: number; - HTTP_STATUS_PARTIAL_CONTENT: number; - HTTP_STATUS_MULTI_STATUS: number; - HTTP_STATUS_ALREADY_REPORTED: number; - HTTP_STATUS_IM_USED: number; - HTTP_STATUS_MULTIPLE_CHOICES: number; - HTTP_STATUS_MOVED_PERMANENTLY: number; - HTTP_STATUS_FOUND: number; - HTTP_STATUS_SEE_OTHER: number; - HTTP_STATUS_NOT_MODIFIED: number; - HTTP_STATUS_USE_PROXY: number; - HTTP_STATUS_TEMPORARY_REDIRECT: number; - HTTP_STATUS_PERMANENT_REDIRECT: number; - HTTP_STATUS_BAD_REQUEST: number; - HTTP_STATUS_UNAUTHORIZED: number; - HTTP_STATUS_PAYMENT_REQUIRED: number; - HTTP_STATUS_FORBIDDEN: number; - HTTP_STATUS_NOT_FOUND: number; - HTTP_STATUS_METHOD_NOT_ALLOWED: number; - HTTP_STATUS_NOT_ACCEPTABLE: number; - HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number; - HTTP_STATUS_REQUEST_TIMEOUT: number; - HTTP_STATUS_CONFLICT: number; - HTTP_STATUS_GONE: number; - HTTP_STATUS_LENGTH_REQUIRED: number; - HTTP_STATUS_PRECONDITION_FAILED: number; - HTTP_STATUS_PAYLOAD_TOO_LARGE: number; - HTTP_STATUS_URI_TOO_LONG: number; - HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number; - HTTP_STATUS_RANGE_NOT_SATISFIABLE: number; - HTTP_STATUS_EXPECTATION_FAILED: number; - HTTP_STATUS_TEAPOT: number; - HTTP_STATUS_MISDIRECTED_REQUEST: number; - HTTP_STATUS_UNPROCESSABLE_ENTITY: number; - HTTP_STATUS_LOCKED: number; - HTTP_STATUS_FAILED_DEPENDENCY: number; - HTTP_STATUS_UNORDERED_COLLECTION: number; - HTTP_STATUS_UPGRADE_REQUIRED: number; - HTTP_STATUS_PRECONDITION_REQUIRED: number; - HTTP_STATUS_TOO_MANY_REQUESTS: number; - HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number; - HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number; - HTTP_STATUS_INTERNAL_SERVER_ERROR: number; - HTTP_STATUS_NOT_IMPLEMENTED: number; - HTTP_STATUS_BAD_GATEWAY: number; - HTTP_STATUS_SERVICE_UNAVAILABLE: number; - HTTP_STATUS_GATEWAY_TIMEOUT: number; - HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number; - HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number; - HTTP_STATUS_INSUFFICIENT_STORAGE: number; - HTTP_STATUS_LOOP_DETECTED: number; - HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number; - HTTP_STATUS_NOT_EXTENDED: number; - HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number; - }; + export namespace constants { + export const NGHTTP2_SESSION_SERVER: number; + export const NGHTTP2_SESSION_CLIENT: number; + export const NGHTTP2_STREAM_STATE_IDLE: number; + export const NGHTTP2_STREAM_STATE_OPEN: number; + export const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number; + export const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number; + export const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number; + export const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number; + export const NGHTTP2_STREAM_STATE_CLOSED: number; + export const NGHTTP2_NO_ERROR: number; + export const NGHTTP2_PROTOCOL_ERROR: number; + export const NGHTTP2_INTERNAL_ERROR: number; + export const NGHTTP2_FLOW_CONTROL_ERROR: number; + export const NGHTTP2_SETTINGS_TIMEOUT: number; + export const NGHTTP2_STREAM_CLOSED: number; + export const NGHTTP2_FRAME_SIZE_ERROR: number; + export const NGHTTP2_REFUSED_STREAM: number; + export const NGHTTP2_CANCEL: number; + export const NGHTTP2_COMPRESSION_ERROR: number; + export const NGHTTP2_CONNECT_ERROR: number; + export const NGHTTP2_ENHANCE_YOUR_CALM: number; + export const NGHTTP2_INADEQUATE_SECURITY: number; + export const NGHTTP2_HTTP_1_1_REQUIRED: number; + export const NGHTTP2_ERR_FRAME_SIZE_ERROR: number; + export const NGHTTP2_FLAG_NONE: number; + export const NGHTTP2_FLAG_END_STREAM: number; + export const NGHTTP2_FLAG_END_HEADERS: number; + export const NGHTTP2_FLAG_ACK: number; + export const NGHTTP2_FLAG_PADDED: number; + export const NGHTTP2_FLAG_PRIORITY: number; + export const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number; + export const DEFAULT_SETTINGS_ENABLE_PUSH: number; + export const DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number; + export const DEFAULT_SETTINGS_MAX_FRAME_SIZE: number; + export const MAX_MAX_FRAME_SIZE: number; + export const MIN_MAX_FRAME_SIZE: number; + export const MAX_INITIAL_WINDOW_SIZE: number; + export const NGHTTP2_DEFAULT_WEIGHT: number; + export const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number; + export const NGHTTP2_SETTINGS_ENABLE_PUSH: number; + export const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number; + export const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number; + export const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number; + export const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number; + export const PADDING_STRATEGY_NONE: number; + export const PADDING_STRATEGY_MAX: number; + export const PADDING_STRATEGY_CALLBACK: number; + export const HTTP2_HEADER_STATUS: string; + export const HTTP2_HEADER_METHOD: string; + export const HTTP2_HEADER_AUTHORITY: string; + export const HTTP2_HEADER_SCHEME: string; + export const HTTP2_HEADER_PATH: string; + export const HTTP2_HEADER_ACCEPT_CHARSET: string; + export const HTTP2_HEADER_ACCEPT_ENCODING: string; + export const HTTP2_HEADER_ACCEPT_LANGUAGE: string; + export const HTTP2_HEADER_ACCEPT_RANGES: string; + export const HTTP2_HEADER_ACCEPT: string; + export const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string; + export const HTTP2_HEADER_AGE: string; + export const HTTP2_HEADER_ALLOW: string; + export const HTTP2_HEADER_AUTHORIZATION: string; + export const HTTP2_HEADER_CACHE_CONTROL: string; + export const HTTP2_HEADER_CONNECTION: string; + export const HTTP2_HEADER_CONTENT_DISPOSITION: string; + export const HTTP2_HEADER_CONTENT_ENCODING: string; + export const HTTP2_HEADER_CONTENT_LANGUAGE: string; + export const HTTP2_HEADER_CONTENT_LENGTH: string; + export const HTTP2_HEADER_CONTENT_LOCATION: string; + export const HTTP2_HEADER_CONTENT_MD5: string; + export const HTTP2_HEADER_CONTENT_RANGE: string; + export const HTTP2_HEADER_CONTENT_TYPE: string; + export const HTTP2_HEADER_COOKIE: string; + export const HTTP2_HEADER_DATE: string; + export const HTTP2_HEADER_ETAG: string; + export const HTTP2_HEADER_EXPECT: string; + export const HTTP2_HEADER_EXPIRES: string; + export const HTTP2_HEADER_FROM: string; + export const HTTP2_HEADER_HOST: string; + export const HTTP2_HEADER_IF_MATCH: string; + export const HTTP2_HEADER_IF_MODIFIED_SINCE: string; + export const HTTP2_HEADER_IF_NONE_MATCH: string; + export const HTTP2_HEADER_IF_RANGE: string; + export const HTTP2_HEADER_IF_UNMODIFIED_SINCE: string; + export const HTTP2_HEADER_LAST_MODIFIED: string; + export const HTTP2_HEADER_LINK: string; + export const HTTP2_HEADER_LOCATION: string; + export const HTTP2_HEADER_MAX_FORWARDS: string; + export const HTTP2_HEADER_PREFER: string; + export const HTTP2_HEADER_PROXY_AUTHENTICATE: string; + export const HTTP2_HEADER_PROXY_AUTHORIZATION: string; + export const HTTP2_HEADER_RANGE: string; + export const HTTP2_HEADER_REFERER: string; + export const HTTP2_HEADER_REFRESH: string; + export const HTTP2_HEADER_RETRY_AFTER: string; + export const HTTP2_HEADER_SERVER: string; + export const HTTP2_HEADER_SET_COOKIE: string; + export const HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string; + export const HTTP2_HEADER_TRANSFER_ENCODING: string; + export const HTTP2_HEADER_TE: string; + export const HTTP2_HEADER_UPGRADE: string; + export const HTTP2_HEADER_USER_AGENT: string; + export const HTTP2_HEADER_VARY: string; + export const HTTP2_HEADER_VIA: string; + export const HTTP2_HEADER_WWW_AUTHENTICATE: string; + export const HTTP2_HEADER_HTTP2_SETTINGS: string; + export const HTTP2_HEADER_KEEP_ALIVE: string; + export const HTTP2_HEADER_PROXY_CONNECTION: string; + export const HTTP2_METHOD_ACL: string; + export const HTTP2_METHOD_BASELINE_CONTROL: string; + export const HTTP2_METHOD_BIND: string; + export const HTTP2_METHOD_CHECKIN: string; + export const HTTP2_METHOD_CHECKOUT: string; + export const HTTP2_METHOD_CONNECT: string; + export const HTTP2_METHOD_COPY: string; + export const HTTP2_METHOD_DELETE: string; + export const HTTP2_METHOD_GET: string; + export const HTTP2_METHOD_HEAD: string; + export const HTTP2_METHOD_LABEL: string; + export const HTTP2_METHOD_LINK: string; + export const HTTP2_METHOD_LOCK: string; + export const HTTP2_METHOD_MERGE: string; + export const HTTP2_METHOD_MKACTIVITY: string; + export const HTTP2_METHOD_MKCALENDAR: string; + export const HTTP2_METHOD_MKCOL: string; + export const HTTP2_METHOD_MKREDIRECTREF: string; + export const HTTP2_METHOD_MKWORKSPACE: string; + export const HTTP2_METHOD_MOVE: string; + export const HTTP2_METHOD_OPTIONS: string; + export const HTTP2_METHOD_ORDERPATCH: string; + export const HTTP2_METHOD_PATCH: string; + export const HTTP2_METHOD_POST: string; + export const HTTP2_METHOD_PRI: string; + export const HTTP2_METHOD_PROPFIND: string; + export const HTTP2_METHOD_PROPPATCH: string; + export const HTTP2_METHOD_PUT: string; + export const HTTP2_METHOD_REBIND: string; + export const HTTP2_METHOD_REPORT: string; + export const HTTP2_METHOD_SEARCH: string; + export const HTTP2_METHOD_TRACE: string; + export const HTTP2_METHOD_UNBIND: string; + export const HTTP2_METHOD_UNCHECKOUT: string; + export const HTTP2_METHOD_UNLINK: string; + export const HTTP2_METHOD_UNLOCK: string; + export const HTTP2_METHOD_UPDATE: string; + export const HTTP2_METHOD_UPDATEREDIRECTREF: string; + export const HTTP2_METHOD_VERSION_CONTROL: string; + export const HTTP_STATUS_CONTINUE: number; + export const HTTP_STATUS_SWITCHING_PROTOCOLS: number; + export const HTTP_STATUS_PROCESSING: number; + export const HTTP_STATUS_OK: number; + export const HTTP_STATUS_CREATED: number; + export const HTTP_STATUS_ACCEPTED: number; + export const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number; + export const HTTP_STATUS_NO_CONTENT: number; + export const HTTP_STATUS_RESET_CONTENT: number; + export const HTTP_STATUS_PARTIAL_CONTENT: number; + export const HTTP_STATUS_MULTI_STATUS: number; + export const HTTP_STATUS_ALREADY_REPORTED: number; + export const HTTP_STATUS_IM_USED: number; + export const HTTP_STATUS_MULTIPLE_CHOICES: number; + export const HTTP_STATUS_MOVED_PERMANENTLY: number; + export const HTTP_STATUS_FOUND: number; + export const HTTP_STATUS_SEE_OTHER: number; + export const HTTP_STATUS_NOT_MODIFIED: number; + export const HTTP_STATUS_USE_PROXY: number; + export const HTTP_STATUS_TEMPORARY_REDIRECT: number; + export const HTTP_STATUS_PERMANENT_REDIRECT: number; + export const HTTP_STATUS_BAD_REQUEST: number; + export const HTTP_STATUS_UNAUTHORIZED: number; + export const HTTP_STATUS_PAYMENT_REQUIRED: number; + export const HTTP_STATUS_FORBIDDEN: number; + export const HTTP_STATUS_NOT_FOUND: number; + export const HTTP_STATUS_METHOD_NOT_ALLOWED: number; + export const HTTP_STATUS_NOT_ACCEPTABLE: number; + export const HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number; + export const HTTP_STATUS_REQUEST_TIMEOUT: number; + export const HTTP_STATUS_CONFLICT: number; + export const HTTP_STATUS_GONE: number; + export const HTTP_STATUS_LENGTH_REQUIRED: number; + export const HTTP_STATUS_PRECONDITION_FAILED: number; + export const HTTP_STATUS_PAYLOAD_TOO_LARGE: number; + export const HTTP_STATUS_URI_TOO_LONG: number; + export const HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number; + export const HTTP_STATUS_RANGE_NOT_SATISFIABLE: number; + export const HTTP_STATUS_EXPECTATION_FAILED: number; + export const HTTP_STATUS_TEAPOT: number; + export const HTTP_STATUS_MISDIRECTED_REQUEST: number; + export const HTTP_STATUS_UNPROCESSABLE_ENTITY: number; + export const HTTP_STATUS_LOCKED: number; + export const HTTP_STATUS_FAILED_DEPENDENCY: number; + export const HTTP_STATUS_UNORDERED_COLLECTION: number; + export const HTTP_STATUS_UPGRADE_REQUIRED: number; + export const HTTP_STATUS_PRECONDITION_REQUIRED: number; + export const HTTP_STATUS_TOO_MANY_REQUESTS: number; + export const HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number; + export const HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number; + export const HTTP_STATUS_INTERNAL_SERVER_ERROR: number; + export const HTTP_STATUS_NOT_IMPLEMENTED: number; + export const HTTP_STATUS_BAD_GATEWAY: number; + export const HTTP_STATUS_SERVICE_UNAVAILABLE: number; + export const HTTP_STATUS_GATEWAY_TIMEOUT: number; + export const HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number; + export const HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number; + export const HTTP_STATUS_INSUFFICIENT_STORAGE: number; + export const HTTP_STATUS_LOOP_DETECTED: number; + export const HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number; + export const HTTP_STATUS_NOT_EXTENDED: number; + export const HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number; + } export function getDefaultSettings(): Settings; export function getPackedSettings(settings: Settings): Settings; From 21390eeb9a0eebdf1cfb4ad7473af3a267b006ad Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 27 Nov 2017 11:15:52 +0900 Subject: [PATCH 184/639] data is not absolutely necessary. https://github.com/mde/ejs/blob/v2.5.7/test/ejs.js#L58 --- types/ejs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index 9d1294e681..c395e54533 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -54,7 +54,7 @@ export function renderFile(path: string, data: Data, opts: Options, cb: Rende */ export function clearCache(): void; -export type TemplateFunction = (data: Data) => any; +export type TemplateFunction = (data?: Data) => string; export interface Options { /** Compiled functions are cached, requires `filename` */ cache?: boolean; From f29db221d658d323b9989638dacb12d8bab32592 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 27 Nov 2017 11:16:29 +0900 Subject: [PATCH 185/639] Add tests --- types/ejs/ejs-tests.ts | 47 +++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/types/ejs/ejs-tests.ts b/types/ejs/ejs-tests.ts index 89b0479529..a7b7b66944 100644 --- a/types/ejs/ejs-tests.ts +++ b/types/ejs/ejs-tests.ts @@ -1,15 +1,17 @@ +/// + import ejs = require("ejs"); +import { readFileSync as read } from 'fs'; import LRU = require("lru-cache"); -import { TemplateFunction } from "ejs"; +import { TemplateFunction, Options } from "ejs"; const fileName = 'test.ejs'; const people = ['geddy', 'neil', 'alex']; const data = { people }; const template = '<%= people.join(", "); %>'; -const options = {delimiter: '$'}; +const options = { filename: fileName }; let result: string; -let cacheResult: string; -let ejsFunction: ejs.TemplateFunction; +let ejsFunction: TemplateFunction; const SimpleCallback = (err: any, html?: string) => { if (err) { @@ -22,17 +24,38 @@ result = ejs.render(template); result = ejs.render(template, data); result = ejs.render(template, data, options); -cacheResult = ejs.renderFile(fileName, SimpleCallback); -cacheResult = ejs.renderFile(fileName, data, SimpleCallback); -cacheResult = ejs.renderFile(fileName, data, options, SimpleCallback); +result = ejs.renderFile(fileName, SimpleCallback); +result = ejs.renderFile(fileName, data, SimpleCallback); +result = ejs.renderFile(fileName, data, options, SimpleCallback); +ejsFunction = ejs.compile(''); +ejsFunction = ejs.compile(read(fileName, "utf8")); ejsFunction = ejs.compile(template); -ejsFunction({}); -ejsFunction(data); -ejs.compile(template, options); +ejsFunction = ejs.compile(template, options); +ejsFunction = ejs.compile(template, { cache: true, filename: fileName }); +ejsFunction = ejs.compile(template, { cache: true, filename: fileName, root: "./" }); +ejsFunction = ejs.compile(template, { context: { foo: 'FOO' } }); +ejsFunction = ejs.compile(template, { compileDebug: false }); +ejsFunction = ejs.compile(template, { client: true }); +ejsFunction = ejs.compile('<$= people.join(", "); $>', { delimiter: '$' }); +ejsFunction = ejs.compile('<%= locals.people.join(", "); %>', { _with: false }); +ejsFunction = ejs.compile('<%= locals.people.join(", "); %>', { strict: true }); +ejsFunction = ejs.compile('<%= it.people.join(", "); %>', { _with: false, localsName: "it" }); +ejsFunction = ejs.compile(template, { rmWhitespace: true }); +const customEscape = (str: string) => !str ? '' : str.toUpperCase(); +ejsFunction = ejs.compile(template, { escape: customEscape }); -ejs.fileLoader = (str: string) => str; +result = ejsFunction(); +result = ejsFunction({}); +result = ejsFunction(data); +/** @see https://github.com/mde/ejs/tree/v2.5.7#custom-fileloader */ +ejs.fileLoader = (path: string) => ""; + +/** @see https://github.com/mde/ejs/tree/v2.5.7#caching */ ejs.clearCache(); - ejs.cache = LRU(100); + +/** @see https://github.com/mde/ejs/tree/v2.5.7#custom-delimiters */ +ejs.delimiter = "%"; +delete ejs.delimiter; From a271488804f91c4eda641f2b6b1a7a2475d7d0dd Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 27 Nov 2017 11:22:27 +0900 Subject: [PATCH 186/639] version up --- types/ejs/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/ejs/index.d.ts b/types/ejs/index.d.ts index c395e54533..e785f2c6ae 100644 --- a/types/ejs/index.d.ts +++ b/types/ejs/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for ejs.js 2.3 +// Type definitions for ejs.js 2.5 // Project: http://ejs.co/ // Definitions by: Ben Liddicott // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.4 export interface Data { [name: string]: any; From ddf0d648dfb0a93bfeaf68134b925b9dc7cc4e08 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 27 Nov 2017 04:00:09 +0100 Subject: [PATCH 187/639] Fix klaw types klaw.Walker is an instance of Readable --- types/klaw/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/klaw/index.d.ts b/types/klaw/index.d.ts index 8134b728c0..c787179870 100644 --- a/types/klaw/index.d.ts +++ b/types/klaw/index.d.ts @@ -30,7 +30,7 @@ declare module "klaw" { type Event = "close" | "data" | "end" | "readable" | "error" - interface Walker { + interface Walker extends Readable { on(event: Event, listener: Function): this on(event: "close", listener: () => void): this on(event: "data", listener: (item: Item) => void): this From c74475e985a15b76ed063edf5bc8fb9677be2558 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Mon, 27 Nov 2017 04:07:19 +0100 Subject: [PATCH 188/639] Bump version number in klaw --- types/klaw/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/klaw/index.d.ts b/types/klaw/index.d.ts index c787179870..7b4e586842 100644 --- a/types/klaw/index.d.ts +++ b/types/klaw/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for klaw v2.1.0 +// Type definitions for klaw v2.1.1 // Project: https://github.com/jprichardson/node-klaw // Definitions by: Matthew McEachen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From b4187f1f44e1a51ba603870a1762fec861824508 Mon Sep 17 00:00:00 2001 From: yasupeke Date: Mon, 27 Nov 2017 17:56:01 +0900 Subject: [PATCH 189/639] =?UTF-8?q?Add=20=E2=80=98events=E2=80=99=20types?= =?UTF-8?q?=20(#21019)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/events/events-tests.ts | 53 ++++++++++++++++++++++++++++++++++++ types/events/index.d.ts | 22 +++++++++++++++ types/events/tsconfig.json | 25 +++++++++++++++++ types/events/tslint.json | 1 + 4 files changed, 101 insertions(+) create mode 100644 types/events/events-tests.ts create mode 100644 types/events/index.d.ts create mode 100644 types/events/tsconfig.json create mode 100644 types/events/tslint.json diff --git a/types/events/events-tests.ts b/types/events/events-tests.ts new file mode 100644 index 0000000000..fe62a6e1a3 --- /dev/null +++ b/types/events/events-tests.ts @@ -0,0 +1,53 @@ +import { EventEmitter } from 'events'; + +const emitter = new EventEmitter(); +const listener = () => { + console.log('once'); +}; +const listener1 = () => { + console.log('listener1'); +}; +const listener2 = () => { + console.log('listener2'); +}; +const listener3 = (arg1: string, arg2: string, arg3: number) => { + console.log('listener3'); +}; + +emitter.setMaxListeners(100); + +emitter.addListener('send', listener1); + +emitter.on('send', listener2); + +emitter.on('send', listener3); + +emitter.once('send', listener); + +emitter.listeners('send'); +emitter.listenerCount('send'); + +EventEmitter.defaultMaxListeners = 100; +console.log(`count(static): ${EventEmitter.listenerCount(emitter, 'send')}`); + +setTimeout(() => { + console.log(`\ncount: ${emitter.listenerCount('send')}`); + emitter.emit('send'); +}, 1000); + +setTimeout(() => { + console.log(`\ncount: ${emitter.listenerCount('send')}`); + emitter.emit('send'); + emitter.removeListener('send', listener2); +}, 2000); + +setTimeout(() => { + console.log(`\ncount: ${emitter.listenerCount('send')}`); + emitter.emit('send'); + emitter.removeAllListeners('send'); +}, 3000); + +setTimeout(() => { + console.log(`\ncount: ${emitter.listenerCount('send')}`); + emitter.emit('send'); +}, 3000); diff --git a/types/events/index.d.ts b/types/events/index.d.ts new file mode 100644 index 0000000000..6907d6f07e --- /dev/null +++ b/types/events/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for events 1.1 +// Project: https://github.com/Gozala/events +// Definitions by: Yasunori Ohoka +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export type Listener = (...args: any[]) => void; + +export class EventEmitter { + static listenerCount(emitter: EventEmitter, type: string): number; + static defaultMaxListeners: number; + + setMaxListeners(n: number): this; + emit(type: string, ...args: any[]): boolean; + addListener(type: string, listener: Listener): this; + on(type: string, listener: Listener): this; + once(type: string, listener: Listener): this; + removeListener(type: string, listener: Listener): this; + removeAllListeners(type: string): this; + listeners(type: string): Listener[]; + listenerCount(type: string): number; +} diff --git a/types/events/tsconfig.json b/types/events/tsconfig.json new file mode 100644 index 0000000000..f43a926ad8 --- /dev/null +++ b/types/events/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "events-tests.ts" + ] +} diff --git a/types/events/tslint.json b/types/events/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/events/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b4e2d2c3daf1d2ee360d0a5dd6eb88f02ce2c377 Mon Sep 17 00:00:00 2001 From: Bradley Odell Date: Mon, 27 Nov 2017 01:15:37 -0800 Subject: [PATCH 190/639] Added types for wheel --- types/wheel/index.d.ts | 25 +++++++++++++++++++++++++ types/wheel/tsconfig.json | 19 +++++++++++++++++++ types/wheel/tslint.json | 6 ++++++ types/wheel/wheel-tests.ts | 8 ++++++++ 4 files changed, 58 insertions(+) create mode 100644 types/wheel/index.d.ts create mode 100644 types/wheel/tsconfig.json create mode 100644 types/wheel/tslint.json create mode 100644 types/wheel/wheel-tests.ts diff --git a/types/wheel/index.d.ts b/types/wheel/index.d.ts new file mode 100644 index 0000000000..c3c23f361f --- /dev/null +++ b/types/wheel/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for wheel 0.0.5 +// Project: https://github.com/anvaka/wheel +// Definitions by: Bradley Odell +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Adds a callback to receive mouse wheel events from the given element. + */ +export default function addWheelListener(element: GlobalEventHandlers, + callback: (event: WheelEvent) => void, + useCapture?: boolean): void; + +/** + * Adds a callback to receive mouse wheel events from the given element. + */ +export function addWheelListener(element: GlobalEventHandlers, + callback: (event: WheelEvent) => void, + useCapture?: boolean): void; + +/** + * Removes a previously added wheel listener callback. + */ +export function removeWheelListener(element: GlobalEventHandlers, + callback: (event: WheelEvent) => void, + useCapture?: boolean): void; diff --git a/types/wheel/tsconfig.json b/types/wheel/tsconfig.json new file mode 100644 index 0000000000..5c9a5c4731 --- /dev/null +++ b/types/wheel/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es5", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "wheel-tests.ts" + ] +} \ No newline at end of file diff --git a/types/wheel/tslint.json b/types/wheel/tslint.json new file mode 100644 index 0000000000..65c83fb1e3 --- /dev/null +++ b/types/wheel/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false + } +} diff --git a/types/wheel/wheel-tests.ts b/types/wheel/wheel-tests.ts new file mode 100644 index 0000000000..8484408549 --- /dev/null +++ b/types/wheel/wheel-tests.ts @@ -0,0 +1,8 @@ +import {addWheelListener, removeWheelListener} from "wheel"; + +const wheelListener = (event: WheelEvent) => { + event.preventDefault(); + removeWheelListener(document, wheelListener); +}; + +addWheelListener(document, wheelListener); From 49c1c1c69ada73decb5a9fe0cb6f40e1779e9e25 Mon Sep 17 00:00:00 2001 From: yasupeke Date: Mon, 27 Nov 2017 18:17:39 +0900 Subject: [PATCH 191/639] [events]Fix parameter type --- types/events/events-tests.ts | 21 ++++++++++++++------- types/events/index.d.ts | 18 +++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/types/events/events-tests.ts b/types/events/events-tests.ts index fe62a6e1a3..ccf89c1402 100644 --- a/types/events/events-tests.ts +++ b/types/events/events-tests.ts @@ -10,8 +10,11 @@ const listener1 = () => { const listener2 = () => { console.log('listener2'); }; -const listener3 = (arg1: string, arg2: string, arg3: number) => { - console.log('listener3'); +const listener3 = (arg1: string) => { + console.log('listener3', arg1); +}; +const listener4 = () => { + console.log('type of number'); }; emitter.setMaxListeners(100); @@ -24,30 +27,34 @@ emitter.on('send', listener3); emitter.once('send', listener); +emitter.once(1, listener4); + emitter.listeners('send'); emitter.listenerCount('send'); EventEmitter.defaultMaxListeners = 100; console.log(`count(static): ${EventEmitter.listenerCount(emitter, 'send')}`); +console.log(`ncount: ${emitter.listenerCount('send')}`); setTimeout(() => { - console.log(`\ncount: ${emitter.listenerCount('send')}`); + console.log('\n'); emitter.emit('send'); }, 1000); setTimeout(() => { - console.log(`\ncount: ${emitter.listenerCount('send')}`); + console.log('\n'); emitter.emit('send'); emitter.removeListener('send', listener2); }, 2000); setTimeout(() => { - console.log(`\ncount: ${emitter.listenerCount('send')}`); - emitter.emit('send'); + console.log('\n'); + emitter.emit('send', 'params1'); emitter.removeAllListeners('send'); }, 3000); setTimeout(() => { - console.log(`\ncount: ${emitter.listenerCount('send')}`); + console.log('\n'); + emitter.emit(1); emitter.emit('send'); }, 3000); diff --git a/types/events/index.d.ts b/types/events/index.d.ts index 6907d6f07e..6214b5cf12 100644 --- a/types/events/index.d.ts +++ b/types/events/index.d.ts @@ -7,16 +7,16 @@ export type Listener = (...args: any[]) => void; export class EventEmitter { - static listenerCount(emitter: EventEmitter, type: string): number; + static listenerCount(emitter: EventEmitter, type: string | number): number; static defaultMaxListeners: number; setMaxListeners(n: number): this; - emit(type: string, ...args: any[]): boolean; - addListener(type: string, listener: Listener): this; - on(type: string, listener: Listener): this; - once(type: string, listener: Listener): this; - removeListener(type: string, listener: Listener): this; - removeAllListeners(type: string): this; - listeners(type: string): Listener[]; - listenerCount(type: string): number; + emit(type: string | number, ...args: any[]): boolean; + addListener(type: string | number, listener: Listener): this; + on(type: string | number, listener: Listener): this; + once(type: string | number, listener: Listener): this; + removeListener(type: string | number, listener: Listener): this; + removeAllListeners(type: string | number): this; + listeners(type: string | number): Listener[]; + listenerCount(type: string | number): number; } From 482932d07ddc267a4ed5fa57f7d078160cd2f067 Mon Sep 17 00:00:00 2001 From: Bradley Odell Date: Mon, 27 Nov 2017 01:47:23 -0800 Subject: [PATCH 192/639] Fixed 2 linting issues in test file. --- types/wheel/wheel-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/wheel/wheel-tests.ts b/types/wheel/wheel-tests.ts index 8484408549..9126bcf4b7 100644 --- a/types/wheel/wheel-tests.ts +++ b/types/wheel/wheel-tests.ts @@ -1,4 +1,4 @@ -import {addWheelListener, removeWheelListener} from "wheel"; +import { addWheelListener, removeWheelListener } from "wheel"; const wheelListener = (event: WheelEvent) => { event.preventDefault(); From 63c2ba94b2adb6ec908281f839f128c8229f65e8 Mon Sep 17 00:00:00 2001 From: yasupeke Date: Mon, 27 Nov 2017 19:06:02 +0900 Subject: [PATCH 193/639] [events]Deleted TypeScript Version --- types/events/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/events/index.d.ts b/types/events/index.d.ts index 6214b5cf12..85ce0a7b0e 100644 --- a/types/events/index.d.ts +++ b/types/events/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/Gozala/events // Definitions by: Yasunori Ohoka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 export type Listener = (...args: any[]) => void; From 32632d3d6b7cf713d84ec5f0ff4122c4902be589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Nor=C3=A9n?= Date: Mon, 27 Nov 2017 11:42:04 +0100 Subject: [PATCH 194/639] Update index.d.ts --- types/react-select/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-select/index.d.ts b/types/react-select/index.d.ts index 7ee2bbd810..7a2601a6c1 100644 --- a/types/react-select/index.d.ts +++ b/types/react-select/index.d.ts @@ -358,7 +358,7 @@ export interface ReactSelectProps extends React.Props; /** * function which returns a custom way to render the options in the menu */ @@ -423,7 +423,7 @@ export interface ReactSelectProps extends React.Props; /** * optional style to apply to the component wrapper From b7274857170a6bc986a1ada05e0ed8064f692dd5 Mon Sep 17 00:00:00 2001 From: Mike Woudenberg Date: Mon, 27 Nov 2017 10:55:21 +0100 Subject: [PATCH 195/639] Adds key to location method and adds timeout property to options --- types/cypress/cypress-tests.ts | 2 ++ types/cypress/index.d.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/cypress/cypress-tests.ts b/types/cypress/cypress-tests.ts index 806443474a..9502f1a63d 100644 --- a/types/cypress/cypress-tests.ts +++ b/types/cypress/cypress-tests.ts @@ -12,6 +12,8 @@ cy .get('.query-button') .contains('Save Form').should('have.class', 'btn'); +cy.location('host'); + cy .get('form') .find('input') diff --git a/types/cypress/index.d.ts b/types/cypress/index.d.ts index 808c765e24..f76aad4afb 100644 --- a/types/cypress/index.d.ts +++ b/types/cypress/index.d.ts @@ -249,7 +249,8 @@ declare namespace Cypress { /** * @see https://on.cypress.io/api/location */ - location(options?: Loggable): Chainable; + location(options?: LoggableTimeoutable): Chainable; + location(key: string, options?: LoggableTimeoutable): Chainable; /** * @see https://on.cypress.io/api/log From c600791d9c1123aa10c4dcaa83df8df85187692c Mon Sep 17 00:00:00 2001 From: Adam Webb Date: Mon, 27 Nov 2017 15:36:18 +0000 Subject: [PATCH 196/639] Add react-image-gallery types for React Image Gallery --- types/react-image-gallery/index.d.ts | 84 +++++++++++++++++++ .../react-image-gallery-tests.tsx | 19 +++++ types/react-image-gallery/tsconfig.json | 24 ++++++ types/react-image-gallery/tslint.json | 1 + 4 files changed, 128 insertions(+) create mode 100644 types/react-image-gallery/index.d.ts create mode 100644 types/react-image-gallery/react-image-gallery-tests.tsx create mode 100644 types/react-image-gallery/tsconfig.json create mode 100644 types/react-image-gallery/tslint.json diff --git a/types/react-image-gallery/index.d.ts b/types/react-image-gallery/index.d.ts new file mode 100644 index 0000000000..8e2e166266 --- /dev/null +++ b/types/react-image-gallery/index.d.ts @@ -0,0 +1,84 @@ +// Type definitions for react-image-gallery 0.8 +// Project: https://github.com/xiaolin/react-image-gallery +// Definitions by: Adam Webb +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from 'react'; + +export interface ReactImageGalleryItem { + original?: string; + thumbnail?: string; + originalClass?: string; + thumbnailClass?: string; + renderItem?(item?: ReactImageGalleryItem): React.ReactNode; + renderThumbInner?(item?: ReactImageGalleryItem): React.ReactNode; + originalAlt?: string; + thumbnailAlt?: string; + originalTitle?: string; + thumbnailTitle?: string; + thumbnailLabel?: string; + description?: string; + srcSet?: string; + sizes?: string; +} + +export interface ReactImageGalleryProps { + items: Array; + infinite?: boolean; + lazyLoad?: boolean; + showNav?: boolean; + showThumbnails?: boolean; + thumbnailPosition?: 'top' | 'right' | 'bottom' | 'left'; + showFullscreenButton?: boolean; + useBrowserFullscreen?: boolean; + showPlayButton?: boolean; + showBullets?: boolean; + showIndex?: boolean; + autoPlay?: boolean; + disableThumbnailScroll?: boolean; + slideOnThumbnailHover?: boolean; + disableArrowKeys?: boolean; + disableSwipe?: boolean; + defaultImage?: string; + indexSeparator?: string; + slideDuration?: number; + swipingTransitionDuration?: number; + slideInterval?: number; + flickThreshold?: number; + swipeThreshold?: number; + stopPropagation?: boolean; + preventDefaultTouchmoveEvent?: boolean; + startIndex?: number; + onImageError?: (event: React.ReactEventHandler) => void; + onThumbnailError?: (event: React.ReactEventHandler) => void; + onThumbnailClick?: (event: React.MouseEventHandler, index: number) => void; + onImageLoad?: (event: React.ReactEventHandler) => void; + onSlide?: (currentIndex: number) => void; + onScreenChange?: (fullScreenElement: Element) => void; + onPause?: (currentIndex: number) => void; + onPlay?: (currentIndex: number) => void; + onClick?: (event: React.MouseEventHandler) => void; + onTouchMove?: (event: React.TouchEventHandler) => void; + onTouchEnd?: (event: React.TouchEventHandler) => void; + onTouchStart?: (event: React.TouchEventHandler) => void; + onMouseOver?: (event: React.MouseEventHandler) => void; + onMouseLeave?: (event: React.MouseEventHandler) => void; + renderCustomControls?: () => React.ReactNode; + renderItem?: (item: ReactImageGalleryItem) => React.ReactNode; + renderThumbInner?: (item: ReactImageGalleryItem) => React.ReactNode; + renderLeftNav?: (onClick: React.MouseEventHandler, isDisabled: boolean) => React.ReactNode; + renderRightNav?: (onClick: React.MouseEventHandler, isDisabled: boolean) => React.ReactNode; + renderPlayPauseButton?: (onClick: React.MouseEventHandler, isPlaying: boolean) => React.ReactNode; + renderFullscreenButton?: (onClick: React.MouseEventHandler, isFullscreen: boolean) => React.ReactNode; +} + +declare class ReactImageGallery extends React.Component { + play: (callback?: boolean) => void; + pause: (callback?: boolean) => void; + fullScreen: () => void; + exitFullScreen: () => void; + slideToIndex: (index: number) => void; + getCurrentIndex: () => void; +} + +export default ReactImageGallery; \ No newline at end of file diff --git a/types/react-image-gallery/react-image-gallery-tests.tsx b/types/react-image-gallery/react-image-gallery-tests.tsx new file mode 100644 index 0000000000..65fedd7828 --- /dev/null +++ b/types/react-image-gallery/react-image-gallery-tests.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +import ReactImageGallery, { ReactImageGalleryItem, ReactImageGalleryProps } from 'react-image-gallery'; + +class ImageGallery extends React.Component { + render() { + const galleryItem: ReactImageGalleryItem = { + original: 'http://localhost/logo.jpg', + originalTitle: 'My Logo' + }; + + const props: ReactImageGalleryProps = { + items: [galleryItem], + autoPlay: false, + showFullscreenButton: false + }; + + return ; + } +} diff --git a/types/react-image-gallery/tsconfig.json b/types/react-image-gallery/tsconfig.json new file mode 100644 index 0000000000..9970170355 --- /dev/null +++ b/types/react-image-gallery/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-image-gallery-tests.tsx" + ] +} diff --git a/types/react-image-gallery/tslint.json b/types/react-image-gallery/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-image-gallery/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e8bfd5adc5236de11c19ffe14b6d90ca3ed4ae71 Mon Sep 17 00:00:00 2001 From: Adam Webb Date: Mon, 27 Nov 2017 15:47:43 +0000 Subject: [PATCH 197/639] Fixed linter errors --- types/react-image-gallery/index.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types/react-image-gallery/index.d.ts b/types/react-image-gallery/index.d.ts index 8e2e166266..479b743e21 100644 --- a/types/react-image-gallery/index.d.ts +++ b/types/react-image-gallery/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/xiaolin/react-image-gallery // Definitions by: Adam Webb // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as React from 'react'; @@ -23,7 +24,7 @@ export interface ReactImageGalleryItem { } export interface ReactImageGalleryProps { - items: Array; + items: ReactImageGalleryItem[]; infinite?: boolean; lazyLoad?: boolean; showNav?: boolean; @@ -69,7 +70,7 @@ export interface ReactImageGalleryProps { renderLeftNav?: (onClick: React.MouseEventHandler, isDisabled: boolean) => React.ReactNode; renderRightNav?: (onClick: React.MouseEventHandler, isDisabled: boolean) => React.ReactNode; renderPlayPauseButton?: (onClick: React.MouseEventHandler, isPlaying: boolean) => React.ReactNode; - renderFullscreenButton?: (onClick: React.MouseEventHandler, isFullscreen: boolean) => React.ReactNode; + renderFullscreenButton?: (onClick: React.MouseEventHandler, isFullscreen: boolean) => React.ReactNode; } declare class ReactImageGallery extends React.Component { @@ -81,4 +82,4 @@ declare class ReactImageGallery extends React.Component getCurrentIndex: () => void; } -export default ReactImageGallery; \ No newline at end of file +export default ReactImageGallery; From 8f7314235d5f010e90722a25b0460779c85901f7 Mon Sep 17 00:00:00 2001 From: Robert Prib Date: Mon, 27 Nov 2017 16:35:44 +0000 Subject: [PATCH 198/639] * Added function overrides for constructing LayerGroup to allow options object to be passed through and for layers to be optional. * Updated MarkerClusterGroupOptions to extend LayerOptions to ensure LayerOptions can be set for Leaflet.MarkerCluster. --- types/leaflet.markercluster/index.d.ts | 2 +- types/leaflet/index.d.ts | 10 ++++++++-- types/leaflet/leaflet-tests.ts | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/types/leaflet.markercluster/index.d.ts b/types/leaflet.markercluster/index.d.ts index f60a7a2891..e2f317dd46 100644 --- a/types/leaflet.markercluster/index.d.ts +++ b/types/leaflet.markercluster/index.d.ts @@ -29,7 +29,7 @@ declare module 'leaflet' { getBounds(): LatLngBounds; } - interface MarkerClusterGroupOptions { + interface MarkerClusterGroupOptions extends LayerOptions { /* * When you mouse over a cluster it shows the bounds of its markers. */ diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index b1e7ead796..ba4082150f 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -668,6 +668,10 @@ export function canvas(options?: RendererOptions): Canvas; */ export class LayerGroup

extends Layer { constructor(layers?: Layer[]); + constructor(layers: Layer[], options?: LayerOptions); + initialize(layers?: Layer[]): this; + initialize(layers: Layer[], options?: LayerOptions): this; + /** * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint). */ @@ -728,10 +732,12 @@ export class LayerGroup

extends Layer { feature?: geojson.FeatureCollection | geojson.Feature | geojson.GeometryCollection; } +// @factory L.layerGroup(layers?: Layer[], options?: Object) /** - * Create a layer group, optionally given an initial set of layers. + * Create a layer group, optionally given an initial set of layers and an `options` object. */ -export function layerGroup(layers: Layer[]): LayerGroup; +export function layerGroup(layers?: Layer[]): LayerGroup; +export function layerGroup(layers: Layer[], options?: LayerOptions): LayerGroup; /** * Extended LayerGroup that also has mouse events (propagated from diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index fc84a78267..a39ea761b1 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -496,3 +496,17 @@ interface MyProperties { iconUrl: 'my-icon.png' }) }) as L.Marker).feature.properties.testProperty = "test"; + +let lg = L.layerGroup(); +lg = L.layerGroup([new L.Layer(), new L.Layer()]); +lg = L.layerGroup([new L.Layer(), new L.Layer()], { + pane: 'overlayPane', + attribution: 'test' +}); + +lg = new L.LayerGroup(); +lg = new L.LayerGroup([new L.Layer(), new L.Layer()]); +lg = new L.LayerGroup([new L.Layer(), new L.Layer()], { + pane: 'overlayPane', + attribution: 'test' +}); From b001d41707555b739b3c857ebc588fb2b3e3ca3d Mon Sep 17 00:00:00 2001 From: Robert Prib Date: Mon, 27 Nov 2017 17:05:36 +0000 Subject: [PATCH 199/639] Fixed dtslint errors cause by using tslint:disable --- types/leaflet/index.d.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index ba4082150f..3b07cee500 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -241,20 +241,20 @@ export abstract class Evented extends Class { */ on(eventMap: LeafletEventHandlerFnMap): this; - /* tslint:disable:unified-signatures */ // With an eventMap there are no additional arguments allowed /** * Removes a previously added listener function. If no function is specified, * it will remove all the listeners of that particular event from the object. * Note that if you passed a custom context to on, you must pass the same context * to off in order to remove the listener. */ + // tslint:disable-next-line off(type: string, fn?: LeafletEventHandlerFn, context?: any): this; /** * Removes a set of type/listener pairs. */ + // tslint:disable-next-line off(eventMap: LeafletEventHandlerFnMap): this; - /* tslint:enable */ /** * Removes all listeners to all events on the object. */ @@ -668,8 +668,10 @@ export function canvas(options?: RendererOptions): Canvas; */ export class LayerGroup

extends Layer { constructor(layers?: Layer[]); + // tslint:disable-next-line constructor(layers: Layer[], options?: LayerOptions); initialize(layers?: Layer[]): this; + // tslint:disable-next-line initialize(layers: Layer[], options?: LayerOptions): this; /** @@ -737,6 +739,7 @@ export class LayerGroup

extends Layer { * Create a layer group, optionally given an initial set of layers and an `options` object. */ export function layerGroup(layers?: Layer[]): LayerGroup; +// tslint:disable-next-line export function layerGroup(layers: Layer[], options?: LayerOptions): LayerGroup; /** @@ -1134,9 +1137,9 @@ export interface PanOptions { noMoveStart?: boolean; } -/* tslint:disable:no-empty-interface */ // This is not empty, it extends two interfaces into one... +// This is not empty, it extends two interfaces into one... +// tslint:disable-next-line export interface ZoomPanOptions extends ZoomOptions, PanOptions {} -/* tslint:enable */ export interface FitBoundsOptions extends ZoomOptions, PanOptions { paddingTopLeft?: PointExpression; From 71c545cfd5477b64a9f85dd178b808666ddf5c20 Mon Sep 17 00:00:00 2001 From: Orta Date: Mon, 27 Nov 2017 16:10:30 -0500 Subject: [PATCH 200/639] Update definition.d.ts --- types/graphql/type/definition.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 7f84c875fb..52df7bd46c 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -455,6 +455,7 @@ export class GraphQLEnumType { constructor(config: GraphQLEnumTypeConfig); getValues(): GraphQLEnumValue[]; getValue(name: string): GraphQLEnumValue; + isValidValue(value: any): boolean; serialize(value: any): string; parseValue(value: any): any; parseLiteral(valueNode: ValueNode): any; From c4db7383b82fc6e44ce71b46d695543b3a6e62df Mon Sep 17 00:00:00 2001 From: CaselIT Date: Mon, 27 Nov 2017 22:33:05 +0100 Subject: [PATCH 201/639] Updated dbref and exported from mongodb. https://github.com/DefinitelyTyped/DefinitelyTyped/issues/21717 --- types/bson/index.d.ts | 3 +++ types/mongodb/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/bson/index.d.ts b/types/bson/index.d.ts index 2b6a636e89..5197d30d88 100644 --- a/types/bson/index.d.ts +++ b/types/bson/index.d.ts @@ -55,6 +55,9 @@ export class Code { } export class DBRef { constructor(namespace: string, oid: ObjectID, db?: string); + namespace: string; + oid: ObjectID; + db?: string; } export class Double { constructor(value: number); diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 32bc523d38..fbbc318a33 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -22,7 +22,7 @@ export function connect(uri: string, options?: MongoClientOptions): Promise; export function connect(uri: string, callback: MongoCallback): void; export function connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; -export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from 'bson'; +export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, ObjectId, Timestamp, DBRef } from 'bson'; // Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html export class MongoClient { From 1b63e441fbdf437974011302a337980cc0c4fcd6 Mon Sep 17 00:00:00 2001 From: Alvin Chan Date: Mon, 27 Nov 2017 18:05:32 -0800 Subject: [PATCH 202/639] Export Option and Observer interfaces for the Lozad package --- types/lozad/index.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/types/lozad/index.d.ts b/types/lozad/index.d.ts index eb0213f6c3..6257c47043 100644 --- a/types/lozad/index.d.ts +++ b/types/lozad/index.d.ts @@ -1,25 +1,25 @@ -// Type definitions for lozad 1.0 +// Type definitions for lozad 1.1 // Project: https://github.com/ApoorvSaxena/lozad.js // Definitions by: York Yao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface Option { - rootMargin?: string; - threshold?: number; - load?(element: HTMLElement | HTMLCanvasElement): void; -} - -interface Observer { - observe(): void; -} - -declare function lozad(selector?: string, options?: Option): Observer; - declare namespace lozad { + interface Option { + rootMargin?: string; + threshold?: number; + load?(element: HTMLElement | HTMLCanvasElement): void; + } + + interface Observer { + observe(): void; + } + const prototype: { }; } +declare function lozad(selector?: string, options?: lozad.Option): lozad.Observer; + export as namespace lozad; export = lozad; From 669c61e559d099e4fda6020b8ecd5ebfb1c71583 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 27 Nov 2017 23:17:37 -0400 Subject: [PATCH 203/639] [rn-modalbox] Added keyboardTopOffset --- types/react-native-modalbox/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/react-native-modalbox/index.d.ts b/types/react-native-modalbox/index.d.ts index 07ddebca2b..457872889b 100644 --- a/types/react-native-modalbox/index.d.ts +++ b/types/react-native-modalbox/index.d.ts @@ -135,6 +135,13 @@ export interface ModalProps extends ViewProperties { */ startOpen?: boolean; + /** + * This property prevent the modal to cover the ios status bar when the modal is scrolling up because the keyboard is opening + * + * Default is ios:22, android:0 + */ + keyboardTopOffset?: number; + /** * Event fired when the modal is closed and the animation is complete * From f0724c38bb468a2e2bb30f5f06042c7786ae20ff Mon Sep 17 00:00:00 2001 From: niris Date: Tue, 28 Nov 2017 12:30:16 +0800 Subject: [PATCH 204/639] puppeteer: fix mouse.click typing --- types/puppeteer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index 8138419b6a..ee88557e15 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -58,7 +58,7 @@ export interface Mouse { * @param y The y position. * @param options The click options. */ - click(x: number, y: number, options: ClickOptions): Promise; + click(x: number, y: number, options?: ClickOptions): Promise; /** * Dispatches a `mousedown` event. * @param options The mouse press options. From 55281420175588eb879a8f9d1364289a61204ebf Mon Sep 17 00:00:00 2001 From: Bradley Odell Date: Mon, 27 Nov 2017 21:37:38 -0800 Subject: [PATCH 205/639] Fixed issues brought up by code reviewers. --- types/wheel/index.d.ts | 2 +- types/wheel/tsconfig.json | 2 +- types/wheel/tslint.json | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/types/wheel/index.d.ts b/types/wheel/index.d.ts index c3c23f361f..c7214ee604 100644 --- a/types/wheel/index.d.ts +++ b/types/wheel/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for wheel 0.0.5 +// Type definitions for wheel 0.0 // Project: https://github.com/anvaka/wheel // Definitions by: Bradley Odell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/wheel/tsconfig.json b/types/wheel/tsconfig.json index 5c9a5c4731..2857ce81c3 100644 --- a/types/wheel/tsconfig.json +++ b/types/wheel/tsconfig.json @@ -16,4 +16,4 @@ "index.d.ts", "wheel-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/wheel/tslint.json b/types/wheel/tslint.json index 65c83fb1e3..f93cf8562a 100644 --- a/types/wheel/tslint.json +++ b/types/wheel/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "dt-header": false - } + "extends": "dtslint/dt.json" } From a68c0ddec45bd18a129f139cfe7a2f28985d44f7 Mon Sep 17 00:00:00 2001 From: Matthias Jobst Date: Tue, 28 Nov 2017 11:21:23 +0100 Subject: [PATCH 206/639] Updated dc for my project that uses composite charts and certain features of color charts To update a project from javascript to typescript I hit a few issues with Composite charts and color charts that I could only fix by editing the types definitions. I added links to the documentation that I used to determine the types that are required. dc.version was added which is documented in the source code. --- types/dc/index.d.ts | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/types/dc/index.d.ts b/types/dc/index.d.ts index 7d893baf3e..62fbd8330c 100644 --- a/types/dc/index.d.ts +++ b/types/dc/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for DCJS // Project: https://github.com/dc-js/dc.js -// Definitions by: hans windhoff , matt traynham +// Definitions by: hans windhoff +// matt traynham +// matthias jobst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files @@ -49,8 +51,9 @@ declare namespace dc { format: Accessor; } + // http://dc-js.github.io/dc.js/docs/html/dc.units.html export interface UnitFunction { - (start: number, end: number, domain?: Array): number|Array; + (start: number|Date, end: number|Date, domain?: number|Array): number | Array; } export interface FloatPointUnits { @@ -135,12 +138,13 @@ declare namespace dc { minHeight: IGetSet; dimension: IGetSet; data: IGetSetComputed<(group: any) => Array, Array, T>; - group: IGetSet; + // http://dc-js.github.io/dc.js/docs/html/dc.baseMixin.html#group__anchor + group: IBiGetSet; ordering: IGetSet, T>; filterAll(): void; - select(selector: d3.Selection|string): d3.Selection; - selectAll(selector: d3.Selection|string): d3.Selection; - anchor(anchor: BaseMixin|d3.Selection|string, chartGroup?: string): d3.Selection; + select(selector: d3.Selection | string): d3.Selection; + selectAll(selector: d3.Selection | string): d3.Selection; + anchor(anchor: BaseMixin | d3.Selection | string, chartGroup?: string): d3.Selection; anchorName(): string; svg: IGetSet, d3.Selection>; resetSvg(): void; @@ -196,10 +200,11 @@ declare namespace dc { } export interface ColorMixin { - colors: IGetSet | Scale, T>; - ordinalColors(r: Array): void; - linearColors(r: Array): void; - colorAccessor: IGetSet, T>; + // http://dc-js.github.io/dc.js/docs/html/dc.colorMixin.html + colors: IGetSet | Scale | string, T>; + ordinalColors(r: Array): T; + linearColors(r: Array): T; + colorAccessor: IGetSet, T>; colorDomain: IGetSet, T>; calculateColorDomain(): void; getColor(datum: any, index?: number): string; @@ -291,7 +296,7 @@ declare namespace dc { dashStyle: IGetSet, LineChart>; renderArea: IGetSet; dotRadius: IGetSet; - renderDataPoints: IGetSet; + renderDataPoints: IGetSet; } export interface DataCountWidgetHTML { @@ -307,7 +312,7 @@ declare namespace dc { export interface DataTableWidget extends BaseMixin { size: IGetSet; showGroups: IGetSet; - columns: IGetSet|Columns>, DataTableWidget>; + columns: IGetSet | Columns>, DataTableWidget>; sortBy: IGetSet, DataTableWidget>; order: IGetSet<(a: any, b: any) => number, DataTableWidget>; } @@ -336,7 +341,7 @@ declare namespace dc { rightYAxis: IGetSet>; } - export interface CompositeChart extends ICompositeChart {} + export interface CompositeChart extends ICompositeChart { } export interface SeriesChart extends ICompositeChart { chart: IGetSet<(c: any) => BaseMixin, SeriesChart>; @@ -444,11 +449,16 @@ declare namespace dc { round: Round; utils: Utils; + // http://dc-js.github.io/dc.js/docs/html/core.js.html, Line 20 + version: string; + legend(): Legend; pieChart(parent: string, chartGroup?: string): PieChart; - barChart(parent: string, chartGroup?: string): BarChart; - lineChart(parent: string, chartGroup?: string): LineChart; + // http://dc-js.github.io/dc.js/docs/html/dc.barChart.html + barChart(parent: string | CompositeChart, chartGroup?: string): BarChart; + // http://dc-js.github.io/dc.js/docs/html/dc.lineChart.html + lineChart(parent: string | CompositeChart, chartGroup?: string): LineChart; dataCount(parent: string, chartGroup?: string): DataCountWidget; dataTable(parent: string, chartGroup?: string): DataTableWidget; dataGrid(parent: string, chartGroup?: string): DataGridWidget; @@ -463,5 +473,4 @@ declare namespace dc { heatMap(parent: string, chartGroup?: string): HeatMap; boxPlot(parent: string, chartGroup?: string): BoxPlot; } -} - +} \ No newline at end of file From 611b5939d1b8221953dd31042ca7605dc089097d Mon Sep 17 00:00:00 2001 From: Raul Tomescu Date: Tue, 28 Nov 2017 11:40:06 +0100 Subject: [PATCH 207/639] Added name to SelectFieldProps --- types/material-ui/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index 22b5d1711f..5ae63560cc 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -1440,6 +1440,7 @@ declare namespace __MaterialUI { hintText?: React.ReactNode; iconStyle?: React.CSSProperties; id?: string; + name?: string; labelStyle?: React.CSSProperties; multiple?: boolean; onBlur?: React.FocusEventHandler<{}>; From 0f27ff20f9234fe086e3b98be330020b69dd1010 Mon Sep 17 00:00:00 2001 From: Romke van der Meulen Date: Tue, 28 Nov 2017 11:49:17 +0100 Subject: [PATCH 208/639] [cucumber] fix redundant return types --- types/cucumber/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/cucumber/index.d.ts b/types/cucumber/index.d.ts index 5d406ffeaa..ce2f586d9b 100644 --- a/types/cucumber/index.d.ts +++ b/types/cucumber/index.d.ts @@ -23,7 +23,7 @@ export interface TableDefinition { hashes(): Array<{ [colName: string]: string }>; } -export type StepDefinitionCode = (this: World, ...stepArgs: any[]) => PromiseLike | any | void; +export type StepDefinitionCode = (this: World, ...stepArgs: any[]) => any; export interface StepDefinitionOptions { timeout?: number; From 605da7672cf74786d61e03e59af38d6b3313720b Mon Sep 17 00:00:00 2001 From: Alec Winograd Date: Tue, 28 Nov 2017 11:50:22 +0100 Subject: [PATCH 209/639] Add initialLayout property to TabNavigator in react-navigation --- types/react-navigation/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index edf5cbc915..de1e220d7c 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -592,7 +592,9 @@ export interface TabViewConfig { } // From navigators/TabNavigator.js -export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig { } +export interface TabNavigatorConfig extends NavigationTabRouterConfig, TabViewConfig { + initialLayout?: { height: number, width: number }; +} // From navigators/TabNavigator.js export function TabNavigator( From d25f6d0f41d8e96cb269675c8a2b6df5bcd87900 Mon Sep 17 00:00:00 2001 From: Alec Winograd Date: Tue, 28 Nov 2017 11:53:41 +0100 Subject: [PATCH 210/639] update tests --- types/react-navigation/react-navigation-tests.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index e8573bac89..619c07c545 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -146,6 +146,11 @@ const tabNavigatorConfig: TabNavigatorConfig = { tabBarOptions: { activeBackgroundColor: "blue" }, }; +const tabNavigatorConfigWithInitialLayout: TabNavigatorConfig = { + ...tabNavigatorConfig, + initialLayout: { height: 0, width: 100 }, +}; + const BasicTabNavigator = TabNavigator( routeConfigMap, tabNavigatorConfig, From 7e822192e5e8e91c4602815ab23f1af63c0aaa9f Mon Sep 17 00:00:00 2001 From: Matthias Jobst Date: Tue, 28 Nov 2017 12:05:04 +0100 Subject: [PATCH 211/639] D3 V3: Update to insert and force charts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added optionality to parameter in insert Added number as initial value in Link Added Date as allowed return für brushing on Date charts Extended Primitive --- types/d3/v3/index.d.ts | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/types/d3/v3/index.d.ts b/types/d3/v3/index.d.ts index 0fbc7502b0..fabb96be43 100644 --- a/types/d3/v3/index.d.ts +++ b/types/d3/v3/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for d3JS 3.5 // Project: http://d3js.org/ -// Definitions by: Alex Ford , Boris Yankov +// Definitions by: Alex Ford +// Boris Yankov +// Matthias Jobst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Latest patch version of module validated against: 3.5.17 @@ -233,28 +235,30 @@ declare namespace d3 { * @param name the element name to append. May be prefixed (see d3.ns.prefix). * @param before the selector to determine position (e.g., ":first-child") */ - insert(name: string, before: string): Update; + // https://github.com/d3/d3-3.x-api-reference/blob/master/Selections.md#insert + insert(name: string, before?: string): Update; /** * Inserts a new child to each node in the selection. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. * @param name the element name to append. May be prefixed (see d3.ns.prefix). * @param before a function to determine the node to use as the next sibling */ - insert(name: string, before: (datum: Datum, index: number, outerIndex: number) => EventTarget): Update; + // https://github.com/d3/d3-3.x-api-reference/blob/master/Selections.md#insert + insert(name: string, before?: (datum: Datum, index: number, outerIndex: number) => EventTarget): Update; /** * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. * @param name the function to compute a new child * @param before the selector to determine position (e.g., ":first-child") */ - insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before: string): Update; + insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before?: string): Update; /** * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. * @param name the function to compute a new child * @param before a function to determine the node to use as the next sibling */ - insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before: (datum: Datum, index: number, outerIndex: number) => EventTarget): Update; + insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before?: (datum: Datum, index: number, outerIndex: number) => EventTarget): Update; /** * Removes the elements from the DOM. They are in a detached state and may be re-added (though there is currently no dedicated API for doing so). @@ -429,7 +433,7 @@ declare namespace d3 { /** * Administrivia: JavaScript primitive types, or "things that toString() predictably". */ - export type Primitive = number | string | boolean; + export type Primitive = number | string | boolean | Date | undefined; /** * Administrivia: anything with a valueOf(): number method is comparable, so we allow it in numeric operations @@ -626,28 +630,28 @@ declare namespace d3 { * @param name the element name to append. May be prefixed (see d3.ns.prefix). * @param before the selector to determine position (e.g., ":first-child") */ - insert(name: string, before: string): Selection; + insert(name: string, before?: string): Selection; /** * Inserts a new child to each node in the selection. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. * @param name the element name to append. May be prefixed (see d3.ns.prefix). * @param before a function to determine the node to use as the next sibling */ - insert(name: string, before: (datum: Datum, index: number, outerIndex: number) => EventTarget): Selection; + insert(name: string, before?: (datum: Datum, index: number, outerIndex: number) => EventTarget): Selection; /** * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. * @param name the function to compute a new child * @param before the selector to determine position (e.g., ":first-child") */ - insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before: string): Selection; + insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before?: string): Selection; /** * Inserts a new child to the end of each node in the selection by computing a new node. This child will inherit its parent's data (if available). Returns a fresh selection consisting of the newly-inserted children. * @param name the function to compute a new child * @param before a function to determine the node to use as the next sibling */ - insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before: (datum: Datum, index: number, outerIndex: number) => EventTarget): Selection; + insert(name: (datum: Datum, index: number, outerIndex: number) => EventTarget, before?: (datum: Datum, index: number, outerIndex: number) => EventTarget): Selection; /** * Removes the elements from the DOM. They are in a detached state and may be re-added (though there is currently no dedicated API for doing so). @@ -2605,7 +2609,8 @@ declare namespace d3 { y(): brush.Scale; y(y: brush.Scale): Brush; - extent(): [number, number] | [[number, number], [number, number]]; + // https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Controls.md#brush_extent + extent(): [number, number] | [[number, number], [number, number]] | [Date, Date]; extent(extent: [number, number] | [[number, number], [number, number]]): Brush; clamp(): boolean | [boolean, boolean]; @@ -2874,10 +2879,12 @@ declare namespace d3 { export function force(): Force, Node>; export function force, Node extends force.Node>(): Force; + // https://github.com/d3/d3-3.x-api-reference/blob/master/Force-Layout.md#links + // Read the note at the end of the section where it talks about initial numbering namespace force { interface Link { - source: T; - target: T; + source: T|number; + target: T|number; } interface Node { From c86c33b89cd2d218d3ac55ce60d2b539403b01fe Mon Sep 17 00:00:00 2001 From: Matthias Jobst Date: Tue, 28 Nov 2017 12:08:07 +0100 Subject: [PATCH 212/639] Modified tests to fit with new definitions --- types/d3/v3/d3-tests.ts | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/types/d3/v3/d3-tests.ts b/types/d3/v3/d3-tests.ts index 87b57e8261..4f50ef0341 100644 --- a/types/d3/v3/d3-tests.ts +++ b/types/d3/v3/d3-tests.ts @@ -1051,7 +1051,7 @@ namespace forceCollapsable { var force = d3.layout.force() .on("tick", tick) .charge(function (d) { return d._children ? -d.size / 100 : -30; } ) - .linkDistance(function (d) { return d.target._children ? 80 : 30; } ) + .linkDistance(function (d) { return (d.target as Node)._children ? 80 : 30; } ) .size([w, h - 160]); var vis = d3.select("body").append("svg:svg") @@ -1083,10 +1083,10 @@ namespace forceCollapsable { // Enter any new links. link.enter().insert("svg:line", ".node") .attr("class", "link") - .attr("x1", function (d) { return d.source.x; } ) - .attr("y1", function (d) { return d.source.y; } ) - .attr("x2", function (d) { return d.target.x; } ) - .attr("y2", function (d) { return d.target.y; } ); + .attr("x1", function (d) { return (d.source as Node).x; } ) + .attr("y1", function (d) { return (d.source as Node).y; } ) + .attr("x2", function (d) { return (d.target as Node).x; } ) + .attr("y2", function (d) { return (d.target as Node).y; } ); // Exit any old links. link.exit().remove(); @@ -1114,10 +1114,10 @@ namespace forceCollapsable { } function tick() { - link.attr("x1", function (d) { return d.source.x; } ) - .attr("y1", function (d) { return d.source.y; } ) - .attr("x2", function (d) { return d.target.x; } ) - .attr("y2", function (d) { return d.target.y; } ); + link.attr("x1", function (d) { return (d.source as Node).x; } ) + .attr("y1", function (d) { return (d.source as Node).y; } ) + .attr("x2", function (d) { return (d.target as Node).x; } ) + .attr("y2", function (d) { return (d.target as Node).y; } ); node.attr("cx", function (d) { return d.x; } ) .attr("cy", function (d) { return d.y; } ); @@ -1738,7 +1738,7 @@ namespace forceCollapsable2 { var force = d3.layout.force() .on("tick", tick) .charge(function (d) { return d._children ? -d.size / 100 : -30; } ) - .linkDistance(function (d) { return d.target._children ? 80 : 30; } ) + .linkDistance(function (d) { return (d.target as Node)._children ? 80 : 30; } ) .size([w, h - 160]); var vis = d3.select("body").append("svg:svg") @@ -1770,10 +1770,10 @@ namespace forceCollapsable2 { // Enter any new links. link.enter().insert("svg:line", ".node") .attr("class", "link") - .attr("x1", function (d) { return d.source.x; } ) - .attr("y1", function (d) { return d.source.y; } ) - .attr("x2", function (d) { return d.target.x; } ) - .attr("y2", function (d) { return d.target.y; } ); + .attr("x1", function (d) { return (d.source as Node).x; } ) + .attr("y1", function (d) { return (d.source as Node).y; } ) + .attr("x2", function (d) { return (d.target as Node).x; } ) + .attr("y2", function (d) { return (d.target as Node).y; } ); // Exit any old links. link.exit().remove(); @@ -1801,11 +1801,11 @@ namespace forceCollapsable2 { } function tick() { - link.attr("x1", function (d) { return d.source.x; } ) - .attr("y1", function (d) { return d.source.y; } ) - .attr("x2", function (d) { return d.target.x; } ) - .attr("y2", function (d) { return d.target.y; } ); - + link.attr("x1", function (d) { return (d.source as Node).x; } ) + .attr("y1", function (d) { return (d.source as Node).y; } ) + .attr("x2", function (d) { return (d.target as Node).x; } ) + .attr("y2", function (d) { return (d.target as Node).y; } ); + node.attr("cx", function (d) { return d.x; } ) .attr("cy", function (d) { return d.y; } ); } From 8c5c23df1c88be90b7e9c9b2b8cd13b1582edfcb Mon Sep 17 00:00:00 2001 From: Robert Prib Date: Tue, 28 Nov 2017 11:32:05 +0000 Subject: [PATCH 213/639] * Removed // tslint:disable-next-line for ZoomPanOptions as it is no longer required. * Removed unneeded comment // @factory L.layerGroup(layers?: Layer[], options?: Object) --- types/leaflet/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 3b07cee500..31a9a4a572 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -734,7 +734,6 @@ export class LayerGroup

extends Layer { feature?: geojson.FeatureCollection | geojson.Feature | geojson.GeometryCollection; } -// @factory L.layerGroup(layers?: Layer[], options?: Object) /** * Create a layer group, optionally given an initial set of layers and an `options` object. */ @@ -1138,7 +1137,6 @@ export interface PanOptions { } // This is not empty, it extends two interfaces into one... -// tslint:disable-next-line export interface ZoomPanOptions extends ZoomOptions, PanOptions {} export interface FitBoundsOptions extends ZoomOptions, PanOptions { From c5855450b378b601c62732c4a461517dc01f6501 Mon Sep 17 00:00:00 2001 From: Robert Prib Date: Tue, 28 Nov 2017 12:58:38 +0000 Subject: [PATCH 214/639] Removed unnecessary overloads. --- types/leaflet/index.d.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 31a9a4a572..34dd9b5cc8 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -667,12 +667,8 @@ export function canvas(options?: RendererOptions): Canvas; * added/removed on the map as well. Extends Layer. */ export class LayerGroup

extends Layer { - constructor(layers?: Layer[]); - // tslint:disable-next-line - constructor(layers: Layer[], options?: LayerOptions); - initialize(layers?: Layer[]): this; - // tslint:disable-next-line - initialize(layers: Layer[], options?: LayerOptions): this; + constructor(layers?: Layer[], options?: LayerOptions); + initialize(layers?: Layer[], options?: LayerOptions): this; /** * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint). @@ -737,9 +733,7 @@ export class LayerGroup

extends Layer { /** * Create a layer group, optionally given an initial set of layers and an `options` object. */ -export function layerGroup(layers?: Layer[]): LayerGroup; -// tslint:disable-next-line -export function layerGroup(layers: Layer[], options?: LayerOptions): LayerGroup; +export function layerGroup(layers?: Layer[], options?: LayerOptions): LayerGroup; /** * Extended LayerGroup that also has mouse events (propagated from From 8fbbfdbe4638e0bcc50c054909c3941eb86d1b46 Mon Sep 17 00:00:00 2001 From: Robert Prib Date: Tue, 28 Nov 2017 14:16:46 +0000 Subject: [PATCH 215/639] Updated tslint:disabled with more specific rules and included comment for explanation for need to ignore. --- types/leaflet/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 34dd9b5cc8..cc18a5a89f 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -247,13 +247,15 @@ export abstract class Evented extends Class { * Note that if you passed a custom context to on, you must pass the same context * to off in order to remove the listener. */ - // tslint:disable-next-line + // With an eventMap there are no additional arguments allowed + // tslint:disable-next-line:unified-signatures off(type: string, fn?: LeafletEventHandlerFn, context?: any): this; /** * Removes a set of type/listener pairs. */ - // tslint:disable-next-line + // With an eventMap there are no additional arguments allowed + // tslint:disable-next-line:unified-signatures off(eventMap: LeafletEventHandlerFnMap): this; /** * Removes all listeners to all events on the object. From 73d6127f7b5b5697fde93462197f288deb68d03e Mon Sep 17 00:00:00 2001 From: Robert Prib Date: Tue, 28 Nov 2017 14:18:59 +0000 Subject: [PATCH 216/639] Removed intialize from LayerGroup. --- types/leaflet/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index cc18a5a89f..71c6ea4adf 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -670,7 +670,6 @@ export function canvas(options?: RendererOptions): Canvas; */ export class LayerGroup

extends Layer { constructor(layers?: Layer[], options?: LayerOptions); - initialize(layers?: Layer[], options?: LayerOptions): this; /** * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint). From 888c6e79aba5c1fe54123ae2b733d1ca9737e858 Mon Sep 17 00:00:00 2001 From: "Matt R. Wilson" Date: Tue, 28 Nov 2017 08:43:05 -0700 Subject: [PATCH 217/639] Fill out `initParams` of `RequestAPI`. This method has the same signature as the verb functions as the args get passed directly to `initParams` from all the verb functions. https://github.com/request/request/blob/master/index.js#L58-L5 --- types/request/index.d.ts | 8 ++++++-- types/request/request-tests.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 20ad40e64e..db05b8ebee 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -5,7 +5,8 @@ // Bart van der Schoor , // Joe Skeen , // Christopher Currens , -// Jon Stevens +// Jon Stevens , +// Matt R. Wilson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -58,11 +59,14 @@ declare namespace request { delete(uri: string, callback?: RequestCallback): TRequest; delete(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; + initParams(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; + initParams(uri: string, callback?: RequestCallback): TRequest; + initParams(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; + forever(agentOptions: any, optionsArg: any): TRequest; jar(store?: any): CookieJar; cookie(str: string): Cookie; - initParams: any; debug: boolean; } diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index d2c308ed75..0f9d2aa29c 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -161,8 +161,6 @@ req.destroy(); // --- --- --- --- --- --- --- --- --- --- --- --- -value = request.initParams; - req = request(uri); req = request(uri, options); req = request(uri, options, callback); @@ -219,6 +217,13 @@ req = request.delete(uri, callback); req = request.delete(options); req = request.delete(options, callback); +value = request.initParams(uri); +value = request.initParams(uri, options); +value = request.initParams(uri, options, callback); +value = request.initParams(uri, callback); +value = request.initParams(options); +value = request.initParams(options, callback); + req = request.forever(value, value); jar = request.jar(); cookie = request.cookie(str); From e9430decb983b1f2c943b985892ffe86031a34b0 Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Tue, 28 Nov 2017 13:21:27 -0500 Subject: [PATCH 218/639] [d3-geo] URGENT PATCH (Broken Definition) `geojson` dependency to 1.0.6 (#21808) * Pin `geojson` dependency to 1.0.6 * The latest version of the `geojson` definitions breaks **d3-geo**. Pin to the last working version for now until more thorough change impact assessment is complete. * Add `private: true` to package.json * Remove `package.json` stub. Replace `CoordinateReferenceSystem` with literal. --- types/d3-geo/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 4093b696e9..7efbb72010 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -36,7 +36,10 @@ export type GeoGeometryObjects = GeoJSON.GeometryObject | GeoSphere; export interface ExtendedGeometryCollection { type: string; bbox?: number[]; - crs?: GeoJSON.CoordinateReferenceSystem; + crs?: { + type: string; + properties: any; + }; geometries: GeometryType[]; } From c5dc464c6e11df46feb8f69ff84afe63d6556c09 Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Tue, 28 Nov 2017 12:49:28 -0700 Subject: [PATCH 219/639] Add ansi-regex package --- types/ansi-regex/ansi-regex-tests.ts | 13 +++++++++++++ types/ansi-regex/index.d.ts | 7 +++++++ types/ansi-regex/tsconfig.json | 23 +++++++++++++++++++++++ types/ansi-regex/tslint.json | 1 + 4 files changed, 44 insertions(+) create mode 100644 types/ansi-regex/ansi-regex-tests.ts create mode 100644 types/ansi-regex/index.d.ts create mode 100644 types/ansi-regex/tsconfig.json create mode 100644 types/ansi-regex/tslint.json diff --git a/types/ansi-regex/ansi-regex-tests.ts b/types/ansi-regex/ansi-regex-tests.ts new file mode 100644 index 0000000000..a5787902f0 --- /dev/null +++ b/types/ansi-regex/ansi-regex-tests.ts @@ -0,0 +1,13 @@ +import ansiRegex = require("ansi-regex"); + +ansiRegex(); // $ExpectType RegExp + +// From the ansi-regex README.md +ansiRegex().test('\u001B[4mcake\u001B[0m'); // $ExpectType boolean +// => true + +ansiRegex().test('cake'); // $ExpectType boolean +// => false + +'\u001B[4mcake\u001B[0m'.match(ansiRegex()); // $ExpectType RegExpMatchArray | null +// => ['\u001B[4m', '\u001B[0m'] diff --git a/types/ansi-regex/index.d.ts b/types/ansi-regex/index.d.ts new file mode 100644 index 0000000000..34890912dc --- /dev/null +++ b/types/ansi-regex/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for ansi-regex 3.0 +// Project: https://github.com/chalk/ansi-regex#readme +// Definitions by: Manish Vachharajani +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function r(): RegExp; +export = r; diff --git a/types/ansi-regex/tsconfig.json b/types/ansi-regex/tsconfig.json new file mode 100644 index 0000000000..cf1ac84a5c --- /dev/null +++ b/types/ansi-regex/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ansi-regex-tests.ts" + ] +} diff --git a/types/ansi-regex/tslint.json b/types/ansi-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ansi-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 2fb3aa3b2f7a3d8453ab8b371212267e83fce3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=5BDesktop=5D?= Date: Tue, 28 Nov 2017 22:16:50 +0100 Subject: [PATCH 220/639] [BSON]: Add buffer field to Binary --- types/bson/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/bson/index.d.ts b/types/bson/index.d.ts index 2b6a636e89..6aeeabe3d9 100644 --- a/types/bson/index.d.ts +++ b/types/bson/index.d.ts @@ -39,6 +39,9 @@ export class Binary { constructor(buffer: Buffer, subType?: number); + /** The underlying Buffer which stores the binary data. */ + readonly buffer: Buffer; + /** The length of the binary. */ length(): number; /** Updates this binary with byte_value */ From 75723b04732245f84130f6de84c3490ee8c74403 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Tue, 28 Nov 2017 15:29:33 -0600 Subject: [PATCH 221/639] allow for undefined transactions --- types/knex/index.d.ts | 2 +- types/knex/knex-tests.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index aaee0b27f7..e96dfbefd8 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -156,7 +156,7 @@ declare namespace Knex { delete(returning?: string | string[]): QueryBuilder; truncate(): QueryBuilder; - transacting(trx: Transaction): QueryBuilder; + transacting(trx?: Transaction): QueryBuilder; connection(connection: any): QueryBuilder; clone(): QueryBuilder; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index dec1bf055f..c7c99813f1 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -672,6 +672,9 @@ knex.transaction<{ length: number }>(function(trx) { console.error(error); }); +// transacting handles undefined +knex.insert({ name: 'Old Books'}).transacting(undefined); + knex.schema.withSchema("public").hasTable("table") as Promise; knex.schema.createTable('users', function (table) { From d136e288cce89d4e48e860599be8302a9d342a24 Mon Sep 17 00:00:00 2001 From: Christopher Altonji Date: Tue, 28 Nov 2017 14:17:42 -0800 Subject: [PATCH 222/639] Added keyboard event as parameter to the callback of bind in combokeys --- types/combokeys/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/combokeys/index.d.ts b/types/combokeys/index.d.ts index f7e1e5b035..24f3313582 100644 --- a/types/combokeys/index.d.ts +++ b/types/combokeys/index.d.ts @@ -35,7 +35,7 @@ declare namespace Combokeys { * @param {handler} optional - one of "keypress", "keydown", or "keyup" * @returns void */ - bind(keys: string | string[], callback: () => void, action?: string): void; + bind(keys: string | string[], callback: (event: KeyboardEvent) => void, action?: string): void; /** From 3f594941b0f40f6c5564a66d8c12092b471bc798 Mon Sep 17 00:00:00 2001 From: Dan Kraus Date: Tue, 28 Nov 2017 17:49:32 -0500 Subject: [PATCH 223/639] Converts var to let --- types/joi/joi-tests.ts | 90 +++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index 58531f5d24..5b9bbde7f5 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -2,50 +2,50 @@ import Joi = require('joi'); // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var x: any = null; -var value: any = null; -var num: number = 0; -var str: string = ''; -var bool: boolean = false; -var exp: RegExp = null; -var obj: object = null; -var date: Date = null; -var err: Error = null; -var func: Function = null; +let x: any = null; +let value: any = null; +let num: number = 0; +let str: string = ''; +let bool: boolean = false; +let exp: RegExp = null; +let obj: object = null; +let date: Date = null; +let err: Error = null; +let func: Function = null; -var anyArr: any[] = []; -var numArr: number[] = []; -var strArr: string[] = []; -var boolArr: boolean[] = []; -var expArr: RegExp[] = []; -var objArr: object[] = []; -var errArr: Error[] = []; -var funcArr: Function[] = []; +let anyArr: any[] = []; +let numArr: number[] = []; +let strArr: string[] = []; +let boolArr: boolean[] = []; +let expArr: RegExp[] = []; +let objArr: object[] = []; +let errArr: Error[] = []; +let funcArr: Function[] = []; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var schema: Joi.Schema = null; -var schemaLike: Joi.SchemaLike = null; +let schema: Joi.Schema = null; +let schemaLike: Joi.SchemaLike = null; -var anySchema: Joi.AnySchema = null; -var numSchema: Joi.NumberSchema = null; -var strSchema: Joi.StringSchema = null; -var arrSchema: Joi.ArraySchema = null; -var boolSchema: Joi.BooleanSchema = null; -var binSchema: Joi.BinarySchema = null; -var dateSchema: Joi.DateSchema = null; -var funcSchema: Joi.FunctionSchema = null; -var objSchema: Joi.ObjectSchema = null; -var altSchema: Joi.AlternativesSchema = null; +let anySchema: Joi.AnySchema = null; +let numSchema: Joi.NumberSchema = null; +let strSchema: Joi.StringSchema = null; +let arrSchema: Joi.ArraySchema = null; +let boolSchema: Joi.BooleanSchema = null; +let binSchema: Joi.BinarySchema = null; +let dateSchema: Joi.DateSchema = null; +let funcSchema: Joi.FunctionSchema = null; +let objSchema: Joi.ObjectSchema = null; +let altSchema: Joi.AlternativesSchema = null; -var schemaArr: Joi.Schema[] = []; +let schemaArr: Joi.Schema[] = []; -var ref: Joi.Reference = null; -var description: Joi.Description = null; +let ref: Joi.Reference = null; +let description: Joi.Description = null; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var validOpts: Joi.ValidationOptions = null; +let validOpts: Joi.ValidationOptions = null; validOpts = { abortEarly: bool }; validOpts = { convert: bool }; @@ -77,7 +77,7 @@ validOpts = { // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var renOpts: Joi.RenameOptions = null; +let renOpts: Joi.RenameOptions = null; renOpts = { alias: bool }; renOpts = { multiple: bool }; @@ -86,7 +86,7 @@ renOpts = { ignoreUndefined: bool }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var emailOpts: Joi.EmailOptions = null; +let emailOpts: Joi.EmailOptions = null; emailOpts = { errorLevel: num }; emailOpts = { errorLevel: bool }; @@ -96,7 +96,7 @@ emailOpts = { minDomainAtoms: num }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var ipOpts: Joi.IpOptions = null; +let ipOpts: Joi.IpOptions = null; ipOpts = { version: str }; ipOpts = { version: strArr }; @@ -104,7 +104,7 @@ ipOpts = { cidr: str }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var uriOpts: Joi.UriOptions = null; +let uriOpts: Joi.UriOptions = null; uriOpts = { scheme: str }; uriOpts = { scheme: exp }; @@ -113,13 +113,13 @@ uriOpts = { scheme: expArr }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var base64Opts: Joi.Base64Options = null; +let base64Opts: Joi.Base64Options = null; base64Opts = { paddingRequired: bool }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var whenOpts: Joi.WhenOptions = null; +let whenOpts: Joi.WhenOptions = null; whenOpts = { is: x }; whenOpts = { is: schema, then: schema }; @@ -128,16 +128,16 @@ whenOpts = { is: schemaLike, then: schemaLike, otherwise: schemaLike }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var refOpts: Joi.ReferenceOptions = null; +let refOpts: Joi.ReferenceOptions = null; refOpts = { separator: str }; refOpts = { contextPrefix: str }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var validErr: Joi.ValidationError = null; -var validErrItem: Joi.ValidationErrorItem; -var validErrFunc: Joi.ValidationErrorFunction; +let validErr: Joi.ValidationError = null; +let validErrItem: Joi.ValidationErrorItem; +let validErrFunc: Joi.ValidationErrorFunction; validErrItem = { message: str, @@ -182,7 +182,7 @@ anySchema = objSchema; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -var schemaMap: Joi.SchemaMap = null; +let schemaMap: Joi.SchemaMap = null; schemaMap = { a: numSchema, From 0c20cfdcd94de5b31c9e7a883775e83393d9a943 Mon Sep 17 00:00:00 2001 From: Dan Kraus Date: Tue, 28 Nov 2017 18:33:14 -0500 Subject: [PATCH 224/639] Casts GuidVersions to pass linter --- types/joi/joi-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/joi/joi-tests.ts b/types/joi/joi-tests.ts index 5b9bbde7f5..785360746e 100644 --- a/types/joi/joi-tests.ts +++ b/types/joi/joi-tests.ts @@ -1,4 +1,5 @@ import Joi = require('joi'); +import { GuidVersions } from 'joi'; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -771,7 +772,7 @@ strSchema = strSchema.ip(ipOpts); strSchema = strSchema.uri(); strSchema = strSchema.uri(uriOpts); strSchema = strSchema.guid(); -strSchema = strSchema.guid({ version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5'] }); +strSchema = strSchema.guid({ version: ['uuidv1' as GuidVersions, 'uuidv2' as GuidVersions, 'uuidv3' as GuidVersions, 'uuidv4' as GuidVersions, 'uuidv5' as GuidVersions]}); strSchema = strSchema.guid({ version: 'uuidv4' }); strSchema = strSchema.hex(); strSchema = strSchema.hostname(); From a0af484a9c641e313b69e7dec32701dbba57cc08 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Tue, 28 Nov 2017 15:43:56 -0800 Subject: [PATCH 225/639] [redux-first-router-link] Fix the type of OnClick --- types/redux-first-router-link/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/redux-first-router-link/index.d.ts b/types/redux-first-router-link/index.d.ts index d7b2e7a079..c74bdd530b 100644 --- a/types/redux-first-router-link/index.d.ts +++ b/types/redux-first-router-link/index.d.ts @@ -9,7 +9,7 @@ import { Location } from 'redux-first-router'; export type To = string | string[] | object; -export type OnClick = false | ((e: React.SyntheticEvent) => boolean | undefined); +export type OnClick = false | ((e: React.MouseEvent) => void); export interface Match

{ params: P; From 7f6508562138dacfd1e12478b7c2bdf69d83d67f Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Tue, 28 Nov 2017 15:46:38 -0800 Subject: [PATCH 226/639] add types for checkSession method --- types/auth0-lock/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index 0a57d988ce..c1a393409a 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -154,6 +154,7 @@ interface Auth0LockStatic { // deprecated getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; + checkSession(options: object, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void; // https://github.com/auth0/lock#resumeauthhash-callback resumeAuth(hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void; show(options?: Auth0LockShowOptions): void; From 9890a3710c594347c55c924842c902dd3ce9220d Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Tue, 28 Nov 2017 15:52:44 -0800 Subject: [PATCH 227/639] Update index.d.ts --- types/auth0-lock/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index c1a393409a..8ed6b50c87 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -154,7 +154,7 @@ interface Auth0LockStatic { // deprecated getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void; - checkSession(options: object, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void; + checkSession(options: any, callback: (error: auth0.Auth0Error, authResult: AuthResult | undefined) => void): void; // https://github.com/auth0/lock#resumeauthhash-callback resumeAuth(hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void; show(options?: Auth0LockShowOptions): void; From d7c4168ae7f75e7ba75278118e3c2b203c258299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Tue, 28 Nov 2017 21:23:54 +0800 Subject: [PATCH 228/639] move v0.100 files to v0 --- types/materialize-css/{ => v0}/index.d.ts | 0 types/materialize-css/{ => v0}/materialize-css-tests.ts | 0 types/materialize-css/{ => v0}/tsconfig.json | 6 +++--- types/materialize-css/{ => v0}/tslint.json | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename types/materialize-css/{ => v0}/index.d.ts (100%) rename types/materialize-css/{ => v0}/materialize-css-tests.ts (100%) rename types/materialize-css/{ => v0}/tsconfig.json (90%) rename types/materialize-css/{ => v0}/tslint.json (100%) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/v0/index.d.ts similarity index 100% rename from types/materialize-css/index.d.ts rename to types/materialize-css/v0/index.d.ts diff --git a/types/materialize-css/materialize-css-tests.ts b/types/materialize-css/v0/materialize-css-tests.ts similarity index 100% rename from types/materialize-css/materialize-css-tests.ts rename to types/materialize-css/v0/materialize-css-tests.ts diff --git a/types/materialize-css/tsconfig.json b/types/materialize-css/v0/tsconfig.json similarity index 90% rename from types/materialize-css/tsconfig.json rename to types/materialize-css/v0/tsconfig.json index cc986baa67..770e3cce3f 100644 --- a/types/materialize-css/tsconfig.json +++ b/types/materialize-css/v0/tsconfig.json @@ -9,9 +9,9 @@ "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, - "baseUrl": "../", + "baseUrl": "../../", "typeRoots": [ - "../" + "../../" ], "types": [], "noEmit": true, @@ -21,4 +21,4 @@ "index.d.ts", "materialize-css-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/materialize-css/tslint.json b/types/materialize-css/v0/tslint.json similarity index 100% rename from types/materialize-css/tslint.json rename to types/materialize-css/v0/tslint.json From dd2f9f7d095c8092ce237cff686e11625c2decc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Tue, 28 Nov 2017 21:25:08 +0800 Subject: [PATCH 229/639] begin work at v1.0.0-alpha.1 add Sidenav --- types/materialize-css/index.d.ts | 112 ++++++++++++++++++ .../test/materialize-css-global.test.ts | 3 + .../test/materialize-css-module.test.ts | 21 ++++ types/materialize-css/tsconfig.json | 25 ++++ types/materialize-css/tslint.json | 6 + 5 files changed, 167 insertions(+) create mode 100644 types/materialize-css/index.d.ts create mode 100644 types/materialize-css/test/materialize-css-global.test.ts create mode 100644 types/materialize-css/test/materialize-css-module.test.ts create mode 100644 types/materialize-css/tsconfig.json create mode 100644 types/materialize-css/tslint.json diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts new file mode 100644 index 0000000000..076dc309dc --- /dev/null +++ b/types/materialize-css/index.d.ts @@ -0,0 +1,112 @@ +// Type definitions for materialize-css 1.0 +// Project: http://materializecss.com/ +// Definitions by: 胡玮文 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export = M; + +declare global { + namespace M { + class Sidenav { + /** + * Construct Sidenav instance and set up overlay + */ + constructor(elem: Element, options?: Partial); + + /** + * Get Instance + */ + static getInstance(elem: Element): Sidenav; + + /** + * Opens Sidenav + */ + open(): void; + + /** + * Closes Sidenav + */ + close(): void; + + /** + * Destroy plugin instance and teardown + */ + destroy(): void; + + /** + * The DOM element the plugin was initialized with + */ + el: Element; + + /** + * The options the instance was initialized with + */ + options: SidenavOptions; + + /** + * Describes open/close state of Sidenav + */ + isOpen: boolean; + + /** + * Describes if sidenav is fixed + */ + isFixed: boolean; + + /** + * Describes if Sidenav is being dragged + */ + isDragged: boolean; + } + + /** + * Options for the Sidenav + */ + interface SidenavOptions { + /** + * Side of screen on which Sidenav appears + * @default 'left' + */ + edge: 'left' | 'right'; + + /** + * Allow swipe gestures to open/close Sidenav + * @default true + */ + draggable: boolean; + + /** + * Length in ms of enter transition + * @default 250 + */ + inDuration: number; + + /** + * Length in ms of exit transition + * @default 200 + */ + outDuration: number; + + /** + * Function called when sidenav starts entering + */ + onOpenStart: (instance: Sidenav, elem: Element) => void; + + /** + * Function called when sidenav finishes entering + */ + onOpenEnd: (instance: Sidenav, elem: Element) => void; + + /** + * Function called when sidenav starts exiting + */ + onCloseStart: (instance: Sidenav, elem: Element) => void; + + /** + * Function called when sidenav finishes exiting + */ + onCloseEnd: (instance: Sidenav, elem: Element) => void; + } + } +} diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts new file mode 100644 index 0000000000..5c3d4213c6 --- /dev/null +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -0,0 +1,3 @@ +const elem = document.querySelector('.sidenav')!; +// $ExpectType Sidenav +const sidenav = new M.Sidenav(elem); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts new file mode 100644 index 0000000000..76ce89595e --- /dev/null +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -0,0 +1,21 @@ +import * as materialize from "materialize-css"; + +// Sidenav +const elem = document.querySelector('.sidenav')!; +// $ExpectType Sidenav +const sidenav = new materialize.Sidenav(elem, { + edge: "left", + inDuration: 300, + onCloseStart: () => console.log("closing") +}); +// $ExpectType void +sidenav.open(); +// $ExpectType void +sidenav.destroy(); + +// $ExpectType SidenavOptions +sidenav.options; +// $ExpectType Element +sidenav.el; +// $ExpectType boolean +sidenav.isOpen; diff --git a/types/materialize-css/tsconfig.json b/types/materialize-css/tsconfig.json new file mode 100644 index 0000000000..25a5435fd4 --- /dev/null +++ b/types/materialize-css/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/materialize-css-global.test.ts", + "test/materialize-css-module.test.ts" + ] +} diff --git a/types/materialize-css/tslint.json b/types/materialize-css/tslint.json new file mode 100644 index 0000000000..5f6e69415a --- /dev/null +++ b/types/materialize-css/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + + } + } From c5ad054706234b4b6a98a483a56689f7fa91e019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Wed, 29 Nov 2017 00:52:43 +0800 Subject: [PATCH 230/639] add jQuery support add Tabs --- types/materialize-css/index.d.ts | 110 ++++++++++++++---- .../test/materialize-css-global.test.ts | 5 +- .../test/materialize-css-jquery.test.ts | 9 ++ .../test/materialize-css-module.test.ts | 33 +++++- types/materialize-css/tsconfig.json | 3 +- 5 files changed, 130 insertions(+), 30 deletions(-) create mode 100644 types/materialize-css/test/materialize-css-jquery.test.ts diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index 076dc309dc..8c7914f2fd 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -4,16 +4,13 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 +/// + export = M; declare global { namespace M { - class Sidenav { - /** - * Construct Sidenav instance and set up overlay - */ - constructor(elem: Element, options?: Partial); - + class Sidenav extends Component { /** * Get Instance */ @@ -29,21 +26,6 @@ declare global { */ close(): void; - /** - * Destroy plugin instance and teardown - */ - destroy(): void; - - /** - * The DOM element the plugin was initialized with - */ - el: Element; - - /** - * The options the instance was initialized with - */ - options: SidenavOptions; - /** * Describes open/close state of Sidenav */ @@ -91,22 +73,100 @@ declare global { /** * Function called when sidenav starts entering */ - onOpenStart: (instance: Sidenav, elem: Element) => void; + onOpenStart: (this: Sidenav, elem: Element) => void; /** * Function called when sidenav finishes entering */ - onOpenEnd: (instance: Sidenav, elem: Element) => void; + onOpenEnd: (this: Sidenav, elem: Element) => void; /** * Function called when sidenav starts exiting */ - onCloseStart: (instance: Sidenav, elem: Element) => void; + onCloseStart: (this: Sidenav, elem: Element) => void; /** * Function called when sidenav finishes exiting */ - onCloseEnd: (instance: Sidenav, elem: Element) => void; + onCloseEnd: (this: Sidenav, elem: Element) => void; + } + + class Tabs extends Component { + /** + * Get Instance + */ + static getInstance(elem: Element): Tabs; + + /** + * Show tab content that corresponds to the tab with the id + * @param tabId The id of the tab that you want to switch to + */ + select(tabId: string): void; + + /** + * The index of tab that is currently shown + */ + index: number; + } + + /** + * Options for the Tabs + */ + interface TabsOptions { + /** + * Transition duration in milliseconds. + * @default 300 + */ + duration: number; + + /** + * Callback for when a new tab content is shown + */ + onShow: (this: Tabs, newContent: Element) => void; + + /** + * Set to true to enable swipeable tabs. This also uses the responsiveThreshold option + * @default false + */ + swipeable: boolean; + + /** + * The maximum width of the screen, in pixels, where the swipeable functionality initializes. + * @default infinity + */ + responsiveThreshold: number; + } + + abstract class Component { + /** + * Construct component instance and set everything up + */ + constructor(elem: Element, options?: Partial); + + /** + * Destroy plugin instance and teardown + */ + destroy(): void; + + /** + * The DOM element the plugin was initialized with + */ + el: Element; + + /** + * The options the instance was initialized with + */ + options: TOptions; } } + + interface JQuery { + // Pick to check methods exist. + sidenav(method: keyof Pick): JQuery; + sidenav(options?: Partial): JQuery; + + tabs(method: keyof Pick): JQuery; + tabs(method: keyof Pick, tabId: string): JQuery; + tabs(options?: Partial): JQuery; + } } diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index 5c3d4213c6..90ca3de1c5 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -1,3 +1,6 @@ -const elem = document.querySelector('.sidenav')!; +const elem = document.querySelector('.whatever')!; // $ExpectType Sidenav const sidenav = new M.Sidenav(elem); + +// $ExpectType Tabs +const tabs = new M.Tabs(elem); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts new file mode 100644 index 0000000000..543bab8cc2 --- /dev/null +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -0,0 +1,9 @@ +$(".whatever").sidenav(); +$(".whatever").sidenav({inDuration: 200}); +$(".whatever").sidenav("open"); +$(".whatever").sidenav("destroy"); + +$(".whatever").tabs(); +$(".whatever").tabs({ duration: 200 }); +$(".whatever").tabs("destroy"); +$(".whatever").tabs("select", "id"); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index 76ce89595e..14221464c9 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -1,21 +1,48 @@ import * as materialize from "materialize-css"; +const elem = document.querySelector('.whatever')!; + // Sidenav -const elem = document.querySelector('.sidenav')!; +// $ExpectType Sidenav +new materialize.Sidenav(elem); // $ExpectType Sidenav const sidenav = new materialize.Sidenav(elem, { edge: "left", inDuration: 300, - onCloseStart: () => console.log("closing") + onCloseStart(el) { + // $ExpectType Sidenav + this; + // $ExpectType Element + el; + } }); // $ExpectType void sidenav.open(); // $ExpectType void sidenav.destroy(); - // $ExpectType SidenavOptions sidenav.options; // $ExpectType Element sidenav.el; // $ExpectType boolean sidenav.isOpen; + +// Tabs +// $ExpectType Tabs +const tabs = new materialize.Tabs(elem, { + duration: 200, + onShow(content) { + // $ExpectType Tabs + this; + // $ExpectType Element + content; + } +}); +// $ExpectType void +tabs.destroy(); +// $ExpectType void +tabs.select("id"); +// $ExpectType TabsOptions +tabs.options; +// $ExpectType number +tabs.index; diff --git a/types/materialize-css/tsconfig.json b/types/materialize-css/tsconfig.json index 25a5435fd4..316e2f8361 100644 --- a/types/materialize-css/tsconfig.json +++ b/types/materialize-css/tsconfig.json @@ -20,6 +20,7 @@ "files": [ "index.d.ts", "test/materialize-css-global.test.ts", - "test/materialize-css-module.test.ts" + "test/materialize-css-module.test.ts", + "test/materialize-css-jquery.test.ts" ] } From 33366d809ac772d68a7e63239329bca71dc70d31 Mon Sep 17 00:00:00 2001 From: Masayuki Ono Date: Wed, 29 Nov 2017 17:00:17 +0900 Subject: [PATCH 231/639] Add cacheControl to FileMetadata --- types/google-cloud__storage/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/google-cloud__storage/index.d.ts b/types/google-cloud__storage/index.d.ts index 544f2e095f..a614ea4982 100644 --- a/types/google-cloud__storage/index.d.ts +++ b/types/google-cloud__storage/index.d.ts @@ -153,6 +153,7 @@ declare namespace Storage { interface FileMetadata { contentType?: string; metadata?: CustomFileMetadata; + cacheControl?: string; } /** From b2bab1dec074db9d658efc4bea17d9464c86de13 Mon Sep 17 00:00:00 2001 From: Asuka Ito Date: Wed, 29 Nov 2017 17:14:42 +0900 Subject: [PATCH 232/639] Support for TypeScript 2.6 strict function types and remove unnecessary import. --- types/redux-form/lib/Field.d.ts | 2 +- types/redux-form/redux-form-tests.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/redux-form/lib/Field.d.ts b/types/redux-form/lib/Field.d.ts index e964299ad3..4fbe9de388 100644 --- a/types/redux-form/lib/Field.d.ts +++ b/types/redux-form/lib/Field.d.ts @@ -36,7 +36,7 @@ export interface CommonFieldProps { export interface BaseFieldProps

extends Partial { name: string; label?: string; - component?: ComponentType

| "input" | "select" | "textarea", + component?: ComponentType

| "input" | "select" | "textarea", format?: Formatter | null; normalize?: Normalizer; props?: P; diff --git a/types/redux-form/redux-form-tests.tsx b/types/redux-form/redux-form-tests.tsx index 04465c845c..b3e94a6c1f 100644 --- a/types/redux-form/redux-form-tests.tsx +++ b/types/redux-form/redux-form-tests.tsx @@ -11,7 +11,6 @@ import { formValueSelector, Field, GenericField, - BaseFieldProps, WrappedFieldProps, Fields, GenericFields, From c0cba20b9f2e44c8b679c88d58aa30d69d3d272c Mon Sep 17 00:00:00 2001 From: Jose Fernandez Exposito Date: Wed, 29 Nov 2017 09:25:52 +0100 Subject: [PATCH 233/639] Added variable process --- types/webpack-env/index.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/types/webpack-env/index.d.ts b/types/webpack-env/index.d.ts index ea9db09289..99022670a9 100644 --- a/types/webpack-env/index.d.ts +++ b/types/webpack-env/index.d.ts @@ -187,6 +187,10 @@ declare namespace __WebpackModuleApi { autoApply?: boolean; } + interface NodeProcess { + env?: any; + } + type __Require1 = (id: string) => any; type __Require2 = (id: string) => T; type RequireLambda = __Require1 & __Require2; @@ -247,3 +251,8 @@ declare var DEBUG: boolean; interface NodeModule extends __WebpackModuleApi.Module {} declare var module: NodeModule; + +declare namespace NodeJS { + interface Process extends __WebpackModuleApi.NodeProcess {} +} +declare var process: NodeJS.Process; From b783642bfb122ab8024626db00633e098dc0d34f Mon Sep 17 00:00:00 2001 From: rjpackito Date: Wed, 29 Nov 2017 12:01:30 +0300 Subject: [PATCH 234/639] Update index.d.ts Add Monitor --- types/yandex-maps/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/yandex-maps/index.d.ts b/types/yandex-maps/index.d.ts index 7bb86f61f6..e397c475cb 100644 --- a/types/yandex-maps/index.d.ts +++ b/types/yandex-maps/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for yandex-maps 2.1 // Project: https://github.com/Delagen/typings-yandex-maps // Definitions by: Delagen +// + // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -3036,4 +3038,12 @@ declare namespace ymaps { shift(offset: number[]): IShape; } + class Monitor { + constructor(dataManager: IDataManager | IOptionManager); + add(name: string[] | string, changeCallback: (event: (object | IEvent)) => void, context: any = null, params: any = null): Monitor; + forceChange(): Monitor; + get(name: string): any; + remove(name: string): Monitor; + removeAll(): Monitor; + } } From 6cff3bd86b476aeaef37aafc34aed572095be2e9 Mon Sep 17 00:00:00 2001 From: Igor Adrov Date: Wed, 29 Nov 2017 12:50:55 +0300 Subject: [PATCH 235/639] Update sip.js to 0.8 --- types/sip.js/index.d.ts | 77 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/types/sip.js/index.d.ts b/types/sip.js/index.d.ts index 2513f7f585..21c1bae002 100644 --- a/types/sip.js/index.d.ts +++ b/types/sip.js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sip.js 0.7 +// Type definitions for sip.js 0.8 // Project: http://sipjs.com // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -71,6 +71,27 @@ export namespace C { } } +export type DescriptionModifier = (description: RTCSessionDescription) => Promise + +export interface SessionDescriptionHandler { + getDescription(options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise; + setDescription(sessionDescription: string, options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise; + hasDescription: (contentType: string) => boolean; + close: () => void; + holdModifier: (description: RTCSessionDescription) => Promise; + + on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; + on(name: 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'userMediaFailed', callback: (error: string) => void): void; + on(name: 'iceCandidate', callback: (candidate: any) => void): void; + on( + name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | + 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, + callback: () => void): void; + on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; + on(name: 'addTrack', callback: (track: any) => void): void; +} + export interface Session { startTime?: Date; endTime?: Date; @@ -81,6 +102,7 @@ export interface Session { localIdentity?: NameAddrHeader; remoteIdentity?: NameAddrHeader; data: ClientContext | ServerContext; + sessionDescriptionHandler: SessionDescriptionHandler; dtmf(tone: string | number, options?: Session.DtmfOptions): Session; terminate(options?: Session.CommonOptions): Session; @@ -140,7 +162,7 @@ export namespace Session { }; } - interface DTMF extends Object {} + interface DTMF extends Object { } interface Muted { audio?: boolean; @@ -189,10 +211,26 @@ export namespace WebRTC { on(name: 'iceCandidate', callback: (candidate: any) => void): void; on( name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | - 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, + 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, callback: () => void): void; on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; } + + class Simple { + constructor(options: SimpleConfigurationParameters); + + on(name: 'registered', callback: (ua: UA) => void): void; + on(name: 'unregistered', callback: (ua: UA) => void): void; + on(name: 'ringing', callback: (session: Session) => void): void; + on(name: 'connecting', callback: (session: Session) => void): void; + on(name: 'connected', callback: (session: Session) => void): void; + on(name: 'ended', callback: (session: Session) => void): void; + on(name: 'message', callback: (message: Message) => void): void; + + call(target: string | URI): Session; + toggleMute(mute: boolean): void; + hangup: () => Session | void; + } } /* Parameters */ @@ -242,6 +280,39 @@ export interface ConfigurationParameters { wsServerReconnectionTimeout?: number; } +export interface SimpleConfigurationParameters { + ua: { + wsServers?: string | Array; + uri?: string; + authorizationUser?: string; + password?: string; + displayName?: string; + traceSip?: boolean; + userAgentString?: string; + }; + media?: { + remote?: { + audio?: Element; + video?: Element; + }; + local?: { + audio?: Element; + video?: Element; + }; + }; +} + +export interface SessionDescriptionHandlerParameters { + constraints?: any; + peerConnectionOptions?: { + rtcConfiguration: { + iceServers: TurnServer[]; + iceCheckingTimeout: number; + }; + RTCOfferOptions: {}; + }; +} + /* Options */ export interface ExtraHeadersOptions { extraHeaders?: string[]; From 26e0d2c226d5c4ae2b5a33883216be785f28b7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Gillot-Lamure?= Date: Tue, 28 Nov 2017 17:38:14 +0000 Subject: [PATCH 236/639] Parameter in callback should not be optionnal Using `?` in this situation would mean that you may, *or may not*, pass the `done` parameter to the callback. It does not mean that the callback can use it or not. You probably always pass the `done` parameter to the callback. See https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#optional-parameters-in-callbacks Having `?` here is annoying for the caller when they use --strictNullChecks because they have to use `!` (the non-null assertion) whenever they use `done` to tell the compiler that it actually will never be null. --- types/agenda/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/agenda/index.d.ts b/types/agenda/index.d.ts index d170a6f6f1..426b187d7c 100644 --- a/types/agenda/index.d.ts +++ b/types/agenda/index.d.ts @@ -113,8 +113,8 @@ declare class Agenda extends EventEmitter { * @param options The options for the job. * @param handler The handler to execute. */ - define(name: string, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void; - define(name: string, options: Agenda.JobOptions, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void; + define(name: string, handler: (job: Agenda.Job, done: (err?: Error) => void) => void): void; + define(name: string, options: Agenda.JobOptions, handler: (job: Agenda.Job, done: (err?: Error) => void) => void): void; /** * Runs job name at the given interval. Optionally, data and options can be passed in. From 6d0db5e66d4d4fb37730a2fccd1c2600edd21066 Mon Sep 17 00:00:00 2001 From: Adrov Igor Date: Wed, 29 Nov 2017 13:06:56 +0300 Subject: [PATCH 237/639] tslint fixes --- types/sip.js/index.d.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/types/sip.js/index.d.ts b/types/sip.js/index.d.ts index 21c1bae002..65aa453a68 100644 --- a/types/sip.js/index.d.ts +++ b/types/sip.js/index.d.ts @@ -2,6 +2,7 @@ // Project: http://sipjs.com // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export as namespace sipjs; @@ -71,7 +72,7 @@ export namespace C { } } -export type DescriptionModifier = (description: RTCSessionDescription) => Promise +export type DescriptionModifier = (description: RTCSessionDescription) => Promise; export interface SessionDescriptionHandler { getDescription(options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise; @@ -219,12 +220,8 @@ export namespace WebRTC { class Simple { constructor(options: SimpleConfigurationParameters); - on(name: 'registered', callback: (ua: UA) => void): void; - on(name: 'unregistered', callback: (ua: UA) => void): void; - on(name: 'ringing', callback: (session: Session) => void): void; - on(name: 'connecting', callback: (session: Session) => void): void; - on(name: 'connected', callback: (session: Session) => void): void; - on(name: 'ended', callback: (session: Session) => void): void; + on(name: 'registered' | 'unregistered', callback: (ua: UA) => void): void; + on(name: 'ringing' | 'connecting' | 'connected' | 'ended', callback: (session: Session) => void): void; on(name: 'message', callback: (message: Message) => void): void; call(target: string | URI): Session; From 3f7e17614965246768484ea2876bdc23ba5b7a12 Mon Sep 17 00:00:00 2001 From: reduckted Date: Wed, 29 Nov 2017 19:10:47 +1000 Subject: [PATCH 238/639] Added the missing getFilenameFromUrl method and fileSystem property to webpack-dev-middleware. --- types/webpack-dev-middleware/index.d.ts | 6 ++++- .../webpack-dev-middleware-tests.ts | 22 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/types/webpack-dev-middleware/index.d.ts b/types/webpack-dev-middleware/index.d.ts index 77174b938b..e88cec98ef 100644 --- a/types/webpack-dev-middleware/index.d.ts +++ b/types/webpack-dev-middleware/index.d.ts @@ -1,11 +1,13 @@ -// Type definitions for webpack-dev-middleware 1.9 +// Type definitions for webpack-dev-middleware 1.12 // Project: https://github.com/webpack/webpack-dev-middleware // Definitions by: Benjamin Lim +// reduckted // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 import { NextHandleFunction } from 'connect'; import * as webpack from 'webpack'; +import MemoryFileSystem = require('memory-fs'); export = WebpackDevMiddleware; @@ -49,5 +51,7 @@ declare namespace WebpackDevMiddleware { close(callback?: () => void): void; invalidate(callback?: (stats: webpack.Stats) => void): void; waitUntilValid(callback?: (stats: webpack.Stats) => void): void; + getFilenameFromUrl: (url: string) => string | false; + fileSystem: MemoryFileSystem; } } diff --git a/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts b/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts index a4b1d57822..8df4675595 100644 --- a/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts +++ b/types/webpack-dev-middleware/webpack-dev-middleware-tests.ts @@ -29,8 +29,22 @@ webpackDevMiddlewareInstance = webpackDevMiddleware(compiler, { const app = express(); app.use([webpackDevMiddlewareInstance]); -webpackDevMiddlewareInstance.close(); -webpackDevMiddlewareInstance.invalidate(); -webpackDevMiddlewareInstance.waitUntilValid(() => { - console.log('Package is in a valid state'); +webpackDevMiddlewareInstance.close(() => { + console.log('closed'); }); + +webpackDevMiddlewareInstance.invalidate((stats) => { + console.log(stats.toJson()); +}); + +webpackDevMiddlewareInstance.waitUntilValid((stats) => { + console.log('Package is in a valid state:' + stats.toJson()); +}); + +const fs = webpackDevMiddlewareInstance.fileSystem; +fs.mkdirpSync('foo'); + +let filename = webpackDevMiddlewareInstance.getFilenameFromUrl('url'); +if (filename !== false) { + filename = filename.substr(0); +} From a26611b24c7a365d5b8697a52f3c893ea19d7499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Wed, 29 Nov 2017 18:18:54 +0800 Subject: [PATCH 239/639] add modal --- types/materialize-css/index.d.ts | 81 +++++++++++++++++++ .../test/materialize-css-global.test.ts | 3 + .../test/materialize-css-jquery.test.ts | 5 ++ .../test/materialize-css-module.test.ts | 26 ++++++ 4 files changed, 115 insertions(+) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index 8c7914f2fd..ebbe4923c4 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -137,6 +137,84 @@ declare global { responsiveThreshold: number; } + class Modal extends Component { + /** + * Get Instance + */ + static getInstance(elem: Element): Modal; + + /** + * Open modal + */ + open(): void; + + /** + * Close modal + */ + close(): void; + + /** + * If the modal is open. + */ + isOpen: boolean; + + /** + * ID of the modal element + */ + id: string; + } + + /** + * Options for the Modal + */ + interface ModalOptions { + /** + * Opacity of the modal overlay. + * @default 0.5 + */ + opacity: number; + + /** + * Transition in duration in milliseconds. + * @default 250 + */ + inDuration: number; + + /** + * Transition out duration in milliseconds. + * @default 250 + */ + outDuration: number; + + /** + * Callback function called when modal is finished entering. + */ + ready: (this: Modal, elem: Element, openingTrigger: Element) => void; + + /** + * Callback function called when modal is finished exiting. + */ + complete: (this: Modal, elem: Element) => void; + + /** + * Allow modal to be dismissed by keyboard or overlay click. + * @default true + */ + dismissible: boolean; + + /** + * Starting top offset + * @default '4%' + */ + startingTop: string; + + /** + * Ending top offset + * @default '10%' + */ + endingTop: string; + } + abstract class Component { /** * Construct component instance and set everything up @@ -168,5 +246,8 @@ declare global { tabs(method: keyof Pick): JQuery; tabs(method: keyof Pick, tabId: string): JQuery; tabs(options?: Partial): JQuery; + + modal(method: keyof Pick): JQuery; + modal(options?: Partial): JQuery; } } diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index 90ca3de1c5..d123c21651 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -4,3 +4,6 @@ const sidenav = new M.Sidenav(elem); // $ExpectType Tabs const tabs = new M.Tabs(elem); + +// $ExpectType Modal +const modal = new M.Modal(elem); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index 543bab8cc2..6fd40b5aa7 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -7,3 +7,8 @@ $(".whatever").tabs(); $(".whatever").tabs({ duration: 200 }); $(".whatever").tabs("destroy"); $(".whatever").tabs("select", "id"); + +$(".whatever").modal(); +$(".whatever").modal({ inDuration: 200 }); +$(".whatever").modal("open"); +$(".whatever").modal("destroy"); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index 14221464c9..edf2ee36ef 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -46,3 +46,29 @@ tabs.select("id"); tabs.options; // $ExpectType number tabs.index; + +// Modal +// $ExpectType Modal +new materialize.Modal(elem); +// $ExpectType Modal +const modal = new materialize.Modal(elem, { + inDuration: 300, + ready(el, trigger) { + // $ExpectType Modal + this; + // $ExpectType Element + el; + // $ExpectType Element + trigger; + } +}); +// $ExpectType void +modal.open(); +// $ExpectType void +modal.destroy(); +// $ExpectType ModalOptions +modal.options; +// $ExpectType Element +modal.el; +// $ExpectType boolean +modal.isOpen; From 9dcd5f175ef0c4717497e6c2a588fdab439f504c Mon Sep 17 00:00:00 2001 From: Evgeny Parkhomenko Date: Wed, 29 Nov 2017 13:36:34 +0300 Subject: [PATCH 240/639] Update index.d.ts --- types/yandex-maps/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/yandex-maps/index.d.ts b/types/yandex-maps/index.d.ts index e397c475cb..168586d042 100644 --- a/types/yandex-maps/index.d.ts +++ b/types/yandex-maps/index.d.ts @@ -1,7 +1,7 @@ // Type definitions for yandex-maps 2.1 // Project: https://github.com/Delagen/typings-yandex-maps // Definitions by: Delagen -// +// // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 From fd9c789d837b0dfdb21ce93c0265bd1828c7ebdf Mon Sep 17 00:00:00 2001 From: Evgeny Parkhomenko Date: Wed, 29 Nov 2017 13:36:52 +0300 Subject: [PATCH 241/639] Update index.d.ts --- types/yandex-maps/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/yandex-maps/index.d.ts b/types/yandex-maps/index.d.ts index 168586d042..bc7d7ae5b6 100644 --- a/types/yandex-maps/index.d.ts +++ b/types/yandex-maps/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/Delagen/typings-yandex-maps // Definitions by: Delagen // - // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 From cd28d1935edf5d07dab7f63555c2d5a8e0f3963b Mon Sep 17 00:00:00 2001 From: Evgeny Parkhomenko Date: Wed, 29 Nov 2017 13:39:54 +0300 Subject: [PATCH 242/639] Update index.d.ts --- types/yandex-maps/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/yandex-maps/index.d.ts b/types/yandex-maps/index.d.ts index bc7d7ae5b6..e717fd5a58 100644 --- a/types/yandex-maps/index.d.ts +++ b/types/yandex-maps/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for yandex-maps 2.1 // Project: https://github.com/Delagen/typings-yandex-maps // Definitions by: Delagen -// // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 From 74c3beb286c0019dbdb048ec08d6ce47afa26498 Mon Sep 17 00:00:00 2001 From: Evgeny Parkhomenko Date: Wed, 29 Nov 2017 13:56:17 +0300 Subject: [PATCH 243/639] Update index.d.ts --- types/yandex-maps/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/yandex-maps/index.d.ts b/types/yandex-maps/index.d.ts index e717fd5a58..94806b9254 100644 --- a/types/yandex-maps/index.d.ts +++ b/types/yandex-maps/index.d.ts @@ -3038,7 +3038,7 @@ declare namespace ymaps { } class Monitor { constructor(dataManager: IDataManager | IOptionManager); - add(name: string[] | string, changeCallback: (event: (object | IEvent)) => void, context: any = null, params: any = null): Monitor; + add(name: string[] | string, changeCallback: (event: (object | IEvent)) => void, context?: any, params?: any): Monitor; forceChange(): Monitor; get(name: string): any; remove(name: string): Monitor; From 53ec42bbcdd9621ab13dfa2537918f622adc9963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Wed, 29 Nov 2017 12:42:27 +0100 Subject: [PATCH 244/639] Adds missing export for lodash/defaultTo. --- types/lodash/defaultTo.d.ts | 2 ++ types/lodash/tsconfig.json | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 types/lodash/defaultTo.d.ts diff --git a/types/lodash/defaultTo.d.ts b/types/lodash/defaultTo.d.ts new file mode 100644 index 0000000000..89fb56505f --- /dev/null +++ b/types/lodash/defaultTo.d.ts @@ -0,0 +1,2 @@ +import { defaultTo } from "./index"; +export = defaultTo; diff --git a/types/lodash/tsconfig.json b/types/lodash/tsconfig.json index 8fdd6ddff3..7e2de20632 100644 --- a/types/lodash/tsconfig.json +++ b/types/lodash/tsconfig.json @@ -6,6 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, + "strictFunctionTypes": false, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ @@ -53,6 +54,7 @@ "deburr.d.ts", "defaults.d.ts", "defaultsDeep.d.ts", + "defaultTo.d.ts", "defer.d.ts", "delay.d.ts", "difference.d.ts", @@ -304,4 +306,4 @@ "zipObject.d.ts", "zipWith.d.ts" ] -} \ No newline at end of file +} From 68a19a76b7c232d1e3dd4e080b4442133609dec1 Mon Sep 17 00:00:00 2001 From: Martin Jakubik Date: Wed, 29 Nov 2017 14:13:23 +0100 Subject: [PATCH 245/639] Add missing RegExp definition and fix route Add the missing RegExp definition for the url params of the route function. Also allow to call the route with the options params. --- types/cypress/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/cypress/index.d.ts b/types/cypress/index.d.ts index f76aad4afb..1ffb365418 100644 --- a/types/cypress/index.d.ts +++ b/types/cypress/index.d.ts @@ -318,9 +318,9 @@ declare namespace Cypress { /** * @see https://on.cypress.io/api/route */ - route(url: string, response?: any): Chainable; - route(method: string, url: string, response?: any): Chainable; - route(fn: () => RouteOptions | RouteOptions): Chainable; + route(url: string | RegExp, response?: any): Chainable; + route(method: string, url: string | RegExp, response?: any): Chainable; + route(fn: (() => RouteOptions) | RouteOptions): Chainable; /** * @see https://on.cypress.io/api/screenshot From ed9e0f6d14d9fb43ae5ff61dfeb213a37b510e91 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Wed, 29 Nov 2017 09:28:28 -0600 Subject: [PATCH 246/639] Update react-autosuggest signatures, documentation, use generic type - Convert Autosuggest component to a generic - Update the renderSuggestionsContainer signature - Add readme with usage example - Document component props - Export function types for easier reuse/passing in as props --- types/react-autosuggest/README.md | 28 ++ types/react-autosuggest/index.d.ts | 245 +++++++++++++----- .../react-autosuggest-tests.tsx | 14 +- 3 files changed, 218 insertions(+), 69 deletions(-) create mode 100644 types/react-autosuggest/README.md diff --git a/types/react-autosuggest/README.md b/types/react-autosuggest/README.md new file mode 100644 index 0000000000..44ff83ecc5 --- /dev/null +++ b/types/react-autosuggest/README.md @@ -0,0 +1,28 @@ +# react-autosuggest usage notes + +The definition uses generics for stronger typing. Read the [TypeScript deep dive on JSX Generic components](https://basarat.gitbooks.io/typescript/docs/jsx/tsx.html#react-jsx-tip-generic-components) for details on consuming these type definitions. + +## Example + +```jsx +import * as Autosuggest from 'react-autosuggest' +interface Language { + name: string + year: number +} + +const LanguageAutosuggest = Autosuggest as { new (): Autosuggest } + + +``` + +Find multiple full examples in `react-autosuggest-tests.tsx` diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index b1f080efe5..4c4d6caaed 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -1,88 +1,205 @@ -// Type definitions for react-autosuggest 9.3 +// Type definitions for react-autosuggest 9.3.2 // Project: http://react-autosuggest.js.org/ // Definitions by: Nicolas Schmitt // Philip Ottesen // Robert Essig // Terry Bayne // Christopher Deutsch +// Kevin Ross // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as React from 'react'; +import * as React from 'react' -declare class Autosuggest extends React.Component {} +declare class Autosuggest extends React.Component> {} -export = Autosuggest; +export = Autosuggest declare namespace Autosuggest { - interface SuggestionsFetchRequest { - value: string; - reason: 'input-changed' | 'input-focused' | 'escape-pressed' | 'suggestions-revealed' | 'suggestion-selected'; - } + /** + * Utilies types based on: + * https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-307871458 + */ - interface InputValues { - value: string; - valueBeforeUpDown?: string; - } + /** @internal */ + type Diff = ({ [P in T]: P } & + { [P in U]: never } & { [x: string]: never })[T] - interface RenderSuggestionParams { - query: string; - isHighlighted: boolean; - } + /** @internal */ + type Omit = Pick> - interface SuggestionHighlightedParams { - suggestion: any; - } + export interface SuggestionsFetchRequestedParams { + value: string + reason: + | 'input-changed' + | 'input-focused' + | 'escape-pressed' + | 'suggestions-revealed' + | 'suggestion-selected' + } - interface ChangeEvent { - newValue: string; - method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type'; - } + export interface RenderSuggestionParams { + query: string + isHighlighted: boolean + } - interface BlurEvent { - highlightedSuggestion: any; - } + export interface SuggestionHighlightedParams { + suggestion: any + } - interface InputProps extends React.InputHTMLAttributes { - value: string; - onChange(event: React.FormEvent, params?: ChangeEvent): void; - onBlur?(event: React.FormEvent, params?: BlurEvent): void; - [key: string]: any; - } + export interface ChangeEvent { + newValue: string + method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type' + } - interface SuggestionSelectedEventData { - suggestion: TSuggestion; - suggestionValue: string; - suggestionIndex: number; - sectionIndex: number | null; - method: 'click' | 'enter'; - } + export interface BlurEvent { + highlightedSuggestion: TSuggestion + } - type ThemeKey = 'container' | 'containerOpen' | 'input' | 'inputOpen' | 'inputFocused' | 'suggestionsContainer' | - 'suggestionsContainerOpen' | 'suggestionsList' | 'suggestion' | 'suggestionFirst' | 'suggestionHighlighted' | - 'sectionContainer' | 'sectionContainerFirst' | 'sectionTitle'; + export interface InputProps + extends Omit, 'onChange' | 'onBlur'> { + onChange(event: React.FormEvent, params?: ChangeEvent): void + onBlur?(event: React.FormEvent, params?: BlurEvent): void + value: string + [key: string]: any + } - type Theme = Record | Partial>; + export interface SuggestionSelectedEventData { + suggestion: TSuggestion + suggestionValue: string + suggestionIndex: number + sectionIndex: number | null + method: 'click' | 'enter' + } - interface AutosuggestProps extends React.Props { - suggestions: any[]; - onSuggestionsFetchRequested(request: SuggestionsFetchRequest): void; - onSuggestionsClearRequested?(): void; - getSuggestionValue(suggestion: any): any; - renderSuggestion(suggestion: any, params: RenderSuggestionParams): JSX.Element; - inputProps: InputProps; - onSuggestionSelected?(event: React.FormEvent, data: SuggestionSelectedEventData): void; - onSuggestionHighlighted?(params: SuggestionHighlightedParams): void; - shouldRenderSuggestions?(value: string): boolean; - alwaysRenderSuggestions?: boolean; - highlightFirstSuggestion?: boolean; - focusInputOnSuggestionClick?: boolean; - multiSection?: boolean; - renderSectionTitle?(section: any): JSX.Element; - getSectionSuggestions?(section: any): any[]; - renderInputComponent?(inputProps: InputProps): JSX.Element; - renderSuggestionsContainer?(containerProps: any, children: any, query: string): JSX.Element; - theme?: Theme; - id?: string; - } + export type ThemeKey = + | 'container' + | 'containerOpen' + | 'input' + | 'inputOpen' + | 'inputFocused' + | 'suggestionsContainer' + | 'suggestionsContainerOpen' + | 'suggestionsList' + | 'suggestion' + | 'suggestionFirst' + | 'suggestionHighlighted' + | 'sectionContainer' + | 'sectionContainerFirst' + | 'sectionTitle' + + export type Theme = + | Record + | Partial> + + export type RenderSuggestionsContainerParams = { + containerProps: { + id: string + key: string + ref: any + style: Object + } + children: React.ReactNode + query: string + } + + // export types for functions - allowing reuse externally - e.g. as props and bound in the constructor + export type GetSectionSuggestions = (section: any) => TSuggestion[] + export type GetSuggestionValue = (suggestion: TSuggestion) => string + export type OnSuggestionHighlighted = (params: SuggestionHighlightedParams) => void + export type SuggestionsFetchRequested = (request: SuggestionsFetchRequestedParams) => void + export type OnSuggestionsClearRequested = () => void + export type OnSuggestionSelected = ( + event: React.FormEvent, + data: SuggestionSelectedEventData, + ) => void + export type RenderInputComponent = ( + inputProps: InputProps, + ) => JSX.Element + export type RenderSuggestionsContainer = (params: RenderSuggestionsContainerParams) => JSX.Element + export type RenderSectionTitle = (section: any) => JSX.Element + export type RenderSuggestion = ( + suggestion: TSuggestion, + params: RenderSuggestionParams, + ) => JSX.Element + export type ShouldRenderSuggestions = (value: string) => boolean + + export interface AutosuggestProps { + /** + * Set it to true if you'd like to render suggestions even when the input is not focused. + */ + alwaysRenderSuggestions?: boolean + /** + * Set it to false if you don't want Autosuggest to keep the input focused when suggestions are clicked/tapped. + */ + focusInputOnSuggestionClick?: boolean + /** + * Implement it to teach Autosuggest where to find the suggestions for every section. + */ + getSectionSuggestions?: GetSectionSuggestions + /** + * Implement it to teach Autosuggest what should be the input value when suggestion is clicked. + */ + getSuggestionValue: GetSuggestionValue + /** + * Set it to true if you'd like Autosuggest to automatically highlight the first suggestion. + */ + highlightFirstSuggestion?: boolean + /** + * Use it only if you have multiple Autosuggest components on a page. + */ + id?: string + /** + * Pass through arbitrary props to the input. It must contain at least value and onChange. + */ + inputProps: InputProps + /** + * Set it to true if you'd like to display suggestions in multiple sections (with optional titles). + */ + multiSection?: boolean + /** + * Will be called every time the highlighted suggestion changes. + */ + onSuggestionHighlighted?: OnSuggestionHighlighted + /** + * Will be called every time you need to recalculate suggestions. + */ + onSuggestionsFetchRequested: SuggestionsFetchRequested + /** + * Will be called every time you need to set suggestions to []. + */ + onSuggestionsClearRequested?: OnSuggestionsClearRequested + /** + * Will be called every time suggestion is selected via mouse or keyboard. + */ + onSuggestionSelected?: OnSuggestionSelected + /** + * Use it only if you need to customize the rendering of the input. + */ + renderInputComponent?: RenderInputComponent + /** + * Use it if you want to customize things inside the suggestions container beyond rendering the suggestions themselves. + */ + renderSuggestionsContainer?: RenderSuggestionsContainer + /** + * Use your imagination to define how section titles are rendered. + */ + renderSectionTitle?: RenderSectionTitle + /** + * Use your imagination to define how suggestions are rendered. + */ + renderSuggestion: RenderSuggestion + /** + * When the input is focused, Autosuggest will consult this function when to render suggestions. Use it, for example, if you want to display suggestions when input value is at least 2 characters long. + */ + shouldRenderSuggestions?: ShouldRenderSuggestions + /** + * These are the suggestions that will be displayed. Items can take an arbitrary shape. + */ + suggestions: TSuggestion[] + /** + * Use your imagination to style the Autosuggest. + */ + theme?: Theme + } } diff --git a/types/react-autosuggest/react-autosuggest-tests.tsx b/types/react-autosuggest/react-autosuggest-tests.tsx index 23841519e4..a8a6268445 100644 --- a/types/react-autosuggest/react-autosuggest-tests.tsx +++ b/types/react-autosuggest/react-autosuggest-tests.tsx @@ -15,6 +15,8 @@ function escapeRegexCharacters(str: string): string { return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } +const LanguageAutosuggest = Autosuggest as { new (): Autosuggest } + export class ReactAutosuggestBasicTest extends React.Component { // region Fields static languages: Language[] = [ @@ -89,7 +91,7 @@ export class ReactAutosuggestBasicTest extends React.Component { sectionTitle: { color: 'blue' } }; - return { .bind(this) }; - return { return {section.title}; } - protected renderInputComponent(inputProps: Autosuggest.InputProps): JSX.Element { + protected renderInputComponent(inputProps: Autosuggest.InputProps): JSX.Element { return (

@@ -280,7 +282,7 @@ export class ReactAutosuggestMultipleTest extends React.Component { ); } - protected renderSuggestionsContainer(containerProps: any, children: any, query: string): JSX.Element { + protected renderSuggestionsContainer({containerProps, children, query}: Autosuggest.RenderSuggestionsContainerParams): JSX.Element { return (
{children} @@ -345,6 +347,8 @@ interface Person { twitter: string; } +const PersonAutosuggest = Autosuggest as { new (): Autosuggest } + export class ReactAutosuggestCustomTest extends React.Component { // region Fields static people: Person[] = [ @@ -386,7 +390,7 @@ export class ReactAutosuggestCustomTest extends React.Component { .bind(this) }; - return Date: Wed, 29 Nov 2017 09:38:47 -0600 Subject: [PATCH 247/639] lint --- types/react-autosuggest/index.d.ts | 155 +++++++++--------- .../react-autosuggest-tests.tsx | 4 +- 2 files changed, 79 insertions(+), 80 deletions(-) diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index 4c4d6caaed..78c11d6878 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-autosuggest 9.3.2 +// Type definitions for react-autosuggest 9.3 // Project: http://react-autosuggest.js.org/ // Definitions by: Nicolas Schmitt // Philip Ottesen @@ -9,11 +9,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as React from 'react' +import * as React from 'react'; declare class Autosuggest extends React.Component> {} -export = Autosuggest +export = Autosuggest; declare namespace Autosuggest { /** @@ -23,56 +23,56 @@ declare namespace Autosuggest { /** @internal */ type Diff = ({ [P in T]: P } & - { [P in U]: never } & { [x: string]: never })[T] + { [P in U]: never } & { [x: string]: never })[T]; /** @internal */ - type Omit = Pick> + type Omit = Pick>; - export interface SuggestionsFetchRequestedParams { - value: string + interface SuggestionsFetchRequestedParams { + value: string; reason: | 'input-changed' | 'input-focused' | 'escape-pressed' | 'suggestions-revealed' - | 'suggestion-selected' + | 'suggestion-selected'; } - export interface RenderSuggestionParams { - query: string - isHighlighted: boolean + interface RenderSuggestionParams { + query: string; + isHighlighted: boolean; } - export interface SuggestionHighlightedParams { - suggestion: any + interface SuggestionHighlightedParams { + suggestion: any; } - export interface ChangeEvent { - newValue: string - method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type' + interface ChangeEvent { + newValue: string; + method: 'down' | 'up' | 'escape' | 'enter' | 'click' | 'type'; } - export interface BlurEvent { - highlightedSuggestion: TSuggestion + interface BlurEvent { + highlightedSuggestion: TSuggestion; } - export interface InputProps + interface InputProps extends Omit, 'onChange' | 'onBlur'> { - onChange(event: React.FormEvent, params?: ChangeEvent): void - onBlur?(event: React.FormEvent, params?: BlurEvent): void - value: string - [key: string]: any + onChange(event: React.FormEvent, params?: ChangeEvent): void; + onBlur?(event: React.FormEvent, params?: BlurEvent): void; + value: string; + [key: string]: any; } - export interface SuggestionSelectedEventData { - suggestion: TSuggestion - suggestionValue: string - suggestionIndex: number - sectionIndex: number | null - method: 'click' | 'enter' + interface SuggestionSelectedEventData { + suggestion: TSuggestion; + suggestionValue: string; + suggestionIndex: number; + sectionIndex: number | null; + method: 'click' | 'enter'; } - export type ThemeKey = + type ThemeKey = | 'container' | 'containerOpen' | 'input' @@ -86,120 +86,119 @@ declare namespace Autosuggest { | 'suggestionHighlighted' | 'sectionContainer' | 'sectionContainerFirst' - | 'sectionTitle' + | 'sectionTitle'; - export type Theme = + type Theme = | Record - | Partial> + | Partial>; - export type RenderSuggestionsContainerParams = { + interface RenderSuggestionsContainerParams { containerProps: { - id: string - key: string - ref: any - style: Object - } - children: React.ReactNode - query: string + id: string; + key: string; + ref: any; + style: any; + }; + children: React.ReactNode; + query: string; } - // export types for functions - allowing reuse externally - e.g. as props and bound in the constructor - export type GetSectionSuggestions = (section: any) => TSuggestion[] - export type GetSuggestionValue = (suggestion: TSuggestion) => string - export type OnSuggestionHighlighted = (params: SuggestionHighlightedParams) => void - export type SuggestionsFetchRequested = (request: SuggestionsFetchRequestedParams) => void - export type OnSuggestionsClearRequested = () => void - export type OnSuggestionSelected = ( + // types for functions - allowing reuse externally - e.g. as props and bound in the constructor + type GetSectionSuggestions = (section: any) => TSuggestion[]; + type GetSuggestionValue = (suggestion: TSuggestion) => string; + type OnSuggestionHighlighted = (params: SuggestionHighlightedParams) => void; + type SuggestionsFetchRequested = (request: SuggestionsFetchRequestedParams) => void; + type OnSuggestionsClearRequested = () => void; + type OnSuggestionSelected = ( event: React.FormEvent, data: SuggestionSelectedEventData, - ) => void - export type RenderInputComponent = ( - inputProps: InputProps, - ) => JSX.Element - export type RenderSuggestionsContainer = (params: RenderSuggestionsContainerParams) => JSX.Element - export type RenderSectionTitle = (section: any) => JSX.Element - export type RenderSuggestion = ( + ) => void; + type RenderInputComponent = (inputProps: InputProps) => JSX.Element; + type RenderSuggestionsContainer = (params: RenderSuggestionsContainerParams) => JSX.Element; + type RenderSectionTitle = (section: any) => JSX.Element; + type RenderSuggestion = ( suggestion: TSuggestion, params: RenderSuggestionParams, - ) => JSX.Element - export type ShouldRenderSuggestions = (value: string) => boolean + ) => JSX.Element; + type ShouldRenderSuggestions = (value: string) => boolean; - export interface AutosuggestProps { + interface AutosuggestProps { /** * Set it to true if you'd like to render suggestions even when the input is not focused. */ - alwaysRenderSuggestions?: boolean + alwaysRenderSuggestions?: boolean; /** * Set it to false if you don't want Autosuggest to keep the input focused when suggestions are clicked/tapped. */ - focusInputOnSuggestionClick?: boolean + focusInputOnSuggestionClick?: boolean; /** * Implement it to teach Autosuggest where to find the suggestions for every section. */ - getSectionSuggestions?: GetSectionSuggestions + getSectionSuggestions?: GetSectionSuggestions; /** * Implement it to teach Autosuggest what should be the input value when suggestion is clicked. */ - getSuggestionValue: GetSuggestionValue + getSuggestionValue: GetSuggestionValue; /** * Set it to true if you'd like Autosuggest to automatically highlight the first suggestion. */ - highlightFirstSuggestion?: boolean + highlightFirstSuggestion?: boolean; /** * Use it only if you have multiple Autosuggest components on a page. */ - id?: string + id?: string; /** * Pass through arbitrary props to the input. It must contain at least value and onChange. */ - inputProps: InputProps + inputProps: InputProps; /** * Set it to true if you'd like to display suggestions in multiple sections (with optional titles). */ - multiSection?: boolean + multiSection?: boolean; /** * Will be called every time the highlighted suggestion changes. */ - onSuggestionHighlighted?: OnSuggestionHighlighted + onSuggestionHighlighted?: OnSuggestionHighlighted; /** * Will be called every time you need to recalculate suggestions. */ - onSuggestionsFetchRequested: SuggestionsFetchRequested + onSuggestionsFetchRequested: SuggestionsFetchRequested; /** * Will be called every time you need to set suggestions to []. */ - onSuggestionsClearRequested?: OnSuggestionsClearRequested + onSuggestionsClearRequested?: OnSuggestionsClearRequested; /** * Will be called every time suggestion is selected via mouse or keyboard. */ - onSuggestionSelected?: OnSuggestionSelected + onSuggestionSelected?: OnSuggestionSelected; /** * Use it only if you need to customize the rendering of the input. */ - renderInputComponent?: RenderInputComponent + renderInputComponent?: RenderInputComponent; /** * Use it if you want to customize things inside the suggestions container beyond rendering the suggestions themselves. */ - renderSuggestionsContainer?: RenderSuggestionsContainer + renderSuggestionsContainer?: RenderSuggestionsContainer; /** * Use your imagination to define how section titles are rendered. */ - renderSectionTitle?: RenderSectionTitle + renderSectionTitle?: RenderSectionTitle; /** * Use your imagination to define how suggestions are rendered. */ - renderSuggestion: RenderSuggestion + renderSuggestion: RenderSuggestion; /** - * When the input is focused, Autosuggest will consult this function when to render suggestions. Use it, for example, if you want to display suggestions when input value is at least 2 characters long. + * When the input is focused, Autosuggest will consult this function when to render suggestions. + * Use it, for example, if you want to display suggestions when input value is at least 2 characters long. */ - shouldRenderSuggestions?: ShouldRenderSuggestions + shouldRenderSuggestions?: ShouldRenderSuggestions; /** * These are the suggestions that will be displayed. Items can take an arbitrary shape. */ - suggestions: TSuggestion[] + suggestions: TSuggestion[]; /** * Use your imagination to style the Autosuggest. */ - theme?: Theme + theme?: Theme; } } diff --git a/types/react-autosuggest/react-autosuggest-tests.tsx b/types/react-autosuggest/react-autosuggest-tests.tsx index a8a6268445..753af3a552 100644 --- a/types/react-autosuggest/react-autosuggest-tests.tsx +++ b/types/react-autosuggest/react-autosuggest-tests.tsx @@ -15,7 +15,7 @@ function escapeRegexCharacters(str: string): string { return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } -const LanguageAutosuggest = Autosuggest as { new (): Autosuggest } +const LanguageAutosuggest = Autosuggest as { new (): Autosuggest }; export class ReactAutosuggestBasicTest extends React.Component { // region Fields @@ -347,7 +347,7 @@ interface Person { twitter: string; } -const PersonAutosuggest = Autosuggest as { new (): Autosuggest } +const PersonAutosuggest = Autosuggest as { new (): Autosuggest }; export class ReactAutosuggestCustomTest extends React.Component { // region Fields From c404dc4c0a41f7837ccaef9e5eac9e61fa1d2af4 Mon Sep 17 00:00:00 2001 From: Paul Selden Date: Wed, 29 Nov 2017 10:39:19 -0500 Subject: [PATCH 248/639] [mobx-apollo] data in the query result can potentially be undefined --- types/mobx-apollo/index.d.ts | 2 +- types/mobx-apollo/mobx-apollo-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/mobx-apollo/index.d.ts b/types/mobx-apollo/index.d.ts index 4054601717..54818cd846 100644 --- a/types/mobx-apollo/index.d.ts +++ b/types/mobx-apollo/index.d.ts @@ -19,7 +19,7 @@ export interface MobxApolloQueryOptions extends WatchQueryOptions { export interface MobxApolloQuery { loading: boolean; - data: T; + data?: T; error?: ApolloError; ref: ObservableQuery; } diff --git a/types/mobx-apollo/mobx-apollo-tests.ts b/types/mobx-apollo/mobx-apollo-tests.ts index 964e6b0c6e..50d6b03abb 100644 --- a/types/mobx-apollo/mobx-apollo-tests.ts +++ b/types/mobx-apollo/mobx-apollo-tests.ts @@ -27,7 +27,7 @@ class PostStore { } get posts() { - return this.postsQuery.data.posts; + return this.postsQuery.data && this.postsQuery.data.posts; } } From cc63ad87828c66ea33f7ebfdf0a20ed922466a95 Mon Sep 17 00:00:00 2001 From: Daphne Date: Wed, 29 Nov 2017 16:54:02 +0100 Subject: [PATCH 249/639] Added disableInteractiveElementBlocking property which was missing See docs. Props of ``` disableInteractiveElementBlocking: An optional flag to opt out of blocking a drag from interactive elements. For more information refer to the section Interactive child elements within a Draggable ``` --- types/react-beautiful-dnd/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-beautiful-dnd/index.d.ts b/types/react-beautiful-dnd/index.d.ts index 785c91c889..7bca09f9c3 100644 --- a/types/react-beautiful-dnd/index.d.ts +++ b/types/react-beautiful-dnd/index.d.ts @@ -99,6 +99,7 @@ export interface DraggableProps { draggableId: DroppableId; type?: TypeId; isDragDisabled?: boolean; + disableInteractiveElementBlocking?: boolean; children(provided: DraggableProvided, snapshot: DraggableStateSnapshot): React.ReactElement; } From 5ccdf36eeb0834f1dde116a280911cdf276846d3 Mon Sep 17 00:00:00 2001 From: daphnes Date: Wed, 29 Nov 2017 16:56:42 +0100 Subject: [PATCH 250/639] Added test for disableInteractiveElementBlocking prop for react-beautiful-dnd --- types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx index 3efc2529ce..8f961e0c7a 100644 --- a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx +++ b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx @@ -73,7 +73,7 @@ class App extends React.Component<{}, AppState> { style={getListStyle(snapshot.isDraggingOver)} > {this.state.items.map(item => ( - + {(provided, snapshot) => (
Date: Thu, 30 Nov 2017 00:24:08 +0800 Subject: [PATCH 251/639] add autocomplete and characterCounter --- types/materialize-css/index.d.ts | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index ebbe4923c4..4ff883aea8 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -10,6 +10,73 @@ export = M; declare global { namespace M { + class Autocomplete extends Component{ + /** + * Get Instance + */ + static getInstance(elem: Element): Autocomplete; + + /** + * Select a specific autocomplete options. + * @param el Element of the autocomplete option. + */ + selectOption(el: Element): void; + + /** + * Update autocomplete options data. + * @param data Autocomplete options data object. + */ + updateData(data: AutocompleteOptions): void; + + /** + * If the autocomplete is open. + */ + isOpen: boolean; + + /** + * Number of matching autocomplete options. + */ + count: number; + + /** + * Index of the current selected option. + */ + activeIndex: number; + } + + interface AutocompleteData { + [key: string]: string | null + } + + interface AutocompleteOptions { + /** + * Data object defining autocomplete options with optional icon strings. + */ + data: AutocompleteData; + + /** + * Limit of results the autocomplete shows. + * @default infinity + */ + limit: number; + + /** + * Callback for when autocompleted. + */ + onAutocomplete: (this: Autocomplete, text: string) => void; + + /** + * Minimum number of characters before autocomplete starts. + * @default 1 + */ + minLength: number; + + /** + * Sort function that defines the order of the list of autocomplete options. + */ + sortFunction: (a: string, b: string, inputText: string) => number; + } + class Sidenav extends Component { /** * Get Instance @@ -215,6 +282,17 @@ declare global { endingTop: string; } + function updateTextFields(): void; + + class CharacterCounter extends Component{ + /** + * Get Instance + */ + static getInstance(elem: Element): CharacterCounter + } + + interface CharacterCounterOptions { } + abstract class Component { /** * Construct component instance and set everything up @@ -240,6 +318,11 @@ declare global { interface JQuery { // Pick to check methods exist. + autocomplete(method: keyof Pick): JQuery; + autocomplete(method: keyof Pick, el: Element): JQuery; + autocomplete(method: keyof Pick, data: M.AutocompleteData): JQuery; + autocomplete(options?: Partial): JQuery; + sidenav(method: keyof Pick): JQuery; sidenav(options?: Partial): JQuery; @@ -249,5 +332,7 @@ declare global { modal(method: keyof Pick): JQuery; modal(options?: Partial): JQuery; + + characterCounter(options?: Partial): JQuery } } From 7ad519fb2d855691059a00aa4d69624305ea3fc8 Mon Sep 17 00:00:00 2001 From: swist Date: Wed, 29 Nov 2017 12:11:05 +0000 Subject: [PATCH 252/639] Adds types for moment-business-time@0.7.1 --- types/moment-business-time/index.d.ts | 41 ++++++++++++++ .../moment-business-time-tests.ts | 56 +++++++++++++++++++ types/moment-business-time/tsconfig.json | 23 ++++++++ types/moment-business-time/tslint.json | 1 + 4 files changed, 121 insertions(+) create mode 100644 types/moment-business-time/index.d.ts create mode 100644 types/moment-business-time/moment-business-time-tests.ts create mode 100644 types/moment-business-time/tsconfig.json create mode 100644 types/moment-business-time/tslint.json diff --git a/types/moment-business-time/index.d.ts b/types/moment-business-time/index.d.ts new file mode 100644 index 0000000000..dc4022f161 --- /dev/null +++ b/types/moment-business-time/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for moment-business-time 0.7 +// Project: https://github.com/lennym/moment-business-time +// Definitions by: Tomasz Nguyen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ On this line, import the module which this module adds to */ +import * as moment from 'moment'; + +/*~ Here, declare the same module as the one you imported above */ +declare module 'moment' { + interface Moment { + nextWorkingDay: () => Moment; + nextWorkingTime: () => Moment; + + lastWorkingDay: () => Moment; + lastWorkingTime: () => Moment; + + addWorkingTime: (...args: Array) => Moment; + subtractWorkingTime: (...args: Array) => Moment; + + workingDiff: (moment: Moment, unit: unitOfTime.Base, fractions?: boolean) => Moment; + + isWorkingDay: () => boolean; + isWorkingTime: () => boolean; + } + + interface WorkingHoursMap { + 0: string[] | null; + 1: string[] | null; + 2: string[] | null; + 3: string[] | null; + 4: string[] | null; + 5: string[] | null; + 6: string[] | null; + } + + interface LocaleSpecification { + workinghours?: WorkingHoursMap; + holidays?: string[]; + } +} diff --git a/types/moment-business-time/moment-business-time-tests.ts b/types/moment-business-time/moment-business-time-tests.ts new file mode 100644 index 0000000000..79f25a720a --- /dev/null +++ b/types/moment-business-time/moment-business-time-tests.ts @@ -0,0 +1,56 @@ +import * as moment from 'moment'; +import 'moment-business-time'; + +moment('2015-02-28T10:00:00Z').nextWorkingDay(); +moment('2015-02-28T20:00:00Z').nextWorkingDay(); +moment('2015-02-28T10:00:00Z').nextWorkingTime(); +moment('2015-02-28T20:00:00Z').nextWorkingTime(); +moment('2015-02-28T10:00:00Z').lastWorkingDay(); +// Fri Feb 27 2015 10:00:00 GMT+0000 +moment('2015-02-28T20:00:00Z').lastWorkingDay(); +// Fri Feb 27 2015 20:00:00 GMT+0000 +moment('2015-02-27T10:00:00Z').addWorkingTime(5, 'hours'); +// Fri Feb 27 2015 15:00:00 GMT+0000 +moment('2015-02-28T10:00:00Z').addWorkingTime(5, 'hours'); +// Mon Mar 02 2015 14:00:00 GMT+0000 +moment('2015-02-27T10:00:00Z').addWorkingTime(5, 'hours', 30, 'minutes'); +// Fri Feb 27 2015 15:30:00 GMT+0000 +moment('2015-02-27T16:00:00Z').subtractWorkingTime(5, 'hours'); +// Fri Feb 27 2015 11:00:00 GMT+0000 +moment('2015-02-28T16:00:00Z').subtractWorkingTime(5, 'hours'); +// Fri Feb 27 2015 12:00:00 GMT+0000 +moment('2015-02-27T16:00:00Z').subtractWorkingTime(5, 'hours', 30, 'minutes'); +// Fri Feb 27 2015 10:30:00 GMT+0000 +moment('2015-02-27T16:30:00Z').workingDiff(moment('2015-02-26T12:00:00Z'), 'hours'); +// 12 +moment('2015-02-27T16:30:00Z').workingDiff(moment('2015-02-26T12:00:00Z'), 'hours', true); +// 12.5 +// set opening time to 09:30 and close early on Wednesdays +moment.updateLocale('en', { + workinghours: { + 0: null, + 1: ['09:30:00', '17:00:00'], + 2: ['09:30:00', '17:00:00'], + 3: ['09:30:00', '13:00:00'], + 4: ['09:30:00', '17:00:00'], + 5: ['09:30:00', '17:00:00'], + 6: null + } +}); +moment('2015-02-25T15:00:00Z').isWorkingTime(); // false +moment('2015-02-23T09:00:00Z').isWorkingTime(); // false +moment.updateLocale('en', { + holidays: [ + '2015-05-04' + ] +}); +moment('2015-05-04T09:30:00Z').isWorkingDay(); // false +moment.updateLocale('en', { + holidays: [ + '*-12-25' + ] +}); +moment('2015-12-25T16:30:00Z').isWorkingDay(); // false +moment('2016-12-25T16:30:00Z').isWorkingDay(); // false +moment('2017-12-25T16:30:00Z').isWorkingDay(); // false +moment('2018-12-25T16:30:00Z').isWorkingDay(); // false diff --git a/types/moment-business-time/tsconfig.json b/types/moment-business-time/tsconfig.json new file mode 100644 index 0000000000..c1212caa2f --- /dev/null +++ b/types/moment-business-time/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "moment-business-time-tests.ts" + ] +} diff --git a/types/moment-business-time/tslint.json b/types/moment-business-time/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moment-business-time/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From fdc661f9135abce9d37084a5ca07c301581f7421 Mon Sep 17 00:00:00 2001 From: Alejandro Haro Date: Wed, 29 Nov 2017 16:42:32 +0000 Subject: [PATCH 253/639] nock: scope.persist(flag?:boolean) --- types/nock/index.d.ts | 6 ++++-- types/nock/nock-tests.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/types/nock/index.d.ts b/types/nock/index.d.ts index 180100a33f..0f420ebeba 100644 --- a/types/nock/index.d.ts +++ b/types/nock/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for nock v8.2.0 // Project: https://github.com/node-nock/nock -// Definitions by: bonnici , Horiuchi_H +// Definitions by: bonnici +// Horiuchi_H +// afharo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -67,7 +69,7 @@ declare namespace nock { filteringRequestBody(fn: (body: string) => string): this; log(out: () => void): this; - persist(): this; + persist(flag?: boolean): this; shouldPersist(): boolean; replyContentLength(): this; replyDate(d?: Date): this; diff --git a/types/nock/nock-tests.ts b/types/nock/nock-tests.ts index 8c2d48e736..bd11acc8a8 100644 --- a/types/nock/nock-tests.ts +++ b/types/nock/nock-tests.ts @@ -108,6 +108,7 @@ scope = scope.filteringRequestBody((path: string) => { scope = scope.log(() => { }); scope = scope.persist(); +scope = scope.persist(false); bool = scope.shouldPersist(); scope = scope.replyContentLength(); scope = scope.replyDate(); From 6df83868b168ce23f5446cdb0384aa0e632a9c6c Mon Sep 17 00:00:00 2001 From: Alejandro Haro Date: Wed, 29 Nov 2017 16:47:06 +0000 Subject: [PATCH 254/639] nock: Match version with current nock package version --- types/nock/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/nock/index.d.ts b/types/nock/index.d.ts index 0f420ebeba..f216fd411a 100644 --- a/types/nock/index.d.ts +++ b/types/nock/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for nock v8.2.0 +// Type definitions for nock v9.1.3 // Project: https://github.com/node-nock/nock // Definitions by: bonnici // Horiuchi_H From 68baa16088ceec61be481c04b602e1eefa9c51fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Thu, 30 Nov 2017 01:25:52 +0800 Subject: [PATCH 255/639] add Autocomplete --- types/materialize-css/index.d.ts | 98 +++++++++++++++++-- .../test/materialize-css-global.test.ts | 9 ++ .../test/materialize-css-jquery.test.ts | 18 +++- .../test/materialize-css-module.test.ts | 68 +++++++++++++ 4 files changed, 183 insertions(+), 10 deletions(-) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index 4ff883aea8..ebc997c51f 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -10,7 +10,7 @@ export = M; declare global { namespace M { - class Autocomplete extends Component{ + class Autocomplete extends Component { /** * Get Instance */ @@ -26,7 +26,7 @@ declare global { * Update autocomplete options data. * @param data Autocomplete options data object. */ - updateData(data: AutocompleteOptions): void; + updateData(data: AutocompleteData): void; /** * If the autocomplete is open. @@ -45,7 +45,7 @@ declare global { } interface AutocompleteData { - [key: string]: string | null + [key: string]: string | null; } interface AutocompleteOptions { @@ -282,16 +282,91 @@ declare global { endingTop: string; } - function updateTextFields(): void; - - class CharacterCounter extends Component{ + class Tooltip extends Component { /** * Get Instance */ - static getInstance(elem: Element): CharacterCounter + static getInstance(elem: Element): Tooltip; + + /** + * Show tooltip. + */ + open(): void; + + /** + * Hide tooltip. + */ + close(): void; + + /** + * If tooltip is open. + */ + isOpen: boolean; + + /** + * If tooltip is hovered. + */ + isHovered: boolean; } - interface CharacterCounterOptions { } + interface TooltipOptions { + /** + * Delay time before tooltip disappears. + * @default 0 + */ + exitDelay: number; + + /** + * Delay time before tooltip appears. + * @default 200 + */ + enterDelay: number; + + /** + * Can take regular text or HTML strings. + * @default null + */ + html: string | null; + + /** + * Set distance tooltip appears away from its activator excluding transitionMovement. + * @default 5 + */ + margin: number; + + /** + * Enter transition duration. + * @default 300 + */ + inDuration: number; + + /** + * Exit transition duration. + * @default 250 + */ + outDuration: number; + + /** + * Set the direction of the tooltip. + * @default 'bottom' + */ + position: 'top' | 'right' | 'bottom' | 'left'; + + /** + * Amount in px that the tooltip moves during its transition. + * @default 10 + */ + transitionMovement: number; + } + + function updateTextFields(): void; + + class CharacterCounter extends Component { + /** + * Get Instance + */ + static getInstance(elem: Element): CharacterCounter; + } abstract class Component { /** @@ -330,9 +405,14 @@ declare global { tabs(method: keyof Pick, tabId: string): JQuery; tabs(options?: Partial): JQuery; + tooltip(method: keyof Pick): JQuery; + tooltip(options?: Partial): JQuery; + modal(method: keyof Pick): JQuery; modal(options?: Partial): JQuery; - characterCounter(options?: Partial): JQuery + // tslint:disable-next-line unified-signatures + characterCounter(method: keyof Pick): JQuery; + characterCounter(): JQuery; } } diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index d123c21651..fa228b444f 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -7,3 +7,12 @@ const tabs = new M.Tabs(elem); // $ExpectType Modal const modal = new M.Modal(elem); + +// $ExpectType Autocomplete +const autocomplete = new M.Autocomplete(elem); + +// $ExpectType CharacterCounter +const characterCounter = new M.CharacterCounter(elem); + +// $ExpectType Tooltip +const tooltips = new M.Tooltip(elem); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index 6fd40b5aa7..42af7fcefd 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -1,5 +1,5 @@ $(".whatever").sidenav(); -$(".whatever").sidenav({inDuration: 200}); +$(".whatever").sidenav({ inDuration: 200 }); $(".whatever").sidenav("open"); $(".whatever").sidenav("destroy"); @@ -12,3 +12,19 @@ $(".whatever").modal(); $(".whatever").modal({ inDuration: 200 }); $(".whatever").modal("open"); $(".whatever").modal("destroy"); + +$(".whatever").characterCounter(); +$(".whatever").characterCounter("destroy"); + +$(".whatever").autocomplete({ + data: { + Apple: null, + Google: "https://placehold.it/250x250" + } +}); +$(".whatever").autocomplete("updateData", { Microsoft: null }); + +$(".whatever").tooltip(); +$(".whatever").tooltip({ html: "" }); +$(".whatever").tooltip("open"); +$(".whatever").tooltip("destroy"); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index edf2ee36ef..2665586b5d 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -29,6 +29,8 @@ sidenav.isOpen; // Tabs // $ExpectType Tabs +new materialize.Tabs(elem); +// $ExpectType Tabs const tabs = new materialize.Tabs(elem, { duration: 200, onShow(content) { @@ -44,6 +46,8 @@ tabs.destroy(); tabs.select("id"); // $ExpectType TabsOptions tabs.options; +// $ExpectType Element +tabs.el; // $ExpectType number tabs.index; @@ -72,3 +76,67 @@ modal.options; modal.el; // $ExpectType boolean modal.isOpen; + +// CharacterCounter +// $ExpectType CharacterCounter +const characterCounter = new materialize.CharacterCounter(elem); +// $ExpectType void +characterCounter.destroy(); +// $ExpectType Element +characterCounter.el; + +// Autocomplete +// $ExpectType Autocomplete +new materialize.Autocomplete(elem); +// $ExpectType Autocomplete +const autocomplete = new materialize.Autocomplete(elem, { + data: { + Apple: null, + Google: "https://placehold.it/250x250" + }, + minLength: 3, + onAutocomplete(text) { + // $ExpectType Autocomplete + this; + // $ExpectType string + text; + }, + sortFunction(a, b, input) { + // $ExpectType string + a; + // $ExpectType string + b; + // $ExpectType string + input; + return 0; + } +}); +// $ExpectType void +autocomplete.updateData({ Microsoft: null }); +// $ExpectType void +autocomplete.destroy(); +// $ExpectType AutocompleteOptions +autocomplete.options; +// $ExpectType Element +autocomplete.el; +// $ExpectType boolean +autocomplete.isOpen; + +// Tooltip +// $ExpectType Tooltip +new materialize.Tooltip(elem); +// $ExpectType Tooltip +const tooltip = new materialize.Tooltip(elem, { + inDuration: 300, + position: "right" +}); +// $ExpectType void +tooltip.open(); +// $ExpectType void +tooltip.destroy(); +// $ExpectType TooltipOptions +tooltip.options; +// $ExpectType Element +tooltip.el; +// $ExpectType boolean +tooltip.isOpen; From 6a4d20e5d3dd51b24b8ff362244b2dc2f27864aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Thu, 30 Nov 2017 01:58:38 +0800 Subject: [PATCH 256/639] fix travis-ci build error --- types/materialize-css/v0/tsconfig.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/materialize-css/v0/tsconfig.json b/types/materialize-css/v0/tsconfig.json index 770e3cce3f..4f000774ea 100644 --- a/types/materialize-css/v0/tsconfig.json +++ b/types/materialize-css/v0/tsconfig.json @@ -13,6 +13,11 @@ "typeRoots": [ "../../" ], + "paths": { + "materialize-css": [ + "materialize-css/v0" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From c14a1c5e2eb18607827408463dfbda1b9c4b9f03 Mon Sep 17 00:00:00 2001 From: LeoTindall Date: Wed, 29 Nov 2017 12:09:45 -0600 Subject: [PATCH 257/639] [chart.js] Allow plugins options to be of any type. --- types/chart.js/chart.js-tests.ts | 3 ++- types/chart.js/index.d.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/chart.js/chart.js-tests.ts b/types/chart.js/chart.js-tests.ts index 9ec7fde23f..d1e86fd317 100644 --- a/types/chart.js/chart.js-tests.ts +++ b/types/chart.js/chart.js-tests.ts @@ -44,7 +44,8 @@ const chart: Chart = new Chart(new CanvasRenderingContext2D(), { zeroLineBorderDashOffset: 2 } }] - } + }, + plugins: { arbitraryPlugin: {option: "value"} } } }); chart.update(); diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 049488f8db..7d18eb39a8 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -176,6 +176,8 @@ declare namespace Chart { cutoutPercentage?: number; circumference?: number; rotation?: number; + // Plugins can require any options + plugins?: any; } interface ChartFontOptions { From e2ec165c87388041342988f6d82c17511903c454 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 13:26:37 -0500 Subject: [PATCH 258/639] Add jschannel --- types/jschannel/index.d.ts | 46 ++++++++++++++++++++++++++++++ types/jschannel/jschannel-tests.ts | 0 types/jschannel/tsconfig.json | 22 ++++++++++++++ types/jschannel/tslint.json | 1 + 4 files changed, 69 insertions(+) create mode 100644 types/jschannel/index.d.ts create mode 100644 types/jschannel/jschannel-tests.ts create mode 100644 types/jschannel/tsconfig.json create mode 100644 types/jschannel/tslint.json diff --git a/types/jschannel/index.d.ts b/types/jschannel/index.d.ts new file mode 100644 index 0000000000..13946e83ee --- /dev/null +++ b/types/jschannel/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for jschannel 1.0.2 +// Project: https://github.com/yochannah/jschannel +// Definitions by: Yitzchok Gottlieb +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export as namespace Channel; + +export function build(config: ChannelConfiguration): MessagingChannel; + +interface MessagingChannel { + unbind: (method: string, doNotPublish?: boolean) => boolean; + bind: (method: string, callback?: (transaction: MessageTransaction, params: any) => void, doNotPublish?: boolean) => MessagingChannel; + call: (message: Message) => void; + notify: (message: Message) => void; + destroy: () => void; +} + +export interface Message { + method: string; + success?: (result: any) => void; + params?: any; + timeout?: number; + error?: (error: any, message: string) => void; +} + +export interface ChannelConfiguration { + window: any; + origin: string; + scope: string; + debugOutput?: boolean; + postMessageObserver?: (origin: string, message: Message) => void; + gotMessageObserver?: (origin: string, message: Message) => void; + onReady?: (channel: MessagingChannel) => void; + reconnect?: boolean; + publish?: boolean; + remote?: string | ReadonlyArray; +} + +export interface MessageTransaction { + delayReturn: (delay: boolean) => boolean; + complete: (result: any) => void; + error: (error: any, message: string) => void; + invoke: (callbackName: string, params: any) => void; + completed: () => boolean; +} diff --git a/types/jschannel/jschannel-tests.ts b/types/jschannel/jschannel-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/jschannel/tsconfig.json b/types/jschannel/tsconfig.json new file mode 100644 index 0000000000..96fdb53367 --- /dev/null +++ b/types/jschannel/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jschannel-tests.ts" + ] +} diff --git a/types/jschannel/tslint.json b/types/jschannel/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jschannel/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 3ca88e4d179584c1da245831889ea7a2c5346fb4 Mon Sep 17 00:00:00 2001 From: Dasa Paddock Date: Wed, 29 Nov 2017 11:35:27 -0800 Subject: [PATCH 259/639] Make `install` parameter `opts` optional --- types/lolex/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lolex/index.d.ts b/types/lolex/index.d.ts index 510cb911ec..68f87793d9 100644 --- a/types/lolex/index.d.ts +++ b/types/lolex/index.d.ts @@ -217,4 +217,4 @@ export interface LolexInstallOpts { * @param toFake Names of methods that should be faked. * @type TClock Type of clock to create. */ -export declare function install(opts: LolexInstallOpts): TClock; +export declare function install(opts?: LolexInstallOpts): TClock; From 9425d106e397826fe9442be0d7925c38e7f1b73c Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 29 Nov 2017 20:09:02 +0000 Subject: [PATCH 260/639] Types for add-zero --- types/add-zero/add-zero-tests.ts | 3 +++ types/add-zero/index.d.ts | 6 ++++++ types/add-zero/tsconfig.json | 22 ++++++++++++++++++++++ types/add-zero/tslint.json | 1 + 4 files changed, 32 insertions(+) create mode 100644 types/add-zero/add-zero-tests.ts create mode 100644 types/add-zero/index.d.ts create mode 100644 types/add-zero/tsconfig.json create mode 100644 types/add-zero/tslint.json diff --git a/types/add-zero/add-zero-tests.ts b/types/add-zero/add-zero-tests.ts new file mode 100644 index 0000000000..9f52ace86e --- /dev/null +++ b/types/add-zero/add-zero-tests.ts @@ -0,0 +1,3 @@ +import addZero from "add-zero"; + +addZero(5, 2); \ No newline at end of file diff --git a/types/add-zero/index.d.ts b/types/add-zero/index.d.ts new file mode 100644 index 0000000000..1380b84ce9 --- /dev/null +++ b/types/add-zero/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for add-zero 1.0 +// Project: https://github.com/rafaelrinaldi/add-zero#readme +// Definitions by: Giles Roadnight +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default function addZero(value: any, digits?: number): string; \ No newline at end of file diff --git a/types/add-zero/tsconfig.json b/types/add-zero/tsconfig.json new file mode 100644 index 0000000000..fe18a9a603 --- /dev/null +++ b/types/add-zero/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "add-zero-tests.ts" + ] +} diff --git a/types/add-zero/tslint.json b/types/add-zero/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/add-zero/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d83fb362f4d7beee79d666902caf5a5743fd620a Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 29 Nov 2017 20:16:27 +0000 Subject: [PATCH 261/639] Fixed linting errors --- types/add-zero/add-zero-tests.ts | 2 +- types/add-zero/index.d.ts | 2 +- types/add-zero/tsconfig.json | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/add-zero/add-zero-tests.ts b/types/add-zero/add-zero-tests.ts index 9f52ace86e..ac0509d26d 100644 --- a/types/add-zero/add-zero-tests.ts +++ b/types/add-zero/add-zero-tests.ts @@ -1,3 +1,3 @@ import addZero from "add-zero"; -addZero(5, 2); \ No newline at end of file +addZero(5, 2); diff --git a/types/add-zero/index.d.ts b/types/add-zero/index.d.ts index 1380b84ce9..907364a62d 100644 --- a/types/add-zero/index.d.ts +++ b/types/add-zero/index.d.ts @@ -3,4 +3,4 @@ // Definitions by: Giles Roadnight // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default function addZero(value: any, digits?: number): string; \ No newline at end of file +export default function addZero(value: string | number, digits?: number): string; diff --git a/types/add-zero/tsconfig.json b/types/add-zero/tsconfig.json index fe18a9a603..e71d235cdf 100644 --- a/types/add-zero/tsconfig.json +++ b/types/add-zero/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From e2c4cb4b3c1ea3e32ab8e6609f55deb0e5b7d0db Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 29 Nov 2017 20:22:10 +0000 Subject: [PATCH 262/639] types for parse-ms --- types/parse-ms/index.d.ts | 12 ++++++++++++ types/parse-ms/parse-ms-tests.ts | 3 +++ types/parse-ms/tsconfig.json | 23 +++++++++++++++++++++++ types/parse-ms/tslint.json | 1 + 4 files changed, 39 insertions(+) create mode 100644 types/parse-ms/index.d.ts create mode 100644 types/parse-ms/parse-ms-tests.ts create mode 100644 types/parse-ms/tsconfig.json create mode 100644 types/parse-ms/tslint.json diff --git a/types/parse-ms/index.d.ts b/types/parse-ms/index.d.ts new file mode 100644 index 0000000000..9bf9f23c87 --- /dev/null +++ b/types/parse-ms/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for parse-ms 1.0 +// Project: https://github.com/sindresorhus/parse-ms#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default function parseMs(ms: number): { + days: number; + hours: number; + minutes: number; + seconds: number; + milliseconds: number; +}; diff --git a/types/parse-ms/parse-ms-tests.ts b/types/parse-ms/parse-ms-tests.ts new file mode 100644 index 0000000000..2b747ad5a8 --- /dev/null +++ b/types/parse-ms/parse-ms-tests.ts @@ -0,0 +1,3 @@ +import parseMs from "parse-ms"; + +const { days, hours, milliseconds, minutes, seconds } = parseMs(3000); diff --git a/types/parse-ms/tsconfig.json b/types/parse-ms/tsconfig.json new file mode 100644 index 0000000000..3fecf7615f --- /dev/null +++ b/types/parse-ms/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "parse-ms-tests.ts" + ] +} diff --git a/types/parse-ms/tslint.json b/types/parse-ms/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/parse-ms/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 14aa81e896eacf15fdc9a8eadf981acb2eada867 Mon Sep 17 00:00:00 2001 From: Ryan Rowland Date: Wed, 29 Nov 2017 12:39:01 -0800 Subject: [PATCH 263/639] [ws] Add removeEventListener and removeListener --- types/ws/index.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/types/ws/index.d.ts b/types/ws/index.d.ts index bbb589a76d..75acbef87b 100644 --- a/types/ws/index.d.ts +++ b/types/ws/index.d.ts @@ -62,6 +62,15 @@ declare class WebSocket extends events.EventEmitter { addEventListener(method: 'open', cb?: (event: { target: WebSocket }) => void): void; addEventListener(method: string, listener?: () => void): void; + removeEventListener(method: 'message', cb?: (event: { data: any; type: string; target: WebSocket }) => void): void; + removeEventListener(method: 'close', cb?: (event: { + wasClean: boolean; code: number; + reason: string; target: WebSocket + }) => void): void; + removeEventListener(method: 'error', cb?: (err: Error) => void): void; + removeEventListener(method: 'open', cb?: (event: { target: WebSocket }) => void): void; + removeEventListener(method: string, listener?: () => void): void; + // Events on(event: 'close', listener: (code: number, reason: string) => void): this; on(event: 'error', listener: (err: Error) => void): this; @@ -80,6 +89,15 @@ declare class WebSocket extends events.EventEmitter { addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this; addListener(event: 'unexpected-response', listener: (request: http.ClientRequest, response: http.IncomingMessage) => void): this; addListener(event: string | symbol, listener: (...args: any[]) => void): this; + + removeListener(event: 'close', listener: (code: number, message: string) => void): this; + removeListener(event: 'error', listener: (err: Error) => void): this; + removeListener(event: 'headers', listener: (headers: {}, request: http.IncomingMessage) => void): this; + removeListener(event: 'message', listener: (data: WebSocket.Data) => void): this; + removeListener(event: 'open' , listener: () => void): this; + removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this; + removeListener(event: 'unexpected-response', listener: (request: http.ClientRequest, response: http.IncomingMessage) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; } declare namespace WebSocket { From de11c43c2ca552c1ccbd8b7afb416ba7ff6620d0 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 15:40:27 -0500 Subject: [PATCH 264/639] Set strictFunctionTypes --- types/jschannel/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jschannel/tsconfig.json b/types/jschannel/tsconfig.json index 96fdb53367..83727a281c 100644 --- a/types/jschannel/tsconfig.json +++ b/types/jschannel/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From cfa037187401d9e9ed8ab4b7027fc494569ab8cf Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 29 Nov 2017 20:41:14 +0000 Subject: [PATCH 265/639] Added author name / address --- types/parse-ms/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/parse-ms/index.d.ts b/types/parse-ms/index.d.ts index 9bf9f23c87..1a8a63d4a2 100644 --- a/types/parse-ms/index.d.ts +++ b/types/parse-ms/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for parse-ms 1.0 // Project: https://github.com/sindresorhus/parse-ms#readme -// Definitions by: My Self +// Definitions by: Giles Roadnight // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export default function parseMs(ms: number): { From 847d1575c244daab4531beb4c6f757568f860bf6 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 16:40:57 -0500 Subject: [PATCH 266/639] Fix version --- types/jschannel/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jschannel/index.d.ts b/types/jschannel/index.d.ts index 13946e83ee..285cff37b9 100644 --- a/types/jschannel/index.d.ts +++ b/types/jschannel/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jschannel 1.0.2 +// Type definitions for jschannel 1.0 // Project: https://github.com/yochannah/jschannel // Definitions by: Yitzchok Gottlieb // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From fa7f52df8beaac56068b84078399df45dcc97c3f Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 16:41:04 -0500 Subject: [PATCH 267/639] Export interface --- types/jschannel/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jschannel/index.d.ts b/types/jschannel/index.d.ts index 285cff37b9..42145531ea 100644 --- a/types/jschannel/index.d.ts +++ b/types/jschannel/index.d.ts @@ -8,7 +8,7 @@ export as namespace Channel; export function build(config: ChannelConfiguration): MessagingChannel; -interface MessagingChannel { +export interface MessagingChannel { unbind: (method: string, doNotPublish?: boolean) => boolean; bind: (method: string, callback?: (transaction: MessageTransaction, params: any) => void, doNotPublish?: boolean) => MessagingChannel; call: (message: Message) => void; From 5d8c5e2a4f58c5e0b825c77517dacde78d94bbd6 Mon Sep 17 00:00:00 2001 From: Yitzchok Gottlieb Date: Wed, 29 Nov 2017 16:41:24 -0500 Subject: [PATCH 268/639] Add test content --- types/jschannel/jschannel-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/jschannel/jschannel-tests.ts b/types/jschannel/jschannel-tests.ts index e69de29bb2..eabd150bf2 100644 --- a/types/jschannel/jschannel-tests.ts +++ b/types/jschannel/jschannel-tests.ts @@ -0,0 +1,3 @@ +import { build } from 'jschannel'; + +build({ window: null, origin: "*", scope: "testScope"}); From 9f809400282f233242a3964844da16ed47c39397 Mon Sep 17 00:00:00 2001 From: Wael Al Jishi Date: Wed, 29 Nov 2017 22:02:27 +0000 Subject: [PATCH 269/639] Fixed Polymer typing for debounce --- types/polymer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/polymer/index.d.ts b/types/polymer/index.d.ts index b1f76d83c6..eee6a6250f 100644 --- a/types/polymer/index.d.ts +++ b/types/polymer/index.d.ts @@ -53,7 +53,7 @@ declare global { // Debouncer - debounce?(jobName: string, callback: Function, wait: number): void; + debounce?(jobName: string, callback: Function, wait?: number): void; isDebouncerActive?(jobName: string): boolean; From c61ecc215c88ab6ec4e69b49b2d4743392b6dde8 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 00:33:28 +0200 Subject: [PATCH 270/639] Add types for react-resolver --- types/react-resolver/index.d.ts | 71 ++++++++++++++++++++++++++++++ types/react-resolver/test.tsx | 44 ++++++++++++++++++ types/react-resolver/tsconfig.json | 25 +++++++++++ types/react-resolver/tslint.json | 1 + 4 files changed, 141 insertions(+) create mode 100644 types/react-resolver/index.d.ts create mode 100644 types/react-resolver/test.tsx create mode 100644 types/react-resolver/tsconfig.json create mode 100644 types/react-resolver/tslint.json diff --git a/types/react-resolver/index.d.ts b/types/react-resolver/index.d.ts new file mode 100644 index 0000000000..9afa5d4b61 --- /dev/null +++ b/types/react-resolver/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for react-resolver 3.1 +// Project: https://github.com/ericclemmons/react-resolver +// Definitions by: forabi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { ComponentType, StatelessComponent, Factory } from 'react'; + +export type AnyComponent

= ComponentType

; + +export interface Resolver { + resolve( + factory: Factory

, + ): Promise<{ + data: D; + Resolved: StatelessComponent

; + }>; + + render

(factory: Factory

, root: Node | null): void; +} + +export const Resolver: Resolver; + +export type ResolveFn = (props: Props) => Promise; + +/** Use this for gaining access to a context as a prop without the boilerplate of setting `contextTypes`. */ +export function context( + prop: K, +): ( + component: AnyComponent, +) => StatelessComponent>; + +/** + * Use `@client(LoaderComponent)` (or `client(LoaderComponent)(YourComponent)`) + * for when you want to skip server-side rendering of part of your view and + * perform it only on the client. + */ +export function client( + loadingComponent: AnyComponent, +): ( + component: AnyComponent, +) => StatelessComponent; + +export function resolve< + OwnProps, + K extends string, + V, + MoreProps = { [x: string]: any } +>( + prop: K, + resolveFn: ResolveFn, +): ( + component: AnyComponent, +) => StatelessComponent; + +export function resolve< + OwnProps, + ResolvableProps = { [x: string]: any }, + MoreProps = { [x: string]: any } +>( + resolversMap: { + [K in keyof ResolvableProps]: ResolveFn< + OwnProps & MoreProps, + ResolvableProps[K] + > + }, +): ( + component: AnyComponent< + OwnProps & { [K in keyof ResolvableProps]?: ResolvableProps[K] } + >, +) => StatelessComponent; diff --git a/types/react-resolver/test.tsx b/types/react-resolver/test.tsx new file mode 100644 index 0000000000..4c4314c063 --- /dev/null +++ b/types/react-resolver/test.tsx @@ -0,0 +1,44 @@ +import * as React from 'react'; +import { Resolver, resolve } from 'react-resolver'; +import * as expect from 'expect'; + +interface OwnProps { + thing: number; +} + +interface ResolvedProps { + data: string; +} + +class Page extends React.Component { + render() { + return

Hello, {this.props.data}!
; + } +} + +const ResolvedPageWithSingleProp = resolve('data', async () => { + return new Promise(resolve => { + setTimeout(() => resolve('World'), 500); + }); +})(Page); + +const ResolvedPageWithPropMap = resolve({ + data: async () => { + return new Promise(resolve => { + setTimeout(() => resolve('World'), 500); + }); + }, +})(Page); + +expect().toExist(); +expect().toExist(); + +// Resolver.render(() => , document.getElementById('app')); + +Resolver.resolve(() => { + return ( + + ); +}).then(({ data, Resolved }) => { + expect(data).toBe('World'); +}); diff --git a/types/react-resolver/tsconfig.json b/types/react-resolver/tsconfig.json new file mode 100644 index 0000000000..f16bd3453a --- /dev/null +++ b/types/react-resolver/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "test.tsx" + ] +} diff --git a/types/react-resolver/tslint.json b/types/react-resolver/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-resolver/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 1308f1fb8bd5ae0334396d48862e6d7597499a29 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 00:38:08 +0200 Subject: [PATCH 271/639] Remove unneeded type alias --- types/react-resolver/index.d.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/types/react-resolver/index.d.ts b/types/react-resolver/index.d.ts index 9afa5d4b61..742260dc7c 100644 --- a/types/react-resolver/index.d.ts +++ b/types/react-resolver/index.d.ts @@ -6,8 +6,6 @@ import { ComponentType, StatelessComponent, Factory } from 'react'; -export type AnyComponent

= ComponentType

; - export interface Resolver { resolve( factory: Factory

, @@ -27,7 +25,7 @@ export type ResolveFn = (props: Props) => Promise; export function context( prop: K, ): ( - component: AnyComponent, + component: ComponentType, ) => StatelessComponent>; /** @@ -36,9 +34,9 @@ export function context( * perform it only on the client. */ export function client( - loadingComponent: AnyComponent, + loadingComponent: ComponentType, ): ( - component: AnyComponent, + component: ComponentType, ) => StatelessComponent; export function resolve< @@ -50,7 +48,7 @@ export function resolve< prop: K, resolveFn: ResolveFn, ): ( - component: AnyComponent, + component: ComponentType, ) => StatelessComponent; export function resolve< @@ -65,7 +63,7 @@ export function resolve< > }, ): ( - component: AnyComponent< + component: ComponentType< OwnProps & { [K in keyof ResolvableProps]?: ResolvableProps[K] } >, ) => StatelessComponent; From 5d792b0f0c1b866fb3c215ec15ea8bc2437d96ad Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 00:39:01 +0200 Subject: [PATCH 272/639] Rename test file --- types/react-resolver/{test.tsx => react-resolver-tests.tsx} | 0 types/react-resolver/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename types/react-resolver/{test.tsx => react-resolver-tests.tsx} (100%) diff --git a/types/react-resolver/test.tsx b/types/react-resolver/react-resolver-tests.tsx similarity index 100% rename from types/react-resolver/test.tsx rename to types/react-resolver/react-resolver-tests.tsx diff --git a/types/react-resolver/tsconfig.json b/types/react-resolver/tsconfig.json index f16bd3453a..c8d99b4c25 100644 --- a/types/react-resolver/tsconfig.json +++ b/types/react-resolver/tsconfig.json @@ -20,6 +20,6 @@ }, "files": [ "index.d.ts", - "test.tsx" + "react-resolver-tests.tsx" ] } From 6e8cb559744725b8e742c0a7cb7c07fc56a1cb06 Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Wed, 29 Nov 2017 13:01:34 -0800 Subject: [PATCH 273/639] Initial commit --- types/yup/index.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ types/yup/tsconfig.json | 22 ++++++++++++++++++++++ types/yup/tslint.json | 1 + types/yup/yup-tests.ts | 0 4 files changed, 62 insertions(+) create mode 100644 types/yup/index.d.ts create mode 100644 types/yup/tsconfig.json create mode 100644 types/yup/tslint.json create mode 100644 types/yup/yup-tests.ts diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts new file mode 100644 index 0000000000..b32806de45 --- /dev/null +++ b/types/yup/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for yup 0.23 +// Project: https://github.com/jquense/yup +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ If this module is a UMD module that exposes a global variable 'myLib' when + *~ loaded outside a module loader environment, declare that global here. + *~ Otherwise, delete this declaration. + */ +export as namespace myLib; + +/*~ If this module has methods, declare them as functions like so. + */ +export function myMethod(a: string): string; +export function myOtherMethod(a: number): number; + +/*~ You can declare types that are available via importing the module */ +export interface someType { + name: string; + length: number; + extras?: string[]; +} + +/*~ You can declare properties of the module using const, let, or var */ +export const myField: number; + +/*~ If there are types, properties, or methods inside dotted names + *~ of the module, declare them inside a 'namespace'. + */ +export namespace subProp { + /*~ For example, given this definition, someone could write: + *~ import { subProp } from 'yourModule'; + *~ subProp.foo(); + *~ or + *~ import * as yourMod from 'yourModule'; + *~ yourMod.subProp.foo(); + */ + export function foo(): void; +} \ No newline at end of file diff --git a/types/yup/tsconfig.json b/types/yup/tsconfig.json new file mode 100644 index 0000000000..d9fa152a10 --- /dev/null +++ b/types/yup/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "yup-tests.ts" + ] +} diff --git a/types/yup/tslint.json b/types/yup/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/yup/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts new file mode 100644 index 0000000000..e69de29bb2 From 4c133d2337f1d6526f06684dc7577d8e1b70eda2 Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Wed, 29 Nov 2017 13:16:03 -0800 Subject: [PATCH 274/639] Added definitions by Dominik Hardtke posted here https://github.com/jquense/yup/issues/91#issuecomment-317221800 --- types/yup/index.d.ts | 142 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 112 insertions(+), 30 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index b32806de45..ac7f46be4b 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -1,39 +1,121 @@ // Type definitions for yup 0.23 // Project: https://github.com/jquense/yup -// Definitions by: My Self +// Definitions by: +// Dominik Hardtke +// Vladyslav Tserman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/*~ If this module is a UMD module that exposes a global variable 'myLib' when - *~ loaded outside a module loader environment, declare that global here. - *~ Otherwise, delete this declaration. - */ -export as namespace myLib; +export as namespace yup; -/*~ If this module has methods, declare them as functions like so. - */ -export function myMethod(a: string): string; -export function myOtherMethod(a: number): number; +export function reach(schema: Schema, path: string, value?: any, context?: any): Schema; +export function addMethod(schemaType: Schema, name: string, method: () => Schema): void; +export function ref(path: string, options: { contextPrefix: string }): Ref; +export function lazy(fn: (value: any) => Schema): Lazy; +export function mixed(): Schema; +export function string(): StringSchema; +export function number(): NumberSchema; +export function boolean(): BooleanSchema; +export function date(): DateSchema; +export function array(): ArraySchema; +export function object(): ObjectSchema; -/*~ You can declare types that are available via importing the module */ -export interface someType { - name: string; - length: number; - extras?: string[]; +export interface ValidationError { + errors: string | Array; + value: any; + path: string; + inner?: Array; } -/*~ You can declare properties of the module using const, let, or var */ -export const myField: number; +interface Ref { +} + +interface Lazy { +} + +interface Schema { + clone(): Schema; + label(label: string): Schema; + meta(metadata: any): Schema; + describe(): SchemaDescription; + concat(schema: Schema): Schema; + validate(value: any, options?: ValidateOptions, callback?: () => void): Promise; + isValid(value: any, options?: any, callback?: () => void): Promise; + cast(value: any): any; + isType(value: any): boolean; + strict(isStrict: boolean): Schema; + strip(stripField: boolean): Schema; + withMutation(builder: (current: Schema) => void): void; + default(value: any): Schema; + default(): any; + nullable(isNullable: boolean): Schema; + required(message?: string): Schema; + typeError(message?: string): Schema; + oneOf(arrayOfValues: Array, message?: string): Schema; + equals(arrayOfValues: Array, message?: string): Schema; + notOneOf(arrayOfValues: Array, message?: string): Schema; + when(keys: string | Array, builder: any | ((value: any, schema: Schema) => Schema)): Schema; + test(name: string, message: string, test: Function, callbackStyleAsync?: boolean): Schema; + test(options: any): Schema; + transform(transformation: (currentValue: any, originalValue: any) => any): Schema; +} + +interface StringSchema extends Schema { + required(message?: string): StringSchema; + min(limit: number | Ref, message?: string): StringSchema; + max(limit: number | Ref, message?: string): StringSchema; + matches(regex: RegExp, message?: string): StringSchema; + email(message?: string): StringSchema; + url(message?: string): StringSchema; + ensure(): StringSchema; + trim(message?: string): StringSchema; + lowercase(message?: string): StringSchema; + uppercase(message?: string): StringSchema; +} + +interface NumberSchema extends Schema { + min(limit: number | Ref, message?: string): NumberSchema; + max(limit: number | Ref, message?: string): NumberSchema; + positive(message?: string): NumberSchema; + negative(message?: string): NumberSchema; + integer(message?: string): NumberSchema; + truncate(): NumberSchema; + round(type: "floor" | "ceil" | "trunc" | "round"): NumberSchema; +} + +interface BooleanSchema extends Schema { + +} + +interface DateSchema extends Schema { + min(limit: Date | string | Ref, message?: string): DateSchema; + max(limit: Date | string | Ref, message?: string): DateSchema; +} + +interface ArraySchema extends Schema { + of(type: Schema): ArraySchema; + required(message?: string): ArraySchema; + min(limit: number | Ref, message?: string): ArraySchema; + max(limit: number | Ref, message?: string): ArraySchema; + ensure(): ArraySchema; + compact(rejector: (value: any) => boolean): ArraySchema; +} + +interface ObjectSchema extends Schema { + shape(fields: any, noSortEdges?: Array<[string, string]>): ObjectSchema; + from(fromKey: string, toKey: string, alias: boolean): ObjectSchema; + noUnknown(onlyKnownKeys: boolean, message?: string): ObjectSchema; + camelCase(): ObjectSchema; + constantCase(): ObjectSchema; +} + +interface ValidateOptions { + +} + +interface SchemaDescription { + type: string; + label: string; + meta: object; + tests: Array; +} -/*~ If there are types, properties, or methods inside dotted names - *~ of the module, declare them inside a 'namespace'. - */ -export namespace subProp { - /*~ For example, given this definition, someone could write: - *~ import { subProp } from 'yourModule'; - *~ subProp.foo(); - *~ or - *~ import * as yourMod from 'yourModule'; - *~ yourMod.subProp.foo(); - */ - export function foo(): void; -} \ No newline at end of file From a30076b01404ab0ce6a0153674ee4ac216cb5e39 Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Wed, 29 Nov 2017 13:50:36 -0800 Subject: [PATCH 275/639] Fix tslint warnings --- types/yup/index.d.ts | 47 +++++++++++++++++++---------------------- types/yup/tsconfig.json | 3 ++- types/yup/tslint.json | 8 ++++++- types/yup/yup-tests.ts | 16 ++++++++++++++ 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index ac7f46be4b..e1ad722030 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -1,9 +1,8 @@ // Type definitions for yup 0.23 // Project: https://github.com/jquense/yup -// Definitions by: -// Dominik Hardtke -// Vladyslav Tserman +// Definitions by: Dominik Hardtke , Vladyslav Tserman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export as namespace yup; @@ -20,19 +19,19 @@ export function array(): ArraySchema; export function object(): ObjectSchema; export interface ValidationError { - errors: string | Array; + errors: string | string[]; value: any; path: string; - inner?: Array; + inner?: ValidationError[]; } -interface Ref { +export interface Ref { } -interface Lazy { +export interface Lazy { } -interface Schema { +export interface Schema { clone(): Schema; label(label: string): Schema; meta(metadata: any): Schema; @@ -50,16 +49,16 @@ interface Schema { nullable(isNullable: boolean): Schema; required(message?: string): Schema; typeError(message?: string): Schema; - oneOf(arrayOfValues: Array, message?: string): Schema; - equals(arrayOfValues: Array, message?: string): Schema; - notOneOf(arrayOfValues: Array, message?: string): Schema; - when(keys: string | Array, builder: any | ((value: any, schema: Schema) => Schema)): Schema; - test(name: string, message: string, test: Function, callbackStyleAsync?: boolean): Schema; + oneOf(arrayOfValues: any[], message?: string): Schema; + equals(arrayOfValues: any[], message?: string): Schema; + notOneOf(arrayOfValues: any[], message?: string): Schema; + when(keys: string | any[], builder: any | ((value: any, schema: Schema) => Schema)): Schema; + test(name: string, message: string, test: (value: any) => boolean, callbackStyleAsync?: boolean): Schema; test(options: any): Schema; transform(transformation: (currentValue: any, originalValue: any) => any): Schema; } -interface StringSchema extends Schema { +export interface StringSchema extends Schema { required(message?: string): StringSchema; min(limit: number | Ref, message?: string): StringSchema; max(limit: number | Ref, message?: string): StringSchema; @@ -72,7 +71,8 @@ interface StringSchema extends Schema { uppercase(message?: string): StringSchema; } -interface NumberSchema extends Schema { +export interface NumberSchema extends Schema { + required(message?: string): NumberSchema; min(limit: number | Ref, message?: string): NumberSchema; max(limit: number | Ref, message?: string): NumberSchema; positive(message?: string): NumberSchema; @@ -82,16 +82,15 @@ interface NumberSchema extends Schema { round(type: "floor" | "ceil" | "trunc" | "round"): NumberSchema; } -interface BooleanSchema extends Schema { - +export interface BooleanSchema extends Schema { } -interface DateSchema extends Schema { +export interface DateSchema extends Schema { min(limit: Date | string | Ref, message?: string): DateSchema; max(limit: Date | string | Ref, message?: string): DateSchema; } -interface ArraySchema extends Schema { +export interface ArraySchema extends Schema { of(type: Schema): ArraySchema; required(message?: string): ArraySchema; min(limit: number | Ref, message?: string): ArraySchema; @@ -100,7 +99,7 @@ interface ArraySchema extends Schema { compact(rejector: (value: any) => boolean): ArraySchema; } -interface ObjectSchema extends Schema { +export interface ObjectSchema extends Schema { shape(fields: any, noSortEdges?: Array<[string, string]>): ObjectSchema; from(fromKey: string, toKey: string, alias: boolean): ObjectSchema; noUnknown(onlyKnownKeys: boolean, message?: string): ObjectSchema; @@ -108,14 +107,12 @@ interface ObjectSchema extends Schema { constantCase(): ObjectSchema; } -interface ValidateOptions { - +export interface ValidateOptions { } -interface SchemaDescription { +export interface SchemaDescription { type: string; label: string; meta: object; - tests: Array; + tests: string[]; } - diff --git a/types/yup/tsconfig.json b/types/yup/tsconfig.json index d9fa152a10..7a38726edd 100644 --- a/types/yup/tsconfig.json +++ b/types/yup/tsconfig.json @@ -13,7 +13,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true }, "files": [ "index.d.ts", diff --git a/types/yup/tslint.json b/types/yup/tslint.json index 3db14f85ea..0fde820a9e 100644 --- a/types/yup/tslint.json +++ b/types/yup/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-empty-interface": false, + "no-any-union": false + } +} diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index e69de29bb2..218ed793fc 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -0,0 +1,16 @@ +import * as yup from 'yup'; + +const schema = yup.object().shape({ + name: yup.string().required(), + age: yup.number().required().positive().integer(), + email: yup.string().email(), + website: yup.string().url(), + createdOn: yup.date().default(() => new Date()) +}); + +// check validity +schema.isValid({ + name: 'jimmy', + age: 24 +}) +.then(valid => valid /* => true */); From 074627c1f96e81881714ad4d5f6ea2fbb8cf0547 Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Wed, 29 Nov 2017 15:22:02 -0800 Subject: [PATCH 276/639] Refactored to allow creating new Types --- types/yup/index.d.ts | 104 +++++++++++++++++++++++++++++++++++++---- types/yup/yup-tests.ts | 33 ++++++++++--- 2 files changed, 120 insertions(+), 17 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index e1ad722030..de1d8d2f07 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -10,13 +10,15 @@ export function reach(schema: Schema, path: string, value?: any, context?: any): export function addMethod(schemaType: Schema, name: string, method: () => Schema): void; export function ref(path: string, options: { contextPrefix: string }): Ref; export function lazy(fn: (value: any) => Schema): Lazy; -export function mixed(): Schema; -export function string(): StringSchema; -export function number(): NumberSchema; -export function boolean(): BooleanSchema; -export function date(): DateSchema; -export function array(): ArraySchema; -export function object(): ObjectSchema; + +export const mixed: SchemaConstructor; +export const string: StringSchemaConstructor; +export const number: NumberSchemaConstructor; +export const boolean: BooleanSchemaConstructor; +export const bool: BooleanSchemaConstructor; +export const date: DateSchemaConstructor; +export const array: ArraySchemaConstructor; +export const object: ObjectSchemaConstructor; export interface ValidationError { errors: string | string[]; @@ -31,6 +33,11 @@ export interface Ref { export interface Lazy { } +export interface SchemaConstructor { + (): Schema; + new(options?: any): Schema; +} + export interface Schema { clone(): Schema; label(label: string): Schema; @@ -38,7 +45,8 @@ export interface Schema { describe(): SchemaDescription; concat(schema: Schema): Schema; validate(value: any, options?: ValidateOptions, callback?: () => void): Promise; - isValid(value: any, options?: any, callback?: () => void): Promise; + isValid(value: any, options?: any, callback?: () => void): Promise; + isValidSync(value: any, options?: any): boolean; cast(value: any): any; isType(value: any): boolean; strict(isStrict: boolean): Schema; @@ -50,14 +58,18 @@ export interface Schema { required(message?: string): Schema; typeError(message?: string): Schema; oneOf(arrayOfValues: any[], message?: string): Schema; - equals(arrayOfValues: any[], message?: string): Schema; notOneOf(arrayOfValues: any[], message?: string): Schema; when(keys: string | any[], builder: any | ((value: any, schema: Schema) => Schema)): Schema; test(name: string, message: string, test: (value: any) => boolean, callbackStyleAsync?: boolean): Schema; - test(options: any): Schema; + test(options: TestOptions): Schema; transform(transformation: (currentValue: any, originalValue: any) => any): Schema; } +export interface StringSchemaConstructor { + (): StringSchema; + new(): StringSchema; +} + export interface StringSchema extends Schema { required(message?: string): StringSchema; min(limit: number | Ref, message?: string): StringSchema; @@ -71,6 +83,11 @@ export interface StringSchema extends Schema { uppercase(message?: string): StringSchema; } +export interface NumberSchemaConstructor { + (): NumberSchema; + new(): NumberSchema; +} + export interface NumberSchema extends Schema { required(message?: string): NumberSchema; min(limit: number | Ref, message?: string): NumberSchema; @@ -82,14 +99,29 @@ export interface NumberSchema extends Schema { round(type: "floor" | "ceil" | "trunc" | "round"): NumberSchema; } +export interface BooleanSchemaConstructor { + (): BooleanSchema; + new(): BooleanSchema; +} + export interface BooleanSchema extends Schema { } +export interface DateSchemaConstructor { + (): DateSchema; + new(): DateSchema; +} + export interface DateSchema extends Schema { min(limit: Date | string | Ref, message?: string): DateSchema; max(limit: Date | string | Ref, message?: string): DateSchema; } +export interface ArraySchemaConstructor { + (): ArraySchema; + new(): ArraySchema; +} + export interface ArraySchema extends Schema { of(type: Schema): ArraySchema; required(message?: string): ArraySchema; @@ -99,6 +131,11 @@ export interface ArraySchema extends Schema { compact(rejector: (value: any) => boolean): ArraySchema; } +export interface ObjectSchemaConstructor { + (): ObjectSchema; + new(): ObjectSchema; +} + export interface ObjectSchema extends Schema { shape(fields: any, noSortEdges?: Array<[string, string]>): ObjectSchema; from(fromKey: string, toKey: string, alias: boolean): ObjectSchema; @@ -108,6 +145,53 @@ export interface ObjectSchema extends Schema { } export interface ValidateOptions { + /** + * Only validate the input, and skip and coercion or transformation. Default - false + */ + strict?: boolean; + /** + * Teturn from validation methods on the first error rather than after all validations run. Default - true + */ + abortEarly?: boolean; + /** + * Remove unspecified keys from objects. Default - false + */ + stripUnknown?: boolean; + /** + * When false validations will not descend into nested schema (relevant for objects or arrays). Default - true + */ + recursive?: boolean; + /** + * Any context needed for validating schema conditions (see: when()) + */ + context?: object; +} + +export interface TestOptions { + /** + * Unique name identifying the test + */ + name?: string; + + /** + * Test function, determines schema validity + */ + test: (value: any) => boolean; + + /** + * The validation error message + */ + message?: string; + + /** + * Values passed to message for interpolation + */ + params?: object; + + /** + * Mark the test as exclusive, meaning only one of the same can be active at once + */ + exclusive?: boolean; } export interface SchemaDescription { diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index 218ed793fc..35d530dbb5 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -1,16 +1,35 @@ import * as yup from 'yup'; const schema = yup.object().shape({ - name: yup.string().required(), - age: yup.number().required().positive().integer(), - email: yup.string().email(), - website: yup.string().url(), - createdOn: yup.date().default(() => new Date()) + name: yup.string().required(), + age: yup.number().required().positive().integer(), + email: yup.string().email(), + website: yup.string().url(), + createdOn: yup.date().default(() => new Date()) }); // check validity schema.isValid({ - name: 'jimmy', - age: 24 + name: 'jimmy', + age: 24 }) .then(valid => valid /* => true */); + +class CustomDateSchema extends yup.date { + isWednesday(message?: string): CustomDateSchema { + return this.test({ + name: 'Wednesday', + // tslint:disable-next-line:no-invalid-template-strings + message: message || '${path} must be Wednesday', + test: value => true /* Check that day is Wednesday */, + }) as CustomDateSchema; + } +} +const date = () => new CustomDateSchema(); + +yup.object().shape({ + startDate: date().isWednesday().required() +}); +const valid = schema.isValidSync({ + startDate: '2017-11-29', +}); From cfd43ded948be39f27dba73ded05813fb8c23945 Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Wed, 29 Nov 2017 16:07:55 -0800 Subject: [PATCH 277/639] Add missing properties, refactor `Schema.when` --- types/yup/index.d.ts | 7 ++++--- types/yup/tslint.json | 4 ++-- types/yup/yup-tests.ts | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index de1d8d2f07..e7a8e29cde 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -4,8 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export as namespace yup; - export function reach(schema: Schema, path: string, value?: any, context?: any): Schema; export function addMethod(schemaType: Schema, name: string, method: () => Schema): void; export function ref(path: string, options: { contextPrefix: string }): Ref; @@ -42,9 +40,11 @@ export interface Schema { clone(): Schema; label(label: string): Schema; meta(metadata: any): Schema; + meta(): any; describe(): SchemaDescription; concat(schema: Schema): Schema; validate(value: any, options?: ValidateOptions, callback?: () => void): Promise; + validateSync(value: any, options?: ValidateOptions): any; isValid(value: any, options?: any, callback?: () => void): Promise; isValidSync(value: any, options?: any): boolean; cast(value: any): any; @@ -59,7 +59,7 @@ export interface Schema { typeError(message?: string): Schema; oneOf(arrayOfValues: any[], message?: string): Schema; notOneOf(arrayOfValues: any[], message?: string): Schema; - when(keys: string | any[], builder: any | ((value: any, schema: Schema) => Schema)): Schema; + when(keys: string | any[], builder: ((value: any, schema: Schema) => Schema) | object): Schema; test(name: string, message: string, test: (value: any) => boolean, callbackStyleAsync?: boolean): Schema; test(options: TestOptions): Schema; transform(transformation: (currentValue: any, originalValue: any) => any): Schema; @@ -140,6 +140,7 @@ export interface ObjectSchema extends Schema { shape(fields: any, noSortEdges?: Array<[string, string]>): ObjectSchema; from(fromKey: string, toKey: string, alias: boolean): ObjectSchema; noUnknown(onlyKnownKeys: boolean, message?: string): ObjectSchema; + transformKeys(callback: (key: any) => any): void camelCase(): ObjectSchema; constantCase(): ObjectSchema; } diff --git a/types/yup/tslint.json b/types/yup/tslint.json index 0fde820a9e..10c5efd5aa 100644 --- a/types/yup/tslint.json +++ b/types/yup/tslint.json @@ -1,7 +1,7 @@ -{ +{ "extends": "dtslint/dt.json", "rules": { "no-empty-interface": false, - "no-any-union": false + "no-any-union": true } } diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index 35d530dbb5..bba33755b1 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -33,3 +33,14 @@ yup.object().shape({ const valid = schema.isValidSync({ startDate: '2017-11-29', }); + +// test when +yup.object().shape({ + checkWednesday: yup.bool().required(), + name: yup.string().required(), + startDate: date() + .required() + .when(['checkWednesday', 'name'], (checkWednesday: boolean, name: string, schema: CustomDateSchema) => { + return checkWednesday ? schema.isWednesday() : schema; + }) +}); From 1e7989f8ced1eb4f3f37b19ec1286178e5ccb3c5 Mon Sep 17 00:00:00 2001 From: icnocop Date: Wed, 29 Nov 2017 17:55:13 -0800 Subject: [PATCH 278/639] [jquery] Overriding the beforeSend function for AjaxSettings and UrlAjaxSettings to indicate a more appropriate settings parameter type Fixed errors when running lint --- types/jquery/index.d.ts | 16 ++++++++++++++++ types/jquery/jquery-tests.ts | 6 ++---- types/jquery/test/example-tests.ts | 2 -- types/jquery/test/longdesc-tests.ts | 2 -- types/jquery/tslint.json | 10 ++++++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index ef3d33a09e..9c635a747b 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -5405,6 +5405,14 @@ declare namespace JQuery { * A string containing the URL to which the request is sent. */ url?: string; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, + * XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and + * settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend + * function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless + * of the type of request. + */ + beforeSend?(this: TContext, jqXHR: jqXHR, settings: AjaxSettings): false | void; } interface UrlAjaxSettings extends Ajax.AjaxSettingsBase { @@ -5412,6 +5420,14 @@ declare namespace JQuery { * A string containing the URL to which the request is sent. */ url: string; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, + * XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and + * settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend + * function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless + * of the type of request. + */ + beforeSend?(this: TContext, jqXHR: jqXHR, settings: UrlAjaxSettings): false | void; } namespace Ajax { diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 6cb790f408..338509a37a 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -1,5 +1,3 @@ -// tslint:disable:interface-name - function JQueryStatic() { function type_assertion() { const $Canvas = $ as JQueryStatic; @@ -6195,7 +6193,7 @@ function JQuery_AjaxSettings() { this; // $ExpectType jqXHR jqXHR; - // $ExpectType AjaxSettingsBase + // $ExpectType AjaxSettings settings; }, cache: false, @@ -6305,7 +6303,7 @@ function JQuery_AjaxSettings() { this; // $ExpectType jqXHR jqXHR; - // $ExpectType AjaxSettingsBase + // $ExpectType AjaxSettings settings; return false; diff --git a/types/jquery/test/example-tests.ts b/types/jquery/test/example-tests.ts index f32a2c3723..728a42b3d6 100644 --- a/types/jquery/test/example-tests.ts +++ b/types/jquery/test/example-tests.ts @@ -1,5 +1,3 @@ -/* tslint:disable:no-arg object-literal-shorthand one-variable-per-declaration only-arrow-functions prefer-const prefer-for-of triple-equals no-var */ - function examples() { function add_0() { $('div').css('border', '2px solid red') diff --git a/types/jquery/test/longdesc-tests.ts b/types/jquery/test/longdesc-tests.ts index bf63445c16..23ff500d24 100644 --- a/types/jquery/test/longdesc-tests.ts +++ b/types/jquery/test/longdesc-tests.ts @@ -1,5 +1,3 @@ -/* tslint:disable:object-literal-key-quotes object-literal-shorthand one-variable-per-declaration only-arrow-functions prefer-const prefer-for-of triple-equals no-var */ - function longdesc() { function add_0() { $('p').add('div').addClass('widget'); diff --git a/types/jquery/tslint.json b/types/jquery/tslint.json index 24680d3efb..dea67c016f 100644 --- a/types/jquery/tslint.json +++ b/types/jquery/tslint.json @@ -5,7 +5,9 @@ "await-promise": false, "ban-types": false, "callable-types": false, + "interface-name": false, "no-any-union": false, + "no-arg": false, "no-boolean-literal-compare": false, "no-declare-current-package": false, "no-empty-interface": false, @@ -14,12 +16,20 @@ "no-unnecessary-generics": false, "no-unnecessary-qualifier": false, "no-unnecessary-type-assertion": false, + "no-var": false, "no-var-keyword": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-for-of": false, "prefer-switch": false, "prefer-template": false, "space-before-function-paren": false, "space-within-parens": false, + "triple-equals": false, "use-default-type-parameter": false } } From 0c412f77490613cdb08f76719eaffaef6f2cffae Mon Sep 17 00:00:00 2001 From: Jouderian Nobre Date: Thu, 30 Nov 2017 01:18:07 -0300 Subject: [PATCH 279/639] [Inquirer] Add missing attributes for Question type --- types/inquirer/index.d.ts | 9 +++++++++ types/inquirer/inquirer-tests.ts | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 2a0b9f60f4..32c54fa99e 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/SBoudrias/Inquirer.js // Definitions by: Qubo // Parvez +// Jouderian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -115,6 +116,14 @@ declare namespace inquirer { * Add a mask when password will entered */ mask?: string; + /** + * Change the default prefix message. + */ + prefix?: string; + /** + * Change the default suffix message. + */ + suffix?: string; } /** diff --git a/types/inquirer/inquirer-tests.ts b/types/inquirer/inquirer-tests.ts index d3591b13d2..4a43dcc98e 100644 --- a/types/inquirer/inquirer-tests.ts +++ b/types/inquirer/inquirer-tests.ts @@ -151,13 +151,15 @@ var questions = [ { type: "input", name: "first_name", - message: "What's your first name" + message: "What's your first name", + prefix: "1 - ", }, { type: "input", name: "last_name", message: "What's your last name", - default: function () { return "Doe"; } + default: function () { return "Doe"; }, + suffix: "!!" }, { type: "input", From f6da6d20bad54570356d759f2560dd5b87b54353 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 30 Nov 2017 14:24:12 +0900 Subject: [PATCH 280/639] Add missing parameter type in asynciterator's multitransformer --- types/asynciterator/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/asynciterator/index.d.ts b/types/asynciterator/index.d.ts index a7be809137..005819aa21 100644 --- a/types/asynciterator/index.d.ts +++ b/types/asynciterator/index.d.ts @@ -152,7 +152,7 @@ export class SimpleTransformIterator extends TransformIterator { export class MultiTransformIterator extends TransformIterator { _transformerQueue: S[]; - protected _createTransformer(): AsyncIterator; + protected _createTransformer(element: S): AsyncIterator; constructor(source?: AsyncIterator | TransformIteratorOptions, options?: TransformIteratorOptions); } From 63b9a87e4fe7d658b368a15ee06f3edac2fcf098 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 30 Nov 2017 14:25:40 +0900 Subject: [PATCH 281/639] Make asynciterator methods public --- types/asynciterator/index.d.ts | 74 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/types/asynciterator/index.d.ts b/types/asynciterator/index.d.ts index 005819aa21..950fb16bbd 100644 --- a/types/asynciterator/index.d.ts +++ b/types/asynciterator/index.d.ts @@ -9,16 +9,16 @@ import { EventEmitter } from "events"; export abstract class AsyncIterator extends NodeJS.EventEmitter { - protected static STATES: ['INIT', 'OPEN', 'CLOSING', 'CLOSED', 'ENDED']; - protected static INIT: 0; - protected static OPEN: 1; - protected static CLOSING: 2; - protected static CLOSED: 3; - protected static ENDED: 4; + static STATES: ['INIT', 'OPEN', 'CLOSING', 'CLOSED', 'ENDED']; + static INIT: 0; + static OPEN: 1; + static CLOSING: 2; + static CLOSED: 3; + static ENDED: 4; - protected _state: number; - protected _readable: boolean; - protected _destination?: AsyncIterator; + _state: number; + _readable: boolean; + _destination?: AsyncIterator; readable: boolean; closed: boolean; @@ -30,11 +30,11 @@ export abstract class AsyncIterator extends NodeJS.EventEmitter { each(callback: (data: T) => void, self?: any): void; close(): void; - protected _changeState(newState: number, eventAsync?: boolean): void; + _changeState(newState: number, eventAsync?: boolean): void; private _hasListeners(eventName: string | symbol): boolean; // tslint:disable-next-line ban-types private _addSingleListener(eventName: string | symbol, listener: Function): void; - protected _end(): void; + _end(): void; getProperty(propertyName: string, callback?: (value: any) => void): any; setProperty(propertyName: string, value: any): void; @@ -43,7 +43,7 @@ export abstract class AsyncIterator extends NodeJS.EventEmitter { copyProperties(source: AsyncIterator, propertyNames: string[]): void; toString(): string; - protected _toStringDetails(): string; + _toStringDetails(): string; transform(options?: SimpleTransformIteratorOptions): SimpleTransformIterator; map(mapper: (item: T) => T2, self?: object): SimpleTransformIterator; @@ -78,9 +78,9 @@ export interface IntegerIteratorOptions { } export class IntegerIterator extends AsyncIterator { - protected _step: number; - protected _last: number; - protected _next: number; + _step: number; + _last: number; + _next: number; constructor(options?: IntegerIteratorOptions); } @@ -92,16 +92,16 @@ export interface BufferedIteratorOptions { export class BufferedIterator extends AsyncIterator { maxBufferSize: number; - protected _pushedCount: number; - protected _buffer: T[]; + _pushedCount: number; + _buffer: T[]; - protected _init(autoStart: boolean): void; - protected _begin(done: () => void): void; - protected _read(count: number, done: () => void): void; - protected _push(item: T): void; - protected _fillBuffer(): void; - protected _completeClose(): void; - protected _flush(done: () => void): void; + _init(autoStart: boolean): void; + _begin(done: () => void): void; + _read(count: number, done: () => void): void; + _push(item: T): void; + _fillBuffer(): void; + _completeClose(): void; + _flush(done: () => void): void; constructor(options?: BufferedIteratorOptions); } @@ -112,12 +112,12 @@ export interface TransformIteratorOptions extends BufferedIteratorOptions { } export class TransformIterator extends BufferedIterator { - protected _optional: boolean; + _optional: boolean; source: AsyncIterator; - protected _validateSource(source: AsyncIterator, allowDestination?: boolean): void; - protected _transform(item: S, done: (result: T) => void): void; - protected _closeWhenDone(): void; + _validateSource(source: AsyncIterator, allowDestination?: boolean): void; + _transform(item: S, done: (result: T) => void): void; + _closeWhenDone(): void; constructor(source?: AsyncIterator | TransformIteratorOptions, options?: TransformIteratorOptions); } @@ -134,16 +134,16 @@ export interface SimpleTransformIteratorOptions extends TransformIteratorO } export class SimpleTransformIterator extends TransformIterator { - protected _offset: number; - protected _limit: number; - protected _prepender?: ArrayIterator; - protected _appender?: ArrayIterator; + _offset: number; + _limit: number; + _prepender?: ArrayIterator; + _appender?: ArrayIterator; - protected _filter?(item: S): boolean; - protected _map?(item: S): T; - protected _transform(item: S, done: (result: T) => void): void; + _filter?(item: S): boolean; + _map?(item: S): T; + _transform(item: S, done: (result: T) => void): void; - protected _insert(inserter: AsyncIterator, done: () => void): void; + _insert(inserter: AsyncIterator, done: () => void): void; constructor(source?: AsyncIterator | SimpleTransformIteratorOptions, options?: SimpleTransformIteratorOptions); @@ -152,7 +152,7 @@ export class SimpleTransformIterator extends TransformIterator { export class MultiTransformIterator extends TransformIterator { _transformerQueue: S[]; - protected _createTransformer(element: S): AsyncIterator; + _createTransformer(element: S): AsyncIterator; constructor(source?: AsyncIterator | TransformIteratorOptions, options?: TransformIteratorOptions); } From 24ea87eba2b97630c5f1e80022405c8df4a2f1d2 Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Wed, 29 Nov 2017 17:43:06 -0800 Subject: [PATCH 282/639] Add Generics, as well as some fixes --- types/yup/index.d.ts | 124 ++++++++++++--------- types/yup/yup-tests.ts | 245 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 291 insertions(+), 78 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index e7a8e29cde..a7f9f4a8d3 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -5,11 +5,12 @@ // TypeScript Version: 2.2 export function reach(schema: Schema, path: string, value?: any, context?: any): Schema; -export function addMethod(schemaType: Schema, name: string, method: () => Schema): void; -export function ref(path: string, options: { contextPrefix: string }): Ref; +export function addMethod(schemaType: Schema, name: string, method: (this: Schema) => Schema): void; +export function ref(path: string, options?: { contextPrefix: string }): Ref; export function lazy(fn: (value: any) => Schema): Lazy; +export function ValidationError(errors: string | string[], value: any, path: string, type?: any): ValidationError; -export const mixed: SchemaConstructor; +export const mixed: MixedSchemaConstructor; export const string: StringSchemaConstructor; export const number: NumberSchemaConstructor; export const boolean: BooleanSchemaConstructor; @@ -18,51 +19,40 @@ export const date: DateSchemaConstructor; export const array: ArraySchemaConstructor; export const object: ObjectSchemaConstructor; -export interface ValidationError { - errors: string | string[]; - value: any; - path: string; - inner?: ValidationError[]; -} - -export interface Ref { -} - -export interface Lazy { -} - -export interface SchemaConstructor { - (): Schema; - new(options?: any): Schema; -} - export interface Schema { - clone(): Schema; - label(label: string): Schema; - meta(metadata: any): Schema; + clone(): this; + label(label: string): this; + meta(metadata: any): this; meta(): any; describe(): SchemaDescription; - concat(schema: Schema): Schema; - validate(value: any, options?: ValidateOptions, callback?: () => void): Promise; - validateSync(value: any, options?: ValidateOptions): any; - isValid(value: any, options?: any, callback?: () => void): Promise; + concat(schema: this): this; + validate(value: U, options?: ValidateOptions): Promise; + validateSync(value: U, options?: ValidateOptions): ValidationError|U; + isValid(value: any, options?: any): Promise; isValidSync(value: any, options?: any): boolean; - cast(value: any): any; + cast(value: any, options?: any): any; isType(value: any): boolean; - strict(isStrict: boolean): Schema; - strip(stripField: boolean): Schema; - withMutation(builder: (current: Schema) => void): void; - default(value: any): Schema; - default(): any; - nullable(isNullable: boolean): Schema; - required(message?: string): Schema; - typeError(message?: string): Schema; - oneOf(arrayOfValues: any[], message?: string): Schema; - notOneOf(arrayOfValues: any[], message?: string): Schema; - when(keys: string | any[], builder: ((value: any, schema: Schema) => Schema) | object): Schema; - test(name: string, message: string, test: (value: any) => boolean, callbackStyleAsync?: boolean): Schema; - test(options: TestOptions): Schema; - transform(transformation: (currentValue: any, originalValue: any) => any): Schema; + strict(isStrict: boolean): this; + strip(strip: boolean): this; + withMutation(fn: (current: this) => void): void; + default(value?: any): this; + nullable(isNullable: boolean): this; + required(message?: string): this; + typeError(message?: string): this; + oneOf(arrayOfValues: any[], message?: string): this; + notOneOf(arrayOfValues: any[], message?: string): this; + when(keys: string | any[], builder: WhenOptions): this; + test(name: string, message: string, test: (value?: any) => boolean, callbackStyleAsync?: boolean): this; + test(options: TestOptions): this; + transform(fn: TransformFunction): this; +} + +export interface MixedSchemaConstructor { + (): MixedSchema; + new(options?: { type?: string, [key: string]: any }): MixedSchema; +} + +export interface MixedSchema extends Schema { } export interface StringSchemaConstructor { @@ -71,7 +61,6 @@ export interface StringSchemaConstructor { } export interface StringSchema extends Schema { - required(message?: string): StringSchema; min(limit: number | Ref, message?: string): StringSchema; max(limit: number | Ref, message?: string): StringSchema; matches(regex: RegExp, message?: string): StringSchema; @@ -89,7 +78,6 @@ export interface NumberSchemaConstructor { } export interface NumberSchema extends Schema { - required(message?: string): NumberSchema; min(limit: number | Ref, message?: string): NumberSchema; max(limit: number | Ref, message?: string): NumberSchema; positive(message?: string): NumberSchema; @@ -124,7 +112,6 @@ export interface ArraySchemaConstructor { export interface ArraySchema extends Schema { of(type: Schema): ArraySchema; - required(message?: string): ArraySchema; min(limit: number | Ref, message?: string): ArraySchema; max(limit: number | Ref, message?: string): ArraySchema; ensure(): ArraySchema; @@ -132,19 +119,32 @@ export interface ArraySchema extends Schema { } export interface ObjectSchemaConstructor { - (): ObjectSchema; + (fields?: any): ObjectSchema; new(): ObjectSchema; } export interface ObjectSchema extends Schema { shape(fields: any, noSortEdges?: Array<[string, string]>): ObjectSchema; - from(fromKey: string, toKey: string, alias: boolean): ObjectSchema; + from(fromKey: string, toKey: string, alias?: boolean): ObjectSchema; noUnknown(onlyKnownKeys: boolean, message?: string): ObjectSchema; - transformKeys(callback: (key: any) => any): void + transformKeys(callback: (key: any) => any): void; camelCase(): ObjectSchema; constantCase(): ObjectSchema; } +export type TransformFunction = ((this: T, value: any, originalValue: any) => any); + +export interface WhenOptionsBuilder { + (value: any, schema: T): T; + (v1: any, v2: any, schema: T): T; + (v1: any, v2: any, v3: any, schema: T): T; + (v1: any, v2: any, v3: any, v4: any, schema: T): T; +} + +export type WhenOptions = WhenOptionsBuilder +| { is: boolean | ((value: any) => boolean), then: any, otherwise: any } +| object; + export interface ValidateOptions { /** * Only validate the input, and skip and coercion or transformation. Default - false @@ -201,3 +201,29 @@ export interface SchemaDescription { meta: object; tests: string[]; } + +export interface ValidationError { + name: string; + value: any; + /** + * A string, indicating where there error was thrown. path is empty at the root level. + */ + path: string; + type: any; + /** + * array of error messages + */ + errors: string | string[]; + + /** + * In the case of aggregate errors, inner is an array of ValidationErrors throw earlier in the validation chain. + */ + inner?: ValidationError[]; +} + +export interface Ref { + [key: string]: any; +} + +export interface Lazy extends Schema { +} diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index bba33755b1..a22d96f594 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -1,46 +1,233 @@ import * as yup from 'yup'; +// tslint:disable-next-line:no-duplicate-imports +import { reach, date, Schema, ObjectSchema, ValidationError, MixedSchema, SchemaDescription, TestOptions, ValidateOptions } from 'yup'; -const schema = yup.object().shape({ - name: yup.string().required(), - age: yup.number().required().positive().integer(), - email: yup.string().email(), - website: yup.string().url(), - createdOn: yup.date().default(() => new Date()) +// reach function +let schema = yup.object().shape({ + nested: yup.object().shape({ + arr: yup.array().of( + yup.object().shape({ num: yup.number().max(4) }) + ) + }) + }); +reach(schema, 'nested.arr.num'); +reach(schema, 'nested.arr[].num'); + +// addMethod function +yup.addMethod(yup.date(), 'format', function(this: Schema) { + return this.clone(); }); -// check validity -schema.isValid({ - name: 'jimmy', - age: 24 -}) -.then(valid => valid /* => true */); +// ref function +schema = yup.object().shape({ + baz: yup.ref('foo.bar'), + foo: yup.object().shape({ + bar: yup.string() + }), + x: yup.ref('$x') +}); -class CustomDateSchema extends yup.date { - isWednesday(message?: string): CustomDateSchema { - return this.test({ +schema.cast({ foo: { bar: 'boom' } }, { context: { x: 5 } }); + +// lazy function +const node: ObjectSchema = yup.object().shape({ + id: yup.number(), + child: yup.lazy(() => + node.default(undefined) + ) +}); +const renderable = yup.lazy(value => { + switch (typeof value) { + case 'number': + return yup.number(); + case 'string': + return yup.string(); + default: + return yup.mixed(); + } +}); +const renderables = yup.array().of(renderable); + +// ValidationError +let error: ValidationError = yup.ValidationError('error', 'value', 'path'); +error = yup.ValidationError(['error', 'error2'], true, 'path'); +error = yup.ValidationError(['error', 'error2'], 5, 'path'); + +// mixed +let mixed: MixedSchema = yup.mixed(); +mixed.clone(); +mixed.label('label'); +mixed.meta({ meta: 'value' }); +mixed.describe().label; +mixed.describe().meta; +mixed.describe().tests; +mixed.describe().type; +mixed.concat(yup.string()); +mixed.validate({}); +mixed.validate({ hello: 'world' }, { strict: true }).then(value => value); +mixed.isValid(undefined, (valid: true) => true); +mixed.isValid({ hello: 'world' }).then(valid => valid); +mixed.cast({}); +mixed.isType('hello'); +mixed.strict(true); +mixed.strip(true); +mixed.withMutation(schema => {}); +mixed.default({ number: 5}); +mixed.default(() => ({ number: 5})); +mixed.default(); +mixed.nullable(true); +mixed.required(); +mixed.typeError('type error'); +mixed.oneOf(['hello', 'world'], 'message'); +mixed.notOneOf(['hello', 'world'], 'message'); +mixed.when('isBig', { + is: value => true, + then: yup.number().min(5), + otherwise: yup.number().min(0) +}); +mixed.when('isBig', { + is: true, + then: yup.number().min(5), + otherwise: yup.number().min(0) +}).when('$other', (value: any, schema: MixedSchema) => value === 4 ? schema.required() : schema); +// tslint:disable-next-line:no-invalid-template-strings +mixed.test('is-jimmy', '${path} is not Jimmy', value => value === 'jimmy'); +mixed.test({ + name: 'lessThan5', + exclusive: true, + // tslint:disable-next-line:no-invalid-template-strings + message: '${path} must be less than 5 characters', + test: value => value == null || value.length <= 5 +}); + +yup.string().transform(function(this, value: any, originalvalue: any) { + return this.isType(value) && value !== null ? value.toUpperCase() : value; +}); + +// Extending Schema Types +class ExtendsMixed extends yup.mixed {} +mixed = new ExtendsMixed(); + +class ExtendsMixed2 extends yup.mixed { + constructor() { + super({ type: 'CustomType' }); + } +} +mixed = new ExtendsMixed2(); + +/** + * Creating new Types + */ +class DateSchema extends yup.date { + isWednesday(message?: string): DateSchema { + return this.clone().test({ name: 'Wednesday', // tslint:disable-next-line:no-invalid-template-strings message: message || '${path} must be Wednesday', test: value => true /* Check that day is Wednesday */, - }) as CustomDateSchema; + }); } } -const date = () => new CustomDateSchema(); - yup.object().shape({ - startDate: date().isWednesday().required() -}); -const valid = schema.isValidSync({ + startDate: new DateSchema().isWednesday().required() +}).isValidSync({ startDate: '2017-11-29', }); -// test when -yup.object().shape({ - checkWednesday: yup.bool().required(), +// String schema +const strSchema = yup.string(); +strSchema.isValid('hello'); // => true +strSchema.required(); +strSchema.min(5, 'message'); +strSchema.max(5, 'message'); +strSchema.matches(/(hi|bye)/); +strSchema.email(); +strSchema.url(); +strSchema.ensure(); +strSchema.trim(); +strSchema.lowercase(); +strSchema.uppercase(); + +// Number schema +const numSchema = yup.number(); +numSchema.isValid(10); // => true +numSchema.min(5, 'message'); +numSchema.max(5, 'message'); +numSchema.positive(); +numSchema.negative(); +numSchema.integer(); +numSchema.truncate(); +numSchema.round('floor'); +numSchema.validate(5, { strict: true }).then(value => value).catch(err => err); + +// Boolean Schema +const boolSchema = yup.boolean(); +boolSchema.isValid(true); // => true + +// Date Schema +const dateSchema = yup.date(); +dateSchema.isValid(new Date()); // => true +dateSchema.min(new Date()); +dateSchema.min('2017-11-12'); +dateSchema.min(new Date(), 'message'); +dateSchema.min('2017-11-12', 'message'); +dateSchema.max(new Date()); +dateSchema.max('2017-11-12'); +dateSchema.max(new Date(), 'message'); +dateSchema.max('2017-11-12', 'message'); + +// Array Schema +const arrSchema = yup.array().of(yup.number().min(2)); +arrSchema.isValid([2, 3]); // => true +arrSchema.isValid([1, -24]); // => false +arrSchema.required(); +arrSchema.ensure(); +arrSchema.compact(value => value === null); + +// Object Schema +const objSchema = yup.object().shape({ name: yup.string().required(), - startDate: date() - .required() - .when(['checkWednesday', 'name'], (checkWednesday: boolean, name: string, schema: CustomDateSchema) => { - return checkWednesday ? schema.isWednesday() : schema; - }) + age: yup.number().required().positive().integer(), + email: yup.string().email(), + website: yup.string().url(), }); +yup.object().shape({ + num: yup.number() +}); +// or +yup.object({ + num: yup.number() +}); + +objSchema.from('prop', 'myProp'); +objSchema.from('prop', 'myProp', true); +objSchema.noUnknown(true); +objSchema.noUnknown(true, 'message'); +objSchema.transformKeys(key => key.toUpperCase()); +objSchema.camelCase(); +objSchema.constantCase(); + +const description: SchemaDescription = { + type: 'type', + label: 'label', + meta: { key: 'value' }, + tests: ['test1', 'test2'] +}; + +const testOptions: TestOptions = { + name: 'name', + test: value => true, + message: 'validation error message', + params: { param1: 'value'}, + exclusive: true +}; + +const validateOptions: ValidateOptions = { + strict: true, + abortEarly: true, + stripUnknown: true, + recursive: true, + context: { + key: 'value' + } +}; From 07e0e424475d884fee719d19fa5237ca3c70ae0b Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 10:52:40 +0200 Subject: [PATCH 283/639] Add type definitions for shrink-ray --- types/shrink-ray/index.d.ts | 54 ++++++++++++++++++++++++++++ types/shrink-ray/shrink-ray-tests.ts | 6 ++++ types/shrink-ray/tsconfig.json | 22 ++++++++++++ types/shrink-ray/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/shrink-ray/index.d.ts create mode 100644 types/shrink-ray/shrink-ray-tests.ts create mode 100644 types/shrink-ray/tsconfig.json create mode 100644 types/shrink-ray/tslint.json diff --git a/types/shrink-ray/index.d.ts b/types/shrink-ray/index.d.ts new file mode 100644 index 0000000000..a237c298fa --- /dev/null +++ b/types/shrink-ray/index.d.ts @@ -0,0 +1,54 @@ +// Type definitions for shrink-ray 0.1 +// Project: https://github.com/aickin/shrink-ray +// Definitions by: forabi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { RequestHandler, Request, Response } from 'express'; +import * as zlib from 'zlib'; +type FilterFunction = (req: Request, res: Response) => boolean; + +type Options = Partial<{ + cacheSize: number; + threshold: number; + zlib: Partial<{ + /** default: zlib.constants.Z_NO_FLUSH */ + flush?: number; + + /** default: zlib.constants.Z_FINISH */ + finishFlush?: number; + + /** default: 16*1024 */ + chunkSize?: number; + windowBits?: number; + + /** compression only */ + strategy?: number; + + /** deflate/inflate only, empty dictionary by default */ + dictionary?: any; + + /** compression only */ + level: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + + /** compression only */ + memLevel: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + }>; + brotli: { + lgblock: number; + lgwin: number; + mode: 0 | 1 | 2; + quality: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11; + }; + filter: FilterFunction; + cache(req: Request, res: Response): boolean; +}>; + +interface CreateMiddleware { + (options?: Options): RequestHandler; + filter: FilterFunction; +} + +declare const createMiddleware: CreateMiddleware; + +export = createMiddleware; diff --git a/types/shrink-ray/shrink-ray-tests.ts b/types/shrink-ray/shrink-ray-tests.ts new file mode 100644 index 0000000000..e221806b88 --- /dev/null +++ b/types/shrink-ray/shrink-ray-tests.ts @@ -0,0 +1,6 @@ +import * as express from 'express'; +import * as shrinkRay from 'shrink-ray'; + +const app = express(); + +app.use(shrinkRay()); diff --git a/types/shrink-ray/tsconfig.json b/types/shrink-ray/tsconfig.json new file mode 100644 index 0000000000..e90ce49102 --- /dev/null +++ b/types/shrink-ray/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shrink-ray-tests.ts" + ] +} diff --git a/types/shrink-ray/tslint.json b/types/shrink-ray/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shrink-ray/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 24ea09d1a531b3aacadf537120f16f1b3c3f3f73 Mon Sep 17 00:00:00 2001 From: Gregor Yushinov Date: Thu, 30 Nov 2017 10:34:56 +0100 Subject: [PATCH 284/639] Fixed connection options --- types/mongoose/index.d.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index f86dea4f8a..7eb768f3c8 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -366,11 +366,11 @@ declare module "mongoose" { auth?: any; /** Use ssl connection (needs to have a mongod server with ssl support) (default: true) */ ssl?: boolean; - /** Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. */ - sslValidate?: object; - /** Reconnect on error (default: true) */ - poolSize?: number; /** Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) */ + sslValidate?: object; + /** Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. */ + poolSize?: number; + /** Reconnect on error (default: true) */ autoReconnect?: boolean; /** TCP KeepAlive on the socket with a X ms delay before start (default: 0). */ keepAlive?: number; @@ -380,10 +380,13 @@ declare module "mongoose" { socketTimeoutMS?: number; /** If the database authentication is dependent on another databaseName. */ authSource?: string; - /** Attempt to reconnect #times (default: 30) */ - retries?: number; + /** If you're connected to a single server or mongos proxy (as opposed to a replica set), + * the MongoDB driver will try to reconnect every reconnectInterval milliseconds for reconnectTries + * times, and give up afterward. When the driver gives up, the mongoose connection emits a + * reconnectFailed event. (default: 30) */ + reconnectTries?: number; /** Will wait # milliseconds between retries (default: 1000) */ - reconnectWait?: number; + reconnectInterval?: number; /** The name of the replicaset to connect to. */ replicaSet?: string; /** The current value of the parameter native_parser */ @@ -400,6 +403,14 @@ declare module "mongoose" { readPreference?: string; /** An object representing read preference tags, see: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */ readPreferencetags?: object; + /** Triggers the server instance to call ismaster (default: true). */ + monitoring?: boolean; + /** The interval of calling ismaster when monitoring is enabled (default: 10000). */ + haInterval?: number; + /** Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit (default: false). */ + domainsEnabled?: boolean; + /** How long driver keeps waiting for servers to come back up (default: Number.MAX_VALUE) */ + bufferMaxEntries?: number; // TODO safe?: any; From 6f1245f8f19c795278962dc6c1b477bad9e27476 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 12:03:44 +0200 Subject: [PATCH 285/639] Set "strictFunctionTypes": true --- types/shrink-ray/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/shrink-ray/tsconfig.json b/types/shrink-ray/tsconfig.json index e90ce49102..84b143dd64 100644 --- a/types/shrink-ray/tsconfig.json +++ b/types/shrink-ray/tsconfig.json @@ -6,6 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, + "strictFunctionTypes": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From d7ca842aebb51baece1b60c6cf754b835f107d32 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Thu, 30 Nov 2017 11:21:19 +0100 Subject: [PATCH 286/639] Fix some smaller things - Rename generated enums not present in schemas so that they have an underscore first in hopes of it being seen as private (and therefore not available to code) - Fix browser.bookmarks.import/export as per PR comments --- types/firefox-webext-browser/index.d.ts | 65 +++++++++++++------------ 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts index 2063abc93e..8a2d34b0be 100644 --- a/types/firefox-webext-browser/index.d.ts +++ b/types/firefox-webext-browser/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Jacob Bom // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 +// Generated using script at github.com/bomjacob/definitelytyped-firefox-webext-browser interface EventListener any> { addListener: (callback: T) => void; @@ -44,13 +45,13 @@ declare namespace browser.alarms { declare namespace browser.manifest { /* manifest types */ - type OptionalPermission = OptionalPermissionEnum; + type OptionalPermission = _OptionalPermission; - type Permission = string | OptionalPermission | PermissionEnum; + type Permission = string | OptionalPermission | _Permission; interface ProtocolHandler { name: string; - protocol: string | ProtocolHandlerProtocolEnum; + protocol: string | _ProtocolHandlerProtocol; uriTemplate: ExtensionURL | HttpURL; } @@ -75,7 +76,7 @@ declare namespace browser.manifest { icons?: { [key: number]: string; }; - incognito?: WebExtensionManifestIncognitoEnum; + incognito?: _WebExtensionManifestIncognito; background?: { page: ExtensionURL; persistent?: PersistentBackgroundProperty; @@ -105,7 +106,7 @@ declare namespace browser.manifest { theme_icons?: ThemeIcons[]; default_popup?: string; browser_style?: boolean; - default_area?: WebExtensionManifestBrowserActionDefaultAreaEnum; + default_area?: _WebExtensionManifestBrowserActionDefaultArea; }; chrome_settings_overrides?: { homepage?: string; @@ -219,9 +220,9 @@ declare namespace browser.manifest { strict_max_version?: string; } - type MatchPattern = string | string | MatchPatternEnum; + type MatchPattern = string | string | _MatchPattern; - type MatchPatternInternal = string | string | MatchPatternInternalEnum; + type MatchPatternInternal = string | string | _MatchPatternInternal; interface ContentScript { matches: MatchPattern[]; @@ -253,13 +254,13 @@ declare namespace browser.manifest { name: string; description: string; path: string; - type: NativeManifestTypeEnum; + type: _NativeManifestType; allowed_extensions: ExtensionID[]; } | { name: ExtensionID; description: string; data: any; - type: NativeManifestTypeEnum; + type: _NativeManifestType; }; interface ThemeType { @@ -365,14 +366,14 @@ declare namespace browser.manifest { timezones?: ExtensionURL; }; properties?: { - additional_backgrounds_alignment?: ThemeTypeAdditionalBackgroundsAlignmentEnum[]; - additional_backgrounds_tiling?: ThemeTypeAdditionalBackgroundsTilingEnum[]; + additional_backgrounds_alignment?: _ThemeTypeAdditionalBackgroundsAlignment[]; + additional_backgrounds_tiling?: _ThemeTypeAdditionalBackgroundsTiling[]; }; } type KeyName = string | string | string; - enum OptionalPermissionEnum { + enum _OptionalPermission { browserSettings = "browserSettings", cookies = "cookies", clipboardRead = "clipboardRead", @@ -391,7 +392,7 @@ declare namespace browser.manifest { tabs = "tabs" } - enum PermissionEnum { + enum _Permission { contextualIdentities = "contextualIdentities", downloads = "downloads", downloadsopen = "downloads.open", @@ -414,7 +415,7 @@ declare namespace browser.manifest { sessions = "sessions" } - enum ProtocolHandlerProtocolEnum { + enum _ProtocolHandlerProtocol { bitcoin = "bitcoin", geo = "geo", gopher = "gopher", @@ -437,35 +438,35 @@ declare namespace browser.manifest { xmpp = "xmpp" } - enum WebExtensionManifestIncognitoEnum { + enum _WebExtensionManifestIncognito { spanning = "spanning" } - enum WebExtensionManifestBrowserActionDefaultAreaEnum { + enum _WebExtensionManifestBrowserActionDefaultArea { navbar = "navbar", menupanel = "menupanel", tabstrip = "tabstrip", personaltoolbar = "personaltoolbar" } - enum MatchPatternEnum { + enum _MatchPattern { all_urls = "" } - enum MatchPatternInternalEnum { + enum _MatchPatternInternal { all_urls = "" } - enum NativeManifestTypeEnum { + enum _NativeManifestType { pkcs11 = "pkcs11", stdio = "stdio" } - enum NativeManifestTypeEnum { + enum _NativeManifestType { storage = "storage" } - enum ThemeTypeAdditionalBackgroundsAlignmentEnum { + enum _ThemeTypeAdditionalBackgroundsAlignment { bottom = "bottom", center = "center", left = "left", @@ -482,7 +483,7 @@ declare namespace browser.manifest { righttop = "right top" } - enum ThemeTypeAdditionalBackgroundsTilingEnum { + enum _ThemeTypeAdditionalBackgroundsTiling { norepeat = "no-repeat", repeat = "repeat", repeatx = "repeat-x", @@ -515,13 +516,13 @@ declare namespace browser.browserSettings { declare namespace browser.clipboard { type ArrayBuffer = any; - enum SetImageDataEnum { + enum _SetImageData { jpeg = "jpeg", png = "png" } /* clipboard functions */ - function setImageData(imageData: ArrayBuffer, imageType: SetImageDataEnum): void; + function setImageData(imageData: ArrayBuffer, imageType: _SetImageData): void; } declare namespace browser.contextualIdentities { @@ -768,7 +769,7 @@ declare namespace browser.downloads { exists?: boolean; } - enum DownloadMethodEnum { + enum _DownloadMethod { GET = "GET", POST = "POST" } @@ -780,7 +781,7 @@ declare namespace browser.downloads { incognito?: boolean; conflictAction?: FilenameConflictAction; saveAs?: boolean; - method?: DownloadMethodEnum; + method?: _DownloadMethod; headers?: Array<{ name: string; value: string; @@ -1956,6 +1957,10 @@ declare namespace browser.bookmarks { type?: BookmarkTreeNodeType; } + export {_import as import}; + + export {_export as export}; + /* bookmarks functions */ function get(idOrIdList: string | string[]): Promise; @@ -1989,9 +1994,9 @@ declare namespace browser.bookmarks { function removeTree(id: string): Promise; - function import_(): Promise; + function _import(): Promise; - function export_(): Promise; + function _export(): Promise; /* bookmarks events */ const onCreated: EventListener<(id: string, bookmark: BookmarkTreeNode) => void>; @@ -2470,10 +2475,10 @@ declare namespace browser.menus { editable: boolean; wasChecked?: boolean; checked?: boolean; - modifiers: OnClickDataModifiersEnum[]; + modifiers: _OnClickDataModifiers[]; } - enum OnClickDataModifiersEnum { + enum _OnClickDataModifiers { Shift = "Shift", Alt = "Alt", Command = "Command", From 2428c4197f851444a3708c0ddb43f39e745227c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Thu, 30 Nov 2017 11:25:45 +0100 Subject: [PATCH 287/639] Fixes lint errors in test file. --- types/lodash/lodash-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index e00d951023..7f624ec50c 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -5702,7 +5702,7 @@ namespace TestorderBy { let orders: boolean|string|(boolean|string)[] = true as any; { - let iteratees: (value: string) => any|((value: string) => any)[] = (value) => 1; + let iteratees = (value: string) => 1; let result: string[]; result = _.orderBy('acbd', iteratees); @@ -5710,7 +5710,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => 1; + let iteratees = (value: SampleObject) => 1; let result: SampleObject[]; result = _.orderBy<{a: number}, SampleObject>(array, iteratees); @@ -5735,7 +5735,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; + let iteratees = (value: SampleObject) => ""; let result: _.LoDashImplicitArrayWrapper; result = _(array).orderBy<{a: number}>(iteratees); @@ -5758,7 +5758,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; + let iteratees = (value: SampleObject) => ""; let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().orderBy<{a: number}>(iteratees); From 3b424cc1421d064df896f2d12594d579edb6cab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Thu, 30 Nov 2017 11:38:04 +0100 Subject: [PATCH 288/639] Revert "Fixes lint errors in test file." This reverts commit 2428c4197f851444a3708c0ddb43f39e745227c8. --- types/lodash/lodash-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 7f624ec50c..e00d951023 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -5702,7 +5702,7 @@ namespace TestorderBy { let orders: boolean|string|(boolean|string)[] = true as any; { - let iteratees = (value: string) => 1; + let iteratees: (value: string) => any|((value: string) => any)[] = (value) => 1; let result: string[]; result = _.orderBy('acbd', iteratees); @@ -5710,7 +5710,7 @@ namespace TestorderBy { } { - let iteratees = (value: SampleObject) => 1; + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => 1; let result: SampleObject[]; result = _.orderBy<{a: number}, SampleObject>(array, iteratees); @@ -5735,7 +5735,7 @@ namespace TestorderBy { } { - let iteratees = (value: SampleObject) => ""; + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; let result: _.LoDashImplicitArrayWrapper; result = _(array).orderBy<{a: number}>(iteratees); @@ -5758,7 +5758,7 @@ namespace TestorderBy { } { - let iteratees = (value: SampleObject) => ""; + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().orderBy<{a: number}>(iteratees); From d9142c2d737c332ce10f1adc628f505a05d81f5f Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 12:43:55 +0200 Subject: [PATCH 289/639] Prettify --- types/react-resolver/index.d.ts | 48 +++++++++---------- types/react-resolver/react-resolver-tests.tsx | 28 +++++------ 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/types/react-resolver/index.d.ts b/types/react-resolver/index.d.ts index 742260dc7c..b3d123ccca 100644 --- a/types/react-resolver/index.d.ts +++ b/types/react-resolver/index.d.ts @@ -7,14 +7,14 @@ import { ComponentType, StatelessComponent, Factory } from 'react'; export interface Resolver { - resolve( + resolve( factory: Factory

, - ): Promise<{ + ): Promise<{ data: D; Resolved: StatelessComponent

; - }>; + }>; - render

(factory: Factory

, root: Node | null): void; + render

(factory: Factory

, root: Node | null): void; } export const Resolver: Resolver; @@ -23,9 +23,9 @@ export type ResolveFn = (props: Props) => Promise; /** Use this for gaining access to a context as a prop without the boilerplate of setting `contextTypes`. */ export function context( - prop: K, + prop: K, ): ( - component: ComponentType, + component: ComponentType, ) => StatelessComponent>; /** @@ -34,36 +34,36 @@ export function context( * perform it only on the client. */ export function client( - loadingComponent: ComponentType, + loadingComponent: ComponentType, ): ( - component: ComponentType, + component: ComponentType, ) => StatelessComponent; export function resolve< - OwnProps, - K extends string, - V, - MoreProps = { [x: string]: any } + OwnProps, + K extends string, + V, + MoreProps = { [x: string]: any } >( - prop: K, - resolveFn: ResolveFn, + prop: K, + resolveFn: ResolveFn, ): ( - component: ComponentType, + component: ComponentType, ) => StatelessComponent; export function resolve< - OwnProps, - ResolvableProps = { [x: string]: any }, - MoreProps = { [x: string]: any } + OwnProps, + ResolvableProps = { [x: string]: any }, + MoreProps = { [x: string]: any } >( - resolversMap: { + resolversMap: { [K in keyof ResolvableProps]: ResolveFn< - OwnProps & MoreProps, - ResolvableProps[K] + OwnProps & MoreProps, + ResolvableProps[K] > - }, + }, ): ( - component: ComponentType< + component: ComponentType< OwnProps & { [K in keyof ResolvableProps]?: ResolvableProps[K] } - >, + >, ) => StatelessComponent; diff --git a/types/react-resolver/react-resolver-tests.tsx b/types/react-resolver/react-resolver-tests.tsx index 4c4314c063..1f19e4ff6d 100644 --- a/types/react-resolver/react-resolver-tests.tsx +++ b/types/react-resolver/react-resolver-tests.tsx @@ -11,23 +11,23 @@ interface ResolvedProps { } class Page extends React.Component { - render() { - return

Hello, {this.props.data}!
; - } + render() { + return
Hello, {this.props.data}!
; + } } const ResolvedPageWithSingleProp = resolve('data', async () => { - return new Promise(resolve => { - setTimeout(() => resolve('World'), 500); - }); + return new Promise(resolve => { + setTimeout(() => resolve('World'), 500); + }); })(Page); const ResolvedPageWithPropMap = resolve({ - data: async () => { - return new Promise(resolve => { - setTimeout(() => resolve('World'), 500); - }); - }, + data: async () => { + return new Promise(resolve => { + setTimeout(() => resolve('World'), 500); + }); + }, })(Page); expect().toExist(); @@ -36,9 +36,7 @@ expect().toExist(); // Resolver.render(() => , document.getElementById('app')); Resolver.resolve(() => { - return ( - - ); + return ; }).then(({ data, Resolved }) => { - expect(data).toBe('World'); + expect(data).toBe('World'); }); From 61ff9913e1b97c1d7e4cba7cd0be8dee42c798b5 Mon Sep 17 00:00:00 2001 From: Matthias Jobst Date: Thu, 30 Nov 2017 11:54:46 +0100 Subject: [PATCH 290/639] Added Date to brush.Scale and removed it from Primitive --- types/d3/v3/index.d.ts | 88 +++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/types/d3/v3/index.d.ts b/types/d3/v3/index.d.ts index fabb96be43..2642ecd5d3 100644 --- a/types/d3/v3/index.d.ts +++ b/types/d3/v3/index.d.ts @@ -433,7 +433,7 @@ declare namespace d3 { /** * Administrivia: JavaScript primitive types, or "things that toString() predictably". */ - export type Primitive = number | string | boolean | Date | undefined; + export type Primitive = number | string | boolean ; /** * Administrivia: anything with a valueOf(): number method is comparable, so we allow it in numeric operations @@ -932,28 +932,28 @@ declare namespace d3 { export function flush(): void; } - interface BaseEvent { - type: string; - sourceEvent?: Event; - } + interface BaseEvent { + type: string; + sourceEvent?: Event; + } - /** - * Define a D3-specific ZoomEvent per https://github.com/mbostock/d3/wiki/Zoom-Behavior#event - */ - interface ZoomEvent extends BaseEvent { - scale: number; - translate: [number, number]; - } + /** + * Define a D3-specific ZoomEvent per https://github.com/mbostock/d3/wiki/Zoom-Behavior#event + */ + interface ZoomEvent extends BaseEvent { + scale: number; + translate: [number, number]; + } - /** - * Define a D3-specific DragEvent per https://github.com/mbostock/d3/wiki/Drag-Behavior#on - */ - interface DragEvent extends BaseEvent { - x: number; - y: number; - dx: number; - dy: number; - } + /** + * Define a D3-specific DragEvent per https://github.com/mbostock/d3/wiki/Drag-Behavior#on + */ + interface DragEvent extends BaseEvent { + x: number; + y: number; + dx: number; + dy: number; + } /** * The current event's value. Use this variable in a handler registered with `selection.on`. @@ -1391,8 +1391,8 @@ declare namespace d3 { export function requote(string: string): string; export var rgb: { - new (r: number, g: number, b: number): Rgb; - new (color: string): Rgb; + new(r: number, g: number, b: number): Rgb; + new(color: string): Rgb; (r: number, g: number, b: number): Rgb; (color: string): Rgb; @@ -1412,8 +1412,8 @@ declare namespace d3 { } export var hsl: { - new (h: number, s: number, l: number): Hsl; - new (color: string): Hsl; + new(h: number, s: number, l: number): Hsl; + new(color: string): Hsl; (h: number, s: number, l: number): Hsl; (color: string): Hsl; @@ -1433,8 +1433,8 @@ declare namespace d3 { } export var hcl: { - new (h: number, c: number, l: number): Hcl; - new (color: string): Hcl; + new(h: number, c: number, l: number): Hcl; + new(color: string): Hcl; (h: number, c: number, l: number): Hcl; (color: string): Hcl; @@ -1450,8 +1450,8 @@ declare namespace d3 { } export var lab: { - new (l: number, a: number, b: number): Lab; - new (color: string): Lab; + new(l: number, a: number, b: number): Lab; + new(color: string): Lab; (l: number, a: number, b: number): Lab; (color: string): Lab; @@ -1471,7 +1471,7 @@ declare namespace d3 { export var color: { (): Color; - new (): Color; + new(): Color; }; interface Color { @@ -1685,7 +1685,7 @@ declare namespace d3 { export function category20(): Ordinal; export function category20b(): Ordinal; export function category20b(): Ordinal; - export function category20c(): Ordinal; + export function category20c(): Ordinal; export function category20c(): Ordinal; interface Ordinal { @@ -1822,10 +1822,10 @@ declare namespace d3 { export function format(specifier: string): Format; export module format { - export function multi(formats: Array<[string, (d: Date) => boolean|number]>): Format; + export function multi(formats: Array<[string, (d: Date) => boolean | number]>): Format; export function utc(specifier: string): Format; namespace utc { - export function multi(formats: Array<[string, (d: Date) => boolean|number]>): Format; + export function multi(formats: Array<[string, (d: Date) => boolean | number]>): Format; } export var iso: Format; @@ -2578,7 +2578,7 @@ declare namespace d3 { tickFormat(): (t: any) => string; tickFormat(format: (t: any) => string): Axis; - tickFormat(format:string): Axis; + tickFormat(format: string): Axis; } export function brush(): Brush; @@ -2586,13 +2586,13 @@ declare namespace d3 { namespace brush { interface Scale { - domain(): number[]; - domain(domain: number[]): Scale; + domain(): number[] | Date[]; + domain(domain: number[] | Date[]): Scale; - range(): number[]; - range(range: number[]): Scale; + range(): number[] | Date[]; + range(range: number[] | Date[]): Scale; - invert?(y: number): number; + invert?(y: number | Date): number | Date; } } @@ -2610,8 +2610,8 @@ declare namespace d3 { y(y: brush.Scale): Brush; // https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Controls.md#brush_extent - extent(): [number, number] | [[number, number], [number, number]] | [Date, Date]; - extent(extent: [number, number] | [[number, number], [number, number]]): Brush; + extent(): [number, number] | [[number, number], [number, number]] | [Date, Date] | [[Date, Date],[Date,Date]]; + extent(extent: [number, number] | [[number, number], [number, number]] | [Date, Date] | [[Date, Date], [Date, Date]]): Brush; clamp(): boolean | [boolean, boolean]; clamp(clamp: boolean | [boolean, boolean]): Brush; @@ -2764,7 +2764,7 @@ declare namespace d3 { timeFormat: { (specifier: string): time.Format; utc(specifier: string): time.Format; - multi(formats: Array<[string, (d: Date) => boolean|number]>): time.Format; + multi(formats: Array<[string, (d: Date) => boolean | number]>): time.Format; } } @@ -2883,8 +2883,8 @@ declare namespace d3 { // Read the note at the end of the section where it talks about initial numbering namespace force { interface Link { - source: T|number; - target: T|number; + source: T | number; + target: T | number; } interface Node { From c72120d5bc85c91b702de6c6bf13738bc18dff7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Thu, 30 Nov 2017 12:10:46 +0100 Subject: [PATCH 291/639] Adds missing export for lodash/conformsTo. --- types/lodash/conformsTo.d.ts | 2 ++ types/lodash/tsconfig.json | 1 + 2 files changed, 3 insertions(+) create mode 100644 types/lodash/conformsTo.d.ts diff --git a/types/lodash/conformsTo.d.ts b/types/lodash/conformsTo.d.ts new file mode 100644 index 0000000000..320b1806e0 --- /dev/null +++ b/types/lodash/conformsTo.d.ts @@ -0,0 +1,2 @@ +import { conformsTo } from "./index"; +export = conformsTo; diff --git a/types/lodash/tsconfig.json b/types/lodash/tsconfig.json index 7e2de20632..5a8938d9a2 100644 --- a/types/lodash/tsconfig.json +++ b/types/lodash/tsconfig.json @@ -45,6 +45,7 @@ "cloneWith.d.ts", "compact.d.ts", "concat.d.ts", + "conformsTo.d.ts", "constant.d.ts", "countBy.d.ts", "create.d.ts", From b85777392521e6933ed9b22f2e6eccb31f2b3ce2 Mon Sep 17 00:00:00 2001 From: Nikita Gubchenko Date: Thu, 30 Nov 2017 15:45:43 +0300 Subject: [PATCH 292/639] [recharts]: added missing IconType The new IconType value was introduced by this PR: https://github.com/recharts/recharts/pull/985 --- types/recharts/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index 6fa7273108..7d42cee0d3 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -21,7 +21,7 @@ export type ItemSorter = (a: T, b: T) => number; export type ContentRenderer

= (props: P) => React.ReactNode; export type DataKey = string | number | ((dataObject: any) => number | [number, number]); -export type IconType = 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye'; +export type IconType = 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'plainline'; export type LegendType = IconType | 'none'; export type LayoutType = 'horizontal' | 'vertical'; export type AnimationEasingType = 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'; From 90d95fc43296f9a7fce902102b8a604b29e18ce4 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 15:31:48 +0200 Subject: [PATCH 293/639] Try fix CI with strictFunctionTypes: false --- types/react-resolver/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-resolver/tsconfig.json b/types/react-resolver/tsconfig.json index c8d99b4c25..94a604e352 100644 --- a/types/react-resolver/tsconfig.json +++ b/types/react-resolver/tsconfig.json @@ -8,7 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": true, + "strictFunctionTypes": false, "baseUrl": "../", "typeRoots": [ "../" From a7491924a9a6782b9859671f712ce0539dc64921 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 15:54:34 +0200 Subject: [PATCH 294/639] Try fix again --- types/react-resolver/index.d.ts | 10 +++++----- types/react-resolver/react-resolver-tests.tsx | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/types/react-resolver/index.d.ts b/types/react-resolver/index.d.ts index b3d123ccca..8afa3285a0 100644 --- a/types/react-resolver/index.d.ts +++ b/types/react-resolver/index.d.ts @@ -7,14 +7,14 @@ import { ComponentType, StatelessComponent, Factory } from 'react'; export interface Resolver { - resolve( + resolve

( factory: Factory

, ): Promise<{ - data: D; + data: any; Resolved: StatelessComponent

; }>; - render

(factory: Factory

, root: Node | null): void; + render(factory: Factory, root: Node | null): void; } export const Resolver: Resolver; @@ -22,11 +22,11 @@ export const Resolver: Resolver; export type ResolveFn = (props: Props) => Promise; /** Use this for gaining access to a context as a prop without the boilerplate of setting `contextTypes`. */ -export function context( +export function context( prop: K, ): ( component: ComponentType, -) => StatelessComponent>; +) => StatelessComponent>; /** * Use `@client(LoaderComponent)` (or `client(LoaderComponent)(YourComponent)`) diff --git a/types/react-resolver/react-resolver-tests.tsx b/types/react-resolver/react-resolver-tests.tsx index 1f19e4ff6d..ce41e6db4c 100644 --- a/types/react-resolver/react-resolver-tests.tsx +++ b/types/react-resolver/react-resolver-tests.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Resolver, resolve } from 'react-resolver'; +import { Resolver, resolve, context } from 'react-resolver'; import * as expect from 'expect'; interface OwnProps { @@ -30,6 +30,8 @@ const ResolvedPageWithPropMap = resolve({ }, })(Page); +const PageWithContext = context('history')(Page); + expect().toExist(); expect().toExist(); From 57d94953c2602f63d2a413b23aee571a3ab7c411 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 15:59:45 +0200 Subject: [PATCH 295/639] Fix again --- types/react-resolver/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-resolver/index.d.ts b/types/react-resolver/index.d.ts index 8afa3285a0..2b27d26d6a 100644 --- a/types/react-resolver/index.d.ts +++ b/types/react-resolver/index.d.ts @@ -22,11 +22,11 @@ export const Resolver: Resolver; export type ResolveFn = (props: Props) => Promise; /** Use this for gaining access to a context as a prop without the boilerplate of setting `contextTypes`. */ -export function context( +export function context( prop: K, ): ( component: ComponentType, -) => StatelessComponent>; +) => StatelessComponent>; /** * Use `@client(LoaderComponent)` (or `client(LoaderComponent)(YourComponent)`) From 5593cde710e9e5c599880c5f8987e70cd4703b43 Mon Sep 17 00:00:00 2001 From: 43081j <43081j@localhost> Date: Thu, 30 Nov 2017 14:40:55 +0000 Subject: [PATCH 296/639] add fake server options --- types/sinon/index.d.ts | 23 ++++++++++++----------- types/sinon/sinon-tests.ts | 10 ++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 4c8f22a6f4..bc657ef79b 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Sinon 4.0 +// Type definitions for Sinon 4.1 // Project: http://sinonjs.org/ // Definitions by: William Sears // Jonathan Little @@ -11,10 +11,8 @@ // sinon uses DOM dependencies which are absent in browser-less environment like node.js // to avoid compiler errors this monkey patch is used // see more details in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11351 -// tslint:disable no-empty-interface -interface Event { } -interface Document { } -// tslint:enable no-empty-interface +interface Event { } // tslint:disable-line no-empty-interface +interface Document { } // tslint:disable-line no-empty-interface declare namespace Sinon { interface SinonSpyCallApi { @@ -293,14 +291,10 @@ declare namespace Sinon { FakeXMLHttpRequest: SinonFakeXMLHttpRequest; } - interface SinonFakeServer { + interface SinonFakeServer extends SinonFakeServerOptions { // Properties - autoRespond: boolean; - autoRespondAfter: number; - fakeHTTPMethods: boolean; getHTTPMethod(request: SinonFakeXMLHttpRequest): string; requests: SinonFakeXMLHttpRequest[]; - respondImmediately: boolean; // Methods respondWith(body: string): void; @@ -322,8 +316,15 @@ declare namespace Sinon { restore(): void; } + interface SinonFakeServerOptions { + autoRespond?: boolean; + autoRespondAfter?: number; + fakeHTTPMethods?: boolean; + respondImmediately?: boolean; + } + interface SinonFakeServerStatic { - create(): SinonFakeServer; + create(options?: SinonFakeServerOptions): SinonFakeServer; } interface SinonStatic { diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 33ac93f595..1fafb259ee 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -230,6 +230,15 @@ function testSpy() { sinon.spy().calledImmediatelyBefore(otherSpy); } +function testFakeServer() { + sinon.fakeServer.create({ + autoRespond: true, + autoRespondAfter: 3, + fakeHTTPMethods: true, + respondImmediately: false + }); +} + testOne(); testTwo(); testThree(); @@ -249,6 +258,7 @@ testGetterStub(); testSetterStub(); testValueStub(); testThrowsStub(); +testFakeServer(); const clock = sinon.useFakeTimers(); clock.setSystemTime(1000); From e277980c20460315b52f212f35b6c65d52e25ded Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Thu, 30 Nov 2017 20:29:37 +0000 Subject: [PATCH 297/639] Lodash: `overSome`: use generic instead of any --- types/lodash/index.d.ts | 6 +++--- types/lodash/lodash-tests.ts | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index f038846d22..7fa84c808c 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -16592,21 +16592,21 @@ declare namespace _ { * @param predicates The predicates to check. * @return Returns the new function. */ - overSome(...predicates: Array any>>): (...args: any[]) => boolean; + overSome(...predicates: Array boolean>>): (...args: T[]) => boolean; } interface LoDashImplicitWrapper { /** * @see _.overSome */ - overSome(...predicates: Array any>>): LoDashImplicitWrapper<(...args: any[]) => boolean>; + overSome(...predicates: Array boolean>>): LoDashImplicitWrapper<(...args: T[]) => boolean>; } interface LoDashExplicitWrapper { /** * @see _.overSome */ - overSome(...predicates: Array any>>): LoDashExplicitWrapper<(...args: any[]) => boolean>; + overSome(...predicates: Array boolean>>): LoDashExplicitWrapper<(...args: T[]) => boolean>; } //_.property diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index e40569204d..4200459e9c 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -13774,16 +13774,16 @@ namespace TestOverEvery { // _.overSome namespace TestOverSome { { - let result: (...args: any[]) => boolean; + let result: (...args: number[]) => boolean; - result = _.overSome(() => true); - result = _.overSome(() => true, () => true); - result = _.overSome([() => true]); - result = _.overSome([() => true], [() => true]); + result = _.overSome((n: number) => true); + result = _.overSome((n: number) => true, (n: number) => true); + result = _.overSome([(n: number) => true]); + result = _.overSome([(n: number) => true], [(n: number) => true]); } { - let result: _.LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; + let result: _.LoDashImplicitObjectWrapper<(...args: number[]) => boolean>; result = _(Math.max).overSome(); result = _(Math.max).overSome(() => true); @@ -13792,7 +13792,7 @@ namespace TestOverSome { } { - let result: _.LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; + let result: _.LoDashExplicitObjectWrapper<(...args: number[]) => boolean>; result = _(Math.max).chain().overSome(); result = _(Math.max).chain().overSome(() => true); From 4f199da0894470598ae76f0592ba1fbb023b2a34 Mon Sep 17 00:00:00 2001 From: Kostya Misura Date: Thu, 30 Nov 2017 22:38:22 +0200 Subject: [PATCH 298/639] extends lambda callback signature to accept primitive types (boolean, number and string) as result --- types/aws-lambda/aws-lambda-tests.ts | 3 +++ types/aws-lambda/index.d.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index ebd31429de..d21f477be0 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -294,6 +294,9 @@ function callback(cb: AWSLambda.Callback) { cb(null); cb(error); cb(null, anyObj); + cb(null, b); + cb(null, str); + cb(null, num); } /* Proxy Callback */ diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index 3b9e31f14c..d6b50ff5e6 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -9,6 +9,7 @@ // wwwy3y3 // Ishaan Malhi // Daniel Cottone +// Kostya Misura // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -364,7 +365,7 @@ export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Co * @param error – an optional parameter that you can use to provide results of the failed Lambda function execution. * @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. */ -export type Callback = (error?: Error | null, result?: object) => void; +export type Callback = (error?: Error | null, result?: object | boolean | number | string) => void; export type ProxyCallback = (error?: Error | null, result?: ProxyResult) => void; export type CustomAuthorizerCallback = (error?: Error | null, result?: AuthResponse) => void; From b0486477ad5ba9895f28f565c0d5238046df8b2c Mon Sep 17 00:00:00 2001 From: Rich Tagger Date: Thu, 30 Nov 2017 12:48:36 -0800 Subject: [PATCH 299/639] Update CharacterMetadata.applyEntity and Modifier.applyEntity null is how removal is indicated --- types/draft-js/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index 3eaa05aa30..ccc0fcf49e 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -797,7 +797,7 @@ declare namespace Draft { class CharacterMetadata { static applyStyle(record: CharacterMetadata, style: string): CharacterMetadata; static removeStyle(record: CharacterMetadata, style: string): CharacterMetadata; - static applyEntity(record: CharacterMetadata, entityKey: string): CharacterMetadata; + static applyEntity(record: CharacterMetadata, entityKey: string | null): CharacterMetadata; static applyEntity(record: CharacterMetadata): CharacterMetadata; /** * Use this function instead of the `CharacterMetadata` constructor. @@ -894,7 +894,7 @@ declare namespace Draft { static setBlockData(contentState: ContentState, selectionState: SelectionState, blockData: Immutable.Map): ContentState; static mergeBlockData(contentState: ContentState, selectionState: SelectionState, blockData: Immutable.Map): ContentState; - static applyEntity(contentState: ContentState, selectionState: SelectionState, entityKey: string): ContentState; + static applyEntity(contentState: ContentState, selectionState: SelectionState, entityKey: string | null): ContentState; } class RichTextEditorUtil { From ee8e4473c93103fe5ce933bf751784ecf79350f5 Mon Sep 17 00:00:00 2001 From: Adam Cook Date: Thu, 30 Nov 2017 13:03:45 -0800 Subject: [PATCH 300/639] Fix incorrect name in stripe-v3 Error --- types/stripe-v3/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/stripe-v3/index.d.ts b/types/stripe-v3/index.d.ts index db8257401c..baa294020a 100644 --- a/types/stripe-v3/index.d.ts +++ b/types/stripe-v3/index.d.ts @@ -118,7 +118,7 @@ declare namespace stripe { charge: string; message?: string; code?: string; - declined_code?: string; + decline_code?: string; param?: string; } From af5e416be3d1516e24f7c9595e97c702d9231c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Por=C4=99bski?= Date: Fri, 1 Dec 2017 00:29:44 +0100 Subject: [PATCH 301/639] Update definitions to match react-table@6.7.4 --- types/react-table/index.d.ts | 176 ++++++++++++++++++++---- types/react-table/react-table-tests.tsx | 138 ++++++++++++++++--- 2 files changed, 271 insertions(+), 43 deletions(-) diff --git a/types/react-table/index.d.ts b/types/react-table/index.d.ts index 30479e6149..8e347c04c4 100644 --- a/types/react-table/index.d.ts +++ b/types/react-table/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for react-table 6.6 +// Type definitions for react-table 6.7 // Project: https://github.com/react-tools/react-table -// Definitions by: Roy Xue , Pavel Sakalo +// Definitions by: Roy Xue , Pavel Sakalo , Krzysztof Porębski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 import * as React from 'react'; @@ -11,19 +11,23 @@ export type Accessor = string | string[] | object | AccessorFunction; export type Aggregator = (values: any, rows: any) => any; export type TableCellRenderer = ((data: any, column: any) => React.ReactNode) | React.ReactNode; export type FilterRender = (params: { column: Column, filter: any, onFilterChange: ReactTableFunction, key?: string }) => React.ReactElement; +export type PivotRenderer = ((cellInfo: any) => React.ReactNode) | (() => any) | string | React.ReactNode; export type ComponentPropsGetter0 = (finalState: any, rowInfo: undefined, column: undefined, instance?: any) => object | undefined; export type ComponentPropsGetterR = (finalState: any, rowInfo?: RowInfo, column?: undefined, instance?: any) => object | undefined; export type ComponentPropsGetterC = (finalState: any, rowInfo?: undefined, column?: Column, instance?: any) => object | undefined; export type ComponentPropsGetterRC = (finalState: any, rowInfo?: RowInfo, column?: Column, instance?: any) => object | undefined; -export type FilterFunction = (filter: any, row: any, column: any) => boolean; +export type DefaultFilterFunction = (filter: any, row: any, column: any) => boolean; +export type FilterFunction = (filter: any, rows: any[], column: any) => boolean; export type SubComponentFunction = (rowInfo: RowInfo) => React.ReactNode; export type PageChangeFunction = (page: number) => void; export type PageSizeChangeFunction = (newPageSize: number, newPage: number) => void; export type SortedChangeFunction = (column: any, additive: boolean) => void; export type FilteredChangeFunction = (column: any, value: any, pivotColumn: any) => void; export type ExpandedChangeFunction = (column: any, event: any, isTouch: boolean) => void; +export type ResizedChangeFunction = (newResized: any, event: any) => void; +export type SortFunction = (a: any, b: any, desc: any) => -1 | 0 | 1; /** NOTE: to many configuration ways (only true values are confusing) */ export interface SortingRule { @@ -46,13 +50,22 @@ export interface TableProps extends /** Default: false */ loading: boolean; - /** Default: false */ + /** Default: true */ showPagination: boolean; + /** Default: false */ + showPaginationTop: boolean; + + /** Default: true */ + showPaginationBottom: boolean; + /** Default: false */ manual: boolean; - /** Default: false */ + /** Default: true */ + multiSort: boolean; + + /** Default: true */ showPageSizeOptions: boolean; /** Default: [5, 10, 20, 25, 50, 100] */ @@ -66,11 +79,14 @@ export interface TableProps extends * Otherwise take value from 'pageSize' if defined * @TODO: add minRows to react-table defaultProps even if undefined */ - minRows: number; + minRows: number | undefined; /** Default: true */ showPageJump: boolean; + /** Default: true */ + sortable: boolean; + /** Default: true */ collapseOnSortingChange: boolean; @@ -93,7 +109,10 @@ export interface TableProps extends defaultFiltering: any[]; /** Default: ... */ - defaultFilterMethod: FilterFunction; + defaultFilterMethod: DefaultFilterFunction; + + /** Default: ... */ + defaultSortMethod: SortFunction; /** Default: true */ resizable: boolean; @@ -104,6 +123,21 @@ export interface TableProps extends /** Default: [] */ defaultResizing: any[]; + /** Default: false */ + defaultSortDesc: boolean; + + /** Default: [] */ + defaultSorted: any[]; + + /** Default: [] */ + defaultFiltered: any[]; + + /** Default: [] */ + defaultResized: any[]; + + /** Default: {} */ + defaultExpanded: {}; + /** On change. */ onChange: ReactTableFunction; @@ -128,18 +162,36 @@ export interface TableProps extends /** Privot defaults. */ pivotDefaults: Partial; + + /** The content rendered inside of a padding row */ + PadRowComponent: () => React.ReactNode; + + /** Server-side callbacks */ + onFetchData: () => void; } export interface ControlledStateOverrideProps { /** Default: undefined */ - page: number; + page: number | undefined; /** Default: undefined */ - pageSize: number; + pageSize: number | undefined; /** Default: undefined */ sorting: number; + /** Default: [] */ + sorted: any[]; + + /** Default: [] */ + filtered: any[]; + + /** Default: [] */ + resized: any[]; + + /** Default: {} */ + expanded: {}; + /** Sub component */ SubComponent: SubComponentFunction; } @@ -160,6 +212,21 @@ export interface PivotingProps { /** Default: _subRows */ subRowsKey: string; + /** Default: _aggregated */ + aggregatedKey: string; + + /** Default: _nestingLevel */ + nestingLevelKey: string; + + /** Default: _original */ + originalKey: string; + + /** Default: _index */ + indexKey: string; + + /** Default: _groupedByPivot */ + groupedByPivotKey: string; + /** * Default: {} - Pivoting State Overrides (see Fully Controlled Component section) * @example { 4: true } @@ -176,11 +243,32 @@ export interface ExpandedRows { } export interface ControlledStateCallbackProps { + /** Called when the page index is changed by the user */ onPageChange: PageChangeFunction; + + /** + * Called when the pageSize is changed by the user. The resolve page is also sent + * to maintain approximate position in the data + */ onPageSizeChange: PageSizeChangeFunction; + + /** + * Called when a sortable column header is clicked with the column itself and if + * the shiftkey was held. If the column is a pivoted column, `column` will be an array of columns + */ onSortedChange: SortedChangeFunction; + + /** + * Called when a user enters a value into a filter input field or the value passed + * to the onFiltersChange handler by the Filter option. + */ onFilteredChange: FilteredChangeFunction; + + /** Called when an expander is clicked. Use this to manage `expanded` */ onExpandedChange: ExpandedChangeFunction; + + /** Called when a user clicks on a resizing component (the right edge of a column header) */ + onResizedChange: ResizedChangeFunction; } export interface ComponentDecoratorProps { @@ -269,14 +357,38 @@ export interface GlobalColumn extends export namespace Column { /** Basic column props */ interface Basics { - /** Default: true */ - sortable: boolean; + /** Default: undefined, use table default */ + sortable: boolean | undefined; /** Default: true */ show: boolean; /** Default: 100 */ minWidth: number; + + /** Default: undefined, use table default */ + resizable: boolean | undefined; + + /** Default: undefined, use table default */ + filterable: boolean | undefined; + + /** Default: ... */ + sortMethod: SortFunction | undefined; + + /** Default: false */ + defaultSortDesc: boolean | undefined; + + /** Used to render aggregated cells. Defaults to a comma separated list of values. */ + Aggregated: TableCellRenderer; + + /** Used to render a pivoted cell */ + Pivot: PivotRenderer; + + /** Used to render the value inside of a Pivot cell */ + PivotValue: TableCellRenderer; + + /** Used to render the expander in both Pivot and Expander cells */ + Expander: TableCellRenderer; } /** Configuration of a columns cell section */ @@ -288,7 +400,7 @@ export namespace Column { * @example 'Cell Value' * @example ({data, column}) =>

Cell Value
, */ - render: TableCellRenderer; + Cell: TableCellRenderer; /** * Set the classname of the `td` element of the column @@ -317,7 +429,7 @@ export namespace Column { * @example 'Header Name' * @example ({data, column}) =>
Header Name
, */ - header: TableCellRenderer; + Header: TableCellRenderer; /** * Set the classname of the `th` element of the column @@ -347,7 +459,7 @@ export namespace Column { * @example 'Footer Name' * @example ({data, column}) =>
Footer Name
, */ - footer: TableCellRenderer; + Footer: TableCellRenderer; /** * Default: string @@ -370,14 +482,23 @@ export namespace Column { /** Filtering related column props */ interface FilterProps { - /** Default: undefined */ - filterMethod: ReactTableFunction; + /** Default: false */ + filterAll: boolean; + + /** + * A function returning a boolean that specifies the filtering logic for the column + * 'filter' == an object specifying which filter is being applied. Format: {id: [the filter column's id], value: [the value the user typed in the filter field], + * pivotId: [if filtering on a pivot column, the pivotId will be set to the pivot column's id and the `id` field will be set to the top level pivoting column]} + * 'row' || 'rows' == the row (or rows, if filterAll is set to true) of data supplied to the table + * 'column' == the column that the filter is on + */ + filterMethod: FilterFunction | DefaultFilterFunction; /** Default: false */ hideFilter: boolean; /** Default: ... */ - filterRender: FilterRender; + Filter: FilterRender; } } @@ -385,14 +506,14 @@ export interface ExpanderDefaults { /** Default: false */ sortable: boolean; + /** Default: false */ + resizable: boolean; + + /** Default: false */ + filterable: boolean; + /** Default: 35 */ width: number; - - /** Default: true */ - hideFilter: boolean; - - /** Will be overriden in methods.js to display ExpanderComponent */ - render: TableCellRenderer; } export interface PivotDefaults { @@ -451,6 +572,13 @@ export interface Column extends /** Header Groups only */ columns?: any[]; + + /** + * Turns this column into a special column for specifying pivot position in your column definitions. + * The `pivotDefaults` options will be applied on top of this column's options. + * It will also let you specify rendering of the header (and header group if this special column is placed in the `columns` option of another column) + */ + pivot?: boolean; } export interface ColumnRenderProps { @@ -506,4 +634,4 @@ export interface FinalState extends TableProps { rowMinWidth: number; } -export default class ReactTable extends React.Component> {} +export default class ReactTable extends React.Component> { } diff --git a/types/react-table/react-table-tests.tsx b/types/react-table/react-table-tests.tsx index cc69a39114..a5609394ce 100644 --- a/types/react-table/react-table-tests.tsx +++ b/types/react-table/react-table-tests.tsx @@ -2,52 +2,152 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; // Import React Table -import ReactTable from "react-table"; +import ReactTable, { Column } from "react-table"; import "react-table/react-table.css"; -const columns = [ +const columns: Column[] = [ { Header: "Name", columns: [ - {Header: "First Name", accessor: "firstName"}, - {Header: "Last Name", id: "lastName"} + { Header: "First Name", accessor: "firstName" }, + { Header: "Last Name", id: "lastName" } ] }, { Header: "Info", columns: [ - {Header: "Age", accessor: "age"}, - {Header: "Status", accessor: "status"} + { Header: "Age", accessor: "age" }, + { Header: "Status", accessor: "status" } ] }, { Header: 'Stats', columns: [ - {Header: "Visits", accessor: "visits"} + { Header: "Visits", accessor: "visits" } ] } ]; const Component = (props: {}) => { const data = [ - {firstName: "plastic", lastName: "leather", age: 1, visits: 87, progress: 53}, - {firstName: "eggs", lastName: "quartz", age: 13, visits: 78, progress: 82}, - {firstName: "wash", lastName: "wrench", age: 29, visits: 75, progress: 49}, - {firstName: "introduction", lastName: "impression", age: 2, visits: 35, progress: 51}, - {firstName: "steel", lastName: "difference", age: 9, visits: 64, progress: 94}, - {firstName: "snakes", lastName: "corn", age: 17, visits: 55, progress: 47}, - {firstName: "ocean", lastName: "definition", age: 26, visits: 17, progress: 22}, - {firstName: "drawing", lastName: "fifth", age: 15, visits: 84, progress: 12}, - {firstName: "silver", lastName: "riddle", age: 15, visits: 59, progress: 24}, - {firstName: "surprise", lastName: "zinc", age: 23, visits: 7, progress: 48}, - {firstName: "riddle", lastName: "information", age: 2, visits: 63, progress: 3} + { firstName: "plastic", lastName: "leather", age: 1, visits: 87, progress: 53 }, + { firstName: "eggs", lastName: "quartz", age: 13, visits: 78, progress: 82 }, + { firstName: "wash", lastName: "wrench", age: 29, visits: 75, progress: 49 }, + { firstName: "introduction", lastName: "impression", age: 2, visits: 35, progress: 51 }, + { firstName: "steel", lastName: "difference", age: 9, visits: 64, progress: 94 }, + { firstName: "snakes", lastName: "corn", age: 17, visits: 55, progress: 47 }, + { firstName: "ocean", lastName: "definition", age: 26, visits: 17, progress: 22 }, + { firstName: "drawing", lastName: "fifth", age: 15, visits: 84, progress: 12 }, + { firstName: "silver", lastName: "riddle", age: 15, visits: 59, progress: 24 }, + { firstName: "surprise", lastName: "zinc", age: 23, visits: 7, progress: 48 }, + { firstName: "riddle", lastName: "information", age: 2, visits: 63, progress: 3 } ]; return (
{ + const id = filter.pivotId || filter.id; + return row[id] !== undefined ? String(row[id]).startsWith(filter.value) : true; + }} columns={columns} - defaultPageSize={10} + defaultSortMethod={(a, b, desc) => { + // force null and undefined to the bottom + a = (a === null || a === undefined) ? -Infinity : a; + b = (b === null || b === undefined) ? -Infinity : b; + // force any string values to lowercase + a = a === 'string' ? a.toLowerCase() : a; + b = b === 'string' ? b.toLowerCase() : b; + // Return either 1 or -1 to indicate a sort priority + if (a > b) { + return 1; + } + if (a < b) { + return -1; + } + // returning 0, undefined or any falsey value will use subsequent sorts or the index as a tiebreaker + return 0; + }} + PadRowComponent={() =>  } + page={undefined} + pageSize={undefined} + sorted={[]} + filtered={[]} + resized={[]} + expanded={{}} + pivotValKey='_pivotVal' + pivotIDKey='_pivotID' + subRowsKey='_subRows' + aggregatedKey='_aggregated' + nestingLevelKey='_nestingLevel' + originalKey='_original' + indexKey='_index' + groupedByPivotKey='_groupedByPivot' + className='' + onFetchData={() => null} + style={{}} + column={{ + Cell: undefined, + Header: undefined, + Footer: undefined, + Aggregated: undefined, + Pivot: undefined, + PivotValue: undefined, + Expander: undefined, + sortable: undefined, + resizable: undefined, + filterable: undefined, + show: true, + minWidth: 100, + className: '', + style: {}, + getProps: () => { }, + headerClassName: '', + headerStyle: {}, + getHeaderProps: () => { }, + footerClassName: '', + footerStyle: {}, + getFooterProps: () => { }, + filterAll: false, + filterMethod: undefined, + sortMethod: undefined, + defaultSortDesc: undefined, + }} + expanderDefaults={{ + sortable: false, + resizable: false, + filterable: false, + }} + pivotDefaults={{}} + previousText='Previous' + nextText='Next' + loadingText='Loading...' + noDataText='No rows found' + pageText='Page' + ofText='of' + rowsText='rows' />
From c55bd19de2162ed180d827788f6c3aee55292258 Mon Sep 17 00:00:00 2001 From: Brenton Simpson Date: Wed, 29 Nov 2017 16:24:37 -0800 Subject: [PATCH 302/639] Renamed jss to dvtng-jss Fixes #19974 The type definitions in `@types/jss` don't match the `jss` package on npm, which has nearly 400k monthly downloads. I'm not sure where to put the definitions currently squatting at `jss`, as it [doesn't appear that](https://www.npmjs.com/~dvtng) @dvtng has published them. --- types/{jss/jss-tests.ts => dvtng-jss/dvtng-jss-tests.ts} | 0 types/{jss => dvtng-jss}/index.d.ts | 0 types/{jss => dvtng-jss}/tsconfig.json | 4 ++-- types/{jss => dvtng-jss}/tslint.json | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename types/{jss/jss-tests.ts => dvtng-jss/dvtng-jss-tests.ts} (100%) rename types/{jss => dvtng-jss}/index.d.ts (100%) rename types/{jss => dvtng-jss}/tsconfig.json (93%) rename types/{jss => dvtng-jss}/tslint.json (100%) diff --git a/types/jss/jss-tests.ts b/types/dvtng-jss/dvtng-jss-tests.ts similarity index 100% rename from types/jss/jss-tests.ts rename to types/dvtng-jss/dvtng-jss-tests.ts diff --git a/types/jss/index.d.ts b/types/dvtng-jss/index.d.ts similarity index 100% rename from types/jss/index.d.ts rename to types/dvtng-jss/index.d.ts diff --git a/types/jss/tsconfig.json b/types/dvtng-jss/tsconfig.json similarity index 93% rename from types/jss/tsconfig.json rename to types/dvtng-jss/tsconfig.json index d22eb9d75e..3d47f98d9f 100644 --- a/types/jss/tsconfig.json +++ b/types/dvtng-jss/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "jss-tests.ts" + "dvtng-jss-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/jss/tslint.json b/types/dvtng-jss/tslint.json similarity index 100% rename from types/jss/tslint.json rename to types/dvtng-jss/tslint.json From 7acb643ae7c4866dcde9dd3e98ec48ac9302f337 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 11:53:35 +0900 Subject: [PATCH 303/639] Delete unnecessary rule invalidation setting --- types/chai/tslint.json | 52 ------------------------------------------ 1 file changed, 52 deletions(-) diff --git a/types/chai/tslint.json b/types/chai/tslint.json index a41bf5d19a..c5c3a64fbf 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -1,79 +1,27 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, "ban-types": false, "callable-types": false, "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, "no-consecutive-blank-lines": false, "no-construct": false, "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, "no-empty-interface": false, - "no-for-in-array": false, "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, "no-unnecessary-class": false, "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, "unified-signatures": false, - "void-return": false, "whitespace": false } } From 7f92dcf27005139b36ab86de65d0b88f0a750203 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:01:21 +0900 Subject: [PATCH 304/639] cleanup simple ignore style lint errors --- types/chai/chai-tests.ts | 75 +++++++++++++++++++--------------------- types/chai/index.d.ts | 13 ++++--- types/chai/tslint.json | 10 +----- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index 401e5f468a..f7c7143994 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -726,7 +726,6 @@ function frozen() { Object.freeze({}).should.be.frozen; } - class PoorlyConstructedError { } function _throw() { // See GH-45: some poorly-constructed custom errors don't have useful names @@ -736,11 +735,11 @@ function _throw() { const specificError = new RangeError('boo'); - const goodFn = () => { } - , badFn = () => { throw new Error('testing'); } - , refErrFn = () => { throw new ReferenceError('hello'); } - , ickyErrFn = () => { throw new PoorlyConstructedError(); } - , specificErrFn = () => { throw specificError; }; + const goodFn = () => { }; + const badFn = () => { throw new Error('testing'); }; + const refErrFn = () => { throw new ReferenceError('hello'); }; + const ickyErrFn = () => { throw new PoorlyConstructedError(); }; + const specificErrFn = () => { throw specificError; }; expect(goodFn).to.not.throw(); goodFn.should.not.throw(); @@ -1090,7 +1089,7 @@ function oneOf() { expect(obj).to.not.be.oneOf([{ z: 3 }]); } -//tdd +// tdd declare function suite(description: string, action: Function): void; declare function test(description: string, action: Function): void; @@ -1105,7 +1104,6 @@ class CrashyObject { } suite('assert', () => { - test('assert', () => { const foo: string = 'bar'; assert(foo === 'bar', 'expected foo to equal `bar`'); @@ -1207,26 +1205,26 @@ suite('assert', () => { assert.deepEqual({ tea: 'chai' }, { tea: 'chai' }); assert.deepEqual({ tea: 'chai' }, { tea: 'black' }); - const obja = Object.create({ tea: 'chai' }) - , objb = Object.create({ tea: 'chai' }); + const obja = Object.create({ tea: 'chai' }); + const objb = Object.create({ tea: 'chai' }); assert.deepEqual(obja, objb); - const obj1 = Object.create({ tea: 'chai' }) - , obj2 = Object.create({ tea: 'black' }); + const obj1 = Object.create({ tea: 'chai' }); + const obj2 = Object.create({ tea: 'black' }); assert.deepEqual(obj1, obj2); }); test('deepEqual (ordering)', () => { - const a = { a: 'b', c: 'd' } - , b = { c: 'd', a: 'b' }; + const a = { a: 'b', c: 'd' }; + const b = { c: 'd', a: 'b' }; assert.deepEqual(a, b); }); test('deepEqual (circular)', () => { - const circularObject: any = {} - , secondCircularObject: any = {}; + const circularObject: any = {}; + const secondCircularObject: any = {}; circularObject.field = circularObject; secondCircularObject.field = secondCircularObject; @@ -1242,8 +1240,8 @@ suite('assert', () => { }); test('notDeepEqual (circular)', () => { - const circularObject: any = {} - , secondCircularObject: any = { tea: 'jasmine' }; + const circularObject: any = {}; + const secondCircularObject: any = { tea: 'jasmine' }; circularObject.field = circularObject; secondCircularObject.field = secondCircularObject; @@ -1372,13 +1370,13 @@ suite('assert', () => { }); test('nestedInclude', () => { - assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'}); - assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'}); + assert.nestedInclude({'.a': {b: 'x'}}, {'\\.a.[b]': 'x'}); + assert.nestedInclude({a: {'[b]': 'x'}}, {'a.\\[b\\]': 'x'}); }); test('notNestedInclude', () => { - assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'}); - assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'}); + assert.notNestedInclude({'.a': {b: 'x'}}, {'\\.a.b': 'y'}); + assert.notNestedInclude({a: {'[b]': 'x'}}, {'a.\\[b\\]': 'y'}); }); test('deepNestedInclude', () => { @@ -1387,7 +1385,7 @@ suite('assert', () => { }); test('notDeepNestedInclude', () => { - assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}}) + assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}}); assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}}); }); @@ -1548,7 +1546,6 @@ suite('assert', () => { assert.sameMembers([1, 54], [6, 1, 54]); }); - test('isAbove', () => { assert.isAbove(10, 5); assert.isAbove(1, 5); @@ -1738,7 +1735,7 @@ suite('assert', () => { test('hasAllKeys', () => { assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']); assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337}); - assert.hasAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); + assert.hasAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); assert.hasAllKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']); }); @@ -1747,8 +1744,8 @@ suite('assert', () => { assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']); assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, baz: 1337}); assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337}); - assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}]); - assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); + assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}]); + assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}]); assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']); }); @@ -1756,21 +1753,21 @@ suite('assert', () => { test('doesNotHaveAnyKeys', () => { assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']); assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'}); - assert.doesNotHaveAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); + assert.doesNotHaveAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); assert.doesNotHaveAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{one: 'two'}, 'example']); }); test('doesNotHaveAllKeys', () => { assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']); assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'}); - assert.doesNotHaveAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); + assert.doesNotHaveAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); assert.doesNotHaveAllKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{one: 'two'}, 'example']); }); test('hasAnyDeepKeys', () => { - assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); - assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), [{one: 'one'}, {two: 'two'}]); - assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); + assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); + assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), [{one: 'one'}, {two: 'two'}]); + assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'}); assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]); assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); @@ -1778,28 +1775,28 @@ suite('assert', () => { test('hasAllDeepKeys', () => { assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne']]), {one: 'one'}); - assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); + assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); assert.hasAllDeepKeys(new Set([{one: 'one'}]), {one: 'one'}); assert.hasAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); }); test('containsAllDeepKeys', () => { - assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); - assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); + assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); + assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'}); assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); }); test('doesNotHaveAnyDeepKeys', () => { - assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); - assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); + assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); + assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'}); assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); }); test('doesNotHaveAllDeepKeys', () => { - assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); - assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {one: 'one'}]); + assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); + assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {one: 'one'}]); assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'}); assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {fifty: 'fifty'}]); }); diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index faafa3b2a8..041cfc7246 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -713,7 +713,6 @@ declare namespace Chai { */ notInclude(haystack: any[], needle: any, message?: string): void; - /** * Asserts that haystack includes needle. Can be used to assert the inclusion of a value in an array or a subset of properties in an object. Deep equality is used. * @@ -1289,7 +1288,7 @@ declare namespace Chai { * @param property Property of object expected to be modified. * @param message Message to display on error. */ - changes(modifier: Function, object: T, property: string /* keyof T */, message?: string): void + changes(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; /** * Asserts that a function does not change the value of a property. @@ -1300,7 +1299,7 @@ declare namespace Chai { * @param property Property of object expected not to be modified. * @param message Message to display on error. */ - doesNotChange(modifier: Function, object: T, property: string /* keyof T */, message?: string): void + doesNotChange(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; /** * Asserts that a function increases an object property. @@ -1311,7 +1310,7 @@ declare namespace Chai { * @param property Property of object expected to be increased. * @param message Message to display on error. */ - increases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void + increases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; /** * Asserts that a function does not increase an object property. @@ -1322,7 +1321,7 @@ declare namespace Chai { * @param property Property of object expected not to be increased. * @param message Message to display on error. */ - doesNotIncrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void + doesNotIncrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; /** * Asserts that a function decreases an object property. @@ -1333,7 +1332,7 @@ declare namespace Chai { * @param property Property of object expected to be decreased. * @param message Message to display on error. */ - decreases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void + decreases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; /** * Asserts that a function does not decrease an object property. @@ -1344,7 +1343,7 @@ declare namespace Chai { * @param property Property of object expected not to be decreased. * @param message Message to display on error. */ - doesNotDecrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void + doesNotDecrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; /** * Asserts if value is not a false value, and throws if it is a true value. diff --git a/types/chai/tslint.json b/types/chai/tslint.json index c5c3a64fbf..e7ca9e57c7 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -3,25 +3,17 @@ "rules": { "ban-types": false, "callable-types": false, - "comment-format": false, - "dt-header": false, "new-parens": false, - "no-consecutive-blank-lines": false, "no-construct": false, "no-declare-current-package": false, "no-empty-interface": false, "no-inferrable-types": false, - "no-padding": false, "no-redundant-jsdoc-2": false, "no-single-declare-module": false, "no-unnecessary-class": false, "no-unnecessary-generics": false, - "object-literal-key-quotes": false, - "one-variable-per-declaration": false, "prefer-const": false, - "semicolon": false, "strict-export-declare-modifiers": false, - "unified-signatures": false, - "whitespace": false + "unified-signatures": false } } From 22a3706f118519342ce9150cf9a828881a2f59f3 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:02:39 +0900 Subject: [PATCH 305/639] Fix lint errors: dt-header, no-padding --- types/chai/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 041cfc7246..43acad105a 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for chai 4.0.0 +// Type definitions for chai 4.0 // Project: http://chaijs.com/ // Definitions by: Jed Mao , // Bart van der Schoor , @@ -13,7 +13,6 @@ // declare namespace Chai { - interface ChaiStatic { expect: ExpectStatic; should(): Should; From 92728fb5e33abc146606a328574e02c48f6e1637 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:23:28 +0900 Subject: [PATCH 306/639] Cleanup ignore lint error: no-single-declare-module --- types/chai/index.d.ts | 11 ++++++----- types/chai/tslint.json | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 43acad105a..4582e884b1 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -10,6 +10,7 @@ // Gintautas Miselis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// // declare namespace Chai { @@ -1651,10 +1652,10 @@ declare namespace Chai { declare const chai: Chai.ChaiStatic; -declare module "chai" { - export = chai; -} +export = chai; -interface Object { - should: Chai.Assertion; +declare global { + interface Object { + should: Chai.Assertion; + } } diff --git a/types/chai/tslint.json b/types/chai/tslint.json index e7ca9e57c7..9e219ef9a8 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -9,7 +9,6 @@ "no-empty-interface": false, "no-inferrable-types": false, "no-redundant-jsdoc-2": false, - "no-single-declare-module": false, "no-unnecessary-class": false, "no-unnecessary-generics": false, "prefer-const": false, From 24ee831cd9f3c78b583d973b521c7f1749d5e631 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:39:39 +0900 Subject: [PATCH 307/639] Cleanup ignore lint error: unified-signatures --- types/chai/index.d.ts | 58 ++++++++---------------------------------- types/chai/tslint.json | 3 +-- 2 files changed, 12 insertions(+), 49 deletions(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 4582e884b1..2dbc51f93b 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -55,8 +55,7 @@ declare namespace Chai { } interface ShouldThrow { - (actual: Function): void; - (actual: Function, expected: string|RegExp, message?: string): void; + (actual: Function, expected?: string|RegExp, message?: string): void; (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void; } @@ -219,9 +218,7 @@ declare namespace Chai { } interface Include { - (value: Object, message?: string): Assertion; - (value: string, message?: string): Assertion; - (value: number, message?: string): Assertion; + (value: Object | string | number, message?: string): Assertion; keys: Keys; deep: Deep; ordered: Ordered; @@ -236,18 +233,12 @@ declare namespace Chai { interface Keys { (...keys: string[]): Assertion; - (keys: any[]): Assertion; - (keys: Object): Assertion; + (keys: any[]|Object): Assertion; } interface Throw { - (): Assertion; - (expected: string, message?: string): Assertion; - (expected: RegExp, message?: string): Assertion; - (constructor: Error, expected?: string, message?: string): Assertion; - (constructor: Error, expected?: RegExp, message?: string): Assertion; - (constructor: Function, expected?: string, message?: string): Assertion; - (constructor: Function, expected?: RegExp, message?: string): Assertion; + (expected?: string|RegExp, message?: string): Assertion; + (constructor: Error|Function, expected?: string|RegExp, message?: string): Assertion; } interface RespondTo { @@ -698,20 +689,11 @@ declare namespace Chai { /** * Asserts that haystack does not include needle. * - * @param haystack Container string. + * @param haystack Container string or array. * @param needle Potential expected substring of haystack. * @param message Message to display on error. */ - notInclude(haystack: string, needle: any, message?: string): void; - - /** - * Asserts that haystack does not include needle. - * - * @param haystack Container array. - * @param needle Potential value contained in haystack. - * @param message Message to display on error. - */ - notInclude(haystack: any[], needle: any, message?: string): void; + notInclude(haystack: string | any[], needle: any, message?: string): void; /** * Asserts that haystack includes needle. Can be used to assert the inclusion of a value in an array or a subset of properties in an object. Deep equality is used. @@ -734,20 +716,11 @@ declare namespace Chai { /** * Asserts that haystack does not include needle. Can be used to assert the absence of a value in an array or a subset of properties in an object. Deep equality is used. * - * @param haystack Container string. + * @param haystack Container string or array. * @param needle Potential expected substring of haystack. * @param message Message to display on error. */ - notDeepInclude(haystack: string, needle: any, message?: string): void; - - /** - * Asserts that haystack does not include needle. Can be used to assert the absence of a value in an array or a subset of properties in an object. Deep equality is used. - * - * @param haystack - * @param needle - * @param message Message to display on error. - */ - notDeepInclude(haystack: any[], needle: any, message?: string): void; + notDeepInclude(haystack: string | any[], needle: any, message?: string): void; /** * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object. @@ -1013,19 +986,10 @@ declare namespace Chai { * Asserts that function will throw an error with message matching regexp. * * @param fn Function that may throw. - * @param regExp Potential expected message match. + * @param errType Potential expected message match or error constructor. * @param message Message to display on error. */ - throws(fn: Function, regExp: RegExp, message?: string): void; - - /** - * Asserts that function will throw an error that is an instance of constructor. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - throws(fn: Function, errType: Function, message?: string): void; + throws(fn: Function, regExp: RegExp|Function, message?: string): void; /** * Asserts that function will throw an error that is an instance of constructor diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 9e219ef9a8..7082cc4bbc 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -12,7 +12,6 @@ "no-unnecessary-class": false, "no-unnecessary-generics": false, "prefer-const": false, - "strict-export-declare-modifiers": false, - "unified-signatures": false + "strict-export-declare-modifiers": false } } From a16a867b2d80617613d879add3b5ad3ed3407891 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:50:44 +0900 Subject: [PATCH 308/639] index.d.ts has no dependency on node --- types/chai/chai-tests.ts | 1 + types/chai/index.d.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index f7c7143994..2f19c46cb1 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -1,3 +1,4 @@ +/// import * as chai from "chai"; const expect = chai.expect; diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 2dbc51f93b..6e23e0fbce 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -10,7 +10,6 @@ // Gintautas Miselis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// // declare namespace Chai { From 5e7dfd0130b876584f438371aaed257c82bff68a Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:53:39 +0900 Subject: [PATCH 309/639] Cleanup lint error: no-unnecessary-class --- types/chai/chai-tests.ts | 4 ---- types/chai/tslint.json | 1 - 2 files changed, 5 deletions(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index 2f19c46cb1..141c985dd4 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -349,10 +349,6 @@ function eql() { (4).should.eql(3, 'blah'); } -class Buffer { - constructor(arr: number[]) { - } -} function buffer() { expect(new Buffer([1])).to.eql(new Buffer([1])); (new Buffer([1])).should.eql(new Buffer([1])); diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 7082cc4bbc..043173f36d 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -9,7 +9,6 @@ "no-empty-interface": false, "no-inferrable-types": false, "no-redundant-jsdoc-2": false, - "no-unnecessary-class": false, "no-unnecessary-generics": false, "prefer-const": false, "strict-export-declare-modifiers": false From eac6a7d42f6cf4aeec54460d430291938607c2ed Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 12:54:04 +0900 Subject: [PATCH 310/639] Cleanup lint error: strict-export-declare-modifiers --- types/chai/index.d.ts | 10 +++++----- types/chai/tslint.json | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 6e23e0fbce..046055f4d5 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -26,20 +26,20 @@ declare namespace Chai { version: string; } - export interface ExpectStatic extends AssertionStatic { + interface ExpectStatic extends AssertionStatic { fail(actual?: any, expected?: any, message?: string, operator?: Operator): void; } - export interface AssertStatic extends Assert { + interface AssertStatic extends Assert { } - export interface AssertionStatic { + interface AssertionStatic { (target: any, message?: string): Assertion; } - export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; + type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; - export type OperatorComparable = boolean | null | number | string | undefined | Date; + type OperatorComparable = boolean | null | number | string | undefined | Date; interface ShouldAssertion { equal(value1: any, value2: any, message?: string): void; diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 043173f36d..022342e522 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -10,7 +10,6 @@ "no-inferrable-types": false, "no-redundant-jsdoc-2": false, "no-unnecessary-generics": false, - "prefer-const": false, - "strict-export-declare-modifiers": false + "prefer-const": false } } From 14af0a7169a3ffdb7957ee60da909eeae76470e7 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 13:00:40 +0900 Subject: [PATCH 311/639] Cleanup ignore lint error: prefer-const --- types/chai/chai-tests.ts | 2 +- types/chai/tslint.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index 141c985dd4..1614f7e77b 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -887,7 +887,7 @@ function use() { _chai.can.use.any(); }); - let expect = chai + const expect = chai .use((_chai, util) => {}) .use((_chai, util) => {}) .expect; diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 022342e522..e3c7a3ed0a 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -9,7 +9,6 @@ "no-empty-interface": false, "no-inferrable-types": false, "no-redundant-jsdoc-2": false, - "no-unnecessary-generics": false, - "prefer-const": false + "no-unnecessary-generics": false } } From e080c0caa8ca31caf6d215296ac6ac58d6a2fcc6 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 13:01:06 +0900 Subject: [PATCH 312/639] Cleanup ignore lint error: no-declare-current-package --- types/chai/index.d.ts | 6 +++--- types/chai/tslint.json | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 046055f4d5..8a9d45d331 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -256,7 +256,7 @@ declare namespace Chai { (object: Object, property: string, message?: string): Assertion; } - export interface Assert { + interface Assert { /** * @param expression Expression to test for truthiness. * @param message Message to display on error. @@ -1587,7 +1587,7 @@ declare namespace Chai { doesNotHaveAllDeepKeys(object: T, keys: Array | { [key: string]: any }, message?: string): void; } - export interface Config { + interface Config { /** * Default: false */ @@ -1604,7 +1604,7 @@ declare namespace Chai { truncateThreshold: number; } - export class AssertionError { + class AssertionError { constructor(message: string, _props?: any, ssf?: Function); name: string; message: string; diff --git a/types/chai/tslint.json b/types/chai/tslint.json index e3c7a3ed0a..2252c04108 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -5,7 +5,6 @@ "callable-types": false, "new-parens": false, "no-construct": false, - "no-declare-current-package": false, "no-empty-interface": false, "no-inferrable-types": false, "no-redundant-jsdoc-2": false, From 8f2c412e781c82ba8c76aa1dc9cb1d6ed5957171 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 13:09:00 +0900 Subject: [PATCH 313/639] Cleanup ignore lint error: no-construct Every line that violates the rules has a clear intention of ensuring coverage. --- types/chai/chai-tests.ts | 3 +++ types/chai/tslint.json | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index 1614f7e77b..ef74d17115 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -133,7 +133,9 @@ function _typeof() { expect(5).to.be.a('number'); (5).should.be.a('number'); + // tslint:disable-next-line:no-construct expect(new Number(1)).to.be.a('number'); + // tslint:disable-next-line:no-construct (new Number(1)).should.be.a('number'); expect(Number(1)).to.be.a('number'); Number(1).should.be.a('number'); @@ -1304,6 +1306,7 @@ suite('assert', () => { test('isString', () => { assert.isString('Foo'); + // tslint:disable-next-line:no-construct assert.isString(new String('foo')); assert.isString(1); }); diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 2252c04108..86050707d8 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -4,7 +4,6 @@ "ban-types": false, "callable-types": false, "new-parens": false, - "no-construct": false, "no-empty-interface": false, "no-inferrable-types": false, "no-redundant-jsdoc-2": false, From e8b1de686427c96dde186a7e253cf9981c541da0 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 13:11:02 +0900 Subject: [PATCH 314/639] Cleanup ignore lint error: no-inferrable-types --- types/chai/chai-tests.ts | 2 +- types/chai/tslint.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index ef74d17115..fba32ec840 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -1104,7 +1104,7 @@ class CrashyObject { suite('assert', () => { test('assert', () => { - const foo: string = 'bar'; + const foo = 'bar' as string; assert(foo === 'bar', 'expected foo to equal `bar`'); assert(foo === 'baz', 'expected foo to equal `bar`'); diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 86050707d8..1a0ebe45c6 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -5,7 +5,6 @@ "callable-types": false, "new-parens": false, "no-empty-interface": false, - "no-inferrable-types": false, "no-redundant-jsdoc-2": false, "no-unnecessary-generics": false } From d8ecf6029f4aeec89c8173c0920caa554e43e5c9 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 1 Dec 2017 13:21:21 +0900 Subject: [PATCH 315/639] argument rename --- types/chai/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 8a9d45d331..984e4103d1 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -988,7 +988,7 @@ declare namespace Chai { * @param errType Potential expected message match or error constructor. * @param message Message to display on error. */ - throws(fn: Function, regExp: RegExp|Function, message?: string): void; + throws(fn: Function, errType: RegExp|Function, message?: string): void; /** * Asserts that function will throw an error that is an instance of constructor From 57a67f6f8f57e47aa1f6f07bfb3d39118bec83d8 Mon Sep 17 00:00:00 2001 From: Austin Turner Date: Sat, 25 Nov 2017 21:22:33 -0700 Subject: [PATCH 316/639] Added typings for sticky-cluster --- types/sticky-cluster/index.d.ts | 25 ++++++++++++++ types/sticky-cluster/sticky-cluster-tests.ts | 34 ++++++++++++++++++++ types/sticky-cluster/tsconfig.json | 23 +++++++++++++ types/sticky-cluster/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/sticky-cluster/index.d.ts create mode 100644 types/sticky-cluster/sticky-cluster-tests.ts create mode 100644 types/sticky-cluster/tsconfig.json create mode 100644 types/sticky-cluster/tslint.json diff --git a/types/sticky-cluster/index.d.ts b/types/sticky-cluster/index.d.ts new file mode 100644 index 0000000000..7d51cad34f --- /dev/null +++ b/types/sticky-cluster/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for sticky-cluster 0.3 +// Project: https://github.com/uqee/sticky-cluster +// Definitions by: Austin Turner +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// +import * as http from 'http'; + +declare namespace stickyCluster { + type InitializeFn = (callback: Callback) => void; + type Callback = (server: http.Server) => void; + interface Options { + concurrency?: number; + port?: number; + debug?: boolean; + prefix?: string; + env?: (index: number) => { stickycluster_worker_index: number }; + hardShutdownDelay?: number; + errorHandler?: (err: any) => void; + } +} + +declare function stickyCluster(callback: stickyCluster.InitializeFn, options?: stickyCluster.Options): void; +export = stickyCluster; diff --git a/types/sticky-cluster/sticky-cluster-tests.ts b/types/sticky-cluster/sticky-cluster-tests.ts new file mode 100644 index 0000000000..e730275d78 --- /dev/null +++ b/types/sticky-cluster/sticky-cluster-tests.ts @@ -0,0 +1,34 @@ +import stickyCluster = require('sticky-cluster'); +import * as express from 'express'; +import * as http from 'http'; + +/** test with all params */ +stickyCluster( + (callback) => { + const app = express(); + const server = http.createServer(app); + + // don't do server.listen(), just pass the server instance into the callback + callback(server); + }, + { + prefix: 'sticky-cluster:', + concurrency: 10, + port: 3000, + debug: true, + hardShutdownDelay: 60 * 1000, + env: (index) => ({ stickycluster_worker_index: index }), + errorHandler: (err) => { console.log(err); process.exit(1); } + } +); + +/** test with no params */ +stickyCluster( + (callback) => { + const app = express(); + const server = http.createServer(app); + + // don't do server.listen(), just pass the server instance into the callback + callback(server); + } +); diff --git a/types/sticky-cluster/tsconfig.json b/types/sticky-cluster/tsconfig.json new file mode 100644 index 0000000000..dcfc338f93 --- /dev/null +++ b/types/sticky-cluster/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sticky-cluster-tests.ts" + ] +} diff --git a/types/sticky-cluster/tslint.json b/types/sticky-cluster/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sticky-cluster/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 24664ff23d5a52753385bbbf77d5819688f19e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Fri, 1 Dec 2017 09:22:56 +0100 Subject: [PATCH 317/639] Fixes TS configuration. --- types/lodash/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/lodash/tsconfig.json b/types/lodash/tsconfig.json index 7eab905857..af6ba5e2e9 100644 --- a/types/lodash/tsconfig.json +++ b/types/lodash/tsconfig.json @@ -6,9 +6,8 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictFunctionTypes": false, - "strictNullChecks": true, "strictFunctionTypes": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From bc46f5f87e0f74a0e6b0029b88e107e3a52c5b5c Mon Sep 17 00:00:00 2001 From: Vladyslav Tserman Date: Fri, 1 Dec 2017 01:45:25 -0800 Subject: [PATCH 318/639] For new packages, tslint conf should only "extends": "dtslint/dt.json" --- types/yup/index.d.ts | 3 +++ types/yup/tslint.json | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index a7f9f4a8d3..403c1cac37 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -52,6 +52,7 @@ export interface MixedSchemaConstructor { new(options?: { type?: string, [key: string]: any }): MixedSchema; } +// tslint:disable-next-line:no-empty-interface export interface MixedSchema extends Schema { } @@ -92,6 +93,7 @@ export interface BooleanSchemaConstructor { new(): BooleanSchema; } +// tslint:disable-next-line:no-empty-interface export interface BooleanSchema extends Schema { } @@ -225,5 +227,6 @@ export interface Ref { [key: string]: any; } +// tslint:disable-next-line:no-empty-interface export interface Lazy extends Schema { } diff --git a/types/yup/tslint.json b/types/yup/tslint.json index 10c5efd5aa..f93cf8562a 100644 --- a/types/yup/tslint.json +++ b/types/yup/tslint.json @@ -1,7 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-empty-interface": false, - "no-any-union": true - } + "extends": "dtslint/dt.json" } From d4efe01e5c6d48c8a6c13e271d44dc589961aa8e Mon Sep 17 00:00:00 2001 From: Nam Nguyen Thanh Date: Fri, 1 Dec 2017 16:46:01 +0700 Subject: [PATCH 319/639] Introduce new param for changeView --- types/fullcalendar/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fullcalendar/index.d.ts b/types/fullcalendar/index.d.ts index 196de10898..4b0f600c6a 100644 --- a/types/fullcalendar/index.d.ts +++ b/types/fullcalendar/index.d.ts @@ -995,7 +995,7 @@ declare global { /** * Immediately switches to a different view. */ - fullCalendar(method: 'changeView', viewName: string): void; + fullCalendar(method: 'changeView', viewName: string, dateOrRange: moment.Moment | Date | string | TimeRange): void; /** * Moves the calendar one step back (either by a month, week, or day). From c7565e2d3c0d9506ad254209f209775af017d2b3 Mon Sep 17 00:00:00 2001 From: Brice BERNARD Date: Fri, 1 Dec 2017 11:04:17 +0100 Subject: [PATCH 320/639] Coding style with prettier --- types/next/.prettierrc | 5 + types/next/document.d.ts | 2 +- types/next/dynamic.d.ts | 23 +++- types/next/error.d.ts | 4 +- types/next/head.d.ts | 2 +- types/next/index.d.ts | 139 ++++++++++++++++-------- types/next/link.d.ts | 4 +- types/next/router.d.ts | 24 +++- types/next/test/next-document-tests.tsx | 18 +-- types/next/test/next-dynamic-tests.tsx | 22 ++-- types/next/test/next-error-tests.tsx | 8 +- types/next/test/next-head-tests.tsx | 18 +-- types/next/test/next-link-tests.tsx | 30 +++-- types/next/test/next-router-tests.tsx | 74 ++++++++----- types/next/test/next-tests.ts | 92 ++++++++++------ 15 files changed, 296 insertions(+), 169 deletions(-) create mode 100644 types/next/.prettierrc diff --git a/types/next/.prettierrc b/types/next/.prettierrc new file mode 100644 index 0000000000..8682c4845c --- /dev/null +++ b/types/next/.prettierrc @@ -0,0 +1,5 @@ +{ + "parser": "typescript", + "tabWidth": 4, + "trailingComma": "all" +} diff --git a/types/next/document.d.ts b/types/next/document.d.ts index dfb34359e1..4696819626 100644 --- a/types/next/document.d.ts +++ b/types/next/document.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from "react"; export interface DocumentProps { __NEXT_DATA__?: any; diff --git a/types/next/dynamic.d.ts b/types/next/dynamic.d.ts index 4271f89c96..62d53f1e72 100644 --- a/types/next/dynamic.d.ts +++ b/types/next/dynamic.d.ts @@ -1,16 +1,29 @@ -import * as React from 'react'; +import * as React from "react"; export interface DynamicOptions { loading?: React.ComponentType; ssr?: boolean; - modules?(props: TCProps & TLProps): { [key: string]: Promise> }; - render?(props: TCProps & TLProps, modules: { [key: string]: React.ComponentType }): void; + modules?( + props: TCProps & TLProps, + ): { [key: string]: Promise> }; + render?( + props: TCProps & TLProps, + modules: { [key: string]: React.ComponentType }, + ): void; } export class SameLoopPromise extends Promise { - constructor(executor: (resolve: (value?: T) => void, reject: (reason?: any) => void) => void); + constructor( + executor: ( + resolve: (value?: T) => void, + reject: (reason?: any) => void, + ) => void, + ); setResult(value: T): void; setError(value: any): void; runIfNeeded(): void; } -export default function(componentPromise: Promise>, options?: DynamicOptions): React.ComponentType; +export default function( + componentPromise: Promise>, + options?: DynamicOptions, +): React.ComponentType; diff --git a/types/next/error.d.ts b/types/next/error.d.ts index a6d8695947..d05d25b9c8 100644 --- a/types/next/error.d.ts +++ b/types/next/error.d.ts @@ -1,2 +1,2 @@ -import * as React from 'react'; -export default class extends React.Component<{statusCode: number}> {} +import * as React from "react"; +export default class extends React.Component<{ statusCode: number }> {} diff --git a/types/next/head.d.ts b/types/next/head.d.ts index fc50b7bcf9..24fab7a076 100644 --- a/types/next/head.d.ts +++ b/types/next/head.d.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from "react"; export function defaultHead(): JSX.Element[]; export default class extends React.Component { diff --git a/types/next/index.d.ts b/types/next/index.d.ts index 17f3848bca..4942e778c5 100644 --- a/types/next/index.d.ts +++ b/types/next/index.d.ts @@ -6,58 +6,109 @@ /// -import * as http from 'http'; -import * as url from 'url'; +import * as http from "http"; +import * as url from "url"; declare namespace next { - type UrlLike = url.UrlObject | url.Url; + type UrlLike = url.UrlObject | url.Url; - interface ServerConfig { - // known keys - webpack?: any; - webpackDevMiddleware?: any; - poweredByHeader?: boolean; - distDir?: string; - assetPrefix?: string; - configOrigin?: string; - useFileSystemPublicRoutes?: boolean; + interface ServerConfig { + // known keys + webpack?: any; + webpackDevMiddleware?: any; + poweredByHeader?: boolean; + distDir?: string; + assetPrefix?: string; + configOrigin?: string; + useFileSystemPublicRoutes?: boolean; - // and since this is a config, it can take anything else, too. - [key: string]: any; - } + // and since this is a config, it can take anything else, too. + [key: string]: any; + } - interface ServerOptions { - dir?: string; - dev?: boolean; - staticMarkup?: boolean; - quiet?: boolean; - conf?: ServerConfig; - } + interface ServerOptions { + dir?: string; + dev?: boolean; + staticMarkup?: boolean; + quiet?: boolean; + conf?: ServerConfig; + } - interface Server { - handleRequest(req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike): Promise; - getRequestHandler(): (req: http.IncomingMessage, res: http.ServerResponse, parsedUrl?: UrlLike) => Promise; - prepare(): Promise; - close(): Promise; - defineRoutes(): Promise; - start(): Promise; - run(req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike): Promise; + interface Server { + handleRequest( + req: http.IncomingMessage, + res: http.ServerResponse, + parsedUrl?: UrlLike, + ): Promise; + getRequestHandler(): ( + req: http.IncomingMessage, + res: http.ServerResponse, + parsedUrl?: UrlLike, + ) => Promise; + prepare(): Promise; + close(): Promise; + defineRoutes(): Promise; + start(): Promise; + run( + req: http.IncomingMessage, + res: http.ServerResponse, + parsedUrl: UrlLike, + ): Promise; - render(req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: {[key: string]: any}, parsedUrl?: UrlLike): Promise; - renderError(err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: {[key: string]: any}): Promise; - render404(req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike): Promise; - renderToHTML(req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: {[key: string]: any}): Promise; - renderErrorToHTML(err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, query?: {[key: string]: any}): Promise; + render( + req: http.IncomingMessage, + res: http.ServerResponse, + pathname: string, + query?: { [key: string]: any }, + parsedUrl?: UrlLike, + ): Promise; + renderError( + err: any, + req: http.IncomingMessage, + res: http.ServerResponse, + pathname: string, + query?: { [key: string]: any }, + ): Promise; + render404( + req: http.IncomingMessage, + res: http.ServerResponse, + parsedUrl: UrlLike, + ): Promise; + renderToHTML( + req: http.IncomingMessage, + res: http.ServerResponse, + pathname: string, + query?: { [key: string]: any }, + ): Promise; + renderErrorToHTML( + err: any, + req: http.IncomingMessage, + res: http.ServerResponse, + pathname: string, + query?: { [key: string]: any }, + ): Promise; - serveStatic(req: http.IncomingMessage, res: http.ServerResponse, path: string): Promise; - isServeableUrl(path: string): boolean; - isInternalUrl(req: http.IncomingMessage): boolean; - readBuildId(): string; - handleBuildId(buildId: string, res: http.ServerResponse): boolean; - getCompilationError(page: string, req: http.IncomingMessage, res: http.ServerResponse): Promise; - handleBuildHash(filename: string, hash: string, res: http.ServerResponse): void; - send404(res: http.ServerResponse): void; - } + serveStatic( + req: http.IncomingMessage, + res: http.ServerResponse, + path: string, + ): Promise; + isServeableUrl(path: string): boolean; + isInternalUrl(req: http.IncomingMessage): boolean; + readBuildId(): string; + handleBuildId(buildId: string, res: http.ServerResponse): boolean; + getCompilationError( + page: string, + req: http.IncomingMessage, + res: http.ServerResponse, + ): Promise; + handleBuildHash( + filename: string, + hash: string, + res: http.ServerResponse, + ): void; + send404(res: http.ServerResponse): void; + } } declare function next(options?: next.ServerOptions): next.Server; diff --git a/types/next/link.d.ts b/types/next/link.d.ts index d931dd550d..36c2e33546 100644 --- a/types/next/link.d.ts +++ b/types/next/link.d.ts @@ -1,5 +1,5 @@ -import * as url from 'url'; -import * as React from 'react'; +import * as url from "url"; +import * as React from "react"; export type UrlLike = url.UrlObject | url.Url; export interface LinkState { diff --git a/types/next/router.d.ts b/types/next/router.d.ts index 9f937ca6ba..90a2e3af55 100644 --- a/types/next/router.d.ts +++ b/types/next/router.d.ts @@ -1,5 +1,5 @@ -import * as React from 'react'; -import * as url from 'url'; +import * as React from "react"; +import * as url from "url"; type UrlLike = url.UrlObject | url.Url; @@ -14,7 +14,9 @@ export interface SingletonRouter { ready(cb: RouterCallback): void; // router properties - readonly components: { [key: string]: { Component: React.ComponentType, err: any } }; + readonly components: { + [key: string]: { Component: React.ComponentType; err: any }; + }; readonly pathname: string; readonly route: string; readonly asPath?: string; @@ -23,8 +25,16 @@ export interface SingletonRouter { // router methods reload(route: string): Promise; back(): void; - push(url: string|UrlLike, as?: string|UrlLike, options?: EventChangeOptions): Promise; - replace(url: string|UrlLike, as?: string|UrlLike, options?: EventChangeOptions): Promise; + push( + url: string | UrlLike, + as?: string | UrlLike, + options?: EventChangeOptions, + ): Promise; + replace( + url: string | UrlLike, + as?: string | UrlLike, + options?: EventChangeOptions, + ): Promise; prefetch(url: string): Promise>; // router events @@ -35,7 +45,9 @@ export interface SingletonRouter { onRouteChangeError?(error: any, url: string): void; } -export function withRouter(Component: React.ComponentType): React.ComponentType; +export function withRouter( + Component: React.ComponentType, +): React.ComponentType; export const Singleton: SingletonRouter; export default Singleton; diff --git a/types/next/test/next-document-tests.tsx b/types/next/test/next-document-tests.tsx index 4fbb25948b..0177d1d451 100644 --- a/types/next/test/next-document-tests.tsx +++ b/types/next/test/next-document-tests.tsx @@ -1,12 +1,12 @@ -import Document, * as document from 'next/document'; -import * as React from 'react'; +import Document, * as document from "next/document"; +import * as React from "react"; const results = ( - - - - - - - + + + + + + + ); diff --git a/types/next/test/next-dynamic-tests.tsx b/types/next/test/next-dynamic-tests.tsx index be10954de9..0b4cdde82d 100644 --- a/types/next/test/next-dynamic-tests.tsx +++ b/types/next/test/next-dynamic-tests.tsx @@ -1,23 +1,25 @@ -import dynamic, * as d from 'next/dynamic'; -import * as React from 'react'; +import dynamic, * as d from "next/dynamic"; +import * as React from "react"; // typically you'd use this with an esnext-style import() statement, but we'll make do without interface DynamicComponentProps { - foo: string; - bar: number; + foo: string; + bar: number; } async function getComponent() { - return ( - (props: DynamicComponentProps) =>
I'm an async component! {props.foo} {props.bar}
- ); + return (props: DynamicComponentProps) => ( +
+ I'm an async component! {props.foo} {props.bar} +
+ ); } interface LoadingComponentProps { - baz: boolean; + baz: boolean; } const DynamicComponent = dynamic(getComponent(), { - loading: (props: LoadingComponentProps) =>
Loading! {props.baz}
+ loading: (props: LoadingComponentProps) =>
Loading! {props.baz}
, }); -const jsx = (); +const jsx = ; diff --git a/types/next/test/next-error-tests.tsx b/types/next/test/next-error-tests.tsx index 38692ac6de..057eb95f23 100644 --- a/types/next/test/next-error-tests.tsx +++ b/types/next/test/next-error-tests.tsx @@ -1,6 +1,4 @@ -import * as React from 'react'; -import ErrorComponent from 'next/error'; +import * as React from "react"; +import ErrorComponent from "next/error"; -const result = ( - -); +const result = ; diff --git a/types/next/test/next-head-tests.tsx b/types/next/test/next-head-tests.tsx index c81333700c..735402ca9a 100644 --- a/types/next/test/next-head-tests.tsx +++ b/types/next/test/next-head-tests.tsx @@ -1,19 +1,11 @@ -import Head, * as head from 'next/head'; -import * as React from 'react'; +import Head, * as head from "next/head"; +import * as React from "react"; const elements: JSX.Element[] = head.defaultHead(); -const jsx = ( - - {elements} - -); +const jsx = {elements}; if (!Head.canUseDOM) { - Head.rewind().map( - x => [x.key, x.props, x.type] - ); + Head.rewind().map(x => [x.key, x.props, x.type]); } -Head.peek().map( - x => [x.key, x.props, x.type] -); +Head.peek().map(x => [x.key, x.props, x.type]); diff --git a/types/next/test/next-link-tests.tsx b/types/next/test/next-link-tests.tsx index 281c6aff7a..2a85fec1ad 100644 --- a/types/next/test/next-link-tests.tsx +++ b/types/next/test/next-link-tests.tsx @@ -1,13 +1,23 @@ -import Link from 'next/link'; -import * as React from 'react'; +import Link from "next/link"; +import * as React from "react"; const links = ( -
- { console.log("Handled error!", e); }} prefetch replace scroll shallow> - Gotta link to somewhere! - - - All props are optional! - -
+
+ { + console.log("Handled error!", e); + }} + prefetch + replace + scroll + shallow + > + Gotta link to somewhere! + + + All props are optional! + +
); diff --git a/types/next/test/next-router-tests.tsx b/types/next/test/next-router-tests.tsx index e713f127b7..fe82d6f0b2 100644 --- a/types/next/test/next-router-tests.tsx +++ b/types/next/test/next-router-tests.tsx @@ -1,28 +1,34 @@ -import Router, * as r from 'next/router'; -import * as React from 'react'; -import * as qs from 'querystring'; +import Router, * as r from "next/router"; +import * as React from "react"; +import * as qs from "querystring"; -Router.readyCallbacks.push(() => { console.log("I'll get called when the router initializes."); }); -Router.ready(() => { console.log("I'll get called immediately if the router initializes, or when it eventually does."); }); +Router.readyCallbacks.push(() => { + console.log("I'll get called when the router initializes."); +}); +Router.ready(() => { + console.log( + "I'll get called immediately if the router initializes, or when it eventually does.", + ); +}); // Access readonly properties of the router. Object.keys(Router.components).forEach(key => { - const c = Router.components[key]; - c.err.isAnAny; + const c = Router.components[key]; + c.err.isAnAny; - return ; + return ; }); function split(routeLike: string) { - routeLike.split('/').forEach(part => { - console.log("path part: ", part); - }); + routeLike.split("/").forEach(part => { + console.log("path part: ", part); + }); } if (Router.asPath) { - split(Router.asPath); - split(Router.asPath); + split(Router.asPath); + split(Router.asPath); } split(Router.pathname); @@ -31,25 +37,41 @@ const query = `?${qs.stringify(Router.query)}`; // Assign some callback methods. Router.onAppUpdated = (nextRoute: string) => console.log(nextRoute); -Router.onRouteChangeStart = (url: string) => console.log("Route is starting to change.", url); -Router.onBeforeHistoryChange = (as: string) => console.log("History hasn't changed yet.", as); -Router.onRouteChangeComplete = (url: string) => console.log("Route chaneg is complete.", url); -Router.onRouteChangeError = (err: any, url: string) => console.log("Route is starting to change.", url, err); +Router.onRouteChangeStart = (url: string) => + console.log("Route is starting to change.", url); +Router.onBeforeHistoryChange = (as: string) => + console.log("History hasn't changed yet.", as); +Router.onRouteChangeComplete = (url: string) => + console.log("Route chaneg is complete.", url); +Router.onRouteChangeError = (err: any, url: string) => + console.log("Route is starting to change.", url, err); // Call methods on the router itself. -Router.reload('/route').then(() => console.log('route was reloaded')); +Router.reload("/route").then(() => console.log("route was reloaded")); Router.back(); -Router.push('/route').then((success: boolean) => console.log('route push success: ', success)); -Router.push('/route', '/asRoute').then((success: boolean) => console.log('route push success: ', success)); -Router.push('/route', '/asRoute', {shallow: false}).then((success: boolean) => console.log('route push success: ', success)); +Router.push("/route").then((success: boolean) => + console.log("route push success: ", success), +); +Router.push("/route", "/asRoute").then((success: boolean) => + console.log("route push success: ", success), +); +Router.push("/route", "/asRoute", { shallow: false }).then((success: boolean) => + console.log("route push success: ", success), +); -Router.replace('/route').then((success: boolean) => console.log('route replace success: ', success)); -Router.replace('/route', '/asRoute').then((success: boolean) => console.log('route replace success: ', success)); -Router.replace('/route', '/asRoute', {shallow: false}).then((success: boolean) => console.log('route replace success: ', success)); +Router.replace("/route").then((success: boolean) => + console.log("route replace success: ", success), +); +Router.replace("/route", "/asRoute").then((success: boolean) => + console.log("route replace success: ", success), +); +Router.replace("/route", "/asRoute", { + shallow: false, +}).then((success: boolean) => console.log("route replace success: ", success)); -Router.prefetch('/route').then(Component => { - const element = (); +Router.prefetch("/route").then(Component => { + const element = ; }); r.withRouter(props =>
); diff --git a/types/next/test/next-tests.ts b/types/next/test/next-tests.ts index 7e9bb474e7..ddbc51ee33 100644 --- a/types/next/test/next-tests.ts +++ b/types/next/test/next-tests.ts @@ -1,56 +1,78 @@ -import createServer = require('next'); -import * as http from 'http'; -import * as url from 'url'; +import createServer = require("next"); +import * as http from "http"; +import * as url from "url"; const defaultServer: createServer.Server = createServer(); const server = createServer({ - dir: '..', - quiet: true, - conf: { - distDir: './dist', - useFileSystemPublicRoutes: false, - anotherProperty: { - key: true - } - }, + dir: "..", + quiet: true, + conf: { + distDir: "./dist", + useFileSystemPublicRoutes: false, + anotherProperty: { + key: true, + }, + }, }); const voidFunc = () => {}; -const stringFunc = (x: string) => x.split('\n'); +const stringFunc = (x: string) => x.split("\n"); server.prepare().then(voidFunc); server.close().then(voidFunc); server.defineRoutes().then(voidFunc); server.start().then(voidFunc); -const parsedUrl = url.parse('https://www.example.com'); +const parsedUrl = url.parse("https://www.example.com"); const handler = server.getRequestHandler(); function handle(req: http.IncomingMessage, res: http.ServerResponse) { - handler(req, res); - handler(req, res, parsedUrl).then(voidFunc); - server.run(req, res, parsedUrl).then(voidFunc); + handler(req, res); + handler(req, res, parsedUrl).then(voidFunc); + server.run(req, res, parsedUrl).then(voidFunc); - server.render(req, res, '/path/to/resource').then(voidFunc); - server.render(req, res, '/path/to/resource', {}, parsedUrl).then(voidFunc); - server.render(req, res, '/path/to/resource', { key: 'value' }, parsedUrl).then(voidFunc); - server.renderError(new Error(), req, res, '/path/to/resource').then(voidFunc); - server.renderError(new Error(), req, res, '/path/to/resource', { key: 'value' }).then(voidFunc); - server.renderError('this can be an error, too!', req, res, '/path/to/resource', { key: 'value' }).then(voidFunc); - server.render404(req, res, parsedUrl).then(voidFunc); + server.render(req, res, "/path/to/resource").then(voidFunc); + server.render(req, res, "/path/to/resource", {}, parsedUrl).then(voidFunc); + server + .render(req, res, "/path/to/resource", { key: "value" }, parsedUrl) + .then(voidFunc); + server + .renderError(new Error(), req, res, "/path/to/resource") + .then(voidFunc); + server + .renderError(new Error(), req, res, "/path/to/resource", { + key: "value", + }) + .then(voidFunc); + server + .renderError( + "this can be an error, too!", + req, + res, + "/path/to/resource", + { key: "value" }, + ) + .then(voidFunc); + server.render404(req, res, parsedUrl).then(voidFunc); - server.renderToHTML(req, res, '/path/to/resource', { foo: 'bar' }).then(x => x.split('\n')); - server.renderErrorToHTML(new Error(), req, res, '/path/to/resource', { foo: 'bar' }).then(x => x.split('\n')); + server + .renderToHTML(req, res, "/path/to/resource", { foo: "bar" }) + .then(x => x.split("\n")); + server + .renderErrorToHTML(new Error(), req, res, "/path/to/resource", { + foo: "bar", + }) + .then(x => x.split("\n")); - server.serveStatic(req, res, '/path/to/thing').then(voidFunc); + server.serveStatic(req, res, "/path/to/thing").then(voidFunc); - let b: boolean; - b = server.isServeableUrl('/path/to/thing'); - b = server.isInternalUrl(req); - b = server.handleBuildId('{buildId}', res); + let b: boolean; + b = server.isServeableUrl("/path/to/thing"); + b = server.isInternalUrl(req); + b = server.handleBuildId("{buildId}", res); - const s: string = server.readBuildId(); - server.getCompilationError('page', req, res).then(err => err.thisIsAnAny); - server.handleBuildHash('filename', 'hash', res); - server.send404(res); + const s: string = server.readBuildId(); + server.getCompilationError("page", req, res).then(err => err.thisIsAnAny); + server.handleBuildHash("filename", "hash", res); + server.send404(res); } From 98d2bc9bb356e3c6152b52ea5adcd4ae3882193c Mon Sep 17 00:00:00 2001 From: Brice BERNARD Date: Fri, 1 Dec 2017 11:10:02 +0100 Subject: [PATCH 321/639] Update query param typing --- types/next/index.d.ts | 8 ++++---- types/next/router.d.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/next/index.d.ts b/types/next/index.d.ts index 4942e778c5..2dadc6e10b 100644 --- a/types/next/index.d.ts +++ b/types/next/index.d.ts @@ -59,7 +59,7 @@ declare namespace next { req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: any }, + query?: { [key: string]: string | string[] }, parsedUrl?: UrlLike, ): Promise; renderError( @@ -67,7 +67,7 @@ declare namespace next { req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: any }, + query?: { [key: string]: string | string[] }, ): Promise; render404( req: http.IncomingMessage, @@ -78,14 +78,14 @@ declare namespace next { req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: any }, + query?: { [key: string]: string | string[] }, ): Promise; renderErrorToHTML( err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: any }, + query?: { [key: string]: string | string[] }, ): Promise; serveStatic( diff --git a/types/next/router.d.ts b/types/next/router.d.ts index 90a2e3af55..4102e87b12 100644 --- a/types/next/router.d.ts +++ b/types/next/router.d.ts @@ -20,7 +20,7 @@ export interface SingletonRouter { readonly pathname: string; readonly route: string; readonly asPath?: string; - readonly query?: { [key: string]: any }; + readonly query?: { [key: string]: string | string[] }; // router methods reload(route: string): Promise; From fb0050d3b188c2ba98df90516d7b2674e40c65f2 Mon Sep 17 00:00:00 2001 From: Brice BERNARD Date: Fri, 1 Dec 2017 11:18:38 +0100 Subject: [PATCH 322/639] Add my name to index.d.ts --- types/next/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/next/index.d.ts b/types/next/index.d.ts index 2dadc6e10b..a9042d83e9 100644 --- a/types/next/index.d.ts +++ b/types/next/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for next 2.4 // Project: https://github.com/zeit/next.js // Definitions by: Drew Hays +// Brice BERNARD // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 327398e6d929eeb0344826b1cb521a09b9b2e880 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 1 Dec 2017 10:41:36 +0000 Subject: [PATCH 323/639] Lodash: `overSome`: tests: remove redundant explicit generic https://github.com/DefinitelyTyped/DefinitelyTyped/pull/21872#discussion_r154215366 --- types/lodash/lodash-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 4200459e9c..24f29c0b29 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -13776,10 +13776,10 @@ namespace TestOverSome { { let result: (...args: number[]) => boolean; - result = _.overSome((n: number) => true); - result = _.overSome((n: number) => true, (n: number) => true); - result = _.overSome([(n: number) => true]); - result = _.overSome([(n: number) => true], [(n: number) => true]); + result = _.overSome((n: number) => true); + result = _.overSome((n: number) => true, (n: number) => true); + result = _.overSome([(n: number) => true]); + result = _.overSome([(n: number) => true], [(n: number) => true]); } { From 254f87722df4d5ab253161b9bab26598f8097b52 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 1 Dec 2017 10:43:54 +0000 Subject: [PATCH 324/639] Lodash: `overEvery`: use generic instead of any --- types/lodash/index.d.ts | 6 +++--- types/lodash/lodash-tests.ts | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 7fa84c808c..b7dc72d007 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -16566,21 +16566,21 @@ declare namespace _ { * @param predicates The predicates to check. * @return Returns the new function. */ - overEvery(...predicates: Array any>>): (...args: any[]) => boolean; + overEvery(...predicates: Array boolean>>): (...args: T[]) => boolean; } interface LoDashImplicitWrapper { /** * @see _.overEvery */ - overEvery(...predicates: Array any>>): LoDashImplicitWrapper<(...args: any[]) => boolean>; + overEvery(...predicates: Array boolean>>): LoDashImplicitWrapper<(...args: T[]) => boolean>; } interface LoDashExplicitWrapper { /** * @see _.overEvery */ - overEvery(...predicates: Array any>>): LoDashExplicitWrapper<(...args: any[]) => boolean>; + overEvery(...predicates: Array boolean>>): LoDashExplicitWrapper<(...args: T[]) => boolean>; } //_.overSome diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 24f29c0b29..e33f93b745 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -13744,30 +13744,30 @@ namespace TestOver { // _.overEvery namespace TestOverEvery { { - let result: (...args: any[]) => boolean; + let result: (...args: number[]) => boolean; - result = _.overEvery(() => true); - result = _.overEvery(() => true, () => true); - result = _.overEvery([() => true]); - result = _.overEvery([() => true], [() => true]); + result = _.overEvery((number) => true); + result = _.overEvery((number) => true, (number) => true); + result = _.overEvery([(number) => true]); + result = _.overEvery([(number) => true], [(number) => true]); } { - let result: _.LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; + let result: _.LoDashImplicitObjectWrapper<(...args: number[]) => boolean>; result = _(Math.max).overEvery(); - result = _(Math.max).overEvery(() => true); + result = _(Math.max).overEvery((number) => true); result = _([Math.max]).overEvery(); - result = _([Math.max]).overEvery([() => true]); + result = _([Math.max]).overEvery([(number) => true]); } { - let result: _.LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; + let result: _.LoDashExplicitObjectWrapper<(...args: number[]) => boolean>; result = _(Math.max).chain().overEvery(); - result = _(Math.max).chain().overEvery(() => true); + result = _(Math.max).chain().overEvery((number) => true); result = _([Math.max]).chain().overEvery(); - result = _([Math.max]).chain().overEvery([() => true]); + result = _([Math.max]).chain().overEvery([(number) => true]); } } From f3d38534f86f96e0615691e81b0c2476cebd3dd3 Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 1 Dec 2017 10:44:27 +0000 Subject: [PATCH 325/639] Lodash: `overSome`: tests: add missing function parameters --- types/lodash/lodash-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index e33f93b745..f011a8216d 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -13786,18 +13786,18 @@ namespace TestOverSome { let result: _.LoDashImplicitObjectWrapper<(...args: number[]) => boolean>; result = _(Math.max).overSome(); - result = _(Math.max).overSome(() => true); + result = _(Math.max).overSome((n: number) => true); result = _([Math.max]).overSome(); - result = _([Math.max]).overSome([() => true]); + result = _([Math.max]).overSome([(n: number) => true]); } { let result: _.LoDashExplicitObjectWrapper<(...args: number[]) => boolean>; result = _(Math.max).chain().overSome(); - result = _(Math.max).chain().overSome(() => true); + result = _(Math.max).chain().overSome((n: number) => true); result = _([Math.max]).chain().overSome(); - result = _([Math.max]).chain().overSome([() => true]); + result = _([Math.max]).chain().overSome([(n: number) => true]); } } From daaa8688f3a125835f192b2e0a5fb5d05e3403ca Mon Sep 17 00:00:00 2001 From: daphnes Date: Fri, 1 Dec 2017 13:13:29 +0100 Subject: [PATCH 326/639] [ElasticSearch] skipped missing in Shards & sort values for each document returned are also returned as part of the response --- types/elasticsearch/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index 8acc7e4097..1552652edd 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -131,6 +131,7 @@ declare module Elasticsearch { total: number; successful: number; failed: number; + skipped: number; } /** @@ -632,6 +633,7 @@ declare module Elasticsearch { fields?: any; highlight?: any; inner_hits?: any; + sort?: string[]; }[]; }; aggregations?: any; From 7be1d3666ccc8cdab59771344ccb0eb102f71c53 Mon Sep 17 00:00:00 2001 From: Matthias Jobst Date: Fri, 1 Dec 2017 13:17:06 +0100 Subject: [PATCH 327/639] Added tests for brush on different axis classes This required some refactoring of the original brush code. Scale contains a generic. Brush can take up to three generics. --- types/d3/v3/d3-tests.ts | 31 +++++++++++++++++++++++++++++ types/d3/v3/index.d.ts | 44 ++++++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/types/d3/v3/d3-tests.ts b/types/d3/v3/d3-tests.ts index 4f50ef0341..8704448c9b 100644 --- a/types/d3/v3/d3-tests.ts +++ b/types/d3/v3/d3-tests.ts @@ -2720,3 +2720,34 @@ function testEnterSizeEmpty() { selectionSize = newNodes.size(); } + +// Example from Matthias Jobst http://github.com/MatthiasJobst +// Checks the brush with different Axis types +class BrushAxisTest { + brush: d3.svg.Brush; + constructor() { + let scale = d3.time.scale(); + this.brush = d3.svg.brush() + .x(scale) // the x accessor accepts time scales + .y(scale); // as does y + } + brushes = () => { + let extent = this.brush.extent(); + let brush = d3.svg.brush(); + brush.x(d3.scale.linear()); // Linear scale + brush.y(d3.scale.log()); // Logarithmic scale + // Does not work: + // brush.extent(this.brush.extent()); + // From https://github.com/d3/d3-3.x-api-reference/blob/master/Ordinal-Scales.md#ordinal_rangePoints + let ordinalScale = d3.scale.ordinal() + .domain([1, 2, 3, 4]) + .rangePoints([0, 100]); + let ordinalBrush = d3.svg.brush() + .x(ordinalScale) // Ordinal scale + .y(d3.scale.linear()); + let colorScale = d3.scale.category10(); + let colorBrush = d3.svg.brush() + .x(colorScale) // Color scale + .y(d3.scale.pow()); + } +} \ No newline at end of file diff --git a/types/d3/v3/index.d.ts b/types/d3/v3/index.d.ts index 2642ecd5d3..9a2f9ae34a 100644 --- a/types/d3/v3/index.d.ts +++ b/types/d3/v3/index.d.ts @@ -2581,40 +2581,44 @@ declare namespace d3 { tickFormat(format: string): Axis; } - export function brush(): Brush; - export function brush(): Brush; + export function brush(): Brush; + export function brush(): Brush; + export function brush(): Brush; + export function brush(): Brush; namespace brush { - interface Scale { - domain(): number[] | Date[]; - domain(domain: number[] | Date[]): Scale; + interface Scale { + domain(): S[]; + domain(domain: S[]): Scale; - range(): number[] | Date[]; - range(range: number[] | Date[]): Scale; + range(): S[]; + range(range: number[]): Scale; - invert?(y: number | Date): number | Date; + invert?(y: number): S; } } - interface Brush { + interface Brush { (selection: Selection): void; (selection: Transition): void; event(selection: Selection): void; event(selection: Transition): void; - x(): brush.Scale; - x(x: brush.Scale): Brush; + x(): brush.Scale; + x(x: brush.Scale): Brush; + x(x: d3.scale.Ordinal | d3.time.Scale): Brush; - y(): brush.Scale; - y(y: brush.Scale): Brush; + y(): brush.Scale; + y(y: brush.Scale): Brush; + y(x: d3.scale.Ordinal | d3.time.Scale): Brush; // https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Controls.md#brush_extent - extent(): [number, number] | [[number, number], [number, number]] | [Date, Date] | [[Date, Date],[Date,Date]]; - extent(extent: [number, number] | [[number, number], [number, number]] | [Date, Date] | [[Date, Date], [Date, Date]]): Brush; + extent(): [X, X] | [Y, Y] | [[X, Y], [X, Y]] | null; + extent(extent: [X, X] | [Y, Y] | [[X, Y], [X, Y]]): Brush; clamp(): boolean | [boolean, boolean]; - clamp(clamp: boolean | [boolean, boolean]): Brush; + clamp(clamp: boolean | [boolean, boolean]): Brush; clear(): void; @@ -2625,10 +2629,10 @@ declare namespace d3 { on(type: 'brushend'): (datum: T, index: number) => void; on(type: string): (datum: T, index: number) => void; - on(type: 'brushstart', listener: (datum: T, index: number) => void): Brush; - on(type: 'brush', listener: (datum: T, index: number) => void): Brush; - on(type: 'brushend', listener: (datum: T, index: number) => void): Brush; - on(type: string, listener: (datum: T, index: number) => void): Brush; + on(type: 'brushstart', listener: (datum: T, index: number) => void): Brush; + on(type: 'brush', listener: (datum: T, index: number) => void): Brush; + on(type: 'brushend', listener: (datum: T, index: number) => void): Brush; + on(type: string, listener: (datum: T, index: number) => void): Brush; } } From 690cdfbf9312415a26feb3fe56c8e95e883fa42a Mon Sep 17 00:00:00 2001 From: Mark Raymond Date: Fri, 1 Dec 2017 13:53:22 +0000 Subject: [PATCH 328/639] Update react-modal typings for 3.1.6. --- types/react-modal/index.d.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index d20d83fcea..715f4c3b01 100644 --- a/types/react-modal/index.d.ts +++ b/types/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal 2.2 +// Type definitions for react-modal 3.1 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov , // Drew Noakes , @@ -24,9 +24,9 @@ declare namespace ReactModal { } interface Classes { - base?: string; - afterOpen?: string; - beforeClose?: string; + base: string; + afterOpen: string; + beforeClose: string; } interface Aria { @@ -68,9 +68,18 @@ declare namespace ReactModal { /* Boolean indicating if the appElement should be hidden. Defaults to true. */ ariaHideApp?: boolean; + /* Boolean indicating if the modal should be focused after render */ + shouldFocusAfterRender?: boolean; + /* Boolean indicating if the overlay should close the modal. Defaults to true. */ shouldCloseOnOverlayClick?: boolean; + /* Boolean indicating if pressing the esc key should close the modal */ + shouldCloseOnEsc?: boolean; + + /* Boolean indicating if the modal should restore focus to the element that had focus prior to its display. */ + shouldReturnFocusAfterClose?: boolean; + /* Function that will be called to get the parent element that the modal will be attached to. */ parentSelector?(): HTMLElement; @@ -81,7 +90,7 @@ declare namespace ReactModal { role?: string; /* String indicating how the content container should be announced to screenreaders. */ - contentLabel: string; + contentLabel?: string; } } From 6ee4d7b6bcb93647dacab7c6471877a839d946f1 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Fri, 1 Dec 2017 16:08:04 +0200 Subject: [PATCH 329/639] Add types for fuzzyset.js This is basically a copy of `fuzzyset` types, but `fuzzyset.js` is a different npm package. --- types/fuzzyset.js/fuzzyset.js-tests.ts | 10 ++++++++++ types/fuzzyset.js/index.d.ts | 22 ++++++++++++++++++++++ types/fuzzyset.js/tsconfig.json | 22 ++++++++++++++++++++++ types/fuzzyset.js/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/fuzzyset.js/fuzzyset.js-tests.ts create mode 100644 types/fuzzyset.js/index.d.ts create mode 100644 types/fuzzyset.js/tsconfig.json create mode 100644 types/fuzzyset.js/tslint.json diff --git a/types/fuzzyset.js/fuzzyset.js-tests.ts b/types/fuzzyset.js/fuzzyset.js-tests.ts new file mode 100644 index 0000000000..97a0d45008 --- /dev/null +++ b/types/fuzzyset.js/fuzzyset.js-tests.ts @@ -0,0 +1,10 @@ +import FuzzySet = require('fuzzyset.js'); + +const fuzzyset: FuzzySet = FuzzySet(['coucou', 'foo', 'bar', 'toto']); +const results = fuzzyset.get('foo'); + +fuzzyset.length(); + +fuzzyset.isEmpty(); + +fuzzyset.values(); diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts new file mode 100644 index 0000000000..df344f18d7 --- /dev/null +++ b/types/fuzzyset.js/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for fuzzyset.js 0.0 +// Project: https://github.com/Glench/fuzzyset.js +// Definitions by: Louis Grignon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface FuzzySet { + get(candidate: string): Array<[number, string]>; + add(value: string): boolean; + length(): number; + isEmpty(): boolean; + values(): string[]; +} + +declare function FuzzySet( + source: string[], + useLevenshtein?: boolean, + gramSizeLower?: number, + gramSizeUpper?: number, +): FuzzySet; + +export = FuzzySet; +export as namespace FuzzySet; diff --git a/types/fuzzyset.js/tsconfig.json b/types/fuzzyset.js/tsconfig.json new file mode 100644 index 0000000000..285a64eaf7 --- /dev/null +++ b/types/fuzzyset.js/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fuzzyset.js-tests.ts" + ] +} diff --git a/types/fuzzyset.js/tslint.json b/types/fuzzyset.js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fuzzyset.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 09bbf1cec87650424506d959504d262070b88a09 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Fri, 1 Dec 2017 16:21:09 +0200 Subject: [PATCH 330/639] Add "strictFunctionTypes": true --- types/fuzzyset.js/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/fuzzyset.js/tsconfig.json b/types/fuzzyset.js/tsconfig.json index 285a64eaf7..a1eeb06b97 100644 --- a/types/fuzzyset.js/tsconfig.json +++ b/types/fuzzyset.js/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 5ec9c9cb59a1a4762fc57c3649b57bac0102181d Mon Sep 17 00:00:00 2001 From: Brice BERNARD Date: Fri, 1 Dec 2017 15:21:17 +0100 Subject: [PATCH 331/639] Remover .prettierrc file --- types/next/.prettierrc | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 types/next/.prettierrc diff --git a/types/next/.prettierrc b/types/next/.prettierrc deleted file mode 100644 index 8682c4845c..0000000000 --- a/types/next/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "parser": "typescript", - "tabWidth": 4, - "trailingComma": "all" -} From 3f8be6b39f12871708e3630af26455d736352ce5 Mon Sep 17 00:00:00 2001 From: Maarten Rijke Date: Fri, 1 Dec 2017 15:45:30 +0100 Subject: [PATCH 332/639] [react-bootstrap-table] Update trClassName signature The trClassName signature for the callback uses ReadonlyArray to type the row, but it should be any as its just one row that is passed, not an array. --- types/react-bootstrap-table/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-bootstrap-table/index.d.ts b/types/react-bootstrap-table/index.d.ts index 0687891657..a07c49a764 100644 --- a/types/react-bootstrap-table/index.d.ts +++ b/types/react-bootstrap-table/index.d.ts @@ -217,7 +217,7 @@ export interface BootstrapTableProps extends Props { * return rowIndex % 2 == 0 ? "tr-odd" : "tr-even"; // return a class name. * } */ - trClassName?: string | ((rowData: ReadonlyArray, rowIndex: number) => string); + trClassName?: string | ((rowData: any, rowIndex: number) => string); /** * Enable row insertion by setting insertRow to true, default is false. * If you enable row insertion, there's a button on the upper left side of table. From b00fe9b49ce3532069400e0d396cf571988e8d6f Mon Sep 17 00:00:00 2001 From: Soner Koksal Date: Fri, 1 Dec 2017 18:34:32 +0300 Subject: [PATCH 333/639] revised version and added author --- types/sockjs-client/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/sockjs-client/index.d.ts b/types/sockjs-client/index.d.ts index 8768e3755a..ae6db5a748 100644 --- a/types/sockjs-client/index.d.ts +++ b/types/sockjs-client/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for sockjs-client 1.0 +// Type definitions for sockjs-client 1.1.4 // Project: https://github.com/sockjs/sockjs-client // Definitions by: Emil Ivanov // Alexander Rusakov // BendingBender +// Soner Köksal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = SockJS; From e66680c8523231b7908e0d9eed7c18b888177f06 Mon Sep 17 00:00:00 2001 From: Soner Koksal Date: Fri, 1 Dec 2017 18:44:33 +0300 Subject: [PATCH 334/639] version correction --- types/sockjs-client/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/sockjs-client/index.d.ts b/types/sockjs-client/index.d.ts index ae6db5a748..aed69a2a02 100644 --- a/types/sockjs-client/index.d.ts +++ b/types/sockjs-client/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sockjs-client 1.1.4 +// Type definitions for sockjs-client 1.1 // Project: https://github.com/sockjs/sockjs-client // Definitions by: Emil Ivanov // Alexander Rusakov From 2c3a4232beece64ed9947db3ab34d127fdcc7865 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Fri, 1 Dec 2017 12:31:15 -0600 Subject: [PATCH 335/639] Add and additional basic test for backward compatibility --- types/react-autosuggest/index.d.ts | 2 +- .../react-autosuggest-tests.tsx | 126 +++++++++++++++++- 2 files changed, 126 insertions(+), 2 deletions(-) diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index 78c11d6878..c7f46200d1 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -11,7 +11,7 @@ import * as React from 'react'; -declare class Autosuggest extends React.Component> {} +declare class Autosuggest extends React.Component> {} export = Autosuggest; diff --git a/types/react-autosuggest/react-autosuggest-tests.tsx b/types/react-autosuggest/react-autosuggest-tests.tsx index 753af3a552..3747e8457b 100644 --- a/types/react-autosuggest/react-autosuggest-tests.tsx +++ b/types/react-autosuggest/react-autosuggest-tests.tsx @@ -15,9 +15,133 @@ function escapeRegexCharacters(str: string): string { return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } +export class ReactAutosuggestBasicTest extends React.Component { + // region Fields + static languages: Language[] = [ + { + name: 'C', + year: 1972 + }, { + name: 'C#', + year: 2000 + }, { + name: 'C++', + year: 1983 + }, { + name: 'Clojure', + year: 2007 + }, { + name: 'Elm', + year: 2012 + }, { + name: 'Go', + year: 2009 + }, { + name: 'Haskell', + year: 1990 + }, { + name: 'Java', + year: 1995 + }, { + name: 'Javascript', + year: 1995 + }, { + name: 'Perl', + year: 1987 + }, { + name: 'PHP', + year: 1995 + }, { + name: 'Python', + year: 1991 + }, { + name: 'Ruby', + year: 1995 + }, { + name: 'Scala', + year: 2003 + } + ]; + // endregion region Constructor + constructor(props: any) { + super(props); + + this.state = { + value: '', + suggestions: this.getSuggestions('') + }; + } + // endregion region Rendering methods + render(): JSX.Element { + const {value, suggestions} = this.state; + const inputProps = { + placeholder: `Type 'c'`, + value, + onChange: this + .onChange + .bind(this) + }; + + const theme = { + input: 'themed-input-class', + container: 'themed-container-class', + suggestionFocused: 'active', + sectionTitle: { color: 'blue' } + }; + + return ; + } + + protected onSuggestionsSelected(event: React.FormEvent, data: Autosuggest.SuggestionSelectedEventData): void { + alert(`Selected language is ${data.suggestion.name} (${data.suggestion.year}).`); + } + + protected renderSuggestion(suggestion: Language, params: Autosuggest.RenderSuggestionParams): JSX.Element { + const className = params.isHighlighted ? "highlighted" : undefined; + return {suggestion.name}; + } + // endregion region Event handlers + protected onChange(event: React.FormEvent, {newValue, method}: any): void { + this.setState({value: newValue}); + } + + protected onSuggestionsFetchRequested({value}: any): void { + this.setState({ + suggestions: this.getSuggestions(value) + }); + } + // endregion region Helper methods + protected getSuggestions(value: string): Language[] { + const escapedValue = escapeRegexCharacters(value.trim()); + + if (escapedValue === '') { + return []; + } + + const regex = new RegExp('^' + escapedValue, 'i'); + + return ReactAutosuggestBasicTest + .languages + .filter(language => regex.test(language.name)); + } + + protected getSuggestionValue(suggestion: Language): string { return suggestion.name; } + // endregion +} + const LanguageAutosuggest = Autosuggest as { new (): Autosuggest }; -export class ReactAutosuggestBasicTest extends React.Component { +export class ReactAutosuggestTypedTest extends React.Component { // region Fields static languages: Language[] = [ { From 83b34b7be6436122e21cdec1b0bea3ff2216cc1f Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 29 Nov 2017 20:38:15 +0000 Subject: [PATCH 336/639] types for format-duration --- .../format-duration/format-duration-tests.ts | 5 ++++ types/format-duration/index.d.ts | 8 +++++++ types/format-duration/tsconfig.json | 23 +++++++++++++++++++ types/format-duration/tslint.json | 1 + 4 files changed, 37 insertions(+) create mode 100644 types/format-duration/format-duration-tests.ts create mode 100644 types/format-duration/index.d.ts create mode 100644 types/format-duration/tsconfig.json create mode 100644 types/format-duration/tslint.json diff --git a/types/format-duration/format-duration-tests.ts b/types/format-duration/format-duration-tests.ts new file mode 100644 index 0000000000..4a08b33119 --- /dev/null +++ b/types/format-duration/format-duration-tests.ts @@ -0,0 +1,5 @@ +import formatDuration = require("format-duration"); + +const milliseconds = 12345; + +const duration: string = formatDuration(milliseconds); diff --git a/types/format-duration/index.d.ts b/types/format-duration/index.d.ts new file mode 100644 index 0000000000..06682200b2 --- /dev/null +++ b/types/format-duration/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for format-duration 1.0 +// Project: https://github.com/ungoldman/format-duration +// Definitions by: Giles Roadnight +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function formatDuration(ms: number): string; + +export = formatDuration; diff --git a/types/format-duration/tsconfig.json b/types/format-duration/tsconfig.json new file mode 100644 index 0000000000..f17a4f7c6c --- /dev/null +++ b/types/format-duration/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "format-duration-tests.ts" + ] +} diff --git a/types/format-duration/tslint.json b/types/format-duration/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/format-duration/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 990f8c840593666d7bb418487e4fb8fa10e55fde Mon Sep 17 00:00:00 2001 From: Brenton Simpson Date: Wed, 29 Nov 2017 17:36:38 -0800 Subject: [PATCH 337/639] Added types for jss These are rudimentary type definitions for `jss`. I optimized for utility over thoroughness - they can probably be improved. Closes https://github.com/cssinjs/jss/issues/362 (and might close https://github.com/cssinjs/jss/issues/361) --- types/jss/index.d.ts | 127 ++++++++++++++++++++++++++++++++++++++++ types/jss/jss-tests.ts | 62 ++++++++++++++++++++ types/jss/tsconfig.json | 24 ++++++++ types/jss/tslint.json | 1 + 4 files changed, 214 insertions(+) create mode 100644 types/jss/index.d.ts create mode 100644 types/jss/jss-tests.ts create mode 100644 types/jss/tsconfig.json create mode 100644 types/jss/tslint.json diff --git a/types/jss/index.d.ts b/types/jss/index.d.ts new file mode 100644 index 0000000000..d0136216ed --- /dev/null +++ b/types/jss/index.d.ts @@ -0,0 +1,127 @@ +// Type definitions for jss 9.3 +// Project: https://github.com/cssinjs/jss#readme +// Definitions by: Brenton Simpson +// Oleg Slobodskoi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export interface Rule { + className: string; + selector: string; + applyTo(element: HTMLElement): void; + prop(key: string): string; + prop(key: string, value: any): this; + toJSON(): string; +} +export interface StyleSheet { + // Gives auto-completion on the rules declared in `createStyleSheet` without + // causing errors for rules added dynamically after creation. + classes: { + [K in keyof T]: string; + } & { [key: string]: string }; + options: any; + linked: boolean; + attached: boolean; + /** + * Attach renderable to the render tree. + */ + attach(): this; + /** + * Remove renderable from render tree. + */ + detach(): this; + /** + * Add a rule to the current stylesheet. + * Will insert a rule also after the stylesheet has been rendered first time. + */ + addRule(style: Style, options?: Partial): Rule; + addRule(name: string, style: Style, options?: Partial): Rule; + /** + * Create and add rules. + * Will render also after Style Sheet was rendered the first time. + */ + addRules(styles: { [key: string]: Style }, options?: Partial): Rule[]; + /** + * Get a rule by name. + */ + getRule(name: string): Rule; + /** + * Delete a rule by name. + * Returns `true`: if rule has been deleted from the DOM. + */ + deleteRule(name: string): boolean; + /** + * Get index of a rule. + */ + indexOf(rule: Rule): number; + /** + * Update the function values with a new data. + */ + update(data?: {}): this; + update(name: string, data: {}): this; + /** + * Convert rules to a CSS string. + */ + toString(options?: { indent?: number }): string; +} +export type GenerateClassName = (rule: Rule, sheet?: StyleSheet) => string; +export interface Style { + [key: string]: any; +} +export interface JSSPlugin { + [key: string]: () => Partial<{ + onCreateRule(name: string, style: Style, options: RuleOptions): Rule, + onProcessRule(rule: Rule, sheet: StyleSheet): void, + onProcessStyle(style: Style, rule: Rule, sheet: StyleSheet): Style, + onProcessSheet(sheet: StyleSheet): void, + onChangeValue(value: any, prop: string, rule: Rule): any, + onUpdate(data: {}, rule: Rule, sheet: StyleSheet): void, + }>; +} +export interface JSSOptions { + createGenerateClassName(): GenerateClassName; + plugins: ReadonlyArray; + virtual: boolean; + insertionPoint: string | HTMLElement; +} +export interface RuleFactoryOptions { + selector: string; + classes: { [key: string]: string }; + sheet: StyleSheet; + index: number; + jss: JSS; + generateClassName: GenerateClassName; +} +export interface RuleOptions { + index: number; + className: string; +} +declare class JSS { + constructor(options?: Partial); + createStyleSheet( + styles: T, + options?: Partial<{ + media: string, + meta: string, + link: boolean, + element: HTMLStyleElement, + index: number, + generateClassName: GenerateClassName, + classNamePrefix: string, + }>, + ): StyleSheet; + removeStyleSheet(sheet: StyleSheet): this; + setup(options?: Partial): this; + use(plugin: JSSPlugin): this; + createRule(style: Style, options?: Partial): Rule; + createRule(name: string, style: Style, options?: Partial): Rule; +} +/** + * Creates a new instance of JSS. + */ +export function create(options?: Partial): JSS; +declare const sharedInstance: JSS; +/** + * A global JSS instance. + */ +export default sharedInstance; diff --git a/types/jss/jss-tests.ts b/types/jss/jss-tests.ts new file mode 100644 index 0000000000..0cf3f51350 --- /dev/null +++ b/types/jss/jss-tests.ts @@ -0,0 +1,62 @@ +// API docs at http://cssinjs.org/js-api + +import { + create as createJSS, + default as sharedInstance +} from 'jss'; + +const jss = createJSS().setup({}); + +const styleSheet = jss.createStyleSheet( + { + ruleWithMockObservable: { + subscribe() {} + }, + container: { + display: 'flex', + width: 100, + opacity: .5, + }, + }, + { + link: true, + } +).attach(); + +styleSheet.classes.container; // $ExpectType string +styleSheet.classes.ruleWithMockObservable; // $ExpectType string + +const rule = styleSheet.addRule('dynamicRule', { color: 'indigo' }); +rule.prop('border-radius', 5).prop('color'); // $ExpectType string +styleSheet.classes.dynamicRule; // $ExpectType string + +styleSheet.deleteRule('dynamicRule'); + +// test that `addRule` supports the shorthand signature +const dynamicRule = styleSheet.addRule({ color: 'red' }); + +const div = document.createElement('div'); +dynamicRule.applyTo(div); + +const containerRule = styleSheet.getRule('container'); +const containerJSON = containerRule.toJSON(); +const css = styleSheet.toString(); + +styleSheet.addRules({ + rule1: { + fontFamily: 'Roboto', + color: '#FFFFFF', + }, + rule2: { + fontFamily: 'Inconsolata', + fontSize: 17, + }, +}); + +styleSheet.detach(); + +sharedInstance.createStyleSheet({ + container: { + background: '#000099', + } +}); diff --git a/types/jss/tsconfig.json b/types/jss/tsconfig.json new file mode 100644 index 0000000000..f34791192c --- /dev/null +++ b/types/jss/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jss-tests.ts" + ] +} diff --git a/types/jss/tslint.json b/types/jss/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jss/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b54545aa62bfeac0165dfb1c40cd2f0c242faff5 Mon Sep 17 00:00:00 2001 From: Ben Stevens Date: Fri, 1 Dec 2017 19:37:27 +0000 Subject: [PATCH 338/639] update stripe-v3 tests --- types/stripe-v3/stripe-v3-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/stripe-v3/stripe-v3-tests.ts b/types/stripe-v3/stripe-v3-tests.ts index acf878d945..ccf86e5215 100644 --- a/types/stripe-v3/stripe-v3-tests.ts +++ b/types/stripe-v3/stripe-v3-tests.ts @@ -42,6 +42,7 @@ describe("Stripe", () => { (error: stripe.Error) => { console.error(error); }); + card.destroy(); }); }); From bd0c4e78c4fa6bbe06621bb49a3dc4abe7a18b59 Mon Sep 17 00:00:00 2001 From: Brenton Simpson Date: Fri, 1 Dec 2017 11:29:26 -0800 Subject: [PATCH 339/639] Added borderRadius to CSSProperties Fixes https://github.com/smyte/jsxstyle/issues/92 --- types/react/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index e41299fdb5..265441ba75 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1045,6 +1045,11 @@ declare namespace React { */ borderLeftWidth?: CSSWideKeyword | any; + /** + * Shorthand property that sets the rounding of all four corners. + */ + borderRadius?: CSSWideKeyword | any; + /** * Shorthand property that defines the border-width, border-style and border-color of an element's right border * in a single declaration. Note that you can use the corresponding longhand properties to set specific From e2dfe19ed6933f3ef6c9016b2143dbf1450334f0 Mon Sep 17 00:00:00 2001 From: Michael Macnair Date: Fri, 1 Dec 2017 21:22:17 +0000 Subject: [PATCH 340/639] Add react-tagsinput definition --- types/react-tagsinput/index.d.ts | 47 +++++++++++++++++++ .../react-tagsinput/react-tagsinput-tests.tsx | 23 +++++++++ types/react-tagsinput/tsconfig.json | 24 ++++++++++ types/react-tagsinput/tslint.json | 1 + 4 files changed, 95 insertions(+) create mode 100644 types/react-tagsinput/index.d.ts create mode 100644 types/react-tagsinput/react-tagsinput-tests.tsx create mode 100644 types/react-tagsinput/tsconfig.json create mode 100644 types/react-tagsinput/tslint.json diff --git a/types/react-tagsinput/index.d.ts b/types/react-tagsinput/index.d.ts new file mode 100644 index 0000000000..5c569df07d --- /dev/null +++ b/types/react-tagsinput/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for react-tagsinput 3.19 +// Project: https://github.com/olahol/react-tagsinput +// Definitions by: Michael Macnair +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from "react"; + +export as namespace ReactTagsInput; +export = TagsInput; + +declare class TagsInput extends React.Component { + accept(): any; + addTag(tag: string): any; + blur(): void; + clearInput(): void; + focus(): void; +} + +declare namespace TagsInput { + interface ReactTagsInputProps extends React.Props { + value: string[]; + onChange: (tags: string[], changed: string[], changedIndexes: number[]) => void; + onChangeInput?: (value: string) => void; + addKeys?: number[]; + currentValue?: string; + inputValue?: string; + onlyUnique?: boolean; + validationRegex?: RegExp; + onValidationReject?: (tags: string[]) => void; + disabled?: boolean; + maxTags?: number; + addOnBlur?: boolean; + addOnPaste?: boolean; + pasteSplit?: (data: string) => string[]; + removeKeys?: number[]; + className?: string; + focusedClassName?: string; + tagProps?: any; + inputProps?: any; + tagDisplayProp?: string | null; + renderTag?: (props: any) => React.Component; + renderInput?: (props: any) => React.Component; + renderLayout?: (tagComponents: React.Component[], inputComponent: React.Component) => any; + preventSubmit?: boolean; + } +} diff --git a/types/react-tagsinput/react-tagsinput-tests.tsx b/types/react-tagsinput/react-tagsinput-tests.tsx new file mode 100644 index 0000000000..8a3a113227 --- /dev/null +++ b/types/react-tagsinput/react-tagsinput-tests.tsx @@ -0,0 +1,23 @@ +import * as React from 'react'; +import * as TagsInput from 'react-tagsinput'; + +interface StateI { + tags: string[]; +} + +class Example extends React.Component<{}, StateI> { + constructor(props: {}) { + super(props); + this.state = {tags: []}; + } + + handleChange(tags: string[]) { + this.setState({tags}); + } + + render() { + return ( + + ); + } +} diff --git a/types/react-tagsinput/tsconfig.json b/types/react-tagsinput/tsconfig.json new file mode 100644 index 0000000000..1e9342e032 --- /dev/null +++ b/types/react-tagsinput/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-tagsinput-tests.tsx" + ] +} diff --git a/types/react-tagsinput/tslint.json b/types/react-tagsinput/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-tagsinput/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From fdf53c6dbd141d0bfc199ccc325c8d14894e389e Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:23:21 +0200 Subject: [PATCH 341/639] Improve definition of .get --- types/fuzzyset.js/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index df344f18d7..2b125be4c7 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -4,7 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface FuzzySet { - get(candidate: string): Array<[number, string]>; + get(candidate: string, defaultValue?: string, minScore?: number): Array<[number, string]> | undefined; + get(candidate: string, minScore?: number): Array<[number, string]> | undefined; add(value: string): boolean; length(): number; isEmpty(): boolean; From 183a98b467bcb7e7a73e8746a4ce49096ac164f4 Mon Sep 17 00:00:00 2001 From: Jan Dryk Date: Sat, 2 Dec 2017 00:23:31 +0100 Subject: [PATCH 342/639] Update index.d.ts --- types/node-forge/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index a7842724a6..2fac7c7e6e 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -304,7 +304,7 @@ declare module "node-forge" { function createDecipher(algorithm: Algorithm, payload: util.ByteBuffer): BlockCipher; interface StartOptions { - iv: string | undefined + iv?: string; } interface BlockCipher { From e0682297ccd10006fd55d72c7978ea05b52b01be Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:24:18 +0200 Subject: [PATCH 343/639] Fix --- types/fuzzyset.js/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index 2b125be4c7..2ddb86ba87 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -5,7 +5,6 @@ interface FuzzySet { get(candidate: string, defaultValue?: string, minScore?: number): Array<[number, string]> | undefined; - get(candidate: string, minScore?: number): Array<[number, string]> | undefined; add(value: string): boolean; length(): number; isEmpty(): boolean; From 09b1e56450ff1bababd01d65b5fbd90611ac0243 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:25:33 +0200 Subject: [PATCH 344/639] Fix again --- types/fuzzyset.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index 2ddb86ba87..32b03f4379 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface FuzzySet { - get(candidate: string, defaultValue?: string, minScore?: number): Array<[number, string]> | undefined; + get(candidate: string, defaultValue: T | undefined, minScore?: number): Array<[number, string]> | T | null; add(value: string): boolean; length(): number; isEmpty(): boolean; From 38fc62bbcfa796a3f2079ec00e81c31e253f427a Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:25:54 +0200 Subject: [PATCH 345/639] Fix again --- types/fuzzyset.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index 32b03f4379..66984d28eb 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface FuzzySet { - get(candidate: string, defaultValue: T | undefined, minScore?: number): Array<[number, string]> | T | null; + get(candidate: string, defaultValue?: T | undefined, minScore?: number): Array<[number, string]> | T | null; add(value: string): boolean; length(): number; isEmpty(): boolean; From e5511020a462a77459a34cbe8661c6d5dd1cbf3c Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:30:20 +0200 Subject: [PATCH 346/639] Add default type parameter --- types/fuzzyset.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index 66984d28eb..55b7207957 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface FuzzySet { - get(candidate: string, defaultValue?: T | undefined, minScore?: number): Array<[number, string]> | T | null; + get(candidate: string, defaultValue?: T | undefined, minScore?: number): Array<[number, string]> | T | null; add(value: string): boolean; length(): number; isEmpty(): boolean; From 1ce7e77601387101862388a6b99a1c2f85edc66b Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:34:36 +0200 Subject: [PATCH 347/639] Require TS 2.3 --- types/fuzzyset.js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index 55b7207957..31764839b5 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Glench/fuzzyset.js // Definitions by: Louis Grignon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 interface FuzzySet { get(candidate: string, defaultValue?: T | undefined, minScore?: number): Array<[number, string]> | T | null; From 8b14224d0eaeed888b0fa01c0a2c3ec088906924 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 01:35:00 +0200 Subject: [PATCH 348/639] Fix linting issue --- types/fuzzyset.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fuzzyset.js/index.d.ts b/types/fuzzyset.js/index.d.ts index 31764839b5..04914683bc 100644 --- a/types/fuzzyset.js/index.d.ts +++ b/types/fuzzyset.js/index.d.ts @@ -5,7 +5,7 @@ // TypeScript Version: 2.3 interface FuzzySet { - get(candidate: string, defaultValue?: T | undefined, minScore?: number): Array<[number, string]> | T | null; + get(candidate: string, defaultValue?: T, minScore?: number): Array<[number, string]> | T | null; add(value: string): boolean; length(): number; isEmpty(): boolean; From 2e1e77c2f7fd4ec3a69c4e98531b04184f2c9534 Mon Sep 17 00:00:00 2001 From: Clark Stevenson Date: Fri, 1 Dec 2017 23:50:45 +0000 Subject: [PATCH 349/639] pixi.js v4.6.2 minor update --- types/pixi.js/index.d.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/types/pixi.js/index.d.ts b/types/pixi.js/index.d.ts index 48b9583c0b..1875746d6e 100644 --- a/types/pixi.js/index.d.ts +++ b/types/pixi.js/index.d.ts @@ -834,7 +834,7 @@ declare namespace PIXI { protected _lastObjectRendered: DisplayObject; resize(screenWidth: number, screenHeight: number): void; - generateTexture(displayObject: DisplayObject, scaleMode?: number, resolution?: number): RenderTexture; + generateTexture(displayObject: DisplayObject, scaleMode?: number, resolution?: number, region?: Rectangle): RenderTexture; render(...args: any[]): void; destroy(removeView?: boolean): void; } @@ -948,7 +948,6 @@ declare namespace PIXI { extract: extract.WebGLExtract; protected drawModes: any; protected _activeShader: Shader; - protected _activeVao: glCore.VertexArrayObject; _activeRenderTarget: RenderTarget; protected _initContext(): void; @@ -1032,7 +1031,7 @@ declare namespace PIXI { update(): void; run(): void; - unload(): void; + unload(displayObject: DisplayObject): void; } abstract class ObjectRenderer extends WebGLManager { constructor(renderer: WebGLRenderer); @@ -2124,7 +2123,7 @@ declare namespace PIXI { protected _tempPoint: Point; resolution: number; hitTest(globalPoint: Point, root?: Container): DisplayObject; - protected setTargetElement(element: HTMLCanvasElement, resolution?: number): void; + setTargetElement(element: HTMLCanvasElement, resolution?: number): void; protected addEvents(): void; protected removeEvents(): void; update(deltaTime?: number): void; @@ -2661,7 +2660,7 @@ declare namespace PIXI { ////////////////////////////////////////////////////////////////////////////// /////////////////////////////pixi-gl-core///////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - // pixi-gl-core 1.1.2 https://github.com/pixijs/pixi-gl-core + // pixi-gl-core 1.1.4 https://github.com/pixijs/pixi-gl-core // sharedArrayBuffer as a type is not available yet. // need to fully define what an `Attrib` is. namespace glCore { @@ -2813,13 +2812,13 @@ declare namespace PIXI { indexBuffer: GLBuffer; dirty: boolean; - bind(): VertexArrayObject; - unbind(): VertexArrayObject; - activate(): VertexArrayObject; - addAttribute(buffer: GLBuffer, attribute: Attrib, type: number, normalized: boolean, stride: number, start: number): VertexArrayObject; - addIndex(buffer: GLBuffer, options?: any): VertexArrayObject; - clear(): VertexArrayObject; - draw(type: number, size: number, start: number): VertexArrayObject; + bind(): this; + unbind(): this; + activate(): this; + addAttribute(buffer: GLBuffer, attribute: Attrib, type?: number, normalized?: boolean, stride?: number, start?: number): this; + addIndex(buffer: GLBuffer, options?: any): this; + clear(): this; + draw(type: number, size: number, start: number): this; destroy(): void; } } From 8ca44be1a4414cb302afc6a24080be246ccb9019 Mon Sep 17 00:00:00 2001 From: Brenton Simpson Date: Fri, 1 Dec 2017 11:33:36 -0800 Subject: [PATCH 350/639] Fixed borderRadius types React's `borderRadius` [can only be](https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/dangerousStyleValue.js) a `string` or a `number`, so the type should reflect that. See also #20743 --- types/react/index.d.ts | 10 +++++----- types/react/test/cssProperties.tsx | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 265441ba75..9780afc546 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -962,12 +962,12 @@ declare namespace React { /** * Defines the shape of the border of the bottom-left corner. */ - borderBottomLeftRadius?: CSSWideKeyword | any; + borderBottomLeftRadius?: CSSWideKeyword | CSSLength; /** * Defines the shape of the border of the bottom-right corner. */ - borderBottomRightRadius?: CSSWideKeyword | any; + borderBottomRightRadius?: CSSWideKeyword | CSSLength; /** * Sets the line style of the bottom border of a box. @@ -1048,7 +1048,7 @@ declare namespace React { /** * Shorthand property that sets the rounding of all four corners. */ - borderRadius?: CSSWideKeyword | any; + borderRadius?: CSSWideKeyword | CSSLength; /** * Shorthand property that defines the border-width, border-style and border-color of an element's right border @@ -1110,12 +1110,12 @@ declare namespace React { /** * Sets the rounding of the top-left corner of the element. */ - borderTopLeftRadius?: CSSWideKeyword | any; + borderTopLeftRadius?: CSSWideKeyword | CSSLength; /** * Sets the rounding of the top-right corner of the element. */ - borderTopRightRadius?: CSSWideKeyword | any; + borderTopRightRadius?: CSSWideKeyword | CSSLength; /** * Sets the style of an element's top border. To set all four borders, use the shorthand property, border-style. diff --git a/types/react/test/cssProperties.tsx b/types/react/test/cssProperties.tsx index 7447d1eb52..4ef8ab792a 100644 --- a/types/react/test/cssProperties.tsx +++ b/types/react/test/cssProperties.tsx @@ -3,6 +3,9 @@ import * as React from 'react'; const initialStyle: React.CSSProperties = { fontWeight: 'initial' }; const initialStyleTest =
; +const borderRadiusStyle: React.CSSProperties = { borderRadius: 5, borderTopRightRadius: '20%' }; +const borderRadiusStyleTest =
; + const backgroundAttachmentStyle: React.CSSProperties = { backgroundAttachment: 'fixed' }; const backgroundAttachmentStyleTest =
; From cfc910c1d0456543279a6783e41325612f6d09a0 Mon Sep 17 00:00:00 2001 From: Brenton Simpson Date: Fri, 1 Dec 2017 13:26:11 -0800 Subject: [PATCH 351/639] Replaced tslint-disable with tsline-disable-line These aren't lines this PR otherwise touches, but it won't build without them. --- types/react/index.d.ts | 9 +++++---- types/react/test/index.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 9780afc546..2f0c8a17bb 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -281,10 +281,10 @@ declare namespace React { constructor(props: P, context?: any); // Disabling unified-signatures to have separate overloads. It's easier to understand this way. - // tslint:disable:unified-signatures + // tslint:disable-next-line:unified-signatures setState(f: (prevState: Readonly, props: P) => Pick, callback?: () => any): void; + // tslint:disable-next-line:unified-signatures setState(state: Pick, callback?: () => any): void; - // tslint:enable:unified-signatures forceUpdate(callBack?: () => any): void; render(): ReactNode; @@ -3524,7 +3524,7 @@ declare namespace React { declare global { namespace JSX { - // tslint:disable:no-empty-interface + // tslint:disable-next-line:no-empty-interface interface Element extends React.ReactElement { } interface ElementClass extends React.Component { render(): React.ReactNode; @@ -3532,9 +3532,10 @@ declare global { interface ElementAttributesProperty { props: {}; } interface ElementChildrenAttribute { children: {}; } + // tslint:disable-next-line:no-empty-interface interface IntrinsicAttributes extends React.Attributes { } + // tslint:disable-next-line:no-empty-interface interface IntrinsicClassAttributes extends React.ClassAttributes { } - // tslint:enable:no-empty-interface interface IntrinsicElements { // HTML diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 3c49215c8a..d13b7eea3f 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -255,7 +255,7 @@ myComponent.reset(); // Refs // -------------------------------------------------------------------------- -// tslint:disable:no-empty-interface +// tslint:disable-next-line:no-empty-interface interface RCProps { } class RefComponent extends React.Component { From 1cf0e6dec47f7b2ad1d21cd9f3dd25de88761120 Mon Sep 17 00:00:00 2001 From: William Lohan Date: Fri, 1 Dec 2017 16:39:52 -0800 Subject: [PATCH 352/639] add less2sass --- types/less2sass/index.d.ts | 20 ++++++++++++++++++++ types/less2sass/less2sass-tests.ts | 4 ++++ types/less2sass/tsconfig.json | 23 +++++++++++++++++++++++ types/less2sass/tslint.json | 1 + 4 files changed, 48 insertions(+) create mode 100644 types/less2sass/index.d.ts create mode 100644 types/less2sass/less2sass-tests.ts create mode 100644 types/less2sass/tsconfig.json create mode 100644 types/less2sass/tslint.json diff --git a/types/less2sass/index.d.ts b/types/less2sass/index.d.ts new file mode 100644 index 0000000000..af2746177a --- /dev/null +++ b/types/less2sass/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for less2sass 1.0 +// Project: http://erickryski.com +// Definitions by: William Lohan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class Less2Sass { + convert(file: string): string; + private convertColourHelpers(): Less2Sass; + private convertExtend(): Less2Sass; + private convertFileExtensions(): Less2Sass; + private convertFunctionUnit(): Less2Sass; + private convertInterpolatedVariables(): Less2Sass; + private convertMixins(): Less2Sass; + private convertTildaStrings(): Less2Sass; + private convertVariables(): Less2Sass; + private includeMixins(): Less2Sass; +} + +declare const less2sass: Less2Sass; +export = less2sass; diff --git a/types/less2sass/less2sass-tests.ts b/types/less2sass/less2sass-tests.ts new file mode 100644 index 0000000000..578b731887 --- /dev/null +++ b/types/less2sass/less2sass-tests.ts @@ -0,0 +1,4 @@ +import * as less2sass from 'less2sass'; + +let scss: string; +scss = less2sass.convert('@myColor: #f938ab; .myClass { color: @myColor; }'); diff --git a/types/less2sass/tsconfig.json b/types/less2sass/tsconfig.json new file mode 100644 index 0000000000..e70848dca8 --- /dev/null +++ b/types/less2sass/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "less2sass-tests.ts" + ] +} diff --git a/types/less2sass/tslint.json b/types/less2sass/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/less2sass/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 09a37f8c3ef7c0a06ad876ec436cc816daf4eb44 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Fri, 1 Dec 2017 16:58:34 -0800 Subject: [PATCH 353/639] fuzzaldrin: Refine the type of the `key` option, add tests. (#21738) --- types/fuzzaldrin/fuzzaldrin-tests.ts | 20 ++++++++++++++++++++ types/fuzzaldrin/index.d.ts | 4 +++- types/fuzzaldrin/tsconfig.json | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 types/fuzzaldrin/fuzzaldrin-tests.ts diff --git a/types/fuzzaldrin/fuzzaldrin-tests.ts b/types/fuzzaldrin/fuzzaldrin-tests.ts new file mode 100644 index 0000000000..90ec26e3e0 --- /dev/null +++ b/types/fuzzaldrin/fuzzaldrin-tests.ts @@ -0,0 +1,20 @@ +import { match, filter, score } from 'fuzzaldrin'; + +let number = 0; +const string = '' as string; +let strings: string[] = []; +let objects: Array<{name: string, speed: number}> = []; + +strings = filter(strings, string); +strings = filter(strings, string, {maxResults: number}); +objects = filter(objects, string, {key: 'name'}); +objects = filter(objects, string, {key: 'name', maxResults: number}); + +number = score(string, string); + +match(string, string); + +// These should be type errors! Uncomment to verify. +// objects = filter(objects, string); +// objects = filter(objects, string, {key: 'speed'}); +// strings = filter(strings, string, {key: 'speed'}); diff --git a/types/fuzzaldrin/index.d.ts b/types/fuzzaldrin/index.d.ts index 1e1427c08f..ca9a64e819 100644 --- a/types/fuzzaldrin/index.d.ts +++ b/types/fuzzaldrin/index.d.ts @@ -2,7 +2,9 @@ // Project: https://github.com/atom/fuzzaldrin // Definitions by: Mohamed Hegazy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -export function filter(candidates: T[], query: string, options?: { key?: string, maxResults?: number }): T[]; +export function filter(candidates: string[], query: string, options?: {maxResults?: number}): string[]; +export function filter(candidates: T[], query: string & T[K], options: {key: K, maxResults?: number}): T[]; export function match(string: string, query: string): any; export function score(string: string, query: string): number; diff --git a/types/fuzzaldrin/tsconfig.json b/types/fuzzaldrin/tsconfig.json index abf333c6bf..2e1263faf8 100644 --- a/types/fuzzaldrin/tsconfig.json +++ b/types/fuzzaldrin/tsconfig.json @@ -17,6 +17,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "fuzzaldrin-tests.ts" ] -} \ No newline at end of file +} From beb3ffadc648f2f0f4cf08d0f7f007be1cab5997 Mon Sep 17 00:00:00 2001 From: Brice BERNARD Date: Sat, 2 Dec 2017 09:09:45 +0100 Subject: [PATCH 354/639] Make query param less restrictive --- types/next/index.d.ts | 40 ++++++++++++++++++++++++++++++++++++---- types/next/router.d.ts | 10 +++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/types/next/index.d.ts b/types/next/index.d.ts index a9042d83e9..70bc8ef049 100644 --- a/types/next/index.d.ts +++ b/types/next/index.d.ts @@ -60,7 +60,15 @@ declare namespace next { req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: string | string[] }, + query?: { + [key: string]: + | boolean + | boolean[] + | number + | number[] + | string + | string[]; + }, parsedUrl?: UrlLike, ): Promise; renderError( @@ -68,7 +76,15 @@ declare namespace next { req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: string | string[] }, + query?: { + [key: string]: + | boolean + | boolean[] + | number + | number[] + | string + | string[]; + }, ): Promise; render404( req: http.IncomingMessage, @@ -79,14 +95,30 @@ declare namespace next { req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: string | string[] }, + query?: { + [key: string]: + | boolean + | boolean[] + | number + | number[] + | string + | string[]; + }, ): Promise; renderErrorToHTML( err: any, req: http.IncomingMessage, res: http.ServerResponse, pathname: string, - query?: { [key: string]: string | string[] }, + query?: { + [key: string]: + | boolean + | boolean[] + | number + | number[] + | string + | string[]; + }, ): Promise; serveStatic( diff --git a/types/next/router.d.ts b/types/next/router.d.ts index 4102e87b12..181208518f 100644 --- a/types/next/router.d.ts +++ b/types/next/router.d.ts @@ -20,7 +20,15 @@ export interface SingletonRouter { readonly pathname: string; readonly route: string; readonly asPath?: string; - readonly query?: { [key: string]: string | string[] }; + readonly query?: { + [key: string]: + | boolean + | boolean[] + | number + | number[] + | string + | string[]; + }; // router methods reload(route: string): Promise; From df277f8016e77f7c82db5da636a6700102023e38 Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Fri, 1 Dec 2017 16:47:50 +0000 Subject: [PATCH 355/639] add redis-error types --- types/redis-errors/index.d.ts | 33 ++++++++++++++++++++++++ types/redis-errors/redis-errors-tests.ts | 27 +++++++++++++++++++ types/redis-errors/tsconfig.json | 23 +++++++++++++++++ types/redis-errors/tslint.json | 1 + 4 files changed, 84 insertions(+) create mode 100644 types/redis-errors/index.d.ts create mode 100644 types/redis-errors/redis-errors-tests.ts create mode 100644 types/redis-errors/tsconfig.json create mode 100644 types/redis-errors/tslint.json diff --git a/types/redis-errors/index.d.ts b/types/redis-errors/index.d.ts new file mode 100644 index 0000000000..663a367d9a --- /dev/null +++ b/types/redis-errors/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for redis-errors 1.2 +// Project: https://github.com/NodeRedis/redis-errors#readme +// Definitions by: James Garbutt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export class RedisError extends Error { +} + +export class ParserError extends RedisError { + buffer: string; + offset: number; + + constructor(message: string, buffer: string, offset: number); +} + +export class ReplyError extends RedisError { + command?: string; + args?: any[]; + code?: string; + + constructor(message: string); +} + +export class AbortError extends RedisError { + command?: string; + args?: any[]; +} + +export class InterruptError extends RedisError { + command?: string; + args?: any[]; + origin: Error; +} diff --git a/types/redis-errors/redis-errors-tests.ts b/types/redis-errors/redis-errors-tests.ts new file mode 100644 index 0000000000..f9d464e5b5 --- /dev/null +++ b/types/redis-errors/redis-errors-tests.ts @@ -0,0 +1,27 @@ +import { + RedisError, + ReplyError, + ParserError, + AbortError, + InterruptError +} from 'redis-errors'; + +const err = new RedisError('some error'); + +const reply = new ReplyError('some error'); +const replyArgs: any[] | undefined = reply.args; +const replyCommand: string | undefined = reply.command; +const replyCode: string | undefined = reply.code; + +const parser = new ParserError('some error', 'a buffer', 4); +const parserBuffer: string = parser.buffer; +const parserOffset: number = parser.offset; + +const abort = new AbortError('some error'); +const abortArgs: any[] | undefined = abort.args; +const abortCommand: string | undefined = abort.command; + +const interrupt = new InterruptError('some error'); +const interruptArgs: any[] | undefined = interrupt.args; +const interruptCommand: string | undefined = interrupt.command; +const interruptOrigin: Error | undefined = interrupt.origin; diff --git a/types/redis-errors/tsconfig.json b/types/redis-errors/tsconfig.json new file mode 100644 index 0000000000..cc922f5c1a --- /dev/null +++ b/types/redis-errors/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redis-errors-tests.ts" + ] +} diff --git a/types/redis-errors/tslint.json b/types/redis-errors/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/redis-errors/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 156b303d821f99e70b1f2ca9f4edbe298ef20990 Mon Sep 17 00:00:00 2001 From: Meir017 Date: Sat, 2 Dec 2017 18:01:46 +0200 Subject: [PATCH 356/639] fixed stack-trace typings removed duplicated function --- types/stack-trace/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/stack-trace/index.d.ts b/types/stack-trace/index.d.ts index e25523b8ba..843d15d0dc 100644 --- a/types/stack-trace/index.d.ts +++ b/types/stack-trace/index.d.ts @@ -9,7 +9,6 @@ export interface StackFrame { getFunctionName(): string; getMethodName(): string; getFileName(): string; - getTypeName(): string; getLineNumber(): number; getColumnNumber(): number; isNative(): boolean; From 72cde9ebb7ed371a6baf7af5db83961ec9144742 Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Sat, 2 Dec 2017 17:55:36 +0100 Subject: [PATCH 357/639] add typings for coinbase --- types/coinbase/coinbase-tests.ts | 108 +++ types/coinbase/index.d.ts | 1333 ++++++++++++++++++++++++++++++ types/coinbase/tsconfig.json | 23 + types/coinbase/tslint.json | 1 + 4 files changed, 1465 insertions(+) create mode 100644 types/coinbase/coinbase-tests.ts create mode 100644 types/coinbase/index.d.ts create mode 100644 types/coinbase/tsconfig.json create mode 100644 types/coinbase/tslint.json diff --git a/types/coinbase/coinbase-tests.ts b/types/coinbase/coinbase-tests.ts new file mode 100644 index 0000000000..793833355e --- /dev/null +++ b/types/coinbase/coinbase-tests.ts @@ -0,0 +1,108 @@ +import * as coinbase from "coinbase"; + +const client = new coinbase.Client({ apiKey: "key", apiSecret: "secret", version: "2017-10-22" }); + +client.getAccounts({}, (error: Error, result: coinbase.Account[]): void => undefined); + +client.getAccount("abcdef", (error: Error, account: coinbase.Account): void => { + account.buy({ amount: "1", commit: false, currency: "BTC", payment_method: "abcdef" }, (error: Error, buy: coinbase.Buy): void => { + buy.commit((error: Error, buy: coinbase.Buy): void => undefined); + }); + + account.createAddress({ name: "foo" }, (error: Error, address: coinbase.Address): void => { + address.getTransactions({}, (error: Error, transactions: coinbase.Transaction[]): void => undefined); + }); + + account.delete((error: Error): void => undefined); + + account.deposit({ amount: "1", commit: false, currency: "USD", payment_method: "abcdef" }, (error: Error, deposit: coinbase.Deposit): void => { + deposit.commit((error: Error, deposit: coinbase.Deposit): void => undefined); + }); + + account.getAddress("abcdef", (error: Error, address: coinbase.Address): void => undefined); + + account.getAddresses((error: Error, address: coinbase.Address[]): void => undefined); + + account.getBuy("abcdef", (error: Error, buy: coinbase.Buy): void => undefined); + + account.getBuys((error: Error, buy: coinbase.Buy[]): void => undefined); + + account.getDeposit("abcdef", (error: Error, deposit: coinbase.Deposit): void => undefined); + + account.getDeposits((error: Error, deposit: coinbase.Deposit[]): void => undefined); + + account.getSell("abcdef", (error: Error, deposit: coinbase.Sell): void => undefined); + + account.getSells((error: Error, deposit: coinbase.Sell[]): void => undefined); + + account.getTransaction("abcdef", (error: Error, deposit: coinbase.Transaction): void => undefined); + + account.getTransactions((error: Error, deposit: coinbase.Transaction[]): void => undefined); + + account.getWithdrawal("abcdef", (error: Error, deposit: coinbase.Withdrawal): void => undefined); + + account.getWithdrawals((error: Error, deposit: coinbase.Withdrawal[]): void => undefined); + + account.requestMoney( + { amount: "1", currency: "EUR", description: "foo", to: "bar", type: "request" }, + (error: Error, result: coinbase.Transaction) => undefined + ); + account.requestMoney({ amount: "1", currency: "EUR", to: "bar", type: "request" }, (error: Error, tx: coinbase.Transaction) => { + tx.cancel((error: Error, tx: coinbase.Transaction): void => undefined); + tx.complete((error: Error, tx: coinbase.Transaction): void => undefined); + tx.resend((error: Error, tx: coinbase.Transaction): void => undefined); + }); + + account.sell( + { agree_btc_amount_varies: true, amount: "1", commit: true, currency: "BTC", payment_method: "abcdef", quote: true}, + (error: Error, sell: coinbase.Sell): void => { + sell.commit((error: Error, sell: coinbase.Sell): void => undefined); + } + ); + account.sell( + { currency: "BTC", payment_method: "abcdef", total: "3"}, + (error: Error, sell: coinbase.Sell): void => { + sell.commit((error: Error, sell: coinbase.Sell): void => undefined); + } + ); + + account.sendMoney( + { amount: "1", currency: "EUR", description: "foo", fee: "2", idem: "bar", to: "baz", type: "send" }, + (error: Error, result: coinbase.Transaction) => undefined + ); + + account.setPrimary((error: Error, result: coinbase.Account): void => undefined); + + account.transferMoney( + { amount: "1", currency: "USD", description: "foo", to: "bar", type: "transfer" }, + (error: Error, tx: coinbase.Transaction): void => undefined + ); + + account.update({ name: "foo" }, (error: Error, result: coinbase.Account): void => undefined); + + account.withdraw({ amount: "1", commit: false, currency: "ETH", payment_method: "abcdef"}, (error: Error, result: coinbase.Withdrawal): void => { + result.commit((error: Error, result: coinbase.Withdrawal): void => undefined); + }); +}); + +client.getBuyPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.MoneyHash): void => undefined); + +client.getCurrencies((error: Error, result: coinbase.Currency[]): void => undefined); + +client.getExchangeRates({currency: "ETC"}, (error: Error, result: coinbase.ExchangeRate): void => undefined); + +client.getPaymentMethod("foo", (error: Error, result: coinbase.PaymentMethod): void => undefined); + +client.getPaymentMethods((error: Error, result: coinbase.PaymentMethod[]): void => undefined); + +client.getSellPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.MoneyHash): void => undefined); + +client.getSpotPrice({ currencyPair: "USD-BTC" }, (error: Error, result: coinbase.MoneyHash): void => undefined); +client.getSpotPrice({ currencyPair: "USD-BTC", date: "2017-22-01" }, (error: Error, result: coinbase.MoneyHash): void => undefined); + +client.getTime((error: Error, result: coinbase.Time): void => undefined); + +client.getUser("abcdef", (error: Error, user: coinbase.User): void => { + user.showAuth((error: Error, auth: coinbase.Auth): void => undefined); + user.update({ name: "foo", time_zone: "bar", native_currency: "USD" }, (error: Error, user: coinbase.User): void => undefined); +}); diff --git a/types/coinbase/index.d.ts b/types/coinbase/index.d.ts new file mode 100644 index 0000000000..ae1e041203 --- /dev/null +++ b/types/coinbase/index.d.ts @@ -0,0 +1,1333 @@ +// Type definitions for coinbase 2.0 +// Project: https://github.com/coinbase/coinbase-node +// Definitions by: Rogier Schouten +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface ClientConstructOpts { + /** + * API key (obtain this from the coinbase website) + */ + apiKey?: string; + /** + * API key secret (obtain this from the coinbase website) + */ + apiSecret?: string; + /** + * OAuth2 access token + */ + accessToken?: string; + /** + * API version in 'yyyy-mm-dd' format, see https://developers.coinbase.com/api/v2#changelog + */ + version?: string; +} + +export interface CreateAccountOpts { + /** + * Account name + */ + name?: string; +} + +export interface GetExchangeRateOpts { + /** + * Base currency, default USD + */ + currency?: string; +} + +export interface GetBuyPriceOpts { + /** + * Currency pair, e.g. 'BTC-USD' + */ + currencyPair: string; +} + +export interface GetSellPriceOpts { + /** + * Currency pair, e.g. 'BTC-USD' + */ + currencyPair: string; +} + +export interface GetSpotPriceOpts { + /** + * Currency pair, e.g. 'BTC-USD' + */ + currencyPair: string; + /** + * Specify date for historic spot price in format YYYY-MM-DD (UTC) + */ + date?: string; +} + +export interface UpdateAccountOpts { + /** + * Account name + */ + name?: string; +} + +export interface CreateAddressOpts { + /** + * Address label + */ + name?: string; +} + +export interface SendMoneyOpts { + /** + * Type send is required when sending money + */ + type: "send"; + /** + * A bitcoin address, litecoin address, ethereum address, or an email of the recipient + */ + to: string; + /** + * Amount to be sent + */ + amount: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * Notes to be included in the email that the recipient receives + */ + description?: string; + /** + * Don’t send notification emails for small amounts (e.g. tips) + */ + skip_notifications?: boolean; + /** + * Transaction fee in BTC/ETH/LTC if you would like to pay it. Fees can be added as a string, such as 0.0005 + */ + fee?: string; + /** + * *Recommended* A token to ensure idempotence. If a previous transaction with the same idem parameter already exists for this sender, + * that previous transaction will be returned and a new one will not be created. Max length 100 characters + */ + idem?: string; + /** + * Whether this send is to another financial institution or exchange. Required if this send is to an address and is valued at over USD$3000. + */ + to_financial_institution?: boolean; + /** + * The website of the financial institution or exchange. Required if to_financial_institution is true. + */ + financial_institution_website?: string; +} + +export interface TransferMoneyOpts { + /** + * Type transfer is required when transferring bitcoin or ethereum between accounts + */ + type: "transfer"; + /** + * ID of the receiving account + */ + to: string; + /** + * Amount to be transferred + */ + amount: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * Notes to be included in the transfer + */ + description?: string; +} + +export interface RequestMoneyOpts { + /** + * Type request is required when sending money + */ + type: "request"; + /** + * An email of the recipient + */ + to: string; + /** + * Amount to be transferred + */ + amount: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * Notes to be included in the email that the recipient receives + */ + description?: string; +} + +export interface UpdateUserOpts { + /** + * User’s name + */ + name?: string; + /** + * Time zone + */ + time_zone?: string; + /** + * Local currency used to display amounts converted from BTC + */ + native_currency?: string; +} + +export interface BuyOpts { + /** + * Buy amount without fees (alternative to total) + */ + amount?: string; + /** + * Buy amount with fees (alternative to amount) + */ + total?: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * The ID of the payment method that should be used for the buy. (todo get payment methods) + */ + payment_method?: string; + /** + * Whether or not you would still like to buy if you have to wait for your money to arrive to lock in a price + */ + agree_btc_amount_varies?: boolean; + /** + * If set to false, this buy will not be immediately completed. Use the commit call to complete it. Default value: true + */ + commit?: boolean; + /** + * If set to true, response will return an unsave buy for detailed price quote. Default value: false + */ + quote?: boolean; +} + +export interface SellOpts { + /** + * Sell amount without fees (alternative to total) + */ + amount?: string; + /** + * Sell amount with fees (alternative to amount) + */ + total?: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * The ID of the payment method that should be used for the sell. + */ + payment_method?: string; + /** + * Whether or not you would still like to sell if you have to wait for your money to arrive to lock in a price + */ + agree_btc_amount_varies?: boolean; + /** + * If set to false, this sell will not be immediately completed. Use the commit call to complete it. Default value: true + */ + commit?: boolean; + /** + * If set to true, response will return an unsave sell for detailed price quote. Default value: false + */ + quote?: boolean; +} + +export interface DepositOpts { + /** + * Deposit amount + */ + amount: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * The ID of the payment method that should be used for the buy. (todo get payment methods) + */ + payment_method?: string; + /** + * If set to false, this deposit will not be immediately completed. Use the commit call to complete it. Default value: true + */ + commit?: boolean; +} + +export interface WithdrawOpts { + /** + * Withdrawal amount + */ + amount: string; + /** + * Currency for the amount (see Client#getCurrencies() for available strings) + */ + currency: string; + /** + * The ID of the payment method that should be used for the buy. (todo get payment methods) + */ + payment_method?: string; + /** + * If set to false, this withdrawal will not be immediately completed. Use the commit call to complete it. Default value: true + */ + commit?: boolean; +} + +/** + * Combination of an amount and a currency + */ +export interface MoneyHash { + /** + * Amount as floating-point in a string + */ + amount: string; + /** + * Currency e.g. "BTC" (see Client#getCurrencies() for available strings) + */ + currency: string; +} + +export type ResourceType = "account" | "transaction" | "address" | "user" | "buy" | "sell" | "deposit" | "withdrawal" | "payment_method"; + +/** + * Base interface for all resources + */ +export interface Resource { + /** + * Resource type + */ + resource: ResourceType; +} + +export class User implements Resource { + /** + * Resource type, constant "user" + */ + resource: "user"; + + /** + * Resource ID + */ + id: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + created_at?: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + updated_at?: string; + + /** + * REST endpoint + */ + resource_path: string; + + /** + * User’s name + */ + name?: string; + + /** + * + */ + username?: string; + + /** + * Location for user’s profile + */ + profile_location?: string; + + /** + * Bio for user’s profile + */ + profile_bio?: string; + + /** + * profile location if user has one + */ + profile_url?: string; + + /** + * User’s avatar url + */ + avatar_url: string; + + /** + * Time zone (needs wallet:user:read permission) + */ + time_zone?: string; + + /** + * Native currency (needs wallet:user:read permission) + */ + native_currency?: string; + + /** + * (needs wallet:user:read permission) + */ + bitcoin_unit?: string; + + /** + * (needs wallet:user:read permission) + */ + country?: Country; + + /** + * Email address (needs wallet:user:email permission) + */ + email?: string; + + /** + * Get current user’s authorization information including granted scopes and send limits when using OAuth2 authentication + * No permission required + */ + showAuth(cb: (error: Error, result: Auth) => void): void; + + /** + * Change user properties + * Scope: wallet:user:update + */ + update(opts: UpdateUserOpts, cb: (error: Error, result: User) => void): void; +} + +export interface Auth { + /** + * Authentication method e.g. "oauth" + */ + method: string; + /** + * Permissions for this user e.g. "wallet:user:read" + */ + scopes: string[]; + + oauth_meta?: any; +} + +export interface Country { + /** + * 2-letter country code + */ + code: string; + /** + * Country name + */ + name: string; +} + +/** + * Bitcoin, Litecoin or Ethereum address + */ +export class Address implements Resource { + /** + * Type of resource, constant string "address" + */ + resource: "address"; + + /** + * Bitcoin, Litecoin or Ethereum address + */ + address: string; + + /** + * User defined label for the address + */ + name?: string; + + /** + * List transactions that have been sent to a specific address. + * Scope: wallet:transactions:read + */ + getTransactions(opts: {}, cb: (error: Error, result: Transaction[]) => void): void; +} + +export type AccountType = "wallet" | "fiat" | "multisig" | "vault" | "multisig_vault"; + +/** + * Account resource represents all of a user’s accounts, including bitcoin, litecoin and ethereum wallets, fiat currency accounts, + * and vaults. This is represented in the type field. It’s important to note that new types can be added over time so you want to + * make sure this won’t break your implementation. + * User can only have one primary account and it’s type can only be wallet. + */ +export class Account implements Resource { + /** + * Type of resource, constant string "account" + */ + resource: "account"; + + /** + * Resource ID + */ + id: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + created_at?: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + updated_at?: string; + + /** + * REST endpoint + */ + resource_path: string; + + /** + * User or system defined name + */ + name: string; + + /** + * Primary account + */ + primary: boolean; + + /** + * Account’s type + */ + type: AccountType; + + /** + * Account’s currency (see Client#getCurrencies() for available strings) + */ + currency: string; + + /** + * Balance + */ + balance: MoneyHash; + + /** + * Promote an account as primary account. + * Scope: wallet:accounts:update + */ + setPrimary(cb: (error: Error, result: Account) => void): void; + + /** + * Modifies user’s account. + * Scope: wallet:accounts:update + */ + update(opts: UpdateAccountOpts, cb: (error: Error, result: Account) => void): void; + + /** + * Removes user’s account. In order to remove an account it can’t be: + * - Primary account + * - Account with non-zero balance + * - Fiat account + * - Vault with a pending withdrawal + * Scope: wallet:accounts:delete + */ + delete(cb: (error: Error) => void): void; + + /** + * Lists addresses for an account. Important: Addresses should be considered one time use only. Create new addresses. + * Scope: wallet:addresses:read + */ + getAddresses(cb: (error: Error, result: Address[]) => void): void; + + /** + * Show an individual address for an account. A regular bitcoin, litecoin or ethereum address can be used in place of `id` but the + * address has to be associated to the correct account. Important: Addresses should be considered one time use only. Create new addresses. + * Scope: wallet:addresses:read + * @param id resource id or a regular bitcoin, litecoin or ethereum address + */ + getAddress(id: string, cb: (error: Error, result: Address) => void): void; + + /** + * Creates a new address for an account. As all the arguments are optinal, it’s possible just to do a empty POST which will create a new + * address. This is handy if you need to create new receive addresses for an account on-demand. + * Addresses can be created for all account types. With fiat accounts, funds will be received with Instant Exchange + * Scope: wallet:addresses:create + * @param opts can be null, optional address name + */ + createAddress(opts: CreateAddressOpts | null, cb: (error: Error, result: Address) => void): void; + + /** + * Lists account’s transactions. + * Scope: wallet:transactions:read + */ + getTransactions(cb: (error: Error, result: Transaction[]) => void): void; + + /** + * Show an individual transaction for an account + * Scope: wallet:transactions:read + * @param id resource id + */ + getTransaction(id: string, cb: (error: Error, result: Transaction) => void): void; + + /** + * Send funds to a bitcoin address, litecoin address, ethereum address, or email address. No transaction fees are required for off + * blockchain bitcoin transactions. + * + * It’s recommended to always supply a unique `idem` field for each transaction. This prevents you from sending the same transaction + * twice if there has been an unexpected network outage or other issue. + * + * When used with OAuth2 authentication, this endpoint requires two factor authentication unless used with + * wallet:transactions:send:bypass-2fa scope. + * + * If the user is able to buy bitcoin, they can send funds from their fiat account using instant exchange feature. + * Buy fees will be included in the created transaction and the recipient will receive the user defined amount. + * To create a multisig transaction, visit Multisig documentation. + * + * Scope: wallet:transactions:send, wallet:transactions:send:bypass-2fa + */ + sendMoney(opts: SendMoneyOpts, cb: (error: Error, result: Transaction) => void): void; + + /** + * Transfer bitcoin, litecoin or ethereum between two of a user’s accounts. Following transfers are allowed: + * - wallet to wallet + * - wallet to vault + * Scope: wallet:transactions:transfer + */ + transferMoney(opts: TransferMoneyOpts, cb: (error: Error, result: Transaction) => void): void; + + /** + * Requests money from an email address. + * Scope: wallet:transactions:request + */ + requestMoney(opts: RequestMoneyOpts, cb: (error: Error, result: Transaction) => void): void; + + /** + * Lists buys for an account. + * Scope: wallet:buys:read + */ + getBuys(cb: (error: Error, result: Buy[]) => void): void; + + /** + * Show an individual buy. + * Scope: wallet:buys:read + * @param id resource id + */ + getBuy(id: string, cb: (error: Error, result: Buy) => void): void; + + /** + * Buys a user-defined amount of bitcoin, litecoin or ethereum. + * There are two ways to define buy amounts–you can use either the amount or the total parameter: + * - When supplying amount, you’ll get the amount of bitcoin, litecoin or ethereum defined. With amount it’s recommended to use BTC or + * ETH as the currency value, but you can always specify a fiat currency and and the amount will be converted to BTC or ETH respectively. + * - When supplying total, your payment method will be debited the total amount and you’ll get the amount in BTC or ETH after fees have + * been reduced from the total. With total it’s recommended to use the currency of the payment method as the currency parameter, + * but you can always specify a different currency and it will be converted. + * Given the price of digital currency depends on the time of the call and on the amount of purchase, it’s recommended to use the + * commit: false parameter to create an uncommitted buy to show the confirmation for the user or get the final quote, and commit that + * with a separate request. + * If you need to query the buy price without locking in the buy, you can use quote: true option. This returns an unsaved buy and + * unlike commit: false, this buy can’t be completed. This option is useful when you need to show the detailed buy price quote + * for the user when they are filling a form or similar situation. + * Scope: wallet:buys:create + * @param opts indicates what to buy + * @param cb receives transaction that you can use to commit the buy + */ + buy(opts: BuyOpts, cb: (error: Error, result: Buy) => void): void; + + /** + * Lists sells for an account. + * Scope: wallet:sells:read + */ + getSells(cb: (error: Error, result: Sell[]) => void): void; + + /** + * Show an individual sell. + * Scope: wallet:sells:read + * @param id resource id + */ + getSell(id: string, cb: (error: Error, result: Sell) => void): void; + + /** + * Sells a user-defined amount of bitcoin, litecoin or ethereum. + * + * There are two ways to define sell amounts–you can use either the amount or the total parameter: + * - When supplying amount, you’ll get the amount of bitcoin, litecoin or ethereum defined. With amount it’s recommended to use BTC or + * ETH as the currency value, but you can always specify a fiat currency and the amount will be converted to BTC or ETH respectively. + * - When supplying total, your payment method will be credited the total amount and you’ll get the amount in BTC or ETH after fees + * have been reduced from the subtotal. With total it’s recommended to use the currency of the payment method as the currency parameter, + * but you can always specify a different currency and it will be converted. + * + * Given the price of digital currency depends on the time of the call and amount of the sell, it’s recommended to use the commit: false + * parameter to create an uncommitted sell to get a quote and then to commit that with a separate request. + * + * If you need to query the sell price without locking in the sell, you can use quote: true option. This returns an unsaved sell and + * unlike commit: false, this sell can’t be completed. This option is useful when you need to show the detailed sell price quote for + * the user when they are filling a form or similar situation. + * Scope: wallet:sells:create + */ + sell(opts: SellOpts, cb: (error: Error, result: Sell) => void): void; + + /** + * Lists deposits for an account. + * Scope: wallet:deposits:read + */ + getDeposits(cb: (error: Error, result: Deposit[]) => void): void; + + /** + * Show an individual deposit. + * Scope: wallet:deposits:read + * @param id resource id + */ + getDeposit(id: string, cb: (error: Error, result: Deposit) => void): void; + + /** + * Deposits user-defined amount of funds to a fiat account. + * Scope: wallet:deposits:create + */ + deposit(opts: DepositOpts, cb: (error: Error, result: Deposit) => void): void; + + /** + * Lists withdrawals for an account. + * Scope: wallet:withdrawals:read + */ + getWithdrawals(cb: (error: Error, result: Withdrawal[]) => void): void; + + /** + * Show an individual withdrawal. + * Scope: wallet:withdrawals:read + * @param id resource id + */ + getWithdrawal(id: string, cb: (error: Error, result: Withdrawal) => void): void; + + /** + * Withdraws user-defined amount of funds from a fiat account. + * Scope: wallet:withdrawals:create + */ + withdraw(opts: WithdrawOpts, cb: (error: Error, result: Withdrawal) => void): void; +} + +/** + * Reference to any resource + */ +export interface ResourceRef { + id: string; + resource: ResourceType; + resource_path: string; +} + +export type TransactionType = "send" | "request" | "transfer" | "buy" | "sell" | "fiat_deposit" | "fiat_withdrawal" | "exchange_deposit" + | "exchange_withdrawal" | "vault_withdrawal"; + +export type TransactionStatus = "pending" | "completed" | "failed" | "expired" | "canceled" | "waiting_for_signature" | "waiting_for_clearing"; + +export class Transaction implements Resource { + /** + * Constant "transaction" + */ + resource: "transaction"; + + /** + * Transaction type + */ + type: TransactionType; + + /** + * Transaction status + */ + status: TransactionStatus; + + /** + * Amount in bitcoin, litecoin or ethereum + */ + amount: MoneyHash; + + /** + * Amount in user's native currency + */ + native_amount: MoneyHash; + + /** + * Account associated with the transaction + */ + account: Account; + + /** + * User defined description + */ + description: string; + + /** + * Indicator if the transaction was instant exchanged (received into a bitcoin address for a fiat account) + */ + instant_exchange: boolean; + + /** + * Detailed information about the transaction + */ + details: any; + + /** + * Information about bitcoin, litecoin or ethereum network including network transaction hash if transaction was on-blockchain. + * Only available for certain types of transactions + */ + network?: any; + + /** + * The receiving party of a debit transaction. Usually another resource but can also be another type like email. + * Only available for certain types of transactions + */ + to?: ResourceRef | string; + + /** + * The originating party of a credit transaction. Usually another resource but can also be another type like bitcoin network. + * Only available for certain types of transactions + */ + from?: ResourceRef | string; + + /** + * Associated bitcoin, litecoin or ethereum address for received payment + */ + address?: Address; + + /** + * Associated OAuth2 application + */ + application?: any; + + /** + * Lets the recipient of a money request complete the request by sending money to the user who requested the money. + * This can only be completed by the user to whom the request was made, not the user who sent the request. + * Scope: wallet:transactions:request + */ + complete(cb: (error: Error, result: Transaction) => void): void; + + /** + * Lets the user resend a money request. This will notify recipient with a new email. + * Scope: wallet:transactions:request + */ + resend(cb: (error: Error, result: Transaction) => void): void; + + /** + * Lets a user cancel a money request. Money requests can be canceled by the sender or the recipient. + * Scope: wallet:transactions:request + */ + cancel(cb: (error: Error, result: Transaction) => void): void; +} + +export type BuyStatus = "created" | "completed" | "canceled"; + +/** + * Buy resource + */ +export class Buy implements Resource { + /** + * Constant "buy" + */ + resource: "buy"; + + /** + * Status + */ + status: BuyStatus; + + /** + * Associated payment method (e.g. a bank, fiat account) + */ + payment_method: ResourceRef; + + /** + * Associated transaction (e.g. a bank, fiat account) + */ + transaction: ResourceRef; + + /** + * Amount in bitcoin, litecoin or ethereum + */ + amount: MoneyHash; + + /** + * Fiat amount with fees + */ + total: MoneyHash; + + /** + * Fiat amount without fees + */ + subtotal: MoneyHash; + + /** + * Fee associated to this buy + */ + fee: MoneyHash; + + /** + * Has this buy been committed? + */ + committed: boolean; + + /** + * Was this buy executed instantly? + */ + instant: boolean; + + /** + * When a buy isn’t executed instantly, it will receive a payout date for the time it will be executed. ISO timestamp + */ + payout_at?: string; + + /** + * Completes a buy that is created in commit: false state. + * If the exchange rate has changed since the buy was created, this call will fail with the error “The exchange rate updated while you + * were waiting. The new total is shown below”. The buy’s total will also be updated. You can repeat the `commit` call to accept the new + * values and start the buy at the new rates. + * Scope: wallet:buys:create + */ + commit(cb: (error: Error, transaction: Buy) => void): void; +} + +export type SellStatus = "created" | "completed" | "canceled"; + +/** + * Sell resource + */ +export class Sell implements Resource { + /** + * Constant "sell" + */ + resource: "sell"; + + /** + * Status of the sell. Currently available values: created, completed, canceled + */ + status: BuyStatus; + + /** + * Associated payment method (e.g. a bank, fiat account) + */ + payment_method: ResourceRef; + + /** + * Associated transaction (e.g. a bank, fiat account) + */ + transaction: ResourceRef; + + /** + * Amount in bitcoin, litecoin or ethereum + */ + amount: MoneyHash; + + /** + * Fiat amount with fees + */ + total: MoneyHash; + + /** + * Fiat amount without fees + */ + subtotal: MoneyHash; + + /** + * Fee associated to this sell + */ + fee: MoneyHash; + + /** + * Has this sell been committed? + */ + committed: boolean; + + /** + * Was this sell executed instantly? + */ + instant: boolean; + + /** + * When a sell isn’t executed instantly, it will receive a payout date for the time it will be executed. ISO timestamp + */ + payout_at?: string; + + /** + * Completes a sell that is created in commit: false state. + * If the exchange rate has changed since the sell was created, this call will fail with the error “The exchange rate updated while you + * were waiting. The new total is shown below”. The buy’s total will also be updated. You can repeat the `commit` call to accept the new + * values and start the buy at the new rates. + * Scope: wallet:sells:create + */ + commit(cb: (error: Error, transaction: Sell) => void): void; +} + +export type DepositStatus = "created" | "completed" | "canceled"; + +/** + * Deposit resource represents a deposit of funds using a payment method (e.g. a bank). Each committed deposit also has an associated transaction. + * Deposits can be started with commit: false which is useful when displaying the confirmation for a deposit. + * These deposits will never complete and receive an associated transaction unless they are committed separately. + */ +export class Deposit implements Resource { + resource: "deposit"; + + /** + * Resource ID + */ + id: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + created_at?: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + updated_at?: string; + + /** + * REST endpoint + */ + resource_path: string; + + /** + * Status of the deposit. Currently available values: created, completed, canceled + */ + status: DepositStatus; + + /** + * Associated payment method (e.g. a bank) + */ + payment_method: ResourceRef; + + /** + * Associated transaction (e.g. a bank, fiat account) + */ + transaction: ResourceRef; + + /** + * Amount + */ + amount: MoneyHash; + + /** + * Amount without fees + */ + subtotal: MoneyHash; + + /** + * Fee associated to this deposit + */ + fee: MoneyHash; + + /** + * Has this deposit been committed? + */ + committed: boolean; + + /** + * When a deposit isn’t executed instantly, it will receive a payout date for the time it will be executed. ISO timestamp + */ + payout_at?: string; + + /** + * Completes a deposit that is created in commit: false state. + * Scope: wallet:deposits:create + */ + commit(cb: (error: Error, result: Deposit) => void): void; +} + +export type WithdrawalStatus = "created" | "completed" | "canceled"; + +/** + * Withdrawal resource represents a withdrawal of funds using a payment method (e.g. a bank). Each committed withdrawal also has a associated + * transaction. + * Withdrawal can be started with commit: false which is useful when displaying the confirmation for a withdrawal. These withdrawals will + * never complete and receive an associated transaction unless they are committed separately. + */ +export class Withdrawal implements Resource { + resource: "deposit"; + + /** + * Resource ID + */ + id: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + created_at?: string; + + /** + * ISO timestamp (sometimes needs additional permissions) + */ + updated_at?: string; + + /** + * REST endpoint + */ + resource_path: string; + + /** + * Status of the deposit. Currently available values: created, completed, canceled + */ + status: WithdrawalStatus; + + /** + * Associated payment method (e.g. a bank) + */ + payment_method: ResourceRef; + + /** + * Associated transaction (e.g. a bank, fiat account) + */ + transaction: ResourceRef; + + /** + * Amount + */ + amount: MoneyHash; + + /** + * Amount without fees + */ + subtotal: MoneyHash; + + /** + * Fee associated to this withdrawal + */ + fee: MoneyHash; + + /** + * Has this withdrawal been committed? + */ + committed: boolean; + + /** + * When a withdrawal isn’t executed instantly, it will receive a payout date for the time it will be executed. ISO timestamp + */ + payout_at?: string; + + /** + * Completes a withdrawal that is created in commit: false state. + * Scope: wallet:withdrawals:create + */ + commit(cb: (error: Error, result: Withdrawal) => void): void; +} + +export type PaymentMethodType = "ach_bank_account" | "sepa_bank_account" | "ideal_bank_account" | "fiat_account" | "bank_wire" + | "credit_card" | "secure3d_card" | "eft_bank_account" | "interac"; + +/** + * Payment method resource represents the different kinds of payment methods that can be used when buying and selling bitcoin, litecoin or + * ethereum. + * As fiat accounts can be used for buying and selling, they have an associated payment method. This type of a payment method will also have + * a fiat_account reference to the actual account. + * + * Currently available type values: + * - ach_bank_account - Regular US bank account + * - sepa_bank_account - European SEPA bank account + * - ideal_bank_account - iDeal bank account (Europe) + * - fiat_account - Fiat nominated Coinbase account + * - bank_wire - Bank wire (US only) + * - credit_card - Credit card (can’t be used for buying/selling) + * - secure3d_card - Secure3D verified payment card + * - eft_bank_account - Canadian EFT bank account + * - interac - Interac Online for Canadian bank accounts + */ +export interface PaymentMethod extends Resource { + /** + * Resource type, constant "payment_method" + */ + resource: "payment_method"; + + /** + * Payment method type + */ + type: PaymentMethodType; + + /** + * Method name + */ + name: string; + + /** + * Payment method’s native currency (see Client#getCurrencies() for available strings) + */ + currency: string; + + /** + * Is primary buying method? + */ + primary_buy: boolean; + + /** + * Is primary selling method? + */ + primary_sell: boolean; + + /** + * Is buying allowed with this method? + */ + allow_buy: boolean; + + /** + * Is selling allowed with this method? + */ + allow_sell: boolean; + + /** + * Does this method allow for instant buys? + */ + instant_buy: boolean; + + /** + * Does this method allow for instant sells? + */ + instant_sell: boolean; + + /** + * If the user has obtained optional wallet:payment-methods:limits permission, an additional field, limits, will be embedded into payment + * method data. It will contain information about buy, instant buy, sell and deposit limits (there’s no limits for withdrawals at this time). + * As each one of these can have several limits you should always look for the lowest remaining value when performing the relevant action. + */ + limits?: PaymentMethodLimits; +} + +/** + * This contains information about buy, instant buy, sell and deposit limits (there’s no limits for withdrawals at this time). + * As each one of these can have several limits you should always look for the lowest remaining value when performing the relevant action. + */ +export interface PaymentMethodLimits { + buy: PaymentMethodLimit[]; + instant_buy: PaymentMethodLimit[]; + sell: PaymentMethodLimit[]; + deposit: PaymentMethodLimit[]; +} + +export interface PaymentMethodLimit { + period_in_days: number; + total: MoneyHash; + remaining: MoneyHash; +} + +/** + * Information about one supported currency. Currency codes will conform to the ISO 4217 standard where possible. + * Currencies which have or had no representation in ISO 4217 may use a custom code (e.g. BTC). + */ +export interface Currency { + /** + * Abbreviation e.g. "USD" or "BTC" + */ + id: string; + /** + * Full name e.g. "United Arab Emirates Dirham" + */ + name: string; + /** + * Floating-point number in a string + */ + min_size: string; +} + +export interface ExchangeRate { + /** + * Base currency + */ + currency: string; + /** + * Rates as floating points in strings; indexed by currency id + */ + rates: { [index: string]: string }; +} + +export interface Time { + iso: string; + epoch: number; +} + +export class Client { + constructor(opts: ClientConstructOpts); + + /** + * Get any user’s information with their ID. + * Scopes: none + * @param id resource id + */ + getUser(id: string, cb: (error: Error, result: User) => void): void; + + /** + * Get the current user. To get user’s email or private information, use permissions wallet:user:email and wallet:user:read. If current + * request has a wallet:transactions:send scope, then the response will contain a boolean sends_disabled field that indicates + * if the user’s send functionality has been disabled. + */ + getCurrentUser(cb: (error: Error, result: User) => void): void; + + /** + * Returns all accounts for the current user + * Scope: wallet:accounts:read + */ + getAccounts(opts: {}, cb: (error: Error, result: Account[]) => void): void; + + /** + * Get one account by its Resource ID + * Scope: wallet:accounts:read + * @param id resource ID or "primary" + */ + getAccount(id: string, cb: (error: Error, result: Account) => void): void; + + /** + * Creates a new account for user. + * Scopes: wallet:accounts:create + */ + createAccount(opts: CreateAccountOpts, cb: (error: Error, result: Account) => void): void; + + /** + * Lists current user’s payment methods + * Scope: wallet:payment-methods:read + */ + getPaymentMethods(cb: (error: Error, result: PaymentMethod[]) => void): void; + + /** + * Show current user’s payment method. + * Scope: wallet:payment-methods:read + */ + getPaymentMethod(id: string, cb: (error: Error, result: PaymentMethod) => void): void; + + /** + * List known currencies. Currency codes will conform to the ISO 4217 standard where possible. Currencies which have or had no + * representation in ISO 4217 may use a custom code (e.g. BTC). + * Scope: none + */ + getCurrencies(cb: (error: Error, result: Currency[]) => void): void; + + /** + * Get current exchange rates. Default base currency is USD but it can be defined as any supported currency. + * Returned rates will define the exchange rate for one unit of the base currency. + * Scope: none + */ + getExchangeRates(opts: GetExchangeRateOpts, cb: (error: Error, result: ExchangeRate) => void): void; + + /** + * Get the total price to buy one bitcoin or ether. Note that exchange rates fluctuates so the price is only correct for seconds at the time. + * This buy price includes standard Coinbase fee (1%) but excludes any other fees including bank fees. + * If you need more accurate price estimate for a specific payment method or amount, @see Account#buy() and `quote: true` option. + * Scope: none + */ + getBuyPrice(opts: GetBuyPriceOpts, cb: (error: Error, result: MoneyHash) => void): void; + + /** + * Get the total price to sell one bitcoin or ether. Note that exchange rates fluctuates so the price is only correct for seconds at the time. + * This sell price includes standard Coinbase fee (1%) but excludes any other fees including bank fees. If you need more accurate price + * estimate for a specific payment method or amount, see sell bitcoin endpoint and quote: true option. + * Scope: none + */ + getSellPrice(opts: GetSellPriceOpts, cb: (error: Error, result: MoneyHash) => void): void; + + /** + * Get the current market price for bitcoin. This is usually somewhere in between the buy and sell price. + * Note that exchange rates fluctuates so the price is only correct for seconds at the time. + * You can also get historic prices with date parameter. + * Scope: none + */ + getSpotPrice(opts: GetSpotPriceOpts, cb: (error: Error, result: MoneyHash) => void): void; + + /** + * Get the API server time. + */ + getTime(cb: (error: Error, result: Time) => void): void; +} diff --git a/types/coinbase/tsconfig.json b/types/coinbase/tsconfig.json new file mode 100644 index 0000000000..6f8b261d27 --- /dev/null +++ b/types/coinbase/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "coinbase-tests.ts" + ] +} diff --git a/types/coinbase/tslint.json b/types/coinbase/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/coinbase/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From a10336e48d6f156fb227c82230355e62292ae7f7 Mon Sep 17 00:00:00 2001 From: Ignacio Bona Piedrabuena Date: Mon, 20 Nov 2017 14:44:58 -0800 Subject: [PATCH 358/639] Adding mount options --- types/ember/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index adef4e70c2..40246fc310 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -2097,7 +2097,10 @@ declare module 'ember' { options?: { path?: string; resetNamespace?: boolean }, callback?: (this: RouterDSL) => void ): void; - mount(name: string): void; + mount( + name: string, + options?: { as?: string, path?: string; resetNamespace?: boolean, engineInfo?: any } + ): void } class Service extends Object {} /** From a946202e81f5f3e420a8fcc1144a37b9ece64093 Mon Sep 17 00:00:00 2001 From: Ignacio Bona Piedrabuena Date: Mon, 20 Nov 2017 15:50:16 -0800 Subject: [PATCH 359/639] Fixing route mount and adding tests --- types/ember/index.d.ts | 9 +++++++-- types/ember/test/router.ts | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 40246fc310..3bc62259de 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -2099,8 +2099,13 @@ declare module 'ember' { ): void; mount( name: string, - options?: { as?: string, path?: string; resetNamespace?: boolean, engineInfo?: any } - ): void + options?: { + as?: string, + path?: string, + resetNamespace?: boolean, + engineInfo?: any + } + ): void; } class Service extends Object {} /** diff --git a/types/ember/test/router.ts b/types/ember/test/router.ts index a4aa89af1a..9ec79ce281 100755 --- a/types/ember/test/router.ts +++ b/types/ember/test/router.ts @@ -20,4 +20,5 @@ AppRouter.map(function() { }); this.route('not-found', { path: '/*path' }); this.mount('my-engine'); + this.mount('my-engine', { as: 'some-other-engine', path: '/some-other-engine'}); }); From a794e8ac591a38486c8db3e0e136f507f1c1e201 Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Sat, 2 Dec 2017 09:17:02 -0800 Subject: [PATCH 360/639] new typings for ember-qunit, ember-mocha, ember-test-helpers --- types/ember-mocha/ember-mocha-tests.ts | 187 ++++++++++++++++++ types/ember-mocha/index.d.ts | 95 +++++++++ types/ember-mocha/tsconfig.json | 21 ++ types/ember-mocha/tslint.json | 18 ++ types/ember-qunit/ember-qunit-tests.ts | 107 ++++++++++ types/ember-qunit/index.d.ts | 124 ++++++++++++ types/ember-qunit/tsconfig.json | 21 ++ types/ember-qunit/tslint.json | 9 + .../ember-test-helpers-tests.ts | 25 +++ types/ember-test-helpers/index.d.ts | 95 +++++++++ types/ember-test-helpers/tsconfig.json | 22 +++ 11 files changed, 724 insertions(+) create mode 100644 types/ember-mocha/ember-mocha-tests.ts create mode 100644 types/ember-mocha/index.d.ts create mode 100644 types/ember-mocha/tsconfig.json create mode 100644 types/ember-mocha/tslint.json create mode 100644 types/ember-qunit/ember-qunit-tests.ts create mode 100644 types/ember-qunit/index.d.ts create mode 100644 types/ember-qunit/tsconfig.json create mode 100644 types/ember-qunit/tslint.json create mode 100644 types/ember-test-helpers/ember-test-helpers-tests.ts create mode 100644 types/ember-test-helpers/index.d.ts create mode 100644 types/ember-test-helpers/tsconfig.json diff --git a/types/ember-mocha/ember-mocha-tests.ts b/types/ember-mocha/ember-mocha-tests.ts new file mode 100644 index 0000000000..a4c055c91b --- /dev/null +++ b/types/ember-mocha/ember-mocha-tests.ts @@ -0,0 +1,187 @@ +import { + describeComponent, describeModel, describeModule, + setResolver, setupAcceptanceTest, setupComponentTest, + setupModelTest, setupTest +} from 'ember-mocha'; +import { describe, it, beforeEach, afterEach, before, after } from 'mocha'; +import chai = require('chai'); +import Ember from "ember"; +import hbs from 'htmlbars-inline-precompile'; + +describeModule('name', function() { + beforeEach(function() { + }); + + it('test', function() { + }); +}); + +describeModule('name', 'description', function() { + it('test', function() { + }); +}); + +describeModule( + 'name', + 'description', + { + needs: ['service:notifications'] + }, + function() { + } +); + +describeModule('component:x-foo', 'TestModule callbacks', { + needs: [], + + beforeSetup() { + }, + setup() { + }, + teardown() { + }, + afterTeardown() { + } +}, function() { +}); + +describeComponent('x-foo', { + integration: true +}, function() { +}); + +describeComponent('x-foo', { + unit: true, + needs: ['helper:pluralize-string'] +}, function() { +}); + +describeComponent.skip( + 'block-slot', + 'Integration: BlockSlotComponent', + { + integration: true + }, + function() { + } +); + +describeModel('user', { + needs: ['model:child'] +}, function() { +}); + +describeModule('component:x-foo', 'TestModule callbacks', function() { + before(function() { + class I18n extends Ember.Object {} + + this.skip(); + this.timeout(1000); + this.registry.register('helper:i18n', I18n); + this.registry.register('helper:i18n', I18n, { singleton: true }); + this.register('service:i18n', {}); + this.inject.service('i18n'); + this.inject.service('i18n', { as: 'i18n' }); + this.factory('object:user').create(); + }); + + after(function() { + }); + + beforeEach(function() { + }); + + afterEach(function() { + }); +}); + +describe('setupTest', function() { + setupTest(); + + setupTest('service:ajax'); + + setupTest('service:ajax', { + unit: true + }); + + setupTest('controller:sidebar', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] + }); + + setupComponentTest('gravatar-image', { + // specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'] + }); + + setupModelTest('contact', { + // Specify the other units that are required for this test. + needs: [] + }); + + const Application = Ember.Application.extend(); + + setupAcceptanceTest({ Application }); + + it('test', function() { + }); +}); + +// if you don't have a custom resolver, do it like this: +setResolver(Ember.DefaultResolver.create()); + +it('renders', function() { + // setup the outer context + this.set('value', 'cat'); + this.on('action', function(result) { + chai.expect(result).to.equal('bar', 'The correct result was returned'); + chai.expect(this.get('value')).to.equal('cat'); + }); + + // render the component + this.render(hbs` + {{ x-foo value=value action="result" }} + `); + this.render('{{ x-foo value=value action="result" }}'); + this.render([ + '{{ x-foo value=value action="result" }}' + ]); + + chai.expect(this.$('div>.value').text()).to.equal('cat', 'The component shows the correct value'); + + this.$('button').click(); +}); + +it('renders', function() { + // creates the component instance + const subject = this.subject(); + + const subject2 = this.subject({ + item: 42 + }); + + const { inputFormat } = this.setProperties({ + inputFormat: 'M/D/YY', + outputFormat: 'MMMM D, YYYY', + date: '5/3/10' + }); + + const { inputFormat: if2, outputFormat } = this.getProperties('inputFormat', 'outputFormat'); + + const inputFormat2 = this.get('inputFormat'); + + // render the component on the page + this.render(); + chai.expect(this.$('.foo').text()).to.equal('bar'); +}); + +it('can calculate the result', function(assert) { + const subject = this.subject(); + + subject.set('value', 'foo'); + chai.assert.equal(subject.get('result'), 'bar'); +}); + +it.skip('disabled test'); + +it.skip('disabled test', function() { }); diff --git a/types/ember-mocha/index.d.ts b/types/ember-mocha/index.d.ts new file mode 100644 index 0000000000..d114b6620d --- /dev/null +++ b/types/ember-mocha/index.d.ts @@ -0,0 +1,95 @@ +// Type definitions for ember-mocha 0.12 +// Project: https://github.com/emberjs/ember-mocha#readme +// Definitions by: Derek Wickern +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { TestContext, ModuleCallbacks } from "ember-test-helpers"; +import Ember from 'ember'; +import { it as mochaIt, ISuiteCallbackContext } from 'mocha'; + +// these globals are re-exported as named exports by ember-mocha +type mochaBefore = typeof before; +type mochaAfter = typeof after; +type mochaBeforeEach = typeof beforeEach; +type mochaAfterEach = typeof afterEach; +type mochaSetup = typeof setup; +type mochaTeardown = typeof teardown; +type mochaSuiteSetup = typeof suiteSetup; +type mochaSuiteTeardown = typeof suiteTeardown; + +declare module 'ember-mocha' { + interface ContextDefinitionFunction { + (name: string, description: string, callbacks: ModuleCallbacks, tests: (this: ISuiteCallbackContext) => void): void; + (name: string, description: string, tests: (this: ISuiteCallbackContext) => void): void; + (name: string, callbacks: ModuleCallbacks, tests: (this: ISuiteCallbackContext) => void): void; + (name: string, tests: (this: ISuiteCallbackContext) => void): void; + } + + interface ContextDefinition extends ContextDefinitionFunction { + only: ContextDefinitionFunction; + skip: ContextDefinitionFunction; + } + + interface SetupTest { + (name?: string, callbacks?: ModuleCallbacks): void; + (callbacks: ModuleCallbacks): void; + } + + /** + * + * @param {string} fullName The full name of the unit, ie controller:application, route:index. + * @param {string} description The description of the module + * @param {ModuleCallbacks} callbacks + * @deprecated Use setupTest instead + */ + export const describeModule: ContextDefinition; + + /** + * + * @param {string} fullName the short name of the component that you'd use in a template, ie x-foo, ic-tabs, etc. + * @param {string} description The description of the module + * @param {ModuleCallbacks} callbacks + * @deprecated Use setupComponentTest instead + */ + export const describeComponent: ContextDefinition; + + /** + * + * @param {string} fullName the short name of the model you'd use in store operations ie user, assignmentGroup, etc. + * @param {string} description The description of the module + * @param {ModuleCallbacks} callbacks + * @deprecated Use setupModelTest instead + */ + export const describeModel: ContextDefinition; + + export const setupTest: SetupTest; + export const setupAcceptanceTest: SetupTest; + export const setupComponentTest: SetupTest; + export const setupModelTest: SetupTest; + + export const it: typeof mochaIt; + + /** + * Sets a Resolver globally which will be used to look up objects from each test's container. + */ + export function setResolver(resolver: Ember.Resolver): void; +} + +declare module 'mocha' { + // augment test callback context + interface ITestCallbackContext extends TestContext {} + interface IHookCallbackContext extends TestContext {} + + // re-export mocha globals as named exports + export const describe: Mocha.IContextDefinition; + export const it: Mocha.ITestDefinition; + export const setup: mochaSetup; + export const teardown: mochaTeardown; + export const suiteSetup: mochaSuiteSetup; + export const suiteTeardown: mochaSuiteTeardown; + export const before: mochaBefore; + export const after: mochaAfter; + export const beforeEach: mochaBeforeEach; + export const afterEach: mochaAfterEach; +} diff --git a/types/ember-mocha/tsconfig.json b/types/ember-mocha/tsconfig.json new file mode 100644 index 0000000000..e9fdedfe7f --- /dev/null +++ b/types/ember-mocha/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember-mocha-tests.ts" + ] +} diff --git a/types/ember-mocha/tslint.json b/types/ember-mocha/tslint.json new file mode 100644 index 0000000000..aed9a80a73 --- /dev/null +++ b/types/ember-mocha/tslint.json @@ -0,0 +1,18 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "only-arrow-functions": false, + "strict-export-declare-modifiers": false, + "no-duplicate-imports": false, + "unified-signatures": false, + "no-declare-current-package": false, + + // ERROR: An interface declaring no members is equivalent to its supertype. + // -- Not true when augmenting an interface + "no-empty-interface": false, + + // ERROR: interface name must not have an "I" prefix + // -- Augmenting @types/mocha which uses "I" prefix + "interface-name": false + } +} diff --git a/types/ember-qunit/ember-qunit-tests.ts b/types/ember-qunit/ember-qunit-tests.ts new file mode 100644 index 0000000000..de22ab3d94 --- /dev/null +++ b/types/ember-qunit/ember-qunit-tests.ts @@ -0,0 +1,107 @@ +import Ember from 'ember'; +import hbs from 'htmlbars-inline-precompile'; +import { test, skip, moduleFor, moduleForModel, moduleForComponent, setResolver } from 'ember-qunit'; + +moduleForComponent('x-foo', { + integration: true +}); + +moduleForComponent('x-foo', { + unit: true, + needs: ['helper:pluralize-string'] +}); + +moduleForModel('user', { + needs: ['model:child'] +}); + +moduleFor('controller:home'); + +moduleFor('component:x-foo', 'Some description'); + +moduleFor('component:x-foo', 'TestModule callbacks', { + beforeSetup() { + }, + + beforeEach(assert) { + this.registry.register('helper:i18n', {}); + this.register('service:i18n', {}); + this.inject.service('i18n'); + this.inject.service('i18n', { as: 'i18n' }); + this.factory('object:user').create(); + assert.ok(true); + }, + + afterEach(assert) { + assert.ok(true); + }, + + afterTeardown(assert) { + assert.ok(true); + } +}); + +// if you don't have a custom resolver, do it like this: +setResolver(Ember.DefaultResolver.create()); + +test('it renders', function(assert) { + assert.expect(2); + + // setup the outer context + this.set('value', 'cat'); + this.on('action', function(result) { + assert.equal(result, 'bar', 'The correct result was returned'); + assert.equal(this.get('value'), 'cat'); + }); + + // render the component + this.render(hbs` + {{ x-foo value=value action="result" }} + `); + this.render('{{ x-foo value=value action="result" }}'); + this.render([ + '{{ x-foo value=value action="result" }}' + ]); + + assert.equal(this.$('div>.value').text(), 'cat', 'The component shows the correct value'); + + this.$('button').click(); +}); + +test('it renders', function(assert) { + assert.expect(1); + + // creates the component instance + const subject = this.subject(); + + const subject2 = this.subject({ + item: 42 + }); + + const { inputFormat } = this.setProperties({ + inputFormat: 'M/D/YY', + outputFormat: 'MMMM D, YYYY', + date: '5/3/10' + }); + + const { inputFormat: if2, outputFormat } = this.getProperties('inputFormat', 'outputFormat'); + + const inputFormat2 = this.get('inputFormat'); + + // render the component on the page + this.render(); + assert.equal(this.$('.foo').text(), 'bar'); +}); + +test('It can calculate the result', function(assert) { + assert.expect(1); + + const subject = this.subject(); + + subject.set('value', 'foo'); + assert.equal(subject.get('result'), 'bar'); +}); + +skip('disabled test'); + +skip('disabled test', function(assert) { }); diff --git a/types/ember-qunit/index.d.ts b/types/ember-qunit/index.d.ts new file mode 100644 index 0000000000..ef75eeeb26 --- /dev/null +++ b/types/ember-qunit/index.d.ts @@ -0,0 +1,124 @@ +// Type definitions for ember-qunit 2.2 +// Project: https://github.com/emberjs/ember-qunit#readme +// Definitions by: Derek Wickern +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// + +declare module 'ember-qunit' { + import Ember from 'ember'; + import { ModuleCallbacks } from "ember-test-helpers"; + + interface QUnitModuleCallbacks extends ModuleCallbacks, Hooks { + beforeSetup?(assert: Assert): void; + setup?(assert: Assert): void; + teardown?(assert: Assert): void; + afterTeardown?(assert: Assert): void; + } + + /** + * + * @param {string} fullName The full name of the unit, ie controller:application, route:index. + * @param {string} description The description of the module + * @param {ModuleCallbacks} callbacks + */ + export function moduleFor(fullName: string, description: string, callbacks?: QUnitModuleCallbacks): void; + export function moduleFor(fullName: string, callbacks?: QUnitModuleCallbacks): void; + + /** + * + * @param {string} fullName the short name of the component that you'd use in a template, ie x-foo, ic-tabs, etc. + * @param {string} description The description of the module + * @param {ModuleCallbacks} callbacks + */ + export function moduleForComponent(fullName: string, description: string, callbacks?: QUnitModuleCallbacks): void; + export function moduleForComponent(fullName: string, callbacks?: QUnitModuleCallbacks): void; + + /** + * + * @param {string} fullName the short name of the model you'd use in store operations ie user, assignmentGroup, etc. + * @param {string} description The description of the module + * @param {ModuleCallbacks} callbacks + */ + export function moduleForModel(fullName: string, description: string, callbacks?: QUnitModuleCallbacks): void; + export function moduleForModel(fullName: string, callbacks?: QUnitModuleCallbacks): void; + + /** + * Sets a Resolver globally which will be used to look up objects from each test's container. + */ + export function setResolver(resolver: Ember.Resolver): void; + + export class QUnitAdapter extends Ember.Test.Adapter {} + + export { module, test, skip, only, todo } from 'qunit'; +} + +declare module 'qunit' { + import { TestContext } from "ember-test-helpers"; + + export const module: typeof QUnit.module; + + /** + * Add a test to run. + * + * Add a test to run using `QUnit.test()`. + * + * The `assert` argument to the callback contains all of QUnit's assertion + * methods. Use this argument to call your test assertions. + * + * `QUnit.test()` can automatically handle the asynchronous resolution of a + * Promise on your behalf if you return a thenable Promise as the result of + * your callback function. + * + * @param {string} name Title of unit being tested + * @param callback Function to close over assertions + */ + export function test(name: string, callback: (this: TestContext, assert: Assert) => void): void; + + /** + * Adds a test to exclusively run, preventing all other tests from running. + * + * Use this method to focus your test suite on a specific test. QUnit.only + * will cause any other tests in your suite to be ignored. + * + * Note, that if more than one QUnit.only is present only the first instance + * will run. + * + * This is an alternative to filtering tests to run in the HTML reporter. It + * is especially useful when you use a console reporter or in a codebase + * with a large set of long running tests. + * + * @param {string} name Title of unit being tested + * @param callback Function to close over assertions + */ + export function only(name: string, callback: (this: TestContext, assert: Assert) => void): void; + + /** + * Use this method to test a unit of code which is still under development (in a “todo” state). + * The test will pass as long as one failing assertion is present. + * + * If all assertions pass, then the test will fail signaling that `QUnit.todo` should + * be replaced by `QUnit.test`. + * + * @param {string} name Title of unit being tested + * @param callback Function to close over assertions + */ + export function todo(name: string, callback: (this: TestContext, assert: Assert) => void): void; + + /** + * Adds a test like object to be skipped. + * + * Use this method to replace QUnit.test() instead of commenting out entire + * tests. + * + * This test's prototype will be listed on the suite as a skipped test, + * ignoring the callback argument and the respective global and module's + * hooks. + * + * @param {string} Title of unit being tested + */ + export const skip: typeof QUnit.skip; + + export default QUnit; +} diff --git a/types/ember-qunit/tsconfig.json b/types/ember-qunit/tsconfig.json new file mode 100644 index 0000000000..845f5b1023 --- /dev/null +++ b/types/ember-qunit/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember-qunit-tests.ts" + ] +} diff --git a/types/ember-qunit/tslint.json b/types/ember-qunit/tslint.json new file mode 100644 index 0000000000..5070b08af9 --- /dev/null +++ b/types/ember-qunit/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "only-arrow-functions": false, + "strict-export-declare-modifiers": false, + "no-duplicate-imports": false, + "no-declare-current-package": false + } +} diff --git a/types/ember-test-helpers/ember-test-helpers-tests.ts b/types/ember-test-helpers/ember-test-helpers-tests.ts new file mode 100644 index 0000000000..fe9876803f --- /dev/null +++ b/types/ember-test-helpers/ember-test-helpers-tests.ts @@ -0,0 +1,25 @@ +/// +import { ModuleCallbacks, TestModule } from "ember-test-helpers"; +import wait from 'ember-test-helpers/wait'; +import hasEmberVersion from 'ember-test-helpers/has-ember-version'; + +function moduleFor(name: string, description: string, callbacks: ModuleCallbacks) { + let module = new TestModule(name, description, callbacks); + + QUnit.module(module.name, { + beforeEach() { + module.setup(); + }, + afterEach() { + module.teardown(); + } + }); +} + +async function testWait() { + await wait(); +} + +if (hasEmberVersion(2, 10)) { + // ... +} diff --git a/types/ember-test-helpers/index.d.ts b/types/ember-test-helpers/index.d.ts new file mode 100644 index 0000000000..26591d7d23 --- /dev/null +++ b/types/ember-test-helpers/index.d.ts @@ -0,0 +1,95 @@ +// Type definitions for ember-test-helpers 0.6 +// Project: https://github.com/emberjs/ember-test-helpers#readme +// Definitions by: Derek Wickern +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// + +declare module 'ember-test-helpers' { + import Ember from 'ember'; + import DS from 'ember-data'; + import { TemplateFactory } from 'htmlbars-inline-precompile'; + import RSVP from "rsvp"; + + interface ModuleCallbacks { + integration?: boolean; + unit?: boolean; + needs?: string[]; + + beforeSetup?(assert?: any): void; + setup?(assert?: any): void; + teardown?(assert?: any): void; + afterTeardown?(assert?: any): void; + + [key: string]: any; + } + + interface TestContext { + get(key: string): any; + getProperties(...keys: K[]): Pick; + set(key: string, value: V): V; + setProperties

(hash: P): P; + on(actionName: string, handler: (this: TestContext, ...args: any[]) => any): void; + send(actionName: string): void; + $: JQueryStatic; + subject(options?: {}): any; + render(template?: string | string[] | TemplateFactory): void; + clearRender(): void; + registry: Ember.Registry; + container: Ember.Container; + dispatcher: Ember.EventDispatcher; + application: Ember.Application; + store: DS.Store; + register(fullName: string, factory: any): void; + factory(fullName: string): any; + inject: { + controller(name: string, options?: { as: string }): any; + service(name: string, options?: { as: string }): any; + }; + } + + class TestModule { + constructor(name: string, callbacks?: ModuleCallbacks); + constructor(name: string, description?: string, callbacks?: ModuleCallbacks); + + name: string; + subjectName: string; + description: string; + isIntegration: boolean; + callbacks: ModuleCallbacks; + context: TestContext; + resolver: Ember.Resolver; + + setup(assert?: any): RSVP.Promise; + teardown(assert?: any): RSVP.Promise; + getContext(): TestContext; + setContext(context: TestContext): void; + } + + class TestModuleForAcceptance extends TestModule {} + class TestModuleForIntegration extends TestModule {} + class TestModuleForComponent extends TestModule {} + class TestModuleForModel extends TestModule {} + + function getContext(): TestContext | undefined; + function setContext(context: TestContext): void; + function unsetContext(): void; + function setResolver(resolver: Ember.Resolver): void; +} + +declare module 'ember-test-helpers/wait' { + import RSVP from "rsvp"; + + interface WaitOptions { + waitForTimers?: boolean; + waitForAJAX?: boolean; + waitForWaiters?: boolean; + } + + export default function wait(options?: WaitOptions): RSVP.Promise; +} + +declare module 'ember-test-helpers/has-ember-version' { + export default function hasEmberVersion(major: number, minor: number): boolean; +} diff --git a/types/ember-test-helpers/tsconfig.json b/types/ember-test-helpers/tsconfig.json new file mode 100644 index 0000000000..dc9c583d1c --- /dev/null +++ b/types/ember-test-helpers/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ember-test-helpers-tests.ts" + ] +} From 09b8dc2546a2669d50198d063b41a8fcec9e29df Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Sat, 2 Dec 2017 18:47:31 +0000 Subject: [PATCH 361/639] add some quill types --- types/quill/index.d.ts | 6 ++++++ types/quill/package.json | 6 ++++++ types/quill/quill-tests.ts | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100644 types/quill/package.json diff --git a/types/quill/index.d.ts b/types/quill/index.d.ts index 6325913519..7cad5330a2 100644 --- a/types/quill/index.d.ts +++ b/types/quill/index.d.ts @@ -2,8 +2,11 @@ // Project: https://github.com/quilljs/quill/ // Definitions by: Sumit // Guillaume +// James Garbutt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { Blot } from 'parchment/src/blot/abstract/blot'; + /** * A stricter type definition would be: * @@ -56,7 +59,9 @@ export interface QuillOptionsStatic { } export interface BoundsStatic { + bottom: number; left: number; + right: number; top: number; height: number; width: number; @@ -136,6 +141,7 @@ export class Quill implements EventEmitter { */ root: HTMLDivElement; clipboard: ClipboardStatic; + scroll: Blot; constructor(container: string | Element, options?: QuillOptionsStatic); deleteText(index: number, length: number, source?: Sources): DeltaStatic; disable(): void; diff --git a/types/quill/package.json b/types/quill/package.json new file mode 100644 index 0000000000..85d0ed05d1 --- /dev/null +++ b/types/quill/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "parchment": "^1.1.2" + } +} diff --git a/types/quill/quill-tests.ts b/types/quill/quill-tests.ts index 142c821ffa..f907092ed1 100644 --- a/types/quill/quill-tests.ts +++ b/types/quill/quill-tests.ts @@ -1,4 +1,5 @@ import { Quill, Delta, DeltaStatic, RangeStatic, StringMap } from 'quill'; +import { Blot } from 'parchment/src/blot/abstract/blot'; function test_quill() { const quillEditor = new Quill('#editor', { @@ -10,6 +11,11 @@ function test_quill() { }); } +function test_scroll() { + const quillEditor = new Quill('#editor'); + const blot: Blot = quillEditor.scroll; +} + function test_deleteText() { const quillEditor = new Quill('#editor'); quillEditor.deleteText(0, 10); From 116d67d8f594369bfb7f839d9f42b7be24c5e930 Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Sat, 2 Dec 2017 10:26:32 -0800 Subject: [PATCH 362/639] fix tslint errors --- types/ember-mocha/index.d.ts | 24 +++-------------- types/ember-qunit/index.d.ts | 26 +++++++------------ .../ember-test-helpers-tests.ts | 2 +- types/ember-test-helpers/tslint.json | 8 ++++++ 4 files changed, 22 insertions(+), 38 deletions(-) create mode 100644 types/ember-test-helpers/tslint.json diff --git a/types/ember-mocha/index.d.ts b/types/ember-mocha/index.d.ts index d114b6620d..6a16c54fde 100644 --- a/types/ember-mocha/index.d.ts +++ b/types/ember-mocha/index.d.ts @@ -36,31 +36,13 @@ declare module 'ember-mocha' { (callbacks: ModuleCallbacks): void; } - /** - * - * @param {string} fullName The full name of the unit, ie controller:application, route:index. - * @param {string} description The description of the module - * @param {ModuleCallbacks} callbacks - * @deprecated Use setupTest instead - */ + /** @deprecated Use setupTest instead */ export const describeModule: ContextDefinition; - /** - * - * @param {string} fullName the short name of the component that you'd use in a template, ie x-foo, ic-tabs, etc. - * @param {string} description The description of the module - * @param {ModuleCallbacks} callbacks - * @deprecated Use setupComponentTest instead - */ + /** @deprecated Use setupComponentTest instead */ export const describeComponent: ContextDefinition; - /** - * - * @param {string} fullName the short name of the model you'd use in store operations ie user, assignmentGroup, etc. - * @param {string} description The description of the module - * @param {ModuleCallbacks} callbacks - * @deprecated Use setupModelTest instead - */ + /** @deprecated Use setupModelTest instead */ export const describeModel: ContextDefinition; export const setupTest: SetupTest; diff --git a/types/ember-qunit/index.d.ts b/types/ember-qunit/index.d.ts index ef75eeeb26..0edc5c837f 100644 --- a/types/ember-qunit/index.d.ts +++ b/types/ember-qunit/index.d.ts @@ -18,28 +18,22 @@ declare module 'ember-qunit' { } /** - * - * @param {string} fullName The full name of the unit, ie controller:application, route:index. - * @param {string} description The description of the module - * @param {ModuleCallbacks} callbacks + * @param fullName The full name of the unit, ie controller:application, route:index. + * @param description The description of the module */ export function moduleFor(fullName: string, description: string, callbacks?: QUnitModuleCallbacks): void; export function moduleFor(fullName: string, callbacks?: QUnitModuleCallbacks): void; /** - * - * @param {string} fullName the short name of the component that you'd use in a template, ie x-foo, ic-tabs, etc. - * @param {string} description The description of the module - * @param {ModuleCallbacks} callbacks + * @param fullName the short name of the component that you'd use in a template, ie x-foo, ic-tabs, etc. + * @param description The description of the module */ export function moduleForComponent(fullName: string, description: string, callbacks?: QUnitModuleCallbacks): void; export function moduleForComponent(fullName: string, callbacks?: QUnitModuleCallbacks): void; /** - * - * @param {string} fullName the short name of the model you'd use in store operations ie user, assignmentGroup, etc. - * @param {string} description The description of the module - * @param {ModuleCallbacks} callbacks + * @param fullName the short name of the model you'd use in store operations ie user, assignmentGroup, etc. + * @param description The description of the module */ export function moduleForModel(fullName: string, description: string, callbacks?: QUnitModuleCallbacks): void; export function moduleForModel(fullName: string, callbacks?: QUnitModuleCallbacks): void; @@ -71,7 +65,7 @@ declare module 'qunit' { * Promise on your behalf if you return a thenable Promise as the result of * your callback function. * - * @param {string} name Title of unit being tested + * @param name Title of unit being tested * @param callback Function to close over assertions */ export function test(name: string, callback: (this: TestContext, assert: Assert) => void): void; @@ -89,7 +83,7 @@ declare module 'qunit' { * is especially useful when you use a console reporter or in a codebase * with a large set of long running tests. * - * @param {string} name Title of unit being tested + * @param name Title of unit being tested * @param callback Function to close over assertions */ export function only(name: string, callback: (this: TestContext, assert: Assert) => void): void; @@ -101,7 +95,7 @@ declare module 'qunit' { * If all assertions pass, then the test will fail signaling that `QUnit.todo` should * be replaced by `QUnit.test`. * - * @param {string} name Title of unit being tested + * @param name Title of unit being tested * @param callback Function to close over assertions */ export function todo(name: string, callback: (this: TestContext, assert: Assert) => void): void; @@ -116,7 +110,7 @@ declare module 'qunit' { * ignoring the callback argument and the respective global and module's * hooks. * - * @param {string} Title of unit being tested + * @param Title of unit being tested */ export const skip: typeof QUnit.skip; diff --git a/types/ember-test-helpers/ember-test-helpers-tests.ts b/types/ember-test-helpers/ember-test-helpers-tests.ts index fe9876803f..f21d554cfa 100644 --- a/types/ember-test-helpers/ember-test-helpers-tests.ts +++ b/types/ember-test-helpers/ember-test-helpers-tests.ts @@ -4,7 +4,7 @@ import wait from 'ember-test-helpers/wait'; import hasEmberVersion from 'ember-test-helpers/has-ember-version'; function moduleFor(name: string, description: string, callbacks: ModuleCallbacks) { - let module = new TestModule(name, description, callbacks); + const module = new TestModule(name, description, callbacks); QUnit.module(module.name, { beforeEach() { diff --git a/types/ember-test-helpers/tslint.json b/types/ember-test-helpers/tslint.json new file mode 100644 index 0000000000..659431c9ea --- /dev/null +++ b/types/ember-test-helpers/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "strict-export-declare-modifiers": false, + "no-duplicate-imports": false, + "no-declare-current-package": false + } +} From 106825d2fe24adea60d3c0f8738c5d5844dd40e9 Mon Sep 17 00:00:00 2001 From: William Lohan Date: Sat, 2 Dec 2017 16:39:26 -0800 Subject: [PATCH 363/639] update project url --- types/less2sass/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/less2sass/index.d.ts b/types/less2sass/index.d.ts index af2746177a..eb1e5801bd 100644 --- a/types/less2sass/index.d.ts +++ b/types/less2sass/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for less2sass 1.0 -// Project: http://erickryski.com +// Project: https://github.com/ekryski/less2sass // Definitions by: William Lohan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From e1ce6b42093d56b5a9bd1b7d81f019a4a09bdb79 Mon Sep 17 00:00:00 2001 From: int0h Date: Sun, 3 Dec 2017 04:16:06 +0300 Subject: [PATCH 364/639] Type definitions for weak 1.0.1 --- types/weak/index.d.ts | 68 ++++++++++++++++++++++++++++++++++++++++ types/weak/tsconfig.json | 22 +++++++++++++ types/weak/tslint.json | 1 + types/weak/weak-tests.ts | 9 ++++++ 4 files changed, 100 insertions(+) create mode 100644 types/weak/index.d.ts create mode 100644 types/weak/tsconfig.json create mode 100644 types/weak/tslint.json create mode 100644 types/weak/weak-tests.ts diff --git a/types/weak/index.d.ts b/types/weak/index.d.ts new file mode 100644 index 0000000000..554e7474d8 --- /dev/null +++ b/types/weak/index.d.ts @@ -0,0 +1,68 @@ +// Type definitions for weak 1.0.1 +// Project: https://github.com/TooTallNate/node-weak +// Definitions by: William Kapp +/// + +interface WeakRef {} + +/** + * Makes weak references to JavaScript Objects + * @param object can be a regular Object, an Array, a Function, a RegExp, or any of the primitive types or constructor function created with new + * @param callback a callback function to be invoked before the object is garbage collected + */ +declare function weak(object: T, callback?: () => void): WeakRef; + +declare namespace weak { + + /** + * Returns the actual reference to the Object that this weak reference was created with. If this is called with a dead reference, undefined is returned. + * @param ref + */ + export function get(ref: WeakRef): T | undefined; + + /** + * Checks to see if ref is a dead reference. Returns true if the original Object has already been GC'd, false otherwise + * @param ref + */ + export function isDead(ref: WeakRef): boolean; + + /** + * Checks to see if ref is "near death". This will be true exactly during the weak reference callback function, and false any other time. + * @param ref + */ + export function isNearDeath(ref: WeakRef): boolean; + + /** + * Checks to see if obj is "weak reference" instance. Returns true if the passed in object is a "weak reference", false otherwise. + * @param obj + */ + export function isWeakRef(obj: Object | WeakRef): boolean; + + /** + * Adds callback to the Array of callback functions that will be invoked before the Object gets garbage collected. The callbacks get executed in the order that they are added. + * @param ref + * @param callback + */ + export function addCallback(ref: WeakRef, callback: () => void): NodeJS.EventEmitter; + + /** + * Removes callback from the Array of callback functions that will be invoked before the Object gets garbage collected. + * @param ref + * @param callback + */ + export function removeCallback(ref: WeakRef, callback: () => void): NodeJS.EventEmitter; + + /** + * Empties the Array of callback functions that will be invoked before the Object gets garbage collected. + * @param ref + */ + export function removeCallbacks(ref: WeakRef): NodeJS.EventEmitter; + + /** + * Returns an Array that ref iterates through to invoke the GC callbacks. This utilizes node's EventEmitter#listeners() function and therefore returns a copy in node 0.10 and newer. + * @param ref + */ + export function callbacks(ref: WeakRef): (() => void)[]; +} + +export = weak; diff --git a/types/weak/tsconfig.json b/types/weak/tsconfig.json new file mode 100644 index 0000000000..a0bb7dd534 --- /dev/null +++ b/types/weak/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../", + "../node" + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "weak-tests.ts" + ] +} diff --git a/types/weak/tslint.json b/types/weak/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/weak/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/weak/weak-tests.ts b/types/weak/weak-tests.ts new file mode 100644 index 0000000000..01a4b2adfc --- /dev/null +++ b/types/weak/weak-tests.ts @@ -0,0 +1,9 @@ +import weak = require('weak'); + +const obj = {a: 123}; + +const weakReference = weak(obj, () => { + // collected +}); + +const sameType = weak.get(weakReference); From 09018134f8a51d8ebc63ce8c83da844834624356 Mon Sep 17 00:00:00 2001 From: int0h Date: Sun, 3 Dec 2017 04:36:47 +0300 Subject: [PATCH 365/639] weak lint fixes --- types/weak/index.d.ts | 46 +++++++++++++++++++++------------------- types/weak/tsconfig.json | 5 +++-- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/types/weak/index.d.ts b/types/weak/index.d.ts index 554e7474d8..5620540fae 100644 --- a/types/weak/index.d.ts +++ b/types/weak/index.d.ts @@ -1,68 +1,70 @@ -// Type definitions for weak 1.0.1 +// Type definitions for weak 1.0 // Project: https://github.com/TooTallNate/node-weak // Definitions by: William Kapp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + /// -interface WeakRef {} +declare class WeakRef {} /** * Makes weak references to JavaScript Objects * @param object can be a regular Object, an Array, a Function, a RegExp, or any of the primitive types or constructor function created with new * @param callback a callback function to be invoked before the object is garbage collected */ -declare function weak(object: T, callback?: () => void): WeakRef; +declare function weak(object: T, callback?: () => void): WeakRef; declare namespace weak { - /** * Returns the actual reference to the Object that this weak reference was created with. If this is called with a dead reference, undefined is returned. - * @param ref + * @param ref weak reference object */ - export function get(ref: WeakRef): T | undefined; + function get(ref: WeakRef): T | undefined; /** * Checks to see if ref is a dead reference. Returns true if the original Object has already been GC'd, false otherwise - * @param ref + * @param ref weak reference object */ - export function isDead(ref: WeakRef): boolean; + function isDead(ref: WeakRef): boolean; /** * Checks to see if ref is "near death". This will be true exactly during the weak reference callback function, and false any other time. - * @param ref + * @param ref weak reference object */ - export function isNearDeath(ref: WeakRef): boolean; + function isNearDeath(ref: WeakRef): boolean; /** * Checks to see if obj is "weak reference" instance. Returns true if the passed in object is a "weak reference", false otherwise. - * @param obj + * @param obj object to check */ - export function isWeakRef(obj: Object | WeakRef): boolean; + function isWeakRef(obj: object | WeakRef): boolean; /** * Adds callback to the Array of callback functions that will be invoked before the Object gets garbage collected. The callbacks get executed in the order that they are added. - * @param ref - * @param callback + * @param ref weak reference object + * @param callback function to be called */ - export function addCallback(ref: WeakRef, callback: () => void): NodeJS.EventEmitter; + function addCallback(ref: WeakRef, callback: () => void): NodeJS.EventEmitter; /** * Removes callback from the Array of callback functions that will be invoked before the Object gets garbage collected. - * @param ref - * @param callback + * @param ref weak reference object + * @param callback function to be called */ - export function removeCallback(ref: WeakRef, callback: () => void): NodeJS.EventEmitter; + function removeCallback(ref: WeakRef, callback: () => void): NodeJS.EventEmitter; /** * Empties the Array of callback functions that will be invoked before the Object gets garbage collected. - * @param ref + * @param ref weak reference object */ - export function removeCallbacks(ref: WeakRef): NodeJS.EventEmitter; + function removeCallbacks(ref: WeakRef): NodeJS.EventEmitter; /** * Returns an Array that ref iterates through to invoke the GC callbacks. This utilizes node's EventEmitter#listeners() function and therefore returns a copy in node 0.10 and newer. - * @param ref + * @param ref weak reference object */ - export function callbacks(ref: WeakRef): (() => void)[]; + function callbacks(ref: WeakRef): Array<(() => void)>; } export = weak; diff --git a/types/weak/tsconfig.json b/types/weak/tsconfig.json index a0bb7dd534..33d1a4cdf3 100644 --- a/types/weak/tsconfig.json +++ b/types/weak/tsconfig.json @@ -7,11 +7,12 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ - "../", - "../node" + "../" ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From c0828a80fd5a246fcc606394928d22a1e84ee1af Mon Sep 17 00:00:00 2001 From: William Lohan Date: Sat, 2 Dec 2017 21:38:58 -0800 Subject: [PATCH 366/639] remove private methods --- types/less2sass/index.d.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/types/less2sass/index.d.ts b/types/less2sass/index.d.ts index eb1e5801bd..25848117f2 100644 --- a/types/less2sass/index.d.ts +++ b/types/less2sass/index.d.ts @@ -5,15 +5,6 @@ declare class Less2Sass { convert(file: string): string; - private convertColourHelpers(): Less2Sass; - private convertExtend(): Less2Sass; - private convertFileExtensions(): Less2Sass; - private convertFunctionUnit(): Less2Sass; - private convertInterpolatedVariables(): Less2Sass; - private convertMixins(): Less2Sass; - private convertTildaStrings(): Less2Sass; - private convertVariables(): Less2Sass; - private includeMixins(): Less2Sass; } declare const less2sass: Less2Sass; From dc914efc0d94e88011b7dfc554ad75c4bff1220a Mon Sep 17 00:00:00 2001 From: int0h Date: Sun, 3 Dec 2017 13:42:25 +0300 Subject: [PATCH 367/639] type guards --- types/weak/index.d.ts | 6 +++--- types/weak/weak-tests.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/types/weak/index.d.ts b/types/weak/index.d.ts index 5620540fae..456a578539 100644 --- a/types/weak/index.d.ts +++ b/types/weak/index.d.ts @@ -26,19 +26,19 @@ declare namespace weak { * Checks to see if ref is a dead reference. Returns true if the original Object has already been GC'd, false otherwise * @param ref weak reference object */ - function isDead(ref: WeakRef): boolean; + function isDead(ref: WeakRef): ref is WeakRef; /** * Checks to see if ref is "near death". This will be true exactly during the weak reference callback function, and false any other time. * @param ref weak reference object */ - function isNearDeath(ref: WeakRef): boolean; + function isNearDeath(ref: WeakRef): ref is WeakRef; /** * Checks to see if obj is "weak reference" instance. Returns true if the passed in object is a "weak reference", false otherwise. * @param obj object to check */ - function isWeakRef(obj: object | WeakRef): boolean; + function isWeakRef(obj: any): obj is WeakRef; /** * Adds callback to the Array of callback functions that will be invoked before the Object gets garbage collected. The callbacks get executed in the order that they are added. diff --git a/types/weak/weak-tests.ts b/types/weak/weak-tests.ts index 01a4b2adfc..a77180823e 100644 --- a/types/weak/weak-tests.ts +++ b/types/weak/weak-tests.ts @@ -7,3 +7,20 @@ const weakReference = weak(obj, () => { }); const sameType = weak.get(weakReference); + +function foo(a: {a: number}) {} + +if (sameType) { + foo(sameType); +} + +const anyVar = null as any; + +if (weak.isWeakRef(anyVar)) { + const a = anyVar; // WeakRef +} + +if (weak.isDead(weakReference)) { + const a = weakReference; // WeakRef + const value = weak.get(weakReference); // undefined only possible +} From 519d07927946ed7026cebe9a0cc90e58c5ee6b47 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Sun, 3 Dec 2017 11:53:58 +0100 Subject: [PATCH 368/639] Fixed autor link typo @mcortesi --- types/mongodb/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index fbbc318a33..0c7b90edfd 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -5,7 +5,7 @@ // Gady Piazza // Jason Dreyzehner // Gaurav Lahoti -// Mariano Cortesi +// Mariano Cortesi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From f3d99a176675b6a0ca8bd20f583ff272d56df644 Mon Sep 17 00:00:00 2001 From: Dmin Date: Sun, 3 Dec 2017 23:40:58 +0900 Subject: [PATCH 369/639] fix(algolia): geo-search parameters type --- types/algoliasearch/algoliasearch-tests.ts | 6 +++--- types/algoliasearch/index.d.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/types/algoliasearch/algoliasearch-tests.ts b/types/algoliasearch/algoliasearch-tests.ts index 1786b07af7..0814b0fc03 100644 --- a/types/algoliasearch/algoliasearch-tests.ts +++ b/types/algoliasearch/algoliasearch-tests.ts @@ -121,12 +121,12 @@ let _algoliaQueryParameters: AlgoliaQueryParameters = { disableTypoToleranceOnAttributes: '', aroundLatLng: '', aroundLatLngViaIP: '', - aroundRadius: '', + aroundRadius: 0, aroundPrecision: 0, minimumAroundRadius: 0, - insideBoundingBox: '', + insideBoundingBox: [[0]], queryType: '', - insidePolygon: '', + insidePolygon: [[0]], removeWordsIfNoResults: '', advancedSyntax: false, optionalWords: [''], diff --git a/types/algoliasearch/index.d.ts b/types/algoliasearch/index.d.ts index f068fc4e22..1a4b8f141a 100644 --- a/types/algoliasearch/index.d.ts +++ b/types/algoliasearch/index.d.ts @@ -1770,7 +1770,7 @@ Interface describing options available for gettings the logs * You can specify aroundRadius=all if you want to compute the geo distance without filtering in a geo area * https://github.com/algolia/algoliasearch-client-js#aroundradius */ - aroundRadius?: any; + aroundRadius?: number | 'all'; /** * Control the precision of a geo search * default: null @@ -1788,7 +1788,7 @@ Interface describing options available for gettings the logs * default: null * https://github.com/algolia/algoliasearch-client-js#insideboundingbox */ - insideBoundingBox?: string; + insideBoundingBox?: number[][]; /** * Selects how the query words are interpreted * default: 'prefixLast' @@ -1803,7 +1803,7 @@ Interface describing options available for gettings the logs * defauly: '' * https://github.com/algolia/algoliasearch-client-js#insidepolygon */ - insidePolygon?: string; + insidePolygon?: number[][]; /** * This option is used to select a strategy in order to avoid having an empty result page * default: 'none' From 34f6a6d09631d2280b461f7fc23c745c97467340 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Sun, 3 Dec 2017 08:42:47 -0800 Subject: [PATCH 370/639] Increase commander asOfVersion to not conflict with current version --- notNeededPackages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notNeededPackages.json b/notNeededPackages.json index 953b52114a..0e5f946e07 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -142,7 +142,7 @@ "libraryName": "commander", "typingsPackageName": "commander", "sourceRepoURL": "https://github.com/tj/commander.js", - "asOfVersion": "2.12.0" + "asOfVersion": "2.12.2" }, { "libraryName": "constant-case", From 27a03d60d880614c982b937ced2fed57fe32a9a0 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Sun, 3 Dec 2017 19:07:05 +0100 Subject: [PATCH 371/639] Changes per @rpl review See commit history at https://github.com/bomjacob/definitelytyped-firefox-webext-browser/compare/71548e2450bd9fe9b6433284bff4a268bf8c00e5...b7e3c091d1392159e04011877c5197af92d8e3a2 for full list of changes. --- .../firefox-webext-browser-tests.ts | 12 +- types/firefox-webext-browser/index.d.ts | 532 +++++++++--------- types/firefox-webext-browser/tsconfig.json | 3 +- 3 files changed, 288 insertions(+), 259 deletions(-) diff --git a/types/firefox-webext-browser/firefox-webext-browser-tests.ts b/types/firefox-webext-browser/firefox-webext-browser-tests.ts index 879b8af0bb..01d9cf9f3d 100644 --- a/types/firefox-webext-browser/firefox-webext-browser-tests.ts +++ b/types/firefox-webext-browser/firefox-webext-browser-tests.ts @@ -1,2 +1,10 @@ -// No tests yet -true; +browser.nonexistentNS; // $ExpectError +browser.nonexistentNS.unknownMethod(); // $ExpectError + +// Test that out overwritten things at least worked +browser.runtime.getManifest(); // $ExpectType WebExtensionManifest +browser.test; // $ExpectError +browser.manifest; // $ExpectError +browser._manifest; // $ExpectType typeof _manifest +browser._manifest.WebExtensionLangpackManifest; // $ExpectError +browser._manifest.NativeManifest; // $ExpectError diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts index 8a2d34b0be..326346be82 100644 --- a/types/firefox-webext-browser/index.d.ts +++ b/types/firefox-webext-browser/index.d.ts @@ -5,12 +5,16 @@ // TypeScript Version: 2.4 // Generated using script at github.com/bomjacob/definitelytyped-firefox-webext-browser -interface EventListener any> { +interface WebExtEventListener any> { addListener: (callback: T) => void; removeListener: (listener: T) => void; hasListener: (listener: T) => boolean; } +interface Window { + browser: typeof browser; +} + declare namespace browser.alarms { /* alarms types */ interface Alarm { @@ -40,11 +44,11 @@ declare namespace browser.alarms { function clearAll(): Promise; /* alarms events */ - const onAlarm: EventListener<(name: Alarm) => void>; + const onAlarm: WebExtEventListener<(name: Alarm) => void>; } -declare namespace browser.manifest { - /* manifest types */ +declare namespace browser._manifest { + /* _manifest types */ type OptionalPermission = _OptionalPermission; type Permission = string | OptionalPermission | _Permission; @@ -162,39 +166,6 @@ declare namespace browser.manifest { }; } - interface WebExtensionLangpackManifest { - manifest_version: number; - applications?: { - gecko?: FirefoxSpecificProperties; - }; - browser_specific_settings?: { - gecko?: FirefoxSpecificProperties; - }; - name: string; - short_name?: string; - description?: string; - author?: string; - version: string; - homepage_url?: string; - langpack_id: string; - languages: { - [key: string]: { - chrome_resources: { - [key: string]: ExtensionURL | { - [key: string]: ExtensionURL; - }; - }; - version: string; - }; - }; - sources?: { - [key: string]: { - base_path: ExtensionURL; - paths?: string[]; - }; - }; - } - interface ThemeIcons { light: ExtensionURL; dark: ExtensionURL; @@ -211,7 +182,7 @@ declare namespace browser.manifest { type ImageDataOrExtensionURL = string; - type ExtensionID = string | string; + type ExtensionID = string; interface FirefoxSpecificProperties { id?: ExtensionID; @@ -220,9 +191,9 @@ declare namespace browser.manifest { strict_max_version?: string; } - type MatchPattern = string | string | _MatchPattern; + type MatchPattern = string | _MatchPattern; - type MatchPatternInternal = string | string | _MatchPatternInternal; + type MatchPatternInternal = string | _MatchPatternInternal; interface ContentScript { matches: MatchPattern[]; @@ -250,19 +221,6 @@ declare namespace browser.manifest { type PersistentBackgroundProperty = boolean; - type NativeManifest = { - name: string; - description: string; - path: string; - type: _NativeManifestType; - allowed_extensions: ExtensionID[]; - } | { - name: ExtensionID; - description: string; - data: any; - type: _NativeManifestType; - }; - interface ThemeType { images?: { additional_backgrounds?: ImageDataOrExtensionURL[]; @@ -371,7 +329,7 @@ declare namespace browser.manifest { }; } - type KeyName = string | string | string; + type KeyName = string; enum _OptionalPermission { browserSettings = "browserSettings", @@ -457,15 +415,6 @@ declare namespace browser.manifest { all_urls = "" } - enum _NativeManifestType { - pkcs11 = "pkcs11", - stdio = "stdio" - } - - enum _NativeManifestType { - storage = "storage" - } - enum _ThemeTypeAdditionalBackgroundsAlignment { bottom = "bottom", center = "center", @@ -558,15 +507,15 @@ declare namespace browser.contextualIdentities { function remove(cookieStoreId: string): void; /* contextualIdentities events */ - const onUpdated: EventListener<(changeInfo: { + const onUpdated: WebExtEventListener<(changeInfo: { contextualIdentity: ContextualIdentity; }) => void>; - const onCreated: EventListener<(changeInfo: { + const onCreated: WebExtEventListener<(changeInfo: { contextualIdentity: ContextualIdentity; }) => void>; - const onRemoved: EventListener<(changeInfo: { + const onRemoved: WebExtEventListener<(changeInfo: { contextualIdentity: ContextualIdentity; }) => void>; } @@ -642,7 +591,7 @@ declare namespace browser.cookies { function getAllCookieStores(): Promise; /* cookies events */ - const onChanged: EventListener<(changeInfo: { + const onChanged: WebExtEventListener<(changeInfo: { removed: boolean; cookie: Cookie; cause: OnChangedCause; @@ -811,18 +760,18 @@ declare namespace browser.downloads { function removeFile(downloadId: number): Promise; - function acceptDanger(downloadId: number): void; + const acceptDanger: ((downloadId: number) => void) | undefined; - function drag(downloadId: number): void; + const drag: ((downloadId: number) => void) | undefined; - function setShelfEnabled(enabled: boolean): void; + const setShelfEnabled: ((enabled: boolean) => void) | undefined; /* downloads events */ - const onCreated: EventListener<(downloadItem: DownloadItem) => void>; + const onCreated: WebExtEventListener<(downloadItem: DownloadItem) => void>; - const onErased: EventListener<(downloadId: number) => void>; + const onErased: WebExtEventListener<(downloadId: number) => void>; - const onChanged: EventListener<(downloadDelta: { + const onChanged: WebExtEventListener<(downloadDelta: { id: number; url?: StringDelta; filename?: StringDelta; @@ -859,11 +808,11 @@ declare namespace browser.events { hasListeners(): boolean; - addRules(eventName: string, webViewInstanceId: number, rules: Rule[]): void; + addRules?(eventName: string, webViewInstanceId: number, rules: Rule[]): void; - getRules(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): void; + getRules?(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): void; - removeRules(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): void; + removeRules?(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): void; } interface UrlFilter { @@ -912,22 +861,22 @@ declare namespace browser.extension { type?: ViewType; windowId?: number; tabId?: number; - }): object/*Window*/[]; + }): Window[]; - function getBackgroundPage(): object/*Window*/; + function getBackgroundPage(): Window; function isAllowedIncognitoAccess(): Promise; function isAllowedFileSchemeAccess(): Promise; - function setUpdateUrlData(data: string): void; + const setUpdateUrlData: ((data: string) => void) | undefined; /* extension events */ - const onRequest: EventListener<(request: any, sender: runtime.MessageSender, sendResponse: () => void) => void> - | EventListener<(sender: runtime.MessageSender, sendResponse: () => void) => void>; + const onRequest: WebExtEventListener<(request: any, sender: runtime.MessageSender, sendResponse: () => void) => void> + | WebExtEventListener<(sender: runtime.MessageSender, sendResponse: () => void) => void> | undefined; - const onRequestExternal: EventListener<(request: any, sender: runtime.MessageSender, sendResponse: () => void) => void> - | EventListener<(sender: runtime.MessageSender, sendResponse: () => void) => void>; + const onRequestExternal: WebExtEventListener<(request: any, sender: runtime.MessageSender, sendResponse: () => void) => void> + | WebExtEventListener<(sender: runtime.MessageSender, sendResponse: () => void) => void> | undefined; } declare namespace browser.extensionTypes { @@ -993,25 +942,25 @@ declare namespace browser.identity { } /* identity functions */ - function getAccounts(): Promise; + const getAccounts: (() => Promise) | undefined; - function getAuthToken(details?: { + const getAuthToken: ((details?: { interactive?: boolean; account?: AccountInfo; scopes?: string[]; - }): Promise; + }) => Promise) | undefined; - function getProfileUserInfo(): Promise<{ + const getProfileUserInfo: (() => Promise<{ email: string; id: string; - }>; + }>) | undefined; - function removeCachedAuthToken(details: { + const removeCachedAuthToken: ((details: { token: string; - }): Promise<{ + }) => Promise<{ email: string; id: string; - }>; + }>) | undefined; function launchWebAuthFlow(details: { url: string; @@ -1021,7 +970,7 @@ declare namespace browser.identity { function getRedirectURL(path?: string): string; /* identity events */ - const onSignInChanged: EventListener<(account: AccountInfo, signedIn: boolean) => void>; + const onSignInChanged: WebExtEventListener<(account: AccountInfo, signedIn: boolean) => void> | undefined; } declare namespace browser.idle { @@ -1037,7 +986,7 @@ declare namespace browser.idle { function setDetectionInterval(intervalInSeconds: number): void; /* idle events */ - const onStateChanged: EventListener<(newState: IdleState) => void>; + const onStateChanged: WebExtEventListener<(newState: IdleState) => void>; } declare namespace browser.management { @@ -1087,7 +1036,7 @@ declare namespace browser.management { /* management functions */ function getAll(): Promise; - function get(id: manifest.ExtensionID): Promise; + function get(id: _manifest.ExtensionID): Promise; function getSelf(): Promise; @@ -1099,13 +1048,13 @@ declare namespace browser.management { function setEnabled(id: string, enabled: boolean): Promise; /* management events */ - const onDisabled: EventListener<(info: ExtensionInfo) => void>; + const onDisabled: WebExtEventListener<(info: ExtensionInfo) => void>; - const onEnabled: EventListener<(info: ExtensionInfo) => void>; + const onEnabled: WebExtEventListener<(info: ExtensionInfo) => void>; - const onInstalled: EventListener<(info: ExtensionInfo) => void>; + const onInstalled: WebExtEventListener<(info: ExtensionInfo) => void>; - const onUninstalled: EventListener<(info: ExtensionInfo) => void>; + const onUninstalled: WebExtEventListener<(info: ExtensionInfo) => void>; } declare namespace browser.notifications { @@ -1169,38 +1118,38 @@ declare namespace browser.notifications { function create(options: CreateNotificationOptions): Promise; function create(notificationId: string, options: CreateNotificationOptions): Promise; - function update(notificationId: string, options: UpdateNotificationOptions): Promise; + const update: ((notificationId: string, options: UpdateNotificationOptions) => Promise) | undefined; function clear(notificationId: string): Promise; function getAll(): Promise; - function getPermissionLevel(): Promise; + const getPermissionLevel: (() => Promise) | undefined; /* notifications events */ - const onClosed: EventListener<(notificationId: string, byUser: boolean) => void>; + const onClosed: WebExtEventListener<(notificationId: string, byUser: boolean) => void>; - const onClicked: EventListener<(notificationId: string) => void>; + const onClicked: WebExtEventListener<(notificationId: string) => void>; - const onButtonClicked: EventListener<(notificationId: string, buttonIndex: number) => void>; + const onButtonClicked: WebExtEventListener<(notificationId: string, buttonIndex: number) => void>; - const onPermissionLevelChanged: EventListener<(level: PermissionLevel) => void>; + const onPermissionLevelChanged: WebExtEventListener<(level: PermissionLevel) => void> | undefined; - const onShowSettings: EventListener<() => void>; + const onShowSettings: WebExtEventListener<() => void> | undefined; - const onShown: EventListener<(notificationId: string) => void>; + const onShown: WebExtEventListener<(notificationId: string) => void>; } declare namespace browser.permissions { /* permissions types */ interface Permissions { - permissions?: manifest.OptionalPermission[]; - origins?: manifest.MatchPattern[]; + permissions?: _manifest.OptionalPermission[]; + origins?: _manifest.MatchPattern[]; } interface AnyPermissions { - permissions?: manifest.Permission[]; - origins?: manifest.MatchPatternInternal[]; + permissions?: _manifest.Permission[]; + origins?: _manifest.MatchPatternInternal[]; } /* permissions functions */ @@ -1213,9 +1162,9 @@ declare namespace browser.permissions { function remove(permissions: Permissions): Promise; /* permissions events */ - const onAdded: EventListener<(permissions: Permissions) => void>; + const onAdded: WebExtEventListener<(permissions: Permissions) => void> | undefined; - const onRemoved: EventListener<(permissions: Permissions) => void>; + const onRemoved: WebExtEventListener<(permissions: Permissions) => void> | undefined; } declare namespace browser.privacy { @@ -1252,7 +1201,7 @@ declare namespace browser.privacy.websites { } /* privacy.websites properties */ - const thirdPartyCookiesAllowed: types.Setting; + const thirdPartyCookiesAllowed: types.Setting | undefined; const hyperlinkAuditingEnabled: types.Setting; @@ -1262,7 +1211,7 @@ declare namespace browser.privacy.websites { const firstPartyIsolate: types.Setting; - const protectedContentEnabled: types.Setting; + const protectedContentEnabled: types.Setting | undefined; const trackingProtectionMode: types.Setting; } @@ -1276,7 +1225,7 @@ declare namespace browser.proxy { function registerProxyScript(url: string): void; /* proxy events */ - const onProxyError: EventListener<(error: object) => void>; + const onProxyError: WebExtEventListener<(error: object) => void>; } declare namespace browser.runtime { @@ -1316,7 +1265,7 @@ declare namespace browser.runtime { interface PlatformInfo { os: PlatformOs; arch: PlatformArch; - nacl_arch: PlatformNaclArch; + nacl_arch?: PlatformNaclArch; } interface BrowserInfo { @@ -1354,11 +1303,11 @@ declare namespace browser.runtime { const id: string; /* runtime functions */ - function getBackgroundPage(): Promise; + function getBackgroundPage(): Promise; function openOptionsPage(): Promise; - function getManifest(): object; + function getManifest(): _manifest.WebExtensionManifest; function getURL(path: string): string; @@ -1366,9 +1315,9 @@ declare namespace browser.runtime { function reload(): void; - function requestUpdateCheck(): Promise; + const requestUpdateCheck: (() => Promise) | undefined; - function restart(): void; + const restart: (() => void) | undefined; function connect(connectInfo?: { name?: string; @@ -1396,39 +1345,39 @@ declare namespace browser.runtime { function getPlatformInfo(): Promise; - function getPackageDirectoryEntry(): Promise; + const getPackageDirectoryEntry: (() => Promise) | undefined; /* runtime events */ - const onStartup: EventListener<() => void>; + const onStartup: WebExtEventListener<() => void>; - const onInstalled: EventListener<(details: { + const onInstalled: WebExtEventListener<(details: { reason: OnInstalledReason; previousVersion?: string; temporary: boolean; id?: string; }) => void>; - const onSuspend: EventListener<() => void>; + const onSuspend: WebExtEventListener<() => void> | undefined; - const onSuspendCanceled: EventListener<() => void>; + const onSuspendCanceled: WebExtEventListener<() => void> | undefined; - const onUpdateAvailable: EventListener<(details: { + const onUpdateAvailable: WebExtEventListener<(details: { version: string; }) => void>; - const onBrowserUpdateAvailable: EventListener<() => void>; + const onBrowserUpdateAvailable: WebExtEventListener<() => void> | undefined; - const onConnect: EventListener<(port: Port) => void>; + const onConnect: WebExtEventListener<(port: Port) => void>; - const onConnectExternal: EventListener<(port: Port) => void>; + const onConnectExternal: WebExtEventListener<(port: Port) => void>; - const onMessage: EventListener<(message: any, sender: MessageSender, sendResponse: () => void) => boolean> - | EventListener<(sender: MessageSender, sendResponse: () => void) => boolean>; + const onMessage: WebExtEventListener<(message: any, sender: MessageSender, sendResponse: () => void) => boolean> + | WebExtEventListener<(sender: MessageSender, sendResponse: () => void) => boolean>; - const onMessageExternal: EventListener<(message: any, sender: MessageSender, sendResponse: () => void) => boolean> - | EventListener<(sender: MessageSender, sendResponse: () => void) => boolean>; + const onMessageExternal: WebExtEventListener<(message: any, sender: MessageSender, sendResponse: () => void) => boolean> + | WebExtEventListener<(sender: MessageSender, sendResponse: () => void) => boolean>; - const onRestartRequired: EventListener<(reason: OnRestartRequiredReason) => void>; + const onRestartRequired: WebExtEventListener<(reason: OnRestartRequiredReason) => void> | undefined; } declare namespace browser.storage { @@ -1441,7 +1390,7 @@ declare namespace browser.storage { class StorageArea { get(keys?: string | string[] | object): Promise; - getBytesInUse(keys?: string | string[]): Promise; + getBytesInUse?(keys?: string | string[]): Promise; set(items: any): Promise; @@ -1458,7 +1407,7 @@ declare namespace browser.storage { const managed: StorageArea; /* storage events */ - const onChanged: EventListener<(changes: StorageChange, areaName: string) => void>; + const onChanged: WebExtEventListener<(changes: StorageChange, areaName: string) => void>; } declare namespace browser.theme { @@ -1471,13 +1420,13 @@ declare namespace browser.theme { /* theme functions */ function getCurrent(windowId?: number): void; - function update(details: manifest.ThemeType): void; - function update(windowId: number, details: manifest.ThemeType): void; + function update(details: _manifest.ThemeType): void; + function update(windowId: number, details: _manifest.ThemeType): void; function reset(windowId?: number): void; /* theme events */ - const onUpdated: EventListener<(updateInfo: ThemeUpdateInfo) => void>; + const onUpdated: WebExtEventListener<(updateInfo: ThemeUpdateInfo) => void>; } declare namespace browser.topSites { @@ -1527,7 +1476,7 @@ declare namespace browser.types { scope?: SettingScope; }): Promise; - onChange: EventListener<(details: { + onChange: WebExtEventListener<(details: { value: any; levelOfControl: LevelOfControl; incognitoSpecific?: boolean; @@ -1579,7 +1528,7 @@ declare namespace browser.webNavigation { tabId: number; }): Promise>; /* webNavigation events */ - const onBeforeNavigate: EventListener<(details: { + const onBeforeNavigate: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; parentFrameId: number; timeStamp: number; }) => void>; - const onCommitted: EventListener<(details: { + const onCommitted: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; - transitionType: TransitionType; - transitionQualifiers: TransitionQualifier[]; + transitionType?: TransitionType; + transitionQualifiers?: TransitionQualifier[]; timeStamp: number; }) => void>; - const onDOMContentLoaded: EventListener<(details: { + const onDOMContentLoaded: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; timeStamp: number; }) => void>; - const onCompleted: EventListener<(details: { + const onCompleted: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; timeStamp: number; }) => void>; - const onErrorOccurred: EventListener<(details: { + const onErrorOccurred: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; - error: string; + error?: string; timeStamp: number; }) => void>; - const onCreatedNavigationTarget: EventListener<(details: { + const onCreatedNavigationTarget: WebExtEventListener<(details: { sourceTabId: number; sourceProcessId: number; sourceFrameId: number; @@ -1640,29 +1589,29 @@ declare namespace browser.webNavigation { timeStamp: number; }) => void>; - const onReferenceFragmentUpdated: EventListener<(details: { + const onReferenceFragmentUpdated: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; - transitionType: TransitionType; - transitionQualifiers: TransitionQualifier[]; + transitionType?: TransitionType; + transitionQualifiers?: TransitionQualifier[]; timeStamp: number; }) => void>; - const onTabReplaced: EventListener<(details: { + const onTabReplaced: WebExtEventListener<(details: { replacedTabId: number; tabId: number; timeStamp: number; }) => void>; - const onHistoryStateUpdated: EventListener<(details: { + const onHistoryStateUpdated: WebExtEventListener<(details: { tabId: number; url: string; - processId: number; + processId?: number; frameId: number; - transitionType: TransitionType; - transitionQualifiers: TransitionQualifier[]; + transitionType?: TransitionType; + transitionQualifiers?: TransitionQualifier[]; timeStamp: number; }) => void>; } @@ -1767,7 +1716,7 @@ declare namespace browser.webRequest { function filterResponseData(requestId: string): object/*StreamFilter*/; /* webRequest events */ - const onBeforeRequest: EventListener<(details: { + const onBeforeRequest: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1785,7 +1734,7 @@ declare namespace browser.webRequest { timeStamp: number; }) => BlockingResponse>; - const onBeforeSendHeaders: EventListener<(details: { + const onBeforeSendHeaders: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1799,7 +1748,7 @@ declare namespace browser.webRequest { requestHeaders?: HttpHeaders; }) => BlockingResponse>; - const onSendHeaders: EventListener<(details: { + const onSendHeaders: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1813,7 +1762,7 @@ declare namespace browser.webRequest { requestHeaders?: HttpHeaders; }) => void>; - const onHeadersReceived: EventListener<(details: { + const onHeadersReceived: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1829,7 +1778,7 @@ declare namespace browser.webRequest { statusCode: number; }) => BlockingResponse>; - const onAuthRequired: EventListener<(details: { + const onAuthRequired: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1852,7 +1801,7 @@ declare namespace browser.webRequest { statusCode: number; }) => BlockingResponse>; - const onResponseStarted: EventListener<(details: { + const onResponseStarted: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1870,7 +1819,7 @@ declare namespace browser.webRequest { statusLine: string; }) => void>; - const onBeforeRedirect: EventListener<(details: { + const onBeforeRedirect: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1889,7 +1838,7 @@ declare namespace browser.webRequest { statusLine: string; }) => void>; - const onCompleted: EventListener<(details: { + const onCompleted: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1907,7 +1856,7 @@ declare namespace browser.webRequest { statusLine: string; }) => void>; - const onErrorOccurred: EventListener<(details: { + const onErrorOccurred: WebExtEventListener<(details: { requestId: string; url: string; method: string; @@ -1994,38 +1943,38 @@ declare namespace browser.bookmarks { function removeTree(id: string): Promise; - function _import(): Promise; + const _import: (() => Promise) | undefined; - function _export(): Promise; + const _export: (() => Promise) | undefined; /* bookmarks events */ - const onCreated: EventListener<(id: string, bookmark: BookmarkTreeNode) => void>; + const onCreated: WebExtEventListener<(id: string, bookmark: BookmarkTreeNode) => void>; - const onRemoved: EventListener<(id: string, removeInfo: { + const onRemoved: WebExtEventListener<(id: string, removeInfo: { parentId: string; index: number; node: BookmarkTreeNode; }) => void>; - const onChanged: EventListener<(id: string, changeInfo: { + const onChanged: WebExtEventListener<(id: string, changeInfo: { title: string; url?: string; }) => void>; - const onMoved: EventListener<(id: string, moveInfo: { + const onMoved: WebExtEventListener<(id: string, moveInfo: { parentId: string; index: number; oldParentId: string; oldIndex: number; }) => void>; - const onChildrenReordered: EventListener<(id: string, reorderInfo: { + const onChildrenReordered: WebExtEventListener<(id: string, reorderInfo: { childIds: string[]; - }) => void>; + }) => void> | undefined; - const onImportBegan: EventListener<() => void>; + const onImportBegan: WebExtEventListener<() => void> | undefined; - const onImportEnded: EventListener<() => void>; + const onImportEnded: WebExtEventListener<() => void> | undefined; } declare namespace browser.browserAction { @@ -2088,7 +2037,7 @@ declare namespace browser.browserAction { function openPopup(): void; /* browserAction events */ - const onClicked: EventListener<(tab: tabs.Tab) => void>; + const onClicked: WebExtEventListener<(tab: tabs.Tab) => void>; } declare namespace browser.browsingData { @@ -2126,7 +2075,7 @@ declare namespace browser.browsingData { function remove(options: RemovalOptions, dataToRemove: DataTypeSet): Promise; - function removeAppcache(options: RemovalOptions): Promise; + const removeAppcache: ((options: RemovalOptions) => Promise) | undefined; function removeCache(options: RemovalOptions): Promise; @@ -2134,13 +2083,13 @@ declare namespace browser.browsingData { function removeDownloads(options: RemovalOptions): Promise; - function removeFileSystems(options: RemovalOptions): Promise; + const removeFileSystems: ((options: RemovalOptions) => Promise) | undefined; function removeFormData(options: RemovalOptions): Promise; function removeHistory(options: RemovalOptions): Promise; - function removeIndexedDB(options: RemovalOptions): Promise; + const removeIndexedDB: ((options: RemovalOptions) => Promise) | undefined; function removeLocalStorage(options: RemovalOptions): Promise; @@ -2148,7 +2097,7 @@ declare namespace browser.browsingData { function removePasswords(options: RemovalOptions): Promise; - function removeWebSQL(options: RemovalOptions): Promise; + const removeWebSQL: ((options: RemovalOptions) => Promise) | undefined; } declare namespace browser.commands { @@ -2163,7 +2112,7 @@ declare namespace browser.commands { function getAll(): Promise; /* commands events */ - const onCommand: EventListener<(command: string) => void>; + const onCommand: WebExtEventListener<(command: string) => void>; } declare namespace browser.devtools { @@ -2174,9 +2123,9 @@ declare namespace browser.devtools.inspectedWindow { class Resource { url: string; - getContent(): Promise; + getContent?(): Promise; - setContent(content: string, commit: boolean): Promise; + setContent?(content: string, commit: boolean): Promise; } /* devtools.inspectedWindow properties */ @@ -2196,12 +2145,12 @@ declare namespace browser.devtools.inspectedWindow { preprocessorScript?: string; }): void; - function getResources(): Promise; + const getResources: (() => Promise) | undefined; /* devtools.inspectedWindow events */ - const onResourceAdded: EventListener<(resource: Resource) => void>; + const onResourceAdded: WebExtEventListener<(resource: Resource) => void> | undefined; - const onResourceContentCommitted: EventListener<(resource: Resource, content: string) => void>; + const onResourceContentCommitted: WebExtEventListener<(resource: Resource, content: string) => void> | undefined; } declare namespace browser.devtools.network { @@ -2211,12 +2160,12 @@ declare namespace browser.devtools.network { } /* devtools.network functions */ - function getHAR(): Promise; + const getHAR: (() => Promise) | undefined; /* devtools.network events */ - const onRequestFinished: EventListener<(request: Request) => void>; + const onRequestFinished: WebExtEventListener<(request: Request) => void> | undefined; - const onNavigated: EventListener<(url: string) => void>; + const onNavigated: WebExtEventListener<(url: string) => void>; } declare namespace browser.devtools.panels { @@ -2224,42 +2173,42 @@ declare namespace browser.devtools.panels { class ElementsPanel { createSidebarPane(title: string): Promise; - onSelectionChanged: EventListener<() => void>; + onSelectionChanged: WebExtEventListener<() => void>; } class SourcesPanel { - createSidebarPane(title: string): void; + createSidebarPane?(title: string): void; - onSelectionChanged: EventListener<() => void>; + onSelectionChanged: WebExtEventListener<() => void>; } class ExtensionPanel { - createStatusBarButton(iconPath: string, tooltipText: string, disabled: boolean): Button; + createStatusBarButton?(iconPath: string, tooltipText: string, disabled: boolean): Button; - onSearch: EventListener<(action: string, queryString?: string) => void>; - onShown: EventListener<(window: object/*global*/) => void>; - onHidden: EventListener<() => void>; + onSearch: WebExtEventListener<(action: string, queryString?: string) => void>; + onShown: WebExtEventListener<(window: object/*global*/) => void>; + onHidden: WebExtEventListener<() => void>; } class ExtensionSidebarPane { - setHeight(height: string): void; + setHeight?(height: string): void; setExpression(expression: string, rootTitle?: string): Promise; setObject(jsonObject: string, rootTitle?: string): Promise; - setPage(path: string): void; + setPage?(path: string): void; - onShown: EventListener<(window: object/*global*/) => void>; - onHidden: EventListener<() => void>; + onShown: WebExtEventListener<(window: object/*global*/) => void>; + onHidden: WebExtEventListener<() => void>; } class Button { - update(tooltipText?: string, disabled?: boolean): void; - update(disabled?: boolean): void; - update(iconPath: string, tooltipText: string, disabled?: boolean): void; + update?(tooltipText?: string, disabled?: boolean): void; + update?(disabled?: boolean): void; + update?(iconPath: string, tooltipText: string, disabled?: boolean): void; - onClicked: EventListener<() => void>; + onClicked: WebExtEventListener<() => void>; } /* devtools.panels properties */ @@ -2272,12 +2221,12 @@ declare namespace browser.devtools.panels { /* devtools.panels functions */ function create(title: string, iconPath: string, pagePath: string): Promise; - function setOpenResourceHandler(): Promise; + const setOpenResourceHandler: (() => Promise) | undefined; - function openResource(url: string, lineNumber: number): Promise; + const openResource: ((url: string, lineNumber: number) => Promise) | undefined; /* devtools.panels events */ - const onThemeChanged: EventListener<(themeName: string) => void>; + const onThemeChanged: WebExtEventListener<(themeName: string) => void>; } declare namespace browser.find { @@ -2335,7 +2284,7 @@ declare namespace browser.geckoProfiler { function getSymbols(debugName: string, breakpadId: string): void; /* geckoProfiler events */ - const onRunning: EventListener<(isRunning: boolean) => void>; + const onRunning: WebExtEventListener<(isRunning: boolean) => void>; } declare namespace browser.history { @@ -2402,14 +2351,14 @@ declare namespace browser.history { function deleteAll(): Promise; /* history events */ - const onVisited: EventListener<(result: HistoryItem) => void>; + const onVisited: WebExtEventListener<(result: HistoryItem) => void>; - const onVisitRemoved: EventListener<(removed: { + const onVisitRemoved: WebExtEventListener<(removed: { allHistory: boolean; urls: string[]; }) => void>; - const onTitleChanged: EventListener<(changed: { + const onTitleChanged: WebExtEventListener<(changed: { url: string; title: string; }) => void>; @@ -2433,6 +2382,77 @@ declare namespace browser.contextMenus { page_action = "page_action", tab = "tab" } + + enum ItemType { + normal = "normal", + checkbox = "checkbox", + radio = "radio", + separator = "separator" + } + + interface OnClickData { + menuItemId: number | string; + parentMenuItemId?: number | string; + mediaType?: string; + linkText?: string; + linkUrl?: string; + srcUrl?: string; + pageUrl?: string; + frameUrl?: string; + selectionText?: string; + editable: boolean; + wasChecked?: boolean; + checked?: boolean; + modifiers: _OnClickDataModifiers[]; + } + + enum _OnClickDataModifiers { + Shift = "Shift", + Alt = "Alt", + Command = "Command", + Ctrl = "Ctrl", + MacCtrl = "MacCtrl" + } + + /* contextMenus properties */ + const ACTION_MENU_TOP_LEVEL_LIMIT: number; + + /* contextMenus functions */ + function create(createProperties: { + type?: ItemType; + id?: string; + icons?: { + [key: number]: string; + }; + title?: string; + checked?: boolean; + contexts?: ContextType[]; + onclick?: (info: menusInternal.OnClickData, tab: tabs.Tab) => void; + parentId?: number | string; + documentUrlPatterns?: string[]; + targetUrlPatterns?: string[]; + enabled?: boolean; + command?: string; + }): number | string; + + function update(id: number | string, updateProperties: { + type?: ItemType; + title?: string; + checked?: boolean; + contexts?: ContextType[]; + onclick?: (info: menusInternal.OnClickData, tab: tabs.Tab) => void; + parentId?: number | string; + documentUrlPatterns?: string[]; + targetUrlPatterns?: string[]; + enabled?: boolean; + }): Promise; + + function remove(menuItemId: number | string): Promise; + + function removeAll(): Promise; + + /* contextMenus events */ + const onClicked: WebExtEventListener<(info: OnClickData, tab?: tabs.Tab) => void>; } declare namespace browser.menus { @@ -2524,7 +2544,7 @@ declare namespace browser.menus { function removeAll(): Promise; /* menus events */ - const onClicked: EventListener<(info: OnClickData, tab?: tabs.Tab) => void>; + const onClicked: WebExtEventListener<(info: OnClickData, tab?: tabs.Tab) => void>; } declare namespace browser.menusInternal { @@ -2589,13 +2609,13 @@ declare namespace browser.omnibox { function setDefaultSuggestion(suggestion: DefaultSuggestResult): void; /* omnibox events */ - const onInputStarted: EventListener<() => void>; + const onInputStarted: WebExtEventListener<() => void>; - const onInputChanged: EventListener<(text: string, suggest: (suggestResults: SuggestResult[]) => void) => void>; + const onInputChanged: WebExtEventListener<(text: string, suggest: (suggestResults: SuggestResult[]) => void) => void>; - const onInputEntered: EventListener<(text: string, disposition: OnInputEnteredDisposition) => void>; + const onInputEntered: WebExtEventListener<(text: string, disposition: OnInputEnteredDisposition) => void>; - const onInputCancelled: EventListener<() => void>; + const onInputCancelled: WebExtEventListener<() => void>; } declare namespace browser.pageAction { @@ -2638,7 +2658,7 @@ declare namespace browser.pageAction { function openPopup(): void; /* pageAction events */ - const onClicked: EventListener<(tab: tabs.Tab) => void>; + const onClicked: WebExtEventListener<(tab: tabs.Tab) => void>; } declare namespace browser.pkcs11 { @@ -2680,7 +2700,7 @@ declare namespace browser.sessions { function getRecentlyClosed(filter?: Filter): Promise; - function getDevices(filter?: Filter): Promise; + const getDevices: ((filter?: Filter) => Promise) | undefined; function restore(sessionId?: string): Promise; @@ -2697,7 +2717,7 @@ declare namespace browser.sessions { function removeWindowValue(windowId: number, key: string): void; /* sessions events */ - const onChanged: EventListener<() => void>; + const onChanged: WebExtEventListener<() => void>; } declare namespace browser.sidebarAction { @@ -2718,7 +2738,7 @@ declare namespace browser.sidebarAction { imageData?: ImageDataType | { [key: number]: ImageDataType; }; - path?: string | string; + path?: string; tabId?: number; }): void; @@ -2755,7 +2775,7 @@ declare namespace browser.tabs { index: number; windowId?: number; openerTabId?: number; - selected: boolean; + selected?: boolean; highlighted: boolean; active: boolean; pinned: boolean; @@ -2840,15 +2860,15 @@ declare namespace browser.tabs { frameId?: number; }): runtime.Port; - function sendRequest(tabId: number, request: any, responseCallback?: (response: any) => void): void; + const sendRequest: ((tabId: number, request: any, responseCallback?: (response: any) => void) => void) | undefined; function sendMessage(tabId: number, message: any, options: { frameId?: number; }, responseCallback?: (response: any) => void): void; - function getSelected(windowId?: number): Promise; + const getSelected: ((windowId?: number) => Promise) | undefined; - function getAllInWindow(windowId?: number): Promise; + const getAllInWindow: ((windowId?: number) => Promise) | undefined; function create(createProperties: { windowId?: number; @@ -2883,10 +2903,10 @@ declare namespace browser.tabs { openerTabId?: number; }): Promise; - function highlight(highlightInfo: { + const highlight: ((highlightInfo: { windowId?: number; tabs: number[] | number; - }): Promise; + }) => Promise) | undefined; function update(updateProperties: { url?: string; @@ -2958,9 +2978,9 @@ declare namespace browser.tabs { function saveAsPDF(pageSettings: PageSettings): Promise; /* tabs events */ - const onCreated: EventListener<(tab: Tab) => void>; + const onCreated: WebExtEventListener<(tab: Tab) => void>; - const onUpdated: EventListener<(tabId: number, changeInfo: { + const onUpdated: WebExtEventListener<(tabId: number, changeInfo: { status: string; discarded?: boolean; url?: string; @@ -2970,53 +2990,53 @@ declare namespace browser.tabs { favIconUrl?: string; }, tab: Tab) => void>; - const onMoved: EventListener<(tabId: number, moveInfo: { + const onMoved: WebExtEventListener<(tabId: number, moveInfo: { windowId: number; fromIndex: number; toIndex: number; }) => void>; - const onSelectionChanged: EventListener<(tabId: number, selectInfo: { + const onSelectionChanged: WebExtEventListener<(tabId: number, selectInfo: { windowId: number; - }) => void>; + }) => void> | undefined; - const onActiveChanged: EventListener<(tabId: number, selectInfo: { + const onActiveChanged: WebExtEventListener<(tabId: number, selectInfo: { windowId: number; - }) => void>; + }) => void> | undefined; - const onActivated: EventListener<(activeInfo: { + const onActivated: WebExtEventListener<(activeInfo: { tabId: number; windowId: number; }) => void>; - const onHighlightChanged: EventListener<(selectInfo: { + const onHighlightChanged: WebExtEventListener<(selectInfo: { + windowId: number; + tabIds: number[]; + }) => void> | undefined; + + const onHighlighted: WebExtEventListener<(highlightInfo: { windowId: number; tabIds: number[]; }) => void>; - const onHighlighted: EventListener<(highlightInfo: { - windowId: number; - tabIds: number[]; - }) => void>; - - const onDetached: EventListener<(tabId: number, detachInfo: { + const onDetached: WebExtEventListener<(tabId: number, detachInfo: { oldWindowId: number; oldPosition: number; }) => void>; - const onAttached: EventListener<(tabId: number, attachInfo: { + const onAttached: WebExtEventListener<(tabId: number, attachInfo: { newWindowId: number; newPosition: number; }) => void>; - const onRemoved: EventListener<(tabId: number, removeInfo: { + const onRemoved: WebExtEventListener<(tabId: number, removeInfo: { windowId: number; isWindowClosing: boolean; }) => void>; - const onReplaced: EventListener<(addedTabId: number, removedTabId: number) => void>; + const onReplaced: WebExtEventListener<(addedTabId: number, removedTabId: number) => void>; - const onZoomChange: EventListener<(ZoomChangeInfo: { + const onZoomChange: WebExtEventListener<(ZoomChangeInfo: { tabId: number; oldZoomFactor: number; newZoomFactor: number; @@ -3120,9 +3140,9 @@ declare namespace browser.windows { function remove(windowId: number): Promise; /* windows events */ - const onCreated: EventListener<(window: Window) => void>; + const onCreated: WebExtEventListener<(window: Window) => void>; - const onRemoved: EventListener<(windowId: number) => void>; + const onRemoved: WebExtEventListener<(windowId: number) => void>; - const onFocusChanged: EventListener<(windowId: number) => void>; + const onFocusChanged: WebExtEventListener<(windowId: number) => void>; } diff --git a/types/firefox-webext-browser/tsconfig.json b/types/firefox-webext-browser/tsconfig.json index 316317e305..202f6824d1 100644 --- a/types/firefox-webext-browser/tsconfig.json +++ b/types/firefox-webext-browser/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, From 7a3b17879620bb4785e7711f615993555ecb568c Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 3 Dec 2017 22:39:42 +0100 Subject: [PATCH 372/639] * add README.md * fix close -> closed * add better typing's for mixins and interceptors Signed-off-by: Konrad Mattheis --- types/enigma.js/README.md | 35 +++++++++++++++++++++++++++++ types/enigma.js/index.d.ts | 46 +++++++++++++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 types/enigma.js/README.md diff --git a/types/enigma.js/README.md b/types/enigma.js/README.md new file mode 100644 index 0000000000..bafa016369 --- /dev/null +++ b/types/enigma.js/README.md @@ -0,0 +1,35 @@ +# Installation +> `npm install --save @types/enigma.js` + +# Summary +This package contains type definitions for enigma.js (https://github.com/qlik-oss/enigma.js). + +# Example + +`npm install --save enigma.js` +`npm install --save bluebird` + +```js +import * as enigma from "enigma.js"; +import * as blubird from "bluebird"; + +let qixSchema = require("./node_modules/enigma.js/schemas/12.20.0.json"); + +let enigmaConfig: enigmaJS.IConfig = { + Promise: blubird, + schema: qixSchema, + url: "ws://localhost:4848/" +}; + +let session = enigma.create(enigmaConfig); + +session.on("traffic:sent", data => console.log("sent:", data)); + +session.open() + .then((global: EngineAPI.IGlobal) => { + return global.EngineVersion() + }) + .then((version) => { + console.log(version); + }); +``` diff --git a/types/enigma.js/index.d.ts b/types/enigma.js/index.d.ts index 38fc18da16..f691e69b2b 100644 --- a/types/enigma.js/index.d.ts +++ b/types/enigma.js/index.d.ts @@ -38,7 +38,7 @@ declare namespace enigmaJS { /** * mixin.extend is an object containing methods to extend the generated API with. These method names cannot already exist or enigma.js will throw an error. */ - extend?: [any]; + extend?: any; /** * mixin.override is an object containing methods that overrides existing API methods. @@ -46,7 +46,35 @@ declare namespace enigmaJS { * Be careful when overriding, you may break expected behaviors in other mixins or your application. * base is a reference to the previous mixin method, can be used to invoke the mixin chain before this mixin method. */ - override?: [any]; + override?: any; + } + + interface IResponseInterceptors { + /** + * This method is invoked when a previous interceptor has rejected the promise, use this to handle for example errors before they are sent into mixins. + * @param session refers to the session executing the interceptor. + * @param request is the JSON-RPC request resulting in this error. You may use .retry() to retry sending it to QIX Engine. + * @param error is whatever the previous interceptor rejected with. + */ + onRejected?(session: ISession, request: any, error: any): Promise; + + /** + * This method is invoked when a promise has been successfully resolved, use this to modify the result or reject the promise chain before it is sent to mixins. + * @param session refers to the session executing the interceptor. + * @param request is the JSON-RPC request resulting in this error. You may use .retry() to retry sending it to QIX Engine. + * @param error is whatever the previous interceptor resolved with. + */ + onFulfilled?(session: ISession, request: any, result: any): Promise; + } + + interface IRequestInterceptors { + /** + * This method is invoked when a request is about to be sent to QIX Engine. + * @param session refers to the session executing the interceptor. + * @param request is the JSON-RPC request resulting in this error. You may use .retry() to retry sending it to QIX Engine. + * @returns request the new request + */ + onFulfilled?(session: ISession, request: any, result: any): any; } interface IProtocol { @@ -83,13 +111,19 @@ declare namespace enigmaJS { * See Mixins section for more information how each entry in this array should look like. * Mixins are applied in the array order. */ - mixins?: [any]; + mixins?: IMixin[]; /** - * Interceptors for augmenting responses before they are passed into mixins and end-users. + * Interceptors for augmenting requests before they are sent to QIX Engine. * See Interceptors section for more information how each entry in this array should look like. * Interceptors are applied in the array order. */ - interceptors?: [any]; + requestInterceptors?: IRequestInterceptors[]; + /** + * Interceptors for augmenting responses before they are sent to QIX Engine. + * See Interceptors section for more information how each entry in this array should look like. + * Interceptors are applied in the array order. + */ + responseInterceptors?: IResponseInterceptors[]; /** * An object containing additional JSON-RPC request parameters. * protocol.delta : Set to false to disable the use of the bandwidth-reducing delta protocol. @@ -148,7 +182,7 @@ declare namespace enigmaJS { * @param event - Event that triggers the function * @param func - Called function */ - on(event: "opened" | "close" | "suspended" | "resumed" | string, func: any): void; + on(event: "opened" | "closed" | "suspended" | "resumed" | string, func: any): void; } interface IGeneratedAPI { From 8770bd18c7f66ba10acdbbeeeff1d5db2310c7e0 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 3 Dec 2017 22:41:26 +0100 Subject: [PATCH 373/639] fix README.md Signed-off-by: Konrad Mattheis --- types/enigma.js/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/enigma.js/README.md b/types/enigma.js/README.md index bafa016369..4370bff4cb 100644 --- a/types/enigma.js/README.md +++ b/types/enigma.js/README.md @@ -1,5 +1,5 @@ # Installation -> `npm install --save @types/enigma.js` +`npm install --save @types/enigma.js` # Summary This package contains type definitions for enigma.js (https://github.com/qlik-oss/enigma.js). @@ -7,6 +7,7 @@ This package contains type definitions for enigma.js (https://github.com/qlik-os # Example `npm install --save enigma.js` + `npm install --save bluebird` ```js @@ -27,7 +28,7 @@ session.on("traffic:sent", data => console.log("sent:", data)); session.open() .then((global: EngineAPI.IGlobal) => { - return global.EngineVersion() + return global.EngineVersion(); }) .then((version) => { console.log(version); From 172856509e41b2eb132de4b9bc2186d59df3d3e0 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 3 Dec 2017 23:18:03 +0100 Subject: [PATCH 374/639] fix FieldListObject Definitions rework Bookmark / Field / Dim / Meas.. ListObjects Signed-off-by: Konrad Mattheis --- types/qlik-engineapi/index.d.ts | 49 +++++++++++++++++---------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/types/qlik-engineapi/index.d.ts b/types/qlik-engineapi/index.d.ts index 7347b17bf0..4be38f9bc0 100644 --- a/types/qlik-engineapi/index.d.ts +++ b/types/qlik-engineapi/index.d.ts @@ -9108,8 +9108,7 @@ declare namespace EngineAPI { /** * SelectionListObject width extend GenericObject */ - interface ISelectionListObject extends IGenericObject { - getLayout(): Promise; + interface ISelectionListObject extends IGenericObjectPrototype { } interface IApp { @@ -9171,8 +9170,7 @@ declare namespace EngineAPI { /** * BookmarkListObject width extend GenericObject */ - interface IBookmarkListObject extends IGenericObject { - getLayout(): Promise; + interface IBookmarkListObject extends IGenericObjectPrototype { } interface IApp { @@ -9234,8 +9232,7 @@ declare namespace EngineAPI { /** * IMeassureListObject */ - interface IMeassureListObject extends IGenericObject { - getLayout(): Promise; + interface IMeassureListObject extends IGenericObjectPrototype { } interface IApp { @@ -9302,8 +9299,7 @@ declare namespace EngineAPI { qData: any; } - interface IDimensionListObject extends IGenericObject { - getLayout(): Promise; + interface IDimensionListObject extends IGenericObjectPrototype { } interface IApp { @@ -9380,15 +9376,15 @@ declare namespace EngineAPI { /** * VariableListObject... */ - interface IVariableListObject { + interface IVariableList { qItems: INxVariableListItem[]; } /** * GenericVariableLayout width extend GenericObjectLayout */ - interface IGenericVariableLayout extends IGenericObjectLayout { - qVariableListObject: IVariableListObject; + interface IGenericVariableListLayout extends IGenericBaseLayout { + qVariableListObject: IVariableList; } /** @@ -9426,8 +9422,7 @@ declare namespace EngineAPI { /** * VariableListObject width extend GenericObject */ - interface IVariableListObject extends IGenericObject { - getLayout(): Promise; + interface IVariableListObject extends IGenericObjectPrototype { } interface IApp { @@ -9442,23 +9437,13 @@ declare namespace EngineAPI { /** * FieldListObject... */ - interface IFieldListObject { + interface IFieldList { /** * NxFieldDescription[] */ qItems: INxFieldDescription[]; } - /** - * GenericFieldLayout width extend GenericObjectLayout - */ - interface IGenericFieldLayout extends IGenericObjectLayout { - /** - * FieldListObject... - */ - qFieldListObject: IFieldListObject; - } - /** * GenericFieldListProperties width extend GenericProperties */ @@ -9673,6 +9658,22 @@ declare namespace EngineAPI { qShowImplicit?: boolean; } + /** + * GenericFieldLayout width extend GenericObjectLayout + */ + interface IGenericFieldLayout extends IGenericBaseLayout { + /** + * FieldListObject... + */ + qFieldListObject: IFieldList; + } + + /** + * FieldListObject width extend GenericObject + */ + interface IFieldListObject extends IGenericObjectPrototype { + } + interface IApp { createObject(qProp: IGenericFieldListProperties): Promise; createSessionObject(qProp: IGenericFieldListProperties): Promise; From cd3935c6727d24a76680d0a263fcf982ec56d750 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 10:58:29 +0900 Subject: [PATCH 375/639] Delete unnecessary rule invalidation setting --- types/chokidar/tslint.json | 73 +------------------------------------- 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/types/chokidar/tslint.json b/types/chokidar/tslint.json index a41bf5d19a..705b12b2c0 100644 --- a/types/chokidar/tslint.json +++ b/types/chokidar/tslint.json @@ -1,79 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "no-trailing-whitespace": false } } From f1be10968fc8eb06d31e339f5c95a758b7b2afee Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:00:51 +0900 Subject: [PATCH 376/639] cleanup lint errors: no-padding, no-trailing-whitespace --- types/chokidar/index.d.ts | 5 +---- types/chokidar/tslint.json | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/types/chokidar/index.d.ts b/types/chokidar/index.d.ts index 229ffb556f..89104d6eb4 100644 --- a/types/chokidar/index.d.ts +++ b/types/chokidar/index.d.ts @@ -19,7 +19,6 @@ export interface WatchedPaths { } export class FSWatcher extends EventEmitter implements fs.FSWatcher { - /** * Constructs a new FSWatcher instance with optional WatchOptions parameter. */ @@ -52,7 +51,6 @@ export class FSWatcher extends EventEmitter implements fs.FSWatcher { } export interface WatchOptions { - /** * Indicates whether the process should continue to run as long as files are being watched. If * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`, @@ -86,7 +84,7 @@ export interface WatchOptions { * be relative to this. */ cwd?: string; - + /** * If set to true then the strings passed to .watch() and .add() are treated as literal path * names, even if they look like globs. Default: false. @@ -155,7 +153,6 @@ export interface WatchOptions { } export interface AwaitWriteFinishOptions { - /** * Amount of time in milliseconds for a file size to remain constant before emitting its event. */ diff --git a/types/chokidar/tslint.json b/types/chokidar/tslint.json index 705b12b2c0..65c83fb1e3 100644 --- a/types/chokidar/tslint.json +++ b/types/chokidar/tslint.json @@ -1,8 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false, - "no-padding": false, - "no-trailing-whitespace": false + "dt-header": false } } From 672a8926e1c3afb8f26c985a2692617e392fdcd9 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:01:50 +0900 Subject: [PATCH 377/639] cleanup lint error: dt-header --- types/chokidar/index.d.ts | 2 +- types/chokidar/tslint.json | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/types/chokidar/index.d.ts b/types/chokidar/index.d.ts index 89104d6eb4..396ad10e0a 100644 --- a/types/chokidar/index.d.ts +++ b/types/chokidar/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for chokidar 1.7.1 +// Type definitions for chokidar 1.7 // Project: https://github.com/paulmillr/chokidar // Definitions by: Stefan Steinhart // Felix Becker diff --git a/types/chokidar/tslint.json b/types/chokidar/tslint.json index 65c83fb1e3..3db14f85ea 100644 --- a/types/chokidar/tslint.json +++ b/types/chokidar/tslint.json @@ -1,6 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "dt-header": false - } -} +{ "extends": "dtslint/dt.json" } From b53f9eac8effb22d82379dbdfe517291fd155c02 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Thanh Date: Mon, 4 Dec 2017 09:04:41 +0700 Subject: [PATCH 378/639] Change dataOrRange to optional param --- types/fullcalendar/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fullcalendar/index.d.ts b/types/fullcalendar/index.d.ts index 4b0f600c6a..3d5ff28f12 100644 --- a/types/fullcalendar/index.d.ts +++ b/types/fullcalendar/index.d.ts @@ -995,7 +995,7 @@ declare global { /** * Immediately switches to a different view. */ - fullCalendar(method: 'changeView', viewName: string, dateOrRange: moment.Moment | Date | string | TimeRange): void; + fullCalendar(method: 'changeView', viewName: string, dateOrRange?: moment.Moment | Date | string | TimeRange): void; /** * Moves the calendar one step back (either by a month, week, or day). From e228c5d8be9b795d0ba289d0494116527fa5f327 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:16:35 +0900 Subject: [PATCH 379/639] Delete unnecessary rule invalidation setting --- types/glob/tslint.json | 67 +----------------------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/types/glob/tslint.json b/types/glob/tslint.json index a41bf5d19a..23fcb29414 100644 --- a/types/glob/tslint.json +++ b/types/glob/tslint.json @@ -1,79 +1,14 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, "semicolon": false, "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "whitespace": true } } From 2351823fb7506671f7dc3270c8798c69f2e4b95d Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:19:14 +0900 Subject: [PATCH 380/639] cleanup simple format lint errors --- types/glob/glob-tests.ts | 16 ++++++++-------- types/glob/index.d.ts | 2 +- types/glob/tslint.json | 5 +---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/types/glob/glob-tests.ts b/types/glob/glob-tests.ts index dcc72341cc..47b899cf8e 100644 --- a/types/glob/glob-tests.ts +++ b/types/glob/glob-tests.ts @@ -1,22 +1,22 @@ import glob = require("glob"); var Glob = glob.Glob; -(()=> { +(() => { var pattern = "test/a/**/[cg]/../[cg]"; console.log(pattern); - var mg = new Glob(pattern, {mark: true, sync: true}, function (er, matches) { - console.log("matches", matches) + var mg = new Glob(pattern, {mark: true, sync: true}, function(er, matches) { + console.log("matches", matches); }); - console.log("after") + console.log("after"); })(); -(()=> { +(() => { var pattern = "{./*/*,/*,/usr/local/*}"; console.log(pattern); - var mg = new Glob(pattern, {mark: true}, function (er, matches) { - console.log("matches", matches) + var mg = new Glob(pattern, {mark: true}, function(er, matches) { + console.log("matches", matches); }); - console.log("after") + console.log("after"); })(); diff --git a/types/glob/index.d.ts b/types/glob/index.d.ts index c7c6ffc601..0b5c280ed2 100644 --- a/types/glob/index.d.ts +++ b/types/glob/index.d.ts @@ -63,7 +63,7 @@ declare namespace G { } interface IGlobSyncStatic { - new (pattern: string, options?: IOptions): IGlobBase + new (pattern: string, options?: IOptions): IGlobBase; prototype: IGlobBase; } diff --git a/types/glob/tslint.json b/types/glob/tslint.json index 23fcb29414..858b8dce48 100644 --- a/types/glob/tslint.json +++ b/types/glob/tslint.json @@ -6,9 +6,6 @@ "no-reference-import": false, "no-var-keyword": false, "only-arrow-functions": false, - "prefer-const": false, - "semicolon": false, - "space-before-function-paren": false, - "whitespace": true + "prefer-const": false } } From ccb1efa3177f1f6fff4fbd7ceca64faecc26a1c2 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:20:28 +0900 Subject: [PATCH 381/639] cleanup ignore lint error: dt-header --- types/glob/index.d.ts | 2 +- types/glob/tslint.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/glob/index.d.ts b/types/glob/index.d.ts index 0b5c280ed2..c78ccc3d6a 100644 --- a/types/glob/index.d.ts +++ b/types/glob/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Glob 5.0.10 +// Type definitions for Glob 5.0 // Project: https://github.com/isaacs/node-glob // Definitions by: vvakame // voy diff --git a/types/glob/tslint.json b/types/glob/tslint.json index 858b8dce48..7220242756 100644 --- a/types/glob/tslint.json +++ b/types/glob/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false, "interface-name": false, "no-reference-import": false, "no-var-keyword": false, From 4013fc4aa86c7d2b462b5f719fafc3bce5aa830d Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:23:35 +0900 Subject: [PATCH 382/639] cleanup ignore lint errors: no-var-keyword, prefer-const --- types/glob/glob-tests.ts | 10 +++++----- types/glob/index.d.ts | 4 ++-- types/glob/tslint.json | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/types/glob/glob-tests.ts b/types/glob/glob-tests.ts index 47b899cf8e..a9024e905d 100644 --- a/types/glob/glob-tests.ts +++ b/types/glob/glob-tests.ts @@ -1,21 +1,21 @@ import glob = require("glob"); -var Glob = glob.Glob; +const Glob = glob.Glob; (() => { - var pattern = "test/a/**/[cg]/../[cg]"; + const pattern = "test/a/**/[cg]/../[cg]"; console.log(pattern); - var mg = new Glob(pattern, {mark: true, sync: true}, function(er, matches) { + const mg = new Glob(pattern, {mark: true, sync: true}, function(er, matches) { console.log("matches", matches); }); console.log("after"); })(); (() => { - var pattern = "{./*/*,/*,/usr/local/*}"; + const pattern = "{./*/*,/*,/usr/local/*}"; console.log(pattern); - var mg = new Glob(pattern, {mark: true}, function(er, matches) { + const mg = new Glob(pattern, {mark: true}, function(er, matches) { console.log("matches", matches); }); console.log("after"); diff --git a/types/glob/index.d.ts b/types/glob/index.d.ts index c78ccc3d6a..13e193fc63 100644 --- a/types/glob/index.d.ts +++ b/types/glob/index.d.ts @@ -19,8 +19,8 @@ declare namespace G { function hasMagic(pattern: string, options?: IOptions): boolean; - var Glob: IGlobStatic; - var GlobSync: IGlobSyncStatic; + let Glob: IGlobStatic; + let GlobSync: IGlobSyncStatic; interface IOptions extends minimatch.IOptions { cwd?: string; diff --git a/types/glob/tslint.json b/types/glob/tslint.json index 7220242756..12936d1b7b 100644 --- a/types/glob/tslint.json +++ b/types/glob/tslint.json @@ -3,8 +3,6 @@ "rules": { "interface-name": false, "no-reference-import": false, - "no-var-keyword": false, - "only-arrow-functions": false, - "prefer-const": false + "only-arrow-functions": false } } From 7fcf093770b0ce4af00582885d327550eaa294a6 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:32:21 +0900 Subject: [PATCH 383/639] cleanup ignore lint error: only-arrow-functions --- types/glob/glob-tests.ts | 12 ++++++++++-- types/glob/tslint.json | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/types/glob/glob-tests.ts b/types/glob/glob-tests.ts index a9024e905d..e0f612e682 100644 --- a/types/glob/glob-tests.ts +++ b/types/glob/glob-tests.ts @@ -5,7 +5,11 @@ const Glob = glob.Glob; const pattern = "test/a/**/[cg]/../[cg]"; console.log(pattern); - const mg = new Glob(pattern, {mark: true, sync: true}, function(er, matches) { + const mg = new Glob(pattern, {mark: true, sync: true}, (er, matches) => { + if (er) { + console.error(er); + return; + } console.log("matches", matches); }); console.log("after"); @@ -15,7 +19,11 @@ const Glob = glob.Glob; const pattern = "{./*/*,/*,/usr/local/*}"; console.log(pattern); - const mg = new Glob(pattern, {mark: true}, function(er, matches) { + const mg = new Glob(pattern, {mark: true}, (er, matches) => { + if (er) { + console.error(er); + return; + } console.log("matches", matches); }); console.log("after"); diff --git a/types/glob/tslint.json b/types/glob/tslint.json index 12936d1b7b..800a90e6b3 100644 --- a/types/glob/tslint.json +++ b/types/glob/tslint.json @@ -2,7 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "interface-name": false, - "no-reference-import": false, - "only-arrow-functions": false + "no-reference-import": false } } From bd61f9b61ba324581d9f40029819199ae3a084f9 Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 4 Dec 2017 11:51:42 +0900 Subject: [PATCH 384/639] cleanup lint error: no-reference-import --- types/glob/index.d.ts | 1 - types/glob/tslint.json | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/types/glob/index.d.ts b/types/glob/index.d.ts index 13e193fc63..f7628d5ab7 100644 --- a/types/glob/index.d.ts +++ b/types/glob/index.d.ts @@ -5,7 +5,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import events = require("events"); import fs = require('fs'); diff --git a/types/glob/tslint.json b/types/glob/tslint.json index 800a90e6b3..2c7c1bed53 100644 --- a/types/glob/tslint.json +++ b/types/glob/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "interface-name": false, - "no-reference-import": false + "interface-name": false } } From ab9c33b354be358cbc15e5e63ad896a3a38afa69 Mon Sep 17 00:00:00 2001 From: Tim Shnaider Date: Mon, 4 Dec 2017 17:32:04 +1300 Subject: [PATCH 385/639] Add 'liveQueryServerURL' option --- types/parse/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 3ad8e6c15d..5b4ff9a0bf 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -17,6 +17,7 @@ declare namespace Parse { let javaScriptKey: string | undefined; let masterKey: string | undefined; let serverURL: string; + let liveQueryServerURL: string; let VERSION: string; interface SuccessOption { From 3628b8552d87631d708a75a156560a899d04b03a Mon Sep 17 00:00:00 2001 From: Polina Date: Mon, 4 Dec 2017 12:34:12 +0700 Subject: [PATCH 386/639] Update index.d.ts of Draft.js typings ContentState.CreateFromBlockArray() should have its second parameter as optional --- types/draft-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index 3eaa05aa30..8a9924f596 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -746,7 +746,7 @@ declare namespace Draft { } class ContentState extends Record { - static createFromBlockArray(blocks: Array, entityMap: any): ContentState; + static createFromBlockArray(blocks: Array, entityMap?: any): ContentState; static createFromText(text: string, delimiter?: string): ContentState; createEntity(type: DraftEntityType, mutability: DraftEntityMutability, data?: Object): ContentState; From 96a344dd423111c9db0fe028cf57cb6a2ec9855b Mon Sep 17 00:00:00 2001 From: Li Yin Date: Mon, 4 Dec 2017 14:00:55 +0800 Subject: [PATCH 387/639] min, max can be string '-inf', '+inf', or '(number', as described in https://redis.io/commands/zrangebyscore --- types/ioredis/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index ec1dbe3512..a0f1c06dcb 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -195,8 +195,8 @@ declare namespace IORedis { zrem(key: string, member: string, ...members: any[]): any; - zremrangebyscore(key: string, min: number, max: number, callback: (err: Error, res: any) => void): void; - zremrangebyscore(key: string, min: number, max: number): Promise; + zremrangebyscore(key: string, min: number | string, max: number | string, callback: (err: Error, res: any) => void): void; + zremrangebyscore(key: string, min: number | string, max: number | string): Promise; zremrangebyrank(key: string, start: number, stop: number, callback: (err: Error, res: any) => void): void; zremrangebyrank(key: string, start: number, stop: number): Promise; @@ -213,12 +213,12 @@ declare namespace IORedis { zrevrange(key: string, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; zrevrange(key: string, start: number, stop: number, withScores?: "WITHSCORES"): Promise; - zrangebyscore(key: string, min: number, max: number, ...args: string[]): any; + zrangebyscore(key: string, min: number | string, max: number | string, ...args: string[]): any; - zrevrangebyscore(key: string, max: number, min: number, ...args: string[]): any; + zrevrangebyscore(key: string, max: number | string, min: number | string, ...args: string[]): any; - zcount(key: string, min: number, max: number, callback: (err: Error, res: number) => void): void; - zcount(key: string, min: number, max: number): Promise; + zcount(key: string, min: number | string, max: number | string, callback: (err: Error, res: number) => void): void; + zcount(key: string, min: number | string, max: number | string): Promise; zcard(key: string, callback: (err: Error, res: number) => void): void; zcard(key: string): Promise; @@ -554,7 +554,7 @@ declare namespace IORedis { zrem(key: string, member: string, ...members: any[]): Pipeline; - zremrangebyscore(key: string, min: number, max: number, callback?: (err: Error, res: any) => void): Pipeline; + zremrangebyscore(key: string, min: number | string, max: number | string, callback?: (err: Error, res: any) => void): Pipeline; zremrangebyrank(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; @@ -568,11 +568,11 @@ declare namespace IORedis { zrevrange(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; zrevrange(key: string, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; - zrangebyscore(key: string, min: number, max: number, ...args: string[]): Pipeline; + zrangebyscore(key: string, min: number | string, max: number | string, ...args: string[]): Pipeline; - zrevrangebyscore(key: string, max: number, min: number, ...args: string[]): Pipeline; + zrevrangebyscore(key: string, max: number | string, min: number | string, ...args: string[]): Pipeline; - zcount(key: string, min: number, max: number, callback?: (err: Error, res: number) => void): Pipeline; + zcount(key: string, min: number | string, max: number | string, callback?: (err: Error, res: number) => void): Pipeline; zcard(key: string, callback?: (err: Error, res: number) => void): Pipeline; From dccfda5de44ad0f78a9794457226ace333a0b64e Mon Sep 17 00:00:00 2001 From: Ari Aviran Date: Mon, 4 Dec 2017 12:02:43 +0200 Subject: [PATCH 388/639] [node] Add Buffer.alloc methods to node v4 Add `Buffer.alloc`, `Buffer.allocUnsafe` and `Buffer.allocUnsafeSlow` class methods that were backported to node v4 (starting with v4.5). In addition add tests to all node versions for these class methods and fix tslint configuration to pass the tests --- types/node/index.d.ts | 2 +- types/node/node-tests.ts | 14 ++++++++++++++ types/node/tslint.json | 3 ++- types/node/v4/index.d.ts | 25 ++++++++++++++++++++++++- types/node/v4/node-tests.ts | 15 +++++++++++++++ types/node/v4/tslint.json | 1 + types/node/v6/node-tests.ts | 14 ++++++++++++++ types/node/v6/tslint.json | 1 + types/node/v7/node-tests.ts | 14 ++++++++++++++ types/node/v7/tslint.json | 1 + 10 files changed, 87 insertions(+), 3 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 61fd375e6f..c90e7b7116 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -104,8 +104,8 @@ declare namespace setImmediate { declare function clearImmediate(immediateId: any): void; // TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version. -/* tslint:disable:callable-types */ interface NodeRequireFunction { + /* tslint:disable-next-line:callable-types */ (id: string): any; } diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index d85a2574db..1413b88629 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -405,6 +405,20 @@ function bufferTests() { const buf1: Buffer = Buffer.from('this is a tést'); const buf2: Buffer = Buffer.from('7468697320697320612074c3a97374', 'hex'); } + // Class Method: Buffer.alloc(size[, fill[, encoding]]) + { + const buf1: Buffer = Buffer.alloc(5); + const buf2: Buffer = Buffer.alloc(5, 'a'); + const buf3: Buffer = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); + } + // Class Method: Buffer.allocUnsafe(size) + { + const buf: Buffer = Buffer.allocUnsafe(5); + } + // Class Method: Buffer.allocUnsafeSlow(size) + { + const buf: Buffer = Buffer.allocUnsafeSlow(10); + } // Class Method byteLenght { diff --git a/types/node/tslint.json b/types/node/tslint.json index 45064d266f..a153c4f63f 100644 --- a/types/node/tslint.json +++ b/types/node/tslint.json @@ -21,6 +21,7 @@ "prefer-const": false, "prefer-method-signature": false, "strict-export-declare-modifiers": false, - "unified-signatures": false + "unified-signatures": false, + "void-return": false } } diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 797bc455b8..5658d4e05e 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Node.js 4.2 +// Type definitions for Node.js 4.x // Project: http://nodejs.org/ // Definitions by: Microsoft TypeScript // DefinitelyTyped @@ -214,6 +214,29 @@ declare var Buffer: { * The same as buf1.compare(buf2). */ compare(buf1: Buffer, buf2: Buffer): number; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + * @param fill if specified, buffer will be initialized by calling buf.fill(fill). + * If parameter is omitted, buffer will be filled with zeros. + * @param encoding encoding used for call to buf.fill while initalizing + */ + alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + allocUnsafe(size: number): Buffer; + /** + * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + allocUnsafeSlow(size: number): Buffer; }; /************************************************ diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 8f005da455..0c5d378d9e 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -268,6 +268,21 @@ function bufferTests() { const buf1: Buffer = Buffer.from('this is a tést'); const buf2: Buffer = Buffer.from('7468697320697320612074c3a97374', 'hex'); } + // Class Method: Buffer.alloc(size[, fill[, encoding]]) + { + const buf1: Buffer = Buffer.alloc(5); + const buf2: Buffer = Buffer.alloc(5, 'a'); + const buf3: Buffer = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); + + } + // Class Method: Buffer.allocUnsafe(size) + { + const buf: Buffer = Buffer.allocUnsafe(5); + } + // Class Method: Buffer.allocUnsafeSlow(size) + { + const buf: Buffer = Buffer.allocUnsafeSlow(10); + } // Test that TS 1.6 works with the 'as Buffer' annotation // on isBuffer. diff --git a/types/node/v4/tslint.json b/types/node/v4/tslint.json index 518f58df03..542ee38c59 100644 --- a/types/node/v4/tslint.json +++ b/types/node/v4/tslint.json @@ -40,6 +40,7 @@ "strict-export-declare-modifiers": false, "typedef-whitespace": false, "unified-signatures": false, + "void-return": false, "whitespace": false } } diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 1a6b87db05..c7521d3d82 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -330,6 +330,20 @@ function bufferTests() { const buf1: Buffer = Buffer.from('this is a tést'); const buf2: Buffer = Buffer.from('7468697320697320612074c3a97374', 'hex'); } + // Class Method: Buffer.alloc(size[, fill[, encoding]]) + { + const buf1: Buffer = Buffer.alloc(5); + const buf2: Buffer = Buffer.alloc(5, 'a'); + const buf3: Buffer = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); + } + // Class Method: Buffer.allocUnsafe(size) + { + const buf: Buffer = Buffer.allocUnsafe(5); + } + // Class Method: Buffer.allocUnsafeSlow(size) + { + const buf: Buffer = Buffer.allocUnsafeSlow(10); + } // Test that TS 1.6 works with the 'as Buffer' annotation // on isBuffer. diff --git a/types/node/v6/tslint.json b/types/node/v6/tslint.json index 518f58df03..542ee38c59 100644 --- a/types/node/v6/tslint.json +++ b/types/node/v6/tslint.json @@ -40,6 +40,7 @@ "strict-export-declare-modifiers": false, "typedef-whitespace": false, "unified-signatures": false, + "void-return": false, "whitespace": false } } diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index 9bbf6a9300..2c33f9019d 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -319,6 +319,20 @@ function bufferTests() { buf = Buffer.from(arr.buffer, 1); buf = Buffer.from(arr.buffer, 0, 1); } + // Class Method: Buffer.alloc(size[, fill[, encoding]]) + { + const buf1: Buffer = Buffer.alloc(5); + const buf2: Buffer = Buffer.alloc(5, 'a'); + const buf3: Buffer = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); + } + // Class Method: Buffer.allocUnsafe(size) + { + const buf: Buffer = Buffer.allocUnsafe(5); + } + // Class Method: Buffer.allocUnsafeSlow(size) + { + const buf: Buffer = Buffer.allocUnsafeSlow(10); + } // Class Method: Buffer.from(buffer) { diff --git a/types/node/v7/tslint.json b/types/node/v7/tslint.json index 518f58df03..542ee38c59 100644 --- a/types/node/v7/tslint.json +++ b/types/node/v7/tslint.json @@ -40,6 +40,7 @@ "strict-export-declare-modifiers": false, "typedef-whitespace": false, "unified-signatures": false, + "void-return": false, "whitespace": false } } From 886c0a0b655a549864a3374a6fcd57f0c55ac13f Mon Sep 17 00:00:00 2001 From: daphnes Date: Mon, 4 Dec 2017 12:26:48 +0100 Subject: [PATCH 389/639] Remove tabbing --- types/elasticsearch/index.d.ts | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index 8ab269768d..dbf836c6ae 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -620,30 +620,30 @@ export interface SearchParams extends GenericParams { type?: NameList; } - export interface SearchResponse { - took: number; - timed_out: boolean; - _scroll_id?: string; - _shards: ShardsResponse; - hits: { - total: number; - max_score: number; - hits: Array<{ - _index: string; - _type: string; - _id: string; - _score: number; - _source: T; - _version?: number; - _explanation?: Explanation; - fields?: any; - highlight?: any; - inner_hits?: any; - sort?: string[]; - }>; - }; - aggregations?: any; - } +export interface SearchResponse { + took: number; + timed_out: boolean; + _scroll_id?: string; + _shards: ShardsResponse; + hits: { + total: number; + max_score: number; + hits: Array<{ + _index: string; + _type: string; + _id: string; + _score: number; + _source: T; + _version?: number; + _explanation?: Explanation; + fields?: any; + highlight?: any; + inner_hits?: any; + sort?: string[]; + }>; + }; + aggregations?: any; +} export interface SearchShardsParams extends GenericParams { preference?: string; From 42d48d23d88a0505000b232d2f17929dac07a158 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Mon, 4 Dec 2017 12:50:33 +0100 Subject: [PATCH 390/639] update to version 2.67.2 Signed-off-by: Konrad Mattheis --- types/qlik-engineapi/index.d.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/types/qlik-engineapi/index.d.ts b/types/qlik-engineapi/index.d.ts index 4be38f9bc0..0f11f39ae2 100644 --- a/types/qlik-engineapi/index.d.ts +++ b/types/qlik-engineapi/index.d.ts @@ -1,5 +1,5 @@ -// Type definitions for qlik-engineapi 12.34 -// Project: http://help.qlik.com/en-US/sense-developer/September2017/Subsystems/EngineAPI/Content/introducing-engine-API.htm +// Type definitions for qlik-engineapi 12.67 +// Project: http://help.qlik.com/en-US/sense-developer/November2017/Subsystems/EngineAPI/Content/introducing-engine-API.htm // Definitions by: Konrad Mattheis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -2984,6 +2984,13 @@ declare namespace EngineAPI { */ getFieldDescription(qFieldName: string): Promise; + /** + * Fetches the Expression behind a Field that is declared with DECLARE FIELD DEFINITIO + * @param qReadableName: name of a Field that is declared with DECLARE FIELD DEFINITION + * @returns qname wich contains the expression + */ + getFieldOnTheFlyByName(qReadableName: string): Promise<{qName: string}>; + /** * Retrieves the description of a field. * @param qFieldName - Name of the field. >> This parameter is mandatory. @@ -7150,6 +7157,21 @@ declare namespace EngineAPI { */ getBaseBNFHash(qBnfType: BnfType): Promise<{ qBnfHash: string }>; + /** + * Gets the current Backus-Naur Form (BNF) grammar of the Qlik engine scripting language, + * as well as a string hash calculated from that grammar. The BNF rules define the syntax + * for the script statements and the script or chart functions. If the hash changes between + * subsequent calls to this method, this indicates that the BNF has changed. + * + * In the Qlik engine grammars, a token is a string of one or more characters that is significant as a group. + * For example, a token could be a function name, a number, a letter, a parenthesis, and so on. + * @param qBnfType The type of grammar to return: + * S: returns the script statements and the script functions. + * E: returns the chart functions. + * @returns qBnfDefs and qBnfHash + */ + getBaseBNFString(qBnfType: BnfType): Promise<{qBnfDefs: IBNFDef, qBnfHash: string}>; + /** * Get a Config Object * @returns A Promise qConfig From 7baed0ae6efb930b6e55b2efb7a53f2ea6c05b50 Mon Sep 17 00:00:00 2001 From: Nitecube Date: Mon, 4 Dec 2017 21:10:24 +0900 Subject: [PATCH 391/639] jquery.fancytree: add methods for Fancytree. fixes FancytreeOptions and NodeData --- types/jquery.fancytree/index.d.ts | 50 ++++++++++++++++++- .../jquery.fancytree-tests.ts | 36 +++++++++++-- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/types/jquery.fancytree/index.d.ts b/types/jquery.fancytree/index.d.ts index 34d90d9e8f..9c793a2c19 100644 --- a/types/jquery.fancytree/index.d.ts +++ b/types/jquery.fancytree/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/mar10/fancytree // Definitions by: Peter Palotas // Mahdi Abedi +// Nitecube // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -93,6 +94,12 @@ declare namespace Fancytree { */ findNextNode(match: (node: FancytreeNode) => boolean, startNode?: FancytreeNode): FancytreeNode; + /** Find all nodes that matches condition. + * + * @returns array of nodes (may be empty) + */ + findAll(match: string|((node: FancytreeNode) => boolean|undefined)): FancytreeNode[]; + /** Generate INPUT elements that can be submitted with html forms. In selectMode 3 only the topmost selected nodes are considered. */ generateFormElements(selected?: boolean, active?: boolean): void; @@ -283,6 +290,11 @@ declare namespace Fancytree { addChildren(child: Fancytree.NodeData, insertBefore?: number): FancytreeNode; + /** Add class to node's span tag and to .extraClasses. + * @param className class name + */ + addClass(className: string): void; + /** Append or prepend a node, or append a child node. This a convenience function that calls addChildren() * * @param mode 'before', 'after', 'firstChild', or 'child' ('over' is a synonym for 'child') (default='child') @@ -508,6 +520,11 @@ declare namespace Fancytree { */ removeChildren(): void; + /** Remove class from node's span tag and .extraClasses. + * @param className class name + */ + removeClass(className: string): void; + /** This method renders and updates all HTML markup that is required to display this node in its current state. * * @param force re-render, even if html markup was already created @@ -594,6 +611,13 @@ declare namespace Fancytree { */ toDict(recursive?: boolean, callback?: (dict: NodeData) => void): NodeData; + /** Set, clear, or toggle class of node's span tag and .extraClasses. + * @param {string} className class name (separate multiple classes by space) + * @param {boolean} [flag] true/false to add/remove class. If omitted, class is toggled. + * @return true if a class was added + */ + toggleClass(className: string, flag?: boolean): boolean; + /** Flip expanded status. */ toggleExpanded(): void; @@ -747,7 +771,7 @@ declare namespace Fancytree { /** Scroll node into visible area, when focused by keyboard (default: false). */ autoScroll?: boolean; /** Display checkboxes to allow selection (default: false) */ - checkbox?: boolean; + checkbox?: boolean|string|((event: JQueryEventObject, data: EventData) => boolean); /** Defines what happens, when the user click a folder node. (default: activate_dblclick_expands) */ clickFolderMode?: FancytreeClickFolderMode; /** 0..2 (null: use global setting $.ui.fancytree.debugInfo) */ @@ -792,13 +816,20 @@ declare namespace Fancytree { titlesTabbable?: boolean; /** Animation options, false:off (default: { effect: "blind", options: {direction: "vertical", scale: "box"}, duration: 200 }) */ toggleEffect?: JQueryUI.EffectOptions; + + /** (dynamic Option)Prevent (de-)selection using mouse or keyboard. */ + unselectable?: boolean|((event: JQueryEventObject, data: Fancytree.EventData) => boolean|undefined); + /** (dynamic Option)Ignore this node when calculating the partsel status of parent nodes in selectMode 3 propagation. */ + unselectableIgnore?: boolean|((event: JQueryEventObject, data: Fancytree.EventData) => boolean|undefined); + /** (dynamic Option)Use this as constant selected value (overriding selectMode 3 propagation). */ + unselectableStatus?: boolean|((event: JQueryEventObject, data: Fancytree.EventData) => boolean|undefined); } /** Data object passed to FancytreeNode() constructor. Note: typically these attributes are accessed by meber methods, e.g. `node.isExpanded()` and `node.setSelected(false)`. */ interface NodeData { /** node text (may contain HTML tags) */ title: string; - icon?: string; + icon?: boolean|string; /** unique key for this node (auto-generated if omitted) */ key?: string; /** (reserved) */ @@ -820,6 +851,21 @@ declare namespace Fancytree { extraClasses?: string; /** all properties from will be copied to `node.data` */ data?: Object; + + /** Will be added as title attribute of the node's icon span,thus enabling a tooltip. */ + iconTooltip?: string; + + /** If set, make this node a status node. Values: 'error', 'loading', 'nodata', 'paging'. */ + statusNodeType?: string; + + /** Made available as node.type. */ + type?: string; + + /** Ignore this node when calculating the partsel status of parent nodes in selectMode 3 propagation. */ + unselectableIgnore?: boolean; + + /** Use this as constant selected value(overriding selectMode 3 propagation). */ + unselectableStatus?: boolean; } /** Data object similar to NodeData, but with additional options. diff --git a/types/jquery.fancytree/jquery.fancytree-tests.ts b/types/jquery.fancytree/jquery.fancytree-tests.ts index 4fa52c790a..de1489de42 100644 --- a/types/jquery.fancytree/jquery.fancytree-tests.ts +++ b/types/jquery.fancytree/jquery.fancytree-tests.ts @@ -13,7 +13,8 @@ $("#tree").fancytree({ { title: "Folder 2", key: "2", folder: true, children: [ { title: "Node 2.1", key: "3" }, - { title: "Node 2.2", key: "4" } + { title: "Node 2.2", key: "4" }, + { title: "NOde 2.3", key: "5", icon: "./icon.svg", checkbox: "radio"} ] } ] @@ -24,7 +25,7 @@ $("#tree").fancytree({ click: (ev: JQueryEventObject, node: Fancytree.EventData) => { return true; }, - checkbox: true, + checkbox: "radio",//boolean or "radio" expand: () => { console.log("expanded"); }, @@ -38,8 +39,14 @@ $("#tree").fancytree({ if (data.node.isFolder()) { return false; } + }, + unselectable: function (event, data) { + return true; + }, + unselectableIgnore: false, + unselectableStatus: function (event, data) { + return false; } - }); //$("#tree").fancytree(); @@ -91,3 +98,26 @@ alert("We have " + tree.count() + " nodes."); // Use the API node.setTitle("New title"); + +// add/remove/toggle class +activeNode.addClass("test-class"); +activeNode.removeClass("test-class"); +activeNode.toggleClass("test-class"); +activeNode.toggleClass("test-class", true); + +// Fancytree.findAll() +var nodes: Fancytree.FancytreeNode[]; +nodes = tree.findAll((node) => { + return true; +}); +nodes = tree.findAll("Node"); + +node.addChildren({ + title: "New Node", + key: "15", + type: "book", + iconTooltip: "Icon toolip", + statusNodeType: "loading", + unselectableIgnore: true, + unselectableStatus: false, +}, 0); \ No newline at end of file From d251c643c3e8c37dc4554751caf0238b69db5102 Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Fri, 1 Dec 2017 12:52:38 -0800 Subject: [PATCH 392/639] Fix lint error: 'tslint:disable' is forbidden --- types/node/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 61fd375e6f..789e91997f 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -104,8 +104,8 @@ declare namespace setImmediate { declare function clearImmediate(immediateId: any): void; // TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version. -/* tslint:disable:callable-types */ interface NodeRequireFunction { +/* tslint:disable-next-line:callable-types */ (id: string): any; } From 8a3c0175f1955388e818cdab98de8c80cd70a5e3 Mon Sep 17 00:00:00 2001 From: Beeno Tung Date: Tue, 5 Dec 2017 00:22:50 +0800 Subject: [PATCH 393/639] Update index.d.ts added 'buffer' as Encoding type --- types/node-rsa/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node-rsa/index.d.ts b/types/node-rsa/index.d.ts index faafdf7d24..63d569378d 100644 --- a/types/node-rsa/index.d.ts +++ b/types/node-rsa/index.d.ts @@ -122,7 +122,7 @@ declare namespace NodeRSA { type Encoding = | 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'latin1' - | 'base64' | 'hex' | 'binary'; + | 'base64' | 'hex' | 'binary' | 'buffer'; interface KeyComponents { n: Buffer; From ec54184e1bf53c8d3344fe1e3c2ccbe1033b1bd5 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 4 Dec 2017 10:39:31 -0600 Subject: [PATCH 394/639] JSX.Element -> React.ReactNode --- types/react-autosuggest/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index c7f46200d1..444753bd54 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -113,13 +113,13 @@ declare namespace Autosuggest { event: React.FormEvent, data: SuggestionSelectedEventData, ) => void; - type RenderInputComponent = (inputProps: InputProps) => JSX.Element; - type RenderSuggestionsContainer = (params: RenderSuggestionsContainerParams) => JSX.Element; - type RenderSectionTitle = (section: any) => JSX.Element; + type RenderInputComponent = (inputProps: InputProps) => React.ReactNode; + type RenderSuggestionsContainer = (params: RenderSuggestionsContainerParams) => React.ReactNode; + type RenderSectionTitle = (section: any) => React.ReactNode; type RenderSuggestion = ( suggestion: TSuggestion, params: RenderSuggestionParams, - ) => JSX.Element; + ) => React.ReactNode; type ShouldRenderSuggestions = (value: string) => boolean; interface AutosuggestProps { From 06313d255bb108839fe9691a2ebe7f8043bb303d Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Mon, 4 Dec 2017 12:13:45 -0500 Subject: [PATCH 395/639] Improve indexBy type inference --- types/ramda/index.d.ts | 4 ++-- types/ramda/ramda-tests.ts | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 9d1683fbbc..de4a05b28f 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -740,8 +740,8 @@ declare namespace R { * Given a function that generates a key, turns a list of objects into an object indexing the objects * by the given key. */ - indexBy(fn: (a: T) => string, list: T[]): U; - indexBy(fn: (a: T) => string): (list: T[]) => U; + indexBy(fn: (a: T) => string, list: T[]): { [key: string]: T }; + indexBy(fn: (a: T) => string): (list: T[]) => { [key: string]: T }; /** * Returns the position of the first occurrence of an item in an array diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 426bb63471..8e91b12ef2 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -678,10 +678,19 @@ interface Obj { }; (() => { - const list = [{id: "xyz", title: "A"}, {id: "abc", title: "B"}]; - const a1 = R.indexBy(R.prop("id"), list); - const a2 = R.indexBy(R.prop("id"))(list); + interface Book { + id: string; + title: string; + } + const list: Book[] = [{id: "xyz", title: "A"}, {id: "abc", title: "B"}]; + const a1 = R.indexBy(R.prop("id"), list); + const a2 = R.indexBy(R.prop("id"))(list); const a3 = R.indexBy<{ id: string }>(R.prop("id"))(list); + + const titlesIndexedByTitles: { [k: string]: string } = R.pipe( + R.map((x: Book) => x.title), + R.indexBy(x => x), + )(list); }); () => { From 37f75ff18ce995938636cfdc08c51cc5dd0602b7 Mon Sep 17 00:00:00 2001 From: "Demeusy, Valentin" Date: Mon, 4 Dec 2017 18:26:03 +0100 Subject: [PATCH 396/639] enh : cypress : update cy.trigger and cy.log API --- types/cypress/cypress-tests.ts | 5 ++++- types/cypress/index.d.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/types/cypress/cypress-tests.ts b/types/cypress/cypress-tests.ts index 9502f1a63d..be1b3cc959 100644 --- a/types/cypress/cypress-tests.ts +++ b/types/cypress/cypress-tests.ts @@ -10,7 +10,8 @@ cy .get('#querying') .contains('ul', 'oranges').should('have.class', 'query-list') .get('.query-button') - .contains('Save Form').should('have.class', 'btn'); + .contains('Save Form').should('have.class', 'btn') + .trigger('mousemove', {clientX: 100, clientY: 200}); cy.location('host'); @@ -39,3 +40,5 @@ cy .spread((x , y, z) => { x + y + z; }); + +cy.log('end'); diff --git a/types/cypress/index.d.ts b/types/cypress/index.d.ts index 1ffb365418..6cbc65f819 100644 --- a/types/cypress/index.d.ts +++ b/types/cypress/index.d.ts @@ -255,7 +255,7 @@ declare namespace Cypress { /** * @see https://on.cypress.io/api/log */ - log(message: string, args: any): Chainable; + log(message: string, args?: any): Chainable; /** * @see https://on.cypress.io/api/next @@ -382,6 +382,7 @@ declare namespace Cypress { * @see https://docs.cypress.io/api/commands/trigger.html */ trigger(eventName: string, position?: PositionType, x?: number, y?: number, options?: TriggerOptions): Chainable; + trigger(eventName: string, eventObject: object): Chainable; /** * @see https://on.cypress.io/api/type From d105bd4c8d8a489690bad0099d1b95d1104379b5 Mon Sep 17 00:00:00 2001 From: John Gozde Date: Mon, 4 Dec 2017 10:27:42 -0700 Subject: [PATCH 397/639] Use ComponentType for React.Fragment --- types/react/index.d.ts | 16 ++++++---------- types/react/test/index.ts | 6 +++--- types/react/test/tsx.tsx | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index e41299fdb5..f9b199cbd5 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -265,7 +265,7 @@ declare namespace React { function isValidElement

(object: {} | null | undefined): object is ReactElement

; const Children: ReactChildren; - const Fragment: symbol | number; + const Fragment: ComponentType; const version: string; // @@ -281,10 +281,8 @@ declare namespace React { constructor(props: P, context?: any); // Disabling unified-signatures to have separate overloads. It's easier to understand this way. - // tslint:disable:unified-signatures - setState(f: (prevState: Readonly, props: P) => Pick, callback?: () => any): void; - setState(state: Pick, callback?: () => any): void; - // tslint:enable:unified-signatures + setState(f: (prevState: Readonly, props: P) => Pick, callback?: () => any): void; // tslint:disable-line:unified-signatures + setState(state: Pick, callback?: () => any): void; // tslint:disable-line:unified-signatures forceUpdate(callBack?: () => any): void; render(): ReactNode; @@ -3519,17 +3517,15 @@ declare namespace React { declare global { namespace JSX { - // tslint:disable:no-empty-interface - interface Element extends React.ReactElement { } + interface Element extends React.ReactElement { } // tslint:disable-line:no-empty-interface interface ElementClass extends React.Component { render(): React.ReactNode; } interface ElementAttributesProperty { props: {}; } interface ElementChildrenAttribute { children: {}; } - interface IntrinsicAttributes extends React.Attributes { } - interface IntrinsicClassAttributes extends React.ClassAttributes { } - // tslint:enable:no-empty-interface + interface IntrinsicAttributes extends React.Attributes { } // tslint:disable-line:no-empty-interface + interface IntrinsicClassAttributes extends React.ClassAttributes { } // tslint:disable-line:no-empty-interface interface IntrinsicElements { // HTML diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 3c49215c8a..e8aabfa35c 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -164,7 +164,7 @@ const statelessElement: React.SFCElement = React.createElement(Stateles const domElement: React.DOMElement, HTMLDivElement> = React.createElement("div"); const htmlElement = React.createElement("input", { type: "text" }); const svgElement = React.createElement("svg", { accentHeight: 12 }); -const fragmentElement: React.ReactElement = React.createElement(React.Fragment, undefined, [React.createElement("div"), React.createElement("div")]); +const fragmentElement: React.ReactElement<{}> = React.createElement(React.Fragment, {}, [React.createElement("div"), React.createElement("div")]); const customProps: React.HTMLProps = props; const customDomElement = "my-element"; @@ -229,7 +229,7 @@ const notValid: boolean = React.isValidElement(props); // false const isValid = React.isValidElement(element); // true let domNode: Element = ReactDOM.findDOMNode(component); domNode = ReactDOM.findDOMNode(domNode); -const fragmentType: symbol | number = React.Fragment; +const fragmentType: React.ComponentType = React.Fragment; // // React Elements @@ -255,7 +255,7 @@ myComponent.reset(); // Refs // -------------------------------------------------------------------------- -// tslint:disable:no-empty-interface +// tslint:disable-next-line:no-empty-interface interface RCProps { } class RefComponent extends React.Component { diff --git a/types/react/test/tsx.tsx b/types/react/test/tsx.tsx index dd91b5a0bd..6322f8f234 100644 --- a/types/react/test/tsx.tsx +++ b/types/react/test/tsx.tsx @@ -63,3 +63,17 @@ const StatelessComponentWithoutProps: React.SFC = (props) => { return

; }; ; + +// Fragments +
+ + + Child 1 + Child 2 + + + Child 3 + Child 4 + + +
; From e04481995185d21b09f4c4570c3dc27dff58ccc0 Mon Sep 17 00:00:00 2001 From: Kelvin Jin Date: Fri, 1 Dec 2017 15:03:59 -0800 Subject: [PATCH 398/639] [shimmer] Add shimmer type definitions --- types/shimmer/index.d.ts | 35 ++++++++++++++++++++++++++++++++++ types/shimmer/shimmer-tests.ts | 23 ++++++++++++++++++++++ types/shimmer/tsconfig.json | 23 ++++++++++++++++++++++ types/shimmer/tslint.json | 1 + 4 files changed, 82 insertions(+) create mode 100644 types/shimmer/index.d.ts create mode 100644 types/shimmer/shimmer-tests.ts create mode 100644 types/shimmer/tsconfig.json create mode 100644 types/shimmer/tslint.json diff --git a/types/shimmer/index.d.ts b/types/shimmer/index.d.ts new file mode 100644 index 0000000000..fd62f8074c --- /dev/null +++ b/types/shimmer/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for Shimmer 1.x +// Project: https://github.com/othiym23/shimmer +// Definitions by: Kelvin Jin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +declare global { + interface Function { + __wrapped?: boolean; + } +} + +declare const shimmer: { + (options: { logger?(msg: string): void }): void; + wrap any>( + nodule: object, + name: string, + wrapper: (original: T) => T + ): void; + massWrap any>( + nodules: object[], + names: string[], + wrapper: (original: T) => T + ): void; + unwrap( + nodule: object, + name: string + ): void; + massUnwrap( + nodules: object[], + names: string[] + ): void; +}; + +export = shimmer; diff --git a/types/shimmer/shimmer-tests.ts b/types/shimmer/shimmer-tests.ts new file mode 100644 index 0000000000..c7b51debe2 --- /dev/null +++ b/types/shimmer/shimmer-tests.ts @@ -0,0 +1,23 @@ +import * as shimmer from 'shimmer'; + +const isWrapped: boolean = [].forEach.__wrapped || false; + +shimmer.wrap(Array.prototype, 'forEach', (forEach) => { + return (...args: any[]) => { + forEach(...args); + }; +}); + +shimmer.unwrap(Array.prototype, 'forEach'); + +shimmer.massWrap([Map.prototype, Set.prototype], ['clear', 'forEach'], (fn) => { + return (...args: any[]) => { + const result = fn(...args); + if (result) { + throw new Error(); + } + return result; + }; +}); + +shimmer.massUnwrap([Map.prototype, Set.prototype], ['clear', 'forEach']); diff --git a/types/shimmer/tsconfig.json b/types/shimmer/tsconfig.json new file mode 100644 index 0000000000..3883d26b91 --- /dev/null +++ b/types/shimmer/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shimmer-tests.ts" + ] +} \ No newline at end of file diff --git a/types/shimmer/tslint.json b/types/shimmer/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shimmer/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5afa32483e299cc02ebb706fca6cddf79134ec1b Mon Sep 17 00:00:00 2001 From: John Gozde Date: Mon, 4 Dec 2017 11:33:33 -0700 Subject: [PATCH 399/639] Prefer disable-next-line --- types/react/index.d.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index f9b199cbd5..a2ea9bdc6c 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -281,8 +281,10 @@ declare namespace React { constructor(props: P, context?: any); // Disabling unified-signatures to have separate overloads. It's easier to understand this way. - setState(f: (prevState: Readonly, props: P) => Pick, callback?: () => any): void; // tslint:disable-line:unified-signatures - setState(state: Pick, callback?: () => any): void; // tslint:disable-line:unified-signatures + // tslint:disable-next-line:unified-signatures + setState(f: (prevState: Readonly, props: P) => Pick, callback?: () => any): void; + // tslint:disable-next-line:unified-signatures + setState(state: Pick, callback?: () => any): void; forceUpdate(callBack?: () => any): void; render(): ReactNode; @@ -3517,15 +3519,18 @@ declare namespace React { declare global { namespace JSX { - interface Element extends React.ReactElement { } // tslint:disable-line:no-empty-interface + // tslint:disable-next-line:no-empty-interface + interface Element extends React.ReactElement { } interface ElementClass extends React.Component { render(): React.ReactNode; } interface ElementAttributesProperty { props: {}; } interface ElementChildrenAttribute { children: {}; } - interface IntrinsicAttributes extends React.Attributes { } // tslint:disable-line:no-empty-interface - interface IntrinsicClassAttributes extends React.ClassAttributes { } // tslint:disable-line:no-empty-interface + // tslint:disable-next-line:no-empty-interface + interface IntrinsicAttributes extends React.Attributes { } + // tslint:disable-next-line:no-empty-interface + interface IntrinsicClassAttributes extends React.ClassAttributes { } interface IntrinsicElements { // HTML From ad0e1920d28a38643a97231881b3359d93cf0efc Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 4 Dec 2017 10:44:00 -0800 Subject: [PATCH 400/639] Re-added exports and "chai" module to chai types (#21924) * Re-added exports and "chai" module to chai types Fixes issues with downstream typings and projects that relied on the chai module. * Re-disabled packaging tslint rules --- types/chai/index.d.ts | 26 +++++++++++++------------- types/chai/tslint.json | 5 ++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 984e4103d1..8c19f1f54a 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -26,20 +26,20 @@ declare namespace Chai { version: string; } - interface ExpectStatic extends AssertionStatic { + export interface ExpectStatic extends AssertionStatic { fail(actual?: any, expected?: any, message?: string, operator?: Operator): void; } - interface AssertStatic extends Assert { + export interface AssertStatic extends Assert { } - interface AssertionStatic { + export interface AssertionStatic { (target: any, message?: string): Assertion; } - type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; + export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; - type OperatorComparable = boolean | null | number | string | undefined | Date; + export type OperatorComparable = boolean | null | number | string | undefined | Date; interface ShouldAssertion { equal(value1: any, value2: any, message?: string): void; @@ -256,7 +256,7 @@ declare namespace Chai { (object: Object, property: string, message?: string): Assertion; } - interface Assert { + export interface Assert { /** * @param expression Expression to test for truthiness. * @param message Message to display on error. @@ -1587,7 +1587,7 @@ declare namespace Chai { doesNotHaveAllDeepKeys(object: T, keys: Array | { [key: string]: any }, message?: string): void; } - interface Config { + export interface Config { /** * Default: false */ @@ -1604,7 +1604,7 @@ declare namespace Chai { truncateThreshold: number; } - class AssertionError { + export class AssertionError { constructor(message: string, _props?: any, ssf?: Function); name: string; message: string; @@ -1615,10 +1615,10 @@ declare namespace Chai { declare const chai: Chai.ChaiStatic; -export = chai; +declare module "chai" { + export = chai; +} -declare global { - interface Object { - should: Chai.Assertion; - } +interface Object { + should: Chai.Assertion; } diff --git a/types/chai/tslint.json b/types/chai/tslint.json index 1a0ebe45c6..f99183c97d 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -4,8 +4,11 @@ "ban-types": false, "callable-types": false, "new-parens": false, + "no-declare-current-package": false, "no-empty-interface": false, "no-redundant-jsdoc-2": false, - "no-unnecessary-generics": false + "no-single-declare-module": false, + "no-unnecessary-generics": false, + "strict-export-declare-modifiers": false } } From 13a6e92a7fdd432276059ab301304bd73dfb6ab6 Mon Sep 17 00:00:00 2001 From: John Gozde Date: Mon, 4 Dec 2017 11:49:38 -0700 Subject: [PATCH 401/639] Revert 'type' changes --- types/react/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index a2ea9bdc6c..4c0aa8c0a3 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -88,7 +88,7 @@ declare namespace React { } interface ReactElement

{ - type: string | symbol | number | ComponentClass

| SFC

; + type: string | ComponentClass

| SFC

; props: P; key: Key | null; } @@ -222,7 +222,7 @@ declare namespace React { props?: ClassAttributes & P, ...children: ReactNode[]): CElement; function createElement

( - type: SFC

| ComponentClass

| string | symbol | number, + type: SFC

| ComponentClass

| string, props?: Attributes & P, ...children: ReactNode[]): ReactElement

; From 809dbe9864a9952d2dc5633905d31e10822e370e Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Fri, 1 Dec 2017 15:41:30 +0000 Subject: [PATCH 402/639] add redis add_command function --- types/redis/index.d.ts | 6 +++++- types/redis/redis-tests.ts | 12 ++++++++---- types/redis/tsconfig.json | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/types/redis/index.d.ts b/types/redis/index.d.ts index 5f7e1d1e10..00029fe2d3 100644 --- a/types/redis/index.d.ts +++ b/types/redis/index.d.ts @@ -5,6 +5,7 @@ // TANAKA Koichi // Stuart Schechter // Junyoung Choi +// James Garbutt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: https://github.com/types/npm-redis @@ -43,7 +44,7 @@ export interface ClientOpts { password?: string; db?: string | number; family?: string; - rename_commands?: { [command: string]: string }; + rename_commands?: { [command: string]: string } | null; tls?: any; prefix?: string; retry_strategy?: RetryStrategy; @@ -1202,6 +1203,9 @@ export interface RedisClient extends Commands, EventEmitter { send_command(command: string, cb?: Callback): boolean; send_command(command: string, args?: any[], cb?: Callback): boolean; + addCommand(command: string): void; + add_command(command: string): void; + /** * Mark the start of a transaction block. */ diff --git a/types/redis/redis-tests.ts b/types/redis/redis-tests.ts index 25bafc0627..4c38b9046e 100644 --- a/types/redis/redis-tests.ts +++ b/types/redis/redis-tests.ts @@ -6,10 +6,10 @@ const num = 0; const str = 'any string'; const err: Error = new Error(); const args: any[] = []; -const resCallback: (err: Error, res: any) => void = () => null; -const numCallback: (err: Error, res: number) => void = () => null; -const strCallback: (err: Error, res: string) => void = () => null; -const messageHandler: (channel: string, message: any) => void = () => null; +const resCallback: (err: Error | null, res: any) => void = () => {}; +const numCallback: (err: Error | null, res: number) => void = () => {}; +const strCallback: (err: Error | null, res: string) => void = () => {}; +const messageHandler: (channel: string, message: any) => void = () => {}; // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- @@ -117,3 +117,7 @@ client.cork(); client.set("abc", "fff", strCallback); client.get("abc", resCallback); client.uncork(); + +// Add command +client.add_command('my command'); +client.addCommand('my other command'); diff --git a/types/redis/tsconfig.json b/types/redis/tsconfig.json index e79b038103..b99c599145 100644 --- a/types/redis/tsconfig.json +++ b/types/redis/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "redis-tests.ts" ] -} \ No newline at end of file +} From a385b18cd63d91f395f54c5c301f74241a884b11 Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Fri, 1 Dec 2017 13:02:40 -0800 Subject: [PATCH 403/639] Export nodejs native tls.checkServerIdentity function --- types/node/index.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 789e91997f..1d79e782d2 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -15,6 +15,7 @@ // Alvis HT Tang // Oliver Joseph Ash // Sebastian Silbermann +// Hannes Magnusson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /************************************************ @@ -4881,7 +4882,7 @@ declare module "tls" { servername?: string; path?: string; ALPNProtocols?: Array; - checkServerIdentity?: (servername: string, cert: string | Buffer | Array) => any; + checkServerIdentity?: typeof checkServerIdentity; secureProtocol?: string; secureContext?: Object; session?: Buffer; @@ -4984,6 +4985,14 @@ declare module "tls" { context: any; } + /* + * Verifies the certificate `cert` is issued to host `host`. + * @host The hostname to verify the certificate against + * @cert PeerCertificate representing the peer's certificate + * + * Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined. + */ + export function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined; export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket; export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; From 89a722bd8f1d70bfcffab63e923a7b5b80c8dd89 Mon Sep 17 00:00:00 2001 From: FaithForHumans Date: Mon, 4 Dec 2017 13:56:48 -0600 Subject: [PATCH 404/639] Getting rid of named component exports. Restoring UncontrolledProps in Alert, ButtonDropdown, Dropdown, NavDropdown, and Tooltip. --- types/reactstrap/index.d.ts | 150 +++++++++--------- types/reactstrap/lib/Alert.d.ts | 7 +- types/reactstrap/lib/Badge.d.ts | 2 +- types/reactstrap/lib/Breadcrumb.d.ts | 2 +- types/reactstrap/lib/BreadcrumbItem.d.ts | 2 +- types/reactstrap/lib/Button.d.ts | 2 +- types/reactstrap/lib/ButtonDropdown.d.ts | 16 +- types/reactstrap/lib/ButtonGroup.d.ts | 2 +- types/reactstrap/lib/ButtonToolbar.d.ts | 2 +- types/reactstrap/lib/Card.d.ts | 2 +- types/reactstrap/lib/CardBlock.d.ts | 2 +- types/reactstrap/lib/CardBody.d.ts | 2 +- types/reactstrap/lib/CardColumns.d.ts | 2 +- types/reactstrap/lib/CardDeck.d.ts | 2 +- types/reactstrap/lib/CardFooter.d.ts | 2 +- types/reactstrap/lib/CardGroup.d.ts | 2 +- types/reactstrap/lib/CardHeader.d.ts | 2 +- types/reactstrap/lib/CardImg.d.ts | 2 +- types/reactstrap/lib/CardImgOverlay.d.ts | 2 +- types/reactstrap/lib/CardLink.d.ts | 2 +- types/reactstrap/lib/CardSubtitle.d.ts | 2 +- types/reactstrap/lib/CardText.d.ts | 2 +- types/reactstrap/lib/CardTitle.d.ts | 2 +- types/reactstrap/lib/Col.d.ts | 2 +- types/reactstrap/lib/Collapse.d.ts | 2 +- types/reactstrap/lib/Container.d.ts | 2 +- types/reactstrap/lib/Dropdown.d.ts | 12 +- types/reactstrap/lib/DropdownItem.d.ts | 2 +- types/reactstrap/lib/DropdownMenu.d.ts | 2 +- types/reactstrap/lib/DropdownToggle.d.ts | 2 +- types/reactstrap/lib/Fade.d.ts | 2 +- types/reactstrap/lib/Form.d.ts | 2 +- types/reactstrap/lib/FormFeedback.d.ts | 2 +- types/reactstrap/lib/FormGroup.d.ts | 2 +- types/reactstrap/lib/FormText.d.ts | 2 +- types/reactstrap/lib/Input.d.ts | 6 +- types/reactstrap/lib/InputGroup.d.ts | 2 +- types/reactstrap/lib/InputGroupAddon.d.ts | 2 +- types/reactstrap/lib/InputGroupButton.d.ts | 2 +- types/reactstrap/lib/Jumbotron.d.ts | 2 +- types/reactstrap/lib/Label.d.ts | 2 +- types/reactstrap/lib/ListGroup.d.ts | 2 +- types/reactstrap/lib/ListGroupItem.d.ts | 2 +- .../reactstrap/lib/ListGroupItemHeading.d.ts | 2 +- types/reactstrap/lib/ListGroupItemText.d.ts | 2 +- types/reactstrap/lib/Media.d.ts | 2 +- types/reactstrap/lib/Modal.d.ts | 2 +- types/reactstrap/lib/ModalBody.d.ts | 2 +- types/reactstrap/lib/ModalFooter.d.ts | 2 +- types/reactstrap/lib/ModalHeader.d.ts | 2 +- types/reactstrap/lib/Nav.d.ts | 2 +- types/reactstrap/lib/NavDropdown.d.ts | 16 +- types/reactstrap/lib/NavItem.d.ts | 2 +- types/reactstrap/lib/NavLink.d.ts | 2 +- types/reactstrap/lib/Navbar.d.ts | 2 +- types/reactstrap/lib/NavbarBrand.d.ts | 2 +- types/reactstrap/lib/NavbarToggler.d.ts | 2 +- types/reactstrap/lib/Pagination.d.ts | 2 +- types/reactstrap/lib/PaginationItem.d.ts | 2 +- types/reactstrap/lib/PaginationLink.d.ts | 2 +- types/reactstrap/lib/Popover.d.ts | 2 +- types/reactstrap/lib/PopoverBody.d.ts | 2 +- types/reactstrap/lib/PopoverHeader.d.ts | 2 +- types/reactstrap/lib/Progress.d.ts | 2 +- types/reactstrap/lib/Row.d.ts | 2 +- types/reactstrap/lib/TabContent.d.ts | 2 +- types/reactstrap/lib/TabPane.d.ts | 2 +- types/reactstrap/lib/Table.d.ts | 2 +- types/reactstrap/lib/Tag.d.ts | 2 +- types/reactstrap/lib/TetherContent.d.ts | 2 +- types/reactstrap/lib/Tooltip.d.ts | 7 +- 71 files changed, 182 insertions(+), 160 deletions(-) diff --git a/types/reactstrap/index.d.ts b/types/reactstrap/index.d.ts index ae06cdd7cf..fb0242be63 100644 --- a/types/reactstrap/index.d.ts +++ b/types/reactstrap/index.d.ts @@ -12,78 +12,78 @@ export interface CSSModule { [className: string]: string; } -export { Alert, AlertProps } from './lib/Alert'; -export { Badge, BadgeProps } from './lib/Badge'; -export { Breadcrumb, BreadcrumbProps } from './lib/Breadcrumb'; -export { BreadcrumbItem, BreadcrumbItemProps } from './lib/BreadcrumbItem'; -export { Button, ButtonProps } from './lib/Button'; -export { ButtonDropdown, ButtonDropdownProps } from './lib/ButtonDropdown'; -export { ButtonGroup, ButtonGroupProps } from './lib/ButtonGroup'; -export { ButtonToolbar, ButtonToolbarProps } from './lib/ButtonToolbar'; -export { Card, CardProps } from './lib/Card'; -export { CardBody, CardBodyProps } from './lib/CardBody'; -export { CardBlock, CardBlockProps } from './lib/CardBlock'; -export { CardColumns, CardColumnsProps } from './lib/CardColumns'; -export { CardDeck, CardDeckProps } from './lib/CardDeck'; -export { CardFooter, CardFooterProps } from './lib/CardFooter'; -export { CardGroup, CardGroupProps } from './lib/CardGroup'; -export { CardHeader, CardHeaderProps } from './lib/CardHeader'; -export { CardImg, CardImgProps } from './lib/CardImg'; -export { CardImgOverlay, CardImgOverlayProps } from './lib/CardImgOverlay'; -export { CardLink, CardLinkProps } from './lib/CardLink'; -export { CardSubtitle, CardSubtitleProps } from './lib/CardSubtitle'; -export { CardText, CardTextProps } from './lib/CardText'; -export { CardTitle, CardTitleProps } from './lib/CardTitle'; -export { Col, ColProps } from './lib/Col'; -export { Collapse, CollapseProps } from './lib/Collapse'; -export { Container, ContainerProps } from './lib/Container'; -export { Dropdown, DropdownProps } from './lib/Dropdown'; -export { DropdownItem, DropdownItemProps } from './lib/DropdownItem'; -export { DropdownMenu, DropdownMenuProps } from './lib/DropdownMenu'; -export { DropdownToggle, DropdownToggleProps } from './lib/DropdownToggle'; -export { Fade, FadeProps } from './lib/Fade'; -export { Form, FormProps } from './lib/Form'; -export { FormFeedback, FormFeedbackProps } from './lib/FormFeedback'; -export { FormGroup, FormGroupProps } from './lib/FormGroup'; -export { FormText, FormTextProps } from './lib/FormText'; -export { Input, InputProps } from './lib/Input'; -export { InputGroup, InputGroupProps } from './lib/InputGroup'; -export { InputGroupAddon, InputGroupAddonProps } from './lib/InputGroupAddon'; -export { InputGroupButton, InputGroupButtonProps } from './lib/InputGroupButton'; -export { Jumbotron, JumbotronProps } from './lib/Jumbotron'; -export { Label, LabelProps } from './lib/Label'; -export { ListGroup, ListGroupProps } from './lib/ListGroup'; -export { ListGroupItem, ListGroupItemProps } from './lib/ListGroupItem'; -export { ListGroupItemHeading, ListGroupItemHeadingProps } from './lib/ListGroupItemHeading'; -export { ListGroupItemText, ListGroupItemTextProps } from './lib/ListGroupItemText'; -export { Media, MediaProps } from './lib/Media'; -export { Modal, ModalProps } from './lib/Modal'; -export { ModalBody, ModalBodyProps } from './lib/ModalBody'; -export { ModalFooter, ModalFooterProps } from './lib/ModalFooter'; -export { ModalHeader, ModalHeaderProps } from './lib/ModalHeader'; -export { Nav, NavProps } from './lib/Nav'; -export { Navbar, NavbarProps } from './lib/Navbar'; -export { NavbarBrand, NavbarBrandProps } from './lib/NavbarBrand'; -export { NavbarToggler, NavbarTogglerProps } from './lib/NavbarToggler'; -export { NavDropdown, NavDropdownProps } from './lib/NavDropdown'; -export { NavItem, NavItemProps } from './lib/NavItem'; -export { NavLink, NavLinkProps } from './lib/NavLink'; -export { Pagination, PaginationProps } from './lib/Pagination'; -export { PaginationItem, PaginationItemProps } from './lib/PaginationItem'; -export { PaginationLink, PaginationLinkProps } from './lib/PaginationLink'; -export { Popover, PopoverProps } from './lib/Popover'; -export { PopoverBody, PopoverBodyProps } from './lib/PopoverBody'; -export { PopoverHeader, PopoverHeaderProps } from './lib/PopoverHeader'; -export { Progress, ProgressProps } from './lib/Progress'; -export { Row, RowProps } from './lib/Row'; -export { TabContent, TabContentProps } from './lib/TabContent'; -export { Table, TableProps } from './lib/Table'; -export { TabPane, TabPaneProps } from './lib/TabPane'; -export { Tag, TagProps } from './lib/Tag'; -export { TetherContent, TetherContentProps } from './lib/TetherContent'; -export { Tooltip, TooltipProps } from './lib/Tooltip'; -export { UncontrolledAlert, UncontrolledAlertProps } from './lib/Uncontrolled'; -export { UncontrolledButtonDropdown, UncontrolledButtonDropdownProps } from './lib/Uncontrolled'; -export { UncontrolledDropdown, UncontrolledDropdownProps } from './lib/Uncontrolled'; -export { UncontrolledNavDropdown, UncontrolledNavDropdownProps } from './lib/Uncontrolled'; -export { UncontrolledTooltip, UncontrolledTooltipProps } from './lib/Uncontrolled'; +export { default as Alert, AlertProps } from './lib/Alert'; +export { default as Badge, BadgeProps } from './lib/Badge'; +export { default as Breadcrumb, BreadcrumbProps } from './lib/Breadcrumb'; +export { default as BreadcrumbItem, BreadcrumbItemProps } from './lib/BreadcrumbItem'; +export { default as Button, ButtonProps } from './lib/Button'; +export { default as ButtonDropdown, ButtonDropdownProps } from './lib/ButtonDropdown'; +export { default as ButtonGroup, ButtonGroupProps } from './lib/ButtonGroup'; +export { default as ButtonToolbar, ButtonToolbarProps } from './lib/ButtonToolbar'; +export { default as Card, CardProps } from './lib/Card'; +export { default as CardBody, CardBodyProps } from './lib/CardBody'; +export { default as CardBlock, CardBlockProps } from './lib/CardBlock'; +export { default as CardColumns, CardColumnsProps } from './lib/CardColumns'; +export { default as CardDeck, CardDeckProps } from './lib/CardDeck'; +export { default as CardFooter, CardFooterProps } from './lib/CardFooter'; +export { default as CardGroup, CardGroupProps } from './lib/CardGroup'; +export { default as CardHeader, CardHeaderProps } from './lib/CardHeader'; +export { default as CardImg, CardImgProps } from './lib/CardImg'; +export { default as CardImgOverlay, CardImgOverlayProps } from './lib/CardImgOverlay'; +export { default as CardLink, CardLinkProps } from './lib/CardLink'; +export { default as CardSubtitle, CardSubtitleProps } from './lib/CardSubtitle'; +export { default as CardText, CardTextProps } from './lib/CardText'; +export { default as CardTitle, CardTitleProps } from './lib/CardTitle'; +export { default as Col, ColProps } from './lib/Col'; +export { default as Collapse, CollapseProps } from './lib/Collapse'; +export { default as Container, ContainerProps } from './lib/Container'; +export { default as Dropdown, DropdownProps } from './lib/Dropdown'; +export { default as DropdownItem, DropdownItemProps } from './lib/DropdownItem'; +export { default as DropdownMenu, DropdownMenuProps } from './lib/DropdownMenu'; +export { default as DropdownToggle, DropdownToggleProps } from './lib/DropdownToggle'; +export { default as Fade, FadeProps } from './lib/Fade'; +export { default as Form, FormProps } from './lib/Form'; +export { default as FormFeedback, FormFeedbackProps } from './lib/FormFeedback'; +export { default as FormGroup, FormGroupProps } from './lib/FormGroup'; +export { default as FormText, FormTextProps } from './lib/FormText'; +export { default as Input, InputProps } from './lib/Input'; +export { default as InputGroup, InputGroupProps } from './lib/InputGroup'; +export { default as InputGroupAddon, InputGroupAddonProps } from './lib/InputGroupAddon'; +export { default as InputGroupButton, InputGroupButtonProps } from './lib/InputGroupButton'; +export { default as Jumbotron, JumbotronProps } from './lib/Jumbotron'; +export { default as Label, LabelProps } from './lib/Label'; +export { default as ListGroup, ListGroupProps } from './lib/ListGroup'; +export { default as ListGroupItem, ListGroupItemProps } from './lib/ListGroupItem'; +export { default as ListGroupItemHeading, ListGroupItemHeadingProps } from './lib/ListGroupItemHeading'; +export { default as ListGroupItemText, ListGroupItemTextProps } from './lib/ListGroupItemText'; +export { default as Media, MediaProps } from './lib/Media'; +export { default as Modal, ModalProps } from './lib/Modal'; +export { default as ModalBody, ModalBodyProps } from './lib/ModalBody'; +export { default as ModalFooter, ModalFooterProps } from './lib/ModalFooter'; +export { default as ModalHeader, ModalHeaderProps } from './lib/ModalHeader'; +export { default as Nav, NavProps } from './lib/Nav'; +export { default as Navbar, NavbarProps } from './lib/Navbar'; +export { default as NavbarBrand, NavbarBrandProps } from './lib/NavbarBrand'; +export { default as NavbarToggler, NavbarTogglerProps } from './lib/NavbarToggler'; +export { default as NavDropdown, NavDropdownProps } from './lib/NavDropdown'; +export { default as NavItem, NavItemProps } from './lib/NavItem'; +export { default as NavLink, NavLinkProps } from './lib/NavLink'; +export { default as Pagination, PaginationProps } from './lib/Pagination'; +export { default as PaginationItem, PaginationItemProps } from './lib/PaginationItem'; +export { default as PaginationLink, PaginationLinkProps } from './lib/PaginationLink'; +export { default as Popover, PopoverProps } from './lib/Popover'; +export { default as PopoverBody, PopoverBodyProps } from './lib/PopoverBody'; +export { default as PopoverHeader, PopoverHeaderProps } from './lib/PopoverHeader'; +export { default as Progress, ProgressProps } from './lib/Progress'; +export { default as Row, RowProps } from './lib/Row'; +export { default as TabContent, TabContentProps } from './lib/TabContent'; +export { default as Table, TableProps } from './lib/Table'; +export { default as TabPane, TabPaneProps } from './lib/TabPane'; +export { default as Tag, TagProps } from './lib/Tag'; +export { default as TetherContent, TetherContentProps } from './lib/TetherContent'; +export { default as Tooltip, TooltipProps } from './lib/Tooltip'; +export { UncontrolledAlert, UncontrolledAlertProps } from './lib/Uncontrolled'; +export { UncontrolledButtonDropdown, UncontrolledButtonDropdownProps } from './lib/Uncontrolled'; +export { UncontrolledDropdown, UncontrolledDropdownProps } from './lib/Uncontrolled'; +export { UncontrolledNavDropdown, UncontrolledNavDropdownProps } from './lib/Uncontrolled'; +export { UncontrolledTooltip, UncontrolledTooltipProps } from './lib/Uncontrolled'; diff --git a/types/reactstrap/lib/Alert.d.ts b/types/reactstrap/lib/Alert.d.ts index 6ce7c0fe0e..c52ff2c35b 100644 --- a/types/reactstrap/lib/Alert.d.ts +++ b/types/reactstrap/lib/Alert.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -export interface UncontrolledAlertProps { +export interface UncontrolledProps { className?: string; cssModule?: CSSModule; color?: string; @@ -9,11 +9,14 @@ export interface UncontrolledAlertProps { transitionEnterTimeout?: number; transitionLeaveTimeout?: number; } +export interface UncontrolledAlertProps extends UncontrolledProps { + /* intentionally blank */ +} export interface AlertProps extends UncontrolledAlertProps { isOpen?: boolean; toggle?: () => void; } -export const Alert: React.StatelessComponent; +declare const Alert: React.StatelessComponent; export default Alert; diff --git a/types/reactstrap/lib/Badge.d.ts b/types/reactstrap/lib/Badge.d.ts index 328e3abf36..b58faeed8c 100644 --- a/types/reactstrap/lib/Badge.d.ts +++ b/types/reactstrap/lib/Badge.d.ts @@ -8,5 +8,5 @@ export interface BadgeProps { cssModule?: CSSModule; } -export const Badge: React.StatelessComponent; +declare const Badge: React.StatelessComponent; export default Badge; diff --git a/types/reactstrap/lib/Breadcrumb.d.ts b/types/reactstrap/lib/Breadcrumb.d.ts index 62ccf477a9..4b5e2b85da 100644 --- a/types/reactstrap/lib/Breadcrumb.d.ts +++ b/types/reactstrap/lib/Breadcrumb.d.ts @@ -6,5 +6,5 @@ export interface BreadcrumbProps { cssModule?: CSSModule; } -export const Breadcrumb: React.StatelessComponent; +declare const Breadcrumb: React.StatelessComponent; export default Breadcrumb; diff --git a/types/reactstrap/lib/BreadcrumbItem.d.ts b/types/reactstrap/lib/BreadcrumbItem.d.ts index 81d18f0f76..4cb8d77c75 100644 --- a/types/reactstrap/lib/BreadcrumbItem.d.ts +++ b/types/reactstrap/lib/BreadcrumbItem.d.ts @@ -10,5 +10,5 @@ export interface BreadcrumbItemProps { [others: string]: any; } -export const BreadcrumbItem: React.StatelessComponent; +declare const BreadcrumbItem: React.StatelessComponent; export default BreadcrumbItem; diff --git a/types/reactstrap/lib/Button.d.ts b/types/reactstrap/lib/Button.d.ts index f4a8b4e4cd..50f69b1fb1 100644 --- a/types/reactstrap/lib/Button.d.ts +++ b/types/reactstrap/lib/Button.d.ts @@ -17,5 +17,5 @@ export interface ButtonProps extends React.HTMLProps { cssModule?: CSSModule; } -export const Button: React.StatelessComponent; +declare const Button: React.StatelessComponent; export default Button; diff --git a/types/reactstrap/lib/ButtonDropdown.d.ts b/types/reactstrap/lib/ButtonDropdown.d.ts index 284818f88f..fd09d6da8f 100644 --- a/types/reactstrap/lib/ButtonDropdown.d.ts +++ b/types/reactstrap/lib/ButtonDropdown.d.ts @@ -1,9 +1,15 @@ import { UncontrolledDropdownProps, DropdownProps } from './Dropdown'; -// tslint:disable-next-line -export interface UncontrolledButtonDropdownProps extends UncontrolledDropdownProps { } -// tslint:disable-next-line -export interface ButtonDropdownProps extends DropdownProps { } +export interface UncontrolledProps extends UncontrolledDropdownProps { + /* intentionally blank */ +} +export interface UncontrolledButtonDropdownProps extends UncontrolledProps { + /* intentionally blank */ +} -export const ButtonDropdown: React.StatelessComponent; +export interface ButtonDropdownProps extends DropdownProps { + /* intentionally blank */ +} + +declare const ButtonDropdown: React.StatelessComponent; export default ButtonDropdown; diff --git a/types/reactstrap/lib/ButtonGroup.d.ts b/types/reactstrap/lib/ButtonGroup.d.ts index cf51a29326..29bbaac38b 100644 --- a/types/reactstrap/lib/ButtonGroup.d.ts +++ b/types/reactstrap/lib/ButtonGroup.d.ts @@ -10,5 +10,5 @@ export interface ButtonGroupProps { vertical?: boolean; } -export const ButtonGroup: React.StatelessComponent; +declare const ButtonGroup: React.StatelessComponent; export default ButtonGroup; diff --git a/types/reactstrap/lib/ButtonToolbar.d.ts b/types/reactstrap/lib/ButtonToolbar.d.ts index e57b84337a..1c782c5745 100644 --- a/types/reactstrap/lib/ButtonToolbar.d.ts +++ b/types/reactstrap/lib/ButtonToolbar.d.ts @@ -8,5 +8,5 @@ export interface ButtonToolbarProps { role?: string; } -export const ButtonToolbar: React.StatelessComponent; +declare const ButtonToolbar: React.StatelessComponent; export default ButtonToolbar; diff --git a/types/reactstrap/lib/Card.d.ts b/types/reactstrap/lib/Card.d.ts index 8398d3b631..97aafdc3e3 100644 --- a/types/reactstrap/lib/Card.d.ts +++ b/types/reactstrap/lib/Card.d.ts @@ -11,5 +11,5 @@ export interface CardProps { style?: React.CSSProperties; } -export const Card: React.StatelessComponent; +declare const Card: React.StatelessComponent; export default Card; diff --git a/types/reactstrap/lib/CardBlock.d.ts b/types/reactstrap/lib/CardBlock.d.ts index a4eae1cf6e..9830e15e6a 100644 --- a/types/reactstrap/lib/CardBlock.d.ts +++ b/types/reactstrap/lib/CardBlock.d.ts @@ -6,5 +6,5 @@ export interface CardBlockProps { cssModule?: CSSModule; } -export const CardBlock: React.StatelessComponent; +declare const CardBlock: React.StatelessComponent; export default CardBlock; diff --git a/types/reactstrap/lib/CardBody.d.ts b/types/reactstrap/lib/CardBody.d.ts index 9ff4ba1f7e..433a6a6ac0 100644 --- a/types/reactstrap/lib/CardBody.d.ts +++ b/types/reactstrap/lib/CardBody.d.ts @@ -6,5 +6,5 @@ export interface CardBodyProps { cssModule?: CSSModule; } -export const CardBody: React.StatelessComponent; +declare const CardBody: React.StatelessComponent; export default CardBody; diff --git a/types/reactstrap/lib/CardColumns.d.ts b/types/reactstrap/lib/CardColumns.d.ts index 4853240671..92eb2019ec 100644 --- a/types/reactstrap/lib/CardColumns.d.ts +++ b/types/reactstrap/lib/CardColumns.d.ts @@ -6,5 +6,5 @@ export interface CardColumnsProps { cssModule?: CSSModule; } -export const CardColumns: React.StatelessComponent; +declare const CardColumns: React.StatelessComponent; export default CardColumns; diff --git a/types/reactstrap/lib/CardDeck.d.ts b/types/reactstrap/lib/CardDeck.d.ts index 963d617383..c14324df37 100644 --- a/types/reactstrap/lib/CardDeck.d.ts +++ b/types/reactstrap/lib/CardDeck.d.ts @@ -6,5 +6,5 @@ export interface CardDeckProps { cssModule?: CSSModule; } -export const CardDeck: React.StatelessComponent; +declare const CardDeck: React.StatelessComponent; export default CardDeck; diff --git a/types/reactstrap/lib/CardFooter.d.ts b/types/reactstrap/lib/CardFooter.d.ts index 415406a14c..6dba776a38 100644 --- a/types/reactstrap/lib/CardFooter.d.ts +++ b/types/reactstrap/lib/CardFooter.d.ts @@ -6,5 +6,5 @@ export interface CardFooterProps { cssModule?: CSSModule; } -export const CardFooter: React.StatelessComponent; +declare const CardFooter: React.StatelessComponent; export default CardFooter; diff --git a/types/reactstrap/lib/CardGroup.d.ts b/types/reactstrap/lib/CardGroup.d.ts index be69f617e7..695747eef4 100644 --- a/types/reactstrap/lib/CardGroup.d.ts +++ b/types/reactstrap/lib/CardGroup.d.ts @@ -6,5 +6,5 @@ export interface CardGroupProps { cssModule?: CSSModule; } -export const CardGroup: React.StatelessComponent; +declare const CardGroup: React.StatelessComponent; export default CardGroup; diff --git a/types/reactstrap/lib/CardHeader.d.ts b/types/reactstrap/lib/CardHeader.d.ts index e9a468e2e4..306ff445e3 100644 --- a/types/reactstrap/lib/CardHeader.d.ts +++ b/types/reactstrap/lib/CardHeader.d.ts @@ -6,5 +6,5 @@ export interface CardHeaderProps { cssModule?: CSSModule; } -export const CardHeader: React.StatelessComponent; +declare const CardHeader: React.StatelessComponent; export default CardHeader; diff --git a/types/reactstrap/lib/CardImg.d.ts b/types/reactstrap/lib/CardImg.d.ts index 76bd9a18f2..e65cba66e2 100644 --- a/types/reactstrap/lib/CardImg.d.ts +++ b/types/reactstrap/lib/CardImg.d.ts @@ -12,5 +12,5 @@ export interface CardImgProps { alt?: string; } -export const CardImg: React.StatelessComponent; +declare const CardImg: React.StatelessComponent; export default CardImg; diff --git a/types/reactstrap/lib/CardImgOverlay.d.ts b/types/reactstrap/lib/CardImgOverlay.d.ts index 0511d38e8b..d31e96d76f 100644 --- a/types/reactstrap/lib/CardImgOverlay.d.ts +++ b/types/reactstrap/lib/CardImgOverlay.d.ts @@ -6,5 +6,5 @@ export interface CardImgOverlayProps { cssModule?: CSSModule; } -export const CardImgOverlay: React.StatelessComponent; +declare const CardImgOverlay: React.StatelessComponent; export default CardImgOverlay; diff --git a/types/reactstrap/lib/CardLink.d.ts b/types/reactstrap/lib/CardLink.d.ts index 68ef38fa62..22c9d614b3 100644 --- a/types/reactstrap/lib/CardLink.d.ts +++ b/types/reactstrap/lib/CardLink.d.ts @@ -8,5 +8,5 @@ export interface CardLinkProps { href?: string; } -export const CardLink: React.StatelessComponent; +declare const CardLink: React.StatelessComponent; export default CardLink; diff --git a/types/reactstrap/lib/CardSubtitle.d.ts b/types/reactstrap/lib/CardSubtitle.d.ts index 5c2cbe574f..915c69c93f 100644 --- a/types/reactstrap/lib/CardSubtitle.d.ts +++ b/types/reactstrap/lib/CardSubtitle.d.ts @@ -6,5 +6,5 @@ export interface CardSubtitleProps { cssModule?: CSSModule; } -export const CardSubtitle: React.StatelessComponent; +declare const CardSubtitle: React.StatelessComponent; export default CardSubtitle; diff --git a/types/reactstrap/lib/CardText.d.ts b/types/reactstrap/lib/CardText.d.ts index 1b411717f5..3782e962be 100644 --- a/types/reactstrap/lib/CardText.d.ts +++ b/types/reactstrap/lib/CardText.d.ts @@ -6,5 +6,5 @@ export interface CardTextProps { cssModule?: CSSModule; } -export const CardText: React.StatelessComponent; +declare const CardText: React.StatelessComponent; export default CardText; diff --git a/types/reactstrap/lib/CardTitle.d.ts b/types/reactstrap/lib/CardTitle.d.ts index 483a47adb7..f551d860ab 100644 --- a/types/reactstrap/lib/CardTitle.d.ts +++ b/types/reactstrap/lib/CardTitle.d.ts @@ -6,5 +6,5 @@ export interface CardTitleProps { cssModule?: CSSModule; } -export const CardTitle: React.StatelessComponent; +declare const CardTitle: React.StatelessComponent; export default CardTitle; diff --git a/types/reactstrap/lib/Col.d.ts b/types/reactstrap/lib/Col.d.ts index c1bc6a0cd9..b0aa8f98c1 100644 --- a/types/reactstrap/lib/Col.d.ts +++ b/types/reactstrap/lib/Col.d.ts @@ -20,5 +20,5 @@ export interface ColProps extends React.HTMLProps { widths?: string[]; } -export const Col: React.StatelessComponent; +declare const Col: React.StatelessComponent; export default Col; diff --git a/types/reactstrap/lib/Collapse.d.ts b/types/reactstrap/lib/Collapse.d.ts index d926fd677d..d2c6bc0c70 100644 --- a/types/reactstrap/lib/Collapse.d.ts +++ b/types/reactstrap/lib/Collapse.d.ts @@ -14,5 +14,5 @@ export interface CollapseProps extends React.HTMLProps { onClosed?: () => void; } -export const Collapse: React.StatelessComponent; +declare const Collapse: React.StatelessComponent; export default Collapse; diff --git a/types/reactstrap/lib/Container.d.ts b/types/reactstrap/lib/Container.d.ts index 63906b7bf3..4721cf68c1 100644 --- a/types/reactstrap/lib/Container.d.ts +++ b/types/reactstrap/lib/Container.d.ts @@ -7,5 +7,5 @@ export interface ContainerProps { cssModule?: CSSModule; } -export const Container: React.StatelessComponent; +declare const Container: React.StatelessComponent; export default Container; diff --git a/types/reactstrap/lib/Dropdown.d.ts b/types/reactstrap/lib/Dropdown.d.ts index 93a0ee1ce5..38bfe65b63 100644 --- a/types/reactstrap/lib/Dropdown.d.ts +++ b/types/reactstrap/lib/Dropdown.d.ts @@ -2,14 +2,17 @@ import { CSSModule } from '../index'; -export interface UncontrolledDropdownProps { +export interface UncontrolledProps { isOpen?: boolean; toggle?: () => void; className?: string; cssModule?: CSSModule; } +export interface UncontrolledDropdownProps extends UncontrolledProps { + /* intentionally blank */ +} -export interface DropdownProps extends UncontrolledDropdownProps { +export interface Props extends UncontrolledProps { disabled?: boolean; dropup?: boolean; group?: boolean; @@ -17,6 +20,9 @@ export interface DropdownProps extends UncontrolledDropdownProps { tag?: React.ReactType; tether?: boolean | Tether.ITetherOptions; } +export interface DropdownProps extends Props { + /* intentionally blank */ +} -export const Dropdown: React.StatelessComponent; +declare const Dropdown: React.StatelessComponent; export default Dropdown; diff --git a/types/reactstrap/lib/DropdownItem.d.ts b/types/reactstrap/lib/DropdownItem.d.ts index 194d89bf0b..963f1e3865 100644 --- a/types/reactstrap/lib/DropdownItem.d.ts +++ b/types/reactstrap/lib/DropdownItem.d.ts @@ -12,5 +12,5 @@ export interface DropdownItemProps { toggle?: boolean; } -export const DropdownItem: React.StatelessComponent; +declare const DropdownItem: React.StatelessComponent; export default DropdownItem; diff --git a/types/reactstrap/lib/DropdownMenu.d.ts b/types/reactstrap/lib/DropdownMenu.d.ts index 1bbf642a09..04ca074b41 100644 --- a/types/reactstrap/lib/DropdownMenu.d.ts +++ b/types/reactstrap/lib/DropdownMenu.d.ts @@ -7,5 +7,5 @@ export interface DropdownMenuProps { cssModule?: CSSModule; } -export const DropdownMenu: React.StatelessComponent; +declare const DropdownMenu: React.StatelessComponent; export default DropdownMenu; diff --git a/types/reactstrap/lib/DropdownToggle.d.ts b/types/reactstrap/lib/DropdownToggle.d.ts index 8f395b998d..51028815d4 100644 --- a/types/reactstrap/lib/DropdownToggle.d.ts +++ b/types/reactstrap/lib/DropdownToggle.d.ts @@ -15,5 +15,5 @@ export interface DropdownToggleProps { size?: string; } -export const DropdownToggle: React.StatelessComponent; +declare const DropdownToggle: React.StatelessComponent; export default DropdownToggle; diff --git a/types/reactstrap/lib/Fade.d.ts b/types/reactstrap/lib/Fade.d.ts index ab77d7fb61..6f86b33846 100644 --- a/types/reactstrap/lib/Fade.d.ts +++ b/types/reactstrap/lib/Fade.d.ts @@ -16,5 +16,5 @@ export interface FadeProps { onEnter?: () => void; } -export const Fade: React.StatelessComponent; +declare const Fade: React.StatelessComponent; export default Fade; diff --git a/types/reactstrap/lib/Form.d.ts b/types/reactstrap/lib/Form.d.ts index 507b617a12..997f4c4e5c 100644 --- a/types/reactstrap/lib/Form.d.ts +++ b/types/reactstrap/lib/Form.d.ts @@ -8,5 +8,5 @@ export interface FormProps extends React.HTMLProps { cssModule?: CSSModule; } -export const Form: React.StatelessComponent; +declare const Form: React.StatelessComponent; export default Form; diff --git a/types/reactstrap/lib/FormFeedback.d.ts b/types/reactstrap/lib/FormFeedback.d.ts index e9479bc53d..20e9b27745 100644 --- a/types/reactstrap/lib/FormFeedback.d.ts +++ b/types/reactstrap/lib/FormFeedback.d.ts @@ -6,5 +6,5 @@ export interface FormFeedbackProps { cssModule?: CSSModule; } -export const FormFeedback: React.StatelessComponent; +declare const FormFeedback: React.StatelessComponent; export default FormFeedback; diff --git a/types/reactstrap/lib/FormGroup.d.ts b/types/reactstrap/lib/FormGroup.d.ts index c3e4d384db..5827f2c17b 100644 --- a/types/reactstrap/lib/FormGroup.d.ts +++ b/types/reactstrap/lib/FormGroup.d.ts @@ -10,5 +10,5 @@ export interface FormGroupProps extends React.HTMLProps { cssModule?: CSSModule; } -export const FormGroup: React.StatelessComponent; +declare const FormGroup: React.StatelessComponent; export default FormGroup; diff --git a/types/reactstrap/lib/FormText.d.ts b/types/reactstrap/lib/FormText.d.ts index ca4e1858fe..a749d6fc30 100644 --- a/types/reactstrap/lib/FormText.d.ts +++ b/types/reactstrap/lib/FormText.d.ts @@ -8,5 +8,5 @@ export interface FormTextProps { cssModule?: CSSModule; } -export const FormText: React.StatelessComponent; +declare const FormText: React.StatelessComponent; export default FormText; diff --git a/types/reactstrap/lib/Input.d.ts b/types/reactstrap/lib/Input.d.ts index cc7377ca1f..f5c5ac1d02 100644 --- a/types/reactstrap/lib/Input.d.ts +++ b/types/reactstrap/lib/Input.d.ts @@ -40,13 +40,11 @@ export interface InputProps extends Intermediate { valid?: boolean; tag?: React.ReactType; innerRef?: string | ((instance: HTMLInputElement) => any); - static?: boolean; + plaintext?: boolean; addon?: boolean; className?: string; cssModule?: CSSModule; - // We don't have the property 'static' here because 'static' is a reserved keyword in TypeScript - // Maybe reactstrap will support an 'isStatic' alias in the future } -export const Input: React.StatelessComponent; +declare const Input: React.StatelessComponent; export default Input; diff --git a/types/reactstrap/lib/InputGroup.d.ts b/types/reactstrap/lib/InputGroup.d.ts index 9a6ac719bb..22f3ba027c 100644 --- a/types/reactstrap/lib/InputGroup.d.ts +++ b/types/reactstrap/lib/InputGroup.d.ts @@ -7,5 +7,5 @@ export interface InputGroupProps { cssModule?: CSSModule; } -export const InputGroup: React.StatelessComponent; +declare const InputGroup: React.StatelessComponent; export default InputGroup; diff --git a/types/reactstrap/lib/InputGroupAddon.d.ts b/types/reactstrap/lib/InputGroupAddon.d.ts index 63ac88c455..31f5af505d 100644 --- a/types/reactstrap/lib/InputGroupAddon.d.ts +++ b/types/reactstrap/lib/InputGroupAddon.d.ts @@ -6,5 +6,5 @@ export interface InputGroupAddonProps { cssModule?: CSSModule; } -export const InputGroupAddon: React.StatelessComponent; +declare const InputGroupAddon: React.StatelessComponent; export default InputGroupAddon; diff --git a/types/reactstrap/lib/InputGroupButton.d.ts b/types/reactstrap/lib/InputGroupButton.d.ts index f51c61b3d1..0d77701932 100644 --- a/types/reactstrap/lib/InputGroupButton.d.ts +++ b/types/reactstrap/lib/InputGroupButton.d.ts @@ -9,5 +9,5 @@ export interface InputGroupButtonProps { color?: string; } -export const InputGroupButton: React.StatelessComponent; +declare const InputGroupButton: React.StatelessComponent; export default InputGroupButton; diff --git a/types/reactstrap/lib/Jumbotron.d.ts b/types/reactstrap/lib/Jumbotron.d.ts index 885bbe5f8f..6cb94c04c1 100644 --- a/types/reactstrap/lib/Jumbotron.d.ts +++ b/types/reactstrap/lib/Jumbotron.d.ts @@ -7,5 +7,5 @@ export interface JumbotronProps { cssModule?: CSSModule; } -export const Jumbotron: React.StatelessComponent; +declare const Jumbotron: React.StatelessComponent; export default Jumbotron; diff --git a/types/reactstrap/lib/Label.d.ts b/types/reactstrap/lib/Label.d.ts index 26728059e0..ae73e100f4 100644 --- a/types/reactstrap/lib/Label.d.ts +++ b/types/reactstrap/lib/Label.d.ts @@ -22,5 +22,5 @@ export interface LabelProps extends Intermediate { xl?: ColumnProps; } -export const Label: React.StatelessComponent; +declare const Label: React.StatelessComponent; export default Label; diff --git a/types/reactstrap/lib/ListGroup.d.ts b/types/reactstrap/lib/ListGroup.d.ts index aec7fa4045..a2a088935b 100644 --- a/types/reactstrap/lib/ListGroup.d.ts +++ b/types/reactstrap/lib/ListGroup.d.ts @@ -7,5 +7,5 @@ export interface ListGroupProps { cssModule?: CSSModule; } -export const ListGroup: React.StatelessComponent; +declare const ListGroup: React.StatelessComponent; export default ListGroup; diff --git a/types/reactstrap/lib/ListGroupItem.d.ts b/types/reactstrap/lib/ListGroupItem.d.ts index 5b610f87e2..d2cb1a9e67 100644 --- a/types/reactstrap/lib/ListGroupItem.d.ts +++ b/types/reactstrap/lib/ListGroupItem.d.ts @@ -13,5 +13,5 @@ export interface ListGroupItemProps { onClick?: React.MouseEventHandler; } -export const ListGroupItem: React.StatelessComponent; +declare const ListGroupItem: React.StatelessComponent; export default ListGroupItem; diff --git a/types/reactstrap/lib/ListGroupItemHeading.d.ts b/types/reactstrap/lib/ListGroupItemHeading.d.ts index 3e8d83a0dc..0f5bdfb457 100644 --- a/types/reactstrap/lib/ListGroupItemHeading.d.ts +++ b/types/reactstrap/lib/ListGroupItemHeading.d.ts @@ -6,5 +6,5 @@ export interface ListGroupItemHeadingProps { cssModule?: CSSModule; } -export const ListGroupItemHeading: React.StatelessComponent; +declare const ListGroupItemHeading: React.StatelessComponent; export default ListGroupItemHeading; diff --git a/types/reactstrap/lib/ListGroupItemText.d.ts b/types/reactstrap/lib/ListGroupItemText.d.ts index ad83a45831..7010eb1289 100644 --- a/types/reactstrap/lib/ListGroupItemText.d.ts +++ b/types/reactstrap/lib/ListGroupItemText.d.ts @@ -6,5 +6,5 @@ export interface ListGroupItemTextProps { cssModule?: CSSModule; } -export const ListGroupItemText: React.StatelessComponent; +declare const ListGroupItemText: React.StatelessComponent; export default ListGroupItemText; diff --git a/types/reactstrap/lib/Media.d.ts b/types/reactstrap/lib/Media.d.ts index 17b65f25f0..daf4fadcc8 100644 --- a/types/reactstrap/lib/Media.d.ts +++ b/types/reactstrap/lib/Media.d.ts @@ -17,5 +17,5 @@ export interface MediaProps { alt?: string; } -export const Media: React.StatelessComponent; +declare const Media: React.StatelessComponent; export default Media; diff --git a/types/reactstrap/lib/Modal.d.ts b/types/reactstrap/lib/Modal.d.ts index 77122f64b4..5fc1ffc734 100644 --- a/types/reactstrap/lib/Modal.d.ts +++ b/types/reactstrap/lib/Modal.d.ts @@ -19,5 +19,5 @@ export interface ModalProps { fade?: boolean; } -export const Modal: React.StatelessComponent; +declare const Modal: React.StatelessComponent; export default Modal; diff --git a/types/reactstrap/lib/ModalBody.d.ts b/types/reactstrap/lib/ModalBody.d.ts index a2693cbf28..1467b5883a 100644 --- a/types/reactstrap/lib/ModalBody.d.ts +++ b/types/reactstrap/lib/ModalBody.d.ts @@ -6,5 +6,5 @@ export interface ModalBodyProps { cssModule?: CSSModule; } -export const ModalBody: React.StatelessComponent; +declare const ModalBody: React.StatelessComponent; export default ModalBody; diff --git a/types/reactstrap/lib/ModalFooter.d.ts b/types/reactstrap/lib/ModalFooter.d.ts index 0241dcde84..ae511eb7cc 100644 --- a/types/reactstrap/lib/ModalFooter.d.ts +++ b/types/reactstrap/lib/ModalFooter.d.ts @@ -6,5 +6,5 @@ export interface ModalFooterProps { cssModule?: CSSModule; } -export const ModalFooter: React.StatelessComponent; +declare const ModalFooter: React.StatelessComponent; export default ModalFooter; diff --git a/types/reactstrap/lib/ModalHeader.d.ts b/types/reactstrap/lib/ModalHeader.d.ts index a235d73183..47632f59e3 100644 --- a/types/reactstrap/lib/ModalHeader.d.ts +++ b/types/reactstrap/lib/ModalHeader.d.ts @@ -8,5 +8,5 @@ export interface ModalHeaderProps { toggle?: () => void; } -export const ModalHeader: React.StatelessComponent; +declare const ModalHeader: React.StatelessComponent; export default ModalHeader; diff --git a/types/reactstrap/lib/Nav.d.ts b/types/reactstrap/lib/Nav.d.ts index 23bf1e58c5..c29c9a6460 100644 --- a/types/reactstrap/lib/Nav.d.ts +++ b/types/reactstrap/lib/Nav.d.ts @@ -13,5 +13,5 @@ export interface NavProps extends React.HTMLProps { vertical?: boolean; } -export const Nav: React.StatelessComponent; +declare const Nav: React.StatelessComponent; export default Nav; diff --git a/types/reactstrap/lib/NavDropdown.d.ts b/types/reactstrap/lib/NavDropdown.d.ts index 22e408489b..e40e60601c 100644 --- a/types/reactstrap/lib/NavDropdown.d.ts +++ b/types/reactstrap/lib/NavDropdown.d.ts @@ -1,9 +1,15 @@ import { UncontrolledDropdownProps, DropdownProps } from './Dropdown'; -// tslint:disable-next-line -export interface UncontrolledNavDropdownProps extends UncontrolledDropdownProps { } -// tslint:disable-next-line -export interface NavDropdownProps extends DropdownProps { } +export interface UncontrolledProps extends UncontrolledDropdownProps { + /* intentionally blank */ +} +export interface UncontrolledNavDropdownProps extends UncontrolledProps { + /* intentionally blank */ +} -export const NavDropdown: React.StatelessComponent; +export interface NavDropdownProps extends DropdownProps { + /* intentionally blank */ +} + +declare const NavDropdown: React.StatelessComponent; export default NavDropdown; diff --git a/types/reactstrap/lib/NavItem.d.ts b/types/reactstrap/lib/NavItem.d.ts index cb32a4fad1..0769347298 100644 --- a/types/reactstrap/lib/NavItem.d.ts +++ b/types/reactstrap/lib/NavItem.d.ts @@ -6,5 +6,5 @@ export interface NavItemProps { cssModule?: CSSModule; } -export const NavItem: React.StatelessComponent; +declare const NavItem: React.StatelessComponent; export default NavItem; diff --git a/types/reactstrap/lib/NavLink.d.ts b/types/reactstrap/lib/NavLink.d.ts index 7fa907c453..53640c65e1 100644 --- a/types/reactstrap/lib/NavLink.d.ts +++ b/types/reactstrap/lib/NavLink.d.ts @@ -11,5 +11,5 @@ export interface NavLinkProps extends React.HTMLProps { href?: string; } -export const NavLink: React.StatelessComponent; +declare const NavLink: React.StatelessComponent; export default NavLink; diff --git a/types/reactstrap/lib/Navbar.d.ts b/types/reactstrap/lib/Navbar.d.ts index fd52feeae8..ed3f28a02c 100644 --- a/types/reactstrap/lib/Navbar.d.ts +++ b/types/reactstrap/lib/Navbar.d.ts @@ -16,5 +16,5 @@ export interface NavbarProps { expand?: boolean | string; } -export const Navbar: React.StatelessComponent; +declare const Navbar: React.StatelessComponent; export default Navbar; diff --git a/types/reactstrap/lib/NavbarBrand.d.ts b/types/reactstrap/lib/NavbarBrand.d.ts index 8e3328ab81..83ac8367b5 100644 --- a/types/reactstrap/lib/NavbarBrand.d.ts +++ b/types/reactstrap/lib/NavbarBrand.d.ts @@ -6,5 +6,5 @@ export interface NavbarBrandProps extends React.HTMLProps { cssModule?: CSSModule; } -export const NavbarBrand: React.StatelessComponent; +declare const NavbarBrand: React.StatelessComponent; export default NavbarBrand; diff --git a/types/reactstrap/lib/NavbarToggler.d.ts b/types/reactstrap/lib/NavbarToggler.d.ts index 1855e2c41c..1eea9880a5 100644 --- a/types/reactstrap/lib/NavbarToggler.d.ts +++ b/types/reactstrap/lib/NavbarToggler.d.ts @@ -9,5 +9,5 @@ export interface NavbarTogglerProps extends React.HTMLProps { left?: boolean; } -export const NavbarToggler: React.StatelessComponent; +declare const NavbarToggler: React.StatelessComponent; export default NavbarToggler; diff --git a/types/reactstrap/lib/Pagination.d.ts b/types/reactstrap/lib/Pagination.d.ts index dd1a0c9d51..7657d90206 100644 --- a/types/reactstrap/lib/Pagination.d.ts +++ b/types/reactstrap/lib/Pagination.d.ts @@ -6,5 +6,5 @@ export interface PaginationProps { size?: string; } -export const Pagination: React.StatelessComponent; +declare const Pagination: React.StatelessComponent; export default Pagination; diff --git a/types/reactstrap/lib/PaginationItem.d.ts b/types/reactstrap/lib/PaginationItem.d.ts index 1e8efa8712..c2eadfab97 100644 --- a/types/reactstrap/lib/PaginationItem.d.ts +++ b/types/reactstrap/lib/PaginationItem.d.ts @@ -8,5 +8,5 @@ export interface PaginationItemProps { tag?: React.ReactType; } -export const PaginationItem: React.StatelessComponent; +declare const PaginationItem: React.StatelessComponent; export default PaginationItem; diff --git a/types/reactstrap/lib/PaginationLink.d.ts b/types/reactstrap/lib/PaginationLink.d.ts index c57bee37ac..52fbc6353a 100644 --- a/types/reactstrap/lib/PaginationLink.d.ts +++ b/types/reactstrap/lib/PaginationLink.d.ts @@ -9,5 +9,5 @@ export interface PaginationLinkProps extends React.HTMLProps tag?: React.ReactType; } -export const PaginationLink: React.StatelessComponent; +declare const PaginationLink: React.StatelessComponent; export default PaginationLink; diff --git a/types/reactstrap/lib/Popover.d.ts b/types/reactstrap/lib/Popover.d.ts index e9e757572e..dcded7ab68 100644 --- a/types/reactstrap/lib/Popover.d.ts +++ b/types/reactstrap/lib/Popover.d.ts @@ -30,5 +30,5 @@ export interface PopoverProps { toggle?: () => void; } -export const Popover: React.StatelessComponent; +declare const Popover: React.StatelessComponent; export default Popover; diff --git a/types/reactstrap/lib/PopoverBody.d.ts b/types/reactstrap/lib/PopoverBody.d.ts index de2d61f5e2..93512cacb1 100644 --- a/types/reactstrap/lib/PopoverBody.d.ts +++ b/types/reactstrap/lib/PopoverBody.d.ts @@ -6,5 +6,5 @@ export interface PopoverBodyProps { cssModule?: CSSModule; } -export const PopoverBody: React.StatelessComponent; +declare const PopoverBody: React.StatelessComponent; export default PopoverBody; diff --git a/types/reactstrap/lib/PopoverHeader.d.ts b/types/reactstrap/lib/PopoverHeader.d.ts index 7f38988391..2ad69c636c 100644 --- a/types/reactstrap/lib/PopoverHeader.d.ts +++ b/types/reactstrap/lib/PopoverHeader.d.ts @@ -6,5 +6,5 @@ export interface PopoverHeaderProps { cssModule?: CSSModule; } -export const PopoverHeader: React.StatelessComponent; +declare const PopoverHeader: React.StatelessComponent; export default PopoverHeader; diff --git a/types/reactstrap/lib/Progress.d.ts b/types/reactstrap/lib/Progress.d.ts index 9ab522746c..89e9df4be9 100644 --- a/types/reactstrap/lib/Progress.d.ts +++ b/types/reactstrap/lib/Progress.d.ts @@ -14,5 +14,5 @@ export interface ProgressProps { barClassName?: string; } -export const Progress: React.StatelessComponent; +declare const Progress: React.StatelessComponent; export default Progress; diff --git a/types/reactstrap/lib/Row.d.ts b/types/reactstrap/lib/Row.d.ts index 30d202e919..e5553ff81f 100644 --- a/types/reactstrap/lib/Row.d.ts +++ b/types/reactstrap/lib/Row.d.ts @@ -7,5 +7,5 @@ export interface RowProps extends React.HTMLProps< HTMLElement> { noGutters?: boolean; } -export const Row: React.StatelessComponent; +declare const Row: React.StatelessComponent; export default Row; diff --git a/types/reactstrap/lib/TabContent.d.ts b/types/reactstrap/lib/TabContent.d.ts index 1aced21b02..2581ea7a93 100644 --- a/types/reactstrap/lib/TabContent.d.ts +++ b/types/reactstrap/lib/TabContent.d.ts @@ -7,5 +7,5 @@ export interface TabContentProps { cssModule?: CSSModule; } -export const TabContent: React.StatelessComponent; +declare const TabContent: React.StatelessComponent; export default TabContent; diff --git a/types/reactstrap/lib/TabPane.d.ts b/types/reactstrap/lib/TabPane.d.ts index 1d588e7304..a39398d59b 100644 --- a/types/reactstrap/lib/TabPane.d.ts +++ b/types/reactstrap/lib/TabPane.d.ts @@ -7,5 +7,5 @@ export interface TabPaneProps { tabId?: number | string; } -export const TabPane: React.StatelessComponent; +declare const TabPane: React.StatelessComponent; export default TabPane; diff --git a/types/reactstrap/lib/Table.d.ts b/types/reactstrap/lib/Table.d.ts index b49c6a5920..c2d31d71e2 100644 --- a/types/reactstrap/lib/Table.d.ts +++ b/types/reactstrap/lib/Table.d.ts @@ -14,5 +14,5 @@ export interface TableProps { responsiveTag?: React.ReactType; } -export const Table: React.StatelessComponent; +declare const Table: React.StatelessComponent; export default Table; diff --git a/types/reactstrap/lib/Tag.d.ts b/types/reactstrap/lib/Tag.d.ts index 0f2ed5bd07..153ff61177 100644 --- a/types/reactstrap/lib/Tag.d.ts +++ b/types/reactstrap/lib/Tag.d.ts @@ -8,5 +8,5 @@ export interface TagProps { cssModule?: CSSModule; } -export const Tag: React.StatelessComponent; +declare const Tag: React.StatelessComponent; export default Tag; diff --git a/types/reactstrap/lib/TetherContent.d.ts b/types/reactstrap/lib/TetherContent.d.ts index 7dd32ae381..54f0190090 100644 --- a/types/reactstrap/lib/TetherContent.d.ts +++ b/types/reactstrap/lib/TetherContent.d.ts @@ -14,5 +14,5 @@ export interface TetherContentProps { style?: React.CSSProperties; } -export const TetherContent: React.StatelessComponent; +declare const TetherContent: React.StatelessComponent; export default TetherContent; diff --git a/types/reactstrap/lib/Tooltip.d.ts b/types/reactstrap/lib/Tooltip.d.ts index 21a99707e8..a6183668bf 100644 --- a/types/reactstrap/lib/Tooltip.d.ts +++ b/types/reactstrap/lib/Tooltip.d.ts @@ -20,7 +20,7 @@ type Placement | 'left middle' | 'left bottom'; -export interface UncontrolledTooltipProps { +export interface UncontrolledProps { placement?: Placement; target: string; disabled?: boolean; @@ -31,11 +31,14 @@ export interface UncontrolledTooltipProps { autohide?: boolean; delay?: number | { show: number, hide: number }; } +export interface UncontrolledTooltipProps extends UncontrolledProps { + /* intentionally blank */ +} export interface TooltipProps extends UncontrolledTooltipProps { toggle?: () => void; isOpen?: boolean; } -export const Tooltip: React.StatelessComponent; +declare const Tooltip: React.StatelessComponent; export default Tooltip; From 30cc923337eb764ea4459dd847c9d61b49aa3154 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Mon, 4 Dec 2017 12:12:07 -0700 Subject: [PATCH 405/639] [azure-sb] Complete rewrite to match stand-alone npm module --- types/azure-sb/azure-sb-tests.ts | 92 +++- types/azure-sb/index.d.ts | 448 ++++++++++++------ types/azure-sb/lib/apnsservice.d.ts | 83 ++++ types/azure-sb/lib/gcmservice.d.ts | 71 +++ types/azure-sb/lib/models/acstokenresult.d.ts | 29 ++ .../lib/models/notificationhubresult.d.ts | 26 + .../lib/models/queuemessageresult.d.ts | 40 ++ types/azure-sb/lib/models/queueresult.d.ts | 41 ++ .../lib/models/registrationresult.d.ts | 26 + types/azure-sb/lib/models/resourceresult.d.ts | 28 ++ types/azure-sb/lib/models/ruleresult.d.ts | 26 + .../lib/models/subscriptionresult.d.ts | 37 ++ types/azure-sb/lib/models/topicresult.d.ts | 32 ++ types/azure-sb/lib/mpnservice.d.ts | 116 +++++ .../azure-sb/lib/notificationhubservice.d.ts | 102 ++++ types/azure-sb/lib/servicebusservice.d.ts | 206 ++++++++ types/azure-sb/lib/servicebusservicebase.d.ts | 12 + .../azure-sb/lib/servicebusserviceclient.d.ts | 14 + types/azure-sb/lib/wnsservice.d.ts | 377 +++++++++++++++ types/azure-sb/lib/wrapservice.d.ts | 21 + types/azure-sb/tsconfig.json | 25 +- 21 files changed, 1687 insertions(+), 165 deletions(-) create mode 100644 types/azure-sb/lib/apnsservice.d.ts create mode 100644 types/azure-sb/lib/gcmservice.d.ts create mode 100644 types/azure-sb/lib/models/acstokenresult.d.ts create mode 100644 types/azure-sb/lib/models/notificationhubresult.d.ts create mode 100644 types/azure-sb/lib/models/queuemessageresult.d.ts create mode 100644 types/azure-sb/lib/models/queueresult.d.ts create mode 100644 types/azure-sb/lib/models/registrationresult.d.ts create mode 100644 types/azure-sb/lib/models/resourceresult.d.ts create mode 100644 types/azure-sb/lib/models/ruleresult.d.ts create mode 100644 types/azure-sb/lib/models/subscriptionresult.d.ts create mode 100644 types/azure-sb/lib/models/topicresult.d.ts create mode 100644 types/azure-sb/lib/mpnservice.d.ts create mode 100644 types/azure-sb/lib/notificationhubservice.d.ts create mode 100644 types/azure-sb/lib/servicebusservice.d.ts create mode 100644 types/azure-sb/lib/servicebusservicebase.d.ts create mode 100644 types/azure-sb/lib/servicebusserviceclient.d.ts create mode 100644 types/azure-sb/lib/wnsservice.d.ts create mode 100644 types/azure-sb/lib/wrapservice.d.ts diff --git a/types/azure-sb/azure-sb-tests.ts b/types/azure-sb/azure-sb-tests.ts index 68b0fc8df7..411862a3b2 100644 --- a/types/azure-sb/azure-sb-tests.ts +++ b/types/azure-sb/azure-sb-tests.ts @@ -1,16 +1,82 @@ +import { Azure } from 'azure-sb'; +import AzureSB = require('azure-sb'); +import Models = Azure.ServiceBus.Results.Models; -var nh = new Azure.ServiceBus.NotificationHubService(); -nh.send('tag', '', function (error, result) {}); -nh.send('tag', '', { headers: {} }, function (error, result) {}); +function createResultCallback() { + return (err: Error | null, result: T, response: Azure.ServiceBus.Response) => { + }; +} -nh.apns.send('tag', { payload: { } }, function (error, result) {}); -nh.apns.send(['tag'], { payload: { } }, function (error, result) {}); -nh.gcm.send('tag', { }, function (error, result) {}); -nh.gcm.send(['tag'], { }, function (error, result) {}); -nh.wns.send('tag', '', 'wns/toast', function (error, result) {}); -nh.wns.send(['tag'], '', 'wns/toast', function (error, result) {}); -nh.wns.send('tag', '', 'wns/toast', { headers: {} }, function (error, result) {}); -nh.wns.sendToastText01('tag', '', function (error, result) {}); -nh.wns.sendToastText01(['tag'], '', function (error, result) {}); -nh.wns.sendToastText01('tag', '', { headers: {} }, function (error, result) {}); \ No newline at end of file +function ResponseCallback(err: Error | null, response: Azure.ServiceBus.Response) { +} + +const ServiceBus = AzureSB.createServiceBusService('connectionstring'); + +// Queues +ServiceBus.listQueues('', createResultCallback()); +ServiceBus.createQueue('test', createResultCallback()); +ServiceBus.createQueueIfNotExists('test', createResultCallback()); +ServiceBus.getQueue('test', createResultCallback()); +ServiceBus.deleteQueue('test', ResponseCallback); + +// Topics +ServiceBus.listTopics('', createResultCallback()); +ServiceBus.createTopic('test', createResultCallback()); +ServiceBus.createTopicIfNotExists('test', createResultCallback()); +ServiceBus.getTopic('test', createResultCallback()); +ServiceBus.deleteTopic('test', ResponseCallback); + +// Subscriptions +ServiceBus.listSubscriptions('test', createResultCallback()); +ServiceBus.createSubscription('test', 'test', createResultCallback()); +ServiceBus.createSubscription('test', 'test', { + DefaultMessageTimeToLive: 'PT10M' +}, createResultCallback()); +ServiceBus.getSubscription('test', 'test', createResultCallback()); +ServiceBus.deleteSubscription('test', 'test', ResponseCallback); + +ServiceBus.listRules('testTopic', 'testSub', createResultCallback()); +ServiceBus.createRule('testTopic', 'testSub', 'testRule', createResultCallback()); +ServiceBus.getRule('testTopic', 'testSub', 'testRule', createResultCallback()); +ServiceBus.deleteRule('testTopic', 'testSub', 'testRule', ResponseCallback); + +// Messages +ServiceBus.sendQueueMessage('testTopic', 'My data', ResponseCallback); +ServiceBus.sendQueueMessage('testTopic', { + body: '{"data":"MyData"}', + contentType: 'application/json', + brokerProperties: { + CorrelationId: '123' + } +}, ResponseCallback); +ServiceBus.receiveQueueMessage('testQueue', createResultCallback()); + +ServiceBus.sendTopicMessage('testTopic', 'My data', ResponseCallback); +ServiceBus.sendTopicMessage('testTopic', { + body: '{"data":"MyData"}', + contentType: 'application/json', + brokerProperties: { + CorrelationId: '123' + } +}, ResponseCallback); +ServiceBus.receiveSubscriptionMessage('testTopic', 'testSub', createResultCallback()); + +ServiceBus.renewLockForMessage('test', ResponseCallback); +ServiceBus.unlockMessage('test', ResponseCallback); +ServiceBus.deleteMessage('test', ResponseCallback); + +// NotificationHub +const nh = AzureSB.createNotificationHubService('test'); +nh.send('tag', '', ResponseCallback); +nh.send('tag', '', { headers: {} }, ResponseCallback); +nh.apns.send('tag', { payload: {} }, ResponseCallback); +nh.apns.send(['tag'], { payload: {} }, ResponseCallback); +nh.gcm.send('tag', {}, ResponseCallback); +nh.gcm.send(['tag'], {}, ResponseCallback); +nh.wns.send('tag', '', 'wns/toast', ResponseCallback); +nh.wns.send(['tag'], '', 'wns/toast', ResponseCallback); +nh.wns.send('tag', '', 'wns/toast', { headers: {} }, ResponseCallback); +nh.wns.sendToastText01('tag', '', ResponseCallback); +nh.wns.sendToastText01(['tag'], '', ResponseCallback); +nh.wns.sendToastText01('tag', '', { headers: {} }, ResponseCallback); diff --git a/types/azure-sb/index.d.ts b/types/azure-sb/index.d.ts index bae1af04a9..ba92395c0f 100644 --- a/types/azure-sb/index.d.ts +++ b/types/azure-sb/index.d.ts @@ -2,172 +2,322 @@ // Project: https://github.com/Azure/azure-sdk-for-node/tree/master/lib/services/serviceBus // Definitions by: Microsoft Azure // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 -declare namespace Azure.ServiceBus { - interface Callback { - (error: any, response: any): void; +export import ServiceBusService = require('./lib/servicebusservice'); +export import NotificationHubService = require('./lib/notificationhubservice'); +export import WrapService = require('./lib/wrapservice'); + +export function createServiceBusService(namespaceOrConnectionString?: string, + accessKey?: string, + issuer?: string, + acsNamespace?: string, + host?: string, + authenticationProvider?: object): ServiceBusService; + +export function createNotificationHubService(hubName: string, + endpointOrConnectionString?: string, + sharedAccessKeyName?: string, + sharedAccessKeyValue?: string): NotificationHubService; + +export function createWrapService(acsHost: string, + issuer?: string, + accessKey?: string): WrapService; + +export namespace Azure.ServiceBus { + export type Duration = string; + export type DateString = string; + + export interface Dictionary { + [k: string]: T; } - interface NotificationHubRegistration { - RegistrationId: string; + export interface ReceiveQueueMessageOptions { + timeoutIntervalInS?: number; + } + + export interface ReceiveSubscriptionMessageOptions extends ReceiveQueueMessageOptions { + isPeekLock?: boolean; + } + + interface IBrokerPropertiesResponse { + readonly DeliveryCount: number; + readonly LockedUntil: DateString; + readonly LockToken: string; + readonly SequenceNumber: number; + } + + interface IBrokerProperties { + CorrelationId: string; + Label: string; + MessageId: string; + PartitionKey: string; + ReplyTo: string; + ReplyToSessionId: string; + ScheduledEnqueueTimeUtc: string; + SessionId: string; + TimeToLive: string; + To: string; + } + + export interface Message { + body: string; + brokerProperties?: BrokerProperties; + contentType?: string; + customProperties?: Dictionary; + } + + /* + * Options interfaces + */ + + interface CreateOptions { + DefaultMessageTimeToLive: string; + DuplicateDetectionHistoryTimeWindow: string; + EnablePartitioning: boolean; + MaxSizeInMegaBytes: number; + RequiresDuplicateDetection: boolean; + } + + interface IQueueOptions extends CreateOptions { + AutoDeleteOnIdle: string; + DeadLetteringOnMessageExpiration: boolean; + LockDuration: string; + RequiresSession: boolean; + } + + interface ICreateTopicOptions extends CreateOptions { + EnableBatchedOperations: boolean; + SizeInBytes: boolean; + SupportOrdering: boolean; + } + + interface ICreateTopicIfNotExistsOptions extends ICreateTopicOptions { + EnableDeadLetteringOnFilterEvaluationExceptions: boolean; + EnableDeadLetteringOnMessageExpiration: boolean; + MaxCorrelationFiltersPerTopic: number; + MaxSqlFiltersPerTopic: number; + MaxSubscriptionsPerTopic: number; + } + + interface ICreateSubscriptionOptions { + DefaultMessageTimeToLive: string; + EnableDeadLetteringOnFilterEvaluationExceptions: boolean; + EnableDeadLetteringOnMessageExpiration: boolean; + LockDuration: string; + RequiresSession: boolean; + } + + interface PaginationOptions { + top: number; + skip: number; + } + + interface ICreateRuleOptions { + trueFilter: string; + falseFilter: string; + sqlExpressionFilter: string; + correlationIdFilter: string; + sqlRuleAction: string; + } + + interface ICreateNotificationHubOptions { + apns: Dictionary; + gcm: Dictionary; + mpns: Dictionary; + wns: Dictionary; + } + + export interface NotificationHubRegistration { + BodyTemplate?: any; ChannelUri?: string; DeviceToken?: string; - gcmRegistrationId?: string; - Tags?: string; - BodyTemplate?: any; - WnsHeaders?: any; - MpnsHeaders?: any; Expiry?: Date; + gcmRegistrationId?: string; + MpnsHeaders?: any; + RegistrationId: string; + Tags?: string; + WnsHeaders?: any; } - export class NotificationHubService { - new(hubName: string, endpointOrConnectionString: string, sharedAccessKeyName?: string, sharedAccessKeyValue?: string): NotificationHubService; - hubName: string; - wns: Wns.Service; - apns: Apns.Service; - gcm: Gcm.Service; - mpns: Mpns.Service; - send(tags: string, payload: Object | string, optionsOrCallback?: { headers: Object } | Callback, callback?: Callback): void; - - createOrUpdateInstallation(installation: string, options: any, callback?: Callback): void; - patchInstallation(installationId: string, partialUpdateOperations: any[], options: any, callback?: Callback): void; - deleteInstallation(installationId: string, options: any, callback?: Callback): void; - getInstallation(installationId: string, options: any, callback?: Callback): void; - - /* - // old school? - createRegistrationId(callback?: Callback): void; - getRegistration(registrationId: string, options: any, callback?: Callback): void; - deleteRegistration(registrationId: string, options?: { etag: any }, callback?: Callback): void; - updateRegistration(registration: NotificationHubRegistration, options?: { etag: any }, callback?: Callback): void; - createOrUpdateRegistration(registration: NotificationHubRegistration, options?: { etag: any }, callback?: Callback): void; - listRegistrations(options?: { top: number, skip: number }, callback?: Callback): void; - listRegistrationsByTag(tag: string, options?: { top: number, skip: number }, callback?: Callback): void; - */ + export interface Response { + body: Dictionary; + headers: Dictionary; + isSuccessful: boolean; + md5?: string; + statusCode: number; } - export module Apns { - interface Payload { - expiry?: Date; - aps?: Object; - badge?: number; - alert?: string; - sound?: string; - payload: Object; + export interface ErrorResponse extends Response { + body: { + Error: { + Code: string; + Detail: string; + }; + }; + } + + export namespace Results.Models { + export enum EntityStatus { + Active = 'Active', + Creating = 'Creating', + Deleting = 'Deleting', + Disabled = 'Disabled', + ReceiveDisabled = 'ReceiveDisabled', + Renaming = 'Renaming', + Restoring = 'Restoring', + SendDisabled = 'SendDisabled', + Unknown = 'Unknown' } - interface Service { - new(service: NotificationHubService): Service; - send(tags: string | string[], payload: Apns.Payload, callback?: Callback): void; - createNativeRegistration(token: string, tags: string | string[], optionsOrCallback?: Object | Callback, callback?: Callback): void; - createOrUpdateNativeRegistration(registrationId: string, token: string, tags: string | string[], optionsOrCallback?: Object | Callback, callback?: Callback): void; - createTemplateRegistration(token: string, tags: string | string[], template: Apns.Payload, optionsOrCallback?: Object | Callback, callback?: Callback): void; - createOrUpdateTemplateRegistration(registrationId: string, token: string, tags: string | string[], template: Apns.Payload, optionsOrCallback?: Object | Callback, callback?: Callback): void; - updateTemplateRegistration(registrationId: string, token: string, tags: string | string[], template: Apns.Payload, optionsOrCallback?: Object | Callback, callback?: Callback): void; - listRegistrationsByToken(token: string, optionsOrCallback?: { top: number, skip: number } | Callback, callback?: Callback): void; + export enum EntityAvailabilityStatus { + Available = 'Available', + Limited = 'Limited', + Renaming = 'Renaming', + Restoring = 'Restoring', + Unknown = 'Unknown' } - } - export module Gcm { - interface Service { - new(service: NotificationHubService): Service; - send(tags: string | string[], payload: any, callback?: Callback): void; - createNativeRegistration(gcmRegistrationId: string, tags: string | string[], optionsOrCallback?: Object | Callback, callback?: Callback): void; - createOrUpdateNativeRegistration(registrationId: string, gcmRegistrationId: string, tags: string | string[], optionsOrCallback?: Object | Callback, callback?: Callback): void; - createTemplateRegistration(gcmRegistrationId: string, tags: string | string[], template: any, optionsOrCallback?: Object | Callback, callback?: Callback): void; - createOrUpdateTemplateRegistration(registrationId: string, gcmRegistrationId: string, tags: string | string[], template: any, optionsOrCallback?: Object | Callback, callback?: Callback): void; - updateTemplateRegistration(registrationId: string, gcmRegistrationId: string, tags: string | string[], template: any, optionsOrCallback?: Object | Callback, callback?: Callback): void; - listRegistrationsByGcmRegistrationId(gcmRegistrationId: string, optionsOrCallback?: { top: number, skip: number } | Callback, callback?: Callback): void; + + interface Base { + _: { + ContentRootElement: string; + id: string; + title: string; + published: DateString; + updated: DateString; + author?: { + name: string; + }; + link: string; + }; + CreatedAt: DateString; + } + + interface ExtendedBase extends Base { + AuthorizationRules: string; + AutoDeleteOnIdle: string; + DefaultMessageTimeToLive: string; + DuplicateDetectionHistoryTimeWindow: Duration; + EnableBatchedOperations: string; + EnableExpress: string; + EnablePartitioning: string; + EntityAvailabilityStatus: string; + IsAnonymousAccessible: string; + MaxSizeInMegabytes: string; + RequiresDuplicateDetection: string; + SizeInBytes: string; + Status: EntityStatus; + UpdatedAt: DateString; + } + + // export interface Generic extends Base { + // [x: string]: string | Dictionary; + // } + + export interface Topic extends ExtendedBase { + AccessedAt: DateString; + CountDetails: { + 'd2p1:ActiveMessageCount': string; + 'd2p1:DeadLetterMessageCount': string; + 'd2p1:ScheduledMessageCount': string; + 'd2p1:TransferMessageCount': string; + 'd2p1:TransferDeadLetterMessageCount': string; + }; + EnableSubscriptionPartitioning: string; + FilteringMessagesBeforePublishing: string; + IsExpress: string; + SubscriptionCount: string; + SupportOrdering: string; + TopicName: string; + } + + export interface Queue extends ExtendedBase { + DeadLetteringOnMessageExpiration: string; + LockDuration: Duration; + MaxDeliveryCount: string; + MessageCount: string; + QueueName: string; + RequiresSession: string; + SupportOrdering: string; + } + + export interface Subscription extends ExtendedBase { + CountDetails: { + 'd3p1:ActiveMessageCount': string; + 'd3p1:DeadLetterMessageCount': string; + 'd3p1:ScheduledMessageCount': string; + 'd3p1:TransferMessageCount': string; + 'd3p1:TransferDeadLetterMessageCount': string; + }; + DeadLetteringOnFilterEvaluationExceptions: string; + DeadLetteringOnMessageExpiration: string; + LockDuration: string; + MaxDeliveryCount: string; + MessageCount: string; + RequiresSession: string; + SubscriptionName: string; + TopicName: string; + } + + /** + * @see https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter + */ + interface SqlFilter { + readonly CompatibilityLevel: string; + Parameters?: Dictionary; + RequiresPreprocessing?: string; + SqlExpression: string; + } + + type CorrelationFilter = Partial<{ + ContentType: string; + CorrelationId: string; + Label: string; + Properties: string; + ReplyTo: string; + ReplyToSessionId: string; + RequiresPreprocessing: string; + SessionId: string; + To: string; + }>; + + export interface Rule extends Base { + Action: string | SqlFilter; + Filter: SqlFilter | CorrelationFilter; + Name: string; + TopicName: string; + SubscriptionName: string; + RuleName: string; } } - export module Mpns { interface Service { } } + /* + * Callbacks + */ + export type ResponseCallback = (error: Error | null, response: Response) => void; - export module Wns { - interface Payload { - text1?: string; - text2?: string; - text3?: string; - text4?: string; - image1src?: string; - image1alt?: string; - image2src?: string; - image2alt?: string; - image3src?: string; - image3alt?: string; - image4src?: string; - image4alt?: string; - lang?: string; - type?: string; - } + export type ResultAndResponseCallback = (error: Error | null, + result: boolean | Results.Models.Base | Results.Models.Base[], + response: Response) => void; - interface Options { - headers: Object; - } + export type TypedResultAndResponseCallback = (error: Error | null, + result: T, + response: Response) => void; - interface Service { - new(service: NotificationHubService): Service; - sendTileSquareBlock(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquareText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquareText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquareText03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquareText04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText05(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText06(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText07(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText08(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText09(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText10(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideText11(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquareImage(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquarePeekImageAndText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquarePeekImageAndText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquarePeekImageAndText03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileSquarePeekImageAndText04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideImage(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideImageCollection(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideImageAndText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideImageAndText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideBlockAndText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideBlockAndText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideSmallImageAndText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideSmallImageAndText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideSmallImageAndText03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideSmallImageAndText04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWideSmallImageAndText05(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageCollection01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageCollection02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageCollection03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageCollection04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageCollection05(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageCollection06(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageAndText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImageAndText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImage01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImage02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImage03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImage04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImage05(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendTileWidePeekImage06(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastText03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastText04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastImageAndText01(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastImageAndText02(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastImageAndText03(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendToastImageAndText04(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - // badges = ['none','activity','alert','available','away','busy','newMessage','paused','playing','unavailable','error', 'attention'] - sendBadge(tags: string | string[], value: string | number, optionsOrCallback?: Options | Callback, callback?: Callback): void; - sendRaw(tags: string | string[], payload: any, optionsOrCallback?: Options | Callback, callback?: Callback): void; - // types = ['wns/toast', 'wns/badge', 'wns/tile', 'wns/raw'] - send(tags: string | string[], payload: string, type: string, optionsOrCallback?: Options | Callback, callback?: Callback): void; - createNativeRegistration(channel: string, tags: string | string[], optionsOrCallback?: Options | Callback, callback?: Callback): void; - createOrUpdateNativeRegistration(registrationId: string, channel: string, tags: string | string[], optionsOrCallback?: Options | Callback, callback?: Callback): void; - listRegistrationsByChannel(channel: string, optionsOrCallback?: { top: number, skip: number } | Callback, callback?: Callback): void; - } - } + /* + * Options interfaces with all properties as optional + */ + export type BrokerProperties = Partial; + export type BrokerPropertiesResponse = IBrokerPropertiesResponse & Partial; + export type CreateQueueOptions = Partial; + export type CreateTopicOptions = Partial; + export type CreateTopicIfNotExistsOptions = Partial; + export type CreateSubscriptionOptions = Partial; + export type ListSubscriptionsOptions = Partial; + export type ListRulesOptions = Partial; + export type CreateRuleOptions = Partial; + export type CreateNotificationHubOptions = Partial; + export type ListNotificationHubsOptions = Partial; + + export type MessageOrName = Message | string; } diff --git a/types/azure-sb/lib/apnsservice.d.ts b/types/azure-sb/lib/apnsservice.d.ts new file mode 100644 index 0000000000..05ca2f7b43 --- /dev/null +++ b/types/azure-sb/lib/apnsservice.d.ts @@ -0,0 +1,83 @@ +import { Azure } from '../index'; +import NotificationHubService = require('azure-sb/lib/notificationhubservice'); +import ResponseCallback = Azure.ServiceBus.ResponseCallback; +import NotificationHubRegistration = Azure.ServiceBus.NotificationHubRegistration; +import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions; +import Dictionary = Azure.ServiceBus.Dictionary; + +type Template = Partial<{ + expiry: Date; + aps: object; + badge: number; + alert: string; + sound: string; + payload: object; +}>; + +declare class ApnsService { + constructor(notificationHubService: NotificationHubService); + + public notificationHubService: NotificationHubService; + + public send(tags: string | string[], + payload: object | string, + callback: ResponseCallback): void; + + public send(tags: string | string[], + payload: object | string, + options: { headers: Dictionary }, + callback: ResponseCallback): void; + + public createNativeRegistration(token: string, + tags: string | string[], + callback: ResponseCallback): void; + + public createNativeRegistration(token: string, + tags: string | string[], + options: object, + callback: ResponseCallback): void; + + public createOrUpdateNativeRegistration(registrationId: string, + token: string, + tags: string | string[], + callback: ResponseCallback): void; + + public createOrUpdateNativeRegistration(registrationId: string, + token: string, + tags: string | string[], + options: object, + callback: ResponseCallback): void; + + public createTemplateRegistration(token: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public createTemplateRegistration(token: string, + tags: string | string[], + template: Template | string, + options: object, + callback: ResponseCallback): void; + + public updateTemplateRegistration(registrationId: string, + token: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public updateTemplateRegistration(registrationId: string, + token: string, + tags: string | string[], + template: Template | string, + options: { headers: Dictionary }, + callback: ResponseCallback): void; + + public listRegistrationsByToken(token: string, + callback: ResponseCallback): void; + + public listRegistrationsByToken(token: string, + options: ListNotificationHubsOptions, + callback: ResponseCallback): void; +} + +export = ApnsService; diff --git a/types/azure-sb/lib/gcmservice.d.ts b/types/azure-sb/lib/gcmservice.d.ts new file mode 100644 index 0000000000..4d1c8f203c --- /dev/null +++ b/types/azure-sb/lib/gcmservice.d.ts @@ -0,0 +1,71 @@ +import { Azure } from '../index'; +import NotificationHubService = require('azure-sb/lib/notificationhubservice'); +import ResponseCallback = Azure.ServiceBus.ResponseCallback; +import NotificationHubRegistration = Azure.ServiceBus.NotificationHubRegistration; +import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions; +import Dictionary = Azure.ServiceBus.Dictionary; + +type Template = Partial<{}>; + +declare class GcmService { + constructor(notificationHubService: NotificationHubService); + + public notificationHubService: NotificationHubService; + + public send(tags: string | string[], + payload: object | string, + callback: ResponseCallback): void; + + public createNativeRegistration(gcmRegistrationId: string, + tags: string | string[], + callback: ResponseCallback): void; + + public createNativeRegistration(token: string, + tags: string | string[], + options: object, + callback: ResponseCallback): void; + + public createOrUpdateNativeRegistration(registrationId: string, + gcmRegistrationId: string, + tags: string | string[], + callback: ResponseCallback): void; + + public createOrUpdateNativeRegistration(registrationId: string, + gcmRegistrationId: string, + tags: string | string[], + options: object, + callback: ResponseCallback): void; + + public createTemplateRegistration(gcmRegistrationId: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public createTemplateRegistration(gcmRegistrationId: string, + tags: string | string[], + template: Template | string, + options: object, + callback: ResponseCallback): void; + + public updateTemplateRegistration(registrationId: string, + gcmRegistrationId: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public updateTemplateRegistration(registrationId: string, + gcmRegistrationId: string, + tags: string | string[], + template: Template | string, + options: { headers: Dictionary }, + callback: ResponseCallback): void; + + public listRegistrationsByGcmRegistrationId(gcmRegistrationId: string, + callback: ResponseCallback): void; + + public listRegistrationsByGcmRegistrationId(gcmRegistrationId: string, + options: ListNotificationHubsOptions, + callback: ResponseCallback): void; +} + +export = GcmService; diff --git a/types/azure-sb/lib/models/acstokenresult.d.ts b/types/azure-sb/lib/models/acstokenresult.d.ts new file mode 100644 index 0000000000..531c606de1 --- /dev/null +++ b/types/azure-sb/lib/models/acstokenresult.d.ts @@ -0,0 +1,29 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Azure } from 'azure-sb'; +import Dictionary = Azure.ServiceBus.Dictionary; + +export namespace Azure.ServiceBus.Results { + export interface AcsTokenResponse extends Dictionary> { + WrapAccessToken: Dictionary; + WrapAccessTokenExpiresIn: Dictionary; + } + + export interface AcsTokenResult { + parse(acsTokenQueryString: string): AcsTokenResponse; + } +} diff --git a/types/azure-sb/lib/models/notificationhubresult.d.ts b/types/azure-sb/lib/models/notificationhubresult.d.ts new file mode 100644 index 0000000000..1aef66c3d6 --- /dev/null +++ b/types/azure-sb/lib/models/notificationhubresult.d.ts @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Azure } from 'azure-sb'; +import Dictionary = Azure.ServiceBus.Dictionary; + +export namespace Azure.ServiceBus.Results { + export interface NotificationHubResult { + serialize(resource: Azure.ServiceBus.CreateNotificationHubOptions): string; + + parse(xml: object): object | object[]; + } +} diff --git a/types/azure-sb/lib/models/queuemessageresult.d.ts b/types/azure-sb/lib/models/queuemessageresult.d.ts new file mode 100644 index 0000000000..a50d0965cb --- /dev/null +++ b/types/azure-sb/lib/models/queuemessageresult.d.ts @@ -0,0 +1,40 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Module dependencies. +import { Azure } from 'azure-sb'; +import Dictionary = Azure.ServiceBus.Dictionary; + +export namespace Azure.ServiceBus.Results { + export interface QueueResponse { + body: any; + headers: Dictionary + } + + export interface QueueMessageResponse { + body: any; + brokerProperties?: Azure.ServiceBus.BrokerProperties; + customProperties?: Dictionary; + contentType?: string; + location?: string; + } + + export interface QueueMessageResult { + parse(responseObject: object): QueueMessageResponse; + + isRFC1123(value: string | any): boolean; + } +} diff --git a/types/azure-sb/lib/models/queueresult.d.ts b/types/azure-sb/lib/models/queueresult.d.ts new file mode 100644 index 0000000000..abeed96dff --- /dev/null +++ b/types/azure-sb/lib/models/queueresult.d.ts @@ -0,0 +1,41 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Azure } from 'azure-sb'; +import Dictionary = Azure.ServiceBus.Dictionary; + +export namespace Azure.ServiceBus.Results { + export interface QueueProperties { + DeadLetteringOnMessageExpiration: string; + DefaultMessageTimeToLive: string; + DuplicateDetectionHistoryTimeWindow: string; + EnableBatchedOperations: boolean; + EnablePartitioning: boolean; + LockDuration: string; + MaxDeliveryCount: number; + MaxSizeInMegabytes: number; + MessageCount: number; + RequiresDuplicateDetection: boolean; + RequiresSession: boolean; + SizeInBytes: number; + } + + export interface QueueResult { + serialize(resource: QueueProperties): string; + + parse(xml: object): object | object[]; + } +} diff --git a/types/azure-sb/lib/models/registrationresult.d.ts b/types/azure-sb/lib/models/registrationresult.d.ts new file mode 100644 index 0000000000..81c1fdd824 --- /dev/null +++ b/types/azure-sb/lib/models/registrationresult.d.ts @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Azure } from 'azure-sb'; +import Dictionary = Azure.ServiceBus.Dictionary; + +export namespace Azure.ServiceBus.Results { + export interface RegistrationResult { + serialize(type: string, resource: object, properties: string[]): string; + + parse(xml: object): object | object[]; + } +} diff --git a/types/azure-sb/lib/models/resourceresult.d.ts b/types/azure-sb/lib/models/resourceresult.d.ts new file mode 100644 index 0000000000..b9654b0438 --- /dev/null +++ b/types/azure-sb/lib/models/resourceresult.d.ts @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Azure } from 'azure-sb'; +import Dictionary = Azure.ServiceBus.Dictionary; + +export namespace Azure.ServiceBus.Results { + export interface ResourceResult { + setName(entry: Dictionary | { _: { id: string } }, nameProperty: string): void; + + serialize(resourceName: string, resource: object, properties: string[]): string; + + parse(resourceName: string, nameProperty: string, xml: object): object | object[]; + } +} diff --git a/types/azure-sb/lib/models/ruleresult.d.ts b/types/azure-sb/lib/models/ruleresult.d.ts new file mode 100644 index 0000000000..369a4ddeb7 --- /dev/null +++ b/types/azure-sb/lib/models/ruleresult.d.ts @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Module dependencies. +import { Azure } from 'azure-sb'; + +export namespace Azure.ServiceBus.Results { + export interface RuleResult { + serialize(rule: Azure.ServiceBus.CreateRuleOptions): string; + + parse(xml: object): object | object[]; + } +} diff --git a/types/azure-sb/lib/models/subscriptionresult.d.ts b/types/azure-sb/lib/models/subscriptionresult.d.ts new file mode 100644 index 0000000000..003c085da0 --- /dev/null +++ b/types/azure-sb/lib/models/subscriptionresult.d.ts @@ -0,0 +1,37 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Azure } from 'azure-sb'; + +export namespace Azure.ServiceBus.Results { + export interface SubscriptionProperties { + LockDuration: string; + RequiresSession: boolean; + DefaultMessageTimeToLive: string; + DeadLetteringOnMessageExpiration: string; + DeadLetteringOnFilterEvaluationExceptions: string; + MessageCount: number; + MaxDeliveryCount: number; + EnableBatchedOperations: boolean; + AutoDeleteOnIdle: boolean; + } + + export interface SubscriptionResult { + serialize(resource: SubscriptionProperties): string; + + parse(xml: object): object | object[]; + } +} diff --git a/types/azure-sb/lib/models/topicresult.d.ts b/types/azure-sb/lib/models/topicresult.d.ts new file mode 100644 index 0000000000..7f20125b51 --- /dev/null +++ b/types/azure-sb/lib/models/topicresult.d.ts @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +export namespace Azure.ServiceBus.Results { + export interface TopicProperties { + DefaultMessageTimeToLive: string; + MaxSizeInMegabytes: number; + RequiresDuplicateDetection: boolean; + DuplicateDetectionHistoryTimeWindow: string; + EnableBatchedOperations: boolean; + SizeInBytes: number; + SupportOrdering: boolean; + EnablePartitioning: boolean; + } +} + +export function serialize(resource: Azure.ServiceBus.Results.TopicProperties): string; + +export function parse(xml: object): object | object[]; diff --git a/types/azure-sb/lib/mpnservice.d.ts b/types/azure-sb/lib/mpnservice.d.ts new file mode 100644 index 0000000000..d476f4d984 --- /dev/null +++ b/types/azure-sb/lib/mpnservice.d.ts @@ -0,0 +1,116 @@ +import { Azure } from '../index'; +import NotificationHubService = require('azure-sb/lib/notificationhubservice'); +import ResponseCallback = Azure.ServiceBus.ResponseCallback; +import NotificationHubRegistration = Azure.ServiceBus.NotificationHubRegistration; +import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions; +import Dictionary = Azure.ServiceBus.Dictionary; + +type Template = TileTemplate | FlipTileTemplate | ToastTemplate; + +interface TileTemplate { + backgroundImage: string; + count: string; + title: string; + backBackgroundImage: string; + backTitle: string; + backContent: string; + id: string; +} + +interface FlipTileTemplate extends TileTemplate { + smallBackgroundImage: string; + wideBackgroundImage: string; + wideBackContent: string; + wideBackBackgroundImage: string; +} + +interface ToastTemplate { + text1: string; + text2: string; + param?: string; +} + +declare class MpnsService { + constructor(notificationHubService: NotificationHubService); + + public notificationHubService: NotificationHubService; + + public send(tags: string | string[], + payload: object | string, + targetName: string, + notificationClass: string, + callback: ResponseCallback): void; + + public send(tags: string | string[], + payload: object | string, + targetName: string, + notificationClass: string, + options: { headers: Dictionary }, + callback: ResponseCallback): void; + + public createNativeRegistration(channel: string, + tags: string | string[], + callback: ResponseCallback): void; + + public createNativeRegistration(channel: string, + tags: string | string[], + options: object, + callback: ResponseCallback): void; + + public createOrUpdateNativeRegistration(registrationId: string, + channel: string, + tags: string | string[], + callback: ResponseCallback): void; + + public createOrUpdateNativeRegistration(registrationId: string, + channel: string, + tags: string | string[], + options: object, + callback: ResponseCallback): void; + + public createRawTemplateRegistration(channel: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public createRawTemplateRegistration(channel: string, + tags: string | string[], + template: Template | string, + options: object, + callback: ResponseCallback): void; + + public createOrUpdateRawTemplateRegistration(registrationId: string, + channel: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public createOrUpdateRawTemplateRegistration(registrationId: string, + channel: string, + tags: string | string[], + template: Template | string, + options: object, + callback: ResponseCallback): void; + + public updatesRawTemplateRegistration(registrationId: string, + channel: string, + tags: string | string[], + template: Template | string, + callback: ResponseCallback): void; + + public updatesRawTemplateRegistration(registrationId: string, + channel: string, + tags: string | string[], + template: Template | string, + options: object, + callback: ResponseCallback): void; + + public listRegistrationsByChannel(channel: string, + callback: ResponseCallback): void; + + public listRegistrationsByChannel(channel: string, + options: ListNotificationHubsOptions, + callback: ResponseCallback): void; +} + +export = MpnsService; diff --git a/types/azure-sb/lib/notificationhubservice.d.ts b/types/azure-sb/lib/notificationhubservice.d.ts new file mode 100644 index 0000000000..d56b53d9d5 --- /dev/null +++ b/types/azure-sb/lib/notificationhubservice.d.ts @@ -0,0 +1,102 @@ +import { Azure } from 'azure-sb'; +import Callback = Azure.ServiceBus.ResponseCallback; +import NotificationHubRegistration = Azure.ServiceBus.NotificationHubRegistration; +import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions; + +import ApnsService = require('./apnsservice'); +import GcmService = require('./gcmservice'); +import MpnsService = require('./mpnservice'); +import WnsService = require('./wnsservice'); + +declare class NotificationHubService { + constructor(hubName: string, + endpointOrConnectionString: string, + sharedAccessKeyName: string, + sharedAccessKeyValue: string); + + public hubName: string; + public wns: WnsService; + public apns: ApnsService; + public gcm: GcmService; + public mpns: MpnsService; + + public send(tags: string, + payload: object | string, + callback: Callback): void; + + public send(tags: string, + payload: object | string, + options: { headers: object }, + callback: Callback): void; + + public createOrUpdateInstallation(installation: string, + callback: Callback): void; + + public createOrUpdateInstallation(installation: string, + options: any, + callback: Callback): void; + + public patchInstallation(installationId: string, + partialUpdateOperations: any[], + callback: Callback): void; + + public patchInstallation(installationId: string, + partialUpdateOperations: any[], + options: any, + callback: Callback): void; + + public deleteInstallation(installationId: string, + callback: Callback): void; + + public deleteInstallation(installationId: string, + options: any, + callback: Callback): void; + + public getInstallation(installationId: string, + callback: Callback): void; + + public getInstallation(installationId: string, + options: any, + callback: Callback): void; + + public createRegistrationId(callback: Callback): void; + + public getRegistration(registrationId: string, + callback: Callback): void; + + public getRegistration(registrationId: string, + options: any, + callback: Callback): void; + + public deleteRegistration(registrationId: string, + callback: Callback): void; + + public deleteRegistration(registrationId: string, + options: { etag: any }, + callback: Callback): void; + + public updateRegistration(registration: NotificationHubRegistration, + callback: Callback): void; + + public updateRegistration(registration: NotificationHubRegistration, + options: { etag: any }, + callback: Callback): void; + + public createOrUpdateRegistration(registration: NotificationHubRegistration, + options: { etag: any }, + callback: Callback): void; + + public listRegistrations(callback: Callback): void; + + public listRegistrations(options: ListNotificationHubsOptions, + callback: Callback): void; + + public listRegistrationsByTag(tag: string, + callback: Callback): void; + + public listRegistrationsByTag(tag: string, + options: ListNotificationHubsOptions, + callback: Callback): void; +} + +export = NotificationHubService; diff --git a/types/azure-sb/lib/servicebusservice.d.ts b/types/azure-sb/lib/servicebusservice.d.ts new file mode 100644 index 0000000000..44f2b2c522 --- /dev/null +++ b/types/azure-sb/lib/servicebusservice.d.ts @@ -0,0 +1,206 @@ +import { Azure } from '../index'; + +import ServiceBusServiceBase = require('./servicebusservicebase'); + +import CreateNotificationHubOptions = Azure.ServiceBus.CreateNotificationHubOptions; +import CreateQueueOptions = Azure.ServiceBus.CreateQueueOptions; +import CreateRuleOptions = Azure.ServiceBus.CreateRuleOptions; +import CreateSubscriptionOptions = Azure.ServiceBus.CreateSubscriptionOptions; +import CreateTopicIfNotExistsOptions = Azure.ServiceBus.CreateTopicIfNotExistsOptions; +import CreateTopicOptions = Azure.ServiceBus.CreateTopicOptions; +import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions; +import ListRulesOptions = Azure.ServiceBus.ListRulesOptions; +import ListSubscriptionsOptions = Azure.ServiceBus.ListSubscriptionsOptions; +import MessageOrName = Azure.ServiceBus.MessageOrName; +import Queue = Azure.ServiceBus.Results.Models.Queue; +import ReceiveQueueMessageOptions = Azure.ServiceBus.ReceiveQueueMessageOptions; +import ReceiveSubscriptionMessageOptions = Azure.ServiceBus.ReceiveSubscriptionMessageOptions; +import ResponseCallback = Azure.ServiceBus.ResponseCallback; +import ResultAndResponseCallback = Azure.ServiceBus.ResultAndResponseCallback; +import Rule = Azure.ServiceBus.Results.Models.Rule; +import Subscription = Azure.ServiceBus.Results.Models.Subscription; +import Topic = Azure.ServiceBus.Results.Models.Topic; +import TypedResultAndResponseCallback = Azure.ServiceBus.TypedResultAndResponseCallback; +import Message = Azure.ServiceBus.Message; + +declare class ServiceBusService extends ServiceBusServiceBase { + constructor(configOrNamespaceOrConnectionString?: string, + accessKey?: string, + issuer?: string, + acsNamespace?: string, + host?: string, + authenticationProvider?: object); + + public receiveQueueMessage(queuePath: string, + callback: TypedResultAndResponseCallback): void; + + public receiveQueueMessage(queuePath: string, + options: ReceiveQueueMessageOptions, + callback: TypedResultAndResponseCallback): void; + + public receiveSubscriptionMessage(topicPath: string, + subscriptionPath: string, + callback: TypedResultAndResponseCallback): void; + + public receiveSubscriptionMessage(topicPath: string, + subscriptionPath: string, + options: ReceiveSubscriptionMessageOptions, + callback: TypedResultAndResponseCallback): void; + + public deleteMessage(message: MessageOrName, + callback: ResponseCallback): void; + + public unlockMessage(message: MessageOrName, + callback: ResponseCallback): void; + + public renewLockForMessage(message: MessageOrName, + callback: ResponseCallback): void; + + public sendQueueMessage(queuePath: string, + message: MessageOrName, + callback: ResponseCallback): void; + + public sendTopicMessage(topicPath: string, + message: MessageOrName, + callback: ResponseCallback): void; + + /* + * Queue Management functions + */ + + public createQueue(queuePath: string, + callback: TypedResultAndResponseCallback): void; + + public createQueue(queuePath: string, + options: CreateQueueOptions, + callback: TypedResultAndResponseCallback): void; + + public createQueueIfNotExists(queuePath: string, + callback: TypedResultAndResponseCallback): void; + + public createQueueIfNotExists(queuePath: string, + options: CreateQueueOptions, + callback: TypedResultAndResponseCallback): void; + + public deleteQueue(queuePath: string, + callback: ResponseCallback): void; + + public getQueue(queuePath: string, + callback: TypedResultAndResponseCallback): void; + + public listQueues(queuePath: string, + callback: TypedResultAndResponseCallback): void; + + /* + * Topic Management functions + */ + + public createTopic(topicPath: string, + callback: TypedResultAndResponseCallback): void; + + public createTopic(topicPath: string, + options: CreateTopicOptions, + callback: TypedResultAndResponseCallback): void; + + public createTopicIfNotExists(topicPath: string, + callback: TypedResultAndResponseCallback): void; + + public createTopicIfNotExists(topicPath: string, + options: CreateTopicIfNotExistsOptions, + callback: TypedResultAndResponseCallback): void; + + public deleteTopic(topicPath: string, + callback: ResponseCallback): void; + + public getTopic(topicPath: string, + callback: TypedResultAndResponseCallback): void; + + public listTopics(topicPath: string, + callback: TypedResultAndResponseCallback): void; + + /* + * Subscription functions + */ + + public createSubscription(topicPath: string, + subscriptionPath: string, + callback: TypedResultAndResponseCallback): void; + + public createSubscription(topicPath: string, + subscriptionPath: string, + options: CreateSubscriptionOptions, + callback: TypedResultAndResponseCallback): void; + + public deleteSubscription(topicPath: string, + subscriptionPath: string, + callback: ResponseCallback): void; + + public getSubscription(topicPath: string, + subscriptionPath: string, + callback: TypedResultAndResponseCallback): void; + + public listSubscriptions(topicPath: string, + callback: TypedResultAndResponseCallback): void; + + public listSubscriptions(topicPath: string, + options: ListSubscriptionsOptions, + callback: TypedResultAndResponseCallback): void; + + /* + * Rule functions + */ + + public createRule(topicPath: string, + subscriptionPath: string, + rulePath: string, + callback: TypedResultAndResponseCallback): void; + + public createRule(topicPath: string, + subscriptionPath: string, + rulePath: string, + options: CreateRuleOptions, + callback: TypedResultAndResponseCallback): void; + + public deleteRule(topicPath: string, + subscriptionPath: string, + rulePath: string, + callback: ResponseCallback): void; + + public getRule(topicPath: string, + subscriptionPath: string, + rulePath: string, + callback: TypedResultAndResponseCallback): void; + + public listRules(topicPath: string, + subscriptionPath: string, + callback: TypedResultAndResponseCallback): void; + + public listRules(topicPath: string, + subscriptionPath: string, + options: ListRulesOptions, + callback: TypedResultAndResponseCallback): void; + + /* + * NotificationHub functions + */ + + public createNotificationHub(hubPath: string, + callback: ResultAndResponseCallback): void; + + public createNotificationHub(hubPath: string, + options: CreateNotificationHubOptions, + callback: ResultAndResponseCallback): void; + + public getNotificationHub(hubPath: string, + callback: ResultAndResponseCallback): void; + + public listNotificationHubs(callback: ResultAndResponseCallback): void; + + public listNotificationHubs(options: ListNotificationHubsOptions, + callback: ResultAndResponseCallback): void; + + public deleteNotificationHub(hubPath: string, + callback: ResponseCallback): void; +} + +export = ServiceBusService; diff --git a/types/azure-sb/lib/servicebusservicebase.d.ts b/types/azure-sb/lib/servicebusservicebase.d.ts new file mode 100644 index 0000000000..c29ead478c --- /dev/null +++ b/types/azure-sb/lib/servicebusservicebase.d.ts @@ -0,0 +1,12 @@ +import ServiceBusServiceClient = require('azure-sb/lib/servicebusserviceclient'); + +declare class ServiceBusServiceBase extends ServiceBusServiceClient { + constructor(configOrNamespaceOrConnectionString: string, + accessKey?: string, + issuer?: string, + acsNamespace?: string, + host?: string, + authenticationProvider?: object); +} + +export = ServiceBusServiceBase; diff --git a/types/azure-sb/lib/servicebusserviceclient.d.ts b/types/azure-sb/lib/servicebusserviceclient.d.ts new file mode 100644 index 0000000000..c97b1e3107 --- /dev/null +++ b/types/azure-sb/lib/servicebusserviceclient.d.ts @@ -0,0 +1,14 @@ +/// +import EventEmitter = NodeJS.EventEmitter; + +declare class ServiceBusServiceClient extends EventEmitter { + constructor(accessKey?: string, + issuer?: string, + sharedAccessKeyName?: string, + sharedAccessKeyValue?: string, + host?: string, + acsHost?: string, + authenticationProvider?: object); +} + +export = ServiceBusServiceClient; diff --git a/types/azure-sb/lib/wnsservice.d.ts b/types/azure-sb/lib/wnsservice.d.ts new file mode 100644 index 0000000000..1fef2da042 --- /dev/null +++ b/types/azure-sb/lib/wnsservice.d.ts @@ -0,0 +1,377 @@ +import NotificationHubService = require('azure-sb/lib/notificationhubservice'); +import Callback = Azure.ServiceBus.ResponseCallback; +import { Azure } from 'azure-sb'; +import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions; +import Dictionary = Azure.ServiceBus.Dictionary; + +type Payload = Partial<{ + text1: string; + text2: string; + text3: string; + text4: string; + image1src: string; + image1alt: string; + image2src: string; + image2alt: string; + image3src: string; + image3alt: string; + image4src: string; + image4alt: string; + lang: string; + type: string; +}>; + +interface Options { + headers: Dictionary; +} + +type badges = + 'none' + | 'activity' + | 'alert' + | 'available' + | 'away' + | 'busy' + | 'newMessage' + | 'paused' + | 'playing' + | 'unavailable' + | 'error' + | 'attention'; + +type types = 'wns/toast' | 'wns/badge' | 'wns/tile' | 'wns/raw'; + +declare class WnsService { + constructor(service: NotificationHubService); + + public notificationHubService: NotificationHubService; + + sendTileSquareBlock(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquareText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquareText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquareText03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquareText04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText05(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText06(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText07(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText08(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText09(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText10(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideText11(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquareImage(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquarePeekImageAndText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquarePeekImageAndText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquarePeekImageAndText03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileSquarePeekImageAndText04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideImage(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideImageCollection(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideImageAndText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideImageAndText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideBlockAndText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideBlockAndText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideSmallImageAndText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideSmallImageAndText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideSmallImageAndText03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideSmallImageAndText04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWideSmallImageAndText05(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageCollection01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageCollection02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageCollection03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageCollection04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageCollection05(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageCollection06(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageAndText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImageAndText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImage01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImage02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImage03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImage04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImage05(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendTileWidePeekImage06(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastText03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastText04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastImageAndText01(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastImageAndText02(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastImageAndText03(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendToastImageAndText04(tags: string | string[], + payload: any, + optionsOrCallback: Options | Callback, + callback?: Callback): void; + + sendBadge(tags: badges | badges[], + value: string | number, + callback?: Callback): void; + + sendBadge(tags: badges | badges[], + value: string | number, + options: Options, + callback?: Callback): void; + + sendRaw(tags: string | string[], + payload: any, + callback?: Callback): void; + + sendRaw(tags: string | string[], + payload: any, + options: Options, + callback?: Callback): void; + + send(tags: string | string[], + payload: string, + type: types, + callback?: Callback): void; + + send(tags: string | string[], + payload: string, + type: types, + options: Options, + callback: Callback): void; + + createNativeRegistration(channel: string, + tags: string | string[], + callback: Callback): void; + + createNativeRegistration(channel: string, + tags: string | string[], + options: Options, + callback: Callback): void; + + createOrUpdateNativeRegistration(registrationId: string, + channel: string, + tags: string | string[], + callback: Callback): void; + + createOrUpdateNativeRegistration(registrationId: string, + channel: string, + tags: string | string[], + options: Options, + callback: Callback): void; + + listRegistrationsByChannel(channel: string, + callback: Callback): void; + + listRegistrationsByChannel(channel: string, + options: ListNotificationHubsOptions, + callback: Callback): void; + +} + +export = WnsService; diff --git a/types/azure-sb/lib/wrapservice.d.ts b/types/azure-sb/lib/wrapservice.d.ts new file mode 100644 index 0000000000..5fbbc87345 --- /dev/null +++ b/types/azure-sb/lib/wrapservice.d.ts @@ -0,0 +1,21 @@ +import { Azure } from 'azure-sb'; + +declare class WrapService { + constructor(acsHost: string, issuer?: string, accessKey?: string); + + public issuer?: string; + public accessKey?: string; + public authenticationProvider: { + signRequest(webResource: any, callback: () => void): void; + }; + public strictSSL: boolean; + + public wrapAccessToken(uri: string, + callback: Azure.ServiceBus.ResponseCallback): void; + + public wrapAccessToken(uri: string, + options: object, + callback: Azure.ServiceBus.ResponseCallback): void; +} + +export = WrapService; diff --git a/types/azure-sb/tsconfig.json b/types/azure-sb/tsconfig.json index 525d24577e..09c9a2a9e4 100644 --- a/types/azure-sb/tsconfig.json +++ b/types/azure-sb/tsconfig.json @@ -17,7 +17,26 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "azure-sb-tests.ts" + "lib/servicebusservice.d.ts", + "lib/wrapservice.d.ts", + "lib/servicebusservicebase.d.ts", + "lib/notificationhubservice.d.ts", + "lib/models/topicresult.d.ts", + "lib/models/queuemessageresult.d.ts", + "lib/models/acstokenresult.d.ts", + "lib/models/registrationresult.d.ts", + "lib/models/ruleresult.d.ts", + "lib/models/queueresult.d.ts", + "lib/models/subscriptionresult.d.ts", + "lib/models/notificationhubresult.d.ts", + "lib/models/resourceresult.d.ts", + "lib/servicebusserviceclient.d.ts", + "lib/gcmservice.d.ts", + "lib/wnsservice.d.ts", + "lib/mpnservice.d.ts", + "lib/apnsservice.d.ts", + "azure-sb-tests.ts", + "index.d.ts" ] -} \ No newline at end of file +} + From 335df032c70764c34be382c89e830d42b908ff20 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 4 Dec 2017 17:05:43 -0400 Subject: [PATCH 406/639] Remove react-native-elements --- notNeededPackages.json | 6 + types/react-native-elements/README.md | 26 - types/react-native-elements/index.d.ts | 2265 ----------------- .../react-native-elements-tests.tsx | 975 ------- types/react-native-elements/tsconfig.json | 25 - types/react-native-elements/tslint.json | 1 - 6 files changed, 6 insertions(+), 3292 deletions(-) delete mode 100644 types/react-native-elements/README.md delete mode 100644 types/react-native-elements/index.d.ts delete mode 100644 types/react-native-elements/react-native-elements-tests.tsx delete mode 100644 types/react-native-elements/tsconfig.json delete mode 100644 types/react-native-elements/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 0e5f946e07..2414ebea00 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -570,6 +570,12 @@ "sourceRepoURL": "https://github.com/gpbl/react-day-picker", "asOfVersion": "5.3.0" }, + { + "libraryName": "react-native-elements", + "typingsPackageName": "react-native-elements", + "sourceRepoURL": "https://github.com/react-native-training/react-native-elements", + "asOfVersion": "0.18" + }, { "libraryName": "realm", "typingsPackageName": "realm", diff --git a/types/react-native-elements/README.md b/types/react-native-elements/README.md deleted file mode 100644 index 9e3975ecdf..0000000000 --- a/types/react-native-elements/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# [React Native Elements](https://github.com/react-native-training/react-native-elements) - -### Component Checklist - -- [x] Buttons -- [x] Badge -- [x] Social Icons / Social Icon Buttons -- [x] Icons -- [x] Side Menu -- [x] Form Elements -- [x] SearchBar -- [x] ButtonGroup -- [x] CheckBoxes -- [x] List Element -- [x] Tab Bar Component -- [x] HTML style headings -- [x] Card component -- [x] Pricing Component -- [x] Grid Component -- [x] Slider Component -- [x] Tile Component -- [x] Avatar Component -- [x] Rating Component -- [x] SwipeDeck Component -- [x] Header Component -- [x] Divider diff --git a/types/react-native-elements/index.d.ts b/types/react-native-elements/index.d.ts deleted file mode 100644 index 821e9b65e7..0000000000 --- a/types/react-native-elements/index.d.ts +++ /dev/null @@ -1,2265 +0,0 @@ -// Type definitions for react-native-elements 0.16 -// Project: https://github.com/react-native-training/react-native-elements#readme -// Definitions by: Kyle Roach -// Ifiok Jr. -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 - -import * as React from 'react'; -import { - ViewStyle, - TextStyle, - Image, - ImageStyle, - ImageURISource, - TouchableWithoutFeedbackProps, - TouchableHighlightProperties, - TouchableOpacityProperties, - ViewProperties, - TextInputProperties, - TextInput, - StatusBarProperties, - KeyboardType, - KeyboardTypeIOS, - StyleProp, - GestureResponderEvent, - Animated, - TransformsStyle -} from 'react-native'; -import TabNavigator from 'react-native-tab-navigator'; - -/** - * Supports auto complete for most used types as well as any other string type. - */ -export type IconType = - | 'material' - | 'material-community' - | 'simple-line-icon' - | 'zocial' - | 'font-awesome' - | 'octicon' - | 'ionicon' - | 'foundation' - | 'evilicon' - | 'entypo' - | string; - -export interface IconObject { - name?: string; - color?: string; - size?: number; - type?: IconType; - style?: StyleProp; -} - -export interface AvatarIcon extends IconObject { - iconStyle?: StyleProp; -} - -export interface TextProps { - /** - * font size 40 - */ - h1?: boolean; - - /** - * font size 34 - */ - h2?: boolean; - - /** - * font size 28 - */ - h3?: boolean; - - /** - * font size 22 - */ - h4?: boolean; - - /** - * font family name - */ - fontFamily?: string; - - /** - * Additional styling for Text - */ - style?: StyleProp; -} - -/** - * HTML Style Headings - * - * @see https://react-native-training.github.io/react-native-elements/API/HTML_style_headings/ - */ -export class Text extends React.Component {} - -export interface AvatarProps { - /** - * Component for enclosing element (eg: TouchableHighlight, View, etc) - * - * @default TouchableOpacity - */ - component?: React.ComponentClass; - - /** - * Width for the Avatar - * - * @default 34 - */ - width?: number; - - /** - * Height for the Avatar - * - * @default 34 - */ - height?: number; - - /** - * Callback function when pressing component - */ - onPress?(): void; - - /** - * Callback function when long pressing component - */ - onLongPress?(): void; - - /** - * Styling for outer container - */ - containerStyle?: StyleProp; - - /** - * Image source - */ - source?: ImageURISource; - - /** - * Style for avatar image - */ - avatarStyle?: ImageStyle; - - /** - * Determines the shape of avatar - * - * @default false - */ - rounded?: boolean; - - /** - * Renders title in the avatar - */ - title?: string; - - /** - * Style for the title - */ - titleStyle?: StyleProp; - - /** - * Style for the view outside image or icon - */ - overlayContainerStyle?: StyleProp; - - /** - * Opacity when pressed - * - * @default 0.2 - */ - activeOpacity?: number; - - /** - * Icon for the avatar - */ - icon?: AvatarIcon; - - /** - * extra styling for icon component - */ - iconStyle?: StyleProp; - - /** - * Small sized icon - */ - small?: boolean; - - /** - * Medium sized icon - */ - medium?: boolean; - - /** - * Large sized icon - */ - large?: boolean; - - /** - * Extra-large sized icon - */ - xlarge?: boolean; -} - -/** - * Avatar Component - * - * @see https://react-native-training.github.io/react-native-elements/API/avatar/ - */ -export class Avatar extends React.Component {} - -export interface ButtonIcon extends IconObject { - buttonStyle?: StyleProp; -} - -export interface ButtonProps extends TouchableWithoutFeedbackProps { - /** - * Specify other component such as TouchableOpacity or other - * - * @default TouchableHighlight (iOS), TouchableNativeFeedback (android) - */ - component?: React.ComponentClass; - - /** - * Additional styling for button component - * - * @default null - */ - buttonStyle?: StyleProp; - - /** - * Button title - */ - title: string; - - /** - * Makes button large - * - * @default false - */ - large?: boolean; - - /** - * Specify different font family - * - * @default System font (iOS), Sans Serif (android) - */ - fontFamily?: string; - - /** - * Specify font weight for title - * - * @default null - */ - fontWeight?: string; - - /** - * Icon configuration for icon on right side of title - */ - iconRight?: ButtonIcon; - - /** - * onPress method - */ - onPress(): void; - - /** - * onLongPress method - */ - onLongPress?(): void; - - /** - * Icon configuration - */ - icon?: ButtonIcon; - - /** - * Specify other icon component instead of default. The component will have all values from the icon prop - * - * @default MaterialIcon - * @see https://github.com/oblador/react-native-vector-icons#icon-component - */ - iconComponent?: JSX.Element; - - /** - * Background color of button - * - * @default #397af8 - */ - backgroundColor?: string; - - /** - * Adds border radius to button - * (Note: if you set this, don't forget to also set borderRadius to containerViewStyle prop, otherwise unexpected behaviour might occur) - * - * @default 0 - */ - borderRadius?: number; - - /** - * Font color - * - * @default #fff - */ - color?: string; - - /** - * Text styling - * - * @default null - */ - textStyle?: StyleProp; - - /** - * Font size - * - * @default 18 - */ - fontSize?: number; - - /** - * Underlay color for button press - * - * @default transparent - */ - underlayColor?: string; - - /** - * Flag to add raised button styling - * - * @default false - */ - raised?: boolean; - - /** - * Indicates button is disabled - * - * @default false - */ - disabled?: boolean; - - /** - * Disabled button styling - * - * @default null - */ - disabledStyle?: StyleProp; - - /** - * Styling for Component container - * - * @default null - */ - containerViewStyle?: StyleProp; - - /** - * Styling for loading spinner - * - * @default null - */ - activityIndicatorStyle?: StyleProp; - - /** - * Display a loading spinner - * - * @default false - */ - loading?: boolean; - - /** - * Display the spinner to the right - * - * @default false - */ - loadingRight?: boolean; -} - -/** - * Button component - * - * @see https://react-native-training.github.io/react-native-elements/API/buttons/ - */ -export class Button extends React.Component {} - -export interface BadgeProps { - /** - * Text value to be displayed by badge - * - * @default null - */ - value?: string | number; - - /** - * Style for the outer badge component - */ - containerStyle?: StyleProp; - - /** - * Style for the outer-most badge component - */ - wrapperStyle?: StyleProp; - - /** - * Style for the text in the badge - */ - textStyle?: StyleProp; - - /** - * Override the default badge contents, mutually exclusive with 'value' property - */ - children?: JSX.Element; - - /** - * Custom component to replace the badge outer component - * - * @default View (if onPress then TouchableOpacity) - */ - component?: React.ComponentClass; - - /** - * Function called when pressed on the badge - */ - onPress?(): void; -} - -/** - * Badge component - * - * @see https://react-native-training.github.io/react-native-elements/API/badge/ - */ -export class Badge extends React.Component {} - -export interface CardProps { - /** - * Flex direction (row or column) - * - * @default 'column' - */ - flexDirection?: 'column' | 'row'; - - /** - * Outer container style - */ - containerStyle?: StyleProp; - - /** - * Inner container style - */ - wrapperStyle?: StyleProp; - - /** - * Card title - */ - title?: string; - - /** - * Additional title styling (if title provided) - */ - titleStyle?: StyleProp; - - /** - * Title rendered over the image - * (only works if image prop is present) - */ - featuredTitle?: string; - - /** - * Styling for featured title - */ - featuredTitleStyle?: StyleProp; - - /** - * Subtitle rendered over the image - * (only works if image prop is present) - */ - featuredSubtitle?: string; - - /** - * Styling for featured subtitle - */ - featuredSubtitleStyle?: StyleProp; - - /** - * Additional divider styling - * (if title provided) - */ - dividerStyle?: StyleProp; - - /** - * Specify different font family - * - * @default System font bold (iOS), Sans Serif Bold (android) - */ - fontFamily?: string; - - /** - * Specify image styling if image is provided - */ - imageStyle?: ImageStyle; - - /** - * Specify styling for view surrounding image - */ - imageWrapperStyle?: StyleProp; - - /** - * Add an image as the heading with the image prop - */ - image?: ImageURISource; -} - -/** - * Card component - * - * @see https://react-native-training.github.io/react-native-elements/API/card/ - */ -export class Card extends React.Component {} - -/** - * Set the buttons within a Group. - */ -export interface ElementObject { - element: JSX.Element | React.ReactType; -} - -/** - * Set the border styles for a component. - */ -export interface InnerBorderStyleProperty { - color?: string; - width?: number; -} - -export interface ButtonGroupProps { - /** - * Current selected index of array of buttons - */ - selectedIndex: number; - - /** - * Method to update Button Group Index - */ - onPress(selectedIndex: number): void; - - /** - * Array of buttons for component, if returning a component, must be an object with { element: componentName } - */ - buttons: string[] | ElementObject[]; - - /** - * Choose other button component such as TouchableOpacity - * - * @default TouchableHighlight - */ - component?: React.ComponentClass; - - /** - * Specify styling for main button container - */ - containerStyle?: StyleProp; - - /** - * inherited styling specify styling for button - */ - buttonStyle?: StyleProp; - - /** - * Specify color for selected state of button - * - * @default 'white' - */ - selectedBackgroundColor?: string; - - /** - * Specify specific styling for text - */ - textStyle?: StyleProp; - - /** - * Specify specific styling for text in the selected state - */ - selectedTextStyle?: StyleProp; - - /** - * inherited styling object { width, color } update the styling of the interior border of the list of buttons - */ - innerBorderStyle?: InnerBorderStyleProperty; - - /** - * Specify underlayColor for TouchableHighlight - * - * @default 'white' - */ - underlayColor?: string; - - /** - * Disables the currently selected button if true - * - * @default false - */ - disableSelected?: boolean; - - /** - * Determines what the opacity of the wrapped view should be when touch is active. - */ - activeOpacity?: number; - - /** - * Border radius for the container - */ - containerBorderRadius?: number; - - /** - * Styling for the final border edge - */ - lastBorderStyle?: StyleProp; - - /** - * - * Called immediately after the underlay is hidden - */ - onHideUnderlay?(): void; - - /** - * Called immediately after the underlay is shown - */ - onShowUnderlay?(): void; - - /** - * Animate the touchable to a new opacity. - */ - setOpacityTo?(value: number): void; -} - -export class ButtonGroup extends React.Component {} - -export interface CheckBoxProps { - /** - * Icon family, can be one of the following - * (required only if specifying an icon that is not from font-awesome) - */ - iconType?: IconType; - - /** - * Specify React Native component for main button - */ - component?: React.ComponentClass; - - /** - * Flag for checking the icon - * - * @default false - */ - checked: boolean; - - /** - * Moves icon to right of text. - * - * @default false - */ - iconRight?: boolean; - - /** - * Aligns checkbox to right - * - * @default false - */ - right?: boolean; - - /** - * Aligns checkbox to center - * - * @default false - */ - center?: boolean; - - /** - * Title of checkbox - */ - title?: string | JSX.Element; - - /** - * Style of main container - */ - containerStyle?: StyleProp; - - /** - * style of text - */ - textStyle?: StyleProp; - - /** - * onLongPress function for checkbox - */ - onLongPress?(): void; - - /** - * onLongPress function for checkbox - */ - onLongIconPress?(): void; - - /** - * onPress function for container - */ - onPress?(): void; - - /** - * onPress function for checkbox - */ - onIconPress?(): void; - - /** - * Default checked icon (Font Awesome Icon) - * - * @default 'check-square-o' - */ - checkedIcon?: string; - - /** - * Default checked icon (Font Awesome Icon) - * - * @default 'square-o' - */ - uncheckedIcon?: string; - - /** - * Default checked color - * - * @default 'green' - */ - checkedColor?: string; - - /** - * Default unchecked color - * @default '#bfbfbf' - */ - uncheckedColor?: string; - - /** - * Specify a custom checked message - */ - checkedTitle?: string; - - /** - * Specify different font family - * @default 'System font bold (iOS)' - * @default 'Sans Serif Bold (android)' - */ - fontFamily?: string; -} -export class CheckBox extends React.Component {} - -export interface DividerProps { - /** - * Style the divider - * - * @default {height: 1, backgroundColor: #e1e8ee} - */ - style?: StyleProp; -} - -export class Divider extends React.Component {} - -export interface FormValidationMessageProps extends ViewProperties { - /** - * Style of the container - */ - containerStyle?: StyleProp; - - /** - * Style of the text within the label message - */ - labelStyle?: StyleProp; - - /** - * Font family for the message - */ - fontFamily?: string; -} -export class FormValidationMessage extends React.Component< - FormValidationMessageProps, - any -> {} - -export interface FormInputProps extends TextInputProperties { - /** - * TextInput container styling - */ - containerStyle?: StyleProp; - - /** - * TextInput styling - */ - inputStyle?: StyleProp; - - /** - * @deprecated - * Get ref of TextInput - */ - textInputRef?(ref: TextInput): void; - - /** - * @deprecated - * Get ref of TextInput container - */ - containerRef?(ref: any): void; - - /** - * Shake the TextInput if not a falsy value and different from the previous value - */ - shake?: any; -} - -export class FormInput extends React.Component { - /** - * Holds reference to the stored input. - */ - input: TextInput; - - /** - * Shake the TextInput - * - * eg `this.formInputRef.shake()` - */ - shake(): void; - - /** - * Call focus on the TextInput - */ - focus(): void; - - /** - * Call blur on the TextInput - */ - blur(): void; - - /** - * Call clear on the TextInput - */ - clearText(): void; -} - -export interface FormLabelProps extends ViewProperties { - /** - * Additional label container style - */ - containerStyle?: StyleProp; - - /** - * Additional label styling - */ - labelStyle?: StyleProp; - - /** - * Specify different font family - * - * @default System font bold (iOS), Sans Serif Bold (android) - */ - fontFamily?: string; -} - -export class FormLabel extends React.Component {} - -export interface GridProps extends ViewProperties { - /** - * Outer grid styling - */ - containerStyle?: StyleProp; - - /** - * Opacity on pressing - * - */ - activeOpacity?: number; - - /** - * onPress method - */ - onPress?(): void; - - children: React.ReactNode; -} - -/** - * @deprecated - * Warning: Grid has been deprecated and will be removed in a future version of React Native Elements - * - * @see https://react-native-training.github.io/react-native-elements/API/grid - */ -export class Grid extends React.Component {} - -export interface SubGridProps extends ViewProperties { - /** - * Size for column or row - */ - size?: number; - - /** - * Opacity on pressing - * - * @default 1 - */ - activeOpacity?: number; - - /** - * Styling for the outer column or row - */ - containerStyle?: StyleProp; - - /** - * onPress method - */ - onPress?(): void; -} - -/** - * @deprecated - * Warning: Row has been deprecated and will be removed in a future version of React Native Elements - * @see https://react-native-training.github.io/react-native-elements/API/grid/#row - */ -export class Row extends React.Component {} - -/** - * @deprecated - * Warning: Col has been deprecated and will be removed in a future version of React Native Elements - * - * @see https://react-native-training.github.io/react-native-elements/API/grid/#column - * - */ -export class Col extends React.Component {} - -export interface HeaderIcon extends IconObject { - icon?: string; -} - -/** - * Defines the types that can be used in a header sub component - */ -export type HeaderSubComponent = JSX.Element | TextProps | HeaderIcon; - -export interface HeaderProps extends ViewProperties { - /** - * Accepts all props for StatusBar - */ - statusBarProps?: StatusBarProperties; - - /** - * Configuration object for default component (icon: string, ...props for React Native Elements Icon) or a valid React Element define your left component here - */ - leftComponent?: HeaderSubComponent; - - /** - * Configuration object for default component (text: string, ...props for React Native Text component) valid React Element define your center component here - */ - centerComponent?: HeaderSubComponent; - - /** - * Configuration object for default component (icon: string, ...props for React Native Elements Icon component) or a valid React Element define your right component here - */ - rightComponent?: HeaderSubComponent; - - /** - * Sets backgroundColor of the parent component - */ - backgroundColor?: string; - - /** - * Styling for outer container - */ - outerContainerStyles?: StyleProp; - - /** - * Styling for inner container - */ - innerContainerStyles?: StyleProp; -} - -/** - * Header component - * @see https://react-native-training.github.io/react-native-elements/API/header/ - */ -export class Header extends React.Component {} - -export interface IconProps { - /** - * Name of icon - */ - name: string; - - /** - * Type (defaults to material, options are material-community, zocial, font-awesome, octicon, ionicon, foundation, evilicon, simple-line-icon, or entypo) - * @default 'material' - */ - type?: IconType; - - /** - * Size of icon - * @default 26 - */ - size?: number; - - /** - * Color of icon - * - * @default 'black' - */ - color?: string; - - /** - * Additional styling to icon - */ - iconStyle?: StyleProp; - - /** - * View if no onPress method is defined, TouchableHighlight if onPress method is defined React Native component update React Native Component - */ - component?: React.ComponentClass; - - /** - * onPress method for button - */ - onPress?(): void; - - /** - * onLongPress method for button - */ - onLongPress?(): void; - - /** - * UnderlayColor for press event - */ - underlayColor?: string; - - /** - * Reverses color scheme - * - * @default false - */ - reverse?: boolean; - - /** - * Adds box shadow to button - * - * @default false - */ - raised?: boolean; - - /** - * Add styling to container holding icon - */ - containerStyle?: StyleProp; - - /** - * Specify reverse icon color - * - * @default 'white' - */ - reverseColor?: string; -} - -/** - * Icon component - * @see https://react-native-training.github.io/react-native-elements/API/icons/ - */ -export class Icon extends React.Component {} - -export interface ListProps extends ViewProperties { - /** - * Style the list container - * @default '{marginTop: 20, borderTopWidth: 1, borderBottomWidth: 1, borderBottomColor: #cbd2d9}' - */ - containerStyle?: StyleProp; -} - -/** - * List component - * @see https://react-native-training.github.io/react-native-elements/API/lists/ - */ -export class List extends React.Component {} - -export interface ListItemProps { - /** - * Left avatar. This is the React Native Image source prop. Avatar can be used in parallel to leftIcon if needed. - */ - avatar?: string | ImageURISource; - - /** - * Avatar styling. This is the React Native Image style prop - */ - avatarStyle?: ImageStyle; - - /** - * Avatar outer container styling - */ - avatarContainerStyle?: StyleProp; - - /** - * Avatar overlay container styling - */ - avatarOverlayContainerStyle?: StyleProp; - - /** - * Set chevron color - * - * @default '#bdc6cf' - */ - chevronColor?: string; - - /** - * View or TouchableHighlight if onPress method is added as prop - * Replace element with custom element - */ - component?: React.ComponentClass; - - /** - * Additional main container styling - */ - containerStyle?: StyleProp; - - /** - * Additional wrapper styling - */ - wrapperStyle?: StyleProp; - - /** - * Define underlay color for TouchableHighlight - * - * @default 'white' - */ - underlayColor?: string; - - /** - * Specify different font family - * - * @default 'HelevticaNeue' (iOS) - * @default 'Sans Serif' (android) - */ - fontFamily?: string; - - /** - * Set if you do not want a chevron - * - * @default false - */ - hideChevron?: boolean; - - /** - * onPress method for link - */ - onPress?(): void; - - /** - * onLongPress method for link - */ - onLongPress?(): void; - - /** - * Make left avatar round - * - * @default false - */ - roundAvatar?: boolean; - - /** - * Main title for list item, can be text or custom view - */ - title?: string; - - /** - * Number of lines for title - * - * @default 1 - */ - titleNumberOfLines?: number; - - /** - * Additional title styling - */ - titleStyle?: StyleProp; - - /** - * Provide styling for title container - */ - titleContainerStyle?: StyleProp; - - /** - * Subtitle text or custom view - */ - subtitle?: string | JSX.Element; - - /** - * Number of lines for Subtitle - * - * @default 1 - */ - subtitleNumberOfLines?: number; - - /** - * Provide styling for subtitle container - */ - subtitleContainerStyle?: StyleProp; - - /** - * Additional subtitle styling - */ - subtitleStyle?: StyleProp; - - /** - * Provide a rightTitle to have a title show up on the right side of the button - */ - rightTitle?: string; - - /** - * Number of lines for Right Title - * - * @default 1 - */ - rightTitleNumberOfLines?: number; - - /** - * Style the outer container of the rightTitle text - * - * @default "{flex: 1, alignItems: 'flex-end', justifyContent: 'center'}"" - */ - rightTitleContainerStyle?: StyleProp; - - /** - * Style the text of the rightTitle text - * - * @default "{marginRight: 5, color: '#bdc6cf'}" - */ - rightTitleStyle?: StyleProp; - - /** - * Add a label with your own styling by providing a label={} prop to ListItem - */ - label?: JSX.Element; - - /** - * Icon configuration for left icon, either a name from the icon library (like material) or a React Native element like Image. - * leftIcon can be used in parallel to avatar if needed. - * {name, color, style, type} - * (type defaults to material icons) OR React Native element - */ - leftIcon?: IconObject | JSX.Element; - - /** - * Attaches an onPress on left Icon - */ - leftIconOnPress?(): void; - - /** - * Attaches an onLongPress on left Icon - */ - leftIconOnLongPress?(): void; - - /** - * Underlay color for left Icon - * - * @default 'white' - */ - leftIconUnderlayColor?: string; - - /** - * {name: 'chevron-right'} object {name, color, style, type} (type defaults to material icons) OR - * React Native element icon configuration for right icon, either a name from the icon library (like material) or a React Native element like Image. - * Shows up unless hideChevron is set - */ - rightIcon?: IconObject | JSX.Element; - - /** - * Attaches an onPress on right Icon - */ - onPressRightIcon?(): void; - - /** - * Add a switch to the right side of your component - * - * @default false - */ - switchButton?: boolean; - - /** - * Add a callback function when the switch is toggled - */ - onSwitch?(value: boolean): void; - - /** - * If true the user won't be able to toggle the switch. Default value is false. - * @default false - */ - switchDisabled?: boolean; - - /** - * Background color when the switch is turned on. - */ - switchOnTintColor?: string; - - /** - * Color of the foreground switch grip. - */ - switchThumbTintColor?: string; - - /** - * Border color on iOS and background color on Android when the switch is turned off. - */ - switchTintColor?: string; - - /** - * The value of the switch. If true the switch will be turned on. Default value is false. - * - * @default false - */ - switched?: boolean; - - /** - * Whether to have the right title area be an input text component. - * - * @default false - */ - textInput?: boolean; - - /** - * Can tell TextInput to automatically capitalize certain characters. - */ - textInputAutoCapitalize?: boolean; - - /** - * Can tell TextInput to automatically capitalize certain characters. - */ - textInputAutoCorrect?: boolean; - - /** - * If true, focuses the input on componentDidMount. The default value is false. - */ - textInputAutoFocus?: boolean; - - /** - * If false, text is not editable. The default value is true. - */ - textInputEditable?: boolean; - - /** - * Can be one of the following: - * 'default', 'email-address', 'numeric', 'phone-pad', 'ascii-capable', 'numbers-and-punctuation', 'url', 'number-pad', 'name-phone-pad', 'decimal-pad', 'twitter', 'web-search' - */ - textInputKeyboardType?: KeyboardType | KeyboardTypeIOS; - - /** - * Limits the maximum number of characters that can be entered. - */ - textInputMaxLength?: number; - - /** - * If true, the text input can be multiple lines. The default value is false. - */ - textInputMultiline?: boolean; - - /** - * Callback that is called when the text input's text changes. Changed text is passed as an argument to the callback handler. - */ - textInputOnChangeText?(text: string): void; - - /** - * Callback that is called when the text input is focused. - */ - textInputOnFocus?(): void; - - /** - * Manually set value of the input - */ - textInputValue?: string; - - /** - * If true, obscures the text entered so that sensitive text like passwords stay secure. - */ - textInputSecure?: boolean; - - /** - * Style for the input text - */ - textInputStyle?: StyleProp; - - /** - * Style for the container surrounding the input text - */ - textInputContainerStyle?: StyleProp; - - /** - * Placeholder for the text input - */ - textInputPlaceholder?: string; - - /** - * Callback that is called when the text input is blurred. - */ - textInputOnBlur?(): void; - - /** - * If true, all text will automatically be selected on focus. - */ - textInputSelectTextOnFocus?: boolean; - - /** - * Determines how the return key should look. For more info see the React Native docs - */ - textInputReturnKeyType?: string; - - /** - * Add a badge to the ListItem by using this prop - * - */ - badge?: BadgeProps | ElementObject; -} - -/** - * ListItem component - * @see https://react-native-training.github.io/react-native-elements/API/lists/ - */ -export class ListItem extends React.Component {} - -export interface ButtonInformation { - title: string; - icon: string; - buttonStyle?: StyleProp; -} - -export interface PricingCardProps { - /** - * Title - */ - title?: string; - - /** - * Price - */ - price: string; - - /** - * Color scheme for button & title - */ - color: string; - - /** - * Pricing information - */ - info?: string[]; - - /** - * {title, icon, buttonStyle} - * Button information - */ - button: ButtonInformation; - - /** - * Function to be run when button is pressed - */ - onButtonPress?(): void; - - /** - * Outer component styling - */ - containerStyle?: StyleProp; - - /** - * Inner wrapper component styling - */ - wrapperStyle?: StyleProp; - - /** - * Specify title font family - * - * System font (font weight 800) (iOS) - * Sans Serif Black (android) - */ - titleFont?: string; - - /** - * Specify pricing font family - * - * System font (font weight 700) (iOS) - * Sans Serif Bold (android) - */ - pricingFont?: string; - - /** - * Specify pricing information font family - * - * System font bold (iOS) - * Sans Serif Bold (android) - */ - infoFont?: string; - - /** - * Specify button font family - * - * System font (iOS) - * Sans Serif (android) - */ - buttonFont?: string; -} - -/** - * PricingCard component - * @see https://react-native-training.github.io/react-native-elements/API/pricing/ - */ -export class PricingCard extends React.Component {} - -export interface RatingProps { - /** - * Callback method when the user finishes rating. Gives you the final rating value as a whole number - */ - onFinishRating(rating: number): void; - - /** - * Choose one of the built-in types: star, rocket, bell, heart or use type custom to render a custom image - */ - type?: 'star' | 'rocket' | 'bell' | 'heart' | 'custom'; - - /** - * Pass in a custom image source; use this along with type='custom' prop above - */ - ratingImage?: ImageURISource | string | number; - - /** - * Pass in a custom fill-color for the rating icon; use this along with type='custom' prop above - * - * @default '#f1c40f' - */ - ratingColor?: string; - - /** - * Pass in a custom background-fill-color for the rating icon; use this along with type='custom' prop above - * - * @default 'white' - */ - ratingBackgroundColor?: string; - - /** - * Number of rating images to display - * - * @default 5 - */ - ratingCount?: number; - - /** - * The size of each rating image - * - * @default 50 - */ - imageSize?: number; - - /** - * Displays the Built-in Rating UI to show the rating value in real-time - */ - showRating?: boolean; - - /** - * Whether the rating can be modiefied by the user - * - * @default false - */ - readonly?: boolean; - - /** - * The initial rating to render - * - * @default ratingCount/2 - */ - startingValue?: number; - - /** - * The number of decimal places for the rating value; must be between 0 and 20 - * - * @default undefined - */ - fractions?: number; - - /** - * Exposes style prop to add additonal styling to the container view - */ - style?: StyleProp; -} - -/** - * Rating component - * @see https://react-native-training.github.io/react-native-elements/API/rating/ - */ -export class Rating extends React.Component {} - -export interface SearchBarProps extends TextInputProperties { - /** - * TextInput container styling - */ - containerStyle?: StyleProp; - - /** - * TextInput styling - */ - inputStyle?: StyleProp; - - /** - * @deprecated - * Get ref of TextInput - */ - textInputRef?(ref: TextInput): void; - - /** - * @deprecated - * Get ref of TextInput container - */ - containerRef?(ref: any): void; - - /** - * Specify color, styling, or another Material Icon Name - */ - icon?: IconObject; - - /** - * Remove icon from textinput - * - * @default false - */ - noIcon?: boolean; - - /** - * @default false change theme to light theme - */ - lightTheme?: boolean; - - /** - * Change TextInput styling to rounded corners - * - * @default false - */ - round?: boolean; - - /** - * Specify other than the default transparent underline color - * - * @default 'transparent' - */ - underlineColorAndroid?: string; - - /** - * Specify color, styling of the loading ActivityIndicator effect - * - * @default "{ color: '#86939e' }" - */ - loadingIcon?: IconObject; - - /** - * Show the loading ActivityIndicator effect - * - * @default false - */ - showLoadingIcon?: boolean; - - /** - * Set the placeholder text - * - * @default '' - */ - placeholder?: string; - - /** - * Set the color of the placeholder text - * - * @default '#86939e' - */ - placeholderTextColor?: string; - - /** - * Method to fire when text is changed - */ - onChangeText?(text: string): void; - - /** - * Specify color, styling, or another Material Icon Name - * (Note: pressing on this icon clears text inside the searchbar) - * - * @default "{ color: '#86939e', name: 'search' }" - */ - clearIcon?: IconObject; -} - -/** - * SearchBar component - * @see https://react-native-training.github.io/react-native-elements/API/searchbar/ - */ -export class SearchBar extends React.Component { - /** - * Holds reference to the stored input. - */ - input: TextInput; - - /** - * Call focus on the TextInput - */ - focus(): void; - - /** - * Call blur on the TextInput - */ - blur(): void; - - /** - * Call clear on the TextInput - */ - clearText(): void; -} - -export interface SideMenuProps { - /** - * Menu component - */ - menu: JSX.Element; - - /** - * Props driven control over menu open state - * - * @default false - */ - isOpen?: boolean; - - /** - * Content view left margin if menu is opened - * - * @default ⅔ of device screen width - */ - openMenuOffset?: number; - - /** - * Content view left margin if menu is hidden - */ - hiddenMenuOffset?: number; - - /** - * Edge distance on content view to open side menu - * - * @default 60 - */ - edgeHitWidth?: number; - - /** - * X axis tolerance - */ - toleranceX?: number; - - /** - * Y axis tolerance - */ - toleranceY?: number; - - /** - * Disable whether the menu can be opened with gestures or not - * - * @default false - */ - disableGestures?: boolean; - - /** - * Function that accepts event as an argument and specify if side-menu should react on the touch or not. - * Check https://facebook.github.io/react-native/docs/gesture-responder-system.html for more details - */ - onStartShouldSetResponderCapture?(event: GestureResponderEvent): boolean; - - /** - * Callback on menu open/close. Is passed isOpen as an argument. - */ - onChange?(isOpen: boolean): void; - - /** - * Callback on menu move. Is passed left as an argument - */ - onMove?(left: number): void; - - /** - * Either 'left' or 'right'. - * - * @default 'left' - */ - menuPosition?: string; - - /** - * Function that accept 2 arguments (prop, value) and return an object: - * - animation you should use at the place you specify parameter to animate - * - newOffset you should use to specify the final value of prop - */ - animationFunction?( - animation: Animated.Value, - newOffset: number - ): Animated.CompositeAnimation; - - /** - * Function that accept 1 argument (value) and return an object - * - leftOffset you should use at the place you need current value of animated parameter (left offset of content view) - */ - animationStyle?(leftOffset: number): StyleProp; - - /** - * When true, content view will bounce back to openMenuOffset when dragged further - * - * @default true - */ - bounceBackOnOverdraw?: boolean; -} - -/** - * @deprecated - * Warning: SideMenu has been deprecated and will be removed in a future version of React Native Elements. For a complete navigation solution that includes SideMenu(Drawer) as well as many other - * features, be sure to check out react-navigation (https://reactnavigation.org) and it's DrawerNavigator. - * - * SideMenu component - * @see https://react-native-training.github.io/react-native-elements/API/side_menu/ - */ -export class SideMenu extends React.Component {} - -export interface SliderProps { - /** - * Initial value of the slider - * - * @default 0 - */ - value?: number; - - /** - * If true the user won't be able to move the slider - * - * @default false - */ - disabled?: boolean; - - /** - * Initial minimum value of the slider - * - * @default 0 - */ - minimumValue?: number; - - /** - * Initial maximum value of the slider - * - * @default 1 - */ - maximumValue?: number; - - /** - * Step value of the slider. The value should be between 0 and maximumValue - minimumValue) - * - * @default 0 - */ - step?: number; - - /** - * The color used for the track to the left of the button - * - * @default '#3f3f3f' - */ - minimumTrackTintColor?: string; - - /** - * The color used for the track to the right of the button - * - * @default '#b3b3b3' - */ - maximumTrackTintColor?: string; - - /** - * The color used for the thumb - * - * @default '#343434' - */ - thumbTintColor?: string; - - /** - * The size of the touch area that allows moving the thumb. The touch area has the same center as the visible thumb. - * This allows to have a visually small thumb while still allowing the user to move it easily. - * - * @default "{width: 40, height: 40}" - */ - thumbTouchSize?: { - width?: number; - height?: number; - }; - - /** - * Callback continuously called while the user is dragging the slider - */ - onValueChange?(value: number): void; - - /** - * Callback called when the user starts changing the value (e.g. when the slider is pressed) - */ - onSlidingStart?(value: number): void; - - /** - * Callback called when the user finishes changing the value (e.g. when the slider is released) - */ - onSlidingComplete?(value: number): void; - - /** - * The style applied to the slider container - */ - style?: StyleProp; - - /** - * The style applied to the track - */ - trackStyle?: StyleProp; - - /** - * The style applied to the thumb - */ - thumbStyle?: StyleProp; - - /** - * Set this to true to visually see the thumb touch rect in green. - * - * @default false - */ - debugTouchArea?: boolean; - - /** - * Set to true if you want to use the default 'spring' animation - * - * @default false - */ - animateTransitions?: boolean; - - /** - * Set to 'spring' or 'timing' to use one of those two types of animations with the default animation properties. - * - * @default 'timing' - */ - animationType?: 'spring' | 'timing'; - - /** - * Used to configure the animation parameters. These are the same parameters in the Animated library. - * - * @default undefined - */ - animationConfig?: - | Animated.TimingAnimationConfig - | Animated.SpringAnimationConfig; -} - -/** - * Slider component - * @see https://react-native-training.github.io/react-native-elements/API/slider/ - */ -export class Slider extends React.Component {} - -export type SocialMediaType = - | 'facebook' - | 'twitter' - | 'google-plus-official' - | 'pinterest' - | 'linkedin' - | 'youtube' - | 'vimeo' - | 'tumblr' - | 'instagram' - | 'quora' - | 'foursquare' - | 'wordpress' - | 'stumbleupon' - | 'github' - | 'github-alt' - | 'twitch' - | 'medium' - | 'soundcloud' - | 'gitlab' - | 'angellist' - | 'codepen'; - -export interface SocialIconProps { - /** - * Title if made into a button - */ - title?: string; - - /** - * Social media type - */ - type: SocialMediaType; - - /** - * Adds a drop shadow, set to false to remove - * - * @default true - */ - raised?: boolean; - - /** - * Creates button - * - * @default false - */ - button?: boolean; - - /** - * onPress method - */ - onPress?(): void; - - /** - * @default none function onLongPress method - */ - onLongPress?(): void; - - /** - * Reverses icon color scheme, setting background to white and icon to primary color - * - * @default false - */ - light?: boolean; - - /** - * Extra styling for icon component - */ - iconStyle?: StyleProp; - - /** - * Button styling - */ - style?: StyleProp; - - /** - * Icon color - */ - iconColor?: string; - - /** - * Icon size - * - * @default 24 - */ - iconSize?: number; - - /** - * Component Type of button - * - * @default TouchableHighlight - */ - component?: React.ComponentClass; - - /** - * Specify different font family - * - * @default System font bold (iOS), Sans Serif Black (android) - */ - fontFamily?: string; - - /** - * Specify font weight of title if set as a button with a title - * - * @default bold (ios), black(android) - */ - fontWeight?: string; - - /** - * Specify text styling - */ - fontStyle?: StyleProp; - - /** - * Disable button - * - * @default false - */ - disabled?: boolean; - - /** - * Shows loading indicator - * - * @default false - */ - loading?: boolean; -} - -/** - * SocialIcon component - * @see https://react-native-training.github.io/react-native-elements/API/social_icons/ - */ -export class SocialIcon extends React.Component {} - -export interface SwipeDeckProps { - /** - * An array of data object which contains each card details. - */ - data: ReadonlyArray; - - /** - * A function that takes a card as a prop and renders it with custom UI - */ - renderCard(card: D): JSX.Element; - - /** - * A function that renders custom UI when no more cards are present - */ - renderNoMoreCards?(): JSX.Element; - - /** - * function function A callback function that takes a card as a prop and take the approriate action when the user swipes the card right - */ - onSwipeRight?(card: D): void; - - /** - * function function A callback function that takes a card as a prop and take the approriate action when the user swipes the card left - */ - onSwipeLeft?(card: D): void; -} - -/** - * SwipeDeck component - * @see https://react-native-training.github.io/react-native-elements/API/swipedeck/ - */ -export class SwipeDeck extends React.Component< - SwipeDeckProps, - any -> {} - -/** - * @deprecated - * Warning: Tabs has been deprecated and will be removed in a future version of React Native Elements. - * For a complete navigation solution that includes Tabs as well as many other features, be sure to check out react-navigation (https://reactnavigation.org) and it's TabRouter. - */ -export class Tabs extends TabNavigator {} - -/** - * @deprecated - * Warning: Tab has been deprecated and will be removed in a future version of React Native Elements. - * For a complete navigation solution that includes Tabs as well as many other features, be sure to check out react-navigation (https://reactnavigation.org) and it's TabRouter. - */ -export class Tab extends TabNavigator.Item {} - -export interface TileProps { - /** - * Icon Component Props - */ - icon?: IconObject; - - /** - * Styling for the outer icon container - */ - iconContainerStyle?: StyleProp; - - /** - * Text inside the tile - */ - title?: string; - - /** - * Styling for the title - */ - titleStyle?: StyleProp; - - /** - * Text inside the tile when tile is featured - */ - caption?: string; - - /** - * Styling for the caption - */ - captionStyle?: StyleProp; - - /** - * Changes the look of the tile - */ - featured?: boolean; - - /** - * @default none object (style) Styling for the outer tile container - */ - containerStyle?: StyleProp; - - /** - * Source for the image - */ - imageSrc: ImageURISource | string | number; - - /** - * Styling for the image - */ - imageContainerStyle?: StyleProp; - - /** - * @default none function (event) Function to call when tile is pressed - */ - onPress?(): void; - - /** - * Number passed to control opacity on press - * - * @default 0.2 - */ - activeOpacity?: number; - - /** - * Styling for bottom container when not featured tile - */ - contentContainerStyle?: StyleProp; - - /** - * Width for the tile - * - * @default Device Width - */ - width?: number; - - /** - * Height for the tile - * - * @default Device Width * 0.8 - */ - height?: number; -} - -/** - * Tile component - * @see https://react-native-training.github.io/react-native-elements/API/tile/ - */ -export class Tile extends React.Component {} - -/** - * Colors - */ - -export interface Colors { - readonly primary: string; - readonly primary1: string; - readonly primary2: string; - readonly secondary: string; - readonly secondary2: string; - readonly secondary3: string; - readonly grey0: string; - readonly grey1: string; - readonly grey2: string; - readonly grey3: string; - readonly grey4: string; - readonly grey5: string; - readonly dkGreyBg: string; - readonly greyOutline: string; - readonly searchBg: string; - readonly disabled: string; - readonly white: string; - readonly error: string; - readonly [key: string]: string; -} - -export const colors: Colors; - -/* Utility Functions */ - -/** - * TODO make the Icon Type an export of the react-native-vector-icons type definitions. - */ -export function getIconType(type: IconType): any; - -/** - * Method to normalize size of fonts across devices - */ -export function normalize(size: number): number; diff --git a/types/react-native-elements/react-native-elements-tests.tsx b/types/react-native-elements/react-native-elements-tests.tsx deleted file mode 100644 index 29155829b2..0000000000 --- a/types/react-native-elements/react-native-elements-tests.tsx +++ /dev/null @@ -1,975 +0,0 @@ -import * as React from 'react'; -import { - ListView, - View, - StyleSheet, - TouchableNativeFeedback, - Image, - TextInput, - Animated, - Dimensions -} from 'react-native'; -import { - Button, - Text, - Badge, - Avatar, - Card, - ButtonGroup, - CheckBox, - Divider, - FormInput, - FormValidationMessage, - FormLabel, - Header, - Icon, - List, - ListItem, - PricingCard, - Rating, - SearchBar, - SideMenu, - Slider, - SocialIcon, - SwipeDeck, - Tabs, - Tab, - Tile, - colors, - getIconType, - normalize -} from 'react-native-elements'; - -const { width, height } = Dimensions.get('window'); - -class TextTest extends React.Component { - render() { - return ( - - Heading 1 - Heading 2 - Heading 3 - Heading 4 - - ); - } -} - -class AvatarTest extends React.Component { - render() { - return ( - - - Avatars - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - - - - Avatar with initials - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - - - - Avatar with icons - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ - flex: 2, - marginLeft: 20, - marginTop: 115 - }} - /> - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ flex: 3, marginTop: 100 }} - /> - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ flex: 4, marginTop: 75 }} - /> - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ flex: 5, marginRight: 60 }} - /> - - - ); - } -} - -const AvatarStyles = StyleSheet.create({ - title: { - fontSize: 30, - marginBottom: 10 - } -}); - -class BadgeTest extends React.Component { - render() { - return ( - - - - - User 1 - - - console.log('pressed')} value="5" /> - - - - ); - } -} - -class ButtonTest extends React.Component { - handleButtonPress() { - console.log('I got pressed'); - } - - render() { - return ( - -