From bd3f46b25e232e9fc126f17e15819b5135898a23 Mon Sep 17 00:00:00 2001 From: Thor Sedeke Date: Sun, 29 Apr 2018 18:04:49 +0200 Subject: [PATCH 001/113] Add definition for koa-response-time --- types/koa-response-time/index.d.ts | 11 +++++++++ .../koa-response-time-tests.ts | 4 ++++ types/koa-response-time/tsconfig.json | 23 +++++++++++++++++++ types/koa-response-time/tslint.json | 1 + 4 files changed, 39 insertions(+) create mode 100644 types/koa-response-time/index.d.ts create mode 100644 types/koa-response-time/koa-response-time-tests.ts create mode 100644 types/koa-response-time/tsconfig.json create mode 100644 types/koa-response-time/tslint.json diff --git a/types/koa-response-time/index.d.ts b/types/koa-response-time/index.d.ts new file mode 100644 index 0000000000..6daf0c8566 --- /dev/null +++ b/types/koa-response-time/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for koa-response-time 2.0 +// Project: https://github.com/koajs/response-time#readme +// Definitions by: Thor Sedeke +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as koa from 'koa'; + +declare function koa_response_time(): koa.Middleware; + +export = koa_response_time; diff --git a/types/koa-response-time/koa-response-time-tests.ts b/types/koa-response-time/koa-response-time-tests.ts new file mode 100644 index 0000000000..6b35c60f9a --- /dev/null +++ b/types/koa-response-time/koa-response-time-tests.ts @@ -0,0 +1,4 @@ +import koaResponseTime = require('koa-response-time'); +import Koa = require('koa'); + +new Koa().use(koaResponseTime()); diff --git a/types/koa-response-time/tsconfig.json b/types/koa-response-time/tsconfig.json new file mode 100644 index 0000000000..cd6c50be36 --- /dev/null +++ b/types/koa-response-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", + "koa-response-time-tests.ts" + ] +} diff --git a/types/koa-response-time/tslint.json b/types/koa-response-time/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/koa-response-time/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 29270f0837c7d81cd698ff721a9f2a020c74d454 Mon Sep 17 00:00:00 2001 From: Thor Sedeke Date: Sun, 29 Apr 2018 20:02:18 +0200 Subject: [PATCH 002/113] Update to module definition --- types/koa-response-time/index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/koa-response-time/index.d.ts b/types/koa-response-time/index.d.ts index 6daf0c8566..8d55bb9188 100644 --- a/types/koa-response-time/index.d.ts +++ b/types/koa-response-time/index.d.ts @@ -4,8 +4,10 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as koa from 'koa'; +declare module 'koa-response-time' { -declare function koa_response_time(): koa.Middleware; + function koa_response_time(): any; + namespace koa_response_time { } -export = koa_response_time; + export = koa_response_time; +} From 848df4943f737a474b6c5d8821a50a6d6c6c7b06 Mon Sep 17 00:00:00 2001 From: Thor Sedeke Date: Sun, 29 Apr 2018 20:06:16 +0200 Subject: [PATCH 003/113] Update to 4 spaces --- types/koa-response-time/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/koa-response-time/index.d.ts b/types/koa-response-time/index.d.ts index 8d55bb9188..a8ae9b0378 100644 --- a/types/koa-response-time/index.d.ts +++ b/types/koa-response-time/index.d.ts @@ -6,8 +6,8 @@ declare module 'koa-response-time' { - function koa_response_time(): any; - namespace koa_response_time { } + function koa_response_time(): any; + namespace koa_response_time { } - export = koa_response_time; + export = koa_response_time; } From 49b4d0f80b1b025b5a0b00b50a7aa26a08804b3d Mon Sep 17 00:00:00 2001 From: Lukas Tetzlaff Date: Sun, 29 Apr 2018 21:54:21 +0200 Subject: [PATCH 004/113] [svgo] Add namespace to remove ugly require-import (#25172) * add namespace to remove ugly require import and allow regular es6 import syntax * set `esModuleInterop` and `allowSyntheticDefaultImports` flags * Add note which compiler options to set for which TS version * Move TS compiler Options comments to `readme.md` --- types/svgo/readme.md | 25 +++++++++++++++++++++++++ types/svgo/svgo-tests.ts | 2 +- types/svgo/tsconfig.json | 5 +++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 types/svgo/readme.md diff --git a/types/svgo/readme.md b/types/svgo/readme.md new file mode 100644 index 0000000000..39fd398ace --- /dev/null +++ b/types/svgo/readme.md @@ -0,0 +1,25 @@ +# @types/svgo + +## Usage + +### TS 2.7+ + +tsconfig.json +``` +{ + "compilerOptions": { + "esModuleInterop": true + } +} +``` + +### Older TS versions + +tsconfig.json +``` +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true + } +} +``` diff --git a/types/svgo/svgo-tests.ts b/types/svgo/svgo-tests.ts index fae53a127d..34664ce31f 100644 --- a/types/svgo/svgo-tests.ts +++ b/types/svgo/svgo-tests.ts @@ -1,4 +1,4 @@ -import SVGO = require("svgo"); +import SVGO from "svgo"; // Various constructor options. let svgo = new SVGO(); diff --git a/types/svgo/tsconfig.json b/types/svgo/tsconfig.json index ec4687a1d9..f34f24c9ce 100644 --- a/types/svgo/tsconfig.json +++ b/types/svgo/tsconfig.json @@ -14,10 +14,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", "svgo-tests.ts" ] -} \ No newline at end of file +} From 232a917561aa9ec0098a626f8a668a52c7e73469 Mon Sep 17 00:00:00 2001 From: Pine Mizune Date: Mon, 30 Apr 2018 05:20:00 +0900 Subject: [PATCH 005/113] update voca 1.3 -> 1.4 (#25396) --- types/voca/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/voca/index.d.ts b/types/voca/index.d.ts index 7f4cafdd7f..5cdf2e5c77 100644 --- a/types/voca/index.d.ts +++ b/types/voca/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Voca 1.3 +// Type definitions for Voca 1.4 // Project: https://vocajs.com/ // Definitions by: Pine Mizune // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 4d560d85373686f47752d87466478666b31df38b Mon Sep 17 00:00:00 2001 From: Thor Sedeke Date: Sun, 29 Apr 2018 22:26:25 +0200 Subject: [PATCH 006/113] Remove module declaration --- types/koa-response-time/index.d.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/types/koa-response-time/index.d.ts b/types/koa-response-time/index.d.ts index a8ae9b0378..6c9f2131fc 100644 --- a/types/koa-response-time/index.d.ts +++ b/types/koa-response-time/index.d.ts @@ -4,10 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -declare module 'koa-response-time' { +declare function koa_response_time(): any; +declare namespace koa_response_time { } - function koa_response_time(): any; - namespace koa_response_time { } - - export = koa_response_time; -} +export = koa_response_time; From 0f30fbe4dcd866320817e817df79634857aaaedf Mon Sep 17 00:00:00 2001 From: Hassan Khan Date: Mon, 30 Apr 2018 17:07:10 +0100 Subject: [PATCH 007/113] Update index.d.ts (#25242) Export `Checkboard` from types --- types/react-color/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-color/index.d.ts b/types/react-color/index.d.ts index 051d9d4b7f..a1fbbad698 100644 --- a/types/react-color/index.d.ts +++ b/types/react-color/index.d.ts @@ -44,6 +44,7 @@ export interface CustomPickerProps extends ClassAttributes { export { default as AlphaPicker, AlphaPickerProps } from "./lib/components/alpha/Alpha"; export { default as BlockPicker, BlockPickerProps } from "./lib/components/block/Block"; +export { default as Checkboard, CheckboardProps } from "./lib/components/common/Checkboard"; export { default as ChromePicker, ChromePickerProps } from "./lib/components/chrome/Chrome"; export { default as CirclePicker, CirclePickerProps } from "./lib/components/circle/Circle"; export { default as CompactPicker, CompactPickerProps } from "./lib/components/compact/Compact"; From 6c7d22ec881375522a3cae60890e9484a7297d6a Mon Sep 17 00:00:00 2001 From: Jussi Kinnula Date: Mon, 30 Apr 2018 19:08:04 +0300 Subject: [PATCH 008/113] Fix auth0 link users (#25245) * Fix @types/auth0 Auth0 ManagementClient linkUsers() interface + change params naming * Add tests for @types/auth0 linkUsers() * Increase @types/auth0 version number for auth0 from 2.7 to 2.9.1 --- types/auth0/auth0-tests.ts | 19 +++++++++++++++++++ types/auth0/index.d.ts | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/types/auth0/auth0-tests.ts b/types/auth0/auth0-tests.ts index 9c1bbe8856..94e7d63cb3 100644 --- a/types/auth0/auth0-tests.ts +++ b/types/auth0/auth0-tests.ts @@ -75,6 +75,25 @@ management // Handle the error. }); +// Link users +management + .createUser({ connection: 'email', email: 'hi@me.co' }) + .catch(err => console.error('Cannot create E-mail user', err)) + .then((emailUser) => { + if (!emailUser) return; + management + .createUser({ connection: 'sms', phone_number: '+1234567890' }) + .catch(err => console.error('Cannot create SMS user', err)) + .then((smsUser) => { + if (!smsUser) return; + const userId = emailUser.user_id; + const params = { user_id: smsUser.user_id, provider: 'sms' }; + management.linkUsers(userId, params) + .catch(err => console.error('Cannot link E-mail and SMS users', err)) + .then((linkedUsers) => console.log(linkedUsers)) + }) + }); + auth .requestChangePasswordEmail({ connection: 'My-Connection', diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index 050f463bfb..95c6af47ea 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for auth0 2.7 +// Type definitions for auth0 2.9.1 // Project: https://github.com/auth0/node-auth0 // Definitions by: Wilson Hobbs , Seth Westphal , Amiram Korach // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -462,7 +462,7 @@ export interface UnlinkAccountsResponse { profileData?: UnlinkAccountsResponseProfile } -export interface LinkAccountsData { +export interface LinkAccountsParams { user_id: string; connection_id?: string; provider?: string; @@ -664,8 +664,8 @@ export class ManagementClient { unlinkUsers(params: UnlinkAccountsParams): Promise; unlinkUsers(params: UnlinkAccountsParams, cb: (err: Error, data: UnlinkAccountsResponse) => void): void; - linkUsers(userId: string, data: LinkAccountsData): Promise; - linkUsers(userId: string, data: LinkAccountsData, cb: (err: Error, data: any) => void): void; + linkUsers(userId: string, params: LinkAccountsParams): Promise; + linkUsers(userId: string, params: LinkAccountsParams, cb: (err: Error, data: any) => void): void; // Tokens From 1b87de76aa434612661f7d84c079d0777ecf3a6c Mon Sep 17 00:00:00 2001 From: Jussi Kinnula Date: Mon, 30 Apr 2018 19:08:53 +0300 Subject: [PATCH 009/113] Add @types/auth0 missing type profileData to Identity interface (#25251) * Add @types/auth0 missing optional type profileData for Identity interface * Update @types/auth0 auth0 version from 2.7 to 2.9.1 --- types/auth0/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index 95c6af47ea..516e2cc368 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -345,6 +345,14 @@ export interface Identity { user_id: string; provider: string; isSocial: boolean; + profileData?: { + email?: string; + email_verified?: boolean; + name?: string; + phone_number?: string; + phone_verified?: boolean; + request_language?: string; + } } export interface AuthenticationClientOptions { From 9746cf7183788050b4e565cafeebb73e036ad925 Mon Sep 17 00:00:00 2001 From: Cyril Gandon Date: Mon, 30 Apr 2018 18:10:24 +0200 Subject: [PATCH 010/113] [restangular] id property of element can be either a string or a number (#25248) --- types/restangular/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/restangular/index.d.ts b/types/restangular/index.d.ts index 00d15ba073..e511120f57 100644 --- a/types/restangular/index.d.ts +++ b/types/restangular/index.d.ts @@ -128,7 +128,7 @@ declare namespace restangular { getRestangularUrl(): string; getRequestedUrl(): string; route?: string; - id?: string; + id?: number | string; reqParams?: any; } From feb092e579db83d9075a5e3370080740c058f35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=E1=BB=8Dc=20Thanh?= Date: Mon, 30 Apr 2018 23:11:53 +0700 Subject: [PATCH 011/113] [@type/elasticsearch] Change string type to any in connectionClass (#25246) * Change `connectionClass` type to any `connectionClass` can not be `string` type. I use my custom `HttpConnector` for sending custom request. * add describe `HttpConnector` class and write test * import `HttpConnector` and use it in `connectionClass` config --- types/elasticsearch/elasticsearch-tests.ts | 12 ++++++++++++ types/elasticsearch/index.d.ts | 4 +++- types/elasticsearch/src/lib/connectors/http.d.ts | 13 +++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 types/elasticsearch/src/lib/connectors/http.d.ts diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index e21f84dc48..3236a181a1 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -1,10 +1,22 @@ import * as elasticsearch from "elasticsearch"; +import HttpConnector = require("elasticsearch/src/lib/connectors/http"); + +class MyHttpConnector extends HttpConnector { + constructor(host: any, config: any) { + super(host, config); + } +} let client = new elasticsearch.Client({ host: 'localhost:9200', log: 'trace' }); +client = new elasticsearch.Client({ + host: 'localhost:9200', + connectionClass: MyHttpConnector +}); + client = new elasticsearch.Client({ hosts: [ 'box1.server.org', diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index e60e8d86c3..7973b598ab 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -12,6 +12,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +import HttpConnector = require("./src/lib/connectors/http"); + export class Client { constructor(params: ConfigOptions); cat: Cat; @@ -111,7 +113,7 @@ export interface ConfigOptions { keepAlive?: boolean; maxSockets?: number; suggestCompression?: boolean; - connectionClass?: string; + connectionClass?: string | typeof HttpConnector; sniffedNodesProtocol?: string; ssl?: object; selector?: any; diff --git a/types/elasticsearch/src/lib/connectors/http.d.ts b/types/elasticsearch/src/lib/connectors/http.d.ts new file mode 100644 index 0000000000..94d1e4e58c --- /dev/null +++ b/types/elasticsearch/src/lib/connectors/http.d.ts @@ -0,0 +1,13 @@ +// HttpConnector for elasticsearch + +export = HttpConnector; + +declare class HttpConnector { + constructor(host: any, config: any); + + // onStatusSet(handler: (status: any) => void): void; + createAgent(config: any): any; + makeAgentConfig(config: any): any; + makeReqParams(params: any): any; + request(params: any, callback: (error: any, response: any, status: any, headers: any) => void): void; +} From 31a5880939de505166f22d783de2a6b6c23c64bb Mon Sep 17 00:00:00 2001 From: Gaurav Lahoti Date: Mon, 30 Apr 2018 21:42:49 +0530 Subject: [PATCH 012/113] redux-persist-transform-encrypt 2.0 definitions (#25231) --- types/redux-persist-transform-encrypt/async.d.ts | 8 ++++++-- types/redux-persist-transform-encrypt/index.d.ts | 4 +++- .../redux-persist-transform-encrypt-tests.ts | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/types/redux-persist-transform-encrypt/async.d.ts b/types/redux-persist-transform-encrypt/async.d.ts index 189b0af333..ea0dc56544 100644 --- a/types/redux-persist-transform-encrypt/async.d.ts +++ b/types/redux-persist-transform-encrypt/async.d.ts @@ -1,3 +1,7 @@ -import createAsyncEncryptor from "."; +import { Transform } from "redux-persist"; -export default createAsyncEncryptor; +export interface AsyncEncryptorConfig { + secretKey: string; +} + +export default function createAsyncEncryptor(config: AsyncEncryptorConfig): Transform; diff --git a/types/redux-persist-transform-encrypt/index.d.ts b/types/redux-persist-transform-encrypt/index.d.ts index a3d5dc1750..354ee043b0 100644 --- a/types/redux-persist-transform-encrypt/index.d.ts +++ b/types/redux-persist-transform-encrypt/index.d.ts @@ -1,12 +1,14 @@ -// Type definitions for redux-persist-transform-encrypt 1.0 +// Type definitions for redux-persist-transform-encrypt 2.0 // Project: https://github.com/maxdeviant/redux-persist-transform-encrypt // Definitions by: Karol Janyst +// Gaurav Lahoti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { Transform } from "redux-persist"; export interface EncryptorConfig { secretKey: string; + onError?: (err: Error) => void; } export default function createEncryptor(config: EncryptorConfig): Transform; diff --git a/types/redux-persist-transform-encrypt/redux-persist-transform-encrypt-tests.ts b/types/redux-persist-transform-encrypt/redux-persist-transform-encrypt-tests.ts index 1a3d61631d..8dcb27bd20 100644 --- a/types/redux-persist-transform-encrypt/redux-persist-transform-encrypt-tests.ts +++ b/types/redux-persist-transform-encrypt/redux-persist-transform-encrypt-tests.ts @@ -1,14 +1,22 @@ import { createStore, Reducer, Store } from "redux"; import { createPersistor, Transform } from "redux-persist"; import createEncryptor, { EncryptorConfig } from "redux-persist-transform-encrypt"; -import createAsyncEncryptor from "redux-persist-transform-encrypt/async"; +import createAsyncEncryptor, { AsyncEncryptorConfig } from "redux-persist-transform-encrypt/async"; const reducer: Reducer = (state: any, action: any) => ({ state, action }); -const config: EncryptorConfig = { secretKey : "foo" }; +const config: EncryptorConfig = { + secretKey: "foo", + onError: (err: Error) => { err.message; } +}; const encryptor: Transform = createEncryptor(config); -const asyncEncryptor: Transform = createAsyncEncryptor(config); + +const configNoError: EncryptorConfig = { secretKey: "foo" }; +const encryptorNoError: Transform = createEncryptor(configNoError); + +const asyncConfig: AsyncEncryptorConfig = { secretKey: "foo" }; +const asyncEncryptor: Transform = createAsyncEncryptor(asyncConfig); const store: Store = createStore(reducer); -createPersistor(store, { transforms : [encryptor, asyncEncryptor] }); +createPersistor(store, { transforms : [encryptor, encryptorNoError, asyncEncryptor] }); From edd9c31ed8730fba9bb8c0c050513d7738605961 Mon Sep 17 00:00:00 2001 From: Brian Crowell Date: Mon, 30 Apr 2018 11:14:16 -0500 Subject: [PATCH 013/113] [node] Allow object-mode write and writev in WritableOptions (#25263) Writable's write function accepts chunks of type any to permit object-mode usage. The implementations you can provide to Writable's constructor should do the same. --- types/node/index.d.ts | 4 ++-- types/node/v4/index.d.ts | 4 ++-- types/node/v6/index.d.ts | 4 ++-- types/node/v7/index.d.ts | 4 ++-- types/node/v8/index.d.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 4fc49dfedb..8c132f3799 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -5871,8 +5871,8 @@ declare module "stream" { highWaterMark?: number; decodeStrings?: boolean; objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: Array<{ chunk: string | Buffer, encoding: string }>, callback: Function) => any; + write?: (chunk: any, encoding: string, callback: Function) => any; + writev?: (chunks: Array<{ chunk: any, encoding: string }>, callback: Function) => any; destroy?: (error?: Error) => any; final?: (callback: (error?: Error) => void) => void; } diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 4793b4e9f7..3a7825dff8 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -2365,8 +2365,8 @@ declare module "stream" { highWaterMark?: number; decodeStrings?: boolean; objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + write?: (chunk: any, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: any, encoding: string }[], callback: Function) => any; } export class Writable extends Stream implements NodeJS.WritableStream { diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 8cde8ee611..e615662fe6 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -3710,8 +3710,8 @@ declare module "stream" { highWaterMark?: number; decodeStrings?: boolean; objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + write?: (chunk: any, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: any, encoding: string }[], callback: Function) => any; } export class Writable extends Stream implements NodeJS.WritableStream { diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index e8290f204c..366eb247fd 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -3818,8 +3818,8 @@ declare module "stream" { highWaterMark?: number; decodeStrings?: boolean; objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + write?: (chunk: any, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: any, encoding: string }[], callback: Function) => any; } export class Writable extends Stream implements NodeJS.WritableStream { diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index 2d705270ef..05d617dd58 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -5368,8 +5368,8 @@ declare module "stream" { highWaterMark?: number; decodeStrings?: boolean; objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: Array<{ chunk: string | Buffer, encoding: string }>, callback: Function) => any; + write?: (chunk: any, encoding: string, callback: Function) => any; + writev?: (chunks: Array<{ chunk: any, encoding: string }>, callback: Function) => any; destroy?: (error?: Error) => any; final?: (callback: (error?: Error) => void) => void; } From 7c9875bc0285a2c288578ffcb21196429db7cdaa Mon Sep 17 00:00:00 2001 From: Andrew Goodale Date: Mon, 30 Apr 2018 12:15:36 -0400 Subject: [PATCH 014/113] Add missing fetch types compatible with TS 2.6+ (#25255) --- types/react-native/globals.d.ts | 93 ++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/types/react-native/globals.d.ts b/types/react-native/globals.d.ts index b222b50ca4..92ae988ecb 100644 --- a/types/react-native/globals.d.ts +++ b/types/react-native/globals.d.ts @@ -21,4 +21,95 @@ declare function requestAnimationFrame(callback: (time: number) => void): number declare function fetchBundle(bundleId: number, callback: (error?: Error | null) => void): void; -declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +// +// Fetch API +// + +declare function fetch(input: Request | string, init?: RequestInit): Promise; + +interface Blob {} + +declare interface FormData { + append(name: string, value: any): void; +} + +declare interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; + formData(): Promise; +} + +declare interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: Function, thisArg?: any): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: HeadersInit_): Headers; +}; + +type BodyInit_ = Blob | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | FormData | string | null; + +declare interface RequestInit { + body?: BodyInit_; + credentials?: RequestCredentials_; + headers?: HeadersInit_; + integrity?: string; + keepalive?: boolean; + method?: string; + mode?: RequestMode_; + referrer?: string; + window?: any; +} + +declare interface Request extends Object, Body { + readonly credentials: RequestCredentials_; + readonly headers: Headers; + readonly method: string; + readonly mode: RequestMode_; + readonly referrer: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +}; + +declare interface ResponseInit { + headers?: HeadersInit_; + status?: number; + statusText?: string; +} + +declare interface Response extends Object, Body { + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: ResponseType_; + readonly url: string; + readonly redirected: boolean; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: BodyInit_, init?: ResponseInit): Response; + error: () => Response; + redirect: (url: string, status?: number) => Response; +}; + +type HeadersInit_ = Headers | string[][] | { [key: string]: string }; +type RequestCredentials_ = "omit" | "same-origin" | "include"; +type RequestMode_ = "navigate" | "same-origin" | "no-cors" | "cors"; +type ResponseType_ = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; From 16bffafcfc8a9235087e9fafbb62c541e27c0161 Mon Sep 17 00:00:00 2001 From: Cyril Gandon Date: Mon, 30 Apr 2018 18:16:06 +0200 Subject: [PATCH 015/113] [restangular] extendModel and extendCollection belongs to IProvider (#25257) * [restangular] extendModel and extendCollection belongs to IProvider * fix(restangular): function returns the object --- types/restangular/index.d.ts | 4 ++-- types/restangular/restangular-tests.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/restangular/index.d.ts b/types/restangular/index.d.ts index e511120f57..e0a77694b2 100644 --- a/types/restangular/index.d.ts +++ b/types/restangular/index.d.ts @@ -69,6 +69,8 @@ declare namespace restangular { setSelfLinkAbsoluteUrl(value: boolean): IProvider; setParentless(value: any): IProvider; setPlainByDefault(isPlain: boolean): IProvider; + extendModel(route: string, extender: (model: IElement) => any): IProvider; + extendCollection(route: string, extender: (collection: ICollection) => any): IProvider; } interface ICustom { @@ -94,8 +96,6 @@ declare namespace restangular { restangularizeCollection(parent: any, element: any, route: string): ICollection; service(route: string, parent?: any): IScopedService; stripRestangular(element: any): any; - extendModel(route: string, extender: (model: IElement) => any): void; - extendCollection(route: string, extender: (collection: ICollection) => any): void; } interface IScopedService extends IService { diff --git a/types/restangular/restangular-tests.ts b/types/restangular/restangular-tests.ts index 2ede97a893..97739fb496 100644 --- a/types/restangular/restangular-tests.ts +++ b/types/restangular/restangular-tests.ts @@ -27,6 +27,16 @@ myApp.config((RestangularProvider: restangular.IProvider) => { return elem; }); + RestangularProvider.extendModel('accounts', function(model: any) { + model.prettifyAmount = function() {}; + return model; + }); + + RestangularProvider.extendCollection('accounts', function(collection: any) { + collection.totalAmount = function() {}; + return collection; + }); + RestangularProvider.setRestangularFields({ id: "_id", route: "restangularRoute", From c63717aa3ee022b0cf50cf4414b295dffb30884b Mon Sep 17 00:00:00 2001 From: gustavderdrache Date: Mon, 30 Apr 2018 12:16:44 -0400 Subject: [PATCH 016/113] Update Parsimmon (#25264) * Fixes type of `thru()` * Fixes documentation of `mark()` * Adds `node()` method --- types/parsimmon/index.d.ts | 14 ++++++++++++-- types/parsimmon/parsimmon-tests.ts | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/types/parsimmon/index.d.ts b/types/parsimmon/index.d.ts index c25ab020de..96909be96a 100644 --- a/types/parsimmon/index.d.ts +++ b/types/parsimmon/index.d.ts @@ -61,6 +61,10 @@ declare namespace Parsimmon { value: T; } + interface Node extends Mark { + name: Name; + } + type Result = Success | Failure; interface Success { @@ -126,7 +130,7 @@ declare namespace Parsimmon { * 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; + thru(call: (wrapper: Parser) => Parser): Parser; /** * expects anotherParser before and after parser, yielding the result of parser */ @@ -181,9 +185,15 @@ declare namespace Parsimmon { */ atLeast(n: number): Parser; /** - * returns a new parser whose failure message is the passed description. + * Yields an object with `start`, `value`, and `end` keys, where `value` is the original + * value yielded by the parser, and `start` and `end` indicate the `Index` objects representing + * the range of the parse result. */ mark(): Parser>; + /** + * Like `mark()`, but yields an object with an additional `name` key to use as an AST. + */ + node(name: Name): Parser>; /** * Returns a new parser whose failure message is description. * For example, string('x').desc('the letter x') will indicate that 'the letter x' was expected. diff --git a/types/parsimmon/parsimmon-tests.ts b/types/parsimmon/parsimmon-tests.ts index c6dbaec22c..dbcf3d0753 100644 --- a/types/parsimmon/parsimmon-tests.ts +++ b/types/parsimmon/parsimmon-tests.ts @@ -192,6 +192,28 @@ strPar = P.test((a: string) => false); strPar = P.takeWhile((a: string) => true); +// Slightly modified from the documentation example for 'parser.thru(wrapper)'. +function makeNode(name: Name) { + return (parser: P.Parser): P.Parser> => { + return P.seqMap( + P.index, + parser, + P.index, + (start, value, end) => { + return { + name, + start, + value, + end, + }; + }, + ); + }; +} + +let node: P.Parser> = P.letters.node('identifier'); +node = P.letters.thru(makeNode('identifier')); + // -- -- -- -- -- -- -- -- -- -- -- -- -- let language: Language; From 4cc58ce6028e3b0ed8c1fd57ff284accce26fbf7 Mon Sep 17 00:00:00 2001 From: Maarten Rijke Date: Mon, 30 Apr 2018 18:17:03 +0200 Subject: [PATCH 017/113] [react-table] Fix onFilteredChange function signature (#25254) Like onSortedChange's first argument of an Array of SortingRules, onFilteredChange's first argument is an Array of Filters. --- types/react-table/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-table/index.d.ts b/types/react-table/index.d.ts index 503b5f4e02..d748fcffb2 100644 --- a/types/react-table/index.d.ts +++ b/types/react-table/index.d.ts @@ -24,7 +24,7 @@ export type SubComponentFunction = (rowInfo: RowInfo) => React.ReactNode; export type PageChangeFunction = (page: number) => void; export type PageSizeChangeFunction = (newPageSize: number, newPage: number) => void; export type SortedChangeFunction = (newSorted: SortingRule[], column: any, additive: boolean) => void; -export type FilteredChangeFunction = (newFiltering: Filter, column: any, value: any) => void; +export type FilteredChangeFunction = (newFiltering: Filter[], column: any, value: any) => void; export type ExpandedChangeFunction = (column: any, event: any, isTouch: boolean) => void; export type ResizedChangeFunction = (newResized: Resize[], event: any) => void; export type SortFunction = (a: any, b: any, desc: any) => -1 | 0 | 1; From cd3e69c4dba14eb2ae9e8dd8e38fc1fe55b8db4f Mon Sep 17 00:00:00 2001 From: Ty Thorsen Date: Mon, 30 Apr 2018 11:17:51 -0500 Subject: [PATCH 018/113] change type of IFlow.opts to IFlowOptions (#25274) --- types/flowjs/flowjs-tests.ts | 2 +- types/flowjs/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/flowjs/flowjs-tests.ts b/types/flowjs/flowjs-tests.ts index efb2c30f5b..6167e7f58f 100644 --- a/types/flowjs/flowjs-tests.ts +++ b/types/flowjs/flowjs-tests.ts @@ -4,7 +4,7 @@ var flowObject: flowjs.IFlow; var bool: boolean = flowObject.support; bool = flowObject.supportDirectory; -var obj: Object = flowObject.opts; +var flowOpts: flowjs.IFlowOptions = flowObject.opts; var flowFileArray: flowjs.IFlowFile[] = flowObject.files; flowObject.assignBrowse( [], false, false, {}); diff --git a/types/flowjs/index.d.ts b/types/flowjs/index.d.ts index 7d1f922330..0a6c361c73 100644 --- a/types/flowjs/index.d.ts +++ b/types/flowjs/index.d.ts @@ -7,7 +7,7 @@ declare namespace flowjs { interface IFlow { support: boolean; supportDirectory: boolean; - opts: Object; + opts: IFlowOptions; files: IFlowFile[]; assignBrowse(domNodes: HTMLElement[], isDirectory: boolean, singleFile: boolean, attributes: Object): void; From 620ed4b696f164efcc4e6f50b5d703b86e22f4fb Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 30 Apr 2018 11:09:12 -0700 Subject: [PATCH 019/113] jquery: Fix tests (#25422) --- types/jquery/jquery-tests.ts | 4 ++-- types/jquery/test/longdesc-tests.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 6773f923ef..5d6aaf0680 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -655,9 +655,9 @@ function JQueryStatic() { } function isNumeric() { - function type_guard(obj: boolean) { + function type_guard(obj: boolean | number) { if ($.isNumeric(obj)) { - // $ExpectType (true & number) | (false & number) + // $ExpectType number obj; } else { // $ExpectType boolean diff --git a/types/jquery/test/longdesc-tests.ts b/types/jquery/test/longdesc-tests.ts index 23ff500d24..3405bb83b5 100644 --- a/types/jquery/test/longdesc-tests.ts +++ b/types/jquery/test/longdesc-tests.ts @@ -1437,7 +1437,7 @@ function longdesc() { $.getJSON('ajax/test.json', function(data) { var items: string[] = []; $.each(data, function(key, val) { - items.push('
  • ' + val + '
  • '); + items.push('
  • ' + val + '
  • '); }); $('
      ', { From d010c2aeab88ecc300eac377ef653fbf721ab188 Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Mon, 30 Apr 2018 16:27:34 -0700 Subject: [PATCH 020/113] node: add util.isDeepStrictEqual() for v9 and v10. (#25408) --- types/node/index.d.ts | 1 + types/node/node-tests.ts | 3 +++ types/node/v9/index.d.ts | 1 + types/node/v9/node-tests.ts | 3 +++ 4 files changed, 8 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 8c132f3799..04e074da29 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6079,6 +6079,7 @@ declare module "util" { /** @deprecated since v4.0.0 - use `value === undefined` instead. */ export function isUndefined(object: any): object is undefined; export function deprecate(fn: T, message: string): T; + export function isDeepStrictEqual(val1: any, val2: any): boolean; export interface CustomPromisify extends Function { __promisify__: TCustom; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 7a055c620e..efc00ef201 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -851,6 +851,9 @@ namespace util_tests { util.deprecate(foo, 'foo() is deprecated, use bar() instead'); // $ExpectType (fn: T, message: string) => T util.deprecate(util.deprecate, 'deprecate() is deprecated, use bar() instead'); + + // util.isDeepStrictEqual + util.isDeepStrictEqual({foo: 'bar'}, {foo: 'bar'}); } } diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 50a17ddb76..d238a3c80b 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -5554,6 +5554,7 @@ declare module "util" { export function isSymbol(object: any): object is symbol; export function isUndefined(object: any): object is undefined; export function deprecate(fn: T, message: string): T; + export function isDeepStrictEqual(val1: any, val2: any): boolean; export interface CustomPromisify extends Function { __promisify__: TCustom; diff --git a/types/node/v9/node-tests.ts b/types/node/v9/node-tests.ts index 7a055c620e..efc00ef201 100644 --- a/types/node/v9/node-tests.ts +++ b/types/node/v9/node-tests.ts @@ -851,6 +851,9 @@ namespace util_tests { util.deprecate(foo, 'foo() is deprecated, use bar() instead'); // $ExpectType (fn: T, message: string) => T util.deprecate(util.deprecate, 'deprecate() is deprecated, use bar() instead'); + + // util.isDeepStrictEqual + util.isDeepStrictEqual({foo: 'bar'}, {foo: 'bar'}); } } From f165fc74838df107ac11d358c4129e3c91c43f19 Mon Sep 17 00:00:00 2001 From: Lee Standen Date: Tue, 1 May 2018 08:49:43 -0700 Subject: [PATCH 021/113] add types for react-autocomplete (#25433) --- types/react-autocomplete/index.d.ts | 147 ++++++++++++++++++ .../react-autocomplete-tests.tsx | 18 +++ types/react-autocomplete/tsconfig.json | 17 ++ types/react-autocomplete/tslint.json | 1 + 4 files changed, 183 insertions(+) create mode 100644 types/react-autocomplete/index.d.ts create mode 100644 types/react-autocomplete/react-autocomplete-tests.tsx create mode 100644 types/react-autocomplete/tsconfig.json create mode 100644 types/react-autocomplete/tslint.json diff --git a/types/react-autocomplete/index.d.ts b/types/react-autocomplete/index.d.ts new file mode 100644 index 0000000000..2234f70c6a --- /dev/null +++ b/types/react-autocomplete/index.d.ts @@ -0,0 +1,147 @@ +// Type definitions for react-autocomplete 1.8 +// Project: https://github.com/reactjs/react-autocomplete +// Definitions by: Lee Standen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Component, ChangeEvent, ReactNode, CSSProperties, HTMLProps } from 'react'; + +export = Autocomplete; +declare namespace Autocomplete { + interface Props { + /** + * The items to display in the dropdown menu + */ + items: any[]; + /** + * The value to display in the input field + */ + value: any; + /** + * Arguments: `event: Event, value: String` + * + * Invoked every time the user changes the input's value. + */ + onChange?: (e: ChangeEvent, value: string) => void; + /** + * Arguments: `value: String, item: Any` + * + * Invoked when the user selects an item from the dropdown menu. + */ + onSelect?: (value: string, item: any) => void; + /** + * Arguments: `item: Any, value: String` + * + * Invoked for each entry in `items` and its return value is used to + * determine whether or not it should be displayed in the dropdown menu. + * By default all items are always rendered. + */ + shouldItemRender?: (item: any, value: string) => boolean; + /** + * Arguments: `item: Any` + * + * Invoked when attempting to select an item. The return value is used to + * determine whether the item should be selectable or not. + * By default all items are selectable. + */ + isItemSelectable?: (item: any) => boolean; + /** + * Arguments: `itemA: Any, itemB: Any, value: String` + * + * The function which is used to sort `items` before display. + */ + sortItems?: (a: any, b: any, value: string) => number; + /** + * Arguments: `item: Any` + * + * Used to read the display value from each entry in `items`. + */ + getItemValue: (item: any) => string; + /** + * Arguments: `item: Any, isHighlighted: Boolean, styles: Object` + * + * Invoked for each entry in `items` that also passes `shouldItemRender` to + * generate the render tree for each item in the dropdown menu. `styles` is + * an optional set of styles that can be applied to improve the look/feel + * of the items in the dropdown menu. + */ + renderItem: (item: any) => ReactNode; + /** + * Arguments: `items: Array, value: String, styles: Object` + * + * Invoked to generate the render tree for the dropdown menu. Ensure the + * returned tree includes every entry in `items` or else the highlight order + * and keyboard navigation logic will break. `styles` will contain + * { top, left, minWidth } which are the coordinates of the top-left corner + * and the width of the dropdown menu. + */ + renderMenu?: ( + items: any[], + value: string, + styles: CSSProperties, + ) => ReactNode; + /** + * Styles that are applied to the dropdown menu in the default `renderMenu` + * implementation. If you override `renderMenu` and you want to use + * `menuStyle` you must manually apply them (`this.props.menuStyle`). + */ + menuStyle?: CSSProperties; + /** + * Arguments: `props: Object` + * + * Invoked to generate the input element. The `props` argument is the result + * of merging `props.inputProps` with a selection of props that are required + * both for functionality and accessibility. At the very least you need to + * apply `props.ref` and all `props.on` event handlers. Failing to do + * this will cause `Autocomplete` to behave unexpectedly. + */ + renderInput?: (props: HTMLProps) => ReactNode; + /** + * Props passed to `props.renderInput`. By default these props will be + * applied to the `` element rendered by `Autocomplete`, unless you + * have specified a custom value for `props.renderInput`. Any properties + * supported by `HTMLInputElement` can be specified, apart from the + * following which are set by `Autocomplete`: value, autoComplete, role, + * aria-autocomplete. `inputProps` is commonly used for (but not limited to) + * placeholder, event handlers (onFocus, onBlur, etc.), autoFocus, etc.. + */ + inputProps?: HTMLProps; + /** + * Props that are applied to the element which wraps the `` and + * dropdown menu elements rendered by `Autocomplete`. + */ + wrapperProps?: HTMLProps; + /** + * This is a shorthand for `wrapperProps={{ style: }}`. + * Note that `wrapperStyle` is applied before `wrapperProps`, so the latter + * will win if it contains a `style` entry. + */ + wrapperStyle?: CSSProperties; + /** + * Whether or not to automatically highlight the top match in the dropdown + * menu. + */ + autoHighlight?: boolean; + /** + * Whether or not to automatically select the highlighted item when the + * `` loses focus. + */ + selectOnBlur?: boolean; + /** + * Arguments: `isOpen: Boolean` + * + * Invoked every time the dropdown menu's visibility changes (i.e. every + * time it is displayed/hidden). + */ + onMenuVisibilityChange?: (isOpen: boolean) => void; + /** + * Used to override the internal logic which displays/hides the dropdown + * menu. This is useful if you want to force a certain state based on your + * UX/business logic. Use it together with `onMenuVisibilityChange` for + * fine-grained control over the dropdown menu dynamics. + */ + open?: boolean; + debug?: boolean; + } +} +declare class Autocomplete extends Component {} diff --git a/types/react-autocomplete/react-autocomplete-tests.tsx b/types/react-autocomplete/react-autocomplete-tests.tsx new file mode 100644 index 0000000000..36834b46d1 --- /dev/null +++ b/types/react-autocomplete/react-autocomplete-tests.tsx @@ -0,0 +1,18 @@ +import * as Autocomplete from 'react-autocomplete'; + +import * as React from 'react'; +import { render } from 'react-dom'; + +declare const container: Element; + +const items = ['hello', 'world']; + +render( + item} + renderItem={(item) =>
      {item}
      } + value={items[0]} + />, + container, +); diff --git a/types/react-autocomplete/tsconfig.json b/types/react-autocomplete/tsconfig.json new file mode 100644 index 0000000000..c30d8089b2 --- /dev/null +++ b/types/react-autocomplete/tsconfig.json @@ -0,0 +1,17 @@ +{ + "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-autocomplete-tests.tsx"] +} diff --git a/types/react-autocomplete/tslint.json b/types/react-autocomplete/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-autocomplete/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b2549f5a1eaee12454b934696136b89bb61b1f1a Mon Sep 17 00:00:00 2001 From: Lee Standen Date: Tue, 1 May 2018 08:50:17 -0700 Subject: [PATCH 022/113] add @atlaskit/single-select (#25432) --- .../atlaskit__single-select-tests.tsx | 14 ++ types/atlaskit__single-select/index.d.ts | 125 ++++++++++++++++++ types/atlaskit__single-select/tsconfig.json | 20 +++ types/atlaskit__single-select/tslint.json | 1 + 4 files changed, 160 insertions(+) create mode 100644 types/atlaskit__single-select/atlaskit__single-select-tests.tsx create mode 100644 types/atlaskit__single-select/index.d.ts create mode 100644 types/atlaskit__single-select/tsconfig.json create mode 100644 types/atlaskit__single-select/tslint.json diff --git a/types/atlaskit__single-select/atlaskit__single-select-tests.tsx b/types/atlaskit__single-select/atlaskit__single-select-tests.tsx new file mode 100644 index 0000000000..baa25dfe1f --- /dev/null +++ b/types/atlaskit__single-select/atlaskit__single-select-tests.tsx @@ -0,0 +1,14 @@ +import SingleSelect, { StatelessSelect } from '@atlaskit/single-select'; + +import * as React from 'react'; +import { render } from 'react-dom'; + +declare const container: Element; + +render( +
      + + +
      , + container, +); diff --git a/types/atlaskit__single-select/index.d.ts b/types/atlaskit__single-select/index.d.ts new file mode 100644 index 0000000000..6536869512 --- /dev/null +++ b/types/atlaskit__single-select/index.d.ts @@ -0,0 +1,125 @@ +// Type definitions for @atlaskit/single-select 4.0 +// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/ +// Definitions by: Lee Standen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Component, ReactNode, SyntheticEvent } from 'react'; + +export default class SingleSelect extends Component {} +export class StatelessSelect extends Component {} + +export interface Props { + /** Subtle items do not have a background color. */ + appearance?: 'default' | 'subtle'; + /** Item to be selected on component mount. */ + defaultSelected?: ItemType; + /** Sets whether the dropdown should be constrained to the width of its trigger */ + droplistShouldFitContainer?: boolean; + /** + * Sets whether the field should be selectable. If it is, the field will be + * a text box, which will filter the items. + */ + hasAutocomplete?: boolean; + /** id property to be passed down to the html select component. */ + id?: string; + /** message to show on the dialog when isInvalid is true */ + invalidMessage?: ReactNode; + /** controls the top margin of the label component rendered. */ + isFirstChild?: boolean; + /** Sets whether the select is selectable. Changes hover state. */ + isDisabled?: boolean; + /** Sets whether the component should be open on mount. */ + isDefaultOpen?: boolean; + /** + * Sets whether form including select can be submitted without an option + * being made. + */ + isRequired?: boolean; + /** + * Set whether there is an error with the selection. Sets an orange border + * and shows the warning icon. + */ + isInvalid?: boolean; + /** + * An array of objects, each one of which must have an array of items, and + * may have a heading. All items should have content and value properties, with + * content being the displayed text. + */ + items?: GroupType[]; + /** Label to be displayed above select. */ + label?: string; + /** name property to be passed to the html select element. */ + name?: string; + /** + * Message to display in any group in items if there are no items in it, + * including if there is one item that has been selected. + */ + noMatchesFound?: string; + /** Handler to be called when the filtered items changes. */ + onFilterChange?: (filter: string) => void; + /** + * Handler to be called when an item is selected. Called with an object that + * has the item selected as a property on the object. + */ + onSelected?: (item: ItemType) => void; + /** + * Handler called when the select is opened or closed. Called with an object + * that has both the event, and the new isOpen state. + */ + onOpenChange?: ( + change: { event: SyntheticEvent; isOpen: boolean }, + ) => void; + /** Text to be shown within the select when no item is selected. */ + placeholder?: string; + /** Where the select dropdown should be displayed relative to the field position. */ + position?: string; + /** Sets whether the field will become focused. */ + shouldFocus?: boolean; + /** Sets whether the field should be constrained to the width of its trigger */ + shouldFitContainer?: boolean; + /** Sets whether the droplist should flip its position when there is not enough space. */ + shouldFlip?: boolean; + /** Set the max height of the dropdown list in pixels. */ + maxHeight?: number; +} + +export interface StatelessProps extends Props { + /** Value to be used when filtering the items. Compared against 'content'. */ + filterValue?: string; + /** Sets whether the Select dropdown is open. */ + isOpen?: boolean; + /** + * Sets whether the field is loading data. The same property is used + * for either initial fetch (when no options are available) as well for + * subsequent loading of more options. The component reacts accordingly + * based on the `items` provided. + */ + isLoading?: boolean; + /** + * Message to be displayed when the component is set to its loading state. + * The message might be displayed differently depending on whether or not + * there are items already being rendered. + */ + loadingMessage?: string; + /** The selected item data */ + selectedItem?: ItemType; +} + +export interface GroupType { + heading?: string; + items: ItemType[]; +} + +export interface ItemType { + content?: ReactNode; + description?: string; + label?: string; + tooltipDescription?: string; + tooltipPosition?: 'top' | 'bottom' | 'left'; + value?: string | number; + filterValues?: string[]; + isDisabled?: boolean; + isSelected?: boolean; + elemBefore?: ReactNode; +} diff --git a/types/atlaskit__single-select/tsconfig.json b/types/atlaskit__single-select/tsconfig.json new file mode 100644 index 0000000000..1ec4324243 --- /dev/null +++ b/types/atlaskit__single-select/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "paths": { + "@atlaskit/single-select": ["atlaskit__single-select"] + } + }, + "files": ["index.d.ts", "atlaskit__single-select-tests.tsx"] +} diff --git a/types/atlaskit__single-select/tslint.json b/types/atlaskit__single-select/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/atlaskit__single-select/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From cf14d85ec08888dca6a43ab69707f661a12c02b8 Mon Sep 17 00:00:00 2001 From: Daniela Yassuda Date: Tue, 1 May 2018 12:51:01 -0300 Subject: [PATCH 023/113] Create definitions for react-image-crop (#25431) * Create definitions for react-image-crop * Fix required TypeScript version to match React's --- types/react-image-crop/index.d.ts | 73 +++++++++++ .../test/react-image-crop-global-tests.ts | 113 ++++++++++++++++++ .../test/react-image-crop-module-tests.tsx | 113 ++++++++++++++++++ types/react-image-crop/tsconfig.json | 26 ++++ types/react-image-crop/tslint.json | 1 + 5 files changed, 326 insertions(+) create mode 100644 types/react-image-crop/index.d.ts create mode 100644 types/react-image-crop/test/react-image-crop-global-tests.ts create mode 100644 types/react-image-crop/test/react-image-crop-module-tests.tsx create mode 100644 types/react-image-crop/tsconfig.json create mode 100644 types/react-image-crop/tslint.json diff --git a/types/react-image-crop/index.d.ts b/types/react-image-crop/index.d.ts new file mode 100644 index 0000000000..afadc9d8ac --- /dev/null +++ b/types/react-image-crop/index.d.ts @@ -0,0 +1,73 @@ +// Type definitions for react-image-crop 3.0 +// Project: https://github.com/DominicTobias/react-image-crop +// Definitions by: Daniela Yassuda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Component, CSSProperties, ReactNode } from 'react'; + +export as namespace ReactCrop; + +declare namespace ReactCrop { + interface Crop { + aspect?: number; + x: number; + y: number; + width?: number; + height?: number; + } + + interface PixelCrop { + x: number; + y: number; + width: number; + height: number; + } + + interface ReactCropProps { + src: string; + crop?: Crop; + imageAlt?: string; + minWidth?: number; + minHeight?: number; + maxWidth?: number; + maxHeight?: number; + keepSelection?: boolean; + onChange: (crop: Crop, pixelCrop: PixelCrop) => void; + onComplete?: (crop: Crop, pixelCrop: PixelCrop) => void; + onImageLoaded?: (target: HTMLImageElement) => void; + onDragStart?: () => void; + onDragEnd?: () => void; + disabled?: boolean; + crossorigin?: string; + children?: ReactNode; + style?: CSSProperties; + imageStyle?: CSSProperties; + } + + function getPixelCrop(image: HTMLImageElement, percentCrop: Crop): Crop; + function makeAspectCrop(crop: Crop, imageAspect: number): Crop; + function containCrop(crop: Crop, imageAspect: number): Crop; +} + +declare class ReactCrop extends Component { + onCropMouseTouchDown: (e: MouseEvent) => void; + onComponentMouseTouchDown: (e: MouseEvent) => void; + onDocMouseTouchMove: (e: MouseEvent) => void; + onComponentKeyDown: (e: MouseEvent) => void; + onDocMouseTouchEnd: (e: MouseEvent) => void; + onImageLoad: (image: HTMLImageElement) => void; + getCropStyle: () => CSSProperties; + getNewSize: () => { + width: number, + height: number, + }; + dragCrop: () => ReactCrop.Crop; + resizeCrop: () => ReactCrop.Crop; + straightenYPath: (clientX: number) => number; + createCropSelection: () => ReactNode; + makeNewCrop: () => ReactCrop.Crop; + crossOverCheck: () => void; +} + +export = ReactCrop; diff --git a/types/react-image-crop/test/react-image-crop-global-tests.ts b/types/react-image-crop/test/react-image-crop-global-tests.ts new file mode 100644 index 0000000000..909610d0f7 --- /dev/null +++ b/types/react-image-crop/test/react-image-crop-global-tests.ts @@ -0,0 +1,113 @@ +interface TestState { + crop?: ReactCrop.Crop; +} + +// Basic use case +class SimpleTest extends React.Component<{}, TestState> { + constructor(props: {}) { + super(props); + this.state = {}; + } + + onChange = (crop: ReactCrop.Crop) => { + this.setState({ crop }); + } + + render() { + return React.createElement( + ReactCrop, + { + src: 'imageSrc', + onChange: this.onChange, + crop: this.state.crop, + }, + ); + } +} + +// Set an aspect ratio to crop +class AspectRatioTest extends React.Component<{}, TestState> { + constructor(props: {}) { + super(props); + this.state = {}; + } + + onChange = (crop: ReactCrop.Crop) => { + this.setState({ crop }); + } + + onImageLoaded = (image: HTMLImageElement) => { + this.setState({ + crop: ReactCrop.makeAspectCrop( + { + x: 0, + y: 0, + aspect: 16 / 9, + width: 50, + }, + image.width / image.height, + ), + }); + } + + render() { + return React.createElement( + ReactCrop, + { + src: 'imageSrc', + onChange: this.onChange, + onImageLoaded: this.onImageLoaded, + crop: this.state.crop, + }, + ); + } +} + +// All available props +class CompleteTest extends React.Component<{}, TestState> { + constructor(props: {}) { + super(props); + this.state = {}; + } + + onChange = (crop: ReactCrop.Crop) => { + this.setState({ crop }); + } + + onImageLoaded = (image: HTMLImageElement) => { + this.setState({ + crop: ReactCrop.makeAspectCrop( + { + x: 0, + y: 0, + aspect: 16 / 9, + width: 20, + }, + image.width / image.height, + ), + }); + } + + render() { + return React.createElement( + ReactCrop, + { + src: 'imageSrc', + onChange: this.onChange, + onImageLoaded: this.onImageLoaded, + crop: this.state.crop, + minWidth: 30, + minHeight: 30, + maxWidth: 90, + maxHeight: 90, + keepSelection: true, + disabled: false, + style: { border: '1px solid black', position: 'relative' }, + onComplete: () => console.log('Crop complete'), + onDragStart: () => console.log('Drag start'), + onDragEnd: () => console.log('Drag end'), + crossorigin: 'anonymous', + }, + ); + } +} diff --git a/types/react-image-crop/test/react-image-crop-module-tests.tsx b/types/react-image-crop/test/react-image-crop-module-tests.tsx new file mode 100644 index 0000000000..b9c0f766d9 --- /dev/null +++ b/types/react-image-crop/test/react-image-crop-module-tests.tsx @@ -0,0 +1,113 @@ +import * as React from 'react'; +import * as ReactCrop from 'react-image-crop'; + +interface TestState { + crop?: ReactCrop.Crop; +} + +// Basic use case +class SimpleTest extends React.Component<{}, TestState> { + constructor(props: {}) { + super(props); + this.state = {}; + } + + onChange = (crop: ReactCrop.Crop) => { + this.setState({ crop }); + } + + render() { + return ( + + ); + } +} + +// Set an aspect ratio to crop +class AspectRatioTest extends React.Component<{}, TestState> { + constructor(props: {}) { + super(props); + this.state = {}; + } + + onChange = (crop: ReactCrop.Crop) => { + this.setState({ crop }); + } + + onImageLoaded = (image: HTMLImageElement) => { + this.setState({ + crop: ReactCrop.makeAspectCrop( + { + x: 0, + y: 0, + aspect: 16 / 9, + width: 50, + }, + image.width / image.height, + ), + }); + } + + render() { + return ( + + ); + } +} + +// All available props +class CompleteTest extends React.Component<{}, TestState> { + constructor(props: {}) { + super(props); + this.state = {}; + } + + onChange = (crop: ReactCrop.Crop) => { + this.setState({ crop }); + } + + onImageLoaded = (image: HTMLImageElement) => { + this.setState({ + crop: ReactCrop.makeAspectCrop( + { + x: 0, + y: 0, + aspect: 16 / 9, + width: 20, + }, + image.width / image.height, + ), + }); + } + + render() { + return ( + console.log('Crop complete')} + onDragStart={() => console.log('Drag start')} + onDragEnd={() => console.log('Drag end')} + crossorigin="anonymous" + /> + ); + } +} diff --git a/types/react-image-crop/tsconfig.json b/types/react-image-crop/tsconfig.json new file mode 100644 index 0000000000..a24cd9e54b --- /dev/null +++ b/types/react-image-crop/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/react-image-crop-global-tests.ts", + "test/react-image-crop-module-tests.tsx" + ] +} diff --git a/types/react-image-crop/tslint.json b/types/react-image-crop/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-image-crop/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 33cd5f4d06d76a4717af1702dcbd1648a440fbc9 Mon Sep 17 00:00:00 2001 From: Ian Copp Date: Tue, 1 May 2018 08:56:33 -0700 Subject: [PATCH 024/113] Add react-share (#25446) --- types/react-share/index.d.ts | 205 +++++++++++++++++++++++++ types/react-share/react-share-tests.ts | 25 +++ types/react-share/tsconfig.json | 23 +++ types/react-share/tslint.json | 1 + 4 files changed, 254 insertions(+) create mode 100644 types/react-share/index.d.ts create mode 100644 types/react-share/react-share-tests.ts create mode 100644 types/react-share/tsconfig.json create mode 100644 types/react-share/tslint.json diff --git a/types/react-share/index.d.ts b/types/react-share/index.d.ts new file mode 100644 index 0000000000..756b917014 --- /dev/null +++ b/types/react-share/index.d.ts @@ -0,0 +1,205 @@ +// Type definitions for react-share 2.1 +// Project: https://github.com/nygardk/react-share#readme +// Definitions by: icopp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from 'react'; + +// ============================================================================= +// Share buttons +// ============================================================================= + +export interface CommonShareButtonProps { + /** + * URL of the shared page + */ + url: string; + /** Disables click action and adds `disabled` class */ + disabled?: boolean; + /** + * Style when button is disabled + * @default { opacity: 0.6 } + */ + disabledStyle?: React.StyleHTMLAttributes; + windowWidth?: number; + windowHeight?: number; + /** + * Takes a function that returns a Promise to be fulfilled before calling + * `onClick`. If you do not return promise, `onClick` is called immediately. + */ + beforeOnClick?: () => Promise; + /** + * Takes a function to be called after closing share dialog. + */ + onShareWindowClose?: () => void; + /** + * An object to pass any additional properties, such as `aria-*` attributes. + */ + additionalProps?: React.HTMLAttributes; +} + +export const FacebookShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** A quote to be shared along with the link. */ + quote?: string; + /** + * A hashtag specified by the developer to be added to the shared + * content. People will still have the opportunity to remove this + * hashtag in the dialog. The hashtag should include the hash symbol. + */ + hashtag?: string; + } +>; +export const GooglePlusShareButton: React.StatelessComponent< + CommonShareButtonProps +>; +export const LinkedinShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + /** Description of the shared page */ + description?: string; + } +>; +export const TwitterShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + via?: string; + hashtags?: string[]; + } +>; +export const TelegramShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + } +>; +export const WhatsappShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + /** + * Separates title from the url + * @default ' ' + */ + separator?: string; + } +>; +export const PinterestShareButton: React.StatelessComponent< + CommonShareButtonProps & { + media: string; + /** Description of the shared page */ + description?: string; + } +>; +export const VKShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + /** Description of the shared page */ + description?: string; + /** An absolute link to the image that will be shared */ + image?: string; + } +>; +export const OKShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + /** Description of the shared page */ + description?: string; + } +>; +export const RedditShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + } +>; +export const TumblrShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + tags?: string[]; + /** Description of the shared page */ + caption?: string; + } +>; +export const LivejournalShareButton: React.StatelessComponent< + CommonShareButtonProps & { title?: string; description?: string } +>; +export const MalruShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + title?: string; + /** Description of the shared page */ + description?: string; + /** An absolute link to the image that will be shared */ + image?: string; + } +>; +export const EmailShareButton: React.StatelessComponent< + CommonShareButtonProps & { + /** Title of the shared page */ + subject?: string; + /** Body of the email, defaults to shared url. */ + body?: string; + } +>; + +// ============================================================================= +// Share counts +// ============================================================================= + +export interface ShareCountComponentProps { + /** The URL you are sharing */ + url: string; + /** Classes to apply (if any) */ + className?: string; + /** Supply a function as the child to render anything but the count */ + children?: (shareCount: number) => React.ReactNode; +} + +export const FacebookShareCount: React.StatelessComponent; +export const GooglePlusShareCount: React.StatelessComponent; +export const LinkedinShareCount: React.StatelessComponent; +export const PinterestShareCount: React.StatelessComponent; +export const VKShareCount: React.StatelessComponent; +export const OKShareCount: React.StatelessComponent; +export const RedditShareCount: React.StatelessComponent; +export const TumblrShareCount: React.StatelessComponent; + +// ============================================================================= +// Icons +// ============================================================================= + +export interface IconComponentProps { + /** Icon size in pixels */ + size?: number; + /** Whether to show round or rect icons */ + round?: boolean; + /** Customize background style, e.g. fill */ + iconBgStyle?: React.CSSProperties; + /** + * Customize logo's fill color + * @default 'white' + */ + logoFillColor?: string; +} + +export const FacebookIcon: React.StatelessComponent; +export const TwitterIcon: React.StatelessComponent; +export const TelegramIcon: React.StatelessComponent; +export const WhatsappIcon: React.StatelessComponent; +export const GooglePlusIcon: React.StatelessComponent; +export const LinkedinIcon: React.StatelessComponent; +export const PinterestIcon: React.StatelessComponent; +export const VKIcon: React.StatelessComponent; +export const OKIcon: React.StatelessComponent; +export const RedditIcon: React.StatelessComponent; +export const TumblrIcon: React.StatelessComponent; +export const LivejournalIcon: React.StatelessComponent; +export const MailruIcon: React.StatelessComponent; +export const EmailIcon: React.StatelessComponent; diff --git a/types/react-share/react-share-tests.ts b/types/react-share/react-share-tests.ts new file mode 100644 index 0000000000..6b4628f8e0 --- /dev/null +++ b/types/react-share/react-share-tests.ts @@ -0,0 +1,25 @@ +import { + FacebookShareCount, // $ExpectType StatelessComponent + GooglePlusShareCount, // $ExpectType StatelessComponent + LinkedinShareCount, // $ExpectType StatelessComponent + PinterestShareCount, // $ExpectType StatelessComponent + VKShareCount, // $ExpectType StatelessComponent + OKShareCount, // $ExpectType StatelessComponent + RedditShareCount, // $ExpectType StatelessComponent + TumblrShareCount, // $ExpectType StatelessComponent + + FacebookIcon, // $ExpectType StatelessComponent + TwitterIcon, // $ExpectType StatelessComponent + TelegramIcon, // $ExpectType StatelessComponent + WhatsappIcon, // $ExpectType StatelessComponent + GooglePlusIcon, // $ExpectType StatelessComponent + LinkedinIcon, // $ExpectType StatelessComponent + PinterestIcon, // $ExpectType StatelessComponent + VKIcon, // $ExpectType StatelessComponent + OKIcon, // $ExpectType StatelessComponent + RedditIcon, // $ExpectType StatelessComponent + TumblrIcon, // $ExpectType StatelessComponent + LivejournalIcon, // $ExpectType StatelessComponent + MailruIcon, // $ExpectType StatelessComponent + EmailIcon, // $ExpectType StatelessComponent +} from 'react-share'; diff --git a/types/react-share/tsconfig.json b/types/react-share/tsconfig.json new file mode 100644 index 0000000000..2b5932cab4 --- /dev/null +++ b/types/react-share/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", + "react-share-tests.ts" + ] +} diff --git a/types/react-share/tslint.json b/types/react-share/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-share/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 6a8109481ac6a52ab045c3a22cc790efc4ff3d05 Mon Sep 17 00:00:00 2001 From: Ian Copp Date: Tue, 1 May 2018 08:57:01 -0700 Subject: [PATCH 025/113] Add express-routemap (#25445) --- .../express-routemap-tests.ts | 7 ++++++ types/express-routemap/index.d.ts | 10 ++++++++ types/express-routemap/tsconfig.json | 23 +++++++++++++++++++ types/express-routemap/tslint.json | 1 + 4 files changed, 41 insertions(+) create mode 100644 types/express-routemap/express-routemap-tests.ts create mode 100644 types/express-routemap/index.d.ts create mode 100644 types/express-routemap/tsconfig.json create mode 100644 types/express-routemap/tslint.json diff --git a/types/express-routemap/express-routemap-tests.ts b/types/express-routemap/express-routemap-tests.ts new file mode 100644 index 0000000000..e169a614b9 --- /dev/null +++ b/types/express-routemap/express-routemap-tests.ts @@ -0,0 +1,7 @@ +import express = require('express'); +import displayRoutes = require('express-routemap'); + +const server = express(); +server.listen(3000, () => { + displayRoutes(server); // $ExpectType void +}); diff --git a/types/express-routemap/index.d.ts b/types/express-routemap/index.d.ts new file mode 100644 index 0000000000..a2e80499b0 --- /dev/null +++ b/types/express-routemap/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for express-routemap 1.1 +// Project: https://github.com/izelnakri/express-routemap#readme +// Definitions by: icopp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Application } from 'express'; + +declare function displayRoutes(app: Application, filename?: string): void; +export = displayRoutes; diff --git a/types/express-routemap/tsconfig.json b/types/express-routemap/tsconfig.json new file mode 100644 index 0000000000..44638d2eb4 --- /dev/null +++ b/types/express-routemap/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", + "express-routemap-tests.ts" + ] +} diff --git a/types/express-routemap/tslint.json b/types/express-routemap/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-routemap/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 625675d4d0029fdfd1648c35424da0e23568b07d Mon Sep 17 00:00:00 2001 From: Ian Copp Date: Tue, 1 May 2018 08:57:43 -0700 Subject: [PATCH 026/113] Add rword (#25444) --- types/rword/index.d.ts | 69 ++++++++++++++++++++++++++++++++++++++ types/rword/rword-tests.ts | 12 +++++++ types/rword/tsconfig.json | 23 +++++++++++++ types/rword/tslint.json | 1 + 4 files changed, 105 insertions(+) create mode 100644 types/rword/index.d.ts create mode 100644 types/rword/rword-tests.ts create mode 100644 types/rword/tsconfig.json create mode 100644 types/rword/tslint.json diff --git a/types/rword/index.d.ts b/types/rword/index.d.ts new file mode 100644 index 0000000000..cad044933b --- /dev/null +++ b/types/rword/index.d.ts @@ -0,0 +1,69 @@ +// Type definitions for rword 2.2 +// Project: https://github.com/Xyfir/rword#readme +// Definitions by: icopp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface GenerateOptions { + /** + * Allows you to set an exact length or range of lengths for words to return. + */ + length?: number | string; + /** + * Words that don't match the regexp will not be returned. + */ + contains?: string | RegExp; + /** + * Changes the capitalization of the words returned. + */ + capitalize?: 'none' | 'all' | 'first'; +} + +/** + * Generates words from the global words array. + * @param count How many words to return. If 1 or not present, a string is + * returned. If greater than 1 an array of strings is returned. + * @param options Allows you to modify the output and words that could be + * randomly chosen. + */ +export function generate(count?: 1, options?: GenerateOptions): string; +/** + * Generates words from the global words array. + * @param count How many words to return. If 1 or not present, a string is + * returned. If greater than 1 an array of strings is returned. + * @param options Allows you to modify the output and words that could be + * randomly chosen. + */ +export function generate(count: number, options?: GenerateOptions): string[]; + +/** + * Generates words from the global pool array. The pool is automatically + * filled using rword.generate(500) and then words are taken out of that + * array as needed. Faster than rword.generate() for generating small + * amounts of words. + * + * You cannot request more than 10 words through this method. + * + * @param count How many words to return. If 1 or not present, a string is + * returned. If greater than 1 an array of strings is returned. + */ +export function generateFromPool(count?: 1): string; + +/** + * Generates words from the global pool array. The pool is automatically + * filled using rword.generate(500) and then words are taken out of that + * array as needed. Faster than rword.generate() for generating small + * amounts of words. + * + * You cannot request more than 10 words through this method. + * + * @param count How many words to return. If 1 or not present, a string is + * returned. If greater than 1 an array of strings is returned. + */ +export function generateFromPool(count: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10): string[]; + +/** + * Shuffles both the global words and pool arrays. This method can most + * likely be ignored as it is automatically called on first run and then + * every 10 to 30 minutes after. + */ +export function shuffle(): void; diff --git a/types/rword/rword-tests.ts b/types/rword/rword-tests.ts new file mode 100644 index 0000000000..7fbab8082a --- /dev/null +++ b/types/rword/rword-tests.ts @@ -0,0 +1,12 @@ +import rword = require('rword'); + +rword.generate(); // $ExpectType string +rword.generate(5, { length: 5 }); // $ExpectType string[] +rword.generate(3, { length: '3-4' }); // $ExpectType string[] +rword.generate(5, { contains: '.*ed' }); // $ExpectType string[] +rword.generate(5, { contains: 'af' }); // $ExpectType string[] +rword.generate(5, { contains: /.*ing$/ }); // $ExpectType string[] +rword.generate(3, { capitalize: 'all' }); // $ExpectType string[] +rword.generate(3, { capitalize: 'first' }); // $ExpectType string[] +rword.generateFromPool(5); // $ExpectType string[] +rword.shuffle(); // $ExpectType void diff --git a/types/rword/tsconfig.json b/types/rword/tsconfig.json new file mode 100644 index 0000000000..f98e8b5cb7 --- /dev/null +++ b/types/rword/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", + "rword-tests.ts" + ] +} diff --git a/types/rword/tslint.json b/types/rword/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rword/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From fa636385c0879aa246d4e8755918fe51c6143362 Mon Sep 17 00:00:00 2001 From: Dvorak Date: Tue, 1 May 2018 15:58:36 +0000 Subject: [PATCH 027/113] Papaparse: added Parser.pause() & Parser.resume() (#25447) --- types/papaparse/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index ddad5970cb..d97a25010b 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -74,6 +74,9 @@ export class Parser { // Gets the cursor position getCharIndex(): number; + + pause(): void; + resume(): void; } export interface ParseConfig { From 1a3875f3e4127129b26da5ce135b2e07f782c894 Mon Sep 17 00:00:00 2001 From: Operations Research Engineering Software+ Date: Tue, 1 May 2018 08:58:59 -0700 Subject: [PATCH 028/113] update index.d.ts (#25441) * update index.d.ts the constructor takes an optional string first argument, and an optional options second argument * Update index.d.ts the first argument to the constructor is actually a required arg according to the docs. --- 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 5147de1de4..6963da082d 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -30,7 +30,7 @@ export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, ObjectId, T // Class documentation : http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html export class MongoClient extends EventEmitter { - constructor(); + constructor(uri: string, options?: MongoClientOptions); /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#.connect */ static connect(uri: string, callback: MongoCallback): void; static connect(uri: string, options?: MongoClientOptions): Promise; From 19561dddb8aa527543bdcdec239aeaefc15aa33c Mon Sep 17 00:00:00 2001 From: Bradley Ayers Date: Wed, 2 May 2018 02:00:12 +1000 Subject: [PATCH 029/113] storybook__addon-storyshots: initial version (#25440) --- types/storybook__addon-storyshots/index.d.ts | 60 +++++++++++++++++++ .../storybook__addon-storyshots-tests.ts | 40 +++++++++++++ .../storybook__addon-storyshots/tsconfig.json | 31 ++++++++++ types/storybook__addon-storyshots/tslint.json | 1 + 4 files changed, 132 insertions(+) create mode 100644 types/storybook__addon-storyshots/index.d.ts create mode 100644 types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts create mode 100644 types/storybook__addon-storyshots/tsconfig.json create mode 100644 types/storybook__addon-storyshots/tslint.json diff --git a/types/storybook__addon-storyshots/index.d.ts b/types/storybook__addon-storyshots/index.d.ts new file mode 100644 index 0000000000..01df2538ae --- /dev/null +++ b/types/storybook__addon-storyshots/index.d.ts @@ -0,0 +1,60 @@ +// Type definitions for @storybook/addon-storyshots 3.4 +// Project: https://github.com/storybooks/storybook/tree/master/addons/storyshots +// Definitions by: Bradley Ayers +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from 'react'; +import { StoryObject } from '@storybook/react'; +import { Page } from "puppeteer"; + +export type Test = (options: { + story: StoryObject; + context: StoryContext; + renderShallowTree: any; + renderTree: any; + snapshotFileName: string; +}) => void | undefined | Promise; + +export interface SnapshotOptions { + createNodeMock?: (element: any) => any; +} + +export interface StoryContext { + kind: string; + story: string; +} + +export interface ImageSnapshotOptions { + context: { + kind: any; + story: string + }; + url: string; +} + +export function imageSnapshot(options?: { + storybookUrl: string; + getMatchOptions: (options: ImageSnapshotOptions) => { failureThreshold: number, failureThresholdType: 'percent' }; + beforeScreenshot: (page: Page, options: ImageSnapshotOptions) => Promise; +}): Test; + +export function multiSnapshotWithOptions(options: SnapshotOptions): Test; + +export const shallowSnapshot: Test; + +export const snapshot: Test; + +export function snapshotWithOptions(options: SnapshotOptions): Test; + +export const renderOnly: Test; + +export function getSnapshotFileName(context: StoryContext): string; + +export default function initStoryshots(options: { + configPath?: string; + framework?: string; + integrityOptions?: {}; + suite?: string; + test?: Test; +}): void; diff --git a/types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts b/types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts new file mode 100644 index 0000000000..3a97a50e71 --- /dev/null +++ b/types/storybook__addon-storyshots/storybook__addon-storyshots-tests.ts @@ -0,0 +1,40 @@ +import initStoryshots, { multiSnapshotWithOptions, snapshotWithOptions, getSnapshotFileName, renderOnly } from "@storybook/addon-storyshots"; +import { shallow } from 'enzyme'; +import toJson from 'enzyme-to-json'; +import 'jest'; +import 'jest-specific-snapshot'; + +initStoryshots({ + integrityOptions: { cwd: '' }, + test: multiSnapshotWithOptions({}), +}); + +initStoryshots({ + test: ({ story, context }) => { + const snapshotFileName = getSnapshotFileName(context); + const storyElement = story.render() as JSX.Element; + const shallowTree = shallow(storyElement); + + if (snapshotFileName) { + expect(toJson(shallowTree)).toMatchSpecificSnapshot(snapshotFileName); + } + } +}); + +initStoryshots({ + configPath: "", + test: renderOnly +}); + +initStoryshots({ + framework: 'react', + configPath: '', + test: snapshotWithOptions({ + createNodeMock: (element) => { + if (element.type === 'div') { + return { scrollWidth: 123 }; + } + return null; + } + }) +}); diff --git a/types/storybook__addon-storyshots/tsconfig.json b/types/storybook__addon-storyshots/tsconfig.json new file mode 100644 index 0000000000..651fb4482b --- /dev/null +++ b/types/storybook__addon-storyshots/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@storybook/addon-storyshots": [ + "storybook__addon-storyshots" + ], + "@storybook/react": [ + "storybook__react" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "storybook__addon-storyshots-tests.ts" + ] +} diff --git a/types/storybook__addon-storyshots/tslint.json b/types/storybook__addon-storyshots/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/storybook__addon-storyshots/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From a1b974611ad9f34d4d93ad2cf5a26ef76dfb11a9 Mon Sep 17 00:00:00 2001 From: Lee Standen Date: Tue, 1 May 2018 09:01:18 -0700 Subject: [PATCH 030/113] Add types for react-circular-progressbar (#25436) --- types/react-circular-progressbar/index.d.ts | 41 +++++++++++++++++++ .../react-circular-progressbar-tests.tsx | 24 +++++++++++ .../react-circular-progressbar/tsconfig.json | 17 ++++++++ types/react-circular-progressbar/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/react-circular-progressbar/index.d.ts create mode 100644 types/react-circular-progressbar/react-circular-progressbar-tests.tsx create mode 100644 types/react-circular-progressbar/tsconfig.json create mode 100644 types/react-circular-progressbar/tslint.json diff --git a/types/react-circular-progressbar/index.d.ts b/types/react-circular-progressbar/index.d.ts new file mode 100644 index 0000000000..2d3e7f228e --- /dev/null +++ b/types/react-circular-progressbar/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for react-circular-progressbar 0.8 +// Project: https://github.com/iqnivek/react-circular-progressbar#readme +// Definitions by: Lee Standen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Component, CSSProperties } from 'react'; + +export default class CircularProgressbar extends Component {} + +export interface Props { + percentage: number; + className?: string; + classes?: ProgressbarClasses; + styles?: ProgressbarStyles; + strokeWidth?: number; + background?: boolean; + backgroundPadding?: number; + initialAnimation?: boolean; + counterClockwise?: boolean; + classForPercentage?: FalseyCallback; + textForPercentage?: FalseyCallback; +} + +export type FalseyCallback = + | '' + | false + | null + | ((percentage: number) => string); + +export interface GroupOverride { + root?: T; + trail?: T; + path?: T; + text?: T; + background?: T; +} + +export interface ProgressbarClasses extends GroupOverride {} + +export interface ProgressbarStyles extends GroupOverride {} diff --git a/types/react-circular-progressbar/react-circular-progressbar-tests.tsx b/types/react-circular-progressbar/react-circular-progressbar-tests.tsx new file mode 100644 index 0000000000..a6fecb5fa4 --- /dev/null +++ b/types/react-circular-progressbar/react-circular-progressbar-tests.tsx @@ -0,0 +1,24 @@ +import CircularProgressbar from 'react-circular-progressbar'; + +import * as React from 'react'; +import { render } from 'react-dom'; + +declare const container: Element; + +render( +
      + (val > 50 ? val.toString() : '')} + strokeWidth={16} + /> + +
      , + container, +); diff --git a/types/react-circular-progressbar/tsconfig.json b/types/react-circular-progressbar/tsconfig.json new file mode 100644 index 0000000000..648646a01e --- /dev/null +++ b/types/react-circular-progressbar/tsconfig.json @@ -0,0 +1,17 @@ +{ + "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-circular-progressbar-tests.tsx"] +} diff --git a/types/react-circular-progressbar/tslint.json b/types/react-circular-progressbar/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-circular-progressbar/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b1f123c0e6c1cc2eca365832a6923fa4d2e454f5 Mon Sep 17 00:00:00 2001 From: Chris Pawlukiewicz Date: Tue, 1 May 2018 10:04:35 -0600 Subject: [PATCH 031/113] @types/puppeteer updated types for puppeteer realease 1.3 (#25428) * updated types for puppeteer realease 1.3 * fixed lint issues * changed the type for tracing stop per bugfix --- types/puppeteer/index.d.ts | 40 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index 899a24eef6..94b57c87b9 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for puppeteer 1.2 +// Type definitions for puppeteer 1.3 // Project: https://github.com/GoogleChrome/puppeteer#readme // Definitions by: Marvin Hagemeister // Christopher Deutsch @@ -94,7 +94,7 @@ export interface Touchscreen { */ export interface Tracing { start(options: TracingStartOptions): Promise; - stop(): Promise; + stop(): Promise; } export interface TracingStartOptions { @@ -136,6 +136,7 @@ export interface ConsoleMessage { } export type PageEvents = + | "close" | "console" | "dialog" | "error" @@ -430,6 +431,24 @@ export interface BoundingBox { height: number; } +export interface BoxModel { + /** Content box, represented as an array of {x, y} points. */ + content: Box[]; + /** Padding box, represented as an array of {x, y} points. */ + padding: Box[]; + /** Border box, represented as an array of {x, y} points. */ + border: Box[]; + /** Margin box, represented as an array of {x, y} points. */ + margin: Box[]; + width: number; + height: number; +} + +export interface Box { + x: number; + y: number; +} + /** * Represents an in-page DOM element. ElementHandles can be created with the page.$ method. */ @@ -454,6 +473,11 @@ export interface ElementHandle extends JSHandle { * This method returns the value resolve to the bounding box of the element (relative to the main frame), or null if the element is not visible. */ boundingBox(): Promise; + /** + * This method returns boxes of the element, or null if the element is not visible. + * Boxes are represented as an array of points; each Point is an object {x, y}. Box points are sorted clock-wise. + */ + boxModel(): Promise; /** * This method scrolls element into view if needed, and then uses page.mouse to click in the center of the element. * If the element is detached from DOM, the method throws an error. @@ -842,6 +866,8 @@ export interface Frame extends FrameBase { } export interface PageEventObj { + /** Emitted when the page closes. */ + close: undefined; /** * Emitted when JavaScript within the page calls one of console API methods, e.g. console.log or console.dir. * Also emitted if the page throws an error or a warning. @@ -1060,6 +1086,14 @@ export interface Page extends EventEmitter, FrameBase { */ select(selector: string, ...values: string[]): Promise; + /** + * Toggles bypassing page's Content-Security-Policy. + * NOTE CSP bypassing happens at the moment of CSP initialization rather then evaluation. + * Usually this means that page.setBypassCSP should be called before navigating to the domain. + * @param enabled sets bypassing of page's Content-Security-Policy. + */ + setBypassCSP(enabled: boolean): Promise; + /** * Determines whether cache is enabled on the page. * @param enabled Whether or not to enable cache on the page. @@ -1297,6 +1331,8 @@ export interface LaunchOptions { env?: any; /** Whether to auto-open DevTools panel for each tab. If this option is true, the headless option will be set false. */ devtools?: boolean; + /** Connects to the browser over a pipe instead of a WebSocket. Defaults to false. */ + pipe?: boolean; } export interface ConnectOptions { From a374c302823c7e6cc2653e80ff14c190da41373b Mon Sep 17 00:00:00 2001 From: Lee Standen Date: Tue, 1 May 2018 09:04:58 -0700 Subject: [PATCH 032/113] Add @atlaskit/layer types (#25427) * Add @atlaskit/layer types * fix name of module in comment --- .../atlaskit__layer/atlaskit__layer-tests.tsx | 15 ++++ types/atlaskit__layer/index.d.ts | 72 +++++++++++++++++++ types/atlaskit__layer/tsconfig.json | 20 ++++++ types/atlaskit__layer/tslint.json | 1 + 4 files changed, 108 insertions(+) create mode 100644 types/atlaskit__layer/atlaskit__layer-tests.tsx create mode 100644 types/atlaskit__layer/index.d.ts create mode 100644 types/atlaskit__layer/tsconfig.json create mode 100644 types/atlaskit__layer/tslint.json diff --git a/types/atlaskit__layer/atlaskit__layer-tests.tsx b/types/atlaskit__layer/atlaskit__layer-tests.tsx new file mode 100644 index 0000000000..d10ad57ff0 --- /dev/null +++ b/types/atlaskit__layer/atlaskit__layer-tests.tsx @@ -0,0 +1,15 @@ +import Layer from '@atlaskit/layer'; + +import * as React from 'react'; +import { render } from 'react-dom'; + +declare const container: Element; + +render( + Hello, world!} + autoFlip={false} + />, + container, +); diff --git a/types/atlaskit__layer/index.d.ts b/types/atlaskit__layer/index.d.ts new file mode 100644 index 0000000000..2f50a5abcf --- /dev/null +++ b/types/atlaskit__layer/index.d.ts @@ -0,0 +1,72 @@ +// Type definitions for @atlaskit/layer 3.1 +// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/ +// Definitions by: Lee Standen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Component, ReactNode } from 'react'; + +export default class Layer extends Component {} + +export interface Props { + /** + * Sets whether the content auto flip when it reaches the border set it as true for default flip + * or set the custom flip positions + */ + autoFlip?: boolean | FlipPositionType | FlipPositionType[]; + /** + * Element to act as a boundary for the Layer. The Layer will not sit outside this element if it + * can help it. If, through it's normal positoning, it would end up outside the boundary the + * layer will flip positions if the autoPosition prop is set. + */ + boundariesElement?: BoundariesElementType; + /** Target to which layer is attached */ + children?: ReactNode; + /** HTML content to display in the layer. Will be aligned to the target according to the position prop. */ + content?: ReactNode; + /** + * String representing the offsets from the target element in the format "[x-offset][y-offset]", + * measured in pixels. + */ + offset?: string; + /** + * Callback that is used to know when the flipped state of Layer changes. This occurs when placing a + * Layered element in the requested position would cause Layer to be rendered outside of the + * boundariesElement (usually viewport). + */ + onFlippedChange?: ( + flipped: boolean, + actualPosition: CSSPositionType, + originalPosition: CSSPositionType, + ) => void; + /** + * Position of a layer relative to its target. The position attribute takes two positional arguments in + * the format position="edge edge-position", where edge specifies what edge to align the layer to, and + * edge-position specifies where on that edge the layer should appear. + */ + position?: PositionType; + /** z-index for the layer component */ + zIndex?: number; + /** Lock scrolling behind the layer */ + lockScroll?: boolean; +} + +export type FlipPositionType = 'top' | 'right' | 'bottom' | 'left'; + +export type PositionType = + | 'top left' + | 'top center' + | 'top right' + | 'right top' + | 'right middle' + | 'right bottom' + | 'bottom left' + | 'bottom center' + | 'bottom right' + | 'left top' + | 'left middle' + | 'left bottom'; + +export type BoundariesElementType = 'viewport' | 'window' | 'scrollParent'; + +export type CSSPositionType = 'absolute' | 'fixed'; diff --git a/types/atlaskit__layer/tsconfig.json b/types/atlaskit__layer/tsconfig.json new file mode 100644 index 0000000000..6b6a475bd3 --- /dev/null +++ b/types/atlaskit__layer/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "paths": { + "@atlaskit/layer": ["atlaskit__layer"] + } + }, + "files": ["index.d.ts", "atlaskit__layer-tests.tsx"] +} diff --git a/types/atlaskit__layer/tslint.json b/types/atlaskit__layer/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/atlaskit__layer/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 78b9e35d82c8b9a0af9a1352717311f3dbeee238 Mon Sep 17 00:00:00 2001 From: Chris LoPresto Date: Tue, 1 May 2018 12:08:48 -0400 Subject: [PATCH 033/113] [awesomplete] Add destroy function (#25426) --- types/awesomplete/awesomplete-tests.ts | 1 + types/awesomplete/index.d.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/awesomplete/awesomplete-tests.ts b/types/awesomplete/awesomplete-tests.ts index f9ff4fed77..a3c66875a4 100644 --- a/types/awesomplete/awesomplete-tests.ts +++ b/types/awesomplete/awesomplete-tests.ts @@ -11,6 +11,7 @@ new Awesomplete(input, { const awesomplete = new Awesomplete(input); awesomplete.list = ["Ada", "Java", "JavaScript", "LOLCODE", "Node.js", "Ruby on Rails"]; +awesomplete.destroy(); new Awesomplete(input, { list: [ diff --git a/types/awesomplete/index.d.ts b/types/awesomplete/index.d.ts index 149b87e9f6..e73b7cf2f3 100644 --- a/types/awesomplete/index.d.ts +++ b/types/awesomplete/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for Awesomplete 1.1 // Project: https://leaverou.github.io/awesomplete/ -// Definitions by: webbiesdk , Ben Dixon , Trevor Bekolay +// Definitions by: webbiesdk +// Ben Dixon +// Trevor Bekolay +// Chris LoPresto // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Awesomplete { @@ -35,6 +38,7 @@ declare class Awesomplete { selected: boolean; open: () => void; status: HTMLElement; + destroy: () => void; } declare namespace Awesomplete { From a51d27f792b1aee312af0b8a1e945ae18403fe18 Mon Sep 17 00:00:00 2001 From: John Wright Date: Tue, 1 May 2018 17:10:15 +0100 Subject: [PATCH 034/113] Add url-safe-base64 npm module declarations (#25418) * feat(types): add url-safe-base64 npm module declarations * chore: fix name and URL --- types/url-safe-base64/index.d.ts | 14 +++++++++++ types/url-safe-base64/tsconfig.json | 23 +++++++++++++++++++ types/url-safe-base64/tslint.json | 1 + .../url-safe-base64/url-safe-base64-tests.ts | 16 +++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 types/url-safe-base64/index.d.ts create mode 100644 types/url-safe-base64/tsconfig.json create mode 100644 types/url-safe-base64/tslint.json create mode 100644 types/url-safe-base64/url-safe-base64-tests.ts diff --git a/types/url-safe-base64/index.d.ts b/types/url-safe-base64/index.d.ts new file mode 100644 index 0000000000..82afe079f6 --- /dev/null +++ b/types/url-safe-base64/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for url-safe-base64 1.1 +// Project: https://github.com/commenthol/url-safe-base64#readme +// Definitions by: John Wright +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function decode(safe: string): string; + +export function encode(base64: string): string; + +export function isBase64(string: string): string; + +export function isUrlSafeBase64(string: string): string; + +export function trim(string: string): string; diff --git a/types/url-safe-base64/tsconfig.json b/types/url-safe-base64/tsconfig.json new file mode 100644 index 0000000000..143154ef11 --- /dev/null +++ b/types/url-safe-base64/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "url-safe-base64-tests.ts" + ] +} diff --git a/types/url-safe-base64/tslint.json b/types/url-safe-base64/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/url-safe-base64/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/url-safe-base64/url-safe-base64-tests.ts b/types/url-safe-base64/url-safe-base64-tests.ts new file mode 100644 index 0000000000..2e8d3299ff --- /dev/null +++ b/types/url-safe-base64/url-safe-base64-tests.ts @@ -0,0 +1,16 @@ +import { decode, encode, isBase64, isUrlSafeBase64, trim } from 'url-safe-base64'; + +const safe = encode('A/B+C=='); +// > 'A-B_C..' +trim(safe); +// > 'A-B_C' +const base64 = decode(safe); +// > 'A/B+C==' +isBase64(base64); +// > true +isBase64(safe); +// > false +isUrlSafeBase64(base64); +// > false +isUrlSafeBase64(safe); +// > true From 349f349e9cadfaf14080f56520a52da4c544e31c Mon Sep 17 00:00:00 2001 From: villevenalainen Date: Tue, 1 May 2018 19:10:45 +0300 Subject: [PATCH 035/113] Definitions for react-native-material-textfield (#25417) * Definition file for react-native-material-textfield * Changed label not mandatory * Format fixing for files. Passing lint. --- .../index.d.ts | 61 +++++++++++++++++++ .../react-native-material-textfield-tests.tsx | 13 ++++ .../tsconfig.json | 25 ++++++++ .../tslint.json | 1 + types/react-native-material-ui/index.d.ts | 2 +- 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 types/react-native-material-textfield/index.d.ts create mode 100644 types/react-native-material-textfield/react-native-material-textfield-tests.tsx create mode 100644 types/react-native-material-textfield/tsconfig.json create mode 100644 types/react-native-material-textfield/tslint.json diff --git a/types/react-native-material-textfield/index.d.ts b/types/react-native-material-textfield/index.d.ts new file mode 100644 index 0000000000..9b6c2941af --- /dev/null +++ b/types/react-native-material-textfield/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for react-native-material-textfield 0.12 +// Project: https://github.com/n4kz/react-native-material-textfield +// Definitions by: Ville Venäläinen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import { TextInputProps, TextStyle, ViewStyle, View } from 'react-native'; + +export interface TextFieldProps extends TextInputProps { + animationDuration?: number; + + fontSize?: number; + titleFontSize?: number; + labelFontSize?: number; + labelHeight?: number; + labelPadding?: number; + inputContainerPadding?: number; + + labelTextStyle?: TextStyle; + titleTextStyle?: TextStyle; + affixTextStyle?: TextStyle; + + tintColor?: string; + textColor?: string; + baseColor?: string; + + label?: string; + title?: string; + + characterRestriction?: number; + + error?: string; + errorColor?: string; + + lineWidth?: number; + activeLineWidth?: number; + + disabled?: boolean; + + disabledLineWidth?: number; + + renderAccessory?(): JSX.Element; + + clearTextOnFocus?: boolean; + + prefix?: string; + suffix?: string; + + containerStyle?: ViewStyle; + inputContainerStyle?: ViewStyle; + + onPress?(event: Event): void; + onChangeText?(text: string): void; +} + +/** + * Material Style Text Field + * @see https://github.com/n4kz/react-native-material-textfield/blob/master/src/components/field/index.js + */ +export class TextField extends React.Component {} diff --git a/types/react-native-material-textfield/react-native-material-textfield-tests.tsx b/types/react-native-material-textfield/react-native-material-textfield-tests.tsx new file mode 100644 index 0000000000..08b33e31d0 --- /dev/null +++ b/types/react-native-material-textfield/react-native-material-textfield-tests.tsx @@ -0,0 +1,13 @@ +import * as React from 'react'; +import { View, Text } from 'react-native'; +import { TextField } from 'react-native-material-textfield'; + +const Example = () => + + + ; diff --git a/types/react-native-material-textfield/tsconfig.json b/types/react-native-material-textfield/tsconfig.json new file mode 100644 index 0000000000..b3c2a6ebba --- /dev/null +++ b/types/react-native-material-textfield/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-material-textfield-tests.tsx" + ] +} diff --git a/types/react-native-material-textfield/tslint.json b/types/react-native-material-textfield/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-material-textfield/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native-material-ui/index.d.ts b/types/react-native-material-ui/index.d.ts index 89b01d13bc..3c4c549504 100644 --- a/types/react-native-material-ui/index.d.ts +++ b/types/react-native-material-ui/index.d.ts @@ -338,7 +338,7 @@ export interface IconToggleProps { export class IconToggle extends Component {} export interface ListItemCenterElement { - primaryText: string; + primaryText: string | JSX.Element; secondaryText?: string; tertiaryText?: string; } From 5dafc2c0f60bbc8e8d103e0c76ae502e2e26d489 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Tue, 1 May 2018 18:16:47 +0200 Subject: [PATCH 036/113] Adding type defintion for murmurhash module of npm (#25413) --- types/murmurhash/index.d.ts | 29 ++++++++++++++++++++++++++++ types/murmurhash/murmurhash-tests.ts | 8 ++++++++ types/murmurhash/tsconfig.json | 23 ++++++++++++++++++++++ types/murmurhash/tslint.json | 1 + 4 files changed, 61 insertions(+) create mode 100644 types/murmurhash/index.d.ts create mode 100644 types/murmurhash/murmurhash-tests.ts create mode 100644 types/murmurhash/tsconfig.json create mode 100644 types/murmurhash/tslint.json diff --git a/types/murmurhash/index.d.ts b/types/murmurhash/index.d.ts new file mode 100644 index 0000000000..31c663fd33 --- /dev/null +++ b/types/murmurhash/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for murmurhash 0.0 +// Project: https://github.com/perezd/node-murmurhash +// Definitions by: Arne Schubert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = murmurhash; + +/** + * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011) + * + * @param key - ASCII only + * @param seed - Positive integer only + * @return - 32-bit positive integer hash + */ +declare function murmurhash(key: string, seed: number): number; + +declare namespace murmurhash { + // Circular reference from murmurhash + function v3(key: string, seed: number): number; + + /** + * JS Implementation of MurmurHash2 + * + * @param str - ASCII only + * @param seed - Positive integer only + * @return - 32-bit positive integer hash + */ + function v2(str: string, seed: number): number; +} diff --git a/types/murmurhash/murmurhash-tests.ts b/types/murmurhash/murmurhash-tests.ts new file mode 100644 index 0000000000..ebbbf09cab --- /dev/null +++ b/types/murmurhash/murmurhash-tests.ts @@ -0,0 +1,8 @@ +import murmurhash = require('murmurhash'); + +const stringValue = "test"; +let numberValue = 123; + +numberValue = murmurhash(stringValue, numberValue); +numberValue = murmurhash.v2(stringValue, numberValue); +numberValue = murmurhash.v3(stringValue, numberValue); diff --git a/types/murmurhash/tsconfig.json b/types/murmurhash/tsconfig.json new file mode 100644 index 0000000000..1778d66a72 --- /dev/null +++ b/types/murmurhash/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", + "murmurhash-tests.ts" + ] +} diff --git a/types/murmurhash/tslint.json b/types/murmurhash/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/murmurhash/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 80d39bdaae464e2d8c36368f7439328e8c6dfc7d Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Tue, 1 May 2018 09:17:50 -0700 Subject: [PATCH 037/113] [esprima] Add tolerant tokenize option (#25410) --- types/esprima/esprima-tests.ts | 1 + types/esprima/index.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/types/esprima/esprima-tests.ts b/types/esprima/esprima-tests.ts index 2032702979..08a3214a95 100644 --- a/types/esprima/esprima-tests.ts +++ b/types/esprima/esprima-tests.ts @@ -29,6 +29,7 @@ program = esprima.parseScript('answer = 42 // TODO: why', { comment: true, range // Tokenizing token = esprima.tokenize('code')[0]; token = esprima.tokenize('code', {range: true})[0]; +token = esprima.tokenize('/E\/\w*/.exec("e")', { tolerant: true })[0]; // Syntax Delegate esprima.parseScript('answer = 42', {}, (node) => { diff --git a/types/esprima/index.d.ts b/types/esprima/index.d.ts index 7817465742..cc612b12d1 100644 --- a/types/esprima/index.d.ts +++ b/types/esprima/index.d.ts @@ -30,6 +30,7 @@ export interface ParseOptions { } export interface TokenizeOptions { + tolerant?: boolean; range?: boolean; loc?: boolean; comment?: boolean; From cc3af3a4a9ad7b430a9c7c4971eb697a8a060053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anderson=20Fria=C3=A7a?= Date: Tue, 1 May 2018 12:18:18 -0400 Subject: [PATCH 038/113] Types for JQuery Focus Exit (#25409) --- types/jquery-focus-exit/index.d.ts | 20 +++++++++++++++ .../jquery-focus-exit-tests.ts | 8 ++++++ types/jquery-focus-exit/tsconfig.json | 25 +++++++++++++++++++ types/jquery-focus-exit/tslint.json | 1 + 4 files changed, 54 insertions(+) create mode 100644 types/jquery-focus-exit/index.d.ts create mode 100644 types/jquery-focus-exit/jquery-focus-exit-tests.ts create mode 100644 types/jquery-focus-exit/tsconfig.json create mode 100644 types/jquery-focus-exit/tslint.json diff --git a/types/jquery-focus-exit/index.d.ts b/types/jquery-focus-exit/index.d.ts new file mode 100644 index 0000000000..8787136a4e --- /dev/null +++ b/types/jquery-focus-exit/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for JQuery Focus Exit 1.0 +// Project: https://github.com/makeup-jquery/jquery-focus-exit +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +export interface FocusElements { + lostFocus?: HTMLElement; + gainedFocus: HTMLElement; +} + +declare global { + interface JQuery { + focusExit(options?: { debug: boolean }): JQuery; + on(event: 'focusExit', handler: ((event: JQuery.Event, data: FocusElements) => void)): JQuery; + one(event: 'focusin', handler: ((event: JQuery.Event) => void)): JQuery; + } +} diff --git a/types/jquery-focus-exit/jquery-focus-exit-tests.ts b/types/jquery-focus-exit/jquery-focus-exit-tests.ts new file mode 100644 index 0000000000..497e44dd97 --- /dev/null +++ b/types/jquery-focus-exit/jquery-focus-exit-tests.ts @@ -0,0 +1,8 @@ +$('.test').one('focusin', e => { + $(e.currentTarget).addClass('focusin'); +}); + +$('.test').focusExit({debug: true}).on('focusExit', (e, data) => { + console.log(e, data); + $(e.currentTarget).removeClass('focusin'); +}); diff --git a/types/jquery-focus-exit/tsconfig.json b/types/jquery-focus-exit/tsconfig.json new file mode 100644 index 0000000000..b9448645b8 --- /dev/null +++ b/types/jquery-focus-exit/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, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "jquery-focus-exit-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jquery-focus-exit/tslint.json b/types/jquery-focus-exit/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery-focus-exit/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file From 79c02230b2a05e4ea8f9dc7f6083a62c1f166b95 Mon Sep 17 00:00:00 2001 From: Mathew Rumsey Date: Tue, 1 May 2018 12:19:57 -0400 Subject: [PATCH 039/113] cloner - new typings - tested (#25406) --- types/cloner/cloner-tests.ts | 43 ++++++++++++++++++++++++++++++++++ types/cloner/index.d.ts | 45 ++++++++++++++++++++++++++++++++++++ types/cloner/tsconfig.json | 23 ++++++++++++++++++ types/cloner/tslint.json | 1 + 4 files changed, 112 insertions(+) create mode 100644 types/cloner/cloner-tests.ts create mode 100644 types/cloner/index.d.ts create mode 100644 types/cloner/tsconfig.json create mode 100644 types/cloner/tslint.json diff --git a/types/cloner/cloner-tests.ts b/types/cloner/cloner-tests.ts new file mode 100644 index 0000000000..63baf4b950 --- /dev/null +++ b/types/cloner/cloner-tests.ts @@ -0,0 +1,43 @@ +import cloner = require("cloner"); + +interface A { + test: string; + nest: { + test: string; + num: number; + }; +} + +interface B { + somethingElse: string; + nest: { + somethingElse: string; + notNaN: number; + }; +} + +let aO: A; +let aN: A; +let bO: B; +let bN: B; + +aO = { + test: "test", + nest: { + test: "nestTest", + num: 1 + } +}; +bO = { + somethingElse: "se", + nest: { + somethingElse: "nestSe", + notNaN: 0 + } +}; + +aN = cloner.deep.copy(aO); +bN = cloner.shallow.copy(bO); + +aN = cloner.deep.merge(aO, bO); +bN = cloner.shallow.merge(aO, bO); diff --git a/types/cloner/index.d.ts b/types/cloner/index.d.ts new file mode 100644 index 0000000000..6021c9a716 --- /dev/null +++ b/types/cloner/index.d.ts @@ -0,0 +1,45 @@ +// Type definitions for cloner 0.4 +// Project: https://github.com/WebReflection/cloner +// Definitions by: matrumz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Deep-style methods that will perform operations by value, instead of reference. + */ +export namespace deep { + /** + * Will loop over all own keys and deeply copy (copy by value) them to a new object. + * + * Preserves inheritance and is recursion aware, meaning it shouldn't fail with recursive properties. + * @param [obj] The object to copy. + */ + function copy(obj: T): T; + /** + * Preserves what's already in the target and merges all own keys found in one or more passed sources. + * + * Properties are merged by value. + * @param [target] Destination object for merged properties. + * @param [sources] Source object(s) for properties to merge. + */ + function merge(target: any, ...sources: any[]): any; +} +/** + * Shallow-style methods that will perform operations by reference, instead of value. + */ +export namespace shallow { + /** + * Will loop over all own keys and shallow copy (copy by reference) them to a new object. + * + * Preserves inheritance and is recursion aware, meaning it shouldn't fail with recursive properties. + * @param [obj] The object to copy. + */ + function copy(obj: T): T; + /** + * Preserves what's already in the target and merges all own keys found in one or more passed sources. + * + * Properties are merged by reference. + * @param [target] Destination object for merged properties. + * @param [sources] Source object(s) for properties to merge. + */ + function merge(target: any, ...sources: any[]): any; +} diff --git a/types/cloner/tsconfig.json b/types/cloner/tsconfig.json new file mode 100644 index 0000000000..9619614ce4 --- /dev/null +++ b/types/cloner/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", + "cloner-tests.ts" + ] +} diff --git a/types/cloner/tslint.json b/types/cloner/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cloner/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b408a4c1b51d92545c23d678f62431cb13e4a91c Mon Sep 17 00:00:00 2001 From: anantoghosh Date: Tue, 1 May 2018 21:50:49 +0530 Subject: [PATCH 040/113] [react-sortable-tree] Fix canDrop and onMoveNode type (#25402) * Fix canDrop and onMoveNode type * Re-structure PreviousAndNextLocation and related interafaces --- types/react-sortable-tree/index.d.ts | 17 +++++++++++++---- .../react-sortable-tree-tests.tsx | 7 ++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/types/react-sortable-tree/index.d.ts b/types/react-sortable-tree/index.d.ts index db90ce90f9..498fd48800 100644 --- a/types/react-sortable-tree/index.d.ts +++ b/types/react-sortable-tree/index.d.ts @@ -57,12 +57,21 @@ export interface ExtendedNodeData extends NodeData { export interface OnVisibilityToggleData extends FullTree, TreeNode { expanded: boolean; } -export interface PreviousAndNextLocation { + +interface PreviousAndNextLocation { prevTreeIndex: number; prevPath: number[]; nextTreeIndex: number; nextPath: number[]; - nextParentNode: TreeItem; +} + +export interface OnDragPreviousAndNextLocation extends PreviousAndNextLocation { + prevParent: TreeItem | null; + nextParent: TreeItem | null; +} + +export interface OnMovePreviousAndNextLocation extends PreviousAndNextLocation { + nextParentNode: TreeItem | null; } export type NodeRenderer = React.ComponentClass; @@ -164,10 +173,10 @@ export interface ReactSortableTreeProps { searchFinishCallback?(matches: NodeData[]): void; generateNodeProps?(data: ExtendedNodeData): { [index: string]: any }; getNodeKey?(data: TreeNode & TreeIndex): string | number; - onMoveNode?(data: NodeData & FullTree): void; + onMoveNode?(data: NodeData & FullTree & OnMovePreviousAndNextLocation): void; onVisibilityToggle?(data: OnVisibilityToggleData): void; canDrag?: ((data: ExtendedNodeData) => boolean) | boolean; - canDrop?(data: PreviousAndNextLocation & NodeData): boolean; + canDrop?(data: OnDragPreviousAndNextLocation & NodeData): boolean; reactVirtualizedListProps?: ListProps; rowHeight?: ((info: Index) => number) | number; slideRegionSize?: number; diff --git a/types/react-sortable-tree/react-sortable-tree-tests.tsx b/types/react-sortable-tree/react-sortable-tree-tests.tsx index f29e814cc9..6ed4b3e74b 100644 --- a/types/react-sortable-tree/react-sortable-tree-tests.tsx +++ b/types/react-sortable-tree/react-sortable-tree-tests.tsx @@ -11,7 +11,8 @@ import SortableTree, ExtendedNodeData, FullTree, OnVisibilityToggleData, - PreviousAndNextLocation, + OnDragPreviousAndNextLocation, + OnMovePreviousAndNextLocation, PlaceholderRendererProps, ThemeProps } from "react-sortable-tree"; @@ -55,10 +56,10 @@ class Test extends React.Component { searchFinishCallback={(matches: NodeData[]) => { const firstTitle = matches[0].node.title; }} generateNodeProps={(data: ExtendedNodeData) => ({buttons: [data.node.title]}) } getNodeKey={defaultGetNodeKey} - onMoveNode={(data: NodeData & FullTree) => {}} + onMoveNode={(data: NodeData & FullTree & OnMovePreviousAndNextLocation) => {}} onVisibilityToggle={(data: OnVisibilityToggleData) => {}} canDrag={true} - canDrop={(data: PreviousAndNextLocation & NodeData) => true} + canDrop={(data: OnDragPreviousAndNextLocation & NodeData) => true} reactVirtualizedListProps={reactVirtualizedListProps} rowHeight={62} slideRegionSize={100} From 01ee3702e42c8769f46b6ef4cfb4de3e978de438 Mon Sep 17 00:00:00 2001 From: Thanh Ngo Date: Tue, 1 May 2018 12:23:25 -0400 Subject: [PATCH 041/113] [idyll-compiler] add types definition for idyll-compiler (#25397) * add types for idyll-compiler * remove unnecessary tslint rule for new typedefs --- types/idyll-compiler/idyll-compiler-tests.ts | 13 +++++ types/idyll-compiler/index.d.ts | 55 ++++++++++++++++++++ types/idyll-compiler/tsconfig.json | 16 ++++++ types/idyll-compiler/tslint.json | 3 ++ 4 files changed, 87 insertions(+) create mode 100644 types/idyll-compiler/idyll-compiler-tests.ts create mode 100644 types/idyll-compiler/index.d.ts create mode 100644 types/idyll-compiler/tsconfig.json create mode 100644 types/idyll-compiler/tslint.json diff --git a/types/idyll-compiler/idyll-compiler-tests.ts b/types/idyll-compiler/idyll-compiler-tests.ts new file mode 100644 index 0000000000..c131a8600d --- /dev/null +++ b/types/idyll-compiler/idyll-compiler-tests.ts @@ -0,0 +1,13 @@ +import compile from "idyll-compiler"; + +// Dummy log +const log = (msg: string) => {}; + +// $ExpectType Node[] | Promise +compile("*italics*", { async: false }, () => log("window")); + +// $ExpectType Node[] | Promise +compile("Simple **idyll**", { async: false }); + +// $ExpectType Node[] | Promise +compile(`# Test`); diff --git a/types/idyll-compiler/index.d.ts b/types/idyll-compiler/index.d.ts new file mode 100644 index 0000000000..577dae2070 --- /dev/null +++ b/types/idyll-compiler/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for idyll-compiler 3.1 +// Project: https://github.com/idyll-lang/idyll/tree/master/packages/idyll-compiler +// Definitions by: Thanh Ngo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +export type PropType = "variable" | "value" | "expression"; +export type PropData = string | number | boolean; +export type PropKey = string; +export type PropValue = [PropType, PropData]; +export type Property = [PropKey, PropValue]; +type __RecursiveNode = [string, Property[], T[]]; +export interface TreeNode extends __RecursiveNode {} +export type Node = TreeNode | string; +export type AST = Node[]; + +export type PostProcessor = + | ((ast: AST) => AST) + | ((ast: AST, callback: (err: any, value: AST) => void) => void); + +export interface Options { + spellcheck?: boolean; + + smartquotes?: boolean; + + /** + * If false and there is no postprocessors, compiler returns the AST synchronously + * Otherwise, a promise is returned + * + */ + async?: boolean; + + /** + * compiler plugins + * If provided, compiler always compiles asynchronously + */ + postProcessors?: PostProcessor[]; +} + +/** + * Compiles the given idyllMarkup and returns an AST either synchronously + * or asynchronously. + * + * If postProcessors are provided or options.async is set to true: + * compiler returns a promise + * Otherwise, compile returns the AST synchronously + * + */ +declare function compiler( + input: string, + options?: Options, + callback?: () => void +): Promise | AST; + +export default compiler; diff --git a/types/idyll-compiler/tsconfig.json b/types/idyll-compiler/tsconfig.json new file mode 100644 index 0000000000..bb08224d15 --- /dev/null +++ b/types/idyll-compiler/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "idyll-compiler-tests.ts"] +} diff --git a/types/idyll-compiler/tslint.json b/types/idyll-compiler/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/idyll-compiler/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From d91f6d2a8bac694b8c1cf4dfec7945712fe48965 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 1 May 2018 21:25:49 +0500 Subject: [PATCH 042/113] WebHookOptions interace `port` property name typo (#25391) See contract in the source code: https://github.com/yagop/node-telegram-bot-api/blob/435f06319e92f12fb7ef642f91d031dafe5aff80/src/telegram.js#L157 --- types/node-telegram-bot-api/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index cfc55d2d33..cacc064abd 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -35,7 +35,7 @@ declare namespace TelegramBot { interface WebHookOptions { host?: string; - post?: number; + port?: number; key: string; cert: string; pfx: string; From eb88013b234c09656f8d533a1fb896849d8a0f73 Mon Sep 17 00:00:00 2001 From: Sarun Intaralawan Date: Tue, 1 May 2018 23:26:04 +0700 Subject: [PATCH 043/113] Change table package name (#25390) --- types/table/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/table/index.d.ts b/types/table/index.d.ts index dfa921bcb2..eb89492968 100644 --- a/types/table/index.d.ts +++ b/types/table/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Tabris.js 4.0 +// Type definitions for table 4.0 // Project: https://github.com/gajus/table // Definitions by: Evan Shortiss // mrmlnc From 3a684d5e26dbb3204f0afde944c60af83f41c6ca Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 1 May 2018 17:26:25 +0100 Subject: [PATCH 044/113] [auth0-lock] Add missing props in AuthResult (#25389) * [auth0-lock] Adds missing params in AuthResult * [auth0-lock] whitespace fix --- types/auth0-lock/auth0-lock-tests.ts | 4 +++- types/auth0-lock/index.d.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index b3b2c81339..0c64fd361b 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -258,6 +258,7 @@ new Auth0Lock(CLIENT_ID, DOMAIN, avatarOptions); const authResult : AuthResult = { accessToken: 'fake_access_token', + expiresIn: 7200, idToken: 'fake_id_token', idTokenPayload: { aud: "EaQzyHt1Dy57l-r5iHcMeT-lh1fFZntg", @@ -267,5 +268,6 @@ const authResult : AuthResult = { sub: "auth0|aksjfkladsf" }, refreshToken: undefined, - state: "923jf092j3.FFSDJFDSKLDF" + state: "923jf092j3.FFSDJFDSKLDF", + tokenType: 'Bearer' }; diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index fec943ce02..27639834db 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -165,6 +165,8 @@ interface Auth0LockShowOptions { interface AuthResult { accessToken: string; + appState?: any; + expiresIn: number; idToken: string; idTokenPayload: { aud: string; @@ -174,8 +176,10 @@ interface AuthResult { sub: string; }; refreshToken?: string; + scope?: string; state: string; -} + tokenType: string; + } interface Auth0LockStatic { new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic; From b09a95d964c88d937c1924247372bbe3a464c79c Mon Sep 17 00:00:00 2001 From: denisname Date: Tue, 1 May 2018 18:27:00 +0200 Subject: [PATCH 045/113] d3-dispatch: Update type definition (#25387) * Update d3-dispatch type definition on(type) may return undefined add jsDoc use ExpectError * Typos in jsDoc --- types/d3-dispatch/d3-dispatch-tests.ts | 16 +++++-- types/d3-dispatch/index.d.ts | 64 ++++++++++++++++++++++++-- types/d3-dispatch/tsconfig.json | 2 +- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/types/d3-dispatch/d3-dispatch-tests.ts b/types/d3-dispatch/d3-dispatch-tests.ts index a9f29ef75d..4e8d2cfb31 100644 --- a/types/d3-dispatch/d3-dispatch-tests.ts +++ b/types/d3-dispatch/d3-dispatch-tests.ts @@ -16,6 +16,9 @@ interface Datum { } let dispatch: d3Dispatch.Dispatch; +let callback: (this: HTMLElement, ...args: any[]) => void; +let callbackOrUndef: ((this: HTMLElement, ...args: any[]) => void) | undefined; +let undef: undefined; // Signature Tests ---------------------------------------- @@ -33,9 +36,15 @@ function cbFn2(this: SVGElement, d: Datum, i: number) { } dispatch.on('foo', cbFn); -// dispatch.on('foo', cbFn2); // test fails as 'this' context type is mismatched between dispatch and callback function +// $ExpectError +dispatch.on('foo', cbFn2); // test fails as 'this' context type is mismatched between dispatch and callback function -dispatch.on('bar', dispatch.on('bar')); +callback = dispatch.on('bar')!; +callbackOrUndef = dispatch.on('bar'); +callbackOrUndef = dispatch.on('unknown'); +undef = dispatch.on('unknown') as undefined; + +dispatch.on('bar', dispatch.on('bar')!); dispatch.call('foo'); dispatch.call('foo', document.body); @@ -49,4 +58,5 @@ dispatch.on('bar', null); // Copy dispatch ----------------------------------------------- const copy: d3Dispatch.Dispatch = dispatch.copy(); -// const copy2: d3Dispatch.Dispatch = dispatch.copy(); // test fails type mismatch of underlying event target +// $ExpectError +const copy2: d3Dispatch.Dispatch = dispatch.copy(); // test fails type mismatch of underlying event target diff --git a/types/d3-dispatch/index.d.ts b/types/d3-dispatch/index.d.ts index 1e6e82e06f..c8beb28a5a 100644 --- a/types/d3-dispatch/index.d.ts +++ b/types/d3-dispatch/index.d.ts @@ -1,18 +1,74 @@ // Type definitions for D3JS d3-dispatch module 1.0 // Project: https://github.com/d3/d3-dispatch/ -// Definitions by: Tom Wanzek , Alex Ford , Boris Yankov +// Definitions by: Tom Wanzek +// Alex Ford +// Boris Yankov +// denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.0.1 +// Last module patch version validated against: 1.0.3 export interface Dispatch { + /** + * Like `function.apply`, invokes each registered callback for the specified type, + * passing the callback the specified arguments, with `that` as the `this` context. + * + * @param type A specified event type. + * @param that The `this` context for the callback. + * @param args Additional arguments to be passed to the callback. + * @throws "unknown type" on unknown event type. + */ apply(type: string, that?: T, args?: any[]): void; - call(type: string, that?: T, ...args: any[]): void; + + /** + * Like `function.call`, invokes each registered callback for the specified type, + * passing the callback the specified arguments, with `that` as the `this` context. + * See dispatch.apply for more information. + * + * @param type A specified event type. + * @param that The `this` context for the callback. + * @param args Additional arguments to be passed to the callback. + * @throws "unknown type" on unknown event type. + */ + call(type: string, that?: T, ...args: any[]): void; + + /** + * Returns a copy of this dispatch object. + * Changes to this dispatch do not affect the returned copy and vice versa. + */ copy(): Dispatch; - on(typenames: string): (this: T, ...args: any[]) => void; + /** + * Returns the callback for the specified typenames, if any. + * If multiple typenames are specified, the first matching callback is returned. + * + * @param types An event typename. + * @param callback A callback. + */ + on(typenames: string): ((this: T, ...args: any[]) => void) | undefined; + /** + * Removes the callback for the specified typenames. + * To remove all callbacks for a given name `foo`, say `dispatch.on(".foo", null).` + * + * @param types An event typename. + */ on(typenames: string, callback: null): this; + /** + * Adds the callback for the specified typenames. + * The callback is registered for the specified (fully-qualified) typenames. + * If a callback was already registered for the given typenames, + * the existing callback is removed before the new callback is added. + * + * @param types An event typename. + * @param callback A callback. + */ on(typenames: string, callback: (this: T, ...args: any[]) => void): this; } +/** + * Creates a new dispatch for the specified event types. Each type is a string, such as "start" or "end". + * + * @param types The event types. + * @throws "illegal type" on empty string or duplicated event types. + */ export function dispatch(...types: string[]): Dispatch; diff --git a/types/d3-dispatch/tsconfig.json b/types/d3-dispatch/tsconfig.json index b270a9c1a0..88000f85e4 100644 --- a/types/d3-dispatch/tsconfig.json +++ b/types/d3-dispatch/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From ad4cda301a1041770c21a04a1df216833501420f Mon Sep 17 00:00:00 2001 From: Robbie Date: Tue, 1 May 2018 17:27:54 +0100 Subject: [PATCH 046/113] Add NavigatorEvent to react-native-navigation (#25386) --- types/react-native-navigation/index.d.ts | 8 ++++++-- .../react-native-navigation-tests.tsx | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/types/react-native-navigation/index.d.ts b/types/react-native-navigation/index.d.ts index 86fee24d55..aeeebc2e87 100644 --- a/types/react-native-navigation/index.d.ts +++ b/types/react-native-navigation/index.d.ts @@ -111,6 +111,10 @@ export interface LightBox { adjustSoftInput?: 'nothing' | 'pan' | 'resize' | 'unspecified'; } +export interface NavigatorEvent { + id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview'; +} + export class Navigator { push(params: PushedScreen): void; pop(params?: { animated?: boolean; animationType?: 'fade' | 'slide-horizontal'; }): void; @@ -133,8 +137,8 @@ export class Navigator { setTabButton(params?: { tabIndex?: number; icon?: any; selectedIcon?: any; label?: string; }): void; switchToTab(params?: { tabIndex?: number }): void; toggleNavBar(params: { to: 'hidden' | 'shown'; animated?: boolean }): void; - setOnNavigatorEvent(callback: (event: { id: string }) => void): void; - addOnNavigatorEvent(callback: (event: { id: string }) => void): () => void; + setOnNavigatorEvent(callback: (event: NavigatorEvent) => void): void; + addOnNavigatorEvent(callback: (event: NavigatorEvent) => void): () => void; screenIsCurrentlyVisible(): Promise; setStyle(params: NavigatorStyle): void; } diff --git a/types/react-native-navigation/react-native-navigation-tests.tsx b/types/react-native-navigation/react-native-navigation-tests.tsx index fb3e86cc65..72a450c13f 100644 --- a/types/react-native-navigation/react-native-navigation-tests.tsx +++ b/types/react-native-navigation/react-native-navigation-tests.tsx @@ -1,8 +1,21 @@ import * as React from 'react'; import { Text, View } from 'react-native'; -import { Navigation, NavigationComponentProps, NavigatorStyle, NavigatorButtons } from 'react-native-navigation'; +import { Navigation, NavigationComponentProps, NavigatorStyle, NavigatorButtons, NavigatorEvent } from 'react-native-navigation'; + +type Props = NavigationComponentProps & { height: number }; + +class Screen1 extends React.Component { + constructor(props: Props) { + super(props); + this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent); + } + + onNavigatorEvent = (event: NavigatorEvent) => { + if (event.id === 'willAppear') { + console.log('will appear'); + } + } -class Screen1 extends React.Component { static navigatorButtons: NavigatorButtons = { leftButtons: [{ id: 'sideMenu' From 01e0ffdbab16b15c702d5b8c87bb122cc6215a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20M=C3=BCller?= Date: Tue, 1 May 2018 16:28:50 +0000 Subject: [PATCH 047/113] pify: Tests fail for exclude option (#25384) * pify: fix exclude option test in pify-tests.ts * pify: add https://github.com/c7hm4r as contributor --- types/pify/index.d.ts | 2 +- types/pify/pify-tests.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/pify/index.d.ts b/types/pify/index.d.ts index b0c8ce4b92..cceb0e9ef0 100644 --- a/types/pify/index.d.ts +++ b/types/pify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for pify 3.0.0 // Project: https://github.com/sindresorhus/pify -// Definitions by: Sam Verschueren , [Michael Müller] +// Definitions by: Sam Verschueren , [Michael Müller] , Christoph Müller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface PromiseModule { diff --git a/types/pify/pify-tests.ts b/types/pify/pify-tests.ts index cadf3ba408..573872c9ad 100644 --- a/types/pify/pify-tests.ts +++ b/types/pify/pify-tests.ts @@ -27,7 +27,7 @@ const fsP = pify(fs); fsP.readFile('foo.txt').then((result: string) => assert(result, 'foo')); pify(fs.readFile)('foo.txt').then((result: string) => assert(result, 'foo')); -pify(fs.readFile, { promiseModule: Promise})('bar.txt').then((result: string) => assert(result, 'bar')); +pify(fs.readFile, { promiseModule: Promise })('bar.txt').then((result: string) => assert(result, 'bar')); pify(fs.exists, { errorFirst: false })('foo.txt').then((result: boolean) => assert(result.toString(), true.toString())); @@ -45,6 +45,6 @@ if (include.f2 === module.f2) throw new Error(); if (include.f3 !== module.f3) throw new Error(); const exclude = pify(module, { exclude: ['f1', 'f2'] }); -if (include.f1 !== module.f1) throw new Error(); -if (include.f2 !== module.f2) throw new Error(); -if (include.f3 === module.f3) throw new Error(); +if (exclude.f1 !== module.f1) throw new Error(); +if (exclude.f2 !== module.f2) throw new Error(); +if (exclude.f3 === module.f3) throw new Error(); From 3c18f364ae21bca7d4d6d9b83190f32faf4199ca Mon Sep 17 00:00:00 2001 From: Ian Copp Date: Wed, 2 May 2018 08:02:37 -0700 Subject: [PATCH 048/113] Add @zeit/next-typescript (#25443) * Add @zeit/next-typescript * Correct for optional parameter --- types/zeit__next-typescript/index.d.ts | 14 ++++++++++ types/zeit__next-typescript/tsconfig.json | 26 +++++++++++++++++++ types/zeit__next-typescript/tslint.json | 1 + .../zeit__next-typescript-tests.ts | 3 +++ 4 files changed, 44 insertions(+) create mode 100644 types/zeit__next-typescript/index.d.ts create mode 100644 types/zeit__next-typescript/tsconfig.json create mode 100644 types/zeit__next-typescript/tslint.json create mode 100644 types/zeit__next-typescript/zeit__next-typescript-tests.ts diff --git a/types/zeit__next-typescript/index.d.ts b/types/zeit__next-typescript/index.d.ts new file mode 100644 index 0000000000..d10fc83f14 --- /dev/null +++ b/types/zeit__next-typescript/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for @zeit/next-typescript 0.1 +// Project: https://github.com/zeit/next-plugins/tree/master/packages/next-typescript +// Definitions by: icopp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { ServerConfig } from 'next'; + +declare function withTypescript( + /** @default {} */ + nextConfig?: ServerConfig +): ServerConfig; + +export = withTypescript; diff --git a/types/zeit__next-typescript/tsconfig.json b/types/zeit__next-typescript/tsconfig.json new file mode 100644 index 0000000000..a0ca0e74d9 --- /dev/null +++ b/types/zeit__next-typescript/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths":{ + "@zeit/next-typescript": ["zeit__next-typescript"] + } + }, + "files": [ + "index.d.ts", + "zeit__next-typescript-tests.ts" + ] +} diff --git a/types/zeit__next-typescript/tslint.json b/types/zeit__next-typescript/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/zeit__next-typescript/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/zeit__next-typescript/zeit__next-typescript-tests.ts b/types/zeit__next-typescript/zeit__next-typescript-tests.ts new file mode 100644 index 0000000000..a7b58c46fc --- /dev/null +++ b/types/zeit__next-typescript/zeit__next-typescript-tests.ts @@ -0,0 +1,3 @@ +import withTypescript = require('@zeit/next-typescript'); + +withTypescript({}); // $ExpectType ServerConfig From e8fd14b182ca01890a4dce49b0ca276183d0fefd Mon Sep 17 00:00:00 2001 From: Dvorak Date: Wed, 2 May 2018 15:34:59 +0000 Subject: [PATCH 049/113] chart.js -- ChartPoint.y is allowed to be string and Date (#25474) * Papaparse: added Parser.pause() & Parser.resume() * chart.js -- ChartPoint.y is allowed to be string and Date --- types/chart.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 2c5de28962..621152162a 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -166,7 +166,7 @@ declare namespace Chart { interface ChartPoint { x?: number | string | Date; - y?: number; + y?: number | string | Date; r?: number; } From 3d4a2de3c4389a851af6716d5ef084662e28d8d8 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Wed, 2 May 2018 17:35:27 +0200 Subject: [PATCH 050/113] node: Fix parameter type of TransformOptions transform callback (#25473) --- types/node/index.d.ts | 8 +++++--- types/node/v9/index.d.ts | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 04e074da29..b545ec718e 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -5989,14 +5989,16 @@ declare module "stream" { uncork(): void; } + type TransformCallback = (err?: Error, data?: any) => void; + export interface TransformOptions extends DuplexOptions { - transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - flush?: (callback: Function) => any; + transform?: (chunk: any, encoding: string, callback: TransformCallback) => any; + flush?: (callback: TransformCallback) => any; } export class Transform extends Duplex { constructor(opts?: TransformOptions); - _transform(chunk: any, encoding: string, callback: Function): void; + _transform(chunk: any, encoding: string, callback: TransformCallback): void; destroy(error?: Error): void; } diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index d238a3c80b..5012d70183 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -5499,14 +5499,16 @@ declare module "stream" { uncork(): void; } + type TransformCallback = (err?: Error, data?: any) => void; + export interface TransformOptions extends DuplexOptions { - transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - flush?: (callback: Function) => any; + transform?: (chunk: any, encoding: string, callback: TransformCallback) => any; + flush?: (callback: TransformCallback) => any; } export class Transform extends Duplex { constructor(opts?: TransformOptions); - _transform(chunk: any, encoding: string, callback: Function): void; + _transform(chunk: any, encoding: string, callback: TransformCallback): void; destroy(error?: Error): void; } From de70166aa8524575732f49472a2db9aa0a4c3b22 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Wed, 2 May 2018 17:37:13 +0200 Subject: [PATCH 051/113] Add type definitions for express-jsonschema (#25471) * Add type definitions for express-jsonschema * Add TypeScript version comment in head --- .../express-jsonschema-tests.ts | 71 +++++++++++++++++++ types/express-jsonschema/index.d.ts | 54 ++++++++++++++ types/express-jsonschema/tsconfig.json | 23 ++++++ types/express-jsonschema/tslint.json | 1 + 4 files changed, 149 insertions(+) create mode 100644 types/express-jsonschema/express-jsonschema-tests.ts create mode 100644 types/express-jsonschema/index.d.ts create mode 100644 types/express-jsonschema/tsconfig.json create mode 100644 types/express-jsonschema/tslint.json diff --git a/types/express-jsonschema/express-jsonschema-tests.ts b/types/express-jsonschema/express-jsonschema-tests.ts new file mode 100644 index 0000000000..85a3852d75 --- /dev/null +++ b/types/express-jsonschema/express-jsonschema-tests.ts @@ -0,0 +1,71 @@ +import { + JsonSchemaCustomPropertyError, + JsonSchemaValidation, + addSchemaProperties, + validate, +} from "express-jsonschema"; + +import { Request, Response, NextFunction } from "express"; +import { JSONSchema4 } from "json-schema"; + +let jsonSchema: JSONSchema4; +let expressMiddleware: (req: Request, res: Response, next: NextFunction) => void; + +jsonSchema = { + id: 'foo', + $ref: 'foo/bar', + $schema: 'http://json-schema.org/schema#', + title: 'foo', + description: 'bar', + default: 42, + multipleOf: 3, + maximum: 4, + exclusiveMaximum: true, + minimum: 5, + exclusiveMinimum: false, + 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', + allOf: [{}], + anyOf: [{}], + oneOf: [{}], + not: {}, + extends: 'foo', + bar: 4, + format: 'date-time', +}; + +expressMiddleware = validate({ test: jsonSchema }, [ jsonSchema ]); +addSchemaProperties({ + test: () => "This is an error with message...", + conditional: (instance: any, schema: JSONSchema4) => { + if (!instance) { + return "An instance should be present"; + } + } +}); diff --git a/types/express-jsonschema/index.d.ts b/types/express-jsonschema/index.d.ts new file mode 100644 index 0000000000..f089e1033e --- /dev/null +++ b/types/express-jsonschema/index.d.ts @@ -0,0 +1,54 @@ +// Type definitions for express-jsonschema 1.1 +// Project: https://github.com/trainiac/express-jsonschema#readme +// Definitions by: Arne Schubert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Request, Response, NextFunction } from "express"; +import { JSONSchema4 } from "json-schema"; + +export class JsonSchemaCustomPropertyError { + name: string; + message: string; + constructor(propertyName: string); +} + +export class JsonSchemaValidation { + name: string; + message: string; + validations: {[requestProperty: string]: Array<{ value: any, property: string, messages: string[]}> }; + constructor(validations: { [requestProperty: string]: { instance: any, property: string, message: string }}); +} + +/** + * Updates customProperties with the newProperties param. Provides a way for client to extend JSON Schema validations. + * + * @param newProperties - An object where the keys are the + * names of the new schema properties and the values are the respective + * functions that implement the validation. + * @throws Client tries to override an existing JSON Schema property. + */ +export function addSchemaProperties(newProperties: { [attribute: string]: (instance: any, schema: JSONSchema4, options: any, ctx: any) => void | string }): void; + +/** + * Accepts an object where the keys are request properties and the + * values are their respective schemas. Optionally, you may provide + * dependency schemas that are referenced by your schemas using `$ref` + * (see https://www.npmjs.com/package/jsonschema#complex-example-with-split-schemas-and-references + * for more details). + * Returns a middleware function that validates the given + * request properties when a request is made. If there is any invalid + * data a JsonSchemaValidation instance is passed to the next middleware. + * If the data is valid the next middleware is called with no params. + * + * @param schemas - An object where the keys are request properties + * and the values are their respective schemas. + * @param schemaDependencies - A list of schemas on which + * schemas in `schemas` parameter are dependent. These will be added + * to the `jsonschema` validator. + * @returns A middleware function. + */ +export function validate( + schemas: { [requestProperty: string]: JSONSchema4 }, + schemaDependencies?: JSONSchema4[], +): (req: Request, res: Response, next: NextFunction) => void; diff --git a/types/express-jsonschema/tsconfig.json b/types/express-jsonschema/tsconfig.json new file mode 100644 index 0000000000..964ad62e02 --- /dev/null +++ b/types/express-jsonschema/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", + "express-jsonschema-tests.ts" + ] +} diff --git a/types/express-jsonschema/tslint.json b/types/express-jsonschema/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-jsonschema/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 255a9b5643d79fe950dfc8fcd2134a76afbb8acd Mon Sep 17 00:00:00 2001 From: Boris Ablamunits Date: Wed, 2 May 2018 18:40:37 +0300 Subject: [PATCH 052/113] Add tickMargin to XAxisProps and YAxisProps (#25470) --- types/recharts/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index d1de1c2c46..b274430529 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -885,6 +885,8 @@ export interface XAxisProps extends EventAttributes { tickLine?: boolean | object; minTickGap?: number; tickSize?: number; + // The margin between tick line and the label + tickMargin?: number; interval?: AxisInterval; reversed?: boolean; // see label section at http://recharts.org/#/en-US/api/XAxis @@ -934,6 +936,8 @@ export interface YAxisProps extends EventAttributes { tickLine?: boolean | object; minTickGap?: number; tickSize?: number; + // The margin between tick line and the label + tickMargin?: number; interval?: AxisInterval; reversed?: boolean; // see label section at http://recharts.org/#/en-US/api/YAxis From 3c6a83e0b309f7d02e4627ef5d234d64059a8641 Mon Sep 17 00:00:00 2001 From: Justin Lessard Date: Wed, 2 May 2018 11:59:11 -0400 Subject: [PATCH 053/113] Updated cleave.js (#25456) --- types/cleave.js/cleave.js-tests.tsx | 11 ++++++++++- types/cleave.js/index.d.ts | 8 +++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/types/cleave.js/cleave.js-tests.tsx b/types/cleave.js/cleave.js-tests.tsx index 825b44a2ad..eb682d432b 100644 --- a/types/cleave.js/cleave.js-tests.tsx +++ b/types/cleave.js/cleave.js-tests.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import Cleave = require("cleave.js"); import CleaveReact = require("cleave.js/react"); -const Example1 = () => { +const ExampleSelector1 = () => { const cleave = new Cleave("#my-input", { phone: true }); cleave.setPhoneRegionCode("AT"); cleave.setRawValue("foo"); @@ -11,6 +11,15 @@ const Example1 = () => { cleave.destroy(); }; +const ExampleElement1 = () => { + const input: HTMLElement = new HTMLElement(); + + const cleave = new Cleave(input, { date: true }); + cleave.setRawValue("2001/01/01"); + const formattedDate: string = cleave.getISOFormatDate(); + cleave.destroy(); +}; + const ExampleReact1 = (props: any) => { return ( , // J Giancono , // Alex Shakun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 import { CleaveOptions } from './options'; declare class Cleave { - constructor(selector: string, options: CleaveOptions); + constructor(selector: string | HTMLElement, options: CleaveOptions); getRawValue(): string; @@ -17,6 +17,8 @@ declare class Cleave { getFormattedValue(): string; + getISOFormatDate(): string; + destroy(): void; setPhoneRegionCode(regionCode: string): void; From a84e447cb1c2a3e37150680ce2442af16e26751f Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Wed, 2 May 2018 18:39:00 +0200 Subject: [PATCH 054/113] Add type definition for "request-as-curl" (#25472) * Add type definitions for request-as-curl * Fix TypeScript version in comment * Add correct project URL --- types/request-as-curl/index.d.ts | 15 ++++++++++++ .../request-as-curl/request-as-curl-tests.ts | 14 +++++++++++ types/request-as-curl/tsconfig.json | 23 +++++++++++++++++++ types/request-as-curl/tslint.json | 1 + 4 files changed, 53 insertions(+) create mode 100644 types/request-as-curl/index.d.ts create mode 100644 types/request-as-curl/request-as-curl-tests.ts create mode 100644 types/request-as-curl/tsconfig.json create mode 100644 types/request-as-curl/tslint.json diff --git a/types/request-as-curl/index.d.ts b/types/request-as-curl/index.d.ts new file mode 100644 index 0000000000..e24266c53d --- /dev/null +++ b/types/request-as-curl/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for request-as-curl 0.1 +// Project: https://github.com/azproduction/node-request-as-curl +// Definitions by: Arne Schubert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { CoreOptions, Request, RequestAPI, RequiredUriUrl } from "request"; + +export = request_as_curl; + +declare function request_as_curl(request: RequestAPI, body?: any): string; + +declare namespace request_as_curl { + function serialize(request: RequestAPI): string; +} diff --git a/types/request-as-curl/request-as-curl-tests.ts b/types/request-as-curl/request-as-curl-tests.ts new file mode 100644 index 0000000000..2865ce3886 --- /dev/null +++ b/types/request-as-curl/request-as-curl-tests.ts @@ -0,0 +1,14 @@ +import requestAsCurl = require("request-as-curl"); + +import { CoreOptions, Request, RequestAPI, RequiredUriUrl } from "request"; + +let stringValue: string; +const req: RequestAPI = {} as any; + +// with optional data +stringValue = requestAsCurl(req, {test: "data"}); + +// without optional data +stringValue = requestAsCurl(req); + +stringValue = requestAsCurl.serialize(req); diff --git a/types/request-as-curl/tsconfig.json b/types/request-as-curl/tsconfig.json new file mode 100644 index 0000000000..9deda4ea8e --- /dev/null +++ b/types/request-as-curl/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", + "request-as-curl-tests.ts" + ] +} diff --git a/types/request-as-curl/tslint.json b/types/request-as-curl/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/request-as-curl/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e05a329534215872e7490511bab6faa0586fdbec Mon Sep 17 00:00:00 2001 From: "Carry.Wu" Date: Thu, 3 May 2018 23:01:04 +0800 Subject: [PATCH 055/113] Added type definitions for behavior3 (#25469) * add behavior3 types * fix test issues * type behavior3 remove jsdoc params. --- types/behavior3/behavior3-tests.ts | 73 +++ types/behavior3/index.d.ts | 908 +++++++++++++++++++++++++++++ types/behavior3/tsconfig.json | 23 + types/behavior3/tslint.json | 1 + 4 files changed, 1005 insertions(+) create mode 100644 types/behavior3/behavior3-tests.ts create mode 100644 types/behavior3/index.d.ts create mode 100644 types/behavior3/tsconfig.json create mode 100644 types/behavior3/tslint.json diff --git a/types/behavior3/behavior3-tests.ts b/types/behavior3/behavior3-tests.ts new file mode 100644 index 0000000000..b612209a09 --- /dev/null +++ b/types/behavior3/behavior3-tests.ts @@ -0,0 +1,73 @@ +import '../behavior3'; + +// Test decode +const blackboard = new b3.Blackboard(); +const behaviorTree = new b3.BehaviorTree(); +behaviorTree.load({ + version: "0.3.0", + scope: "tree", + id: "6bc03cd0-38ef-4a3e-8e08-54c412491525", + title: "A behavior tree", + description: "", + root: "607d29f5-9dbc-4cc4-8ebb-e57c4908d87b", + properties: {}, + nodes: { + "607d29f5-9dbc-4cc4-8ebb-e57c4908d87b": { + id: "607d29f5-9dbc-4cc4-8ebb-e57c4908d87b", + name: "Sequence", + title: "Sequence", + description: "", + properties: {}, + display: { + x: -216, + y: -36 + }, + children: [ + "09f04185-205b-40c0-8494-ffd53ffd0820", + "df7366f8-999a-4971-872c-cef57607f99f" + ] + }, + "df7366f8-999a-4971-872c-cef57607f99f": { + id: "df7366f8-999a-4971-872c-cef57607f99f", + name: "Runner", + title: "Runner", + description: "", + properties: {}, + display: { + x: -12, + y: -36 + } + }, + "e498e1a5-5295-43c3-8716-20dd6d3407f2": { + id: "e498e1a5-5295-43c3-8716-20dd6d3407f2", + name: "Succeeder", + title: "Succeeder", + description: "", + properties: {}, + display: { + x: 192, + y: -96 + } + }, + "09f04185-205b-40c0-8494-ffd53ffd0820": { + id: "09f04185-205b-40c0-8494-ffd53ffd0820", + name: "Inverter", + title: "Inverter", + description: "", + properties: {}, + display: { + x: -36, + y: -108 + }, + child: "e498e1a5-5295-43c3-8716-20dd6d3407f2" + } + }, + display: { + camera_x: 640, + camera_y: 324, + camera_z: 1, + x: -324, + y: -36 + } + }); +behaviorTree.tick(null, blackboard); diff --git a/types/behavior3/index.d.ts b/types/behavior3/index.d.ts new file mode 100644 index 0000000000..7cb3ad9deb --- /dev/null +++ b/types/behavior3/index.d.ts @@ -0,0 +1,908 @@ +// Type definitions for behavior3 0.2 +// Project: https://github.com/behavior3/behavior3js +// Definitions by: carry.wu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Behavior3JS + * =========== + * + * * * * + * + * **Behavior3JS** is a Behavior Tree library written in JavaScript. It + * provides structures and algorithms that assist you in the task of creating + * intelligent agents for your game or application. Check it out some features + * of Behavior3JS: + * + * - Based on the work of (Marzinotto et al., 2014), in which they propose a + * **formal**, **consistent** and **general** definition of Behavior Trees; + * - **Optimized to control multiple agents**: you can use a single behavior + * tree instance to handle hundreds of agents; + * - It was **designed to load and save trees in a JSON format**, in order to + * use, edit and test it in multiple environments, tools and languages; + * - A **cool visual editor** which you can access online; + * - Several **composite, decorator and action nodes** available within the + * library. You still can define your own nodes, including composites and + * decorators; + * - **Completely free**, the core module and the visual editor are all + * published under the MIT License, which means that you can use them for + * your open source and commercial projects; + * - **Lightweight**! + * + * Visit http://behavior3.com to know more! + * + * + * ## Core Classes and Functions + * + * This library include the following core structures... + * + * + * **Public:** + * + * - **BehaviorTree**: the structure that represents a Behavior Tree; + * - **Blackboard**: represents a "memory" in an agent and is required to to + * run a `BehaviorTree`; + * - **Composite**: base class for all composite nodes; + * - **Decorator**: base class for all decorator nodes; + * - **Action**: base class for all action nodes; + * - **Condition**: base class for all condition nodes; + * + * + * **Internal:** + * + * - **Tick**: used as container and tracking object through the tree during + * the tick signal; + * - **BaseNode**: the base class that provide all common node features; + * + * *Some classes are used internally on Behavior3JS, but you may need to access + * its functionalities eventually, specially the `Tick` object.* + * + * + * **Nodes:** + * + * - **Composite Nodes**: Sequence, Priority, MemSequence, MemPriority. + * - **Decorators**: Inverter, Limiter, MaxTime, Repeater, + * RepeaterUntilFailure, RepeaterUntilSuccess. + * - **Actions**: Succeeder, Failer, Error, Runner, Wait. + * + * ## The list of all constants in B3. + * + * NAME | VALUE + * ------------------- | ---------------------- + * VERSION | depends on the version + * | + * **Node State** | + * SUCCESS | 1 + * FAILURE | 2 + * RUNNING | 3 + * ERROR | 4 + * | + * **Node categories** | + * COMPOSITE | 'composite' + * DECORATOR | 'decorator' + * ACTION | 'action' + * CONDITION | 'condition' + * + */ +declare namespace b3 { + /** + * This function is used to create unique IDs for trees and nodes. + * + * (consult http://www.ietf.org/rfc/rfc4122.txt). + * + */ + function createUUID(): string; + + /** + * The BaseNode class is used as super class to all nodes in BehaviorJS. It + * comprises all common variables and methods that a node must have to + * execute. + * + * **IMPORTANT:** Do not inherit from this class, use `Composite`, + * `Decorator`, `Action` or `Condition`, instead. + * + * The attributes are specially designed to serialization of the node in a + * JSON format. In special, the `parameters` attribute can be set into the + * visual editor (thus, in the JSON file), and it will be used as parameter + * on the node initialization at `BehaviorTree.load`. + * + * BaseNode also provide 5 callback methods, which the node implementations + * can override. They are `enter`, `open`, `tick`, `close` and `exit`. See + * their documentation to know more. These callbacks are called inside the + * `_execute` method, which is called in the tree traversal. + * + */ + class BaseNode { + /** + * Initialization method. + */ + constructor({category, name, title, description, properties}?: {category?: string, name?: string, title?: string, description?: string, properties?: any}); + + /** + * This is the main method to propagate the tick signal to this node. This + * method calls all callbacks: `enter`, `open`, `tick`, `close`, and + * `exit`. It only opens a node if it is not already open. In the same + * way, this method only close a node if the node returned a status + * different of `RUNNING`. + * + */ + _execute(tick: Tick): number; + + /** + * Wrapper for enter method. + */ + _enter(tick: Tick): void; + + /** + * Wrapper for open method. + */ + _open(tick: Tick): void; + + /** + * Wrapper for tick method. + */ + _tick(tick: Tick): number; + + /** + * Wrapper for close method. + */ + _close(tick: Tick): void; + + /** + * Wrapper for exit method. + */ + _exit(tick: Tick): void; + + /** + * Enter method, override this to use. It is called every time a node is + * asked to execute, before the tick itself. + */ + enter(tick: Tick): void; + + /** + * Open method, override this to use. It is called only before the tick + * callback and only if the not isn't closed. + * + * Note: a node will be closed if it returned `RUNNING` in the tick. + * + */ + open(tick: Tick): void; + + /** + * Tick method, override this to use. This method must contain the real + * execution of node (perform a task, call children, etc.). It is called + * every time a node is asked to execute. + * + */ + tick(tick: Tick): void; + + /** + * Close method, override this to use. This method is called after the tick + * callback, and only if the tick return a state different from + * `RUNNING`. + * + */ + close(tick: Tick): void; + + /** + * Exit method, override this to use. Called every time in the end of the + * execution. + * + */ + exit(tick: Tick): void; + } + + /** + * Action is the base class for all action nodes. Thus, if you want to create + * new custom action nodes, you need to inherit from this class. For example, + * take a look at the Runner action: + * + * class Runner extends b3.Action { + * constructor(){ + * super({name: 'Runner'}); + * } + * tick(tick) { + * return b3.RUNNING; + * } + * }; + * + */ + class Action extends BaseNode { + /** + * Creates an instance of Action. + */ + constructor({name, title, properties}?: {name?: string, title?: string, properties?: any}); + } + + /** + * The BehaviorTree class, as the name implies, represents the Behavior Tree + * structure. + * + * There are two ways to construct a Behavior Tree: by manually setting the + * root node, or by loading it from a data structure (which can be loaded + * from a JSON). Both methods are shown in the examples below and better + * explained in the user guide. + * + * The tick method must be called periodically, in order to send the tick + * signal to all nodes in the tree, starting from the root. The method + * `BehaviorTree.tick` receives a target object and a blackboard as + * parameters. The target object can be anything: a game agent, a system, a + * DOM object, etc. This target is not used by any piece of Behavior3JS, + * i.e., the target object will only be used by custom nodes. + * + * The blackboard is obligatory and must be an instance of `Blackboard`. This + * requirement is necessary due to the fact that neither `BehaviorTree` or + * any node will store the execution variables in its own object (e.g., the + * BT does not store the target, information about opened nodes or number of + * times the tree was called). But because of this, you only need a single + * tree instance to control multiple (maybe hundreds) objects. + * + * Manual construction of a Behavior Tree + * -------------------------------------- + * + * var tree = new b3.BehaviorTree(); + * + * tree.root = new b3.Sequence({children:[ + * new b3.Priority({children:[ + * new MyCustomNode(), + * new MyCustomNode() + * ]}), + * ... + * ]}); + * + * + * Loading a Behavior Tree from data structure + * ------------------------------------------- + * + * var tree = new b3.BehaviorTree(); + * + * tree.load({ + * 'title' : 'Behavior Tree title' + * 'description' : 'My description' + * 'root' : 'node-id-1' + * 'nodes' : { + * 'node-id-1' : { + * 'name' : 'Priority', // this is the node type + * 'title' : 'Root Node', + * 'description' : 'Description', + * 'children' : ['node-id-2', 'node-id-3'], + * }, + * ... + * } + * }) + * + */ + class BehaviorTree { + /** + * Initialization method. + */ + constructor(); + + /** + * This method loads a Behavior Tree from a data structure, populating this + * object with the provided data. Notice that, the data structure must + * follow the format specified by Behavior3JS. Consult the guide to know + * more about this format. + * + * You probably want to use custom nodes in your BTs, thus, you need to + * provide the `names` object, in which this method can find the nodes by + * `names[NODE_NAME]`. This variable can be a namespace or a dictionary, + * as long as this method can find the node by its name, for example: + * + * //json + * ... + * 'node1': { + * 'name': MyCustomNode, + * 'title': ... + * } + * ... + * + * //code + * var bt = new b3.BehaviorTree(); + * bt.load(data, {'MyCustomNode':MyCustomNode}) + * + * + */ + load(data: any, names?: any): void; + + /** + * This method dump the current BT into a data structure. + * + * Note: This method does not record the current node parameters. Thus, + * it may not be compatible with load for now. + * + */ + dump(): any; + + /** + * Propagates the tick signal through the tree, starting from the root. + * + * This method receives a target object of any type (Object, Array, + * DOMElement, whatever) and a `Blackboard` instance. The target object has + * no use at all for all Behavior3JS components, but surely is important + * for custom nodes. The blackboard instance is used by the tree and nodes + * to store execution variables (e.g., last node running) and is obligatory + * to be a `Blackboard` instance (or an object with the same interface). + * + * Internally, this method creates a Tick object, which will store the + * target and the blackboard objects. + * + * Note: BehaviorTree stores a list of open nodes from last tick, if these + * nodes weren't called after the current tick, this method will close them + * automatically. + * + */ + tick(target: any, blackboard: Blackboard): string; + } + + /** + * The Blackboard is the memory structure required by `BehaviorTree` and its + * nodes. It only have 2 public methods: `set` and `get`. These methods works + * in 3 different contexts: global, per tree, and per node per tree. + * + * Suppose you have two different trees controlling a single object with a + * single blackboard, then: + * + * - In the global context, all nodes will access the stored information. + * - In per tree context, only nodes sharing the same tree share the stored + * information. + * - In per node per tree context, the information stored in the blackboard + * can only be accessed by the same node that wrote the data. + * + * The context is selected indirectly by the parameters provided to these + * methods, for example: + * + * // getting/setting variable in global context + * blackboard.set('testKey', 'value'); + * var value = blackboard.get('testKey'); + * + * // getting/setting variable in per tree context + * blackboard.set('testKey', 'value', tree.id); + * var value = blackboard.get('testKey', tree.id); + * + * // getting/setting variable in per node per tree context + * blackboard.set('testKey', 'value', tree.id, node.id); + * var value = blackboard.get('testKey', tree.id, node.id); + * + * Note: Internally, the blackboard store these memories in different + * objects, being the global on `_baseMemory`, the per tree on `_treeMemory` + * and the per node per tree dynamically create inside the per tree memory + * (it is accessed via `_treeMemory[id].nodeMemory`). Avoid to use these + * variables manually, use `get` and `set` instead. + * + */ + class Blackboard { + /** + * Initialization method. + */ + constructor(); + + /** + * Internal method to retrieve the tree context memory. If the memory does + * not exist, this method creates it. + * + */ + _getTreeMemory(treeScope: string): any; + + /** + * Internal method to retrieve the node context memory, given the tree + * memory. If the memory does not exist, this method creates is. + * + */ + _getNodeMemory(treeMemory: string, nodeScope: string): any; + + /** + * Internal method to retrieve the context memory. If treeScope and + * nodeScope are provided, this method returns the per node per tree + * memory. If only the treeScope is provided, it returns the per tree + * memory. If no parameter is provided, it returns the global memory. + * Notice that, if only nodeScope is provided, this method will still + * return the global memory. + * + */ + _getMemory(treeScope: string, nodeScope: string): any; + + /** + * Stores a value in the blackboard. If treeScope and nodeScope are + * provided, this method will save the value into the per node per tree + * memory. If only the treeScope is provided, it will save the value into + * the per tree memory. If no parameter is provided, this method will save + * the value into the global memory. Notice that, if only nodeScope is + * provided (but treeScope not), this method will still save the value into + * the global memory. + * + */ + set(key: string, value: string, treeScope: string, nodeScope: string): void; + + /** + * Retrieves a value in the blackboard. If treeScope and nodeScope are + * provided, this method will retrieve the value from the per node per tree + * memory. If only the treeScope is provided, it will retrieve the value + * from the per tree memory. If no parameter is provided, this method will + * retrieve from the global memory. If only nodeScope is provided (but + * treeScope not), this method will still try to retrieve from the global + * memory. + * + */ + get(key: string, treeScope: string, nodeScope: string): any; + } + + /** + * Composite is the base class for all composite nodes. Thus, if you want to + * create new custom composite nodes, you need to inherit from this class. + * + * When creating composite nodes, you will need to propagate the tick signal + * to the children nodes manually. To do that, override the `tick` method and + * call the `_execute` method on all nodes. For instance, take a look at how + * the Sequence node inherit this class and how it call its children: + * + * // Inherit from Composite, using the util function Class. + * class Sequence extends Composite { + * + * constructor(){ + * // Remember to set the name of the node. + * super({name: 'Sequence'}); + * } + * + * // Override the tick function + * tick(tick) { + * + * // Iterates over the children + * for (var i=0; i Date: Thu, 3 May 2018 11:28:04 -0400 Subject: [PATCH 056/113] Added intercom-client (#25510) * added feather-icons * added strictfunctiontypes * added intercom-client * splitting pull requests by package --- types/intercom-client/index.d.ts | 13 +++++++++++++ types/intercom-client/intercom-client-tests.ts | 3 +++ types/intercom-client/tsconfig.json | 16 ++++++++++++++++ types/intercom-client/tslint.json | 1 + 4 files changed, 33 insertions(+) create mode 100644 types/intercom-client/index.d.ts create mode 100644 types/intercom-client/intercom-client-tests.ts create mode 100644 types/intercom-client/tsconfig.json create mode 100644 types/intercom-client/tslint.json diff --git a/types/intercom-client/index.d.ts b/types/intercom-client/index.d.ts new file mode 100644 index 0000000000..b68dc87e71 --- /dev/null +++ b/types/intercom-client/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for intercom-client 2.9 +// Project: https://github.com/intercom/intercom-node +// Definitions by: Jinesh Shah +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface IdentityVerificationOptions { + secretKey: string; + identifier: string; +} + +export const IdentityVerification: { + userHash(opts: IdentityVerificationOptions): string; +}; diff --git a/types/intercom-client/intercom-client-tests.ts b/types/intercom-client/intercom-client-tests.ts new file mode 100644 index 0000000000..e74dab4f53 --- /dev/null +++ b/types/intercom-client/intercom-client-tests.ts @@ -0,0 +1,3 @@ +import * as intercom from "intercom-client"; + +intercom.IdentityVerification.userHash({ secretKey: "", identifier: "" }); // $ExpectType string diff --git a/types/intercom-client/tsconfig.json b/types/intercom-client/tsconfig.json new file mode 100644 index 0000000000..a74d113775 --- /dev/null +++ b/types/intercom-client/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "intercom-client-tests.ts"] +} diff --git a/types/intercom-client/tslint.json b/types/intercom-client/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/intercom-client/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 73a7a2d99ff63502d7fb426133a340fadc945538 Mon Sep 17 00:00:00 2001 From: Jinesh Shah Date: Thu, 3 May 2018 11:28:43 -0400 Subject: [PATCH 057/113] Added feather-icons (#25509) * added feather-icons * added strictfunctiontypes * added intercom-client --- types/feather-icons/feather-icons-tests.ts | 7 +++++++ types/feather-icons/index.d.ts | 22 ++++++++++++++++++++++ types/feather-icons/tsconfig.json | 16 ++++++++++++++++ types/feather-icons/tslint.json | 1 + 4 files changed, 46 insertions(+) create mode 100644 types/feather-icons/feather-icons-tests.ts create mode 100644 types/feather-icons/index.d.ts create mode 100644 types/feather-icons/tsconfig.json create mode 100644 types/feather-icons/tslint.json diff --git a/types/feather-icons/feather-icons-tests.ts b/types/feather-icons/feather-icons-tests.ts new file mode 100644 index 0000000000..fc71f25798 --- /dev/null +++ b/types/feather-icons/feather-icons-tests.ts @@ -0,0 +1,7 @@ +import * as feather from "feather-icons"; + +feather.replace(); // $ExpectType void +feather.icons[""].toSvg(); // $ExpectType string +feather.icons[""].name; // $ExpectType string +feather.icons[""].contents; // $ExpectType string +feather.icons[""].tags; // $ExpectType string[] diff --git a/types/feather-icons/index.d.ts b/types/feather-icons/index.d.ts new file mode 100644 index 0000000000..34acfb80aa --- /dev/null +++ b/types/feather-icons/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for feather-icons 4.7 +// Project: https://github.com/feathericons/feather#readme +// Definitions by: Jinesh Shah +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace feather; + +export interface FeatherAttributes { + [key: string]: string | number; +} + +export function replace(options?: FeatherAttributes): void; + +export const icons: { + [key: string]: { + name: string; + contents: string; + tags: string[]; + attrs: FeatherAttributes; + toSvg: (options?: FeatherAttributes) => string; + }; +}; diff --git a/types/feather-icons/tsconfig.json b/types/feather-icons/tsconfig.json new file mode 100644 index 0000000000..ab8237b4de --- /dev/null +++ b/types/feather-icons/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "feather-icons-tests.ts"] +} diff --git a/types/feather-icons/tslint.json b/types/feather-icons/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/feather-icons/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From ee09f446b0b61f27a9e774048f87347a0a1c15d8 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Thu, 3 May 2018 17:29:14 +0200 Subject: [PATCH 058/113] ws: add address method to Server (#25503) --- types/ws/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/ws/index.d.ts b/types/ws/index.d.ts index 7848bf3992..f9bda66eba 100644 --- a/types/ws/index.d.ts +++ b/types/ws/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ws 4.0 +// Type definitions for ws 5.1 // Project: https://github.com/websockets/ws // Definitions by: Paul Loyd // Matt Silverlock @@ -176,6 +176,7 @@ declare namespace WebSocket { constructor(options?: ServerOptions, callback?: () => void); + address(): { port: number; family: string; address: string; }; close(cb?: (err?: Error) => void): void; handleUpgrade(request: http.IncomingMessage, socket: net.Socket, upgradeHead: Buffer, callback: (client: WebSocket) => void): void; From 884979debd85d0bad3cb3b999c0574bf46e49fb5 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Thu, 3 May 2018 11:50:27 -0400 Subject: [PATCH 059/113] [react-native] ScrollView - make scrollToLocation method (#25505) --- types/react-native/index.d.ts | 20 ++++++++--------- types/react-native/test/index.tsx | 37 ++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 3b51e1012f..3da848137d 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3784,14 +3784,6 @@ export interface SectionListData extends SectionBase { [key: string]: any; } -export interface SectionListScrollParams { - animated?: boolean; - itemIndex: number; - sectionIndex: number; - viewOffset?: number; - viewPosition?: number; -} - export interface SectionListProps extends ScrollViewProps { /** * Rendered in between adjacent Items within each section. @@ -3900,7 +3892,17 @@ export interface SectionListProps extends ScrollViewProps { * Only enabled by default on iOS because that is the platform standard there. */ stickySectionHeadersEnabled?: boolean; +} +export interface SectionListScrollParams { + animated?: boolean; + itemIndex: number; + sectionIndex: number; + viewOffset?: number; + viewPosition?: number; +} + +export interface SectionListStatic extends React.ComponentClass> { /** * Scrolls to the item at the specified sectionIndex and itemIndex (within the section) * positioned in the viewable area such that viewPosition 0 places it at the top @@ -3909,8 +3911,6 @@ export interface SectionListProps extends ScrollViewProps { scrollToLocation?(params: SectionListScrollParams): void; } -export interface SectionListStatic extends React.ComponentClass> {} - /** * @see https://facebook.github.io/react-native/docs/virtualizedlist.html#props */ diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index a4564d6614..0bd0309963 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -259,6 +259,12 @@ export class FlatListTest extends React.Component, {}> { } export class SectionListTest extends React.Component, {}> { + myList: SectionList + + scrollMe = () => { + this.myList.scrollToLocation({itemIndex: 0, sectionIndex: 1}); + } + render() { const sections = [ { @@ -277,19 +283,24 @@ export class SectionListTest extends React.Component, { ]; return ( - ( - - {section.title} - - )} - renderItem={(info: { item: string }) => ( - - {info.item} - - )} - /> + +