diff --git a/.editorconfig b/.editorconfig index 404ff0701c..fc4ed3486f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,5 +5,5 @@ indent_size = 4 trim_trailing_whitespace = true insert_final_newline = true -[{*.json,*.yml,*.ts}] +[{*.json,*.yml,*.ts,*.tsx,*.md}] indent_style = space diff --git a/README.md b/README.md index 026994fdd5..125b897e42 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# DefinitelyTyped [![Build Status](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped.svg?branch=master)](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped) - -[![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +# DefinitelyTyped > The repository for *high quality* TypeScript type definitions. @@ -8,6 +6,19 @@ Also see the [definitelytyped.org](http://definitelytyped.org) website, although *You can also read this README in [Spanish](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md), [Korean](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md), and [Russian](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ru.md)!* +## Current status + +This section tracks the health of the repository and publishing process. +It may be helpful for contributors experiencing any issues with their PRs and packages. + +* All packages are type-checking/linting cleanly: [![Build Status](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped.svg?branch=master)](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped) +* All packages are being published to npm in under 10,000 seconds: [![Publish Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) +* [typescript-bot](https://github.com/typescript-bot) has been active on DefinitelyTyped [![Activity Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) + +If anything here seems wrong, or any of the above are failing, please raise an issue in [the DefinitelyTyped Gitter channel](https://gitter.im/DefinitelyTyped/DefinitelyTyped). + +[![Join the chat at https://gitter.im/DefinitelyTyped/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/DefinitelyTyped/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + ## What are declaration files? See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html). @@ -342,6 +353,3 @@ This project is licensed under the MIT license. Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file. [![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon) - -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average? -[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours? diff --git a/README.ru.md b/README.ru.md index b90bdeac7c..9186c2ddd5 100644 --- a/README.ru.md +++ b/README.ru.md @@ -8,7 +8,7 @@ Также посетите веб-сайт [definitelytyped.org](http://definitelytyped.org), хотя информация в этом README более свежая. -*Вы также можете прочитать этот README на [английском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md), [испанском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md) and [корейском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md).* +*Вы также можете прочитать этот README на [английском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md), [испанском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md) и [корейском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md).* ## Что такое файлы декларации (файлы описания/объявления типов)? @@ -101,9 +101,9 @@ DefinitelyTyped работает только благодаря вкладу т // John ``` -* Если есть `tslint.json`, запустите `npm run lint package-name`. В противном случае запустите `tsc` in в директории пакета. +* Если есть `tslint.json`, запустите `npm run lint package-name`. В противном случае запустите `tsc` в директории пакета. -Когда вы создаете PR для редактирования существующего пакета, `dt-bot` должен @-уведомить previous authors. +Когда вы создаете PR для редактирования существующего пакета, `dt-bot` должен @-уведомить предыдущих авторов. Если этого не произойдет, вы можете сделать это самостоятельно в комментарии, связанном с PR. @@ -124,7 +124,7 @@ DefinitelyTyped работает только благодаря вкладу т | tsconfig.json | Позволяет вам запускать `tsc` внутри пакета. | | tslint.json | Включает linting. | -Создайте их, запустив `npx dts-gen --dt --name my-package-name --template module` если у вас ≥ 5.2.0, `npm install -g dts-gen` и `dts-gen --dt --name my-package-name --template module` в противном случае. +Создайте их, запустив `npx dts-gen --dt --name my-package-name --template module` если у вас npm ≥ 5.2.0, `npm install -g dts-gen` и `dts-gen --dt --name my-package-name --template module` в противном случае. Посмотреть все варианты на [dts-gen](https://github.com/Microsoft/dts-gen). Вы можете отредактировать `tsconfig.json` чтобы добавить новые файлы, добавить `"target": "es6"` (необходимо для асинхронных функций), добавить в `"lib"`, или добавить опцию компилятора `"jsx"`. @@ -283,7 +283,7 @@ f("one"); "typeRoots": ["../../"], "paths": { "history": [ "history/v2" ] - }, + } }, "files": [ "index.d.ts", diff --git a/types/activestorage/activestorage-tests.ts b/types/activestorage/activestorage-tests.ts new file mode 100644 index 0000000000..ac9622e2d8 --- /dev/null +++ b/types/activestorage/activestorage-tests.ts @@ -0,0 +1,28 @@ +import * as ActiveStorage from 'activestorage'; + +ActiveStorage.start(); + +const delegate: ActiveStorage.DirectUploadDelegate = { + directUploadWillCreateBlobWithXHR(xhr) { + console.log(xhr.status); + }, + + directUploadWillStoreFileWithXHR(xhr) { + console.log(xhr.status); + }, +}; + +const d = new ActiveStorage.DirectUpload( + new File([], 'blank.txt'), + '/rails/active_storage/direct_uploads', + delegate +); + +d.create((error, blob) => { + if (error) { + console.log(error.message); + } else { + const { byte_size, checksum, content_type, filename, signed_id } = blob; + console.log({ byte_size, checksum, content_type, filename, signed_id }); + } +}); diff --git a/types/activestorage/index.d.ts b/types/activestorage/index.d.ts new file mode 100644 index 0000000000..2d749c84ec --- /dev/null +++ b/types/activestorage/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for ActiveStorage 5.2 +// Project: https://github.com/rails/rails/tree/master/activestorage/app/javascipt +// Definitions by: Cameron Bothner +// Definitions: https://github.com/cbothner/DefinitelyTyped +// TypeScript Version: 2.1 + +export as namespace ActiveStorage + +export function start(): void; + +export class DirectUpload { + id: number; + file: File; + url: string; + + constructor(file: File, url: string, delegate: DirectUploadDelegate) + + create(callback: (error: Error, blob: Blob) => void): void; +} + +export interface DirectUploadDelegate { + directUploadWillCreateBlobWithXHR?: (xhr: XMLHttpRequest) => void; + + directUploadWillStoreFileWithXHR?: (xhr: XMLHttpRequest) => void; +} + +export interface Blob { + byte_size: number; + checksum: string; + content_type: string; + filename: string; + signed_id: string; +} diff --git a/types/activestorage/tsconfig.json b/types/activestorage/tsconfig.json new file mode 100644 index 0000000000..326c2c7401 --- /dev/null +++ b/types/activestorage/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "activestorage-tests.ts"] +} diff --git a/types/activestorage/tslint.json b/types/activestorage/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/activestorage/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/array-move/array-move-tests.ts b/types/array-move/array-move-tests.ts new file mode 100644 index 0000000000..0bf720b751 --- /dev/null +++ b/types/array-move/array-move-tests.ts @@ -0,0 +1,8 @@ +import arrayMove = require('array-move'); + +const input = ['a', 'b', 'c']; +const input2 = [1, 2, 3]; + +arrayMove(input, 1, 2); // $ExpectType string[] +arrayMove(input2, 1, 2); // $ExpectType number[] +arrayMove.mut(input, 1, 2); // $ExpectType void diff --git a/types/array-move/index.d.ts b/types/array-move/index.d.ts new file mode 100644 index 0000000000..9b9aae938a --- /dev/null +++ b/types/array-move/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for array-move 1.0 +// Project: https://github.com/sindresorhus/array-move +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = arrayMove; + +/** + * Move an array item to a different position. + * + * @param from Index of item to move. If negative, it will begin that many elements from the end. + * @param to Index of where to move the item. If negative, it will begin that many elements from the end. + * @returns A new array with the item moved to the new position. + */ +declare function arrayMove(input: T, from: number, to: number): T; + +declare namespace arrayMove { + /** + * Moves the item to the new position in the input array. + * + * Useful for huge arrays where absolute performance is needed. + * + * @param from Index of item to move. If negative, it will begin that many elements from the end. + * @param to Index of where to move the item. If negative, it will begin that many elements from the end. + */ + function mut(input: any[], from: number, to: number): void; +} diff --git a/types/array-move/tsconfig.json b/types/array-move/tsconfig.json new file mode 100644 index 0000000000..6b4a5d5bb0 --- /dev/null +++ b/types/array-move/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", + "array-move-tests.ts" + ] +} diff --git a/types/array-move/tslint.json b/types/array-move/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/array-move/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/auth0-lock/auth0-lock-tests.ts b/types/auth0-lock/auth0-lock-tests.ts index 6e23e81d5e..53c50dd98f 100644 --- a/types/auth0-lock/auth0-lock-tests.ts +++ b/types/auth0-lock/auth0-lock-tests.ts @@ -130,7 +130,8 @@ const otherOptions : Auth0LockConstructorOptions = { hashCleanup: false, leeway: 30, _enableImpersonation: true, - _enableIdPInitiatedLogin: false + _enableIdPInitiatedLogin: false, + defaultADUsernameFromEmailPrefix: false }; new Auth0Lock(CLIENT_ID, DOMAIN, otherOptions); diff --git a/types/auth0-lock/index.d.ts b/types/auth0-lock/index.d.ts index 2916ec58c8..32a3228e56 100644 --- a/types/auth0-lock/index.d.ts +++ b/types/auth0-lock/index.d.ts @@ -130,7 +130,7 @@ interface Auth0LockConstructorOptions { closable?: boolean; configurationBaseUrl?: string; container?: string; - defaultADUsernameFromEmailPrefix?: string; + defaultADUsernameFromEmailPrefix?: boolean; defaultDatabaseConnection?: string; defaultEnterpriseConnection?: string; flashMessage?: Auth0LockFlashMessageOptions; diff --git a/types/beeper/beeper-tests.ts b/types/beeper/beeper-tests.ts new file mode 100644 index 0000000000..b3f6f8d60b --- /dev/null +++ b/types/beeper/beeper-tests.ts @@ -0,0 +1,7 @@ +import beeper = require('beeper'); + +beeper(); +beeper(3); +beeper(3, () => {}); +beeper('****-*-*'); +beeper('****-*-*', () => {}); diff --git a/types/beeper/index.d.ts b/types/beeper/index.d.ts new file mode 100644 index 0000000000..3e17e4be1c --- /dev/null +++ b/types/beeper/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for beeper 1.1 +// Project: https://github.com/sindresorhus/beeper#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = beeper; + +declare function beeper(count?: number, cb?: () => void): void; +declare function beeper(melody: string, cb?: () => void): void; diff --git a/types/beeper/tsconfig.json b/types/beeper/tsconfig.json new file mode 100644 index 0000000000..54614ad773 --- /dev/null +++ b/types/beeper/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", + "beeper-tests.ts" + ] +} diff --git a/types/beeper/tslint.json b/types/beeper/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/beeper/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bn.js/bn.js-tests.ts b/types/bn.js/bn.js-tests.ts index a5d37dfdeb..738d5220d4 100644 --- a/types/bn.js/bn.js-tests.ts +++ b/types/bn.js/bn.js-tests.ts @@ -8,3 +8,11 @@ bn.byteLength; bn.toArrayLike(Buffer, 'le', 2); const test = new BN(1, 'le'); + +const ctx = BN.red('p224'); +ctx.prime.name; + +const red = bn.toRed(ctx); +const newRed = red.redAdd(new BN(1)); +newRed.cmp(bn); +newRed.fromRed(); diff --git a/types/bn.js/index.d.ts b/types/bn.js/index.d.ts index db4c9f8b9e..be04dbcc5f 100644 --- a/types/bn.js/index.d.ts +++ b/types/bn.js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/indutny/bn.js // Definitions by: Leonid Logvinov // Henry Nguyen +// Gaylor Bosson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -9,36 +10,16 @@ type Endianness = 'le' | 'be'; type IPrimeName = 'k256' | 'p224' | 'p192' | 'p25519'; -declare class RedBN { - redAdd(b: RedBN): RedBN; - redIAdd(b: RedBN): RedBN; - redSub(b: RedBN): RedBN; - redISub(b: RedBN): RedBN; - redShl(num: number): RedBN; - redMul(b: RedBN): RedBN; - redIMul(b: RedBN): RedBN; - redSqr(): RedBN; - redISqr(): RedBN; - /** - * @description square root modulo reduction context's prime - */ - redSqrt(): RedBN; - /** - * @description modular inverse of the number - */ - redInvm(): RedBN; - redNeg(): RedBN; - /** - * @description modular exponentiation - */ - redPow(b: RedBN): RedBN; - fromRed(): BN; +interface MPrime { + name: string; + p: BN; + n: number; + k: BN; } -// FIXME: not sure how to specify the reduction context here interface ReductionContext { m: number; - prime: any; + prime: MPrime; [key: string]: any; } @@ -78,11 +59,6 @@ declare class BN { */ static min(left: BN, right: BN): BN; - /** - * @description Convert number to red - */ - toRed(reductionContext: ReductionContext): RedBN; - /** * @description clone number */ @@ -522,6 +498,87 @@ declare class BN { * @description inverse `a` modulo `b` */ invm(b: BN): BN; + + /** + * @description Convert number to red + */ + toRed(reductionContext: ReductionContext): RedBN; +} + +/** + * Big-Number class with additionnal methods that are using modular + * operation. + */ +declare class RedBN extends BN { + /** + * @description Convert back a number using a reduction context + */ + fromRed(): BN; + + /** + * @description modular addition + */ + redAdd(b: BN): RedBN; + + /** + * @description in-place modular addition + */ + redIAdd(b: BN): RedBN; + + /** + * @description modular subtraction + */ + redSub(b: BN): RedBN; + + /** + * @description in-place modular subtraction + */ + redISub(b: BN): RedBN; + + /** + * @description modular shift left + */ + redShl(num: number): RedBN; + + /** + * @description modular multiplication + */ + redMul(b: BN): RedBN; + + /** + * @description in-place modular multiplication + */ + redIMul(b: BN): RedBN; + + /** + * @description modular square + */ + redSqr(): RedBN; + + /** + * @description in-place modular square + */ + redISqr(): RedBN; + + /** + * @description modular square root + */ + redSqrt(): RedBN; + + /** + * @description modular inverse of the number + */ + redInvm(): RedBN; + + /** + * @description modular negation + */ + redNeg(): RedBN; + + /** + * @description modular exponentiation + */ + redPow(b: BN): RedBN; } export = BN; diff --git a/types/cordova-plugin-ble-central/cordova-plugin-ble-central-tests.ts b/types/cordova-plugin-ble-central/cordova-plugin-ble-central-tests.ts index 6e4317ac9d..f7830c18b2 100644 --- a/types/cordova-plugin-ble-central/cordova-plugin-ble-central-tests.ts +++ b/types/cordova-plugin-ble-central/cordova-plugin-ble-central-tests.ts @@ -61,59 +61,89 @@ var demoExtendedData : BLECentralPlugin.PeripheralDataExtended = { //get updates about the bluethooth states ble.startStateNotifications((state) => log(`BLE state ${state}`)); +ble.startStateNotifications((state) => log(`BLE state ${state}`), (err: string) => log(`things when wrong ${err}`)); -ble.isEnabled(()=> log(`bluetooth is enabled`), ()=>log(`bluetooth is not enabled`)); +ble.isEnabled(()=> log(`bluetooth is enabled`), err =>log(`bluetooth is not enabled: ${err}`)); //here we try to enable bluetooth -ble.enable(() => log(`yes it worked, or it was already enabled `), () => log(`nope it didn't work, the user pressed cancel, or we are in iOS`)); +ble.enable(() => log(`yes it worked, or it was already enabled `), err => log(`nope it didn't work, the user pressed cancel, or we are in iOS: ${err}`)); ble.showBluetoothSettings(() => log(`yes it worked`), () => log(`nope it didn't work`)) //stop getting updates about the bluethooth states ble.stopStateNotifications() +ble.stopStateNotifications(() => log(`yes it worked`)) +ble.stopStateNotifications(() => log(`yes it worked`), () => log(`nope it didn't work`)) //scan 5 seconds -ble.scan([], 5000, (data) => { devices.push(data); }, ()=> log('couldn\'t connect') ); +ble.scan([], 5000, (data) => { devices.push(data); }); +ble.scan([], 5000, (data) => { devices.push(data); }, () => log(`couldn't connect`) ); +ble.scan([], 5000, (data) => { devices.push(data); }, err => log(`couldn't connect: ${err}`) ); //scan continously -ble.startScan([], (data) => { devices.push(data); }, ()=> log('couldn\'t connect') ) +ble.startScan([], (data) => { devices.push(data); }) +ble.startScan([], (data) => { devices.push(data); }, () => log('couldn\'t connect') ) +ble.startScan([], (data) => { devices.push(data); }, err => log(`couldn't connect: ${err}`) ); ////scan continously -ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); }, ()=> log('couldn\'t connect') ) +ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); }); +ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); }, err => log(`couldn't connect: ${err}`)); //stop scanning ble.stopScan(()=> log('all good'), ()=> log('couldn\'t stop scanning')); //are we conenected to that device? +ble.isConnected(demoDevice.id, () => log(`already connected to this device`)); ble.isConnected(demoDevice.id, () => log(`already connected to this device`), ()=> log(`not yet connected to that device`)); //connect to a specific device var extendedData : BLECentralPlugin.PeripheralDataExtended; -ble.connect(demoDevice.id, (data)=> extendedData = data, () => log(`couldn't connect to the device`) ); +ble.connect(demoDevice.id, (data)=> extendedData = data, err => log(`couldn't connect to the device: ${err}`) ); //read some data from a characteristic var charsOfOneOfItsServices = demoExtendedData.characteristics.filter((value) => value.service == demoExtendedData.services[0]); +ble.read(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic); ble.read(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, (data) => log(`we've received some data`), ()=> log(`couldn't read any data`)); //read the rssi ble.readRSSI(demoDevice.id, (rssi)=>log(`Device ${demoDevice.name} has an RSSI of ${rssi}`)); +ble.readRSSI(demoDevice.id, (rssi)=>log(`Device ${demoDevice.name} has an RSSI of ${rssi}`), err => log(`Unable to read RSSI: ${err}`)); + + +// request mtu +ble.requestMtu(demoDevice.id, 10); +ble.requestMtu(demoDevice.id, 10, () => log('it worked')); +ble.requestMtu(demoDevice.id, 10, () => log('it worked'), () => log('it failed')); + +// refreshDeviceCache +ble.refreshDeviceCache(demoDevice.id, 10); +ble.refreshDeviceCache(demoDevice.id, 10, () => log('it worked')); +ble.refreshDeviceCache(demoDevice.id, 10, () => log('it worked'), () => log('it failed')); var notificationsReceived : number = 0; //get notified of changes for that characteristic -ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, (data)=> notificationsReceived++, ()=> log(`darn`)); +ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, + (data)=> notificationsReceived++); +ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, + (data)=> notificationsReceived++, err => log(`darn: ${err}`)); //write some data +ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40)); +ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`)); ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`), ()=> log(`could't write`)); //write some data without getting notified +ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40)); +ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`)); ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`), ()=> log(`could't write`)); //stop getting notified of changes. ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic); +ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, () => log('it worked')); +ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, () => log('it worked'), () => log('it failed')); //notificationsReceived == 1 //just disconnect ble.disconnect(demoDevice.id); - - - +ble.disconnect(demoDevice.id, () => log('it worked')); +ble.disconnect(demoDevice.id, () => log('it worked'), () => log('it failed')); diff --git a/types/cordova-plugin-ble-central/index.d.ts b/types/cordova-plugin-ble-central/index.d.ts index ccf2396833..070b62ff9e 100644 --- a/types/cordova-plugin-ble-central/index.d.ts +++ b/types/cordova-plugin-ble-central/index.d.ts @@ -1,12 +1,13 @@ -// Type definitions for cordova-plugin-ble-central 1.1.2 +// Type definitions for cordova-plugin-ble-central 1.2.2 // Project: https://github.com/don/cordova-plugin-ble-central // Definitions by: Gidon Junge +// Philip Peitsch // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace BLECentralPlugin { - interface PeripheralCharacteristic { + interface PeripheralCharacteristic { service: string; characteristic: string; properties: string[]; @@ -26,7 +27,12 @@ declare namespace BLECentralPlugin { characteristics: PeripheralCharacteristic[] } - + + interface BLEError { + name: string; + id: string; + errorMessage: string; + } interface StartScanOptions { @@ -34,75 +40,80 @@ declare namespace BLECentralPlugin { } export interface BLECentralPluginStatic { - scan(services: string[], seconds: number, success : (data: PeripheralData) => any): void; - scan(services: string[], seconds: number, success : (data: PeripheralData) => any, failure : () => any): void; - - startScan(services: string[], success: (data: PeripheralData) => any): void; - startScan(services: string[], success: (data: PeripheralData) => any, failure: () => any): void; + scan(services: string[], seconds: number, success : (data: PeripheralData) => any, failure? : (error: string) => any): void; - startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any): void; - startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure: () => any): void; + startScan(services: string[], success: (data: PeripheralData) => any, failure?: (error: string|BLEError) => any): void; + + startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure?: (error: string) => any): void; stopScan(): void; - stopScan(success: () => any): void; - stopScan(success: () => any, failure: () => any): void; - - connect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: () => any): void; + stopScan(success: () => any, failure?: () => any): void; - disconnect(device_id:string): void; - disconnect(device_id:string, success: () => any): void; - disconnect(device_id:string, success: () => any, failure: () => any): void; + connect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: (error: string|BLEError) => any): void; - read(device_id: string, service_uuid:string, characteristic_uuid:string): void; - read(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any): void; - read(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure: () => any): void; + /* Automatically connect to a device when it is in range of the phone + [iOS] background notifications on ios must be enabled if you want to run in the background + [Android] this relies on the autoConnect argument of BluetoothDevice.connectGatt(). Not all Android devices implement this feature correctly. */ + autoConnect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: (error: string|BLEError) => any): void; - write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer): void; - write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any): void; - write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any, failure: () => any): void; + disconnect(device_id:string, success?: () => any, failure?: (error: string|BLEError) => any): void; - /* Writes data to a characteristic without a response from the peripheral. You are not notified if the write fails in the BLE stack. + read(device_id: string, service_uuid:string, characteristic_uuid:string, success?: (rawData: ArrayBuffer) => any, failure?: (error: string|BLEError) => any): void; + + write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success?: () => any, failure?: (error: string|BLEError) => any): void; + + /* Writes data to a characteristic without a response from the peripheral. You are not notified if the write fails in the BLE stack. The success callback is be called when the characteristic is written.*/ - writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer): void; - writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any): void; - writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any, failure: () => any): void; + writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success?: () => any, failure?: (error: string) => any): void; /* Register to be notified when the value of a characteristic changes. */ - startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any): void; - startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure: () => any): void; - - stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string): void; - stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: () => any): void; - stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: () => any, failure: () => any): void; + startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure?: (error: string|BLEError) => any): void; + + stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success?: () => any, failure?: (error: string|BLEError) => any): void; /* Reports if bluetooth is enabled. */ - isEnabled(success: () => any , failure: () => any): void; + isEnabled(success: () => any , failure: (error: string) => any): void; /* Calls the success callback when the peripheral is connected and the failure callback when not connected. */ - isConnected(device_id: string, success: () => any): void; - isConnected(device_id: string, success: () => any, failure: () => any): void; + isConnected(device_id: string, success: () => any, failure?: (error: string) => any): void; - startStateNotifications(success: (state: string) => any): void; - startStateNotifications(success: (state: string) => any, failure: () => any): void; + /* May be used to request (on Android) a larger MTU size to be able to send more data at once + [iOS] requestMtu is not supported on iOS. */ + requestMtu(device_id: string, mtu: number, success?: () => any, failure?: () => any): void; + + /* Clears cached services and characteristics info for some poorly behaved devices. Uses an undocumented API, + so it is not guaranteed to work. + [iOS] refreshDeviceCache is not supported on iOS. */ + refreshDeviceCache(device_id: string, timeout_millis: number, success?: (data: PeripheralDataExtended) => any, failure?: (error: string|BLEError) => any): void; + + startStateNotifications(success: (state: string) => any, failure?: (error: string) => any): void; + + stopStateNotifications(success?: () => any, failure?: () => any): void; - stopStateNotifications(): void; - stopStateNotifications(success: () => any): void; - stopStateNotifications(success: () => any, failure: () => any): void; - /* Opens the Bluetooth settings for the operating systems. [iOS] showBluetoothSettings is not supported on iOS. */ - showBluetoothSettings(): void; - showBluetoothSettings(success: () => any): void; showBluetoothSettings(success: () => any, failure: () => any): void; - + /* Enable Bluetooth on the device. [iOS] enable is not supported on iOS. */ - enable(success: () => any, failure: () => any): void; - + enable(success: () => any, failure: (error: string) => any): void; - readRSSI(device_id:string, success: (rssi: number) => any): void; - readRSSI(device_id:string, success: (rssi: number) => any, failure: () => any): void; + readRSSI(device_id:string, success: (rssi: number) => any, failure?: (error: string) => any): void; + + /* Find connected peripherals offering the listed service UUIDs. + This function wraps CBCentralManager.retrieveConnectedPeripheralsWithServices. + [Android] peripheralsWithIdentifiers is not supported on Android. */ + connectedPeripheralsWithServices(services: string[], success: (data: PeripheralData[]) => any, failure: () => any): void; + + /* Find known (but not necessarily connected) peripherals offering the listed service UUIDs. + This function wraps CBCentralManager.retrievePeripheralsWithIdentifiers + [Android] peripheralsWithIdentifiers is not supported on Android. */ + peripheralsWithIdentifiers(services: string[], success: (data: PeripheralData[]) => any, failure: () => any): void; + + /* Find the bonded devices. + [iOS] bondedDevices is not supported on iOS. */ + bondedDevices(success: (data: PeripheralData[]) => any, failure: () => any): void; } } -declare var ble: BLECentralPlugin.BLECentralPluginStatic; \ No newline at end of file +declare var ble: BLECentralPlugin.BLECentralPluginStatic; diff --git a/types/country-data/country-data-tests.ts b/types/country-data/country-data-tests.ts new file mode 100644 index 0000000000..850116dc63 --- /dev/null +++ b/types/country-data/country-data-tests.ts @@ -0,0 +1,14 @@ +import * as lib from 'country-data'; + +lib.callingCodes.all; // $ExpectType ReadonlyArray +lib.callingCountries.all; // $ExpectType ReadonlyArray +lib.continents.africa; // $ExpectType Continent +lib.continents.africa.countries; // $ExpectType ReadonlyArray +lib.countries.all; // $ExpectType ReadonlyArray +lib.currencies.all; // $ExpectType ReadonlyArray +lib.languages.all; // $ExpectType ReadonlyArray +lib.regions.antarctica; // $ExpectType Region +lib.regions.antarctica.countries; // $ExpectType ReadonlyArray +lib.lookup.countries(""); // $ExpectType ReadonlyArray +lib.lookup.currencies(""); // $ExpectType ReadonlyArray +lib.lookup.languages(""); // $ExpectType ReadonlyArray diff --git a/types/country-data/index.d.ts b/types/country-data/index.d.ts new file mode 100644 index 0000000000..80acbbcbba --- /dev/null +++ b/types/country-data/index.d.ts @@ -0,0 +1,103 @@ +// Type definitions for country-data 0.0 +// Project: https://github.com/OpenBookPrices/country-data +// Definitions by: Logan Dam +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Country { + readonly alpha2: string; + readonly alpha3: string; + readonly countryCallingCodes: ReadonlyArray; + readonly currencies: ReadonlyArray; + readonly emoji: string; + readonly ioc: string; + readonly languages: ReadonlyArray; + readonly name: string; + readonly status: string; +} + +export interface Currency { + readonly code: string; + readonly decimals: number; + readonly name: string; + readonly number: number; +} + +export interface Language { + readonly alpha2: string; + readonly alpha3: string; + readonly bibliographic: string; + readonly name: string; +} + +export interface Continent { + readonly name: string; + readonly regions: ReadonlyArray; + readonly countries: ReadonlyArray; +} + +export interface Region { + readonly name: string; + readonly countries: ReadonlyArray; +} + +export const countries: { + readonly all: ReadonlyArray; +}; + +export const continents: { + readonly africa: Continent; + readonly antarctica: Continent; + readonly asia: Continent; + readonly europe: Continent; + readonly northAmerica: Continent; + readonly oceania: Continent; + readonly southAmerica: Continent; +}; + +export const callingCodes: { + readonly all: ReadonlyArray; +}; + +export const callingCountries: { + readonly all: ReadonlyArray; +}; + +export const currencies: { + readonly all: ReadonlyArray; +}; + +export const languages: { + readonly all: ReadonlyArray; +}; + +export const regions: { + readonly centralAsia: Region; + readonly southernAsia: Region; + readonly southeastAsia: Region; + readonly eastAsia: Region; + readonly westernAsia: Region; + readonly centralAfrica: Region; + readonly northAfrica: Region; + readonly southernAfrica: Region; + readonly eastAfrica: Region; + readonly westAfrica: Region; + readonly centralAmerica: Region; + readonly northernAmerica: Region; + readonly caribbean: Region; + readonly southAmerica: Region; + readonly antarctica: Region; + readonly northernEurope: Region; + readonly southernEurope: Region; + readonly easternEurope: Region; + readonly westernEurope: Region; + readonly australia: Region; + readonly melanesia: Region; + readonly micronesia: Region; + readonly polynesia: Region; +}; + +export const lookup: { + readonly countries: (query: any) => ReadonlyArray; + readonly currencies: (query: any) => ReadonlyArray; + readonly languages: (query: any) => ReadonlyArray; +}; diff --git a/types/country-data/tsconfig.json b/types/country-data/tsconfig.json new file mode 100644 index 0000000000..ccbbf6ecd6 --- /dev/null +++ b/types/country-data/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", + "country-data-tests.ts" + ] +} diff --git a/types/country-data/tslint.json b/types/country-data/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/country-data/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 0a3c482505..8f54ee4f5c 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -5,6 +5,11 @@ function add10(n: number) { CustomFunctions.associate('ADD10', add10); +CustomFunctions.associate({ + ADD10: add10, + RANDOM: (n: number) => n * Math.random() +}); + async function getStockValues(ticker: string): Promise { const response = await fetch(`myService.com/prices/${ticker}`); return (await response.json())["price"]; diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index f78f6a45c4..174308c131 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -16,9 +16,14 @@ Copyright (c) Microsoft Corporation declare namespace CustomFunctions { /** * @beta - * Ties together the function's JavaScript name with the JSON id property + * Associates the JavaScript function to the name given by the "id" property in the metadata JSON file. */ function associate(id: string, functionObject: Function): void; + /** + * @beta + * Associates the JavaScript functions to the names given by the "id" properties in the metadata JSON file. + */ + function associate(mappings: { [key: string]: Function }): void; /** * A handler passed automatically as the last parameter @@ -28,7 +33,6 @@ declare namespace CustomFunctions { * to handle what happens when the function stops streaming. * @beta */ - interface StreamingHandler extends CancelableHandler { /** * Sets the returned result for a streaming custom function. @@ -36,6 +40,7 @@ declare namespace CustomFunctions { */ setResult: (value: T | Error) => void; } + /** * @beta * CancelableHandler interface diff --git a/types/d3-geo/d3-geo-tests.ts b/types/d3-geo/d3-geo-tests.ts index 6e824e8e69..36c4debbe3 100644 --- a/types/d3-geo/d3-geo-tests.ts +++ b/types/d3-geo/d3-geo-tests.ts @@ -371,6 +371,7 @@ const gnomonicRaw: d3Geo.GeoRawProjection = d3Geo.geoGnomonicRaw(); const mercatorRaw: d3Geo.GeoRawProjection = d3Geo.geoMercatorRaw(); const orthographicRaw: d3Geo.GeoRawProjection = d3Geo.geoOrthographicRaw(); const stereographicRaw: d3Geo.GeoRawProjection = d3Geo.geoStereographicRaw(); +const equalEarthRaw: d3Geo.GeoRawProjection = d3Geo.geoEqualEarthRaw(); const transverseMercatorRaw: d3Geo.GeoRawProjection = d3Geo.geoTransverseMercatorRaw(); const naturalEarth1Raw: d3Geo.GeoRawProjection = d3Geo.geoNaturalEarth1Raw(); @@ -398,6 +399,7 @@ const gnomonic: d3Geo.GeoProjection = d3Geo.geoGnomonic(); const mercator: d3Geo.GeoProjection = d3Geo.geoMercator(); const orthographic: d3Geo.GeoProjection = d3Geo.geoOrthographic(); const stereographic: d3Geo.GeoProjection = d3Geo.geoStereographic(); +const equalEarth: d3Geo.GeoProjection = d3Geo.geoEqualEarth(); const transverseMercator: d3Geo.GeoProjection = d3Geo.geoTransverseMercator(); const naturalEarth1: d3Geo.GeoProjection = d3Geo.geoNaturalEarth1(); diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index 8f22503d71..16c51dfae6 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -1,10 +1,10 @@ -// Type definitions for D3JS d3-geo module 1.10 +// Type definitions for D3JS d3-geo module 1.11 // Project: https://github.com/d3/d3-geo/ // Definitions by: Hugues Stefanski , Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// Last module patch version validated against: 1.10.0 +// Last module patch version validated against: 1.11.3 import * as GeoJSON from 'geojson'; @@ -1345,11 +1345,22 @@ export function geoOrthographicRaw(): GeoRawProjection; * The stereographic projection. */ export function geoStereographic(): GeoProjection; + /** * The raw stereographic projection. */ export function geoStereographicRaw(): GeoRawProjection; +/** + * The Equal Eartch projection, by Bojan Šavrič et al., 2018. + */ +export function geoEqualEarth(): GeoProjection; + +/** + * The raw Equal Earth projection, by Bojan Šavrič et al., 2018. + */ +export function geoEqualEarthRaw(): GeoRawProjection; + // Composite Projections --------------------------------------------------- /** diff --git a/types/d3/index.d.ts b/types/d3/index.d.ts index 43c264f280..9b62c1e025 100644 --- a/types/d3/index.d.ts +++ b/types/d3/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for D3JS d3 standard bundle 5.5 +// Type definitions for D3JS d3 standard bundle 5.7 // Project: https://github.com/d3/d3 // Definitions by: Tom Wanzek // Alex Ford @@ -7,7 +7,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// Last module patch version validated against: 5.5.0 +// Last module patch version validated against: 5.7.0 // NOTE TO MAINTAINERS: Review D3 v4.x module dependencies (see v4 sub-folder) and update its path-mappings in tsconfig (v4 folder), // if new MAJOR version of D3 v4 modules are released!!! diff --git a/types/debounce-fn/debounce-fn-tests.ts b/types/debounce-fn/debounce-fn-tests.ts new file mode 100644 index 0000000000..9f9d3881e9 --- /dev/null +++ b/types/debounce-fn/debounce-fn-tests.ts @@ -0,0 +1,10 @@ +import debounceFn = require('debounce-fn'); + +const debounced = debounceFn((s: string) => true); +debounced; // $ExpectType ((s: string) => boolean | undefined) & { cancel(): void; } + +debounceFn((s: string) => true); +debounceFn((s: string) => true, { wait: 100 }); +debounceFn((s: string) => true, { immediate: true }); + +debounced.cancel(); diff --git a/types/debounce-fn/index.d.ts b/types/debounce-fn/index.d.ts new file mode 100644 index 0000000000..01e147a14a --- /dev/null +++ b/types/debounce-fn/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for debounce-fn 1.0 +// Project: https://github.com/sindresorhus/debounce-fn#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +export = debounce; + +/** + * Returns a debounced function that delays calling the `input` function until after `wait` milliseconds + * have elapsed since the last time the debounced function was called. + * + * It comes with a `.cancel()` method to cancel any scheduled `input` function calls. + */ +declare function debounce( + input: (...args: TArgs) => TResult, + options?: debounce.Options +): ((...args: TArgs) => TResult | undefined) & { cancel(): void }; + +declare namespace debounce { + interface Options { + /** + * Time to wait until the `input` function is called. + * @default 0 + */ + wait?: number; + /** + * Trigger the function on the leading edge instead of the trailing edge of the `wait` interval. + * For example, can be useful for preventing accidental double-clicks on a "submit" button + * from firing a second time. + */ + immediate?: boolean; + } +} diff --git a/types/debounce-fn/tsconfig.json b/types/debounce-fn/tsconfig.json new file mode 100644 index 0000000000..f2d90018fb --- /dev/null +++ b/types/debounce-fn/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", + "debounce-fn-tests.ts" + ] +} diff --git a/types/debounce-fn/tslint.json b/types/debounce-fn/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/debounce-fn/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/doge-seed/doge-seed-tests.ts b/types/doge-seed/doge-seed-tests.ts new file mode 100644 index 0000000000..fa47414d65 --- /dev/null +++ b/types/doge-seed/doge-seed-tests.ts @@ -0,0 +1,4 @@ +import dogeSeed = require('doge-seed'); + +dogeSeed(); // $ExpectType string +dogeSeed(128); // $ExpectType string diff --git a/types/doge-seed/index.d.ts b/types/doge-seed/index.d.ts new file mode 100644 index 0000000000..8670f36332 --- /dev/null +++ b/types/doge-seed/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for doge-seed 1.0 +// Project: https://github.com/lukechilds/doge-seed#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = dogeSeed; + +/** + * Generates a cryptographically secure mnemonic seed phrase with added dankness. + * The first four words will be a randomly generated Doge-like sentence. + * + * The seed phrases are fully valid checksummed BIP39 seeds. They can be used with any cryptocurrency + * and can be imported into any BIP39 compliant wallet. + * + * @param bits The number of bits to derive a BIP39 mnemonic from. Default: `128`. + * @returns A BIP39 mnemonic seed phrase. + */ +declare function dogeSeed(bits?: 128 | 160 | 192 | 224 | 256): string; diff --git a/types/doge-seed/tsconfig.json b/types/doge-seed/tsconfig.json new file mode 100644 index 0000000000..cd46d1ee9c --- /dev/null +++ b/types/doge-seed/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", + "doge-seed-tests.ts" + ] +} diff --git a/types/doge-seed/tslint.json b/types/doge-seed/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/doge-seed/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/execall/execall-tests.ts b/types/execall/execall-tests.ts new file mode 100644 index 0000000000..8a9d3b7768 --- /dev/null +++ b/types/execall/execall-tests.ts @@ -0,0 +1,3 @@ +import execall = require('execall'); + +execall(/(\d+)/g, '$200 and $400'); // $ExpectType Match[] diff --git a/types/execall/index.d.ts b/types/execall/index.d.ts new file mode 100644 index 0000000000..29e7d3945e --- /dev/null +++ b/types/execall/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for execall 1.0 +// Project: https://github.com/sindresorhus/execall +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = execall; + +/** + * Find multiple RegExp matches in a string. Instead of having to iterate over + * `RegExp#exec`, immutable, and with a nicer result format. + * + * @param re Regular expression to match against the `input`. + * @returns An array of matches. + */ +declare function execall(re: RegExp, input: string): execall.Match[]; + +declare namespace execall { + interface Match { + match: string; + sub: string[]; + index: number; + } +} diff --git a/types/execall/tsconfig.json b/types/execall/tsconfig.json new file mode 100644 index 0000000000..70a42a9a18 --- /dev/null +++ b/types/execall/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", + "execall-tests.ts" + ] +} diff --git a/types/execall/tslint.json b/types/execall/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/execall/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/exif/exif-tests.ts b/types/exif/exif-tests.ts new file mode 100644 index 0000000000..57d29fc80b --- /dev/null +++ b/types/exif/exif-tests.ts @@ -0,0 +1,18 @@ +import Exif = require('exif'); +const ExifImage = Exif.ExifImage; + +new ExifImage({ image: 'myImage.jpg' }, (error, exifData) => { + if (error) { + console.log(`Error: ${error.message}`); + } else { + console.log(exifData); + } +}); + +Exif('myImage.jpg', (error, exifData, dataPath) => { + if (error) { + console.log(`Error: ${error.message}`); + } else { + console.log(exifData, dataPath); + } +}); diff --git a/types/exif/index.d.ts b/types/exif/index.d.ts new file mode 100644 index 0000000000..78a1859517 --- /dev/null +++ b/types/exif/index.d.ts @@ -0,0 +1,143 @@ +// Type definitions for exif 0.6 +// Project: https://github.com/gomfunkel/node-exif#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Exif { + interface ExifData { + image: { + Copyright?: string; + ExifOffset?: number; + ImageHeight?: number; + ImageWidth?: number; + Make?: string; + Model?: string; + ModifyDate?: string; + Orientation?: number; + ResolutionUnit?: number; + Software?: string; + XResolution?: number; + YCbCrPositioning?: number; + YResolution?: number; + }; + thumbnail: { + Compression?: number; + Orientation?: number; + ResolutionUnit?: number; + ThumbnailLength?: number; + ThumbnailOffset?: number; + XResolution?: number; + YCbCrPositioning?: number; + YResolution?: number; + }; + exif: { + ApertureValue?: number; + BrightnessValue?: number; + ColorSpace?: number; + ComponentsConfiguration?: Buffer; + CompressedBitsPerPixel?: number; + CreateDate?: string; + DateTimeOriginal?: string; + ExifImageHeight?: number; + ExifImageWidth?: number; + ExifVersion?: Buffer; + ExposureCompensation?: number; + ExposureMode?: number; + ExposureProgram?: number; + ExposureTime?: number; + FileSource?: Buffer; + Flash?: number; + FlashpixVersion?: Buffer; + FNumber?: number; + FocalLength?: number; + FocalLengthIn35mmFormat?: number; + FocalPlaneResolutionUnit?: number; + FocalPlaneXResolution?: number; + FocalPlaneYResolution?: number; + ImageUniqueID?: string; + InteropOffset?: number; + ISO?: number; + MakerNote?: Buffer; + MaxApertureValue?: number; + MeteringMode?: number; + SceneCaptureType?: number; + SceneType?: Buffer; + SensingMethod?: number; + ShutterSpeedValue?: number; + UserComment?: Buffer; + WhiteBalance?: number; + }; + gps: { + GPSAltitude?: number; + GPSAltitudeRef?: number; + GPSDateStamp?: string; + GPSLatitude?: number[]; + GPSLatitudeRef?: string; + GPSLongitude?: number[]; + GPSLongitudeRef?: string; + GPSTimeStamp?: number[]; + GPSVersionId?: number[]; + }; + interoperability: { + InteropIndex?: string; + InteropVersion?: Buffer; + }; + makernote: { + AutoBracketing?: number; + BlurWarning?: number; + ExposureWarning?: number; + error?: string; + FlashExposureComp?: number; + FocusMode?: number; + FocusWarning?: number; + FujiFlashMode?: number; + Macro?: number; + Quality?: string; + Sharpness?: number; + SlowSync?: number; + Version?: Buffer; + WhiteBalance?: number; + }; + } + + interface ExifOptions { + agfaMaxEntries?: number; + epsonMaxEntries?: number; + /** node-exif corrects the thumbnail offset in order to have an offset from the start of the buffer/file. */ + fixThumbnailOffset?: boolean; + fujifilmMaxEntries?: number; + ifd0MaxEntries?: number; + ifd1MaxEntries?: number; + /** + * The image to get Exif data from can be either a filesystem path or a Buffer. + * + * If `image` is not specified, the developer must call `loadImage()` to parse the image. + */ + image?: string | Buffer; + /** Specifies the maximum entries to be parsed */ + maxEntries?: number; + maxGpsEntries?: number; + maxInteroperabilityEntries?: number; + noPadding?: boolean; + olympusMaxEntries?: number; + panasonicMaxEntries?: number; + sanyoMaxEntries?: number; + /** An object named "offsets" is added to exifData and contains lot of offsets needed to get thumbnail and other things. */ + tiffOffsets?: number; + } + + type ExifImageCallback = (error: Error | null, data: ExifData) => void; + type ExifCallback = (error: Error | null, data: ExifData, dataPath: string) => void; + + class ExifImage { + constructor(options: ExifOptions | string | Buffer, callback: ExifImageCallback); + constructor(); + loadImage(file: string | Buffer, callback: ExifImageCallback): void; + } +} + +declare function Exif(path: string, callback: Exif.ExifCallback): void; + +export = Exif; diff --git a/types/exif/tsconfig.json b/types/exif/tsconfig.json new file mode 100644 index 0000000000..4c0c12d69a --- /dev/null +++ b/types/exif/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", + "exif-tests.ts" + ] +} diff --git a/types/exif/tslint.json b/types/exif/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/exif/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/first-run/first-run-tests.ts b/types/first-run/first-run-tests.ts new file mode 100644 index 0000000000..5451c7c88c --- /dev/null +++ b/types/first-run/first-run-tests.ts @@ -0,0 +1,6 @@ +import firstRun = require('first-run'); + +firstRun(); // $ExpectType boolean +firstRun({ name: 'foo' }); // $ExpectType boolean + +firstRun.clear(); diff --git a/types/first-run/index.d.ts b/types/first-run/index.d.ts new file mode 100644 index 0000000000..dc92053d03 --- /dev/null +++ b/types/first-run/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for first-run 1.2 +// Project: https://github.com/sindresorhus/first-run +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = firstRun; + +/** + * Check if it's the first time the process is run. + */ +declare function firstRun(options?: firstRun.Options): boolean; + +declare namespace firstRun { + /** + * Clear the state. + */ + function clear(): void; + + interface Options { + /** + * The name used to identify it. + * @default name field in your package.json + */ + name: string; + } +} diff --git a/types/first-run/tsconfig.json b/types/first-run/tsconfig.json new file mode 100644 index 0000000000..6a4ce007ab --- /dev/null +++ b/types/first-run/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", + "first-run-tests.ts" + ] +} diff --git a/types/first-run/tslint.json b/types/first-run/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/first-run/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/geojson/geojson-tests.ts b/types/geojson/geojson-tests.ts index 4ea0f57a6f..82787c8c36 100644 --- a/types/geojson/geojson-tests.ts +++ b/types/geojson/geojson-tests.ts @@ -1,10 +1,10 @@ import { - BBox, Feature, FeatureCollection, GeometryCollection, LineString, - MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, GeometryObject + MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, GeoJsonGeometryTypes, + GeoJsonTypes, GeometryObject } from "geojson"; -let featureCollection: FeatureCollection = { +let featureCollection: FeatureCollection = { type: "FeatureCollection", features: [ { @@ -53,6 +53,17 @@ let featureCollection: FeatureCollection = { type: "Feature", bbox: [-180.0, -90.0, 180.0, 90.0], @@ -65,6 +76,11 @@ const featureWithPolygon: Feature = { properties: null }; +featureWithPolygon.type; // $ExpectType "Feature" +featureWithPolygon.geometry; // $ExpectType Polygon +featureWithPolygon.geometry.type; // $ExpectType "Polygon" +featureWithPolygon.geometry.coordinates; // $ExpectType number[][][] + const point: Point = { type: "Point", coordinates: [100.0, 0.0] @@ -135,6 +151,8 @@ let feature: Feature = { properties: null }; +feature.properties; // $ExpectType GeoJsonProperties + feature = { type: "Feature", geometry: polygon, @@ -275,12 +293,16 @@ const featureGeometryNull: Feature = { geometry: null }; +featureGeometryNull.properties.foo; // $ExpectType "bar" | "baz" + const featureNoNull: Feature = { type: "Feature", properties: testProps, geometry: point }; +featureNoNull.geometry.type; // $ExpectType "Point" + const collectionAllNull: FeatureCollection = { type: "FeatureCollection", features: [featureAllNull], @@ -301,6 +323,8 @@ const collectionGeometryMaybeNull: FeatureCollection features: [featureGeometryNull, featureNoNull], }; +collectionGeometryMaybeNull.features[0].geometry; // $ExpectType Point | null + const collectionNoNull: FeatureCollection = { type: "FeatureCollection", features: [featureNoNull], @@ -311,6 +335,9 @@ const collectionDefault: FeatureCollection = { features: [] }; +collectionDefault.features[0].geometry; // $ExpectType Geometry +collectionDefault.features[0].properties!.foo; // $ExpectType any + isNull = featureAllNull.geometry; isPoint = featurePropertyNull.geometry; isNull = featureAllNull.properties; diff --git a/types/geojson/index.d.ts b/types/geojson/index.d.ts index 93f66d3f27..db8074e242 100644 --- a/types/geojson/index.d.ts +++ b/types/geojson/index.d.ts @@ -4,6 +4,7 @@ // Arne Schubert // Jeff Jacobson // Ilia Choly +// Dan Vanderkam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -16,14 +17,13 @@ export as namespace GeoJSON; * The valid values for the "type" property of GeoJSON geometry objects. * https://tools.ietf.org/html/rfc7946#section-1.4 */ -export type GeoJsonGeometryTypes = "Point" | "LineString" | "MultiPoint" | "Polygon" | "MultiLineString" | - "MultiPolygon" | "GeometryCollection"; +export type GeoJsonGeometryTypes = Geometry['type']; /** * The value values for the "type" property of GeoJSON Objects. * https://tools.ietf.org/html/rfc7946#section-1.4 */ -export type GeoJsonTypes = "FeatureCollection" | "Feature" | GeoJsonGeometryTypes; +export type GeoJsonTypes = GeoJSON['type']; /** * Bounding box @@ -58,6 +58,10 @@ export interface GeoJsonObject { type: GeoJsonTypes; /** * Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. + * The value of the bbox member is an array of length 2*n where n is the number of dimensions + * represented in the contained geometries, with all axes of the most southwesterly point + * followed by all axes of the more northeasterly point. + * The axes order of a bbox follows the axes order of geometries. * https://tools.ietf.org/html/rfc7946#section-5 */ bbox?: BBox; @@ -69,24 +73,17 @@ export interface GeoJsonObject { export type GeoJSON = Geometry | Feature | FeatureCollection; /** - * A geometry object. - * https://tools.ietf.org/html/rfc7946#section-3 - */ -export interface GeometryObject extends GeoJsonObject { - type: GeoJsonGeometryTypes; -} - -/** - * Union of geometry objects. + * Geometry object. * https://tools.ietf.org/html/rfc7946#section-3 */ export type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon | GeometryCollection; +export type GeometryObject = Geometry; /** * Point geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.2 */ -export interface Point extends GeometryObject { +export interface Point extends GeoJsonObject { type: "Point"; coordinates: Position; } @@ -95,7 +92,7 @@ export interface Point extends GeometryObject { * MultiPoint geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.3 */ -export interface MultiPoint extends GeometryObject { +export interface MultiPoint extends GeoJsonObject { type: "MultiPoint"; coordinates: Position[]; } @@ -104,7 +101,7 @@ export interface MultiPoint extends GeometryObject { * LineString geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.4 */ -export interface LineString extends GeometryObject { +export interface LineString extends GeoJsonObject { type: "LineString"; coordinates: Position[]; } @@ -113,7 +110,7 @@ export interface LineString extends GeometryObject { * MultiLineString geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.5 */ -export interface MultiLineString extends GeometryObject { +export interface MultiLineString extends GeoJsonObject { type: "MultiLineString"; coordinates: Position[][]; } @@ -122,7 +119,7 @@ export interface MultiLineString extends GeometryObject { * Polygon geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.6 */ -export interface Polygon extends GeometryObject { +export interface Polygon extends GeoJsonObject { type: "Polygon"; coordinates: Position[][]; } @@ -131,7 +128,7 @@ export interface Polygon extends GeometryObject { * MultiPolygon geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.7 */ -export interface MultiPolygon extends GeometryObject { +export interface MultiPolygon extends GeoJsonObject { type: "MultiPolygon"; coordinates: Position[][][]; } @@ -140,7 +137,7 @@ export interface MultiPolygon extends GeometryObject { * Geometry Collection * https://tools.ietf.org/html/rfc7946#section-3.1.8 */ -export interface GeometryCollection extends GeometryObject { +export interface GeometryCollection extends GeoJsonObject { type: "GeometryCollection"; geometries: Geometry[]; } @@ -151,7 +148,7 @@ export type GeoJsonProperties = { [name: string]: any; } | null; * A feature object which contains a geometry and associated properties. * https://tools.ietf.org/html/rfc7946#section-3.2 */ -export interface Feature extends GeoJsonObject { +export interface Feature extends GeoJsonObject { type: "Feature"; /** * The feature's geometry @@ -172,7 +169,7 @@ export interface Feature extends GeoJsonObject { +export interface FeatureCollection extends GeoJsonObject { type: "FeatureCollection"; features: Array>; } diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 1df7c85690..97c16f305c 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -342,15 +342,15 @@ export interface GraphQLScalarTypeConfig { * }); * */ -export class GraphQLObjectType { +export class GraphQLObjectType { name: string; description: Maybe; astNode: Maybe; extensionASTNodes: Maybe>; - isTypeOf: Maybe>; + isTypeOf: Maybe>; - constructor(config: GraphQLObjectTypeConfig); - getFields(): GraphQLFieldMap; + constructor(config: GraphQLObjectTypeConfig); + getFields(): GraphQLFieldMap; getInterfaces(): GraphQLInterfaceType[]; toString(): string; toJSON(): string; @@ -371,7 +371,7 @@ export type GraphQLTypeResolver = ( value: TSource, context: TContext, info: GraphQLResolveInfo -) => MaybePromise>; +) => MaybePromise | string>>; export type GraphQLIsTypeOfFn = ( source: TSource, diff --git a/types/hex-rgb/hex-rgb-tests.ts b/types/hex-rgb/hex-rgb-tests.ts new file mode 100644 index 0000000000..f9bbf5ea71 --- /dev/null +++ b/types/hex-rgb/hex-rgb-tests.ts @@ -0,0 +1,4 @@ +import hexRgb = require('hex-rgb'); + +hexRgb('#cd2222cc'); // $ExpectType RgbaObj +hexRgb('#cd2222cc', { format: 'array' }); // $ExpectType [number, number, number, number] diff --git a/types/hex-rgb/index.d.ts b/types/hex-rgb/index.d.ts new file mode 100644 index 0000000000..ab1de9bf24 --- /dev/null +++ b/types/hex-rgb/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for hex-rgb 3.0 +// Project: https://github.com/sindresorhus/hex-rgb#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = hexRgb; + +declare function hexRgb(hex: string): hexRgb.RgbaObj; +declare function hexRgb(hex: string, options: hexRgb.Options): hexRgb.RgbaArr; + +declare namespace hexRgb { + interface Options { + format: 'array'; + } + + interface RgbaObj { + red: number; + green: number; + blue: number; + alpha: number; + } + + type RgbaArr = [number, number, number, number]; +} diff --git a/types/hex-rgb/tsconfig.json b/types/hex-rgb/tsconfig.json new file mode 100644 index 0000000000..c20c71b94f --- /dev/null +++ b/types/hex-rgb/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", + "hex-rgb-tests.ts" + ] +} diff --git a/types/hex-rgb/tslint.json b/types/hex-rgb/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hex-rgb/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/html-tags/html-tags-tests.ts b/types/html-tags/html-tags-tests.ts new file mode 100644 index 0000000000..802dbb665e --- /dev/null +++ b/types/html-tags/html-tags-tests.ts @@ -0,0 +1,9 @@ +import htmlTags = require('html-tags'); +import voidHtmlTags = require('html-tags/void'); +import htmlTagsJson = require('html-tags/html-tags.json'); +import voidHtmlTagsJson = require('html-tags/html-tags-void.json'); + +htmlTags; // $ExpectType string[] +voidHtmlTags; // $ExpectType string[] +htmlTagsJson; // $ExpectType string[] +voidHtmlTagsJson; // $ExpectType string[] diff --git a/types/html-tags/html-tags-void.json.d.ts b/types/html-tags/html-tags-void.json.d.ts new file mode 100644 index 0000000000..3e194ddf27 --- /dev/null +++ b/types/html-tags/html-tags-void.json.d.ts @@ -0,0 +1,3 @@ +export = voidHtmlTags; + +declare const voidHtmlTags: string[]; diff --git a/types/html-tags/html-tags.json.d.ts b/types/html-tags/html-tags.json.d.ts new file mode 100644 index 0000000000..888779dc9c --- /dev/null +++ b/types/html-tags/html-tags.json.d.ts @@ -0,0 +1,3 @@ +export = htmlTags; + +declare const htmlTags: string[]; diff --git a/types/html-tags/index.d.ts b/types/html-tags/index.d.ts new file mode 100644 index 0000000000..635ce4820f --- /dev/null +++ b/types/html-tags/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for html-tags 2.0 +// Project: https://github.com/sindresorhus/html-tags#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = htmlTags; + +declare const htmlTags: string[]; diff --git a/types/html-tags/tsconfig.json b/types/html-tags/tsconfig.json new file mode 100644 index 0000000000..971c9bb630 --- /dev/null +++ b/types/html-tags/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 + }, + "files": [ + "index.d.ts", + "void.d.ts", + "html-tags.json.d.ts", + "html-tags-void.json.d.ts", + "html-tags-tests.ts" + ] +} diff --git a/types/html-tags/tslint.json b/types/html-tags/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/html-tags/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/html-tags/void.d.ts b/types/html-tags/void.d.ts new file mode 100644 index 0000000000..3e194ddf27 --- /dev/null +++ b/types/html-tags/void.d.ts @@ -0,0 +1,3 @@ +export = voidHtmlTags; + +declare const voidHtmlTags: string[]; diff --git a/types/http-proxy-middleware/http-proxy-middleware-tests.ts b/types/http-proxy-middleware/http-proxy-middleware-tests.ts index aae082a956..9967dedcd9 100644 --- a/types/http-proxy-middleware/http-proxy-middleware-tests.ts +++ b/types/http-proxy-middleware/http-proxy-middleware-tests.ts @@ -140,3 +140,6 @@ proxy({ proxy({ headers: {host: 'www.example.org'} }); + +// Shorthands +proxy('/'); diff --git a/types/http-proxy-middleware/index.d.ts b/types/http-proxy-middleware/index.d.ts index 09b80e21c4..13f2669e5f 100644 --- a/types/http-proxy-middleware/index.d.ts +++ b/types/http-proxy-middleware/index.d.ts @@ -15,7 +15,7 @@ import * as httpProxy from "http-proxy"; import { Readable } from 'stream'; declare function proxy(config: proxy.Config): proxy.Proxy; -declare function proxy(contextOrUri: string | string[] | proxy.Filter, config: proxy.Config): proxy.Proxy; +declare function proxy(contextOrUri: string | string[] | proxy.Filter, config?: proxy.Config): proxy.Proxy; declare namespace proxy { type Filter = (pathname: string, req: http.IncomingMessage) => boolean; diff --git a/types/http-rx/http-rx-tests.ts b/types/http-rx/http-rx-tests.ts index 082585fdf9..b76ba67832 100644 --- a/types/http-rx/http-rx-tests.ts +++ b/types/http-rx/http-rx-tests.ts @@ -1,13 +1,14 @@ import { Observable } from 'rxjs'; import httpRx = require('http-rx'); +import request = require('request'); -const httpGet: Observable = httpRx.get(''); +const httpGet: Observable<{response: request.Response}> = httpRx.get(''); -const httpHead: Observable = httpRx.head(''); +const httpHead: Observable<{body: any}> = httpRx.head(''); -const httpPatch: Observable = httpRx.patch(''); +const httpPatch: Observable<{response: request.Response, body: any}> = httpRx.patch(''); -const httpPost: Observable = httpRx.post(''); +const httpPost: Observable<{response: request.Response, body: any}> = httpRx.post('', {json: true}); const httpPut: Observable<{}> = httpRx.put(''); diff --git a/types/http-rx/index.d.ts b/types/http-rx/index.d.ts index 3b0c734fb0..c752427b8a 100644 --- a/types/http-rx/index.d.ts +++ b/types/http-rx/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for http-rx 1.1 +// Type definitions for http-rx 2.0 // Project: https://github.com/JasonRammoray/HttpRx // Definitions by: L2jLiga // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,18 +7,23 @@ import { Observable } from 'rxjs'; import request = require('request'); +interface ResponseWrapper { + response: request.Response; + body: any; +} + interface HttpRx { - get(url: string, options?: request.CoreOptions): Observable; + get(url: string, options?: request.CoreOptions): Observable; - head(url: string, options?: request.CoreOptions): Observable; + head(url: string, options?: request.CoreOptions): Observable; - patch(url: string, options?: request.CoreOptions): Observable; + patch(url: string, options?: request.CoreOptions): Observable; - post(url: string, options?: request.CoreOptions): Observable; + post(url: string, options?: request.CoreOptions): Observable; - put(url: string, options?: request.CoreOptions): Observable; + put(url: string, options?: request.CoreOptions): Observable; - 'delete'(url: string, options?: request.CoreOptions): Observable; + delete(url: string, options?: request.CoreOptions): Observable; } declare const httpRx: HttpRx; diff --git a/types/is-elevated/index.d.ts b/types/is-elevated/index.d.ts new file mode 100644 index 0000000000..c875437fde --- /dev/null +++ b/types/is-elevated/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for is-elevated 2.0 +// Project: https://github.com/sindresorhus/is-elevated#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = isElevated; + +declare function isElevated(): Promise; diff --git a/types/is-elevated/is-elevated-tests.ts b/types/is-elevated/is-elevated-tests.ts new file mode 100644 index 0000000000..b2ba2f48fe --- /dev/null +++ b/types/is-elevated/is-elevated-tests.ts @@ -0,0 +1,3 @@ +import isElevated = require('is-elevated'); + +isElevated(); // $ExpectType Promise diff --git a/types/is-elevated/tsconfig.json b/types/is-elevated/tsconfig.json new file mode 100644 index 0000000000..ad48a57318 --- /dev/null +++ b/types/is-elevated/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", + "is-elevated-tests.ts" + ] +} diff --git a/types/is-elevated/tslint.json b/types/is-elevated/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-elevated/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/is-online/index.d.ts b/types/is-online/index.d.ts new file mode 100644 index 0000000000..04fa123c44 --- /dev/null +++ b/types/is-online/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for is-online 8.0 +// Project: https://github.com/sindresorhus/is-online#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = isOnline; + +/** + * Check if the internet connection is up. + * + * The following checks are run in parallel: + * - Retrieve [icanhazip.com](https://github.com/major/icanhaz) via HTTPS + * - Query `myip.opendns.com` on OpenDNS (Node.js only) + * - Retrieve Apple's Captive Portal test page (Node.js only) + * + * When the first check succeeds, the returned Promise is resolved to `true`. + */ +declare function isOnline(options?: isOnline.Options): Promise; + +declare namespace isOnline { + interface Options { + /** + * Milliseconds to wait for a server to respond. + * @default 5000 + */ + timeout?: number; + /** + * Internet Protocol version to use. This is an advanced option that is usually not necessary to be set, + * but it can prove useful to specifically assert IPv6 connectivity. + * @default 'v4' + */ + version?: 'v4' | 'v6'; + } +} diff --git a/types/is-online/is-online-tests.ts b/types/is-online/is-online-tests.ts new file mode 100644 index 0000000000..74dbda5efa --- /dev/null +++ b/types/is-online/is-online-tests.ts @@ -0,0 +1,6 @@ +import isOnline = require('is-online'); + +isOnline(); // $ExpectType Promise +isOnline({ timeout: 10 }); // $ExpectType Promise +isOnline({ version: 'v4' }); // $ExpectType Promise +isOnline({ version: 'v6' }); // $ExpectType Promise diff --git a/types/is-online/tsconfig.json b/types/is-online/tsconfig.json new file mode 100644 index 0000000000..7009c26024 --- /dev/null +++ b/types/is-online/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", + "is-online-tests.ts" + ] +} diff --git a/types/is-online/tslint.json b/types/is-online/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-online/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/is-reachable/index.d.ts b/types/is-reachable/index.d.ts new file mode 100644 index 0000000000..6e2ea2d62f --- /dev/null +++ b/types/is-reachable/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for is-reachable 3.0 +// Project: https://github.com/sindresorhus/is-reachable#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = isReachable; + +/** + * Check if servers are reachable. + * + * The Node.js version will do a TCP handshake with the target's port. It attempts to detect cases where a router + * redirects the request to itself. + * + * The browser version is limited by the fact that browsers cannot connect to arbitrary ports. It only supports + * HTTP and HTTPS and the check relies on the `/favicon.ico` path being present. + * + * @param targets One or more targets to check. Can either be a full [URL](https://nodejs.org/api/url.html) + * like `https://hostname`, `hostname:port` or just `hostname`. When the protocol is missing from a target + * `http` is assumed. + * + * [Well-known protocols](http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml) + * are supported (e.g. `ftp://`, `mysql://`, `redis://` and more). + * + * @returns A `Promise` for a `boolean` which is `true` if any of the `targets` are reachable. + */ +declare function isReachable( + targets: string | string[], + options?: isReachable.Options +): Promise; + +declare namespace isReachable { + interface Options { + /** + * Timeout in milliseconds after which a request is considered failed. + * @default 5000 + */ + timeout?: number; + } +} diff --git a/types/is-reachable/is-reachable-tests.ts b/types/is-reachable/is-reachable-tests.ts new file mode 100644 index 0000000000..d497d004f2 --- /dev/null +++ b/types/is-reachable/is-reachable-tests.ts @@ -0,0 +1,4 @@ +import isReachable = require('is-reachable'); + +isReachable('sindresorhus.com'); // $ExpectType Promise +isReachable('google.com:80', { timeout: 10 }); // $ExpectType Promise diff --git a/types/is-reachable/tsconfig.json b/types/is-reachable/tsconfig.json new file mode 100644 index 0000000000..c30236ebd5 --- /dev/null +++ b/types/is-reachable/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", + "is-reachable-tests.ts" + ] +} diff --git a/types/is-reachable/tslint.json b/types/is-reachable/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-reachable/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery/v2/index.d.ts b/types/jquery/v2/index.d.ts index 2643960e6d..068bbfc991 100644 --- a/types/jquery/v2/index.d.ts +++ b/types/jquery/v2/index.d.ts @@ -603,6 +603,14 @@ interface BaseJQueryEventObject extends Event { metaKey: boolean; } +interface JQueryCustomEventObject extends BaseJQueryEventObject { + /** + * @see {@link https://api.jquery.com/category/events/event-object/} + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent} + */ + detail?: any; +} + interface JQueryInputEventObject extends BaseJQueryEventObject { altKey: boolean; ctrlKey: boolean; @@ -632,7 +640,7 @@ interface JQueryKeyEventObject extends JQueryInputEventObject { keyCode: number; } -interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject{ +interface JQueryEventObject extends BaseJQueryEventObject, JQueryCustomEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject { } /** diff --git a/types/js-levenshtein/index.d.ts b/types/js-levenshtein/index.d.ts new file mode 100644 index 0000000000..5b29d11026 --- /dev/null +++ b/types/js-levenshtein/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for js-levenshtein 1.1 +// Project: https://github.com/gustf/js-levenshtein +// Definitions by: Kallu609 +// Pyry Rouvila +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Calculates Levenshtein distance between two strings + */ +declare function levenshtein(compareFrom: string, compareTo: string): number; + +export = levenshtein; diff --git a/types/js-levenshtein/js-levenshtein-tests.ts b/types/js-levenshtein/js-levenshtein-tests.ts new file mode 100644 index 0000000000..539473ccf4 --- /dev/null +++ b/types/js-levenshtein/js-levenshtein-tests.ts @@ -0,0 +1,3 @@ +import levenshtein = require('js-levenshtein'); + +levenshtein('kittens', 'mittens'); // $ExpectType number diff --git a/types/js-levenshtein/tsconfig.json b/types/js-levenshtein/tsconfig.json new file mode 100644 index 0000000000..6df128481b --- /dev/null +++ b/types/js-levenshtein/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "js-levenshtein-tests.ts"] +} diff --git a/types/js-levenshtein/tslint.json b/types/js-levenshtein/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/js-levenshtein/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/js-types/index.d.ts b/types/js-types/index.d.ts new file mode 100644 index 0000000000..756680fd04 --- /dev/null +++ b/types/js-types/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for js-types 2.0 +// Project: https://github.com/sindresorhus/js-types#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = jsTypes; + +declare const jsTypes: string[]; diff --git a/types/js-types/js-types-tests.ts b/types/js-types/js-types-tests.ts new file mode 100644 index 0000000000..b7e5a4fe8b --- /dev/null +++ b/types/js-types/js-types-tests.ts @@ -0,0 +1,5 @@ +import jsTypes = require('js-types'); +import jsTypesJson = require('js-types/js-types.json'); + +jsTypes; // $ExpectType string[] +jsTypesJson; // $ExpectType string[] diff --git a/types/js-types/js-types.json.d.ts b/types/js-types/js-types.json.d.ts new file mode 100644 index 0000000000..83565f43d1 --- /dev/null +++ b/types/js-types/js-types.json.d.ts @@ -0,0 +1,3 @@ +export = jsTypes; + +declare const jsTypes: string[]; diff --git a/types/js-types/tsconfig.json b/types/js-types/tsconfig.json new file mode 100644 index 0000000000..1b81a82e27 --- /dev/null +++ b/types/js-types/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "js-types.json.d.ts", + "js-types-tests.ts" + ] +} diff --git a/types/js-types/tslint.json b/types/js-types/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/js-types/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jsonabc/index.d.ts b/types/jsonabc/index.d.ts new file mode 100644 index 0000000000..41a785d015 --- /dev/null +++ b/types/jsonabc/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for jsonabc 2.3 +// Project: http://novicelab.org/jsonabc +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/** + * Sort the JSON (clean, parse, sort, stringify). + * @param noArray Sort or don't sort arrays + */ +export function sort(inputStr: string, noArray?: boolean): string; + +/** + * Sort the JSON (clean, parse, sort, stringify). + * @param noArray Sort or don't sort arrays + */ +export function sortObj(input: object, noArray?: boolean): object; + +/** Remove trailing commas */ +export function cleanJSON(input: string): string; diff --git a/types/jsonabc/jsonabc-tests.ts b/types/jsonabc/jsonabc-tests.ts new file mode 100644 index 0000000000..8d51d94bac --- /dev/null +++ b/types/jsonabc/jsonabc-tests.ts @@ -0,0 +1,9 @@ +import * as myJsonAbc from 'jsonabc'; + +myJsonAbc.sortObj({ c: 0, b: 1, a: 0 }); +myJsonAbc.sortObj({ c: 0, b: 1, a: 0 }, false); + +myJsonAbc.sort('{ c: 0, b: 1, a: 0 }'); +myJsonAbc.sort('{ c: 0, b: 1, a: 0 }', true); + +myJsonAbc.cleanJSON('{ c: 0, b: 1, a: 0 }'); diff --git a/types/jsonabc/tsconfig.json b/types/jsonabc/tsconfig.json new file mode 100644 index 0000000000..072c667a18 --- /dev/null +++ b/types/jsonabc/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jsonabc-tests.ts" + ] +} diff --git a/types/jsonabc/tslint.json b/types/jsonabc/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jsonabc/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/latest-semver/index.d.ts b/types/latest-semver/index.d.ts new file mode 100644 index 0000000000..761a487b88 --- /dev/null +++ b/types/latest-semver/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for latest-semver 1.0 +// Project: https://github.com/sindresorhus/latest-semver#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = latestSemver; + +declare function latestSemver(versions: string[]): string | undefined; diff --git a/types/latest-semver/latest-semver-tests.ts b/types/latest-semver/latest-semver-tests.ts new file mode 100644 index 0000000000..ec8312e467 --- /dev/null +++ b/types/latest-semver/latest-semver-tests.ts @@ -0,0 +1,4 @@ +import latestSemver = require('latest-semver'); + +// $ExpectType string | undefined +latestSemver(['v1.8.0-alpha.1', 'v1.3.16', 'v1.7.0', 'v1.6.9']); diff --git a/types/latest-semver/tsconfig.json b/types/latest-semver/tsconfig.json new file mode 100644 index 0000000000..54f1df51e2 --- /dev/null +++ b/types/latest-semver/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", + "latest-semver-tests.ts" + ] +} diff --git a/types/latest-semver/tslint.json b/types/latest-semver/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/latest-semver/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/latest-version/index.d.ts b/types/latest-version/index.d.ts new file mode 100644 index 0000000000..5127714c15 --- /dev/null +++ b/types/latest-version/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for latest-version 4.0 +// Project: https://github.com/sindresorhus/latest-version#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = latestVersion; + +declare function latestVersion(name: string, options?: latestVersion.Options): Promise; + +declare namespace latestVersion { + interface Options { + version?: string; + } +} diff --git a/types/latest-version/latest-version-tests.ts b/types/latest-version/latest-version-tests.ts new file mode 100644 index 0000000000..2cbd29b61f --- /dev/null +++ b/types/latest-version/latest-version-tests.ts @@ -0,0 +1,4 @@ +import latestVersion = require('latest-version'); + +latestVersion('ava'); // $ExpectType Promise +latestVersion('npm', { version: 'latest-5' }); // $ExpectType Promise diff --git a/types/latest-version/tsconfig.json b/types/latest-version/tsconfig.json new file mode 100644 index 0000000000..a62d14b69d --- /dev/null +++ b/types/latest-version/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", + "latest-version-tests.ts" + ] +} diff --git a/types/latest-version/tslint.json b/types/latest-version/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/latest-version/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/loopbench/index.d.ts b/types/loopbench/index.d.ts new file mode 100644 index 0000000000..bd5e61d3e2 --- /dev/null +++ b/types/loopbench/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for loopbench 1.2 +// Project: https://github.com/mcollina/loopbench#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { EventEmitter } from 'events'; + +export = loopbench; + +/** + * Creates a new instance of loopbench. + */ +declare function loopbench(options?: loopbench.Options): loopbench.LoopBench; + +declare namespace loopbench { + interface Options { + /** + * The interval at which the eventLoop should be sampled, defaults to `5`. + */ + sampleInterval?: number; + /** + * The maximum amount of delay that is tolerated before `overLimit` becomes true, + * and the `load` event is emitted, defaults to `42`. + */ + limit?: number; + } + + /** + * Events: + * - `load`, emitted when `instance.delay > instance.limit` + * - `unload`, emitted when `overLimit` goes from `true` and `false` + */ + interface LoopBench extends EventEmitter { + /** + * The delay in milliseconds (and fractions) from the expected run. It might be negative (in older nodes). + */ + readonly delay: number; + + /** + * The maximum amount of delay that is tolerated before `overLimit` becomes true, + * and the `load` event is emitted. + */ + readonly limit: number; + + /** + * Is `true` if the `instance.delay > instance.limit`. + */ + readonly overLimit: boolean; + + /** + * Stops the sampling. + */ + stop(): void; + + addListener(event: 'load' | 'unload', listener: () => void): this; + on(event: 'load' | 'unload', listener: () => void): this; + once(event: 'load' | 'unload', listener: () => void): this; + removeListener(event: 'load' | 'unload', listener: () => void): this; + off(event: 'load' | 'unload', listener: () => void): this; + removeAllListeners(event?: 'load' | 'unload'): this; + listeners(event: 'load' | 'unload'): Array<() => void>; + rawListeners(event: 'load' | 'unload'): Array<() => void>; + emit(event: 'load' | 'unload'): boolean; + listenerCount(type: 'load' | 'unload'): number; + prependListener(event: 'load' | 'unload', listener: () => void): this; + prependOnceListener(event: 'load' | 'unload', listener: () => void): this; + eventNames(): Array<'load' | 'unload'>; + } +} diff --git a/types/loopbench/loopbench-tests.ts b/types/loopbench/loopbench-tests.ts new file mode 100644 index 0000000000..e78a22e08a --- /dev/null +++ b/types/loopbench/loopbench-tests.ts @@ -0,0 +1,11 @@ +import loopbench = require('loopbench'); + +const inst = loopbench(); +inst; // $ExpectType LoopBench +loopbench({ sampleInterval: 1 }); // $ExpectType LoopBench +loopbench({ limit: 1 }); // $ExpectType LoopBench + +inst.delay; // $ExpectType number +inst.limit; // $ExpectType number +inst.overLimit; // $ExpectType boolean +inst.stop(); diff --git a/types/loopbench/tsconfig.json b/types/loopbench/tsconfig.json new file mode 100644 index 0000000000..05e37ab0fa --- /dev/null +++ b/types/loopbench/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", + "loopbench-tests.ts" + ] +} diff --git a/types/loopbench/tslint.json b/types/loopbench/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/loopbench/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/mangopay2-nodejs-sdk/index.d.ts b/types/mangopay2-nodejs-sdk/index.d.ts new file mode 100644 index 0000000000..e0c5d5c0e2 --- /dev/null +++ b/types/mangopay2-nodejs-sdk/index.d.ts @@ -0,0 +1,4383 @@ +// Type definitions for mangopay2-nodejs-sdk 1.9 +// Project: https://github.com/MangoPay/mangopay2-nodejs-sdk +// Definitions by: Ifiok Jr. +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +/// + +import { + ApiMethod, + CountryISO, + CurrencyISO, + MakeKeysRequired, + Omit, + OmitType, + PickPartialRequired, + ValueOf, + PickPartial, + DeepPartial +} from "./types"; + +export = MangoPay; + +declare class MangoPay { + constructor(config: MangoPay.Config); + config: MangoPay.Config; + requestOptions: MangoPay.RequestOptions; + Users: MangoPay.Users; + BankAccounts: MangoPay.BankAccounts; + BankingAliases: MangoPay.BankingAliases; + DisputeDocuments: MangoPay.DisputeDocuments; + Wallets: MangoPay.Wallets; + KycDocuments: MangoPay.KycDocuments; + UboDeclarations: MangoPay.UboDeclarations; + Cards: MangoPay.Cards; + CardRegistrations: MangoPay.CardRegistrations; + CardPreAuthorizations: MangoPay.CardPreAuthorizations; + PayIns: MangoPay.PayIns; + Transfers: MangoPay.Transfers; + PayOuts: MangoPay.PayOuts; + Refunds: MangoPay.Refunds; + Clients: MangoPay.Clients; + Disputes: MangoPay.Disputes; + Repudiations: MangoPay.Repudiations; + Events: MangoPay.Events; + Responses: MangoPay.Responses; + Mandates: MangoPay.Mandates; + Hooks: MangoPay.Hooks; + Reports: MangoPay.Reports; + + models: typeof MangoPay.models; + + Log(...args: any[]): void; + authorize(callback: (data: MangoPay.AuthorizationData) => void): void; + authorize(): Promise; + buildRequestData(entity: any): any; + canReadSubRequestData(entity: any, propertyName: any): boolean; + isExpired(): boolean; + method( + method: ApiMethod, + callback: (...args: any[]) => void, + options: MangoPay.RequestOptions + ): any; +} + +declare namespace MangoPay { + interface AuthorizationData { + access_token: string; + token_type: string; + expires_in: number; + } + + interface Headers { + "Content-Type": string; + "User-Agent": string; + "Idempotency-Key": string; + Authorization: string; + [header: string]: string | undefined; + } + + /** A UTC timestamp in seconds */ + type Timestamp = number; + type ColumnAndDirection = "ASC" | "DESC"; + type AVSResult = + | "NO_CHECK" + | "NO_MATCH" + | "ADDRESS_MATCH_ONLY" + | "POSTAL_CODE_MATCH_ONLY" + | "FULL_MATCH"; + type SecureMode = "DEFAULT" | "FORCE"; + type PreAuthorizationExecutionType = "DIRECT"; + type PaymentStatus = "WAITING" | "CANCELED" | "EXPIRED" | "VALIDATED"; + type PreAuthorizationStatus = "CREATED" | "SUCCEEDED" | "FAILED"; + interface BillingData { + Address: models.Address | address.AddressData | string; + } + + interface SecurityInfoData { + AVSResult: AVSResult; + } + + interface MoneyData { + /** + * The currency - should be ISO_4217 format + */ + Currency: CurrencyISO; + + /** + * An amount of money in the smallest sub-division of the currency, e.g. 12.60 EUR would be represented as 1260 whereas 12 JPY would be represented as just 12) + */ + Amount: number; + } + + interface WithResponse { + statusCode: number; + body: T; + headers: Headers; + } + + interface NoArgMethodOverload { + (options: MethodOptionWithResponse): Promise>; + (options?: MethodOptionWithoutResponse): Promise; + ( + callback: (data: WithResponse) => void, + options?: MethodOptionWithResponse + ): void; + (callback: (data: R) => void, options?: MethodOptionWithoutResponse): void; + } + + interface MethodOverload { + (data: T, options: MethodOptionWithResponse): Promise>; + (data: T, options?: MethodOptionWithoutResponse): Promise; + ( + data: T, + callback: (data: WithResponse) => void, + options: MethodOptionWithResponse + ): void; + ( + data: T, + callback: (data: R) => void, + options?: MethodOptionWithoutResponse + ): void; + } + + interface TwoArgsMethodOverload { + (data: T, extra: U, options: MethodOptionWithResponse): Promise< + WithResponse + >; + (data: T, extra: U, options?: MethodOptionWithoutResponse): Promise; + ( + data: T, + extra: U, + callback: (data: WithResponse) => void, + options?: MethodOptionWithResponse + ): void; + ( + data: T, + extra: U, + callback: (data: R) => void, + options?: MethodOptionWithoutResponse + ): void; + } + + interface ThreeArgsMethodOverload { + (data: T, extra: U, lastArg: V, options: MethodOptionWithResponse): Promise< + WithResponse + >; + ( + data: T, + extra: U, + lastArg: V, + options?: MethodOptionWithoutResponse + ): Promise; + ( + data: T, + extra: U, + lastArg: V, + callback: (data: WithResponse) => void, + options?: MethodOptionWithResponse + ): void; + ( + data: T, + extra: U, + lastArg: V, + callback: (data: R) => void, + options?: MethodOptionWithoutResponse + ): void; + } + + interface Config { + /** + * API Client Id + */ + clientId: string; + + /** + * API Client Api Key + */ + clientApiKey: string; + + /** + * API Base URL.The fault base value points to sandbox. + * Production is 'https://api.mangopay.com' + * + * @default "https://api.sandbox.mangopay.com" + */ + baseUrl?: string; + + /** + * Active debugging + * @default false + */ + debugMode?: boolean; + + /** + * Log function to be used for debug + * @default `console.log` + */ + logClass?(...args: any[]): void; + + /** + * Set the connection timeout limit(in milliseconds) + * @default 30000 + */ + connectionTimeout?: number; + + /** + * Set the response timeout limit(in milliseconds) + * @default 80000 + */ + responseTimeout?: number; + + /** + * API Version + * @default 'v2.01' + */ + apiVersion?: string; + + /** + * Set a custom error handler + * @default `console.error` + */ + errorHandler?(options: any, err: any): void; + } + + interface RequestOptions { + requestConfig: { + timeout: number; + }; + responseConfig: { + timeout: number; + }; + + /** + * Path options are replacing the ${placeholders} from apiMethods + */ + path: { + clientId: string; + apiVersion: string; + readonly id: string; + }; + headers: Partial; + } + + type WithToJson = T & { toJSON(): any }; + + // Determines the shape of the response + interface ReadResponseHeaders { + readResponseHeaders: true; + } + + interface PaginationOptions { + /** + * The page number of results you wish to return + * @default 1 + */ + Page?: number; + + /** + * The number of results to return per page: Max 100; + * @default 10 + */ + Per_Page?: number; + } + + interface FilterOptions extends Record { + /** + * The column to sort against and direction - only CreationDate (or Date for the events) is available and ASC or DESC for the direction + */ + Sort?: ColumnAndDirection; + + /** + * To return only resources that have CreationDate BEFORE this date + */ + BeforeDate?: Timestamp; + + /** + * To return only resources that have CreationDate AFTER this date + */ + AfterDate?: Timestamp; + } + + interface MethodOptions extends DeepPartial { + data?: WithToJson | string; + parameters?: FilterOptions & PaginationOptions; + } + + interface MethodOptionWithResponse extends MethodOptions { + readResponseHeaders: true; + } + + interface MethodOptionWithoutResponse extends MethodOptions { + readResponseHeaders?: false; + } + + interface DependsObject { + dependsPropertyName: string; + propertyName: string; + propertyValueMapping: Record; + } + + interface ModelMethods { + initialize(): void; + + /** + * Returns object property value + * @param attribute + */ + getData(attribute: K): T[K]; + + /** + * @param attribute - attribute's value to be set or hash of properties with values + * @param value - value to be set + */ + setData(attribute: K, value: T[K]): this; + setData(attribute: Partial): this; + + getReadOnlyProperties(): Array; + getDependsObjects(): DependsObject[]; + parse(): void; + } + + namespace models { + const PayInExecutionType: IPayInExecutionType; + const PayInPaymentType: IPayInPaymentType; + const MandateStatus: IMandateStatus; + const LegalPersonType: ILegalPersonType; + const PersonType: IPersonType; + const BankAccountType: IBankAccountType; + const DeclaredUboStatus: IDeclaredUboStatus; + const KycDocumentStatus: IKycDocumentStatus; + const KycDocumentType: IKycDocumentType; + const PayOutPaymentType: IPayOutPaymentType; + const PlatformType: IPlatformType; + const UboDeclarationRefusedReasonType: IUboDeclarationRefusedReasonType; + const UboDeclarationStatus: IUboDeclarationStatus; + const UboRefusedReasonType: IUboRefusedReasonType; + const UserNaturalCapacity: IUserNaturalCapacity; + class DeclaredUbo extends Model { + constructor(data: Partial); + } + + class Model implements ModelMethods { + initialize(): void; + getData(attribute: K): T[K]; + setData(attribute: K, value: T[K]): this; + setData(attribute: Partial): this; + setData(attribute: any, value?: any): this; + getReadOnlyProperties(): Array; + getDependsObjects(): DependsObject[]; + parse(): void; + constructor(data: T); + } + + class EntityBase extends Model { + initialize(): void; + + /** + * Returns object property value + */ + getData(attribute: K): T[K]; + + /** + * @param attribute - attribute's value to be set or hash of properties with values + * @param value - value to be set + */ + setData(attribute: K, value: T[K]): this; + setData(attribute: Partial): this; + + getReadOnlyProperties(): Array; + getDependsObjects(): DependsObject[]; + parse(): void; + toJSON(): any; + } + + class Money extends EntityBase { + constructor(data: MoneyData); + } + + class Billing extends EntityBase { + constructor(data: BillingData); + } + + class Address extends EntityBase { + constructor(data: Partial); + } + + interface Address extends address.AddressData {} + + class BankingAlias extends EntityBase { + constructor(data: Partial); + } + + class BankingAliasIBAN extends BankingAlias {} + + interface BankingAlias extends bankingAlias.IBANBankingAliasData {} + + class BankAccount extends EntityBase { + constructor(data: bankAccount.CreationDetails); + } + interface BankAccount extends bankAccount.DataIntersection {} + + class BankAccountDetails { + constructor(data: any); + } + + class BankAccountDetailsCA extends BankAccountDetails { + constructor(data: any); + } + + interface BankAccountDetailsCA extends bankAccount.CADetails {} + + class BankAccountDetailsOther extends BankAccountDetails { + constructor(data: any); + } + + interface BankAccountDetailsOther extends bankAccount.OtherDetails {} + + class BankAccountDetailsGB extends BankAccountDetails { + constructor(data: any); + } + + interface BankAccountDetailsGB extends bankAccount.GBDetails {} + + class BankAccountDetailsIBAN extends BankAccountDetails { + constructor(data: any); + } + + interface BankAccountDetailsIBAN extends bankAccount.IBANDetails {} + + class BankAccountDetailsUS extends BankAccountDetails { + constructor(data: any); + } + + interface BankAccountDetailsUS extends bankAccount.USDetails {} + + class Transaction extends EntityBase { + constructor(data: transaction.TransactionData); + } + + interface Transaction extends transaction.TransactionData {} + + class ClientWallet extends EntityBase {} + + class Wallet extends EntityBase { + constructor(data: wallet.CreateWallet | wallet.UpdateWallet); + } + + class DocumentPageConsult extends Model { + constructor(data: Partial); + } + + interface DocumentPageConsult extends disputeDocument.DocumentPageConsult {} + + class Document extends EntityBase { + constructor(data: any); + } + + class DisputeDocument extends Document {} + + interface DisputeDocument extends disputeDocument.DisputeDocumentData {} + + class DisputeDocumentPage extends EntityBase { + constructor(data: disputeDocument.CreateDisputeDocumentPage); + } + + interface DisputeDocumentPage + extends disputeDocument.CreateDisputeDocumentPage {} + + class KycDocument extends EntityBase { + constructor(data: Partial); + } + + interface KycDocument extends kycDocument.KycDocumentData {} + + class KycPage { + constructor(data: kycDocument.CreateKycPage); + } + + interface KycPage extends kycDocument.CreateKycPage {} + + class EMoney { + constructor(data: eMoney.EMoneyData); + } + + interface EMoney extends eMoney.EMoneyData {} + + class UboDeclaration extends EntityBase { + constructor( + data: + | uboDeclaration.CreateUboDeclaration + | uboDeclaration.UpdateUboDeclaration + ); + } + + interface UboDeclaration extends uboDeclaration.UboDeclarationData {} + + class CardRegistration extends EntityBase< + cardRegistration.CardRegistrationData + > { + constructor( + data: + | cardRegistration.CreateCardRegistration + | cardRegistration.UpdateCardRegistration + ); + } + + interface CardRegistration extends cardRegistration.CardRegistrationData {} + + class Card extends EntityBase { + constructor(data: card.CardData); + } + + interface Card extends card.CardData {} + + class CardPreAuthorization { + constructor( + data: + | cardPreAuthorization.CardPreAuthorizationData + | cardPreAuthorization.UpdateCardPreAuthorization + ); + } + + interface CardPreAuthorization + extends cardPreAuthorization.CardPreAuthorizationData {} + + class SecurityInfo extends EntityBase< + SecurityInfo & entityBase.EntityBaseData + > { + constructor(data: SecurityInfo); + } + + class UserLegal extends EntityBase { + PersonType: "LEGAL"; + constructor( + data: MakeKeysRequired< + Partial, + user.RequiredUserLegalData + > + ); + + /** + * Sets the person type for the model + * @param personType + */ + setPersonType(type: user.PersonType): void; + } + + interface UserLegal extends user.UserLegalData {} + + class UserNatural extends EntityBase { + PersonType: "NATURAL"; + constructor( + data: MakeKeysRequired< + Partial, + user.RequiredUserNaturalData + > + ); + + /** + * Sets the person type for the model + * @param personType + */ + setPersonType(type: user.PersonType): void; + } + + interface UserNatural extends user.UserNaturalData {} + + class User extends EntityBase { + constructor(data: user.UserData); + + /** + * Sets the person type for the model + * @param personType + */ + setPersonType(type: user.PersonType): void; + } + + interface User extends user.UserData {} + + class PayIn extends EntityBase { + constructor(data: any); + } + + interface PayIn extends payIn.BasePayInData {} + + class PayInPaymentDetails extends EntityBase { + constructor(data: any); + } + + class PayInExecutionDetails extends EntityBase { + constructor(data: any); + } + + class PayInExecutionDetailsDirect extends PayInExecutionDetails { + constructor(data: any); + } + + class PayInExecutionDetailsWeb extends PayInExecutionDetails { + constructor(data: any); + } + + class PayInPaymentDetailsBankWire extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsBankingAlias extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsCard extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsCardDirect extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsCardWeb extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsDirectDebitDirect extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsDirectDebitWeb extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsPayPal extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInPaymentDetailsPreAuthorized extends PayInPaymentDetails { + constructor(data: any); + } + + class PayInTemplateURLOptions extends EntityBase { + constructor(data: any); + } + + class Refund extends EntityBase { + constructor(data: refund.CreatePayInRefund | refund.CreateTransferRefund); + } + + class RefundReasonDetails extends EntityBase { + constructor(data: any); + } + + class Repudiation extends EntityBase { + constructor(data: Partial); + } + + interface Repudiation extends repudiation.RepudiationData {} + + class Client extends EntityBase { + constructor(data?: Partial); + } + + interface Client extends client.ClientData {} + + class PlatformCategorization extends EntityBase< + client.PlatformCategorization + > { + constructor(data: client.PlatformCategorization); + } + + class Dispute extends EntityBase { + constructor(data: Partial); + } + + interface Dispute extends dispute.DisputeData {} + + class DisputeReason extends Model { + constructor(data: any); + } + + class SettlementTransfer extends EntityBase< + settlementTransfer.SettlementTransferData + > { + constructor(data: Partial); + } + + interface SettlementTransfer + extends settlementTransfer.SettlementTransferData {} + + class Transfer extends EntityBase { + constructor(data: Partial); + } + + interface Transfer extends transfer.TransferData {} + + class PayOut extends EntityBase { + constructor(data: Partial); + } + // interface PayOut extends PayOut.PayoutData {} + + class PayOutPaymentDetails extends EntityBase { + constructor(data?: any); + } + + class PayOutPaymentDetailsBankWire extends PayOutPaymentDetails { + constructor(data?: any); + } + + class Mandate extends EntityBase { + constructor(data?: Partial); + } + + interface Mandate extends mandate.MandateData {} + + class Hook extends EntityBase { + constructor(data?: Partial); + } + + interface Hook extends hook.HookData {} + + class Report extends EntityBase { + constructor(data?: Partial); + } + + interface Report extends report.ReportData {} + + class ReportFilter extends Model { + constructor(data?: Partial); + } + + interface Report extends report.Filters {} + } + + interface IPayInExecutionType { + Direct: "DIRECT"; + Web: "WEB"; + } + + interface IPayInPaymentType { + BankWire: "BANK_WIRE"; + Card: "CARD"; + DirectDebit: "DIRECT_DEBIT"; + Preauthorized: "PREAUTHORIZED"; + PayPal: "PAYPAL"; + } + + interface IMandateStatus { + Created: "CREATED"; + Submitted: "SUBMITTED"; + Active: "ACTIVE"; + Failed: "FAILED"; + } + + interface ILegalPersonType { + NotSpecified: "NotSpecified"; + Business: "BUSINESS"; + Organization: "ORGANIZATION"; + Soletrader: "SOLETRADER"; + } + + interface IPersonType { + NotSpecified: "NotSpecified"; + Natural: "NATURAL"; + Legal: "LEGAL"; + } + + interface IBankAccountType { + NotSpecified: "NotSpecified"; + IBAN: "IBAN"; + GB: "GB"; + US: "US"; + CA: "CA"; + OTHER: "OTHER"; + } + + interface IDeclaredUboStatus { + Created: "CREATED"; + Validated: "VALIDATED"; + Refused: "REFUSED"; + } + + interface IKycDocumentStatus { + Created: "CREATED"; + ValidationAsked: "VALIDATION_ASKED"; + Validated: "VALIDATED"; + Refused: "REFUSED"; + } + + interface IKycDocumentType { + IdentityProof: "IDENTITY_PROOF"; + RegistrationProof: "REGISTRATION_PROOF"; + ArticlesOfAssociation: "ARTICLES_OF_ASSOCIATION"; + ShareholderDeclaration: "SHAREHOLDER_DECLARATION"; + AddressProof: "ADDRESS_PROOF"; + } + + interface IPayOutPaymentType { + BankWire: "BANK_WIRE"; + } + + interface IPlatformType { + NotSpecified: "NotSpecified"; + MARKETPLACE: "MARKETPLACE"; + P2P_PAYMENT: "P2P_PAYMENT"; + CROWDFUNDING_DONATION: "CROWDFUNDING_DONATION"; + CROWDFUNDING_REWARD: "CROWDFUNDING_REWARD"; + CROWDFUNDING_EQUITY: "CROWDFUNDING_EQUITY"; + CROWDFUNDING_LOAN: "CROWDFUNDING_LOAN"; + OTHER: "OTHER"; + } + + interface IUboDeclarationRefusedReasonType { + /** + * When at least one natural user is missing on the declaration + */ + MissingUbo: "MISSING_UBO"; + + /** + * When at least one natural user should not be declared as UBO + */ + InvalidDeclaredUbo: "INVALID_DECLARED_UBO"; + + /** + * When at least one natural user declared as UBO has been created + * with wrong details (i.e. date of birth, country of residence) + */ + InvalidUboDetails: "INVALID_UBO_DETAILS"; + } + + interface IUboDeclarationStatus { + /** + * When the UBO declaration was created + */ + Created: "CREATED"; + + /** + * When validation has been requested for the UBO declaration + */ + ValidationAsked: "VALIDATION_ASKED"; + + /** + * When the UBO declaration was validated + */ + Validated: "VALIDATED"; + + /** + * When the UBO declaration was refused + */ + Refused: "REFUSED"; + } + + interface IUboRefusedReasonType { + /** + * When user should not be declared as UBO + */ + InvalidDeclaredUbo: "INVALID_DECLARED_UBO"; + + /** + * When user declared as UBO was created with wrong + * details (i.e. date of birth, country of residence) + */ + InvalidUboDetails: "INVALID_UBO_DETAILS"; + } + + interface IUserNaturalCapacity { + /** + * Real customer + */ + Normal: "NORMAL"; + + /** + * User used only for declaration purpose + */ + Declarative: "DECLARATIVE"; + } + + namespace entityBase { + interface EntityBaseData { + Id: string; + Tag: string; + CreationDate: number; + } + } + + namespace address { + interface AddressData { + AddressLine1: string; + AddressLine2: string; + City: string; + Region: string; + PostalCode: string; + Country: string; + } + type AddressType = string | AddressData | models.Address; + } + + namespace bankingAlias { + type BankingAliasType = "IBAN"; + interface BankingAliasData extends entityBase.EntityBaseData { + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId: string; + + /** + * The ID of a wallet + */ + WalletId: string; + + /** + * The Country of the Address + */ + Country: CountryISO; + + /** + * The type of banking alias (note that only IBAN is available at present) + */ + Type: BankingAliasType; + + /** + * The owner of the wallet/banking alias + */ + OwnerName: string; + + /** + * Whether the banking alias is active or not + */ + Active: boolean; + } + + interface IBANBankingAliasData extends BankingAliasData { + /** + * The type of banking alias (note that only IBAN is available at present) + */ + Type: "IBAN"; + + /** + * The IBAN of the banking alias + */ + IBAN: string; + + /** + * The BIC of the banking alias + */ + BIC: string; + } + + interface CreateIBANBankingAlias + extends PickPartialRequired< + IBANBankingAliasData, + "Tag" | "CreditedUserId", + "OwnerName" | "Country" + > {} + } + + namespace bankAccount { + type BankAccountType = "IBAN" | "GB" | "US" | "CA" | "OTHER"; + type DepositAccountType = "CHECKING" | "SAVINGS"; + + interface BaseData extends entityBase.EntityBaseData { + /** + * The object owner's UserId + */ + UserId: string; + + /** + * The type of bank account + */ + Type: BankAccountType; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: address.AddressType; + + /** + * @deprecated + */ + Details?: models.BankAccountDetails; + + /** + * Whether the bank account is active or not + */ + Active: boolean; + } + + interface IBANDetails { + Type: "IBAN"; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: address.AddressType; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The IBAN of the bank account + */ + IBAN: string; + + /** + * The BIC of the bank account + */ + BIC?: string; + } + + type IBANData = BaseData & IBANDetails; + + interface USDetails { + Type: "US"; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: address.AddressType; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The account number of the bank account. US account numbers must be digits only. + */ + AccountNumber: string; + + /** + * The ABA of the bank account. Must be numbers only, and 9 digits long + */ + ABA: string; + + /** + * The type of account + */ + DepositAccountType?: DepositAccountType; + } + + type USData = BaseData & USDetails; + + interface CADetails { + Type: "CA"; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: address.AddressType; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The branch code of the bank where the bank account. Must be numbers only, and 5 digits long + */ + BranchCode: string; + + /** + * The institution number of the bank account. Must be numbers only, and 3 or 4 digits long + */ + InstitutionNumber: string; + + /** + * The account number of the bank account. Must be numbers only. Canadian account numbers must be a maximum of 20 digits. + */ + AccountNumber: string; + + /** + * The name of the bank where the account is held. Must be letters or numbers only and maximum 50 characters long. + */ + BankName: string; + } + + type CAData = BaseData & CADetails; + + interface GBDetails { + Type: "GB"; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: address.AddressType; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The sort code of the bank account. Must be numbers only, and 6 digits long + */ + SortCode: string; + + /** + * The account number of the bank account. Must be numbers only. GB account numbers must be 8 digits long. + */ + AccountNumber: string; + } + + type GBData = BaseData & GBDetails; + + interface OtherDetails { + Type: "OTHER"; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: address.AddressType; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The Country of the Address + */ + Country: string; + + /** + * The BIC of the bank account + */ + BIC: string; + + /** + * The account number of the bank account. Must be numbers only. Canadian account numbers must be a maximum of 20 digits. + */ + AccountNumber: string; + } + + type OtherData = BaseData & OtherDetails; + + type Data = OtherData | CAData | GBData | IBANData | USData; + type DataIntersection = OtherData & CAData & GBData & IBANData & USData; + type CreationDetails = + | OtherDetails + | CADetails + | GBDetails + | IBANDetails + | USDetails; + } + + namespace transaction { + type TransactionNature = + | "REGULAR" + | "REPUDIATION" + | "REFUND" + | "SETTLEMENT"; + type TransactionType = "PAYIN" | "TRANSFER" | "PAYOUT"; + type TransactionStatus = "CREATED" | "SUCCEEDED" | "FAILED"; + + interface TransactionData extends entityBase.EntityBaseData { + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Details about the funds that are being credited (DebitedFunds – Fees = CreditedFunds) + */ + CreditedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * The ID of the wallet that was debited + */ + DebitedWalletId: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId: string; + + /** + * The nature of the transaction + */ + Nature: TransactionNature; + + /** + * The status of the transaction + */ + Status: TransactionStatus; + + /** + * When the transaction happened + */ + ExecutionDate: Timestamp; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * The type of the transaction + */ + Type: TransactionType; + } + } + + namespace wallet { + type ClientFundsType = "FEES" | "CREDIT"; + type FundsType = "DEFAULT" | ClientFundsType; + + interface WalletData extends entityBase.EntityBaseData { + /** + * An array of userIDs of who own's the wallet. For now, you only can set up a unique owner. + */ + Owners: [string]; + + /** + * The current balance of the wallet + */ + Balance: MoneyData; + + /** + * The type of funds in the wallet + */ + FundsType: FundsType; + + /** + * A desciption of the wallet + */ + Description: string; + + /** + * The currency - should be ISO_4217 format + */ + Currency: CurrencyISO; + } + + interface ClientWalletData + extends Omit { + FundsType: ClientFundsType; + } + + type CreateWallet = UpdateWallet & + Pick; + type UpdateWallet = PickPartial; + } + + namespace disputeDocument { + type DisputeDocumentType = + | "DELIVERY_PROOF" + | "INVOICE" + | "REFUND_PROOF" + | "USER_CORRESPONDANCE" + | "USER_ACCEPTANCE_PROOF" + | "PRODUCT_REPLACEMENT_PROOF" + | "OTHER"; + + type DocumentStatus = + | "CREATED" + | "VALIDATION_ASKED" + | "VALIDATED" + | "REFUSED"; + + type RefusedReasonType = + | "DOCUMENT_UNREADABLE" + | "DOCUMENT_NOT_ACCEPTED" + | "DOCUMENT_HAS_EXPIRED" + | "DOCUMENT_INCOMPLETE" + | "DOCUMENT_MISSING" + | "SPECIFIC_CASE" + | "DOCUMENT_FALSIFIED" + | "OTHER"; + + interface DisputeDocumentData extends entityBase.EntityBaseData { + /** + * Gives the type of the KYC document + */ + Type: DisputeDocumentType; + + /** + * The object owner's UserId + */ + UserId: string; + + /** + * The Id of a Dispute + */ + DisputeId: string; + + /** + * The status of this KYC/Dispute document + */ + Status: DocumentStatus; + + /** + * The message accompanying a refusal + */ + RefusedReasonMessage: string; + + /** + * The type of reason for refusal + */ + RefusedReasonType: RefusedReasonType; + + /** + * The date when the document was processed by MANGOPAY + */ + ProcessedDate: Timestamp; + } + + interface CreateDisputeDocument { + /** + * Gives the type of the KYC document + */ + Type: DisputeDocumentType; + Tag?: string; + } + + interface SubmitDisputeDocument { + /** + * The status of this KYC/Dispute document + */ + Status: "VALIDATION_ASKED"; + Tag?: string; + } + + /** + * - Documents have to be in "CREATED" Status + * - You can create as many pages as needed + * + * Remember to change Status to "VALIDATION_ASKED" to submit KYC documents + * The maximum size per page is about 7Mb (or 10Mb when base64encoded). The following formats are accepted for the documents : .pdf, .jpeg, .jpg, .gif and .png. The minimum size is 1Kb. + */ + interface CreateDisputeDocumentPage { + /** + * The base64 encoded file which needs to be uploaded + * + * You need to fill in only the binary code. Do not send the first part that some converters add into the binary code which is + * `` + * + * e.g. + * ```json + * { + * "File": "/9j/4AAQSkZJRgABAQEBLAEsAAD/.../wgARCAAyADIDAREAAhEBAxEB/8QAGwAAAgMBAQEA" + * } + * ``` + */ + File: string; + } + + interface DocumentPageConsult { + /** + * URL where this document page can be viewed. + */ + Url: string; + + /** + * Time in millis when the page consult will expire. + */ + ExpirationDate: Timestamp; + } + } + + namespace kycDocument { + type KycDocumentType = + | "IDENTITY_PROOF" + | "REGISTRATION_PROOF" + | "ARTICLES_OF_ASSOCIATION" + | "SHAREHOLDER_DECLARATION" + | "ADDRESS_PROOF"; + type DocumentStatus = + | "CREATED" + | "VALIDATION_ASKED" + | "VALIDATED" + | "REFUSED"; + + type KYCDocumentRefusedReasonType = + | "DOCUMENT_UNREADABLE" + | "DOCUMENT_NOT_ACCEPTED" + | "DOCUMENT_HAS_EXPIRED" + | "DOCUMENT_INCOMPLETE" + | "DOCUMENT_MISSING" + | "DOCUMENT_DO_NOT_MATCH_USER_DATA" + | "DOCUMENT_DO_NOT_MATCH_ACCOUNT_DATA" + | "SPECIFIC_CASE" + | "DOCUMENT_FALSIFIED" + | "UNDERAGE_PERSON" + | "SPECIFIC_CASE"; + + interface KycDocumentData extends entityBase.EntityBaseData { + /** + * Gives the type of the KYC document + */ + Type: KycDocumentType; + + /** + * The object owner's UserId + */ + UserId: string; + + /** + * The status of this KYC/Dispute document + */ + Status: DocumentStatus; + + /** + * The message accompanying a refusal + */ + RefusedReasonMessage: string; + + /** + * The type of reason for refusal + */ + RefusedReasonType: KYCDocumentRefusedReasonType; + + /** + * The date when the document was processed by MANGOPAY + */ + ProcessedDate: Timestamp; + } + + interface CreateKycDocument { + /** + * Gives the type of the KYC document + */ + Type: KycDocumentType; + Tag?: string; + } + + interface CreateKycDocument { + /** + * Gives the type of the KYC document + */ + Type: KycDocumentType; + Tag?: string; + } + + interface SubmitKycDocument { + /** + * The status of this KYC/Dispute document + */ + Status: "VALIDATION_ASKED"; + Tag?: string; + } + + /** + * - Documents have to be in "CREATED" Status + * - You can create as many pages as needed + * + * Remember to change Status to "VALIDATION_ASKED" to submit KYC documents + * The maximum size per page is about 7Mb (or 10Mb when base64encoded). The following formats are accepted for the documents : .pdf, .jpeg, .jpg, .gif and .png. The minimum size is 1Kb. + */ + interface CreateKycPage { + /** + * The base64 encoded file which needs to be uploaded + * + * You need to fill in only the binary code. Do not send the first part that some converters add into the binary code which is + * `` + * + * e.g. + * ```json + * { + * "File": "/9j/4AAQSkZJRgABAQEBLAEsAAD/.../wgARCAAyADIDAREAAhEBAxEB/8QAGwAAAgMBAQEA" + * } + * ``` + */ + File: string; + } + } + + namespace eMoney { + interface EMoneyData extends entityBase.EntityBaseData { + /** + * The object owner's UserId + */ + UserId: string; + + /** + * The amount of money that has been credited to this user + */ + CreditedEMoney: MoneyData; + + /** + * The amount of money that has been debited from this user + */ + DebitedEMoney: MoneyData; + } + } + + namespace uboDeclaration { + interface UboDeclarationData extends entityBase.EntityBaseData { + /** + * The object owner's UserId + */ + UserId: string; + + /** + * Status of a UBO Declaration + */ + Status: kycDocument.DocumentStatus; + + /** + * Reason types for a UBO Declaration + */ + RefusedReasonTypes: string[]; + + /** + * Refused Reason Message for a UBO Declaration + */ + RefusedReasonMessage: string; + + /** + * An array of UserIDs declared as Ultimate Beneficial Owners of a BUSINESS Legal User. + */ + DeclaredUBOs: string[]; + } + + interface CreateUboDeclaration { + DeclaredUBOs?: string[]; + } + + interface UpdateUboDeclaration { + Id: string; + Tag?: string; + Status?: "VALIDATION_ASKED"; + + /** + * An array of UserIDs declared as Ultimate Beneficial Owners of a BUSINESS Legal User. + */ + DeclaredUBOs?: string[]; + } + } + + namespace cardRegistration { + interface CardRegistrationData extends entityBase.EntityBaseData { + /** + * The object owner's UserId + */ + UserId: string; + /** + * The currency - should be ISO_4217 format + */ + Currency: CurrencyISO; + + /** + * A special key to use when registering a card + */ + AccessKey: string; + + /** + * A specific value to pass to the CardRegistrationURL + */ + PreregistrationData: string; + + /** + * The URL to submit the card details form to + */ + CardRegistrationURL: string; + + /** + * Having registered a card, this confirmation hash needs to be updated to the card item + */ + RegistrationData: string; + + /** + * The type of card + */ + CardType: card.CardType; + + /** + * The ID of a card + */ + CardId: string; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * Status of the card registration + */ + Status: card.CardStatus; + } + + interface CreateCardRegistration + extends PickPartialRequired< + CardRegistrationData, + "CardType" | "Tag", + "UserId" | "Currency" + > {} + type UpdateCardRegistration = PickPartial< + CardRegistrationData, + "Tag" | "RegistrationData" + >; + } + + namespace card { + type CardType = + | "CB_VISA_MASTERCARD" + | "DINERS" + | "MASTERPASS" + | "MAESTRO" + | "P24" + | "IDEAL" + | "BCMC" + | "PAYLIB"; + type CardStatus = "CREATED" | "VALIDATED" | "ERROR"; + type CardValidity = "UNKNOWN" | "VALID" | "INVALID"; + + interface CardData extends entityBase.EntityBaseData { + /** + * The expiry date of the card - must be in format MMYY + */ + ExpirationDate: string; + + /** + * A partially obfuscated version of the credit card number + */ + Alias: string; + + /** + * The provider of the card + */ + CardProvider: string; + + /** + * The type of card + */ + CardType: CardType; + + /** + * The Country of the Address + */ + Country: string; + + /** + * The card product type - more info + */ + Product: string; + + /** + * The bank code + */ + BankCode: string; + + /** + * Whether the card is active or not + */ + Active: boolean; + + /** + * The currency - should be ISO_4217 format + */ + Currency: CurrencyISO; + + /** + * Whether the card is valid or not. Once they process (or attempt to process) a payment with the card we are able to indicate if it is "valid" or "invalid". + * If they didn’t process a payment yet the "Validity" stay at "unknown". + */ + Validity: CardValidity; + + /** + * A unique representation of a 16-digits card number + */ + Fingerprint: string; + } + + interface UpdateCard { + Id: string; + Active?: false; + } + } + + namespace cardPreAuthorization { + interface CardPreAuthorizationData extends entityBase.EntityBaseData { + /** + * A user's ID + */ + AuthorId: string; + + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Status of the PreAuthorization + */ + Status: PreAuthorizationStatus; + + /** + * The status of the payment after the PreAuthorization. You can pass the PaymentStatus from "WAITING" to "CANCELED" should you need/want to + */ + PaymentStatus: PaymentStatus; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * How the PreAuthorization has been executed + */ + ExecutionType: PreAuthorizationExecutionType; + + /** + * The SecureMode corresponds to '3D secure' for CB Visa and MasterCard. This field lets you activate it manually. + * The field lets you activate it automatically with "DEFAULT" (Secured Mode will be activated from €50 or when MANGOPAY detects there is a higher risk ), + * "FORCE" (if you wish to specifically force the secured mode). + */ + SecureMode: SecureMode; + + /** + * The ID of a card + */ + CardId: string; + + /** + * The value is 'true' if the SecureMode was used + */ + SecureModeNeeded: boolean; + + /** + * This is the URL where to redirect users to proceed to 3D secure validation + */ + SecureModeRedirectUrl: string; + + /** + * This is the URL where users are automatically redirected after 3D secure validation (if activated) + */ + SecureModeReturnURL: string; + + /** + * The date when the payment is to be processed by + */ + ExpirationDate: Timestamp; + + /** + * The Id of the associated PayIn + */ + PayInId: string; + + /** + * Contains useful information related to the user billing + */ + Billing: BillingData; + + /** + * Contains useful information related to security and fraud + */ + SecurityInfo: SecurityInfoData; + } + + type CreateCardPreAuthorization = PickPartialRequired< + CardPreAuthorizationData, + "Tag" | "Billing" | "SecureMode", + "AuthorId" | "DebitedFunds" | "CardId" | "SecureModeReturnURL" + >; + type UpdateCardPreAuthorization = PickPartialRequired< + CardPreAuthorizationData, + "Tag", + "PaymentStatus" | "Id" + >; + } + + namespace hook { + type HookValidity = "UNKNOWN" | "VALID" | "INVALID"; + type HookStatus = "DISABLED" | "ENABLED"; + + interface HookData extends entityBase.EntityBaseData { + /** + * This is the URL where your receive notification for each EventType + */ + Url: string; + + /** + * Whether the hook is enabled or not + */ + Status: HookStatus; + + /** + * Whether the hook is valid or not + */ + Validity: HookValidity; + + /** + * The event type + */ + EventType: event.EventType; + } + + interface CreateHook + extends PickPartialRequired {} + + interface UpdateHook + extends PickPartialRequired< + HookData, + "EventType" | "Url" | "Tag", + "Id" + > {} + } + + namespace report { + interface Filters { + /** + * To return only resources that have CreationDate BEFORE this date + */ + BeforeDate: Timestamp; + + /** + * To return only resources that have CreationDate AFTER this date + */ + AfterDate: Timestamp; + + /** + * The type of the transaction + */ + Type: transaction.TransactionType[]; + + /** + * The status of the transaction + */ + Status: transaction.TransactionStatus[]; + + /** + * The nature of the transaction + */ + Nature: transaction.TransactionNature[]; + + /** + * The minimum amount of DebitedFunds + */ + MinDebitedFundsAmount: number; + + /** + * The currency for the minimum amount of DebitedFunds + */ + MinDebitedFundsCurrency: CurrencyISO; + + /** + * The maximum amount of DebitedFunds + */ + MaxDebitedFundsAmount: number; + + /** + * The currency for the maximum amount of DebitedFunds + */ + MaxDebitedFundsCurrency: CurrencyISO; + + /** + * The minimum amount of Fees + */ + MinFeesAmount: number; + + /** + * The currency for the minimum amount of Fees + */ + MinFeesCurrency: CurrencyISO; + + /** + * The maximum amount of Fees + */ + MaxFeesAmount: number; + + /** + * The currency for the maximum amount of Fees + */ + MaxFeesCurrency: CurrencyISO; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The ID of a wallet + */ + WalletId: string; + } + + type Column = + | "Alias" + | "AuthorId" + | "BankAccountId" + | "BankWireRef" + | "CardId" + | "CardType" + | "Country" + | "CreationDate" + | "CreditedFundsAmount" + | "CreditedFundsCurrency" + | "CreditedUserId" + | "CreditedWalletId" + | "Culture" + | "DebitedFundsAmount" + | "DebitedFundsCurrency" + | "DebitedWalletId" + | "DeclaredDebitedFundsAmount" + | "DeclaredDebitedFundsCurrency" + | "DeclaredFeesAmount" + | "DeclaredFeesCurrency" + | "ExecutionDate" + | "ExecutionType" + | "ExpirationDate" + | "FeesAmount" + | "FeesCurrency" + | "Id" + | "Nature" + | "PaymentType" + | "PreauthorizationId" + | "ResultCode" + | "ResultMessage" + | "Status" + | "Tag" + | "Type" + | "WireReference"; + + interface ReportData extends entityBase.EntityBaseData { + /** + * The date when the report was executed + */ + ReportDate: Timestamp; + + /** + * The URL to download the report + */ + DownloadURL: string; + + /** + * A URL that we will ping when the report is ready to download(works in a similar way to the hooks) + */ + CallbackURL: string; + + /** + * The format of the report download + */ + DownloadFormat: "CSV"; + + /** + * The type of report + */ + ReportType: "TRANSACTIONS"; + + /** + * The column to sort against and direction seperate by a `:` + */ + Sort: string; + + /** + * Whether the report should be limited to the first 10 lines(and therefore quicker to execute) + */ + Preview: boolean; + + /** + * An object of various filters for the report + */ + Filters: Filters; + + /** + * A list of columns / infos to show in the report + */ + Columns: Column[]; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + } + + interface CreateReport + extends PickPartial< + ReportData, + | "Tag" + | "CallbackURL" + | "DownloadFormat" + | "Sort" + | "Preview" + | "Filters" + | "Columns" + > {} + } + + namespace mandate { + /** + * - "CREATED" - the mandate has been created + * - "SUBMITTED" - the mandate has been submitted to the banks and you can now do payments with this mandate + * - "ACTIVE" - the mandate is active and has been accepted by the banks and/or successfully used in a payment + * - "FAILED" - the mandate has failed for a variety of reasons and is no longer available for payments + */ + type MandateStatus = ValueOf; + type MandateScheme = "SEPA" | "BACS"; + type MandateCultureCode = "EN" | "FR" | "NL" | "DE" | "ES" | "IT" | "PL"; + type MandateExecutionType = "WEB"; + type MandateType = "DIRECT_DEBIT"; + interface MandateData extends entityBase.EntityBaseData { + /** + * An ID of a Bank Account + */ + BankAccountId: string; + + /** + * The object owner's UserId + */ + UserId: string; + + /** + * The URL to redirect to after payment (whether successful or not) + */ + ReturnURL: string; + + /** + * The URL to redirect to user to for them to proceed with the payment + */ + RedirectURL: string; + + /** + * The URL to download the mandate + */ + DocumentURL: string; + + /** + * The language to use for the mandate confirmation page - needs to be the ISO code of the language + */ + Culture: MandateCultureCode; + + /** + * The type of mandate, but will only be completed once the mandate has been submitted + */ + Scheme: MandateScheme; + + /** + * The status of the mandate: + */ + Status: MandateStatus; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * The execution type for creating the mandate + */ + ExecutionType: MandateExecutionType; + + /** + * The type of Mandate + */ + MandateType: MandateType; + + /** + * The banking reference for this mandate + */ + BankReference: string; + } + + interface CreateMandate + extends PickPartialRequired< + MandateData, + "Tag", + "BankAccountId" | "Culture" | "ReturnURL" + > {} + } + + namespace user { + /** + * Should be only one of these values: + * 1 - for incomes <18K€), + * 2 - for incomes between 18 and 30K€, + * 3 - for incomes between 30 and 50K€, + * 4 - for incomes between 50 and 80K€, + * 5 - for incomes between 80 and 120K€, + * 6 - for incomes >120K€ + */ + type IncomeRange = 1 | 2 | 3 | 4 | 5 | 6; + type PersonType = "NATURAL" | "LEGAL"; + type KYCLevel = "LIGHT" | "REGULAR"; + type LegalPersonType = "BUSINESS" | "ORGANIZATION" | "SOLETRADER"; + type StaticKeys = + | "KYCLevel" + | "PersonType" + | "Id" + | "CreationDate" + | "ProofOfIdentity" + | "ProofOfAddress" + | "ProofOfRegistration" + | "LegalRepresentativeProofOfIdentity" + | "ShareholderDeclaration" + | "Statute"; + interface UserData extends entityBase.EntityBaseData { + /** + * Type of user + */ + PersonType: PersonType; + + /** + * The person's email address (not more than 12 consecutive numbers) - must be a valid email + */ + Email: string; + + /** + * KYC Level (LIGHT or REGULAR) + */ + KYCLevel: KYCLevel; + } + + interface UserLegalData extends UserData { + PersonType: "LEGAL"; + + /** + * The name of the legal user + */ + Name: string; + + /** + * Type for legal user. + */ + LegalPersonType: LegalPersonType; + + /** + * The address of the company’s headquarters + */ + HeadquartersAddress: address.AddressType; + + /** + * The first name of the company’s Legal representative person + */ + LegalRepresentativeFirstName: string; + + /** + * The last name of the company’s Legal representative person + */ + LegalRepresentativeLastName: string; + + /** + * The address of the company’s Legal representative person + */ + LegalRepresentativeAddress: address.AddressType; + + /** + * The email of the company’s Legal representative person - must be valid + */ + LegalRepresentativeEmail: string; + + /** + * The date of birth of the company’s Legal representative person - be careful to set the right timezone (should be UTC) to avoid 00h becoming 23h (and hence interpreted as the day before) + */ + LegalRepresentativeBirthday: Timestamp; + + /** + * The nationality of the company’s Legal representative person + */ + LegalRepresentativeNationality: CountryISO; + + /** + * The country of residence of the company’s Legal representative person + */ + LegalRepresentativeCountryOfResidence: CountryISO; + ProofOfIdentity: string | null; + + /** + * The business statute of the company + */ + Statute: string | null; + + /** + * A MANGOPAY reference to the validated document of the proof of registration of the company + */ + ProofOfRegistration: string | null; + + /** + * The shareholder declaration of the company + */ + ShareholderDeclaration: string | null; + + /** + * The official registered number of the business + */ + CompanyNumber: string; + } + + interface UserNaturalData extends UserData { + PersonType: "NATURAL"; + + /** + * The name of the user + */ + FirstName: string; + + /** + * The last name of the user + */ + LastName: string; + + /** + * The user address + */ + Address: string | address.AddressData; + + /** + * The date of birth of the user - be careful to set the right timezone (should be UTC) to avoid 00h becoming 23h (and hence interpreted as the day before) + */ + Birthday: Timestamp; + + /** + * The user’s nationality. ISO 3166-1 alpha-2 format is expected + */ + Nationality: CountryISO; + + /** + * The user’s country of residence. ISO 3166-1 alpha-2 format is expected + */ + CountryOfResidence: CountryISO; + + /** + * User’s occupation, ie. Work + */ + Occupation: string; + IncomeRange: IncomeRange; + + /** + * Maximum length is 255 characters + */ + ProofOfIdentity: string | null; + + /** + * Maximum length is 255 characters + */ + ProofOfAddress: string | null; + + /** + * The capacity of this user - for use with UBO declarations + */ + Capacity: "NORMAL" | "DECLARATIVE"; + } + + type RequiredUserLegalData = + | "LegalPersonType" + | "Name" + | "LegalRepresentativeBirthday" + | "LegalRepresentativeCountryOfResidence" + | "LegalRepresentativeNationality" + | "LegalRepresentativeFirstName" + | "LegalRepresentativeLastName" + | "Email"; + + type RequiredUserNaturalData = + | "FirstName" + | "LastName" + | "Birthday" + | "Nationality" + | "CountryOfResidence" + | "Email"; + + interface BaseUserLegalData + extends PickPartial< + UserLegalData, + | RequiredUserLegalData + | "CompanyNumber" + | "LegalRepresentativeEmail" + | "LegalRepresentativeAddress" + | "HeadquartersAddress" + | "Tag" + > { + PersonType: "LEGAL"; + } + + interface UpdateUserLegalData extends BaseUserLegalData { + Id: string; + } + + interface CreateUserLegalData + extends MakeKeysRequired< + BaseUserLegalData, + RequiredUserLegalData | "PersonType" + > {} + + interface BaseUserNaturalData + extends PickPartial< + UserNaturalData, + RequiredUserNaturalData | "Address" | "Occupation" | "IncomeRange" + > { + PersonType: "NATURAL"; + } + + interface UpdateUserNaturalData extends BaseUserNaturalData { + Id: string; + } + + interface CreateUserNaturalData + extends MakeKeysRequired< + BaseUserNaturalData, + RequiredUserNaturalData | "PersonType" + > {} + } + + namespace payIn { + type PayInPaymentType = ValueOf; + type PayInExecutionType = + | ValueOf + | "EXTERNAL_INSTRUCTION"; + + interface TemplateURLOptions { + Payline: string; + } + + interface BasePayInData extends entityBase.EntityBaseData { + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Details about the funds that are being credited (DebitedFunds – Fees = CreditedFunds) + */ + CreditedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * The ID of the wallet that was debited + */ + DebitedWalletId: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId: string; + + /** + * The nature of the transaction + */ + Nature: transaction.TransactionNature; + + /** + * The status of the transaction + */ + Status: transaction.TransactionStatus; + + /** + * When the transaction happened + */ + ExecutionDate: Timestamp; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * The type of the transaction + */ + Type: transaction.TransactionType; + + /** + * The type of payin + */ + PaymentType: PayInPaymentType; + + /** + * The type of execution for the payin + */ + ExecutionType: PayInExecutionType; + } + + interface CardWebPayInData extends BasePayInData { + ExecutionType: "WEB"; + PaymentType: "CARD"; + + /** + * The URL to redirect to after payment (whether successful or not) + */ + ReturnURL: string; + + /** + * The type of card + */ + CardType: card.CardType; + + /** + * The SecureMode corresponds to '3D secure' for CB Visa and MasterCard. This field lets you activate it manually. The field lets you activate it + * automatically with "DEFAULT" (Secured Mode will be activated from €50 or when MANGOPAY detects there is a higher risk ), "FORCE" (if you wish to specifically force the secured mode). + */ + SecureMode: SecureMode; + + /** + * The language to use for the payment page - needs to be the ISO code of the language + */ + Culture: CountryISO; + + /** + * The URL to use for the payment page template + */ + TemplateURL: string; + + /** + * A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric characters or spaces. + * See here for important info. Note that each bank handles this information differently, some show less or no information. + */ + StatementDescriptor: string; + + /** + * The URL to redirect to user to for them to proceed with the payment + */ + RedirectURL: string; + } + + interface CreateCardWebPayIn { + ExecutionType: "WEB"; + PaymentType: "CARD"; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId?: string; + + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * The URL to redirect to after payment (whether successful or not) + */ + ReturnURL: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + + /** + * The type of card + */ + CardType: card.CardType; + + /** + * The SecureMode corresponds to '3D secure' for CB Visa and MasterCard. This field lets you activate it manually. + * The field lets you activate it automatically with "DEFAULT" (Secured Mode will be activated from €50 or when MANGOPAY detects + * there is a higher risk ), "FORCE" (if you wish to specifically force the secured mode). + */ + SecureMode?: SecureMode; + + /** + * The language to use for the payment page - needs to be the ISO code of the language + */ + Culture: CountryISO; + + /** + * A URL to an SSL page to allow you to customise the payment page. Must be in the format: array("PAYLINE"=>"https://...") and meet all the + * specifications listed here. Note that only a template for Payline is currently available + */ + TemplateURLOptions?: TemplateURLOptions; + + /** + * A custom description to appear on the user's bank statement. It can be up to 10 characters long, and + * can only include alphanumeric characters or spaces. See here for important info. Note that each bank handles this information differently, some show less or no information. + */ + StatementDescriptor?: string; + } + + interface CardDirectPayInData extends BasePayInData { + ExecutionType: "DIRECT"; + PaymentType: "CARD"; + + /** + * This is the URL where users are automatically redirected after 3D secure validation (if activated) + */ + SecureModeReturnURL: string; + + /** + * The ID of a card + */ + CardId: string; + + /** + * The SecureMode corresponds to '3D secure' for CB Visa and MasterCard. This field lets you activate it manually. The field lets you activate it + * automatically with "DEFAULT" (Secured Mode will be activated from €50 or when MANGOPAY detects there is a higher risk ), "FORCE" (if you wish to specifically force the secured mode). + */ + SecureMode: SecureMode; + + /** + * A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric + * characters or spaces. See here for important info. Note that each bank handles this information differently, some show less or no information. + */ + StatementDescriptor: string; + + /** + * Contains useful information related to the user billing + */ + Billing: BillingData; + + /** + * Contains information related to security and fraud + */ + SecurityInfo: SecurityInfoData; + + /** + * The value is 'true' if the SecureMode was used + */ + SecureModeNeeded: boolean; + + /** + * This is the URL where to redirect users to proceed to 3D secure validation + */ + SecureModeRedirectUrl: string; + } + + interface CreateCardDirectPayIn { + ExecutionType: "DIRECT"; + PaymentType: "CARD"; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId?: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * This is the URL where users are automatically redirected after 3D secure validation (if activated) + */ + SecureModeReturnURL: string; + + /** + * The ID of a card + */ + CardId: string; + + /** + * The SecureMode corresponds to '3D secure' for CB Visa and MasterCard. This field lets you activate it manually. The field lets you activate it automatically + * with "DEFAULT" (Secured Mode will be activated from €50 or when MANGOPAY detects there is a higher risk ), "FORCE" (if you wish to specifically force the secured mode). + */ + SecureMode?: SecureMode; + + /** + * Contains useful information related to the user billing + */ + Billing?: BillingData; + + /** + * A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric characters or spaces. + * See here for important info. Note that each bank handles this information differently, some show less or no information. + */ + StatementDescriptor?: string; + } + + interface CardPreAuthorizedPayInData extends BasePayInData { + PreauthorizationId: string; + ExecutionType: "DIRECT"; + PaymentType: "PREAUTHORIZED"; + } + + interface CreateCardPreAuthorizedPayIn { + ExecutionType: "DIRECT"; + PaymentType: "PREAUTHORIZED"; + + /** + * Custom data that you can add to this item + */ + Tag?: string; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId?: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * The ID of the Preauthorization object + */ + PreauthorizationId: string; + } + + interface BankAccountData { + /** + * The BIC of the bank account + */ + BIC: string; + + /** + * The IBAN of the bank account + */ + IBAN: string; + + /** + * The name of the owner of the bank account + */ + OwnerName: string; + + /** + * The address of the owner of the bank account + */ + OwnerAddress: string; + + /** + * The type of bank account + */ + Type: ValueOf; + } + + interface BankWireDirectPayInData extends BasePayInData { + ExecutionType: "DIRECT"; + PaymentType: "BANK_WIRE"; + + /** + * The declared debited funds + */ + DeclaredDebitedFunds: MoneyData; + + /** + * The declared fees + */ + DeclaredFees: MoneyData; + + /** + * Wire reference + */ + WireReference: string; + + /** + * Bank account details + */ + BankAccount: BankAccountData; + } + + interface CreateBankWireDirectPayIn + extends PickPartialRequired< + BankWireDirectPayInData, + "Tag", + | "AuthorId" + | "CreditedUserId" + | "CreditedWalletId" + | "DeclaredDebitedFunds" + | "DeclaredFees" + > { + ExecutionType: "DIRECT"; + PaymentType: "BANK_WIRE"; + } + + type PayInData = + | CardDirectPayInData + | CardPreAuthorizedPayInData + | CardWebPayInData + | BankWireDirectPayInData; + } + + namespace refund { + type RefundReasonType = + | "INITIALIZED_BY_CLIENT" + | "BANKACCOUNT_INCORRECT" + | "OWNER_DO_NOT_MATCH_BANKACCOUNT" + | "BANKACCOUNT_HAS_BEEN_CLOSED" + | "WITHDRAWAL_IMPOSSIBLE_ON_SAVINGS_ACCOUNTS" + | "OTHER"; + interface RefundReason { + RefundReasonType: RefundReasonType; + } + + interface RefundData extends transaction.TransactionData { + /** + * The nature of the transaction + */ + Nature: "REFUND"; + + /** + * The initial transaction ID + */ + InitialTransactionId: string; + + /** + * The initial transaction type + */ + InitialTransactionType: transaction.TransactionType; + + /** + * Contains info about the reason for refund + */ + RefundReason: RefundReason; + } + + interface CreatePayInRefund { + AuthorId: string; + Tag?: string; + DebitedFunds?: MoneyData; + Fees?: MoneyData; + } + + interface CreateTransferRefund { + AuthorId: string; + Tag?: string; + } + } + + namespace repudiation { + interface RepudiationData extends transaction.TransactionData { + /** + * The nature of the transaction + */ + Nature: "REPUDIATION"; + + /** + * The initial transaction ID + */ + InitialTransactionId: string; + + /** + * The initial transaction type + */ + InitialTransactionType: transaction.TransactionType; + + /** + * Contains info about the reason for refund + */ + RefundReason: refund.RefundReason; + } + } + + namespace client { + type BusinessType = "MARKETPLACE" | "CROWDFUNDING" | "FRANCHISE" | "OTHER"; + type Sector = + | "RENTALS" + | "STORES_FASHION_ACCESSORIES_OBJECTS" + | "BEAUTY_COSMETICS_HEALTH" + | "FOOD_WINE_RESTAURANTS" + | "HOSPITALITY_TRAVEL_CORIDING" + | "ART_MUSIC_ENTERTAINMENT" + | "FURNITURE_GARDEN" + | "SERVICES_JOBBING_EDUCATION" + | "SPORT_RECREATION_ACTIVITIES" + | "TICKETING"; + type PlatformType = ValueOf; + + interface PlatformCategorization { + Sector: Sector; + BusinessType: BusinessType; + } + + interface ClientData extends entityBase.EntityBaseData { + /** + * The pretty name for the client + */ + Name: string; + + /** + * The registered name of your company + */ + RegisteredName: string; + + /** + * An ID for the client (i.e. url friendly, lowercase etc - sort of namespace identifier) + */ + ClientId: string; + + /** + * The primary branding colour to use for your merchant + */ + PrimaryThemeColour: string; + + /** + * The primary branding colour to use for buttons for your merchant + */ + PrimaryButtonColour: string; + + /** + * The URL of the logo of your client + */ + Logo: string; + + /** + * A list of email addresses to use when contacting you for technical issues/communications + */ + TechEmails: string[]; + + /** + * A list of email addresses to use when contacting you for admin/commercial issues/communications + */ + AdminEmails: string[]; + + /** + * A list of email addresses to use when contacting you for fraud/compliance issues/communications + */ + FraudEmails: string[]; + + /** + * A list of email addresses to use when contacting you for billing issues/communications + */ + BillingEmails: string[]; + + /** + * The Categorization of your platform, in terms of Business Type and Sector + */ + PlatformCategorization: PlatformCategorization; + + /** + * A description of what your platform does + */ + PlatformDescription: string; + + /** + * The URL for your website + */ + PlatformURL: string; + + /** + * The address of the company’s headquarters + */ + HeadquartersAddress: address.AddressType; + + /** + * The tax (or VAT) number for your company + */ + TaxNumber: string; + + /** + * Your unique MANGOPAY reference which you should use when contacting us + */ + CompanyReference: string; + } + + interface UpdateClient { + /** + * The primary branding colour to use for buttons for your merchant + */ + PrimaryButtonColour?: string; + + /** + * The primary branding colour to use for your merchant + */ + PrimaryThemeColour?: string; + + /** + * A list of email addresses to use when contacting you for admin/commercial issues/communications + */ + AdminEmails?: string[]; + + /** + * A list of email addresses to use when contacting you for technical issues/communications + */ + TechEmails?: string[]; + + /** + * A list of email addresses to use when contacting you for billing issues/communications + */ + BillingEmails?: string[]; + + /** + * A list of email addresses to use when contacting you for fraud/compliance issues/communications + */ + FraudEmails?: string[]; + + /** + * The address of the company’s headquarters + */ + HeadquartersAddress?: address.AddressType; + + /** + * The tax (or VAT) number for your company + */ + TaxNumber?: string; + + /** + * The type of platform + */ + PlatformType?: PlatformType; + + /** + * A description of what your platform does + */ + PlatformDescription?: string; + + /** + * The URL for your website + */ + PlatformURL?: string; + } + + interface UpdateClientLogo { + /** + * The base64 encoded file which needs to be uploaded + */ + File: string; + } + } + + namespace event { + type EventType = + | "PAYIN_NORMAL_CREATED" + | "PAYIN_NORMAL_SUCCEEDED" + | "PAYIN_NORMAL_FAILED" + | "PAYOUT_NORMAL_CREATED" + | "PAYOUT_NORMAL_SUCCEEDED" + | "PAYOUT_NORMAL_FAILED" + | "TRANSFER_NORMAL_CREATED" + | "TRANSFER_NORMAL_SUCCEEDED" + | "TRANSFER_NORMAL_FAILED" + | "PAYIN_REFUND_CREATED" + | "PAYIN_REFUND_SUCCEEDED" + | "PAYIN_REFUND_FAILED" + | "PAYOUT_REFUND_CREATED" + | "PAYOUT_REFUND_SUCCEEDED" + | "PAYOUT_REFUND_FAILED" + | "TRANSFER_REFUND_CREATED" + | "TRANSFER_REFUND_SUCCEEDED" + | "TRANSFER_REFUND_FAILED" + | "KYC_CREATED" + | "KYC_VALIDATION_ASKED" + | "KYC_SUCCEEDED" + | "KYC_FAILED" + | "PAYIN_REPUDIATION_CREATED" + | "PAYIN_REPUDIATION_SUCCEEDED" + | "PAYIN_REPUDIATION_FAILED" + | "DISPUTE_DOCUMENT_CREATED" + | "DISPUTE_DOCUMENT_VALIDATION_ASKED" + | "DISPUTE_DOCUMENT_SUCCEEDED" + | "DISPUTE_DOCUMENT_FAILED" + | "DISPUTE_CREATED" + | "DISPUTE_SUBMITTED" + | "DISPUTE_ACTION_REQUIRED" + | "DISPUTE_FURTHER_ACTION_REQUIRED" + | "DISPUTE_CLOSED" + | "DISPUTE_SENT_TO_BANK" + | "TRANSFER_SETTLEMENT_CREATED" + | "TRANSFER_SETTLEMENT_SUCCEEDED" + | "TRANSFER_SETTLEMENT_FAILED" + | "MANDATE_CREATED" + | "MANDATE_FAILED" + | "MANDATE_ACTIVATED" + | "MANDATE_SUBMITTED" + | "PREAUTHORIZATION_PAYMENT_WAITING" + | "PREAUTHORIZATION_PAYMENT_EXPIRED" + | "PREAUTHORIZATION_PAYMENT_CANCELED" + | "PREAUTHORIZATION_PAYMENT_VALIDATED" + | "UBO_DECLARATION_CREATED" + | "UBO_DECLARATION_VALIDATION_ASKED" + | "UBO_DECLARATION_REFUSED" + | "UBO_DECLARATION_VALIDATED"; + + interface EventData { + /** + * The ID of whatever the event is + */ + ResourceId: string; + + /** + * When the event happened + */ + Date: Timestamp; + + /** + * The event type + */ + EventType: EventType; + } + } + + namespace dispute { + type DisputeReasonType = + | "DUPLICATE" + | "FRAUD" + | "PRODUCT_UNACCEPTABLE" + | "UNKNOWN" + | "OTHER" + | "REFUND_CONVERSION_RATE" + | "LATE_FAILURE_INSUFFICIENT_FUNDS" + | "LATE_FAILURE_CONTACT_USER" + | "LATE_FAILURE_BANKACCOUNT_CLOSED" + | "LATE_FAILURE_BANKACCOUNT_INCOMPATIBLE" + | "LATE_FAILURE_BANKACCOUNT_INCORRECT" + | "AUTHORISATION_DISPUTED" + | "TRANSACTION_NOT_RECOGNIZED" + | "PRODUCT_NOT_PROVIDED" + | "CANCELED_REOCCURING_TRANSACTION" + | "REFUND_NOT_PROCESSED"; + + type DisputeStatus = + | "CREATED" + | "PENDING_CLIENT_ACTION" + | "SUBMITTED" + | "PENDING_BANK_ACTION" + | "REOPENED_PENDING_CLIENT_ACTION" + | "CLOSED"; + + type DisputeType = "CONTESTABLE" | "NOT_CONTESTABLE" | "RETRIEVAL"; + + interface DisputeReason { + DisputeReasonType: DisputeReasonType; + DisputeReasonMessage: string; + } + + interface DisputeData extends entityBase.EntityBaseData { + /** + * The initial transaction ID + */ + InitialTransactionId: string; + + /** + * The initial transaction type + */ + InitialTransactionType: transaction.TransactionType; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * Info about the reason for the dispute + */ + DisputeReason: DisputeReason; + + /** + * The status of the dispute + */ + Status: DisputeStatus; + + /** + * Used to communicate information about the dispute status to you + */ + StatusMessage: string; + + /** + * The amount of funds that were disputed + */ + DisputedFunds: MoneyData; + + /** + * The amount you wish to contest + */ + ContestedFunds: MoneyData; + + /** + * The type of dispute + */ + DisputeType: DisputeType; + + /** + * The deadline by which you must contest the dispute (if you wish to contest it) + */ + ContestDeadlineDate: Timestamp; + + /** + * The ID of the associated repudiation transaction + */ + RepudiationId: string; + } + + interface SubmitDispute + extends PickPartial {} + + interface UpdateDispute extends PickPartial {} + } + + interface DisputeReason extends dispute.DisputeReason {} + + namespace settlementTransfer { + interface SettlementTransferData extends transaction.TransactionData { + /** + * The nature of the transaction + */ + Nature: "SETTLEMENT"; + + /** + * The ID of the associated repudiation transaction + */ + RepudiationId: string; + + /** + * The initial transaction ID + */ + InitialTransactionId: string; + + /** + * The initial transaction type + */ + InitialTransactionType: transaction.TransactionType; + + /** + * Contains info about the reason for refund + */ + RefundReason: refund.RefundReason; + } + + interface CreateSettlementTransfer + extends PickPartialRequired< + SettlementTransferData, + "Tag", + "AuthorId" | "DebitedFunds" | "Fees" + > {} + } + + namespace transfer { + interface TransferData extends entityBase.EntityBaseData { + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Details about the funds that are being credited (DebitedFunds – Fees = CreditedFunds) + */ + CreditedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * The ID of the wallet that was debited + */ + DebitedWalletId: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId: string; + + /** + * The nature of the transaction + */ + Nature: transaction.TransactionNature; + + /** + * The status of the transaction + */ + Status: transaction.TransactionStatus; + + /** + * When the transaction happened + */ + ExecutionDate: Timestamp; + + /** + * The result code + */ + ResultCode: string; + + /** + * A verbal explanation of the ResultCode + */ + ResultMessage: string; + + /** + * The type of the transaction + */ + Type: "TRANSFER"; + } + + interface CreateTransfer { + /** + * Custom data that you can add to this item + */ + Tag?: string; + + /** + * A user's ID + */ + AuthorId: string; + + /** + * The user ID who is credited (defaults to the owner of the wallet) + */ + CreditedUserId?: string; + + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * The ID of the wallet that was debited + */ + DebitedWalletId: string; + + /** + * The ID of the wallet where money will be credited + */ + CreditedWalletId: string; + } + } + + namespace PayOut { + interface PayOutData extends Omit { + /** + * The type of the transaction + */ + Type: "PAYOUT"; + + PaymentType: IPayOutPaymentType["BankWire"]; + + /** + * An ID of a Bank Account + */ + BankAccountId: string; + + /** + * A custom reference you wish to appear on the user’s bank statement (your Client Name is already shown). This reference can contain max 12 characters + */ + BankWireRef: string; + } + + interface CreatePayOut { + /** + * A user's ID + */ + AuthorId: string; + + /** + * Information about the funds that are being debited + */ + DebitedFunds: MoneyData; + + /** + * Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet) + */ + Fees: MoneyData; + + /** + * An ID of a Bank Account + */ + BankAccountId: string; + + /** + * The ID of the wallet that was debited + */ + DebitedWalletId: string; + + /** + * A custom reference you wish to appear on the user’s bank statement (your Client Name is already shown). This reference can contain max 12 characters + */ + BankWireRef?: string; + Tag?: string; + } + } + + class Users { + /** + * Create a new user + * @param user + */ + create: MethodOverload & + MethodOverload; + + /** + * Update a user + * @param user + * @param options + */ + update: MethodOverload< + models.UserLegal | user.UpdateUserLegalData, + user.UserLegalData + > & + MethodOverload< + models.UserNatural | user.UpdateUserNaturalData, + user.UserNaturalData + >; + + /** + * Get natural or legal user by ID + * @param userId + * @param options + */ + get: MethodOverload; + + /** + * Get natural user by ID + * @param userId + * @param options + */ + getNatural: MethodOverload; + + /** + * Get legal user by ID + * @param userId + * @param options + */ + getLegal: MethodOverload; + + /** + * Get all users + */ + getAll: NoArgMethodOverload< + Array + >; + + /** + * Create bank account for user + * @param userId + * @param bankAccount + * @param options + */ + createBankAccount: TwoArgsMethodOverload< + string, + bankAccount.USDetails, + bankAccount.USData + > & + TwoArgsMethodOverload< + string, + bankAccount.OtherDetails, + bankAccount.OtherData + > & + TwoArgsMethodOverload< + string, + bankAccount.IBANDetails, + bankAccount.IBANData + > & + TwoArgsMethodOverload & + TwoArgsMethodOverload; + + /** + * Deactivate a bank account + * + * Note that once deactivated, a bank account can't be reactivated afterwards + * @param userId + * @param bankAccountId + * @param options + */ + deactivateBankAccount: TwoArgsMethodOverload; + + /** + * Get all bank accounts for user + * @param userId + * @param options + */ + getBankAccounts: MethodOverload; + + /** + * Get all bank accounts for user + * @param userId + * @param bankAccountId + * @param options + */ + getBankAccount: TwoArgsMethodOverload; + + /** + * Get all wallets accounts for user + */ + getWallets: MethodOverload; + + /** + * Get all transactions for user + * @param userId + * @param options + */ + getTransactions: MethodOverload; + + /** + * Get all cards for user + * @param userId + * @param options + */ + getCards: MethodOverload; + + /** + * Create new KYC document + * @param userId + * @param kycDocument + * @param options + */ + createKycDocument: TwoArgsMethodOverload< + string, + kycDocument.CreateKycDocument, + kycDocument.KycDocumentData + >; + + /** + * Get all KYC documents for user + * @param userId + * @param options + */ + getKycDocuments: MethodOverload; + + /** + * Get KYC document + * @param userId + * @param kycDocumentId + * @param options + */ + getKycDocument: TwoArgsMethodOverload< + string, + string, + kycDocument.KycDocumentData + >; + + /** + * Update status of KYC Document (Currently only allows for submitting the document) + * @param userId + * @param kycDocument + * @param options + */ + updateKycDocument: TwoArgsMethodOverload< + string, + kycDocument.SubmitKycDocument, + kycDocument.KycDocumentData + >; + + /** + * Create page for KYC document + * @param userId + * @param kycDocumentId + * @param kycPage + * @param options + */ + createKycPage: ThreeArgsMethodOverload< + string, + string, + kycDocument.CreateKycPage, + kycDocument.KycDocumentData + >; + + /** + * Create page for KYC document + * @param userId + * @param kycDocumentId + * @param filePath + * @param options + */ + createKycPageFromFile: ThreeArgsMethodOverload< + string, + string, + string, + kycDocument.KycDocumentData + >; + + /** + * Get users's EMoney + * @param userId + * @param options + */ + getEMoney: MethodOverload; + + /** + * Create an UboDeclaration for the user + * @param userId + * @param uboDeclaration + * @param options + */ + createUboDeclaration: TwoArgsMethodOverload< + string, + uboDeclaration.CreateUboDeclaration, + uboDeclaration.UboDeclarationData + >; + + /** + * Get all user preauthorizations + * @param userId + * @param options + */ + getPreAuthorizations: MethodOverload< + string, + cardPreAuthorization.CardPreAuthorizationData[] + >; + } + + /** + * You need to create document in order to upload pages on this document. + * + * 1. The KYC Document Object is a request to validate a required document. There is one request for one Type of document + * 2. Upload a file through a Page. A document should get several pages + * 3. Edit the object Document and set the Status field to "VALIDATION_ASKED" (instead of "CREATED") + * 4. The demand is received by our team. The object is waiting for a "VALIDATED" status + * + * Note that you are not allowed to store KYC documents on your side unless you have permission from the approriate authorities in your country + */ + class KycDocuments { + /** + * Get all KycDocuments + * @param options + */ + getAll: NoArgMethodOverload; + + /** + * Get KycDocument + * @param kycDocumentId + * @param options + */ + get: MethodOverload; + + /** + * Creates temporary URLs where each page of a KYC document can be viewed. + * @param documentId + */ + createKycDocumentConsult: MethodOverload< + string, + any // Unsure of data structure from docs + >; + } + + /** + * An UBO Declaration is an electronic version of the previous KYC document "Shareholder Declaration", in order to declare all the Ultimate Beneficial Owners of a BUSINESS-typed legal User + * (ie the shareholders with >25% of capital or voting rights). + * + * 1. Create each Ultimate Beneficial Owner as a Natural User, who must have a "DECLARATIVE" Capacity. + * 2. Create a new UBO Declaration for your legal user, and link every Ultimate Beneficial Owners created previously thanks to DeclaredUBOs. + * - This list can be empty if your legal user has no Ultimate Beneficial Owner, or no eligible one (ie. no Ultimate Beneficial Owner that owns more than 25% of this company). + * 3. Edit the UBODeclaration object and set the Status field to "VALIDATION_ASKED" (instead of "CREATED") + * 4. The demand is received by our team and once processed, it will either get a "VALIDATED" status, or "REFUSED" with more information provided in the RefusedReasonTypes parameter + * + * Note that UBO declarations are not yet a requirement for your user to be KYC verified and are optional at this stage + */ + class UboDeclarations { + /** + * Retrieves a UBO declaration object from the API. + * @param id + * @param options + */ + get: MethodOverload; + + /** + * Updates a UBO declaration entity. + * @param uboDeclaration Updated UBO declaration entity - must have ID + * @param options + */ + update: MethodOverload< + uboDeclaration.UpdateUboDeclaration, + uboDeclaration.UboDeclarationData + >; + } + + class BankAccounts { + /** + * Retrieve list of transactions for a bank account + * @param bankAccountId + * @param options + */ + getTransactions: MethodOverload; + } + + class Wallets { + /** + * Create new wallet + * @param wallet + * @param options + */ + create: MethodOverload< + wallet.CreateWallet | models.Wallet, + wallet.WalletData + >; + + /** + * Update wallet + * @param wallet + * @param options + */ + update: MethodOverload< + wallet.UpdateWallet | models.Wallet, + wallet.WalletData + >; + + /** + * Get a specific wallet + * @param walletId + */ + get: MethodOverload; + + /** + * Get transactions for the wallet + * @param walletId + * @param options + */ + getTransactions: MethodOverload; + } + + class Cards { + /** + * Get card + * @param cardId + * @param ptions + */ + get: MethodOverload; + + /** + * Gets a list of cards having the same fingerprint. + * The fingerprint is a hash uniquely generated per 16-digit card number. + * + * @param fingerprint The fingerprint hash + */ + getByFingerprint: MethodOverload; + + /** + * Update card (currently only supports deactivation) + * @param card + * @param options + */ + update: MethodOverload; + + /** + * Get list of Transactions of a Card + * @param cardId + * @param options + */ + getTransactions: MethodOverload; + + /** + * Gets list of PreAuthorizations of a Card. + * @param cardId + * @param options + */ + getPreAuthorizations: MethodOverload< + string, + cardPreAuthorization.CardPreAuthorizationData[] + >; + } + + /** + * You need to register a card in order to process a Direct PayIn. Card registration enables you to tokenize a Card. These are the steps to follow: + * + * 1. Create a CardRegistration Object + * 2. Get a PreRegistrationData + * 3. The user posts PreRegistrationData, AccessKey and card details through a form (PHP & JS samples) to the CardRegistrationURL (5. in the diagram) + * 4. Get a RegistrationData back + * 5. Edit the CardRegistration Object (POST method) with the RegistrationData just received + * 6. Get the CardId ready to use into the Direct PayIn Object + * + * - If you don’t want to save the card you must change the field ACTIVE in the card object to false + */ + class CardRegistrations { + /** + * Create new card registration + * @param cardRegistration + * @param options + */ + create: MethodOverload< + cardRegistration.CreateCardRegistration, + cardRegistration.CardRegistrationData + >; + + /** + * Create new card registration + * @param cardRegistrationId + * @param options + */ + get: MethodOverload; + + /** + * Update card registration + * @param cardRegistration + */ + update: MethodOverload< + cardRegistration.UpdateCardRegistration, + cardRegistration.CardRegistrationData + >; + } + + /** + * The PreAuthorization Object ensures the solvency of a registered card for 7 days. The overall process is as follows: + * + * 1. Register a card (CardRegistration) + * 2. Create a PreAuthorization with the CardId. This allows you to charge an amount on a card + * 3. Charge the card through the PreAuthorized PayIn object (Payins/preauthorized/direct) + * + * How does PreAuthorization work? + * - Once the PreAuthorization object is created the Status is "CREATED" until 3D secure validation. + * - If the authorization is successful the status is "SUCCEEDED" if it failed the status is "FAILED". + * - Once Status = "SUCCEEDED" and PaymentStatus = "WAITING" you can charge the card. + * - The Pay-In amount has to be less than or equal to the amount authorized. + */ + class CardPreAuthorizations { + /** + * Create new pre-authorization + * @param cardPreAuthorization + * @param options + */ + create: MethodOverload< + cardPreAuthorization.CreateCardPreAuthorization, + cardPreAuthorization.CardPreAuthorizationData + >; + + /** + * Get data for Card pre-authorization + * @param cardPreAuthorizationId + * @param options + */ + get: MethodOverload; + + /** + * Update pre-authorization object (currently only supports cancellation) + * @param cardPreAuthorization + */ + update: MethodOverload< + cardPreAuthorization.UpdateCardPreAuthorization, + cardPreAuthorization.CardPreAuthorizationData + >; + } + + class PayIns { + /** + * Create new pay-in + * @param payIn + * @param options + */ + create: MethodOverload< + payIn.CreateCardDirectPayIn, + payIn.CardDirectPayInData + > & + MethodOverload< + payIn.CreateCardPreAuthorizedPayIn, + payIn.CardPreAuthorizedPayInData + > & + MethodOverload & + MethodOverload< + payIn.CreateBankWireDirectPayIn, + payIn.BankWireDirectPayInData + >; + + /** + * Get pay-in + * @param payInId + * @param options + */ + get: MethodOverload; + + /** + * Create refund for pay-in object + * @param payInId + * @param refundData + * @param options + */ + createRefund: TwoArgsMethodOverload< + string, + refund.CreatePayInRefund, + refund.RefundData + >; + + /** + * Gets list of Refunds for a PayIn + * @param payInId + * @param options + */ + getRefunds: MethodOverload; + } + + class Refunds { + /** + * Get events + * @param refundId + * @param options + */ + get: MethodOverload; + } + + class Clients { + /** + * Get the client + */ + get: NoArgMethodOverload; + + /** + * Update the client + * @param client + * @param options + */ + update: MethodOverload; + + /** + * Upload client logo from base64 image string + * @param base64Logo + * @param options + */ + uploadLogo: MethodOverload; + + /** + * Upload client logo from file path + * @param filePath + * @param options + */ + uploadLogoFromFile: MethodOverload; + + /** + * Get all client wallets + * @param options + */ + getClientWallets: NoArgMethodOverload; + + /** + * Get a client wallet + * @param fundsType + * @param currency + * @param options + */ + getClientWallet: TwoArgsMethodOverload< + wallet.ClientFundsType, + CurrencyISO, + wallet.ClientWalletData + >; + + /** + * Get client wallets by the type of funds + * @param fundsType + * @param options + */ + getClientWalletsByFundsType: MethodOverload< + wallet.ClientFundsType, + wallet.ClientWalletData[] + >; + + /** + * Get a client wallet's transactions + * @param fundsType + * @param currency + * @param options + */ + getClientWalletTransactions: TwoArgsMethodOverload< + wallet.ClientFundsType, + CurrencyISO, + transaction.TransactionData[] + >; + } + + class PayOuts { + /** + * Create new pay-out + * @param payOut + * @param options + */ + create: MethodOverload; + + /** + * Get payout + * @param payOutId + * @param options + */ + get: MethodOverload; + + /** + * Gets list of Refunds of a PayOut + * @param payOutId + * @param options + */ + getRefunds: MethodOverload; + } + + class Transfers { + /** + * Create new transfer + * @param transfer + * @param options + */ + create: MethodOverload; + + /** + * Get transfer + * @param transferId + * @param options + */ + get: MethodOverload; + + /** + * Create refund for transfer object + * @param transferId + * @param refund + * @param options + */ + createRefund: TwoArgsMethodOverload< + string, + refund.CreateTransferRefund, + refund.RefundData + >; + + /** + * Gets list of Refunds of a Transfer + * @param transferId + * @param options + */ + getRefunds: MethodOverload; + } + + class BankingAliases { + /** + * Create a banking alias + * @param bankingAlias + * @param options + */ + create: MethodOverload< + bankingAlias.CreateIBANBankingAlias, + bankingAlias.IBANBankingAliasData + >; + + /** + * Get a banking alias + * @param bankingAliasId + * @param options + */ + get: MethodOverload; + + /** + * Get all banking aliases + * @param options + */ + getAll: NoArgMethodOverload; + + /** + * Update banking alias + * @param bankingAliasId + * @param options + */ + update: MethodOverload< + Partial>, + bankingAlias.IBANBankingAliasData + >; + + /** + * Deactivate banking alias + * @param bankingAliasId + * @param options + */ + deactivate: MethodOverload; + + /** + * Activate banking alias + * @param bankingAliasId + * @param options + */ + activate: MethodOverload; + } + + class DisputeDocuments { + /** + * Get all KycDocuments + * @param options + */ + getAll: NoArgMethodOverload; + + /** + * Get KycDocument + * @param documentId + * @param options + */ + get: MethodOverload; + + /** + * Creates temporary URLs where each page of a KYC document can be viewed. + * @param documentId + */ + createDisputeDocumentConsult: MethodOverload< + string, + any // Unsure of data structure from docs + >; + } + + class Repudiations { + /** + * Gets list of Refunds of a Repudiation + * @param repudiationId + * @param options + */ + getRefunds: MethodOverload; + } + + class Disputes { + /** + * Get dispute + * @param disputeId + * @param options + */ + get: MethodOverload; + + /** + * Get all disputes + * @param options + */ + getAll: NoArgMethodOverload; + + /** + * Update dispute's tag + * @param dispute + * @param options + */ + update: MethodOverload; + + /** + * Contest dispute + * @param disputeId + * @param contestedFunds + * @param options + */ + contestDispute: TwoArgsMethodOverload< + string, + MoneyData, + dispute.DisputeData + >; + + /** + * This method is used to resubmit a Dispute if it is reopened requiring more docs + * @param disputeId + * @param options + */ + resubmitDispute: MethodOverload; + + /** + * Close dispute + * @param disputeId + * @param options + */ + closeDispute: MethodOverload; + + /** + * Gets dispute's transactions + * @param disputeId + * @param options + */ + getTransactions: MethodOverload; + + /** + * Gets dispute's documents for wallet + * @param walletId + * @param options + */ + getDisputesForWallet: MethodOverload; + + /** + * Gets user's disputes + * @param userId + * @param options + */ + getDisputesForUser: MethodOverload; + + /** + * Gets repudiation + * @param repudiationId + * @param options + */ + getRepudiation: MethodOverload; + + /** + * Creates settlement transfer + * @param settlementTransfer + * @param repudiationId + * @param options + */ + createSettlementTransfer: TwoArgsMethodOverload< + settlementTransfer.CreateSettlementTransfer, + string, + settlementTransfer.SettlementTransferData + >; + + /** + * Gets settlement transfer + * @param settlementTransferId + * @param options + */ + getSettlementTransfer: MethodOverload< + string, + settlementTransfer.SettlementTransferData + >; + + /** + * Gets documents for dispute + * @param disputeId + * @param options + */ + getDocumentsForDispute: MethodOverload< + string, + disputeDocument.DisputeDocumentData[] + >; + + /** + * Update dispute document + * @param disputeId + * @param disputeDocument + * @param options + */ + updateDisputeDocument: TwoArgsMethodOverload< + string, + Partial, + disputeDocument.DisputeDocumentData + >; + + /** + * Creates document for dispute + * @param disputeId + * @param disputeDocument + * @param options + */ + createDisputeDocument: TwoArgsMethodOverload< + string, + disputeDocument.CreateDisputeDocument, + disputeDocument.DisputeDocumentData + >; + + /** + * Creates document's page for dispute + * @param disputeId + * @param disputeDocumentId + * @param disputeDocumentPage + * @param options + */ + createDisputeDocumentPage: ThreeArgsMethodOverload< + string, + string, + disputeDocument.CreateDisputeDocumentPage, + disputeDocument.DisputeDocumentData + >; + + /** + * Creates document's page for dispute from file + * @param disputeId + * @param disputeDocumentId + * @param file + * @param options + */ + createDisputeDocumentPageFromFile: ThreeArgsMethodOverload< + string, + string, + string, + disputeDocument.DisputeDocumentData + >; + + /** + * Retrieve a list of Disputes pending settlement + * @param options + */ + getPendingSettlement: NoArgMethodOverload; + } + + class Events { + /** + * Get events + * @param options + */ + getAll: NoArgMethodOverload; + } + + class Responses { + /** + * Get response from previous call + * @param options + */ + get: NoArgMethodOverload; + } + + class Mandates { + /** + * Create a new Mandate + * @param mandate + * @param options + */ + create: MethodOverload; + + /** + * Get all mandates + * @param options + */ + getAll: NoArgMethodOverload; + + /** + * Get mandate by ID + * @param mandateId + * @param options + */ + get: MethodOverload; + + /** + * Cancel a mandate + * @param mandateId + * @param options + */ + cancel: MethodOverload; + + /** + * Gets user's mandates + * @param userId + * @param options + */ + getMandatesForUser: MethodOverload; + + /** + * Gets bank account mandates + * @param userId + * @param bankAccountId + * @param options + */ + getMandatesForBankAccount: TwoArgsMethodOverload< + string, + string, + mandate.MandateData[] + >; + + /** + * Gets Transactions for a Mandate + * @param mandateId + * @param options + */ + getTransactions: MethodOverload; + } + class Hooks { + /** + * Create new hook + * @param hook + * @param options + */ + create: MethodOverload; + + /** + * Get hook + * @param hookId + * @param options + */ + get: MethodOverload; + + /** + * Save hook + * @param hook + * @param options + */ + update: MethodOverload; + + /** + * Get all hooks + * @param options + */ + getAll: NoArgMethodOverload; + } + + class Reports { + /** + * Create a report + * @param report + * @param options + */ + create: MethodOverload; + + /** + * Get a report + * @param reportId + * @param options + */ + get: MethodOverload; + + /** + * Get all reports + * @param options + */ + getAll: NoArgMethodOverload; + } +} diff --git a/types/mangopay2-nodejs-sdk/mangopay2-nodejs-sdk-tests.ts b/types/mangopay2-nodejs-sdk/mangopay2-nodejs-sdk-tests.ts new file mode 100644 index 0000000000..ba15315ce7 --- /dev/null +++ b/types/mangopay2-nodejs-sdk/mangopay2-nodejs-sdk-tests.ts @@ -0,0 +1,721 @@ +import Mangopay = require("mangopay2-nodejs-sdk"); + +// $ExpectError +const invalidConfig: Mangopay.Config = {}; + +/* General Types */ + +const validConfig: Mangopay.Config = { + clientId: "your_client_id", + clientApiKey: "your_client_api_key", + baseUrl: "https://api.mangopay.com" +}; + +const api = new Mangopay(validConfig); // IGNORE-TEST $ExpectType MangoPay +const payIn: Mangopay.models.PayIn = new api.models.PayIn({}); // IGNORE-TEST $ExpectType PayIn +const address: Mangopay.models.Address = new api.models.Address({}); // IGNORE-TEST $ExpectType Address + +const addressData: Mangopay.address.AddressData = { + AddressLine1: "20 T Street", + AddressLine2: "", + City: "London", + Country: "UK", + PostalCode: "FR43 2WE", + Region: "London" +}; + +/* Users */ + +const legalUser = new api.models.UserLegal({ + Name: "MangoPay", + Email: "info@mangopay.com", + LegalPersonType: "BUSINESS", + LegalRepresentativeFirstName: "Mango", + LegalRepresentativeLastName: "Pay", + LegalRepresentativeEmail: "mango@mangopay.com", + HeadquartersAddress: new api.models.Address({ + AddressLine1: "4101 Reservoir Rd NW", + AddressLine2: "", + City: "Washington", + Region: "District of Columbia", + PostalCode: "20007", + Country: "US" + }), + LegalRepresentativeBirthday: 1300186358, + LegalRepresentativeNationality: "FR", + LegalRepresentativeCountryOfResidence: "FR", + Tag: "custom tag" +}); + +api.Users.create(legalUser).then(data => { + const d = data; // IGNORE-TEST $ExpectType UserLegalData + const value = data.PersonType; // IGNORE-TEST $ExpectType "LEGAL" + + console.log(`${legalUser.Name} user created at ${legalUser.CreationDate}`); +}); + +api.Users.create(legalUser, { readResponseHeaders: true }).then(data => { + const d = data; // IGNORE-TEST $ExpectType WithResponse + const value = data.body; // IGNORE-TEST $ExpectType UserLegalData +}); + +api.Users.create( + { + PersonType: "LEGAL", + Name: "MangoPay", + Email: "info@mangopay.com", + LegalPersonType: "BUSINESS", + LegalRepresentativeFirstName: "Mango", + LegalRepresentativeLastName: "Pay", + LegalRepresentativeEmail: "mango@mangopay.com", + HeadquartersAddress: new api.models.Address({ + AddressLine1: "4101 Reservoir Rd NW", + AddressLine2: "", + City: "Washington", + Region: "District of Columbia", + PostalCode: "20007", + Country: "US" + }), + LegalRepresentativeBirthday: 1300186358, + LegalRepresentativeNationality: "FR", + LegalRepresentativeCountryOfResidence: "FR", + Tag: "custom tag" + }, + { headers: {} } +).then(data => { + const d = data; // IGNORE-TEST $ExpectType UserLegalData +}); + +const naturalUser = new api.models.UserNatural({ + Email: "info@mangopay.com", + Birthday: 1300186358, + FirstName: "Sara", + LastName: "McNick", + CountryOfResidence: "GB", + Nationality: "US" +}); + +api.Users.create(naturalUser, {}).then(data => { + const d = data; // IGNORE-TEST $ExpectType UserNaturalData + const value = data.PersonType; // IGNORE-TEST $ExpectType "NATURAL" + return; +}); + +api.Users.create( + { + PersonType: "NATURAL", + Email: "info@mangopay.com", + Birthday: 1300186358, + FirstName: "Sara", + LastName: "McNick", + CountryOfResidence: "GB", + Nationality: "US" + }, + data => { + const d = data; // IGNORE-TEST $ExpectType UserNaturalData + console.log("create", data); + } +); + +api.Users.get("1234").then(data => { + const d = data; // IGNORE-TEST $ExpectType UserLegalData | UserNaturalData + if (data.PersonType === "LEGAL") { + const legalData = data; // IGNORE-TEST $ExpectType UserLegalData + } else { + const naturalData = data; // IGNORE-TEST $ExpectType UserNaturalData + } +}); + +api.Users.getAll().then(users => { + users.forEach(user => { + const d = user; // IGNORE-TEST $ExpectType UserLegalData | UserNaturalData + if (user.PersonType === "LEGAL") { + const legalData = user; // IGNORE-TEST $ExpectType UserLegalData + } else { + const naturalData = user; // IGNORE-TEST $ExpectType UserNaturalData + } + }); +}); + +api.Users.update({ + Id: "1234", + PersonType: "NATURAL", + Email: "info@mangopay.com", + Birthday: 1300186358, + FirstName: "Sara", + LastName: "McNick", + CountryOfResidence: "GB", + Nationality: "US" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType UserNaturalData +}); + +api.Users.createBankAccount("user-id", { + Type: "GB", + AccountNumber: "12345678", + SortCode: "123456", + OwnerAddress: "", + OwnerName: "" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType GBData +}); + +api.Users.getBankAccount("user-id", "bankAccount-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType Data +}); + +api.Users.getBankAccounts("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType Data[] +}); + +api.Users.deactivateBankAccount("user-id", "bankAccount-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType void +}); + +api.Users.getTransactions("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransactionData[] +}); + +api.Users.getWallets("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType WalletData[] +}); + +api.Users.getCards("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType CardData[] +}); + +api.Users.createKycDocument("user-id", { Type: "ADDRESS_PROOF" }).then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData +}); + +api.Users.getKycDocuments("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData[] +}); + +api.Users.getKycDocument("user-id", "kycDocument-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData +}); + +api.Users.updateKycDocument("user-id", { Status: "VALIDATION_ASKED" }).then( + data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData + } +); + +api.Users.createKycPage("user-id", "kycDocument-id", { + File: "...base64data..." +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData +}); + +api.Users.createKycPageFromFile( + "user-id", + "kyc-document-id", + "path/to/file" +).then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData +}); + +// MangoPay. + +api.Users.getEMoney("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType EMoneyData +}); + +api.Users.createUboDeclaration("user-id", { DeclaredUBOs: ["user1"] }).then( + data => { + const d = data; // IGNORE-TEST $ExpectType UboDeclarationData + } +); + +api.Users.getPreAuthorizations("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType CardPreAuthorizationData[] +}); + +/* KycDocuments */ + +api.KycDocuments.getAll().then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData[] +}); + +api.KycDocuments.get("kyc-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType KycDocumentData +}); + +api.KycDocuments.createKycDocumentConsult("kyc-id").then(data => { + const d = data; // TODO unsure of expected type +}); + +/* UboDeclarations */ + +api.UboDeclarations.get("ubo-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType UboDeclarationData +}); + +api.UboDeclarations.update({ + Id: "ubo-id", + DeclaredUBOs: ["user1", "user2"] +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType UboDeclarationData +}); + +/* BankAccounts */ + +api.BankAccounts.getTransactions("account-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransactionData[] +}); + +/* Wallets */ + +api.Wallets.create({ + Currency: "GBP", + Description: "A description", + Owners: ["user-id"] +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType WalletData +}); + +const wallet = new api.models.Wallet({ + Currency: "GB", + Description: "A description", + Owners: ["user-id"] +}); + +api.Wallets.create(wallet).then(data => { + const d = data; // IGNORE-TEST $ExpectType WalletData +}); + +api.Wallets.update({ + Description: "A description" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType WalletData +}); + +api.Wallets.get("wallet-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType WalletData +}); + +api.Wallets.getTransactions("wallet-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransactionData[] +}); + +/* Cards */ + +api.Cards.get("card-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType CardData +}); + +api.Cards.getByFingerprint("fingerprinthash").then(data => { + const d = data; // IGNORE-TEST $ExpectType CardData[] +}); + +api.Cards.update({ Active: false, Id: "card-id" }).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardData +}); + +api.Cards.getTransactions("card-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransactionData[] +}); + +/* CardRegistrations */ + +api.CardRegistrations.create({ + CardType: "BCMC", + Currency: "GBP", + UserId: "user-id" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardRegistrationData +}); + +api.CardRegistrations.get("reg-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType CardRegistrationData +}); + +api.CardRegistrations.update({ RegistrationData: "hmmm" }).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardRegistrationData +}); + +/* CardPreAuthorizations */ + +api.CardPreAuthorizations.create({ + AuthorId: "user", + CardId: "card-id", + DebitedFunds: { Currency: "AUD", Amount: 4000 }, + SecureModeReturnURL: "https://secureurl.com" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardPreAuthorizationData +}); + +api.CardPreAuthorizations.get("auth-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType CardPreAuthorizationData +}); + +api.CardPreAuthorizations.update({ + Id: "auth-id", + PaymentStatus: "CANCELED" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardPreAuthorizationData +}); + +/* Refunds */ + +api.Refunds.get("refund-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType RefundData +}); + +/* PayIns */ + +api.PayIns.create({ + PaymentType: "CARD", + ExecutionType: "DIRECT", + AuthorId: "user-id", + CardId: "card-id", + CreditedWalletId: "wallet-id", + Fees: { Amount: 100, Currency: "GBP" }, + DebitedFunds: { Amount: 2000, Currency: "GBP" }, + SecureModeReturnURL: "https://secure-return.co" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardDirectPayInData +}); + +api.PayIns.create({ + PaymentType: "CARD", + ExecutionType: "WEB", + AuthorId: "user-id", + CreditedWalletId: "wallet-id", + Fees: { Amount: 100, Currency: "GBP" }, + DebitedFunds: { Amount: 2000, Currency: "GBP" }, + ReturnURL: "https://secure-return.co", + Culture: "AD", + CardType: "MAESTRO" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType CardWebPayInData +}); + +api.PayIns.create({ + PaymentType: "BANK_WIRE", + ExecutionType: "DIRECT", + AuthorId: "user-id", + CreditedWalletId: "wallet-id", + CreditedUserId: "credited-user-id", + DeclaredDebitedFunds: { Amount: 10000, Currency: "GBP" }, + DeclaredFees: { Amount: 500, Currency: "GBP" } +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType BankWireDirectPayInData +}); + +api.PayIns.get("payin-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType PayInData +}); + +api.PayIns.createRefund("payin-id", { AuthorId: "user-id" }).then(data => { + const d = data; // IGNORE-TEST $ExpectType RefundData +}); + +api.PayIns.getRefunds("payin-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType RefundData[] +}); + +/* Clients */ +api.Clients.get().then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientData +}); + +api.Clients.update({ PlatformType: "CROWDFUNDING_DONATION" }).then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientData +}); + +api.Clients.uploadLogo("...logobase64...").then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientData +}); + +api.Clients.uploadLogoFromFile("path/to/file").then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientData +}); + +api.Clients.getClientWallets().then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientWalletData[] +}); + +api.Clients.getClientWallet("CREDIT", "GBP").then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientWalletData +}); + +api.Clients.getClientWalletsByFundsType("FEES").then(data => { + const d = data; // IGNORE-TEST $ExpectType ClientWalletData[] +}); + +api.Clients.getClientWalletTransactions("CREDIT", "GBP").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransactionData[] +}); + +/* PayOuts */ + +api.PayOuts.create({ + Fees: { Amount: 0, Currency: "GBP" }, + AuthorId: "user-id", + DebitedFunds: { Amount: 2000, Currency: "GBP" }, + BankAccountId: "bank-id", + DebitedWalletId: "wallet-id" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType PayOutData +}); + +api.PayOuts.get("payout-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType PayOutData +}); + +api.PayOuts.getRefunds("payout-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType RefundData[] +}); + +/* Transfers */ + +api.Transfers.create({ + Fees: { Amount: 0, Currency: "GBP" }, + AuthorId: "user-id", + DebitedFunds: { Amount: 2000, Currency: "GBP" }, + DebitedWalletId: "debit-wallet-id", + CreditedWalletId: "credit-wallet-id" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType TransferData +}); + +api.Transfers.get("transfer-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransferData +}); + +api.Transfers.createRefund("transfer-id", { AuthorId: "user-id" }).then( + data => { + const d = data; // IGNORE-TEST $ExpectType RefundData + } +); + +api.Transfers.getRefunds("transfer-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType RefundData[] +}); + +/* BankingAliases */ + +api.BankingAliases.create({ + Country: "GB", + CreditedUserId: "user-id", + OwnerName: "owner-id" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType IBANBankingAliasData +}); +api.BankingAliases.get("alias-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType IBANBankingAliasData +}); +api.BankingAliases.getAll().then(data => { + const d = data; // IGNORE-TEST $ExpectType IBANBankingAliasData[] +}); +api.BankingAliases.update({ OwnerName: "some-name" }).then(data => { + const d = data; // IGNORE-TEST $ExpectType IBANBankingAliasData +}); +api.BankingAliases.deactivate("alias-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType IBANBankingAliasData +}); +api.BankingAliases.activate("alias-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType IBANBankingAliasData +}); + +/* DisputeDocuments */ + +api.DisputeDocuments.getAll().then(data => { + const d = data; // IGNORE-TEST $ExpectType DisputeDocumentData[] +}); + +api.DisputeDocuments.get("dispute-doc-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType DisputeDocumentData +}); + +api.DisputeDocuments.createDisputeDocumentConsult("dispute-doc-id").then( + data => { + const d = data; // TODO unsure of expected type + } +); + +/* Repudiations */ + +api.Repudiations.getRefunds("repudiation-id").then(data => { + const d = data; // $Expect RefundData[] +}); + +/* Disputes */ + +api.Disputes.get("dispute-id").then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.getAll().then(data => { + const d = data; // $Expect DisputeData[] +}); + +api.Disputes.update({ Tag: "any tags" }).then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.contestDispute("dispute-id", { + Amount: 1000, + Currency: "GBP" +}).then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.resubmitDispute("dispute-id").then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.closeDispute("dispute-id").then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.getTransactions("dispute-id").then(data => { + const d = data; // $Expect TransactionData[] +}); + +api.Disputes.getDisputesForWallet("wallet-id").then(data => { + const d = data; // $Expect DisputeData[] +}); + +api.Disputes.getDisputesForUser("user-id").then(data => { + const d = data; // $Expect DisputeData[] +}); + +api.Disputes.getRepudiation("repudiation-id").then(data => { + const d = data; // $Expect RepudationData +}); + +api.Disputes.createSettlementTransfer( + { + AuthorId: "user-id", + DebitedFunds: { Amount: 1000, Currency: "GBP" }, + Fees: { Amount: 200, Currency: "GBP" } + }, + "repudiation-id" +).then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.getSettlementTransfer("settlement-id").then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.getDocumentsForDispute("dispute-id").then(data => { + const d = data; // $Expect DisputeDocumentData[] +}); + +api.Disputes.updateDisputeDocument("dispute-id", { Tag: "update" }).then( + data => { + const d = data; // $Expect DisputeDocumentData + } +); + +api.Disputes.createDisputeDocument("dispute-id", { + Type: "DELIVERY_PROOF" +}).then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.createDisputeDocumentPage("dispute-id", "dispute-doc-id", { + File: "...base64string..." +}).then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.createDisputeDocumentPageFromFile( + "dispute-id", + "dispute-doc-id", + "path/to/file" +).then(data => { + const d = data; // $Expect DisputeData +}); + +api.Disputes.getPendingSettlement().then(data => { + const d = data; // $Expect DisputeData +}); + +/* Events */ + +api.Events.getAll().then(data => { + const d = data; // $Expect EventData[] +}); + +/* Responses */ + +api.Responses.get().then(data => { + const d = data; // IGNORE-TEST $ExpectType any[] +}); + +/* Mandates */ + +api.Mandates.create({ + BankAccountId: "bank-account-id", + ReturnURL: "https://return-url.com", + Culture: "EN" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType MandateData +}); + +api.Mandates.getAll().then(data => { + const d = data; // IGNORE-TEST $ExpectType MandateData[] +}); + +api.Mandates.get("mandate-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType MandateData +}); + +api.Mandates.cancel("mandate-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType MandateData +}); + +api.Mandates.getMandatesForUser("user-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType MandateData[] +}); + +api.Mandates.getMandatesForBankAccount("user-id", "bank-account-id").then( + data => { + const d = data; // IGNORE-TEST $ExpectType MandateData[] + } +); +api.Mandates.getTransactions("mandate-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType TransactionData[] +}); + +/* Hooks */ + +api.Hooks.create({ + Url: "https://hook-url.com", + EventType: "DISPUTE_ACTION_REQUIRED" +}).then(data => { + const d = data; // IGNORE-TEST $ExpectType HookData +}); + +api.Hooks.get("hook-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType HookData +}); + +api.Hooks.update({ Id: "hook-id", Url: "https://new-hook.com/hooks" }).then( + data => { + const d = data; // IGNORE-TEST $ExpectType HookData + } +); + +api.Hooks.getAll().then(data => { + const d = data; // IGNORE-TEST $ExpectType HookData[] +}); + +/* Reports */ + +api.Reports.create({ Columns: ["Alias", "AuthorId"] }).then(data => { + const d = data; // IGNORE-TEST $ExpectType ReportData +}); + +api.Reports.get("report-id").then(data => { + const d = data; // IGNORE-TEST $ExpectType ReportData +}); + +api.Reports.getAll().then(data => { + const d = data; // IGNORE-TEST $ExpectType ReportData[] +}); diff --git a/types/mangopay2-nodejs-sdk/tsconfig.json b/types/mangopay2-nodejs-sdk/tsconfig.json new file mode 100644 index 0000000000..5ff752d7e4 --- /dev/null +++ b/types/mangopay2-nodejs-sdk/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noEmit": true, + "lib": ["es6"], + "noUnusedLocals": false, + "noUnusedParameters": false, + "forceConsistentCasingInFileNames": true, + "experimentalDecorators": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "types": [], + "typeRoots": ["../"] + }, + + "files": ["index.d.ts", "types.d.ts", "mangopay2-nodejs-sdk-tests.ts"] +} diff --git a/types/mangopay2-nodejs-sdk/tslint.json b/types/mangopay2-nodejs-sdk/tslint.json new file mode 100644 index 0000000000..c31797feab --- /dev/null +++ b/types/mangopay2-nodejs-sdk/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-redundant-jsdoc": false, + "no-misused-new": false, + "no-empty-interface": false, + "interface-name": false, + "no-unnecessary-class": false + } +} diff --git a/types/mangopay2-nodejs-sdk/types.d.ts b/types/mangopay2-nodejs-sdk/types.d.ts new file mode 100644 index 0000000000..1edb7bd4f2 --- /dev/null +++ b/types/mangopay2-nodejs-sdk/types.d.ts @@ -0,0 +1,565 @@ +/** + * Makes specified keys of an interface Optional. + */ +export type MakeKeysOptional = Omit & + Partial>; + +export type PickPartial = Pick, Par>; + +export type PickPartialRequired< + T, + Par extends keyof T, + Req extends keyof T +> = Pick, Par> & Pick, Req>; + +export type DeepPartial = { [P in keyof T]?: DeepPartial }; + +/** + * Makes specified keys of an interface nullable. + */ +export type MakeKeysNullable = Omit & + { [P in T2]: T1[P] | null }; + +/** + * Makes specified keys of an interface Required. + */ +export type MakeKeysRequired = Omit & + Required>; + +export type Omit = Pick>; + +export type OmitType = Omit; + +export type ValueOf = T[keyof T]; + +export type ApiMethod = + | "authentication_oauth" + | "responses_get" + | "events_all" + | "hooks_create" + | "hooks_all" + | "hooks_get" + | "hooks_save" + | "cardregistration_create" + | "cardregistration_get" + | "cardregistration_save" + | "preauthorization_create" + | "preauthorization_get" + | "preauthorization_save" + | "preauthorizations_get_for_user" + | "card_get" + | "cards_get_by_fingerprint" + | "card_save" + | "card_get_preauthorizations" + | "payins_card-web_create" + | "payins_card-direct_create" + | "payins_preauthorized-direct_create" + | "payins_bankwire-direct_create" + | "payins_directdebit-web_create" + | "payins_directdebit-direct_create" + | "payins_paypal-web_create" + | "payins_get" + | "payins_createrefunds" + | "payouts_bankwire_create" + | "payouts_get" + | "refunds_get" + | "refunds_get_for_repudiation" + | "refunds_get_for_transfer" + | "refunds_get_for_payin" + | "refunds_get_for_payout" + | "transfers_create" + | "transfers_get" + | "transfers_createrefunds" + | "users_createnaturals" + | "users_createlegals" + | "users_createbankaccounts_iban" + | "users_createbankaccounts_gb" + | "users_createbankaccounts_us" + | "users_createbankaccounts_ca" + | "users_createbankaccounts_other" + | "users_all" + | "users_allwallets" + | "users_allbankaccount" + | "users_allcards" + | "users_alltransactions" + | "users_allkycdocuments" + | "users_get" + | "users_getnaturals" + | "users_getlegals" + | "users_getbankaccount" + | "users_deactivate_bankaccount" + | "users_savenaturals" + | "users_savelegals" + | "users_getemoney" + | "wallets_create" + | "wallets_alltransactions" + | "wallets_get" + | "wallets_save" + | "kyc_documents_create" + | "kyc_documents_get" + | "kyc_documents_save" + | "kyc_page_create" + | "kyc_documents_all" + | "kyc_documents_get_alt" + | "kyc_documents_create_consult" + | "disputes_get" + | "disputes_save_tag" + | "disputes_save_contest_funds" + | "dispute_save_close" + | "disputes_get_transactions" + | "disputes_all" + | "disputes_get_for_wallet" + | "disputes_get_for_user" + | "disputes_document_create" + | "disputes_document_page_create" + | "disputes_document_save" + | "disputes_document_get" + | "disputes_document_get_for_dispute" + | "disputes_document_all" + | "disputes_document_create_consult" + | "disputes_repudiation_get" + | "disputes_repudiation_create_settlement" + | "disputes_repudiation_get_settlement" + | "disputes_pending_settlement" + | "reports_transaction_create" + | "reports_wallet_create" + | "reports_get" + | "reports_all" + | "mandates_directdebit-web_create" + | "mandates_get" + | "mandates_cancel" + | "mandates_all" + | "mandates_get_for_user" + | "mandates_get_for_bank_account" + | "clients_get" + | "clients_update" + | "clients_upload_logo" + | "client_wallets_all" + | "client_wallets_get" + | "client_wallets_by_fundsType" + | "client_wallets_transactions" + | "banking_aliases_iban_create" + | "banking_aliases_get" + | "banking_aliases_update" + | "banking_aliases_all" + | "ubo_declaration_create" + | "ubo_declaration_update" + | "ubo_declaration_get" + | "transactions_get_for_mandate" + | "transactions_get_for_card" + | "transactions_get_for_bank_account"; + +export type CountryISO = + | "AD" + | "AE" + | "AF" + | "AG" + | "AI" + | "AL" + | "AM" + | "AO" + | "AQ" + | "AR" + | "AS" + | "AT" + | "AU" + | "AW" + | "AX" + | "AZ" + | "BA" + | "BB" + | "BD" + | "BE" + | "BF" + | "BG" + | "BH" + | "BI" + | "BJ" + | "BL" + | "BM" + | "BN" + | "BO" + | "BQ" + | "BR" + | "BS" + | "BT" + | "BV" + | "BW" + | "BY" + | "BZ" + | "CA" + | "CC" + | "CD" + | "CF" + | "CG" + | "CH" + | "CI" + | "CK" + | "CL" + | "CM" + | "CN" + | "CO" + | "CR" + | "CU" + | "CV" + | "CW" + | "CX" + | "CY" + | "CZ" + | "DE" + | "DJ" + | "DK" + | "DM" + | "DO" + | "DZ" + | "EC" + | "EE" + | "EG" + | "EH" + | "ER" + | "ES" + | "ET" + | "FI" + | "FJ" + | "FK" + | "FM" + | "FO" + | "FR" + | "GA" + | "GB" + | "GD" + | "GE" + | "GF" + | "GG" + | "GH" + | "GI" + | "GL" + | "GM" + | "GN" + | "GP" + | "GQ" + | "GR" + | "GS" + | "GT" + | "GU" + | "GW" + | "GY" + | "HK" + | "HM" + | "HN" + | "HR" + | "HT" + | "HU" + | "ID" + | "IE" + | "IL" + | "IM" + | "IN" + | "IO" + | "IQ" + | "IR" + | "IS" + | "IT" + | "JE" + | "JM" + | "JO" + | "JP" + | "KE" + | "KG" + | "KH" + | "KI" + | "KM" + | "KN" + | "KP" + | "KR" + | "KW" + | "KY" + | "KZ" + | "LA" + | "LB" + | "LC" + | "LI" + | "LK" + | "LR" + | "LS" + | "LT" + | "LU" + | "LV" + | "LY" + | "MA" + | "MC" + | "MD" + | "ME" + | "MF" + | "MG" + | "MH" + | "MK" + | "ML" + | "MM" + | "MN" + | "MO" + | "MP" + | "MQ" + | "MR" + | "MS" + | "MT" + | "MU" + | "MV" + | "MW" + | "MX" + | "MY" + | "MZ" + | "NA" + | "NC" + | "NE" + | "NF" + | "NG" + | "NI" + | "NL" + | "NO" + | "NP" + | "NR" + | "NU" + | "NZ" + | "OM" + | "PA" + | "PE" + | "PF" + | "PG" + | "PH" + | "PK" + | "PL" + | "PM" + | "PN" + | "PR" + | "PS" + | "PT" + | "PW" + | "PY" + | "QA" + | "RE" + | "RO" + | "RS" + | "RU" + | "RW" + | "SA" + | "SB" + | "SC" + | "SD" + | "SE" + | "SG" + | "SH" + | "SI" + | "SJ" + | "SK" + | "SL" + | "SM" + | "SN" + | "SO" + | "SR" + | "SS" + | "ST" + | "SV" + | "SX" + | "SY" + | "SZ" + | "TC" + | "TD" + | "TF" + | "TG" + | "TH" + | "TJ" + | "TK" + | "TL" + | "TM" + | "TN" + | "TO" + | "TR" + | "TT" + | "TV" + | "TW" + | "TZ" + | "UA" + | "UG" + | "UM" + | "US" + | "UY" + | "UZ" + | "VA" + | "VC" + | "VE" + | "VG" + | "VI" + | "VN" + | "VU" + | "WF" + | "WS" + | "YE" + | "YT" + | "ZA" + | "ZM" + | "ZW"; + +export type CurrencyISO = + | "AED" + | "AFN" + | "ALL" + | "AMD" + | "ANG" + | "AOA" + | "ARS" + | "AUD" + | "AWG" + | "AZN" + | "BAM" + | "BBD" + | "BDT" + | "BGN" + | "BHD" + | "BIF" + | "BMD" + | "BND" + | "BOB" + | "BRL" + | "BSD" + | "BTN" + | "BWP" + | "BYN" + | "BZD" + | "CAD" + | "CDF" + | "CHF" + | "CLP" + | "CNY" + | "COP" + | "CRC" + | "CUC" + | "CUP" + | "CVE" + | "CZK" + | "DJF" + | "DKK" + | "DOP" + | "DZD" + | "EGP" + | "ERN" + | "ETB" + | "EUR" + | "FJD" + | "FKP" + | "GBP" + | "GEL" + | "GGP" + | "GHS" + | "GIP" + | "GMD" + | "GNF" + | "GTQ" + | "GYD" + | "HKD" + | "HNL" + | "HRK" + | "HTG" + | "HUF" + | "IDR" + | "ILS" + | "IMP" + | "INR" + | "IQD" + | "IRR" + | "ISK" + | "JEP" + | "JMD" + | "JOD" + | "JPY" + | "KES" + | "KGS" + | "KHR" + | "KMF" + | "KPW" + | "KRW" + | "KWD" + | "KYD" + | "KZT" + | "LAK" + | "LBP" + | "LKR" + | "LRD" + | "LSL" + | "LYD" + | "MAD" + | "MDL" + | "MGA" + | "MKD" + | "MMK" + | "MNT" + | "MOP" + | "MRU" + | "MUR" + | "MVR" + | "MWK" + | "MXN" + | "MYR" + | "MZN" + | "NAD" + | "NGN" + | "NIO" + | "NOK" + | "NPR" + | "NZD" + | "OMR" + | "PAB" + | "PEN" + | "PGK" + | "PHP" + | "PKR" + | "PLN" + | "PYG" + | "QAR" + | "RON" + | "RSD" + | "RUB" + | "RWF" + | "SAR" + | "SBD" + | "SCR" + | "SDG" + | "SEK" + | "SGD" + | "SHP" + | "SLL" + | "SOS" + | "SPL" + | "SRD" + | "STN" + | "SVC" + | "SYP" + | "SZL" + | "THB" + | "TJS" + | "TMT" + | "TND" + | "TOP" + | "TRY" + | "TTD" + | "TVD" + | "TWD" + | "TZS" + | "UAH" + | "UGX" + | "USD" + | "UYU" + | "UZS" + | "VEF" + | "VND" + | "VUV" + | "WST" + | "XAF" + | "XCD" + | "XDR" + | "XOF" + | "XPF" + | "YER" + | "ZAR" + | "ZMW" + | "ZWD"; diff --git a/types/mnemonic-words/index.d.ts b/types/mnemonic-words/index.d.ts new file mode 100644 index 0000000000..4ce91c08d6 --- /dev/null +++ b/types/mnemonic-words/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for mnemonic-words 1.0 +// Project: https://github.com/sindresorhus/mnemonic-words#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = mnemonicWords; + +declare const mnemonicWords: string[]; diff --git a/types/mnemonic-words/mnemonic-words-tests.ts b/types/mnemonic-words/mnemonic-words-tests.ts new file mode 100644 index 0000000000..a3c5569c8c --- /dev/null +++ b/types/mnemonic-words/mnemonic-words-tests.ts @@ -0,0 +1,5 @@ +import mnemonicWords = require('mnemonic-words'); +import mnemonicWordsJson = require('mnemonic-words/words.json'); + +mnemonicWords; // $ExpectType string[] +mnemonicWordsJson; // $ExpectType string[] diff --git a/types/mnemonic-words/tsconfig.json b/types/mnemonic-words/tsconfig.json new file mode 100644 index 0000000000..44998ff2f3 --- /dev/null +++ b/types/mnemonic-words/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "words.json.d.ts", + "mnemonic-words-tests.ts" + ] +} diff --git a/types/mnemonic-words/tslint.json b/types/mnemonic-words/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mnemonic-words/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/mnemonic-words/words.json.d.ts b/types/mnemonic-words/words.json.d.ts new file mode 100644 index 0000000000..2d95294802 --- /dev/null +++ b/types/mnemonic-words/words.json.d.ts @@ -0,0 +1,3 @@ +export = mnemonicWords; + +declare const mnemonicWords: string[]; diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 15e21d2b43..a3725382e4 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -1022,7 +1022,7 @@ export type Condition = { $caseSensitive?: boolean; $diacraticSensitive?: boolean; }; - $where: Object; + $where?: Object; $geoIntersects?: Object; $geoWithin?: Object; $near?: Object; diff --git a/types/negative-zero/index.d.ts b/types/negative-zero/index.d.ts new file mode 100644 index 0000000000..80887bad0c --- /dev/null +++ b/types/negative-zero/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for negative-zero 2.0 +// Project: https://github.com/sindresorhus/negative-zero#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = negativeZero; + +declare function negativeZero(input: number): boolean; diff --git a/types/negative-zero/negative-zero-tests.ts b/types/negative-zero/negative-zero-tests.ts new file mode 100644 index 0000000000..d1ec33d84b --- /dev/null +++ b/types/negative-zero/negative-zero-tests.ts @@ -0,0 +1,3 @@ +import negativeZero = require('negative-zero'); + +negativeZero(-0); // $ExpectType boolean diff --git a/types/negative-zero/tsconfig.json b/types/negative-zero/tsconfig.json new file mode 100644 index 0000000000..e1bc860e6b --- /dev/null +++ b/types/negative-zero/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", + "negative-zero-tests.ts" + ] +} diff --git a/types/negative-zero/tslint.json b/types/negative-zero/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/negative-zero/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/new-github-issue-url/index.d.ts b/types/new-github-issue-url/index.d.ts new file mode 100644 index 0000000000..f784a0d85d --- /dev/null +++ b/types/new-github-issue-url/index.d.ts @@ -0,0 +1,81 @@ +// Type definitions for new-github-issue-url 0.1 +// Project: https://github.com/sindresorhus/new-github-issue-url#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +export = newGithubIssueUrl; + +/** + * Returns a URL string. + */ +declare function newGithubIssueUrl(options: newGithubIssueUrl.Options): string; + +declare namespace newGithubIssueUrl { + type Without = { [P in Exclude]?: never }; + type XOR = (T | U) extends object ? (Without & U) | (Without & T) : T | U; + + type Options = XOR; + + interface BaseOptions { + /** + * The issue body. + */ + body?: string; + /** + * The issue title. + */ + title?: string; + /** + * Use an [issue template](https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository). + * + * For example, if you want to use a template at `ISSUE_TEMPLATE/unicorn.md`, you would specify `unicorn.md` here. + */ + template?: string; + /** + * The labels for the issue. + * + * *Requires the user to have the permission to add labels.* + */ + labels?: string[]; + /** + * The milestone for the issue. + * + * *Requires the user to have the permission to add milestone.* + */ + milestone?: string; + /** + * The user to assign to the issue. + * + * *Requires the user to have the permission to add assignee.* + */ + assignee?: string; + /** + * The projects to add the issue to. + * + * The project reference format is `user/`, for example, if the URL to the project + * is `https://github.com/sindresorhus/some-repo/projects/3`, the project reference would be `some-repo/3`. + * + * *Requires the user to have the permission to add projects.* + */ + projects?: string[]; + } + + interface RepoUrlOptions extends BaseOptions { + /** + * The full URL to the repo. + */ + repoUrl: string; + } + + interface UserRepoOptions extends BaseOptions { + /** + * GitHub username or organization. + */ + user: string; + /** + * GitHub repo. + */ + repo: string; + } +} diff --git a/types/new-github-issue-url/new-github-issue-url-tests.ts b/types/new-github-issue-url/new-github-issue-url-tests.ts new file mode 100644 index 0000000000..c64b1aaa61 --- /dev/null +++ b/types/new-github-issue-url/new-github-issue-url-tests.ts @@ -0,0 +1,54 @@ +import newGithubIssueUrl = require('new-github-issue-url'); + +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-issue-url.git', +}); +// $ExpectType string +newGithubIssueUrl({ + user: 'sindresorhus', + repo: 'new-github-issue-url', +}); +// $ExpectError +newGithubIssueUrl({ + user: 'sindresorhus', +}); +// $ExpectError +newGithubIssueUrl({ + repo: 'new-github-issue-url', +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + body: 'foo', +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + title: 'foo', +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + template: 'unicorn.md', +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + labels: ['foo', 'bar'], +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + milestone: 'foo', +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + assignee: 'sindresorhus', +}); +// $ExpectType string +newGithubIssueUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + projects: ['some-repo/3'], +}); diff --git a/types/new-github-issue-url/tsconfig.json b/types/new-github-issue-url/tsconfig.json new file mode 100644 index 0000000000..3b1da7ee63 --- /dev/null +++ b/types/new-github-issue-url/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", + "new-github-issue-url-tests.ts" + ] +} diff --git a/types/new-github-issue-url/tslint.json b/types/new-github-issue-url/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/new-github-issue-url/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/new-github-release-url/index.d.ts b/types/new-github-release-url/index.d.ts new file mode 100644 index 0000000000..3b1be4b7f2 --- /dev/null +++ b/types/new-github-release-url/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for new-github-release-url 0.1 +// Project: https://github.com/sindresorhus/new-github-release-url#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +export = newGithubReleaseUrl; + +/** + * Returns a URL string. + */ +declare function newGithubReleaseUrl(options: newGithubReleaseUrl.Options): string; + +declare namespace newGithubReleaseUrl { + type Without = { [P in Exclude]?: never }; + type XOR = (T | U) extends object ? (Without & U) | (Without & T) : T | U; + + type Options = XOR; + + interface BaseOptions { + /** + * The tag name of the release. + */ + tag?: string; + /** + * The branch name or commit SHA to point the release's tag at, if the tag doesn't already exist. + * @default The default branch + */ + target?: string; + /** + * The title of the release. + * GitHub shows the `tag` name when not specified. + */ + title?: string; + /** + * The description text of the release. + */ + body?: string; + /** + * Whether the release should be marked as a pre-release. + * @default false + */ + isPrerelease?: boolean; + } + + interface RepoUrlOptions extends BaseOptions { + /** + * The full URL to the repo. + */ + repoUrl: string; + } + + interface UserRepoOptions extends BaseOptions { + /** + * GitHub username or organization. + */ + user: string; + /** + * GitHub repo. + */ + repo: string; + } +} diff --git a/types/new-github-release-url/new-github-release-url-tests.ts b/types/new-github-release-url/new-github-release-url-tests.ts new file mode 100644 index 0000000000..9efe4e83db --- /dev/null +++ b/types/new-github-release-url/new-github-release-url-tests.ts @@ -0,0 +1,44 @@ +import newGithubReleaseUrl = require('new-github-release-url'); + +// $ExpectType string +newGithubReleaseUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', +}); +// $ExpectType string +newGithubReleaseUrl({ + user: 'sindresorhus', + repo: 'new-github-release-url', +}); +// $ExpectError +newGithubReleaseUrl({ + user: 'sindresorhus', +}); +// $ExpectError +newGithubReleaseUrl({ + repo: 'new-github-release-url', +}); +// $ExpectType string +newGithubReleaseUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + tag: 'foo', +}); +// $ExpectType string +newGithubReleaseUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + target: 'foo', +}); +// $ExpectType string +newGithubReleaseUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + title: 'foo', +}); +// $ExpectType string +newGithubReleaseUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + body: 'foo', +}); +// $ExpectType string +newGithubReleaseUrl({ + repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git', + isPrerelease: true, +}); diff --git a/types/new-github-release-url/tsconfig.json b/types/new-github-release-url/tsconfig.json new file mode 100644 index 0000000000..62cf729db4 --- /dev/null +++ b/types/new-github-release-url/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", + "new-github-release-url-tests.ts" + ] +} diff --git a/types/new-github-release-url/tslint.json b/types/new-github-release-url/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/new-github-release-url/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/node-xlsx/index.d.ts b/types/node-xlsx/index.d.ts new file mode 100644 index 0000000000..bd500d8a4e --- /dev/null +++ b/types/node-xlsx/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for node-xlsx 0.12 +// Project: https://github.com/mgcrea/node-xlsx#readme +// Definitions by: chenc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +/** + * parsing a xlsx from file/buffer, outputs an object of worksheets + * @param mixed file path or buffer + * @param options options is for xlsx + * @returns worksheets data, like: { name: 'worksheets', data: [[1,2,3],['1', '2','word']] } + */ +export declare function parse( + mixed: string | ArrayBuffer, + options?: {} +): Array<{ + name: string; + data: Array<[]>; +}>; + +/** + * building a xlsx + * @param worksheets worksheets data, like:{ name: 'worksheets', data: [[1,2,3],['1', '2','word']] } + * @param options spannig multiple rows A1:A4 + * @returns returns a buffer of worksheets + */ +export declare function build( + worksheets: Array<{ name: string; data: any[][] }>, + options?: {} +): ArrayBuffer; +declare const _default: { + parse: typeof parse; + build: typeof build; +}; +export default _default; diff --git a/types/node-xlsx/node-xlsx-tests.ts b/types/node-xlsx/node-xlsx-tests.ts new file mode 100644 index 0000000000..f9dffcad47 --- /dev/null +++ b/types/node-xlsx/node-xlsx-tests.ts @@ -0,0 +1,8 @@ +import { build } from 'node-xlsx'; +const data = [ + [1, 2, 3], + [true, false, null, 'sheetjs'], + ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'], + ['baz', null, 'qux'], +]; +const buffer = build([{ name: 'mySheetName', data }]); diff --git a/types/node-xlsx/tsconfig.json b/types/node-xlsx/tsconfig.json new file mode 100644 index 0000000000..915d266284 --- /dev/null +++ b/types/node-xlsx/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", + "node-xlsx-tests.ts" + ] +} diff --git a/types/node-xlsx/tslint.json b/types/node-xlsx/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-xlsx/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/npm-email/index.d.ts b/types/npm-email/index.d.ts new file mode 100644 index 0000000000..055a68f8af --- /dev/null +++ b/types/npm-email/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for npm-email 3.0 +// Project: https://github.com/sindresorhus/npm-email#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = npmEmail; + +/** + * Get the email of an npm user. + * + * @param username npm username to look up. + * @returns A promise for the user's email address. + */ +declare function npmEmail(username: string): Promise; diff --git a/types/npm-email/npm-email-tests.ts b/types/npm-email/npm-email-tests.ts new file mode 100644 index 0000000000..b0640c73e3 --- /dev/null +++ b/types/npm-email/npm-email-tests.ts @@ -0,0 +1,3 @@ +import npmEmail = require('npm-email'); + +npmEmail('sindresorhus'); // $ExpectType Promise diff --git a/types/npm-email/tsconfig.json b/types/npm-email/tsconfig.json new file mode 100644 index 0000000000..985ed0472a --- /dev/null +++ b/types/npm-email/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", + "npm-email-tests.ts" + ] +} diff --git a/types/npm-email/tslint.json b/types/npm-email/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-email/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/npm-keyword/index.d.ts b/types/npm-keyword/index.d.ts new file mode 100644 index 0000000000..94c8af9f13 --- /dev/null +++ b/types/npm-keyword/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for npm-keyword 5.0 +// Project: https://github.com/sindresorhus/npm-keyword#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = npmKeyword; + +/** + * Get a list of npm packages with a certain keyword. + * + * @param keyword One or more keywords. Only matches packages that have *all* the given keywords. Example: `['string', 'camelcase']` + * @returns A promise for a list of packages having the specified keyword in their package.json `keyword` property. + */ +declare function npmKeyword( + keyword: string | string[], + options?: npmKeyword.Options +): Promise; + +declare namespace npmKeyword { + /** + * @param keyword One or more keywords. Only matches packages that have *all* the given keywords. Example: `['string', 'camelcase']` + * @returns A promise for a list of package names. Use this if you don't need the description as it's faster. + */ + function names(keyword: string | string[], options?: Options): Promise; + + /** + * @param keyword One or more keywords. Only matches packages that have *all* the given keywords. Example: `['string', 'camelcase']` + * @returns A promise for the count of packages. + */ + function count(keyword: string | string[]): Promise; + + interface Options { + /** + * Limits the amount of results. + * @default 250 + */ + size?: number; + } + + interface PackageDescriptor { + name: string; + description: string; + } +} diff --git a/types/npm-keyword/npm-keyword-tests.ts b/types/npm-keyword/npm-keyword-tests.ts new file mode 100644 index 0000000000..17418bdb04 --- /dev/null +++ b/types/npm-keyword/npm-keyword-tests.ts @@ -0,0 +1,7 @@ +import npmKeyword = require('npm-keyword'); + +npmKeyword('gulpplugin'); // $ExpectType Promise +npmKeyword('gulpplugin', { size: 10 }); // $ExpectType Promise +npmKeyword.names('gulpplugin'); // $ExpectType Promise +npmKeyword.names('gulpplugin', { size: 10 }); // $ExpectType Promise +npmKeyword.count('gulpplugin'); // $ExpectType Promise diff --git a/types/npm-keyword/tsconfig.json b/types/npm-keyword/tsconfig.json new file mode 100644 index 0000000000..b0c0fed33d --- /dev/null +++ b/types/npm-keyword/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", + "npm-keyword-tests.ts" + ] +} diff --git a/types/npm-keyword/tslint.json b/types/npm-keyword/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-keyword/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/npm-run-path/index.d.ts b/types/npm-run-path/index.d.ts new file mode 100644 index 0000000000..6a052e0450 --- /dev/null +++ b/types/npm-run-path/index.d.ts @@ -0,0 +1,45 @@ +// Type definitions for npm-run-path 2.0 +// Project: https://github.com/sindresorhus/npm-run-path#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = npmRunPath; + +/** + * Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries. + */ +declare function npmRunPath(options?: npmRunPath.Options): string; + +declare namespace npmRunPath { + function env(options?: EnvOptions): ProcessEnv; + + interface Options { + /** + * Working directory. + */ + cwd?: string; + /** + * PATH to be appended. + * Set it to an empty string to exclude the default [PATH](https://github.com/sindresorhus/path-key). + * @default PATH + */ + path?: string; + } + + interface EnvOptions { + /** + * Working directory. + */ + cwd?: string; + /** + * Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct + * [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use + * in the `child_process` options. + */ + env?: ProcessEnv; + } + + interface ProcessEnv { + [key: string]: string | undefined; + } +} diff --git a/types/npm-run-path/npm-run-path-tests.ts b/types/npm-run-path/npm-run-path-tests.ts new file mode 100644 index 0000000000..4cff236373 --- /dev/null +++ b/types/npm-run-path/npm-run-path-tests.ts @@ -0,0 +1,16 @@ +/// + +import childProcess = require('child_process'); +import npmRunPath = require('npm-run-path'); + +npmRunPath(); // $ExpectType string +npmRunPath({ cwd: '/foo' }); // $ExpectType string +npmRunPath({ path: '/usr/local/bin' }); // $ExpectType string + +npmRunPath.env(); // $ExpectType ProcessEnv +npmRunPath.env({ cwd: '/foo' }); // $ExpectType ProcessEnv +npmRunPath.env({ env: process.env }); // $ExpectType ProcessEnv + +childProcess.execFileSync('foo', { + env: npmRunPath.env(), +}); diff --git a/types/npm-run-path/tsconfig.json b/types/npm-run-path/tsconfig.json new file mode 100644 index 0000000000..d6738a23ca --- /dev/null +++ b/types/npm-run-path/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", + "npm-run-path-tests.ts" + ] +} diff --git a/types/npm-run-path/tslint.json b/types/npm-run-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-run-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/npm-user-packages/index.d.ts b/types/npm-user-packages/index.d.ts new file mode 100644 index 0000000000..99ed62012f --- /dev/null +++ b/types/npm-user-packages/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for npm-user-packages 3.0 +// Project: https://github.com/kevva/npm-user-packages#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = npmUserPackages; + +/** + * Get packages by a npm user. + * @param username User to fetch packages from. + */ +declare function npmUserPackages(username: string): Promise; + +declare namespace npmUserPackages { + interface PackageData { + author: { + email?: string; + name: string; + url?: string; + username?: string; + }; + date: string; + description: string; + keywords: string[]; + links: { + bugs?: string; + homepage?: string; + npm: string; + repository?: string; + }; + maintainers: Array<{ + email: string; + username: string; + }>; + name: string; + publisher: { + email: string; + username: string; + }; + scope: string; + version: string; + } +} diff --git a/types/npm-user-packages/npm-user-packages-tests.ts b/types/npm-user-packages/npm-user-packages-tests.ts new file mode 100644 index 0000000000..509e82a16b --- /dev/null +++ b/types/npm-user-packages/npm-user-packages-tests.ts @@ -0,0 +1,3 @@ +import npmUserPackages = require('npm-user-packages'); + +npmUserPackages('kevva'); // $ExpectType Promise diff --git a/types/npm-user-packages/tsconfig.json b/types/npm-user-packages/tsconfig.json new file mode 100644 index 0000000000..5650f12560 --- /dev/null +++ b/types/npm-user-packages/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", + "npm-user-packages-tests.ts" + ] +} diff --git a/types/npm-user-packages/tslint.json b/types/npm-user-packages/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-user-packages/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/npm-user/index.d.ts b/types/npm-user/index.d.ts new file mode 100644 index 0000000000..2d03c12c0c --- /dev/null +++ b/types/npm-user/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for npm-user 3.0 +// Project: https://github.com/sindresorhus/npm-user#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = npmUser; + +declare function npmUser(name: string): Promise; + +declare namespace npmUser { + interface UserData { + name: string | null; + avatar: string | null; + email: string | null; + github: string | null; + twitter: string | null; + } +} diff --git a/types/npm-user/npm-user-tests.ts b/types/npm-user/npm-user-tests.ts new file mode 100644 index 0000000000..1d63de27ef --- /dev/null +++ b/types/npm-user/npm-user-tests.ts @@ -0,0 +1,11 @@ +import npmUser = require('npm-user'); + +npmUser('sindresorhus').then(user => { + user; // $ExpectType UserData + + user.name; // $ExpectType string | null + user.avatar; // $ExpectType string | null + user.email; // $ExpectType string | null + user.github; // $ExpectType string | null + user.twitter; // $ExpectType string | null +}); diff --git a/types/npm-user/tsconfig.json b/types/npm-user/tsconfig.json new file mode 100644 index 0000000000..1e5c1d464f --- /dev/null +++ b/types/npm-user/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", + "npm-user-tests.ts" + ] +} diff --git a/types/npm-user/tslint.json b/types/npm-user/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-user/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index dec070dad5..2df9aed3eb 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -1661,7 +1661,7 @@ declare namespace Office { * Specifies how to coerce data returned or set by the invoked method. * * @remarks - * PowerPoint supports only `Office.CoercionType.Text`, `Office.CoercionType.Image`, and `Office.CoercionType.SlideRange`. + * PowerPoint supports only `Office.CoercionType.Text`, `Office.CoercionType.Image`, `Office.CoercionType.SlideRange`, and `Office.CoercionType.XmlSvg`. * * Project supports only `Office.CoercionType.Text`. * @@ -1726,7 +1726,12 @@ declare namespace Office { * Data is returned or set as an image stream. * Note: Only applies to data in Excel, Word, and PowerPoint. */ - Image + Image, + /** + * Data is returned or set as XML data containing an SVG image. + * Note: Only applies to data in Excel, Word, and PowerPoint. + */ + XmlSvg } /** * Specifies whether the document in the associated application is read-only or read-write. @@ -3543,6 +3548,10 @@ declare namespace Office { * PowerPoint and PowerPoint Online * `Office.CoercionType.SlideRange` * + * + * Excel, PowerPoint, and Word + * `Office.CoercionType.XmlSvg` + * * * * **Support details** @@ -3710,6 +3719,10 @@ declare namespace Office { * PowerPoint and PowerPoint Online * `Office.CoercionType.SlideRange` * + * + * Excel, PowerPoint, and Word + * `Office.CoercionType.XmlSvg` + * * * * **Support details** @@ -17753,6 +17766,107 @@ declare namespace OfficeCore { //////////////////////////////////////////////////////////////// declare namespace Excel { + /** Represents which cell properties to load, when used as part of a "range.getCellProperties" method. */ + interface CellPropertiesLoadOptions { + address?: boolean; + addressLocal?: boolean; + format?: Excel.CellPropertiesFormatLoadOptions; + hasSpill?: boolean; + hidden?: boolean; + hyperlink?: boolean; + style?: boolean; + } + /** Represents which row properties to load, when used as part of a "range.getRowProperties" method. */ + interface RowPropertiesLoadOptions extends CellPropertiesLoadOptions { + rowHidden?: boolean; + rowIndex?: boolean; + format?: Excel.CellPropertiesFormatLoadOptions & { + rowHeight?: boolean; + }; + } + /** Represents which column properties to load, when used as part of a "range.getColumnProperties" method. */ + interface ColumnPropertiesLoadOptions extends CellPropertiesLoadOptions { + columnIndex?: boolean; + columnHidden?: boolean; + format?: Excel.CellPropertiesFormatLoadOptions & { + columnWidth?: boolean; + }; + } + /** Represents which properties to load on the format object. */ + interface CellPropertiesFormatLoadOptions { + autoIndent?: boolean; + borders?: Excel.CellPropertiesBorderLoadOptions; + fill?: Excel.CellPropertiesFillLoadOptions; + font?: Excel.CellPropertiesFontLoadOptions; + horizontalAlignment?: boolean; + indentLevel?: boolean; + protection?: boolean; + readingOrder?: boolean; + shrinkToFit?: boolean; + textOrientation?: boolean; + useStandardHeight?: boolean; + useStandardWidth?: boolean; + verticalAlignment?: boolean; + wrapText?: boolean; + } + /** Represents the input parameter of setCellProperties. */ + interface SettableCellProperties { + format?: Excel.CellPropertiesFormat; + hyperlink?: Excel.RangeHyperlink; + style?: string; + } + /** Represents the returned properties of getCellProperties. */ + interface CellProperties extends SettableCellProperties { + address?: string; + addressLocal?: string; + hasSpill?: boolean; + hidden?: boolean; + } + /** Represents the input parameter of setRowProperties. */ + interface SettableRowProperties extends SettableCellProperties { + rowHidden?: boolean; + format?: Excel.CellPropertiesFormat & { + rowHeight?: number; + }; + } + /** Represents the returned properties of getRowProperties. */ + interface RowProperties extends SettableRowProperties { + rowIndex?: number; + address?: string; + addressLocal?: string; + hasSpill?: boolean; + } + /** Represents the input parameter of setColumnProperties. */ + interface SettableColumnProperties extends SettableCellProperties { + columnHidden?: boolean; + format?: Excel.CellPropertiesFormat & { + columnWidth?: number; + }; + } + /** Represents the returned properties of getColumnProperties. */ + interface ColumnProperties extends SettableColumnProperties { + columnIndex?: number; + address?: string; + addressLocal?: string; + hasSpill?: boolean; + } + /** Represents the returned format properties of getCellProperties or format input parameter of setCellProperties. */ + interface CellPropertiesFormat { + autoIndent?: boolean; + borders?: Excel.CellBorderCollection; + fill?: Excel.CellPropertiesFill; + font?: Excel.CellPropertiesFont; + horizontalAlignment?: Excel.HorizontalAlignment | "General" | "Left" | "Center" | "Right" | "Fill" | "Justify" | "CenterAcrossSelection" | "Distributed"; + indentLevel?: number; + protection?: Excel.CellPropertiesProtection; + readingOrder?: Excel.ReadingOrder | "Context" | "LeftToRight" | "RightToLeft"; + shrinkToFit?: boolean; + textOrientation?: number; + useStandardHeight?: boolean; + useStandardWidth?: boolean; + verticalAlignment?: Excel.VerticalAlignment | "Top" | "Center" | "Bottom" | "Justify" | "Distributed"; + wrapText?: boolean; + } /** * * Creates and opens a new workbook. Optionally, the workbook can be pre-populated with a base64-encoded .xlsx file. @@ -17761,7 +17875,7 @@ declare namespace Excel { * * @param base64File Optional. The base64 encoded .xlsx file. The default value is null. */ - function createWorkbook(base64?: string): Promise; + function createWorkbook(base64?: string): Promise; interface ThreeArrowsSet { [index: number]: Icon; redDownArrow: Icon; @@ -17994,6 +18108,8 @@ declare namespace Excel { * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. */ function run(context: OfficeExtension.ClientRequestContext, batch: (context: Excel.RequestContext) => Promise): Promise; + function postprocessBindingDescriptor(response: any): any; + function getDataCommonPostprocess(response: any, callArgs: any): any; /** * * Provides information about the binding that raised the SelectionChanged event. @@ -18826,7 +18942,7 @@ declare namespace Excel { context: RequestContext; /** * - * Turn on/off JavaScript events in current taskpane or content add-in. + * Toggle JavaScript events in the current task pane or content add-in. * * [Api set: ExcelApi 1.8] */ @@ -19150,6 +19266,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.4] */ readonly settings: Excel.SettingCollection; + /** + * + * Represents a collection of Slicers associated with the workbook. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly slicers: Excel.SlicerCollection; /** * * Represents a collection of styles associated with the workbook. Read-only. @@ -19300,6 +19424,22 @@ declare namespace Excel { * @beta */ getActiveChartOrNullObject(): Excel.Chart; + /** + * + * Gets the currently active slicer in the workbook. If there is no active slicer, will throw exception when invoke this statement. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getActiveSlicer(): Excel.Slicer; + /** + * + * Gets the currently active slicer in the workbook. If there is no active slicer, will return null object + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getActiveSlicerOrNullObject(): Excel.Slicer; /** * * True if the workbook is being edited by multiple users (co-authoring). @@ -19383,6 +19523,15 @@ declare namespace Excel { * @eventproperty */ readonly onSelectionChanged: OfficeExtension.EventHandlers; + /** + * + * Occurs when a WAC operation occurs. + * + * [Api set: WACOperationEvents 1.1] + * + * @eventproperty + * @beta + */ /** * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) * Whereas the original Excel.Workbook object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.WorkbookData`) that contains shallow copies of any loaded child properties from the original object. @@ -19509,6 +19658,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.1] */ readonly charts: Excel.ChartCollection; + /** + * + * Returns a collection of all the Comments objects on the worksheet. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly comments: Excel.CommentCollection; /** * * Gets an object that can be used to manipulate frozen panes on the worksheet. Read-only. @@ -19561,6 +19718,14 @@ declare namespace Excel { * @beta */ readonly shapes: Excel.ShapeCollection; + /** + * + * Returns collection of slicers that are part of the worksheet. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly slicers: Excel.SlicerCollection; /** * * Collection of tables that are part of the worksheet. Read-only. @@ -20621,6 +20786,8 @@ declare namespace Excel { set(properties: Interfaces.RangeUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ set(properties: Excel.Range): void; + autoFill(destinationRange: Range | string, autoFillType?: Excel.AutoFillType): void; + autoFill(destinationRange: Range | string, autoFillType?: "FillDefault" | "FillCopy" | "FillSeries" | "FillFormats" | "FillValues" | "FillDays" | "FillWeekdays" | "FillMonths" | "FillYears" | "LinearTrend" | "GrowthTrend" | "FlashFill"): void; /** * * Calculates a range of cells on a worksheet. @@ -20766,6 +20933,14 @@ declare namespace Excel { * @param column Column number of the cell to be retrieved. Zero-indexed. */ getCell(row: number, column: number): Excel.Range; + /** + * + * Returns a 2D array, encapsulating the data for each cell's font, fill, borders, alignment, and other properties. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getCellProperties(cellPropertiesLoadOptions: CellPropertiesLoadOptions): OfficeExtension.ClientResult; /** * * Gets a column contained in the range. @@ -20775,6 +20950,14 @@ declare namespace Excel { * @param column Column number of the range to be retrieved. Zero-indexed. */ getColumn(column: number): Excel.Range; + /** + * + * Returns a single-dimensional array, encapsulating the data for each column's font, fill, borders, alignment, and other properties. For properties that are not consistent across each cell within a given column, null will be returned. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getColumnProperties(columnPropertiesLoadOptions: ColumnPropertiesLoadOptions): OfficeExtension.ClientResult; /** * * Gets a certain number of columns to the right of the current Range object. @@ -20882,6 +21065,14 @@ declare namespace Excel { * @param row Row number of the range to be retrieved. Zero-indexed. */ getRow(row: number): Excel.Range; + /** + * + * Returns a single-dimensional array, encapsulating the data for each row's font, fill, borders, alignment, and other properties. For properties that are not consistent across each cell within a given row, null will be returned. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getRowProperties(rowPropertiesLoadOptions: RowPropertiesLoadOptions): OfficeExtension.ClientResult; /** * * Gets a certain number of rows above the current Range object. @@ -21063,6 +21254,22 @@ declare namespace Excel { * [Api set: ExcelApi 1.1] */ select(): void; + /** + * + * Updates the range based on a 2D array of cell properties , encapsulating things like font, fill, borders, alignment, and so forth. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + setCellProperties(cellPropertiesData: SettableCellProperties[][]): void; + /** + * + * Updates the range based on a single-dimensional array of column properties, encapsulating things like font, fill, borders, alignment, and so forth. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + setColumnProperties(columnPropertiesData: SettableColumnProperties[]): void; /** * * Set a range to be recalculated when the next recalculation occurs. @@ -21071,6 +21278,14 @@ declare namespace Excel { * @beta */ setDirty(): void; + /** + * + * Updates the range based on a single-dimensional array of row properties, encapsulating things like font, fill, borders, alignment, and so forth. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + setRowProperties(rowPropertiesData: SettableRowProperties[]): void; /** * * Displays the card for an active cell if it has rich value content. @@ -21617,6 +21832,126 @@ declare namespace Excel { */ matchCase?: boolean; } + /** + * + * Represents which properties to load on the format.fill object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellPropertiesFillLoadOptions { + color?: boolean; + pattern?: boolean; + patternColor?: boolean; + patternTintAndShade?: boolean; + tintAndShade?: boolean; + } + /** + * + * Represents which properties to load on the format.font object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellPropertiesFontLoadOptions { + bold?: boolean; + color?: boolean; + italic?: boolean; + name?: boolean; + size?: boolean; + strikethrough?: boolean; + subscript?: boolean; + superscript?: boolean; + tintAndShade?: boolean; + underline?: boolean; + } + /** + * + * Represents which properties to load on the format.borders object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellPropertiesBorderLoadOptions { + color?: boolean; + style?: boolean; + tintAndShade?: boolean; + weight?: boolean; + } + /** + * + * Represents the returned format.protection properties of getCell/Row/ColumnProperties or format.protection input parameter of setCell/Row/ColumnProperties. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellPropertiesProtection { + formulaHidden?: boolean; + locked?: boolean; + } + /** + * + * Represents the returned format.fill properties of getCell/Row/ColumnProperties or format.fill input parameter of setCell/Row/ColumnProperties. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellPropertiesFill { + color?: string; + pattern?: Excel.FillPattern | "None" | "Solid" | "Gray50" | "Gray75" | "Gray25" | "Horizontal" | "Vertical" | "Down" | "Up" | "Checker" | "SemiGray75" | "LightHorizontal" | "LightVertical" | "LightDown" | "LightUp" | "Grid" | "CrissCross" | "Gray16" | "Gray8" | "LinearGradient" | "RectangularGradient"; + patternColor?: string; + patternTintAndShade?: number; + tintAndShade?: number; + } + /** + * + * Represents the returned format.font properties of getCell/Row/ColumnProperties or format.font input parameter of setCell/Row/ColumnProperties. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellPropertiesFont { + bold?: boolean; + color?: string; + italic?: boolean; + name?: string; + size?: number; + strikethrough?: boolean; + subscript?: boolean; + superscript?: boolean; + tintAndShade?: number; + underline?: Excel.RangeUnderlineStyle | "None" | "Single" | "Double" | "SingleAccountant" | "DoubleAccountant"; + } + /** + * + * Represents the returned format.borders properties of getCell/Row/ColumnProperties or format.borders input parameter of setCell/Row/ColumnProperties. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellBorderCollection { + bottom?: Excel.CellBorder; + diagonalDown?: Excel.CellBorder; + diagonalUp?: Excel.CellBorder; + horizontal?: Excel.CellBorder; + left?: Excel.CellBorder; + right?: Excel.CellBorder; + top?: Excel.CellBorder; + vertical?: Excel.CellBorder; + } + /** + * + * Represents the returned single border properties of getCell/Row/ColumnProperties or border property input parameter of setCell/Row/ColumnProperties. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface CellBorder { + color?: string; + style?: Excel.BorderLineStyle | "None" | "Continuous" | "Dash" | "DashDot" | "DashDotDot" | "Dot" | "Double" | "SlantDashDot"; + tintAndShade?: number; + weight?: Excel.BorderWeight | "Hairline" | "Thin" | "Medium" | "Thick"; + } /** * * RangeView represents a set of visible cells of the parent range. @@ -21899,7 +22234,7 @@ declare namespace Excel { context: RequestContext; private static DateJSONPrefix; private static DateJSONSuffix; - private static replaceStringDateWithDate(value); + private static replaceStringDateWithDate; /** * * Returns the key that represents the id of the Setting. Read-only. @@ -23324,7 +23659,7 @@ declare namespace Excel { prompt: Excel.DataValidationPrompt; /** * - * Data Validation rule that contains different type of data validation criteria. + * Data validation rule that contains different type of data validation criteria. * * [Api set: ExcelApi 1.8] */ @@ -23528,7 +23863,8 @@ declare namespace Excel { interface BasicDataValidation { /** * - * Gets or sets the Formula1, i.e. minimum value or value depending of the operator. + * Specifies the right-hand operand when the operator property is set to a binary operator such as GreaterThan (the left-hand operand is the value the user tries to enter in the cell). With the ternary operators Between and NotBetween, specifies the lower bound operand. + For example, setting formula1 to 10 and operator to GreaterThan means that valid data for the range must be greater than 10. When setting the value, it can be passed in as a number, a range object, or a string formula (where the string is either a stringified number, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * @@ -23537,7 +23873,7 @@ declare namespace Excel { formula1: string | number | Range; /** * - * Gets or sets the Formula2, i.e. maximum value or value depending of the operator. + * With the ternary operators Between and NotBetween, specifies the upper bound operand. Is not used with the binary operators, such as GreaterThan. When setting the value, it can be passed in as a number, a range object, or a string formula (where the string is either a stringified number, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * @@ -23561,7 +23897,7 @@ declare namespace Excel { interface DateTimeDataValidation { /** * - * Gets or sets the Formula1, i.e. minimum value or value depending of the operator. + * Specifies the right-hand operand when the operator property is set to a binary operator such as GreaterThan (the left-hand operand is the value the user tries to enter in the cell). With the ternary operators Between and NotBetween, specifies the lower bound operand. When setting the value, it can be passed in as a Date, a Range object, or a string formula (where the string is either a stringified date/time in ISO8601 format, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * @@ -23570,7 +23906,7 @@ declare namespace Excel { formula1: string | Date | Range; /** * - * Gets or sets the Formula2, i.e. maximum value or value depending of the operator. + * With the ternary operators Between and NotBetween, specifies the upper bound operand. Is not used with the binary operators, such as GreaterThan. When setting the value, it can be passed in as a Date, a Range object, or a string (where the string is either a stringified date/time in ISO8601 format, a cell reference like "=A1", or a formula like "=MIN(A1, B1)"). When retrieving the value, it will always be returned as a string formula, for example: "=10", "=A1", "=SUM(A1:B5)", etc. * @@ -23617,7 +23953,7 @@ declare namespace Excel { interface CustomDataValidation { /** * - * Custom data validation formula, it is to create special rules, such as preventing duplicates, or limiting the total in a range of cells. + * A custom data validation formula. This creates special input rules, such as preventing duplicates, or limiting the total in a range of cells. * * [Api set: ExcelApi 1.8] */ @@ -23639,14 +23975,14 @@ declare namespace Excel { message: string; /** * - * It determines show error alert dialog or not when users enter invalid data, it defaults to true. + * Determines whether to show an error alert dialog or not when a user enters invalid data. The default is true. * * [Api set: ExcelApi 1.8] */ showAlert: boolean; /** * - * Represents Data validation alert type, please see Excel.DataValidationAlertStyle for details. + * Represents data validation alert type, please see Excel.DataValidationAlertStyle for details. * * [Api set: ExcelApi 1.8] */ @@ -23675,7 +24011,7 @@ declare namespace Excel { message: string; /** * - * It determines showing the prompt or not when user selects a cell with the data validation. + * Determines whether or not to show the prompt when user selects a cell with data validation. * * [Api set: ExcelApi 1.8] */ @@ -23951,7 +24287,7 @@ declare namespace Excel { context: RequestContext; /** * - * HTML color code representing the color of the background, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") * * [Api set: ExcelApi 1.1] */ @@ -24532,7 +24868,7 @@ declare namespace Excel { readonly series: Excel.ChartSeriesCollection; /** * - * Represents the title of the specified chart, including the text, visibility, position, and formating of the title. Read-only. + * Represents the title of the specified chart, including the text, visibility, position, and formatting of the title. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -24625,7 +24961,7 @@ declare namespace Excel { showAllFieldButtons: boolean; /** * - * Represents whether to to show the data labels when the value is greater than the maximum value on the value axis. + * Represents whether to show the data labels when the value is greater than the maximum value on the value axis. If value axis became smaller than the size of data points, you can use this property to set whether to show the data labels. This property applies to 2-D charts only. * @@ -25295,7 +25631,7 @@ declare namespace Excel { name: string; /** * - * Specifies how bars and columns are positioned. Can be a value between – 100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. + * Specifies how bars and columns are positioned. Can be a value between –100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. * * [Api set: ExcelApi 1.8] */ @@ -25460,7 +25796,7 @@ declare namespace Excel { context: RequestContext; /** * - * Represents the fill format of a chart series, which includes background formating information. Read-only. + * Represents the fill format of a chart series, which includes background formatting information. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -25695,7 +26031,7 @@ declare namespace Excel { readonly border: Excel.ChartBorder; /** * - * Represents the fill format of a chart, which includes background formating information. Read-only. + * Represents the fill format of a chart, which includes background formatting information. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -26033,7 +26369,7 @@ declare namespace Excel { position: Excel.ChartAxisPosition | "Automatic" | "Maximum" | "Minimum" | "Custom"; /** * - * Represents the specified axis position where the other axis crosses at. Read Only. Set to this property should use SetPositionAt(double) method. + * Represents the specified axis position where the other axis crosses at. You should use the SetPositionAt(double) method to set this property. * * [Api set: ExcelApi 1.8] */ @@ -26423,7 +26759,7 @@ declare namespace Excel { readonly format: Excel.ChartDataLabelFormat; /** * - * Represents whether data labels automatically generates appropriate text based on context. + * Represents whether data labels automatically generate appropriate text based on context. * * [Api set: ExcelApi 1.8] */ @@ -27236,14 +27572,14 @@ declare namespace Excel { context: RequestContext; /** * - * Represents the height of the legendEntry on the chart Legend. + * Represents the height of the legendEntry on the chart legend. * * [Api set: ExcelApi 1.8] */ readonly height: number; /** * - * Represents the index of the LegendEntry in the Chart Legend. + * Represents the index of the legendEntry in the chart legend. * * [Api set: ExcelApi 1.8] */ @@ -27386,7 +27722,7 @@ declare namespace Excel { readonly border: Excel.ChartBorder; /** * - * Represents the fill format of an object, which includes background formating information. Read-only. + * Represents the fill format of an object, which includes background formatting information. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -27749,7 +28085,7 @@ declare namespace Excel { readonly border: Excel.ChartBorder; /** * - * Represents the fill format of an object, which includes background formating information. Read-only. + * Represents the fill format of an object, which includes background formatting information. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -27828,7 +28164,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.1] * - * @param color HTML color code representing the color of the background, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + * @param color HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). */ setSolidColor(color: string): void; /** @@ -28898,7 +29234,7 @@ declare namespace Excel { readonly border: Excel.ChartBorder; /** * - * Represents the fill format of an object, which includes background formating information. + * Represents the fill format of an object, which includes background formatting information. * * [Api set: ExcelApi 1.8] */ @@ -29908,6 +30244,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.3] */ readonly worksheet: Excel.Worksheet; + /** + * + * True if the PivotTable should use custom lists when sorting. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enableDataValueEditing: boolean; /** * * Id of the PivotTable. Read-only. @@ -29994,6 +30338,14 @@ declare namespace Excel { class PivotLayout extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; + /** + * + * True if formatting will be automatically formatted when it’s refreshed or when fields are moved + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + autoFormat: boolean; /** * * True if the field list should be shown or hidden from the UI. @@ -30009,6 +30361,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.8] */ layoutType: Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline"; + /** + * + * True if formatting is preserved when the report is refreshed or recalculated by operations such as pivoting, sorting, or changing page field items. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + preserveFormatting: boolean; /** * * True if the PivotTable report shows grand totals for columns. @@ -30752,7 +31112,7 @@ declare namespace Excel { position: number; /** * - * Determines whether the data should be sown as a specific summary calculation or not. + * Determines whether the data should be shown as a specific summary calculation or not. * * [Api set: ExcelApi 1.8] */ @@ -30818,14 +31178,14 @@ declare namespace Excel { interface ShowAsRule { /** * - * The Base PivotField to base the ShowAs calculation, if applicable based on the ShowAsCalculation type, else null. + * The base PivotField to base the ShowAs calculation, if applicable based on the ShowAsCalculation type, else null. * * [Api set: ExcelApi 1.8] */ baseField?: Excel.PivotField; /** * - * The Base Item to base the ShowAs calculation on, if applicable based on the ShowAsCalculation type, else null. + * The base Item to base the ShowAs calculation on, if applicable based on the ShowAsCalculation type, else null. * * [Api set: ExcelApi 1.8] */ @@ -31201,7 +31561,7 @@ declare namespace Excel { topSum = "TopSum", bottomItems = "BottomItems", bottomPercent = "BottomPercent", - bottomSum = "BottomSum", + bottomSum = "BottomSum" } /** * @@ -31221,7 +31581,7 @@ declare namespace Excel { * Descending sort. Largest to smallest or Z to A. * */ - descending = "Descending", + descending = "Descending" } /** * @@ -31307,7 +31667,7 @@ declare namespace Excel { * Aggregate using the variance of the data, equivalent to the VARP function. * */ - varianceP = "VarianceP", + varianceP = "VarianceP" } /** * @@ -31412,7 +31772,7 @@ declare namespace Excel { ((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total)) * */ - index = "Index", + index = "Index" } /** * @@ -31451,7 +31811,7 @@ declare namespace Excel { * The filter axis. * */ - filter = "Filter", + filter = "Filter" } /** * @@ -32703,7 +33063,7 @@ declare namespace Excel { formula?: string; /** * - * What the icon conditional formula should be based on. + * What the criterion conditional formula should be based on. * * [Api set: ExcelApi 1.6] */ @@ -33688,6 +34048,8 @@ declare namespace Excel { * [Api set: ExcelApi 1.7] */ class StyleCollection extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; /** Gets the loaded child items in this collection. */ readonly items: Excel.Style[]; /** @@ -33699,6 +34061,14 @@ declare namespace Excel { * @param name Name of the style to be added. */ add(name: string): void; + /** + * + * Gets the number of styles in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getCount(): OfficeExtension.ClientResult; /** * * Gets a style by name. @@ -33708,6 +34078,16 @@ declare namespace Excel { * @param name Name of the style to be retrieved. */ getItem(name: string): Excel.Style; + /** + * + * Gets a style based on its position in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Style; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -33726,6 +34106,10 @@ declare namespace Excel { load(option?: Excel.Interfaces.StyleCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.StyleCollection; load(option?: string | string[]): Excel.StyleCollection; load(option?: OfficeExtension.LoadOption): Excel.StyleCollection; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original `Excel.StyleCollection` object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.StyleCollectionData`) that contains an "items" array with shallow copies of any loaded properties from the collection's items. + */ toJSON(): Excel.Interfaces.StyleCollectionData; } /** @@ -34554,6 +34938,30 @@ declare namespace Excel { context: RequestContext; /** Gets the loaded child items in this collection. */ readonly items: Excel.Comment[]; + /** + * + * Creates a new comment(comment thread) based on the cell location and content. Invalid argument will be thrown if the location is larger than one cell. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param content The comment content. + * @param cellAddress Cell to insert comment to. May be an Excel Range object, or a string. If string, must contain the full address, including the sheet name + * @param contentType Optional. Type of the comment content + */ + add(content: string, cellAddress: Range | string, contentType?: Excel.ContentType): Excel.Comment; + /** + * + * Creates a new comment(comment thread) based on the cell location and content. Invalid argument will be thrown if the location is larger than one cell. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param content The comment content. + * @param cellAddress Cell to insert comment to. May be an Excel Range object, or a string. If string, must contain the full address, including the sheet name + * @param contentType Optional. Type of the comment content + */ + add(content: string, cellAddress: Range | string, contentType?: "Plain"): Excel.Comment; /** * * Gets the number of comments in the collection. @@ -34582,6 +34990,26 @@ declare namespace Excel { * @param index Index value of the object to be retrieved. Zero-indexed. */ getItemAt(index: number): Excel.Comment; + /** + * + * Gets a comment on the specific cell in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param cellAddress Cell which the comment is on. May be an Excel Range object, or a string. If string, must contain the full address, including the sheet name + */ + getItemByCell(cellAddress: Range | string): Excel.Comment; + /** + * + * Gets a comment related to its reply ID in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param replyId The identifier of comment reply. + */ + getItemByReplyId(replyId: string): Excel.Comment; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -34624,6 +35052,14 @@ declare namespace Excel { * @beta */ readonly replies: Excel.CommentReplyCollection; + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content: string; /** * * Represents the comment identifier. Read-only. @@ -34640,6 +35076,28 @@ declare namespace Excel { * @beta */ readonly isParent: boolean; + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Excel.Comment): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ + set(properties: Interfaces.CommentUpdateData, options?: OfficeExtension.UpdateOptions): void; + /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ + set(properties: Excel.Comment): void; + /** + * + * Deletes the comment thread. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + delete(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -34701,6 +35159,14 @@ declare namespace Excel { * @param contentType Optional. Type of the comment content */ add(content: string, contentType?: "Plain"): Excel.CommentReply; + /** + * + * Gets the number of comment replies in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getCount(): OfficeExtension.ClientResult; /** * * Returns a comment reply identified by its ID. Read-only. @@ -34711,6 +35177,16 @@ declare namespace Excel { * @param commentReplyId The identifier for the comment reply. */ getItem(commentReplyId: string): Excel.CommentReply; + /** + * + * Gets a comment reply based on its position in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.CommentReply; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -34745,6 +35221,14 @@ declare namespace Excel { class CommentReply extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content: string; /** * * Represents the comment reply identifier. Read-only. @@ -34761,6 +35245,20 @@ declare namespace Excel { * @beta */ readonly isParent: boolean; + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Excel.CommentReply): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ + set(properties: Interfaces.CommentReplyUpdateData, options?: OfficeExtension.UpdateOptions): void; + /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ + set(properties: Excel.CommentReply): void; /** * * Deletes the comment reply. @@ -34769,6 +35267,14 @@ declare namespace Excel { * @beta */ delete(): void; + /** + * + * Get its parent comment of this reply. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getParentComment(): Excel.Comment; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -34856,6 +35362,34 @@ declare namespace Excel { * @param base64ImageString A base64 encoded image in JPEG or PNG formats. */ addImage(base64ImageString: string): Excel.Shape; + /** + * + * Adds a line to worksheet. Returns a Shape object that represents the new line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param startLeft The distance, in points, from the start left of the line to the left side of the worksheet. + * @param startTop The distance, in points, from the start top of the line to the top of the worksheet. + * @param endLeft The distance, in points, from the end left of the line to the left of the worksheet. + * @param endTop The distance, in points, from the end top of the line to the top of the worksheet. + * @param connectorType Represents the connector type. See Excel.ConnectorType for details. + */ + addLine(startLeft: number, startTop: number, endLeft: number, endTop: number, connectorType?: Excel.ConnectorType): Excel.Shape; + /** + * + * Adds a line to worksheet. Returns a Shape object that represents the new line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param startLeft The distance, in points, from the start left of the line to the left side of the worksheet. + * @param startTop The distance, in points, from the start top of the line to the top of the worksheet. + * @param endLeft The distance, in points, from the end left of the line to the left of the worksheet. + * @param endTop The distance, in points, from the end top of the line to the top of the worksheet. + * @param connectorType Represents the connector type. See Excel.ConnectorType for details. + */ + addLine(startLeft: number, startTop: number, endLeft: number, endTop: number, connectorType?: "Straight" | "Elbow" | "Curve"): Excel.Shape; /** * * Creates an SVG from a XML string and adds it to worksheet. Returns a Shape object that represents the new Image. @@ -34886,14 +35420,24 @@ declare namespace Excel { getCount(): OfficeExtension.ClientResult; /** * - * Returns a shape identified by the shape id. Read-only. + * Gets a shape using its name. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta * - * @param shapeId The identifier for the shape. + * @param name Name of the shape to be retrieved. */ - getItem(shapeId: string): Excel.Shape; + getItem(name: string): Excel.Shape; + /** + * + * Gets a shape based on its position in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Shape; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -34960,6 +35504,30 @@ declare namespace Excel { * @beta */ readonly image: Excel.Image; + /** + * + * Returns the line object for the shape object. Error will be thrown, if the shape object is other shape type (Like, GeometricShape, SmartArt, etc.) rather than Image. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly line: Excel.Line; + /** + * + * Returns the line formatting of the shape object. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly lineFormat: Excel.ShapeLineFormat; + /** + * + * Represents the parent group of the specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly parentGroup: Excel.Shape; /** * * Returns the textFrame object of a shape. Read only. @@ -35018,6 +35586,14 @@ declare namespace Excel { * @beta */ left: number; + /** + * + * Represents the level of the specified shape. Level 0 means the shape is not part of any group, level 1 means the shape is part of a top-level group, etc. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly level: number; /** * * Represents if the aspect ratio locked, in boolean, of the shape. @@ -35028,12 +35604,12 @@ declare namespace Excel { lockAspectRatio: boolean; /** * - * Represents the name of the shape. Read-only. + * Represents the name of the shape. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta */ - readonly name: string; + name: string; /** * * Represents the placment, value that represents the way the object is attached to the cells below it. @@ -35066,7 +35642,7 @@ declare namespace Excel { * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta */ - readonly type: Excel.ShapeType | "Unknown" | "Image" | "GeometricShape" | "Group"; + readonly type: Excel.ShapeType | "Unknown" | "Image" | "GeometricShape" | "Group" | "Line"; /** * * Represents the visibility, in boolean, of the specified shape. @@ -35481,14 +36057,24 @@ declare namespace Excel { getCount(): OfficeExtension.ClientResult; /** * - * Returns a shape identified by the shape id. Read-only. + * Gets a shape using its name. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta * - * @param shapeId The identifier for the shape. + * @param name Name of the shape to be retrieved. */ - getItem(shapeId: string): Excel.Shape; + getItem(name: string): Excel.Shape; + /** + * + * Gets a shape based on its position in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Shape; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -35513,6 +36099,81 @@ declare namespace Excel { */ toJSON(): Excel.Interfaces.GroupShapeCollectionData; } + /** + * + * Represents a Line object inside a worksheet. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + class Line extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; + /** + * + * Returns the shape object for the line. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly shape: Excel.Shape; + /** + * + * Represents the shape identifier. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly id: string; + /** + * + * Represents the connector type for the line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectorType: Excel.ConnectorType | "Straight" | "Elbow" | "Curve"; + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Excel.Line): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ + set(properties: Interfaces.LineUpdateData, options?: OfficeExtension.UpdateOptions): void; + /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ + set(properties: Excel.Line): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Excel.Line` - Where option is a comma-delimited string or an array of strings that specify the properties to load. + * + * `load(option?: { select?: string; expand?: string; }): Excel.Line` - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.Line` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. + */ + load(option?: Excel.Interfaces.LineLoadOptions): Excel.Line; + load(option?: string | string[]): Excel.Line; + load(option?: { + select?: string; + expand?: string; + }): Excel.Line; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original Excel.Line object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.LineData`) that contains shallow copies of any loaded child properties from the original object. + */ + toJSON(): Excel.Interfaces.LineData; + } /** * * Represents the fill formatting for a shape object. @@ -35606,6 +36267,105 @@ declare namespace Excel { */ toJSON(): Excel.Interfaces.ShapeFillData; } + /** + * + * Represents the line formatting for the shape object. For picture and geometric shape, line formatting represents the border of shape object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + class ShapeLineFormat extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; + /** + * + * Represents the line color in HTML color format, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + color: string; + /** + * + * Represents the line style of the shape. Returns null when line is not visible or has mixed line dash style property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + dashStyle: Excel.ShapeLineDashStyle | "Dash" | "DashDot" | "DashDotDot" | "LongDash" | "LongDashDot" | "RoundDot" | "Solid" | "SquareDot" | "LongDashDotDot" | "SystemDash" | "SystemDot" | "SystemDashDot"; + /** + * + * Represents the line style of the shape object. Returns null when line is not visible or has mixed line visible property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style: Excel.ShapeLineStyle | "Single" | "ThickBetweenThin" | "ThickThin" | "ThinThick" | "ThinThin"; + /** + * + * Represents the degree of transparency of the specified line as a value from 0.0 (opaque) through 1.0 (clear). Returns null when the shape has mixed line transparency property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + transparency: number; + /** + * + * Represents whether the line formatting of a shape element is visible. Returns null when the shape has mixed line visible property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + visible: boolean; + /** + * + * Represents weight of the line, in points. Returns null when the line is not visible or has mixed line weight property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + weight: number; + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Excel.ShapeLineFormat): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ + set(properties: Interfaces.ShapeLineFormatUpdateData, options?: OfficeExtension.UpdateOptions): void; + /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ + set(properties: Excel.ShapeLineFormat): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Excel.ShapeLineFormat` - Where option is a comma-delimited string or an array of strings that specify the properties to load. + * + * `load(option?: { select?: string; expand?: string; }): Excel.ShapeLineFormat` - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.ShapeLineFormat` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. + */ + load(option?: Excel.Interfaces.ShapeLineFormatLoadOptions): Excel.ShapeLineFormat; + load(option?: string | string[]): Excel.ShapeLineFormat; + load(option?: { + select?: string; + expand?: string; + }): Excel.ShapeLineFormat; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original Excel.ShapeLineFormat object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.ShapeLineFormatData`) that contains shallow copies of any loaded child properties from the original object. + */ + toJSON(): Excel.Interfaces.ShapeLineFormatData; + } /** * * Represents the text frame for a shape object. @@ -35936,6 +36696,444 @@ declare namespace Excel { */ toJSON(): Excel.Interfaces.ShapeFontData; } + /** + * + * Represents a slicer object in the workbook. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + class Slicer extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; + /** + * + * Represents the collection of SlicerItems that are part of the slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly slicerItems: Excel.SlicerItemCollection; + /** + * + * Represents the worksheet containing the slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly worksheet: Excel.Worksheet; + /** + * + * Represents the caption of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + caption: string; + /** + * + * Represents the height, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + height: number; + /** + * + * Represents the unique id of slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly id: string; + /** + * + * True if all filters currently applied on the slicer is cleared. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly isFilterCleared: boolean; + /** + * + * Represents the distance, in points, from the left side of the slicer to the left of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + left: number; + /** + * + * Represents the name of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name: string; + /** + * + * Represents the name used in the formula. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + nameInFormula: string; + /** + * + * Represents the sort order of the items in the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + sortBy: Excel.SlicerSortType | "DataSourceOrder" | "Ascending" | "Descending"; + /** + * + * Constant value that represents the Slicer style. Possible values are: SlicerStyleLight1 thru SlicerStyleLight6, TableStyleOther1 thru TableStyleOther2, SlicerStyleDark1 thru SlicerStyleDark6. A custom user-defined style present in the workbook can also be specified. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style: string; + /** + * + * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + top: number; + /** + * + * Represents the width, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + width: number; + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Excel.Slicer): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ + set(properties: Interfaces.SlicerUpdateData, options?: OfficeExtension.UpdateOptions): void; + /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ + set(properties: Excel.Slicer): void; + /** + * + * Clears all the filters currently applied on the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + clearFilters(): void; + /** + * + * Deletes the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + delete(): void; + /** + * + * Returns an array of selected items' names. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getSelectedItems(): OfficeExtension.ClientResult; + /** + * + * Select slicer items based on their names. Previous selection will be cleared. + All items will be deselected if the array is empty. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param items Optional. The specified slicer item names to be selected. + */ + selectItems(items?: string[]): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Excel.Slicer` - Where option is a comma-delimited string or an array of strings that specify the properties to load. + * + * `load(option?: { select?: string; expand?: string; }): Excel.Slicer` - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.Slicer` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. + */ + load(option?: Excel.Interfaces.SlicerLoadOptions): Excel.Slicer; + load(option?: string | string[]): Excel.Slicer; + load(option?: { + select?: string; + expand?: string; + }): Excel.Slicer; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original Excel.Slicer object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.SlicerData`) that contains shallow copies of any loaded child properties from the original object. + */ + toJSON(): Excel.Interfaces.SlicerData; + } + /** + * + * Represents a collection of all the slicer objects on the workbook or a worksheet. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + class SlicerCollection extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; + /** Gets the loaded child items in this collection. */ + readonly items: Excel.Slicer[]; + /** + * + * Adds a new slicer to the workbook. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param slicerSource The data source that the new slicer will be based on. It can be a PivotTable object, a Table object or a string. When a PivotTable object is passed, the data source is the source of the PivotTable object. When a Table object is passed, the data source is the Table object. When a string is passed, it is interpreted as the name/id of a PivotTable/Table. + * @param sourceField The field in the data source to filter by. It can be a PivotField object, a TableColumn object, the id of a PivotField or the id/name of TableColumn. + * @param slicerDestination Optional. The worksheet where the new slicer will be created in. It can be a Worksheet object or the name/id of a worksheet. This parameter can be omitted if the slicer collection is retrieved from worksheet. + * @returns The new slicer. + */ + add(slicerSource: string | PivotTable | Table, sourceField: string | PivotField | number | TableColumn, slicerDestination?: string | Worksheet): Excel.Slicer; + /** + * + * Returns the number of slicers in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getCount(): OfficeExtension.ClientResult; + /** + * + * Gets a slicer object using its name or id. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param key The name or id of the slicer. + */ + getItem(key: string): Excel.Slicer; + /** + * + * Gets a slicer based on its position in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Slicer; + /** + * + * Gets a slicer using its name or id. If the slicer does not exist, will return a null object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param key Name or Id of the slicer to be retrieved. + */ + getItemOrNullObject(key: string): Excel.Slicer; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Excel.SlicerCollection` - Where option is a comma-delimited string or an array of strings that specify the properties to load. + * + * `load(option?: { select?: string; expand?: string; }): Excel.SlicerCollection` - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.SlicerCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. + */ + load(option?: Excel.Interfaces.SlicerCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.SlicerCollection; + load(option?: string | string[]): Excel.SlicerCollection; + load(option?: OfficeExtension.LoadOption): Excel.SlicerCollection; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original `Excel.SlicerCollection` object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.SlicerCollectionData`) that contains an "items" array with shallow copies of any loaded properties from the collection's items. + */ + toJSON(): Excel.Interfaces.SlicerCollectionData; + } + /** + * + * Represents a slicer item in a slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + class SlicerItem extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; + /** + * + * True if the slicer item has data. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly hasData: boolean; + /** + * + * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isSelected: boolean; + /** + * + * Represents the unique value representing the slicer item. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly key: string; + /** + * + * Represents the value displayed on UI. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly name: string; + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Excel.SlicerItem): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ + set(properties: Interfaces.SlicerItemUpdateData, options?: OfficeExtension.UpdateOptions): void; + /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ + set(properties: Excel.SlicerItem): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Excel.SlicerItem` - Where option is a comma-delimited string or an array of strings that specify the properties to load. + * + * `load(option?: { select?: string; expand?: string; }): Excel.SlicerItem` - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.SlicerItem` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. + */ + load(option?: Excel.Interfaces.SlicerItemLoadOptions): Excel.SlicerItem; + load(option?: string | string[]): Excel.SlicerItem; + load(option?: { + select?: string; + expand?: string; + }): Excel.SlicerItem; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original Excel.SlicerItem object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.SlicerItemData`) that contains shallow copies of any loaded child properties from the original object. + */ + toJSON(): Excel.Interfaces.SlicerItemData; + } + /** + * + * Represents a collection of all the slicer item objects on the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + class SlicerItemCollection extends OfficeExtension.ClientObject { + /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ + context: RequestContext; + /** Gets the loaded child items in this collection. */ + readonly items: Excel.SlicerItem[]; + /** + * + * Returns the number of slicer items in the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + getCount(): OfficeExtension.ClientResult; + /** + * + * Gets a slicer item object using its key or name. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param key The key or name of the slicer item. + */ + getItem(key: string): Excel.SlicerItem; + /** + * + * Gets a slicer item based on its position in the collection. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.SlicerItem; + /** + * + * Gets a slicer item using its key or name. If the slicer item does not exist, will return a null object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param key Key or name of the slicer to be retrieved. + */ + getItemOrNullObject(key: string): Excel.SlicerItem; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Excel.SlicerItemCollection` - Where option is a comma-delimited string or an array of strings that specify the properties to load. + * + * `load(option?: { select?: string; expand?: string; }): Excel.SlicerItemCollection` - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.SlicerItemCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. + */ + load(option?: Excel.Interfaces.SlicerItemCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.SlicerItemCollection; + load(option?: string | string[]): Excel.SlicerItemCollection; + load(option?: OfficeExtension.LoadOption): Excel.SlicerItemCollection; + /** + * Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to `JSON.stringify()`. (`JSON.stringify`, in turn, calls the `toJSON` method of the object that is passed to it.) + * Whereas the original `Excel.SlicerItemCollection` object is an API object, the `toJSON` method returns a plain JavaScript object (typed as `Excel.Interfaces.SlicerItemCollectionData`) that contains an "items" array with shallow copies of any loaded properties from the collection's items. + */ + toJSON(): Excel.Interfaces.SlicerItemCollectionData; + } /** * [Api set: ExcelApi 1.7] */ @@ -35958,21 +37156,21 @@ declare namespace Excel { * Axis displays data series. * */ - series = "Series", + series = "Series" } /** * [Api set: ExcelApi 1.7] */ enum ChartAxisGroup { primary = "Primary", - secondary = "Secondary", + secondary = "Secondary" } /** * [Api set: ExcelApi 1.7] */ enum ChartAxisScaleType { linear = "Linear", - logarithmic = "Logarithmic", + logarithmic = "Logarithmic" } /** * [Api set: ExcelApi 1.7] @@ -35981,7 +37179,7 @@ declare namespace Excel { automatic = "Automatic", maximum = "Maximum", minimum = "Minimum", - custom = "Custom", + custom = "Custom" } /** * [Api set: ExcelApi 1.7] @@ -35990,7 +37188,7 @@ declare namespace Excel { none = "None", cross = "Cross", inside = "Inside", - outside = "Outside", + outside = "Outside" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -35999,7 +37197,7 @@ declare namespace Excel { enum CalculationState { done = "Done", calculating = "Calculating", - pending = "Pending", + pending = "Pending" } /** * [Api set: ExcelApi 1.7] @@ -36008,7 +37206,7 @@ declare namespace Excel { nextToAxis = "NextToAxis", high = "High", low = "Low", - none = "None", + none = "None" } /** * [Api set: ExcelApi 1.7] @@ -36079,7 +37277,7 @@ declare namespace Excel { * This will set the axis in units of custom value. * */ - custom = "Custom", + custom = "Custom" } /** * @@ -36090,7 +37288,7 @@ declare namespace Excel { enum ChartAxisTimeUnit { days = "Days", months = "Months", - years = "Years", + years = "Years" } /** * @@ -36101,7 +37299,7 @@ declare namespace Excel { */ enum ChartBoxQuartileCalculation { inclusive = "Inclusive", - exclusive = "Exclusive", + exclusive = "Exclusive" } /** * @@ -36127,7 +37325,7 @@ declare namespace Excel { * Axis groups data on a time scale. * */ - dateAxis = "DateAxis", + dateAxis = "DateAxis" } /** * @@ -36140,7 +37338,7 @@ declare namespace Excel { category = "Category", auto = "Auto", binWidth = "BinWidth", - binCount = "BinCount", + binCount = "BinCount" } /** * [Api set: ExcelApi 1.7] @@ -36156,7 +37354,7 @@ declare namespace Excel { grey50 = "Grey50", grey75 = "Grey75", automatic = "Automatic", - roundDot = "RoundDot", + roundDot = "RoundDot" } /** * [Api set: ExcelApi 1.1] @@ -36173,7 +37371,7 @@ declare namespace Excel { top = "Top", bottom = "Bottom", bestFit = "BestFit", - callout = "Callout", + callout = "Callout" } /** * @@ -36185,7 +37383,7 @@ declare namespace Excel { enum ChartErrorBarsInclude { both = "Both", minusValues = "MinusValues", - plusValues = "PlusValues", + plusValues = "PlusValues" } /** * @@ -36199,7 +37397,7 @@ declare namespace Excel { percent = "Percent", stDev = "StDev", stError = "StError", - custom = "Custom", + custom = "Custom" } /** * @@ -36216,7 +37414,7 @@ declare namespace Excel { state = "State", country = "Country", continent = "Continent", - world = "World", + world = "World" } /** * @@ -36227,7 +37425,7 @@ declare namespace Excel { */ enum ChartGradientStyle { twoPhaseColor = "TwoPhaseColor", - threePhaseColor = "ThreePhaseColor", + threePhaseColor = "ThreePhaseColor" } /** * @@ -36239,7 +37437,7 @@ declare namespace Excel { enum ChartGradientStyleType { extremeValue = "ExtremeValue", number = "Number", - percent = "Percent", + percent = "Percent" } /** * @@ -36252,7 +37450,7 @@ declare namespace Excel { top = "Top", bottom = "Bottom", left = "Left", - right = "Right", + right = "Right" } /** * [Api set: ExcelApi 1.1] @@ -36264,7 +37462,7 @@ declare namespace Excel { left = "Left", right = "Right", corner = "Corner", - custom = "Custom", + custom = "Custom" } /** * [Api set: ExcelApi 1.7] @@ -36282,14 +37480,14 @@ declare namespace Excel { dash = "Dash", circle = "Circle", plus = "Plus", - picture = "Picture", + picture = "Picture" } /** * [Api set: ExcelApi 1.8] */ enum ChartPlotAreaPosition { automatic = "Automatic", - custom = "Custom", + custom = "Custom" } /** * @@ -36301,7 +37499,7 @@ declare namespace Excel { enum ChartMapLabelStrategy { none = "None", bestFit = "BestFit", - showAll = "ShowAll", + showAll = "ShowAll" } /** * @@ -36315,7 +37513,7 @@ declare namespace Excel { mercator = "Mercator", miller = "Miller", robinson = "Robinson", - albers = "Albers", + albers = "Albers" } /** * @@ -36327,7 +37525,7 @@ declare namespace Excel { enum ChartParentLabelStrategy { none = "None", banner = "Banner", - overlapping = "Overlapping", + overlapping = "Overlapping" } /** * @@ -36343,7 +37541,7 @@ declare namespace Excel { */ auto = "Auto", columns = "Columns", - rows = "Rows", + rows = "Rows" } /** * @@ -36356,7 +37554,7 @@ declare namespace Excel { left = "Left", right = "Right", justify = "Justify", - distributed = "Distributed", + distributed = "Distributed" } /** * @@ -36369,7 +37567,7 @@ declare namespace Excel { bottom = "Bottom", top = "Top", justify = "Justify", - distributed = "Distributed", + distributed = "Distributed" } /** * [Api set: ExcelApi 1.8] @@ -36377,7 +37575,7 @@ declare namespace Excel { enum ChartTickLabelAlignment { center = "Center", left = "Left", - right = "Right", + right = "Right" } /** * [Api set: ExcelApi 1.1] @@ -36464,14 +37662,14 @@ declare namespace Excel { treemap = "Treemap", waterfall = "Waterfall", sunburst = "Sunburst", - funnel = "Funnel", + funnel = "Funnel" } /** * [Api set: ExcelApi 1.1] */ enum ChartUnderlineStyle { none = "None", - single = "Single", + single = "Single" } /** * [Api set: ExcelApi 1.8] @@ -36479,14 +37677,14 @@ declare namespace Excel { enum ChartDisplayBlanksAs { notPlotted = "NotPlotted", zero = "Zero", - interplotted = "Interplotted", + interplotted = "Interplotted" } /** * [Api set: ExcelApi 1.8] */ enum ChartPlotBy { rows = "Rows", - columns = "Columns", + columns = "Columns" } /** * [Api set: ExcelApi 1.8] @@ -36495,7 +37693,7 @@ declare namespace Excel { splitByPosition = "SplitByPosition", splitByValue = "SplitByValue", splitByPercentValue = "SplitByPercentValue", - splitByCustomSplit = "SplitByCustomSplit", + splitByCustomSplit = "SplitByCustomSplit" } /** * [Api set: ExcelApi 1.8] @@ -36517,7 +37715,7 @@ declare namespace Excel { monochromaticPalette10 = "MonochromaticPalette10", monochromaticPalette11 = "MonochromaticPalette11", monochromaticPalette12 = "MonochromaticPalette12", - monochromaticPalette13 = "MonochromaticPalette13", + monochromaticPalette13 = "MonochromaticPalette13" } /** * [Api set: ExcelApi 1.7] @@ -36528,7 +37726,7 @@ declare namespace Excel { logarithmic = "Logarithmic", movingAverage = "MovingAverage", polynomial = "Polynomial", - power = "Power", + power = "Power" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36538,7 +37736,7 @@ declare namespace Excel { bringToFront = "BringToFront", bringForward = "BringForward", sendToBack = "SendToBack", - sendBackward = "SendBackward", + sendBackward = "SendBackward" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36549,6 +37747,7 @@ declare namespace Excel { image = "Image", geometricShape = "GeometricShape", group = "Group", + line = "Line" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36556,7 +37755,7 @@ declare namespace Excel { */ enum ShapeScaleType { currentSize = "CurrentSize", - originalSize = "OriginalSize", + originalSize = "OriginalSize" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36565,7 +37764,7 @@ declare namespace Excel { enum ShapeScaleFrom { scaleFromTopLeft = "ScaleFromTopLeft", scaleFromMiddle = "ScaleFromMiddle", - scaleFromBottomRight = "ScaleFromBottomRight", + scaleFromBottomRight = "ScaleFromBottomRight" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36577,7 +37776,7 @@ declare namespace Excel { gradient = "Gradient", pattern = "Pattern", pictureAndTexture = "PictureAndTexture", - mixed = "Mixed", + mixed = "Mixed" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36600,7 +37799,7 @@ declare namespace Excel { dotDotDashHeavy = "DotDotDashHeavy", wavy = "Wavy", wavyHeavy = "WavyHeavy", - wavyDouble = "WavyDouble", + wavyDouble = "WavyDouble" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -36612,7 +37811,36 @@ declare namespace Excel { jpeg = "JPEG", gif = "GIF", png = "PNG", - svg = "SVG", + svg = "SVG" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ShapeLineStyle { + single = "Single", + thickBetweenThin = "ThickBetweenThin", + thickThin = "ThickThin", + thinThick = "ThinThick", + thinThin = "ThinThin" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ShapeLineDashStyle { + dash = "Dash", + dashDot = "DashDot", + dashDotDot = "DashDotDot", + longDash = "LongDash", + longDashDot = "LongDashDot", + roundDot = "RoundDot", + solid = "Solid", + squareDot = "SquareDot", + longDashDotDot = "LongDashDotDot", + systemDash = "SystemDash", + systemDot = "SystemDot", + systemDashDot = "SystemDashDot" } /** * [Api set: ExcelApi 1.1] @@ -36620,7 +37848,7 @@ declare namespace Excel { enum BindingType { range = "Range", table = "Table", - text = "Text", + text = "Text" } /** * [Api set: ExcelApi 1.1] @@ -36633,7 +37861,7 @@ declare namespace Excel { insideVertical = "InsideVertical", insideHorizontal = "InsideHorizontal", diagonalDown = "DiagonalDown", - diagonalUp = "DiagonalUp", + diagonalUp = "DiagonalUp" } /** * [Api set: ExcelApi 1.1] @@ -36646,7 +37874,7 @@ declare namespace Excel { dashDotDot = "DashDotDot", dot = "Dot", double = "Double", - slantDashDot = "SlantDashDot", + slantDashDot = "SlantDashDot" } /** * [Api set: ExcelApi 1.1] @@ -36655,15 +37883,30 @@ declare namespace Excel { hairline = "Hairline", thin = "Thin", medium = "Medium", - thick = "Thick", + thick = "Thick" } /** * [Api set: ExcelApi 1.1] */ enum CalculationMode { + /** + * + * The default recalculation behavior where Excel calculates new formula results every time the relevant data is changed. + * + */ automatic = "Automatic", + /** + * + * Calculates new formula results every time the relevant data is changed, unless the formula is in a data table. + * + */ automaticExceptTables = "AutomaticExceptTables", - manual = "Manual", + /** + * + * Calculations only occur when the user or add-in requests them. + * + */ + manual = "Manual" } /** * [Api set: ExcelApi 1.1] @@ -36686,7 +37929,7 @@ declare namespace Excel { * This will rebuild the full dependency chain, mark all cells as dirty and then recalculate them. * */ - fullRebuild = "FullRebuild", + fullRebuild = "FullRebuild" } /** * [Api set: ExcelApi 1.1 for All/Formats/Contents, 1.7 for Hyperlinks & HyperlinksAndFormats.] @@ -36716,7 +37959,7 @@ declare namespace Excel { * Removes hyperlinks and formatting for the cell but leaves content, conditional formats, and data validation intact. * */ - removeHyperlinks = "RemoveHyperlinks", + removeHyperlinks = "RemoveHyperlinks" } /** * @@ -36727,7 +37970,7 @@ declare namespace Excel { enum ConditionalDataBarAxisFormat { automatic = "Automatic", none = "None", - cellMidPoint = "CellMidPoint", + cellMidPoint = "CellMidPoint" } /** * @@ -36738,7 +37981,7 @@ declare namespace Excel { enum ConditionalDataBarDirection { context = "Context", leftToRight = "LeftToRight", - rightToLeft = "RightToLeft", + rightToLeft = "RightToLeft" } /** * @@ -36748,7 +37991,7 @@ declare namespace Excel { */ enum ConditionalFormatDirection { top = "Top", - bottom = "Bottom", + bottom = "Bottom" } /** * [Api set: ExcelApi 1.6] @@ -36761,7 +38004,7 @@ declare namespace Excel { topBottom = "TopBottom", presetCriteria = "PresetCriteria", containsText = "ContainsText", - cellValue = "CellValue", + cellValue = "CellValue" } /** * @@ -36777,7 +38020,7 @@ declare namespace Excel { number = "Number", percent = "Percent", formula = "Formula", - percentile = "Percentile", + percentile = "Percentile" } /** * @@ -36790,7 +38033,7 @@ declare namespace Excel { number = "Number", percent = "Percent", formula = "Formula", - percentile = "Percentile", + percentile = "Percentile" } /** * @@ -36805,7 +38048,7 @@ declare namespace Excel { number = "Number", percent = "Percent", formula = "Formula", - percentile = "Percentile", + percentile = "Percentile" } /** * @@ -36818,7 +38061,7 @@ declare namespace Excel { topItems = "TopItems", topPercent = "TopPercent", bottomItems = "BottomItems", - bottomPercent = "BottomPercent", + bottomPercent = "BottomPercent" } /** * @@ -36853,7 +38096,7 @@ declare namespace Excel { threeStdDevAboveAverage = "ThreeStdDevAboveAverage", threeStdDevBelowAverage = "ThreeStdDevBelowAverage", uniqueValues = "UniqueValues", - duplicateValues = "DuplicateValues", + duplicateValues = "DuplicateValues" } /** * @@ -36866,7 +38109,7 @@ declare namespace Excel { contains = "Contains", notContains = "NotContains", beginsWith = "BeginsWith", - endsWith = "EndsWith", + endsWith = "EndsWith" } /** * @@ -36883,7 +38126,7 @@ declare namespace Excel { greaterThan = "GreaterThan", lessThan = "LessThan", greaterThanOrEqual = "GreaterThanOrEqual", - lessThanOrEqual = "LessThanOrEqual", + lessThanOrEqual = "LessThanOrEqual" } /** * @@ -36894,7 +38137,7 @@ declare namespace Excel { enum ConditionalIconCriterionOperator { invalid = "Invalid", greaterThan = "GreaterThan", - greaterThanOrEqual = "GreaterThanOrEqual", + greaterThanOrEqual = "GreaterThanOrEqual" } /** * [Api set: ExcelApi 1.6] @@ -36903,7 +38146,7 @@ declare namespace Excel { edgeTop = "EdgeTop", edgeBottom = "EdgeBottom", edgeLeft = "EdgeLeft", - edgeRight = "EdgeRight", + edgeRight = "EdgeRight" } /** * [Api set: ExcelApi 1.6] @@ -36914,7 +38157,7 @@ declare namespace Excel { dash = "Dash", dashDot = "DashDot", dashDotDot = "DashDotDot", - dot = "Dot", + dot = "Dot" } /** * [Api set: ExcelApi 1.6] @@ -36922,7 +38165,7 @@ declare namespace Excel { enum ConditionalRangeFontUnderlineStyle { none = "None", single = "Single", - double = "Double", + double = "Double" } /** * [Api set: CustomFunctions 1.1] @@ -36931,7 +38174,7 @@ declare namespace Excel { enum CustomFunctionType { invalid = "Invalid", script = "Script", - webService = "WebService", + webService = "WebService" } /** * [Api set: CustomFunctions 1.1] @@ -36939,7 +38182,7 @@ declare namespace Excel { */ enum CustomFunctionMetadataFormat { invalid = "Invalid", - openApi = "OpenApi", + openApi = "OpenApi" } /** * @@ -37007,7 +38250,7 @@ declare namespace Excel { * MixedCriteria means that the range has data validation present on some but not all cells * */ - mixedCriteria = "MixedCriteria", + mixedCriteria = "MixedCriteria" } /** * @@ -37023,7 +38266,7 @@ declare namespace Excel { greaterThan = "GreaterThan", lessThan = "LessThan", greaterThanOrEqualTo = "GreaterThanOrEqualTo", - lessThanOrEqualTo = "LessThanOrEqualTo", + lessThanOrEqualTo = "LessThanOrEqualTo" } /** * @@ -37034,14 +38277,14 @@ declare namespace Excel { enum DataValidationAlertStyle { stop = "Stop", warning = "Warning", - information = "Information", + information = "Information" } /** * [Api set: ExcelApi 1.1] */ enum DeleteShiftDirection { up = "Up", - left = "Left", + left = "Left" } /** * [Api set: ExcelApi 1.2] @@ -37081,7 +38324,7 @@ declare namespace Excel { today = "Today", tomorrow = "Tomorrow", yearToDate = "YearToDate", - yesterday = "Yesterday", + yesterday = "Yesterday" } /** * [Api set: ExcelApi 1.2] @@ -37092,7 +38335,7 @@ declare namespace Excel { day = "Day", hour = "Hour", minute = "Minute", - second = "Second", + second = "Second" } /** * [Api set: ExcelApi 1.2] @@ -37107,14 +38350,14 @@ declare namespace Excel { topItems = "TopItems", topPercent = "TopPercent", icon = "Icon", - custom = "Custom", + custom = "Custom" } /** * [Api set: ExcelApi 1.2] */ enum FilterOperator { and = "And", - or = "Or", + or = "Or" } /** * [Api set: ExcelApi 1.1] @@ -37127,7 +38370,7 @@ declare namespace Excel { fill = "Fill", justify = "Justify", centerAcrossSelection = "CenterAcrossSelection", - distributed = "Distributed", + distributed = "Distributed" } /** * [Api set: ExcelApi 1.2] @@ -37155,7 +38398,7 @@ declare namespace Excel { threeTriangles = "ThreeTriangles", fiveBoxes = "FiveBoxes", linkedEntityFinanceIcon = "LinkedEntityFinanceIcon", - linkedEntityMapIcon = "LinkedEntityMapIcon", + linkedEntityMapIcon = "LinkedEntityMapIcon" } /** * [Api set: ExcelApi 1.2] @@ -37163,21 +38406,21 @@ declare namespace Excel { enum ImageFittingMode { fit = "Fit", fitAndCenter = "FitAndCenter", - fill = "Fill", + fill = "Fill" } /** * [Api set: ExcelApi 1.1] */ enum InsertShiftDirection { down = "Down", - right = "Right", + right = "Right" } /** * [Api set: ExcelApi 1.4] */ enum NamedItemScope { worksheet = "Worksheet", - workbook = "Workbook", + workbook = "Workbook" } /** * [Api set: ExcelApi 1.1 for String,Integer,Double,Boolean,Range,Error; 1.7 for Array] @@ -37189,7 +38432,7 @@ declare namespace Excel { boolean = "Boolean", range = "Range", error = "Error", - array = "Array", + array = "Array" } /** * [Api set: ExcelApi 1.1] @@ -37199,7 +38442,7 @@ declare namespace Excel { single = "Single", double = "Double", singleAccountant = "SingleAccountant", - doubleAccountant = "DoubleAccountant", + doubleAccountant = "DoubleAccountant" } /** * [Api set: ExcelApi 1.1] @@ -37207,7 +38450,7 @@ declare namespace Excel { enum SheetVisibility { visible = "Visible", hidden = "Hidden", - veryHidden = "VeryHidden", + veryHidden = "VeryHidden" } /** * [Api set: ExcelApi 1.1 for Unknown, Empty, String, Integer, Double, Boolean, Error. 1.7 for RichValue] @@ -37220,7 +38463,7 @@ declare namespace Excel { double = "Double", boolean = "Boolean", error = "Error", - richValue = "RichValue", + richValue = "RichValue" } /** * @@ -37241,14 +38484,14 @@ declare namespace Excel { * Search in reverse order. * */ - backwards = "Backwards", + backwards = "Backwards" } /** * [Api set: ExcelApi 1.2] */ enum SortOrientation { rows = "Rows", - columns = "Columns", + columns = "Columns" } /** * [Api set: ExcelApi 1.2] @@ -37257,21 +38500,21 @@ declare namespace Excel { value = "Value", cellColor = "CellColor", fontColor = "FontColor", - icon = "Icon", + icon = "Icon" } /** * [Api set: ExcelApi 1.2] */ enum SortDataOption { normal = "Normal", - textAsNumber = "TextAsNumber", + textAsNumber = "TextAsNumber" } /** * [Api set: ExcelApi 1.2] */ enum SortMethod { pinYin = "PinYin", - strokeCount = "StrokeCount", + strokeCount = "StrokeCount" } /** * [Api set: ExcelApi 1.1] @@ -37281,7 +38524,7 @@ declare namespace Excel { center = "Center", bottom = "Bottom", justify = "Justify", - distributed = "Distributed", + distributed = "Distributed" } /** * [Api set: ExcelApi 1.7] @@ -37291,7 +38534,7 @@ declare namespace Excel { boolean = "Boolean", date = "Date", string = "String", - float = "Float", + float = "Float" } /** * [Api set: ExcelApi 1.7] @@ -37308,7 +38551,7 @@ declare namespace Excel { * Remote means event comes from remote user session. * */ - remote = "Remote", + remote = "Remote" } /** * [Api set: ExcelApi 1.7] @@ -37361,7 +38604,7 @@ declare namespace Excel { * CellDeleted represents the data change event is triggered by deleting cells. * */ - cellDeleted = "CellDeleted", + cellDeleted = "CellDeleted" } /** * [Api set: ExcelApi 1.7] @@ -37511,6 +38754,7 @@ declare namespace Excel { * */ worksheetFormatChanged = "WorksheetFormatChanged", + wacoperationEvent = "WACOperationEvent" } /** * [Api set: ExcelApi 1.7] @@ -37531,7 +38775,7 @@ declare namespace Excel { category = "Category", format = "Format", manager = "Manager", - company = "Company", + company = "Company" } /** * [Api set: ExcelApi 1.8] @@ -37554,7 +38798,7 @@ declare namespace Excel { * Subtotals are off. * */ - off = "Off", + off = "Off" } /** * [Api set: ExcelApi 1.8] @@ -37577,7 +38821,7 @@ declare namespace Excel { * Inner fields' items are on same row as outer fields' items and subtotals are always on the bottom. * */ - outline = "Outline", + outline = "Outline" } /** * [Api set: ExcelApi 1.7] @@ -37600,14 +38844,14 @@ declare namespace Excel { * Selection is not allowed for all cells. * */ - none = "None", + none = "None" } /** * [Api set: ExcelApi 1.7] */ enum PageOrientation { portrait = "Portrait", - landscape = "Landscape", + landscape = "Landscape" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37654,7 +38898,7 @@ declare namespace Excel { envelopePersonal = "EnvelopePersonal", fanfoldUS = "FanfoldUS", fanfoldStdGerman = "FanfoldStdGerman", - fanfoldLegalGerman = "FanfoldLegalGerman", + fanfoldLegalGerman = "FanfoldLegalGerman" } /** * [Api set: ExcelApi 1.7] @@ -37679,7 +38923,7 @@ declare namespace Excel { * Right to left reading order * */ - rightToLeft = "RightToLeft", + rightToLeft = "RightToLeft" } /** * [Api set: ExcelApi 1.7] @@ -37736,7 +38980,7 @@ declare namespace Excel { accent6_20 = "Accent6_20", accent6_40 = "Accent6_40", accent6_60 = "Accent6_60", - explanatoryText = "ExplanatoryText", + explanatoryText = "ExplanatoryText" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37746,7 +38990,7 @@ declare namespace Excel { asDisplayed = "AsDisplayed", blank = "Blank", dash = "Dash", - notAvailable = "NotAvailable", + notAvailable = "NotAvailable" } /** * [Api set: ExcelApi 1.7] @@ -37756,7 +39000,7 @@ declare namespace Excel { before = "Before", after = "After", beginning = "Beginning", - end = "End", + end = "End" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37780,7 +39024,7 @@ declare namespace Excel { * Comments will be printed where they were inserted in the worksheet. * */ - inPlace = "InPlace", + inPlace = "InPlace" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37798,7 +39042,7 @@ declare namespace Excel { * Process across pages or page fields to the right before moving down the rows. * */ - overThenDown = "OverThenDown", + overThenDown = "OverThenDown" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37822,7 +39066,7 @@ declare namespace Excel { * Assign the page margins in centimeters. * */ - centimeters = "Centimeters", + centimeters = "Centimeters" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37852,7 +39096,25 @@ declare namespace Excel { * There is a separate first page header/footer, then there is a separate header/footer for odd and even pages. * */ - firstOddAndEven = "FirstOddAndEven", + firstOddAndEven = "FirstOddAndEven" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum AutoFillType { + fillDefault = "FillDefault", + fillCopy = "FillCopy", + fillSeries = "FillSeries", + fillFormats = "FillFormats", + fillValues = "FillValues", + fillDays = "FillDays", + fillWeekdays = "FillWeekdays", + fillMonths = "FillMonths", + fillYears = "FillYears", + linearTrend = "LinearTrend", + growthTrend = "GrowthTrend", + flashFill = "FlashFill" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37862,7 +39124,7 @@ declare namespace Excel { all = "All", formulas = "Formulas", values = "Values", - formats = "Formats", + formats = "Formats" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37873,7 +39135,7 @@ declare namespace Excel { validLinkedData = "ValidLinkedData", disambiguationNeeded = "DisambiguationNeeded", brokenLinkedData = "BrokenLinkedData", - fetchingData = "FetchingData", + fetchingData = "FetchingData" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38056,7 +39318,16 @@ declare namespace Excel { plaqueTabs = "PlaqueTabs", chartX = "ChartX", chartStar = "ChartStar", - chartPlus = "ChartPlus", + chartPlus = "ChartPlus" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ConnectorType { + straight = "Straight", + elbow = "Elbow", + curve = "Curve" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38068,7 +39339,7 @@ declare namespace Excel { * Indicates plain format type of the comment content. * */ - plain = "Plain", + plain = "Plain" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38128,7 +39399,7 @@ declare namespace Excel { * Cells that are visible. * */ - visible = "Visible", + visible = "Visible" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38224,7 +39495,7 @@ declare namespace Excel { * Cells that have a string value. * */ - text = "Text", + text = "Text" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38233,7 +39504,7 @@ declare namespace Excel { enum Placement { twoCell = "TwoCell", oneCell = "OneCell", - absolute = "Absolute", + absolute = "Absolute" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38260,7 +39531,7 @@ declare namespace Excel { gray16 = "Gray16", gray8 = "Gray8", linearGradient = "LinearGradient", - rectangularGradient = "RectangularGradient", + rectangularGradient = "RectangularGradient" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38274,7 +39545,7 @@ declare namespace Excel { justifyLow = "JustifyLow", distributed = "Distributed", thaiDistributed = "ThaiDistributed", - shapeTextHorizontalAlignType_MaxEnumIDs = "ShapeTextHorizontalAlignType_MaxEnumIDs", + shapeTextHorizontalAlignType_MaxEnumIDs = "ShapeTextHorizontalAlignType_MaxEnumIDs" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38286,7 +39557,7 @@ declare namespace Excel { bottom = "Bottom", justified = "Justified", distributed = "Distributed", - shapeTextVerticalAlignType_MaxEnumIDs = "ShapeTextVerticalAlignType_MaxEnumIDs", + shapeTextVerticalAlignType_MaxEnumIDs = "ShapeTextVerticalAlignType_MaxEnumIDs" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38296,7 +39567,7 @@ declare namespace Excel { overflow = "Overflow", ellipsis = "Ellipsis", clip = "Clip", - shapeTextVertOverflowType_MaxEnumIDs = "ShapeTextVertOverflowType_MaxEnumIDs", + shapeTextVertOverflowType_MaxEnumIDs = "ShapeTextVertOverflowType_MaxEnumIDs" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38305,7 +39576,7 @@ declare namespace Excel { enum ShapeTextHorzOverflowType { overflow = "Overflow", clip = "Clip", - shapeTextHorzOverflowType_MaxEnumIDs = "ShapeTextHorzOverflowType_MaxEnumIDs", + shapeTextHorzOverflowType_MaxEnumIDs = "ShapeTextHorzOverflowType_MaxEnumIDs" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38313,7 +39584,7 @@ declare namespace Excel { */ enum ShapeTextReadingOrder { ltr = "LTR", - rtl = "RTL", + rtl = "RTL" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38327,7 +39598,7 @@ declare namespace Excel { eastAsianVertical = "EastAsianVertical", mongolianVertical = "MongolianVertical", wordArtVerticalRTL = "WordArtVerticalRTL", - shapeTextOrientationType_MaxEnumIDs = "ShapeTextOrientationType_MaxEnumIDs", + shapeTextOrientationType_MaxEnumIDs = "ShapeTextOrientationType_MaxEnumIDs" } /** * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -38337,7 +39608,7 @@ declare namespace Excel { autoSizeNone = "AutoSizeNone", autoSizeTextToFitShape = "AutoSizeTextToFitShape", autoSizeShapeToFitText = "AutoSizeShapeToFitText", - autoSizeMixed = "AutoSizeMixed", + autoSizeMixed = "AutoSizeMixed" } /** * @@ -38358,7 +39629,7 @@ declare namespace Excel { * Discard the possible changes when closing the workbook. * */ - skipSave = "SkipSave", + skipSave = "SkipSave" } /** * @@ -38381,7 +39652,16 @@ declare namespace Excel { Ignored if the workbook was previously saved. * */ - prompt = "Prompt", + prompt = "Prompt" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum SlicerSortType { + dataSourceOrder = "DataSourceOrder", + ascending = "Ascending", + descending = "Descending" } /** * @@ -42202,7 +43482,7 @@ declare namespace Excel { nonBlankCellOffSheet = "NonBlankCellOffSheet", notImplemented = "NotImplemented", unsupportedOperation = "UnsupportedOperation", - invalidOperationInCellEditMode = "InvalidOperationInCellEditMode", + invalidOperationInCellEditMode = "InvalidOperationInCellEditMode" } module Interfaces { /** @@ -42222,7 +43502,7 @@ declare namespace Excel { interface RuntimeUpdateData { /** * - * Turn on/off JavaScript events in current taskpane or content add-in. + * Toggle JavaScript events in the current task pane or content add-in. * * [Api set: ExcelApi 1.8] */ @@ -42744,7 +44024,7 @@ declare namespace Excel { prompt?: Excel.DataValidationPrompt; /** * - * Data Validation rule that contains different type of data validation criteria. + * Data validation rule that contains different type of data validation criteria. * * [Api set: ExcelApi 1.8] */ @@ -42898,7 +44178,7 @@ declare namespace Excel { interface RangeFillUpdateData { /** * - * HTML color code representing the color of the background, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") * * [Api set: ExcelApi 1.1] */ @@ -43121,7 +44401,7 @@ declare namespace Excel { plotArea?: Excel.Interfaces.ChartPlotAreaUpdateData; /** * - * Represents the title of the specified chart, including the text, visibility, position, and formating of the title. + * Represents the title of the specified chart, including the text, visibility, position, and formatting of the title. * * [Api set: ExcelApi 1.1] */ @@ -43200,7 +44480,7 @@ declare namespace Excel { showAllFieldButtons?: boolean; /** * - * Represents whether to to show the data labels when the value is greater than the maximum value on the value axis. + * Represents whether to show the data labels when the value is greater than the maximum value on the value axis. If value axis became smaller than the size of data points, you can use this property to set whether to show the data labels. This property applies to 2-D charts only. * @@ -43556,7 +44836,7 @@ declare namespace Excel { name?: string; /** * - * Specifies how bars and columns are positioned. Can be a value between – 100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. + * Specifies how bars and columns are positioned. Can be a value between –100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. * * [Api set: ExcelApi 1.8] */ @@ -44026,7 +45306,7 @@ declare namespace Excel { format?: Excel.Interfaces.ChartDataLabelFormatUpdateData; /** * - * Represents whether data labels automatically generates appropriate text based on context. + * Represents whether data labels automatically generate appropriate text based on context. * * [Api set: ExcelApi 1.8] */ @@ -45080,6 +46360,14 @@ declare namespace Excel { } /** An interface for updating data on the PivotTable object, for use in "pivotTable.set({ ... })". */ interface PivotTableUpdateData { + /** + * + * True if the PivotTable should use custom lists when sorting. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enableDataValueEditing?: boolean; /** * * Name of the PivotTable. @@ -45098,6 +46386,14 @@ declare namespace Excel { } /** An interface for updating data on the PivotLayout object, for use in "pivotLayout.set({ ... })". */ interface PivotLayoutUpdateData { + /** + * + * True if formatting will be automatically formatted when it’s refreshed or when fields are moved + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + autoFormat?: boolean; /** * * True if the field list should be shown or hidden from the UI. @@ -45113,6 +46409,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.8] */ layoutType?: Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline"; + /** + * + * True if formatting is preserved when the report is refreshed or recalculated by operations such as pivoting, sorting, or changing page field items. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + preserveFormatting?: boolean; /** * * True if the PivotTable report shows grand totals for columns. @@ -45234,7 +46538,7 @@ declare namespace Excel { position?: number; /** * - * Determines whether the data should be sown as a specific summary calculation or not. + * Determines whether the data should be shown as a specific summary calculation or not. * * [Api set: ExcelApi 1.8] */ @@ -46367,10 +47671,32 @@ declare namespace Excel { interface CommentCollectionUpdateData { items?: Excel.Interfaces.CommentData[]; } + /** An interface for updating data on the Comment object, for use in "comment.set({ ... })". */ + interface CommentUpdateData { + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: string; + } /** An interface for updating data on the CommentReplyCollection object, for use in "commentReplyCollection.set({ ... })". */ interface CommentReplyCollectionUpdateData { items?: Excel.Interfaces.CommentReplyData[]; } + /** An interface for updating data on the CommentReply object, for use in "commentReply.set({ ... })". */ + interface CommentReplyUpdateData { + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: string; + } /** An interface for updating data on the ShapeCollection object, for use in "shapeCollection.set({ ... })". */ interface ShapeCollectionUpdateData { items?: Excel.Interfaces.ShapeData[]; @@ -46385,6 +47711,14 @@ declare namespace Excel { * @beta */ fill?: Excel.Interfaces.ShapeFillUpdateData; + /** + * + * Returns the line formatting of the shape object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + lineFormat?: Excel.Interfaces.ShapeLineFormatUpdateData; /** * * Returns or sets the alternative descriptive text string for a Shape object when the object is saved to a Web page. @@ -46435,6 +47769,14 @@ declare namespace Excel { * @beta */ lockAspectRatio?: boolean; + /** + * + * Represents the name of the shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: string; /** * * Represents the placment, value that represents the way the object is attached to the cells below it. @@ -46482,6 +47824,17 @@ declare namespace Excel { interface GroupShapeCollectionUpdateData { items?: Excel.Interfaces.ShapeData[]; } + /** An interface for updating data on the Line object, for use in "line.set({ ... })". */ + interface LineUpdateData { + /** + * + * Represents the connector type for the line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectorType?: Excel.ConnectorType | "Straight" | "Elbow" | "Curve"; + } /** An interface for updating data on the ShapeFill object, for use in "shapeFill.set({ ... })". */ interface ShapeFillUpdateData { /** @@ -46501,6 +47854,57 @@ declare namespace Excel { */ transparency?: number; } + /** An interface for updating data on the ShapeLineFormat object, for use in "shapeLineFormat.set({ ... })". */ + interface ShapeLineFormatUpdateData { + /** + * + * Represents the line color in HTML color format, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + color?: string; + /** + * + * Represents the line style of the shape. Returns null when line is not visible or has mixed line dash style property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + dashStyle?: Excel.ShapeLineDashStyle | "Dash" | "DashDot" | "DashDotDot" | "LongDash" | "LongDashDot" | "RoundDot" | "Solid" | "SquareDot" | "LongDashDotDot" | "SystemDash" | "SystemDot" | "SystemDashDot"; + /** + * + * Represents the line style of the shape object. Returns null when line is not visible or has mixed line visible property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: Excel.ShapeLineStyle | "Single" | "ThickBetweenThin" | "ThickThin" | "ThinThick" | "ThinThin"; + /** + * + * Represents the degree of transparency of the specified line as a value from 0.0 (opaque) through 1.0 (clear). Returns null when the shape has mixed line transparency property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + transparency?: number; + /** + * + * Represents whether the line formatting of a shape element is visible. Returns null when the shape has mixed line visible property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + visible?: boolean; + /** + * + * Represents weight of the line, in points. Returns null when the line is not visible or has mixed line weight property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + weight?: number; + } /** An interface for updating data on the TextFrame object, for use in "textFrame.set({ ... })". */ interface TextFrameUpdateData { /** @@ -46662,11 +48066,117 @@ declare namespace Excel { */ underline?: Excel.ShapeFontUnderlineStyle | "None" | "Single" | "Double" | "Heavy" | "Dotted" | "DottedHeavy" | "Dash" | "DashHeavy" | "DashLong" | "DashLongHeavy" | "DotDash" | "DotDashHeavy" | "DotDotDash" | "DotDotDashHeavy" | "Wavy" | "WavyHeavy" | "WavyDouble"; } + /** An interface for updating data on the Slicer object, for use in "slicer.set({ ... })". */ + interface SlicerUpdateData { + /** + * + * Represents the worksheet containing the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + worksheet?: Excel.Interfaces.WorksheetUpdateData; + /** + * + * Represents the caption of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + caption?: string; + /** + * + * Represents the height, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + height?: number; + /** + * + * Represents the distance, in points, from the left side of the slicer to the left of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + left?: number; + /** + * + * Represents the name of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: string; + /** + * + * Represents the name used in the formula. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + nameInFormula?: string; + /** + * + * Represents the sort order of the items in the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + sortBy?: Excel.SlicerSortType | "DataSourceOrder" | "Ascending" | "Descending"; + /** + * + * Constant value that represents the Slicer style. Possible values are: SlicerStyleLight1 thru SlicerStyleLight6, TableStyleOther1 thru TableStyleOther2, SlicerStyleDark1 thru SlicerStyleDark6. A custom user-defined style present in the workbook can also be specified. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: string; + /** + * + * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + top?: number; + /** + * + * Represents the width, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + width?: number; + } + /** An interface for updating data on the SlicerCollection object, for use in "slicerCollection.set({ ... })". */ + interface SlicerCollectionUpdateData { + items?: Excel.Interfaces.SlicerData[]; + } + /** An interface for updating data on the SlicerItem object, for use in "slicerItem.set({ ... })". */ + interface SlicerItemUpdateData { + /** + * + * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isSelected?: boolean; + } + /** An interface for updating data on the SlicerItemCollection object, for use in "slicerItemCollection.set({ ... })". */ + interface SlicerItemCollectionUpdateData { + items?: Excel.Interfaces.SlicerItemData[]; + } /** An interface describing the data returned by calling "runtime.toJSON()". */ interface RuntimeData { /** * - * Turn on/off JavaScript events in current taskpane or content add-in. + * Toggle JavaScript events in the current task pane or content add-in. * * [Api set: ExcelApi 1.8] */ @@ -46796,6 +48306,14 @@ declare namespace Excel { settings?: Excel.Interfaces.SettingData[]; /** * + * Represents a collection of Slicers associated with the workbook. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + slicers?: Excel.Interfaces.SlicerData[]; + /** + * * Represents a collection of styles associated with the workbook. Read-only. * * [Api set: ExcelApi 1.7] @@ -46921,6 +48439,14 @@ declare namespace Excel { charts?: Excel.Interfaces.ChartData[]; /** * + * Returns a collection of all the Comments objects on the worksheet. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + comments?: Excel.Interfaces.CommentData[]; + /** + * * Gets the horizontal page break collection for the worksheet. This collection only contains manual page breaks. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -46966,6 +48492,14 @@ declare namespace Excel { shapes?: Excel.Interfaces.ShapeData[]; /** * + * Returns collection of slicers that are part of the worksheet. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + slicers?: Excel.Interfaces.SlicerData[]; + /** + * * Collection of tables that are part of the worksheet. Read-only. * * [Api set: ExcelApi 1.1] @@ -47793,7 +49327,7 @@ declare namespace Excel { prompt?: Excel.DataValidationPrompt; /** * - * Data Validation rule that contains different type of data validation criteria. + * Data validation rule that contains different type of data validation criteria. * * [Api set: ExcelApi 1.8] */ @@ -47982,7 +49516,7 @@ declare namespace Excel { interface RangeFillData { /** * - * HTML color code representing the color of the background, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") * * [Api set: ExcelApi 1.1] */ @@ -48210,7 +49744,7 @@ declare namespace Excel { series?: Excel.Interfaces.ChartSeriesData[]; /** * - * Represents the title of the specified chart, including the text, visibility, position, and formating of the title. Read-only. + * Represents the title of the specified chart, including the text, visibility, position, and formatting of the title. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -48296,7 +49830,7 @@ declare namespace Excel { showAllFieldButtons?: boolean; /** * - * Represents whether to to show the data labels when the value is greater than the maximum value on the value axis. + * Represents whether to show the data labels when the value is greater than the maximum value on the value axis. If value axis became smaller than the size of data points, you can use this property to set whether to show the data labels. This property applies to 2-D charts only. * @@ -48666,7 +50200,7 @@ declare namespace Excel { name?: string; /** * - * Specifies how bars and columns are positioned. Can be a value between – 100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. + * Specifies how bars and columns are positioned. Can be a value between –100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. * * [Api set: ExcelApi 1.8] */ @@ -49047,7 +50581,7 @@ declare namespace Excel { position?: Excel.ChartAxisPosition | "Automatic" | "Maximum" | "Minimum" | "Custom"; /** * - * Represents the specified axis position where the other axis crosses at. Read Only. Set to this property should use SetPositionAt(double) method. + * Represents the specified axis position where the other axis crosses at. You should use the SetPositionAt(double) method to set this property. * * [Api set: ExcelApi 1.8] */ @@ -49199,7 +50733,7 @@ declare namespace Excel { format?: Excel.Interfaces.ChartDataLabelFormatData; /** * - * Represents whether data labels automatically generates appropriate text based on context. + * Represents whether data labels automatically generate appropriate text based on context. * * [Api set: ExcelApi 1.8] */ @@ -49627,14 +51161,14 @@ declare namespace Excel { interface ChartLegendEntryData { /** * - * Represents the height of the legendEntry on the chart Legend. + * Represents the height of the legendEntry on the chart legend. * * [Api set: ExcelApi 1.8] */ height?: number; /** * - * Represents the index of the LegendEntry in the Chart Legend. + * Represents the index of the legendEntry in the chart legend. * * [Api set: ExcelApi 1.8] */ @@ -50450,6 +51984,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.8] */ rowHierarchies?: Excel.Interfaces.RowColumnPivotHierarchyData[]; + /** + * + * True if the PivotTable should use custom lists when sorting. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enableDataValueEditing?: boolean; /** * * Id of the PivotTable. Read-only. @@ -50475,6 +52017,14 @@ declare namespace Excel { } /** An interface describing the data returned by calling "pivotLayout.toJSON()". */ interface PivotLayoutData { + /** + * + * True if formatting will be automatically formatted when it’s refreshed or when fields are moved + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + autoFormat?: boolean; /** * * True if the field list should be shown or hidden from the UI. @@ -50490,6 +52040,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.8] */ layoutType?: Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline"; + /** + * + * True if formatting is preserved when the report is refreshed or recalculated by operations such as pivoting, sorting, or changing page field items. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + preserveFormatting?: boolean; /** * * True if the PivotTable report shows grand totals for columns. @@ -50660,7 +52218,7 @@ declare namespace Excel { position?: number; /** * - * Determines whether the data should be sown as a specific summary calculation or not. + * Determines whether the data should be shown as a specific summary calculation or not. * * [Api set: ExcelApi 1.8] */ @@ -51892,6 +53450,14 @@ declare namespace Excel { * @beta */ replies?: Excel.Interfaces.CommentReplyData[]; + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: string; /** * * Represents the comment identifier. Read-only. @@ -51915,6 +53481,14 @@ declare namespace Excel { } /** An interface describing the data returned by calling "commentReply.toJSON()". */ interface CommentReplyData { + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: string; /** * * Represents the comment reply identifier. Read-only. @@ -51946,6 +53520,14 @@ declare namespace Excel { * @beta */ fill?: Excel.Interfaces.ShapeFillData; + /** + * + * Returns the line formatting of the shape object. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + lineFormat?: Excel.Interfaces.ShapeLineFormatData; /** * * Returns or sets the alternative descriptive text string for a Shape object when the object is saved to a Web page. @@ -51996,6 +53578,14 @@ declare namespace Excel { * @beta */ left?: number; + /** + * + * Represents the level of the specified shape. Level 0 means the shape is not part of any group, level 1 means the shape is part of a top-level group, etc. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + level?: number; /** * * Represents if the aspect ratio locked, in boolean, of the shape. @@ -52006,7 +53596,7 @@ declare namespace Excel { lockAspectRatio?: boolean; /** * - * Represents the name of the shape. Read-only. + * Represents the name of the shape. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -52044,7 +53634,7 @@ declare namespace Excel { * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta */ - type?: Excel.ShapeType | "Unknown" | "Image" | "GeometricShape" | "Group"; + type?: Excel.ShapeType | "Unknown" | "Image" | "GeometricShape" | "Group" | "Line"; /** * * Represents the visibility, in boolean, of the specified shape. @@ -52124,6 +53714,25 @@ declare namespace Excel { interface GroupShapeCollectionData { items?: Excel.Interfaces.ShapeData[]; } + /** An interface describing the data returned by calling "line.toJSON()". */ + interface LineData { + /** + * + * Represents the shape identifier. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + id?: string; + /** + * + * Represents the connector type for the line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectorType?: Excel.ConnectorType | "Straight" | "Elbow" | "Curve"; + } /** An interface describing the data returned by calling "shapeFill.toJSON()". */ interface ShapeFillData { /** @@ -52151,6 +53760,57 @@ declare namespace Excel { */ type?: Excel.ShapeFillType | "NoFill" | "Solid" | "Gradient" | "Pattern" | "PictureAndTexture" | "Mixed"; } + /** An interface describing the data returned by calling "shapeLineFormat.toJSON()". */ + interface ShapeLineFormatData { + /** + * + * Represents the line color in HTML color format, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + color?: string; + /** + * + * Represents the line style of the shape. Returns null when line is not visible or has mixed line dash style property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + dashStyle?: Excel.ShapeLineDashStyle | "Dash" | "DashDot" | "DashDotDot" | "LongDash" | "LongDashDot" | "RoundDot" | "Solid" | "SquareDot" | "LongDashDotDot" | "SystemDash" | "SystemDot" | "SystemDashDot"; + /** + * + * Represents the line style of the shape object. Returns null when line is not visible or has mixed line visible property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: Excel.ShapeLineStyle | "Single" | "ThickBetweenThin" | "ThickThin" | "ThinThick" | "ThinThin"; + /** + * + * Represents the degree of transparency of the specified line as a value from 0.0 (opaque) through 1.0 (clear). Returns null when the shape has mixed line transparency property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + transparency?: number; + /** + * + * Represents whether the line formatting of a shape element is visible. Returns null when the shape has mixed line visible property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + visible?: boolean; + /** + * + * Represents weight of the line, in points. Returns null when the line is not visible or has mixed line weight property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + weight?: number; + } /** An interface describing the data returned by calling "textFrame.toJSON()". */ interface TextFrameData { /** @@ -52320,6 +53980,160 @@ declare namespace Excel { */ underline?: Excel.ShapeFontUnderlineStyle | "None" | "Single" | "Double" | "Heavy" | "Dotted" | "DottedHeavy" | "Dash" | "DashHeavy" | "DashLong" | "DashLongHeavy" | "DotDash" | "DotDashHeavy" | "DotDotDash" | "DotDotDashHeavy" | "Wavy" | "WavyHeavy" | "WavyDouble"; } + /** An interface describing the data returned by calling "slicer.toJSON()". */ + interface SlicerData { + /** + * + * Represents the collection of SlicerItems that are part of the slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + slicerItems?: Excel.Interfaces.SlicerItemData[]; + /** + * + * Represents the worksheet containing the slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + worksheet?: Excel.Interfaces.WorksheetData; + /** + * + * Represents the caption of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + caption?: string; + /** + * + * Represents the height, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + height?: number; + /** + * + * Represents the unique id of slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + id?: string; + /** + * + * True if all filters currently applied on the slicer is cleared. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isFilterCleared?: boolean; + /** + * + * Represents the distance, in points, from the left side of the slicer to the left of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + left?: number; + /** + * + * Represents the name of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: string; + /** + * + * Represents the name used in the formula. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + nameInFormula?: string; + /** + * + * Represents the sort order of the items in the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + sortBy?: Excel.SlicerSortType | "DataSourceOrder" | "Ascending" | "Descending"; + /** + * + * Constant value that represents the Slicer style. Possible values are: SlicerStyleLight1 thru SlicerStyleLight6, TableStyleOther1 thru TableStyleOther2, SlicerStyleDark1 thru SlicerStyleDark6. A custom user-defined style present in the workbook can also be specified. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: string; + /** + * + * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + top?: number; + /** + * + * Represents the width, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + width?: number; + } + /** An interface describing the data returned by calling "slicerCollection.toJSON()". */ + interface SlicerCollectionData { + items?: Excel.Interfaces.SlicerData[]; + } + /** An interface describing the data returned by calling "slicerItem.toJSON()". */ + interface SlicerItemData { + /** + * + * True if the slicer item has data. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + hasData?: boolean; + /** + * + * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isSelected?: boolean; + /** + * + * Represents the unique value representing the slicer item. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + key?: string; + /** + * + * Represents the value displayed on UI. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: string; + } + /** An interface describing the data returned by calling "slicerItemCollection.toJSON()". */ + interface SlicerItemCollectionData { + items?: Excel.Interfaces.SlicerItemData[]; + } /** An interface describing the data returned by calling "functionResult.toJSON()". */ interface FunctionResultData { /** @@ -52347,7 +54161,7 @@ declare namespace Excel { $all?: boolean; /** * - * Turn on/off JavaScript events in current taskpane or content add-in. + * Toggle JavaScript events in the current task pane or content add-in. * * [Api set: ExcelApi 1.8] */ @@ -54120,7 +55934,7 @@ declare namespace Excel { prompt?: boolean; /** * - * Data Validation rule that contains different type of data validation criteria. + * Data validation rule that contains different type of data validation criteria. * * [Api set: ExcelApi 1.8] */ @@ -54334,7 +56148,7 @@ declare namespace Excel { $all?: boolean; /** * - * HTML color code representing the color of the background, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") * * [Api set: ExcelApi 1.1] */ @@ -54618,7 +56432,7 @@ declare namespace Excel { series?: Excel.Interfaces.ChartSeriesCollectionLoadOptions; /** * - * For EACH ITEM in the collection: Represents the title of the specified chart, including the text, visibility, position, and formating of the title. + * For EACH ITEM in the collection: Represents the title of the specified chart, including the text, visibility, position, and formatting of the title. * * [Api set: ExcelApi 1.1] */ @@ -54711,7 +56525,7 @@ declare namespace Excel { showAllFieldButtons?: boolean; /** * - * For EACH ITEM in the collection: Represents whether to to show the data labels when the value is greater than the maximum value on the value axis. + * For EACH ITEM in the collection: Represents whether to show the data labels when the value is greater than the maximum value on the value axis. If value axis became smaller than the size of data points, you can use this property to set whether to show the data labels. This property applies to 2-D charts only. * @@ -54800,7 +56614,7 @@ declare namespace Excel { series?: Excel.Interfaces.ChartSeriesCollectionLoadOptions; /** * - * Represents the title of the specified chart, including the text, visibility, position, and formating of the title. + * Represents the title of the specified chart, including the text, visibility, position, and formatting of the title. * * [Api set: ExcelApi 1.1] */ @@ -54893,7 +56707,7 @@ declare namespace Excel { showAllFieldButtons?: boolean; /** * - * Represents whether to to show the data labels when the value is greater than the maximum value on the value axis. + * Represents whether to show the data labels when the value is greater than the maximum value on the value axis. If value axis became smaller than the size of data points, you can use this property to set whether to show the data labels. This property applies to 2-D charts only. * @@ -55271,7 +57085,7 @@ declare namespace Excel { name?: boolean; /** * - * For EACH ITEM in the collection: Specifies how bars and columns are positioned. Can be a value between – 100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. + * For EACH ITEM in the collection: Specifies how bars and columns are positioned. Can be a value between –100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. * * [Api set: ExcelApi 1.8] */ @@ -55618,7 +57432,7 @@ declare namespace Excel { name?: boolean; /** * - * Specifies how bars and columns are positioned. Can be a value between – 100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. + * Specifies how bars and columns are positioned. Can be a value between –100 and 100. Applies only to 2-D bar and 2-D column charts. Read/Write. * * [Api set: ExcelApi 1.8] */ @@ -56104,7 +57918,7 @@ declare namespace Excel { position?: boolean; /** * - * Represents the specified axis position where the other axis crosses at. Read Only. Set to this property should use SetPositionAt(double) method. + * Represents the specified axis position where the other axis crosses at. You should use the SetPositionAt(double) method to set this property. * * [Api set: ExcelApi 1.8] */ @@ -56280,7 +58094,7 @@ declare namespace Excel { format?: Excel.Interfaces.ChartDataLabelFormatLoadOptions; /** * - * Represents whether data labels automatically generates appropriate text based on context. + * Represents whether data labels automatically generate appropriate text based on context. * * [Api set: ExcelApi 1.8] */ @@ -56751,14 +58565,14 @@ declare namespace Excel { $all?: boolean; /** * - * Represents the height of the legendEntry on the chart Legend. + * Represents the height of the legendEntry on the chart legend. * * [Api set: ExcelApi 1.8] */ height?: boolean; /** * - * Represents the index of the LegendEntry in the Chart Legend. + * Represents the index of the legendEntry in the chart legend. * * [Api set: ExcelApi 1.8] */ @@ -56802,14 +58616,14 @@ declare namespace Excel { $all?: boolean; /** * - * For EACH ITEM in the collection: Represents the height of the legendEntry on the chart Legend. + * For EACH ITEM in the collection: Represents the height of the legendEntry on the chart legend. * * [Api set: ExcelApi 1.8] */ height?: boolean; /** * - * For EACH ITEM in the collection: Represents the index of the LegendEntry in the Chart Legend. + * For EACH ITEM in the collection: Represents the index of the legendEntry in the chart legend. * * [Api set: ExcelApi 1.8] */ @@ -57848,6 +59662,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.3] */ worksheet?: Excel.Interfaces.WorksheetLoadOptions; + /** + * + * For EACH ITEM in the collection: True if the PivotTable should use custom lists when sorting. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enableDataValueEditing?: boolean; /** * * For EACH ITEM in the collection: Id of the PivotTable. Read-only. @@ -57893,6 +59715,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.3] */ worksheet?: Excel.Interfaces.WorksheetLoadOptions; + /** + * + * True if the PivotTable should use custom lists when sorting. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enableDataValueEditing?: boolean; /** * * Id of the PivotTable. Read-only. @@ -57924,6 +59754,14 @@ declare namespace Excel { */ interface PivotLayoutLoadOptions { $all?: boolean; + /** + * + * True if formatting will be automatically formatted when it’s refreshed or when fields are moved + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + autoFormat?: boolean; /** * * True if the field list should be shown or hidden from the UI. @@ -57939,6 +59777,14 @@ declare namespace Excel { * [Api set: ExcelApi 1.8] */ layoutType?: boolean; + /** + * + * True if formatting is preserved when the report is refreshed or recalculated by operations such as pivoting, sorting, or changing page field items. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + preserveFormatting?: boolean; /** * * True if the PivotTable report shows grand totals for columns. @@ -58186,7 +60032,7 @@ declare namespace Excel { position?: boolean; /** * - * For EACH ITEM in the collection: Determines whether the data should be sown as a specific summary calculation or not. + * For EACH ITEM in the collection: Determines whether the data should be shown as a specific summary calculation or not. * * [Api set: ExcelApi 1.8] */ @@ -58244,7 +60090,7 @@ declare namespace Excel { position?: boolean; /** * - * Determines whether the data should be sown as a specific summary calculation or not. + * Determines whether the data should be shown as a specific summary calculation or not. * * [Api set: ExcelApi 1.8] */ @@ -60262,6 +62108,14 @@ declare namespace Excel { */ interface CommentCollectionLoadOptions { $all?: boolean; + /** + * + * For EACH ITEM in the collection: Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: boolean; /** * * For EACH ITEM in the collection: Represents the comment identifier. Read-only. @@ -60288,6 +62142,14 @@ declare namespace Excel { */ interface CommentLoadOptions { $all?: boolean; + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: boolean; /** * * Represents the comment identifier. Read-only. @@ -60314,6 +62176,14 @@ declare namespace Excel { */ interface CommentReplyCollectionLoadOptions { $all?: boolean; + /** + * + * For EACH ITEM in the collection: Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: boolean; /** * * For EACH ITEM in the collection: Represents the comment reply identifier. Read-only. @@ -60340,6 +62210,14 @@ declare namespace Excel { */ interface CommentReplyLoadOptions { $all?: boolean; + /** + * + * Get/Set the content. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + content?: boolean; /** * * Represents the comment reply identifier. Read-only. @@ -60400,6 +62278,30 @@ declare namespace Excel { image?: Excel.Interfaces.ImageLoadOptions; /** * + * For EACH ITEM in the collection: Returns the line object for the shape object. Error will be thrown, if the shape object is other shape type (Like, GeometricShape, SmartArt, etc.) rather than Image. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + line?: Excel.Interfaces.LineLoadOptions; + /** + * + * For EACH ITEM in the collection: Returns the line formatting of the shape object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + lineFormat?: Excel.Interfaces.ShapeLineFormatLoadOptions; + /** + * + * For EACH ITEM in the collection: Represents the parent group of the specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + parentGroup?: Excel.Interfaces.ShapeLoadOptions; + /** + * * For EACH ITEM in the collection: Returns the textFrame object of a shape. Read only. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -60456,6 +62358,14 @@ declare namespace Excel { * @beta */ left?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the level of the specified shape. Level 0 means the shape is not part of any group, level 1 means the shape is part of a top-level group, etc. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + level?: boolean; /** * * For EACH ITEM in the collection: Represents if the aspect ratio locked, in boolean, of the shape. @@ -60466,7 +62376,7 @@ declare namespace Excel { lockAspectRatio?: boolean; /** * - * For EACH ITEM in the collection: Represents the name of the shape. Read-only. + * For EACH ITEM in the collection: Represents the name of the shape. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -60574,6 +62484,30 @@ declare namespace Excel { image?: Excel.Interfaces.ImageLoadOptions; /** * + * Returns the line object for the shape object. Error will be thrown, if the shape object is other shape type (Like, GeometricShape, SmartArt, etc.) rather than Image. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + line?: Excel.Interfaces.LineLoadOptions; + /** + * + * Returns the line formatting of the shape object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + lineFormat?: Excel.Interfaces.ShapeLineFormatLoadOptions; + /** + * + * Represents the parent group of the specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + parentGroup?: Excel.Interfaces.ShapeLoadOptions; + /** + * * Returns the textFrame object of a shape. Read only. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -60630,6 +62564,14 @@ declare namespace Excel { * @beta */ left?: boolean; + /** + * + * Represents the level of the specified shape. Level 0 means the shape is not part of any group, level 1 means the shape is part of a top-level group, etc. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + level?: boolean; /** * * Represents if the aspect ratio locked, in boolean, of the shape. @@ -60640,7 +62582,7 @@ declare namespace Excel { lockAspectRatio?: boolean; /** * - * Represents the name of the shape. Read-only. + * Represents the name of the shape. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -60834,6 +62776,30 @@ declare namespace Excel { image?: Excel.Interfaces.ImageLoadOptions; /** * + * For EACH ITEM in the collection: Returns the line object for the shape object. Error will be thrown, if the shape object is other shape type (Like, GeometricShape, SmartArt, etc.) rather than Image. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + line?: Excel.Interfaces.LineLoadOptions; + /** + * + * For EACH ITEM in the collection: Returns the line formatting of the shape object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + lineFormat?: Excel.Interfaces.ShapeLineFormatLoadOptions; + /** + * + * For EACH ITEM in the collection: Represents the parent group of the specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + parentGroup?: Excel.Interfaces.ShapeLoadOptions; + /** + * * For EACH ITEM in the collection: Returns the textFrame object of a shape. Read only. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -60890,6 +62856,14 @@ declare namespace Excel { * @beta */ left?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the level of the specified shape. Level 0 means the shape is not part of any group, level 1 means the shape is part of a top-level group, etc. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + level?: boolean; /** * * For EACH ITEM in the collection: Represents if the aspect ratio locked, in boolean, of the shape. @@ -60900,7 +62874,7 @@ declare namespace Excel { lockAspectRatio?: boolean; /** * - * For EACH ITEM in the collection: Represents the name of the shape. Read-only. + * For EACH ITEM in the collection: Represents the name of the shape. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -60965,6 +62939,40 @@ declare namespace Excel { */ zorderPosition?: boolean; } + /** + * + * Represents a Line object inside a worksheet. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface LineLoadOptions { + $all?: boolean; + /** + * + * Returns the shape object for the line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + shape?: Excel.Interfaces.ShapeLoadOptions; + /** + * + * Represents the shape identifier. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + id?: boolean; + /** + * + * Represents the connector type for the line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectorType?: boolean; + } /** * * Represents the fill formatting for a shape object. @@ -60999,6 +63007,64 @@ declare namespace Excel { */ type?: boolean; } + /** + * + * Represents the line formatting for the shape object. For picture and geometric shape, line formatting represents the border of shape object. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface ShapeLineFormatLoadOptions { + $all?: boolean; + /** + * + * Represents the line color in HTML color format, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + color?: boolean; + /** + * + * Represents the line style of the shape. Returns null when line is not visible or has mixed line dash style property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + dashStyle?: boolean; + /** + * + * Represents the line style of the shape object. Returns null when line is not visible or has mixed line visible property (e.g. group type of shape). See Excel.ShapeLineStyle for details. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: boolean; + /** + * + * Represents the degree of transparency of the specified line as a value from 0.0 (opaque) through 1.0 (clear). Returns null when the shape has mixed line transparency property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + transparency?: boolean; + /** + * + * Represents whether the line formatting of a shape element is visible. Returns null when the shape has mixed line visible property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + visible?: boolean; + /** + * + * Represents weight of the line, in points. Returns null when the line is not visible or has mixed line weight property (e.g. group type of shape). + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + weight?: boolean; + } /** * * Represents the text frame for a shape object. @@ -61187,6 +63253,310 @@ declare namespace Excel { */ underline?: boolean; } + /** + * + * Represents a slicer object in the workbook. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface SlicerLoadOptions { + $all?: boolean; + /** + * + * Represents the worksheet containing the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + worksheet?: Excel.Interfaces.WorksheetLoadOptions; + /** + * + * Represents the caption of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + caption?: boolean; + /** + * + * Represents the height, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + height?: boolean; + /** + * + * Represents the unique id of slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + id?: boolean; + /** + * + * True if all filters currently applied on the slicer is cleared. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isFilterCleared?: boolean; + /** + * + * Represents the distance, in points, from the left side of the slicer to the left of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + left?: boolean; + /** + * + * Represents the name of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: boolean; + /** + * + * Represents the name used in the formula. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + nameInFormula?: boolean; + /** + * + * Represents the sort order of the items in the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + sortBy?: boolean; + /** + * + * Constant value that represents the Slicer style. Possible values are: SlicerStyleLight1 thru SlicerStyleLight6, TableStyleOther1 thru TableStyleOther2, SlicerStyleDark1 thru SlicerStyleDark6. A custom user-defined style present in the workbook can also be specified. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: boolean; + /** + * + * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + top?: boolean; + /** + * + * Represents the width, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + width?: boolean; + } + /** + * + * Represents a collection of all the slicer objects on the workbook or a worksheet. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface SlicerCollectionLoadOptions { + $all?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the worksheet containing the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + worksheet?: Excel.Interfaces.WorksheetLoadOptions; + /** + * + * For EACH ITEM in the collection: Represents the caption of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + caption?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the height, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + height?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the unique id of slicer. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + id?: boolean; + /** + * + * For EACH ITEM in the collection: True if all filters currently applied on the slicer is cleared. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isFilterCleared?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the distance, in points, from the left side of the slicer to the left of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + left?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the name of slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the name used in the formula. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + nameInFormula?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the sort order of the items in the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + sortBy?: boolean; + /** + * + * For EACH ITEM in the collection: Constant value that represents the Slicer style. Possible values are: SlicerStyleLight1 thru SlicerStyleLight6, TableStyleOther1 thru TableStyleOther2, SlicerStyleDark1 thru SlicerStyleDark6. A custom user-defined style present in the workbook can also be specified. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + style?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + Throws an invalid argument exception when set with negative value as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + top?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the width, in points, of the slicer. + Throws an invalid argument exception when set with negative value or zero as input. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + width?: boolean; + } + /** + * + * Represents a slicer item in a slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface SlicerItemLoadOptions { + $all?: boolean; + /** + * + * True if the slicer item has data. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + hasData?: boolean; + /** + * + * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isSelected?: boolean; + /** + * + * Represents the unique value representing the slicer item. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + key?: boolean; + /** + * + * Represents the value displayed on UI. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: boolean; + } + /** + * + * Represents a collection of all the slicer item objects on the slicer. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface SlicerItemCollectionLoadOptions { + $all?: boolean; + /** + * + * For EACH ITEM in the collection: True if the slicer item has data. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + hasData?: boolean; + /** + * + * For EACH ITEM in the collection: True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isSelected?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the unique value representing the slicer item. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + key?: boolean; + /** + * + * For EACH ITEM in the collection: Represents the value displayed on UI. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + name?: boolean; + } /** * * An object containing the result of a function-evaluation operation @@ -61213,7 +63583,6 @@ declare namespace Excel { } } - //////////////////////////////////////////////////////////////// //////////////////////// End Excel APIs //////////////////////// //////////////////////////////////////////////////////////////// diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 005e9cf037..b15cd3653a 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -1661,7 +1661,7 @@ declare namespace Office { * Specifies how to coerce data returned or set by the invoked method. * * @remarks - * PowerPoint supports only `Office.CoercionType.Text`, `Office.CoercionType.Image`, and `Office.CoercionType.SlideRange`. + * PowerPoint supports only `Office.CoercionType.Text`, `Office.CoercionType.Image`, `Office.CoercionType.SlideRange`, and `Office.CoercionType.XmlSvg`. * * Project supports only `Office.CoercionType.Text`. * @@ -1726,7 +1726,12 @@ declare namespace Office { * Data is returned or set as an image stream. * Note: Only applies to data in Excel, Word, and PowerPoint. */ - Image + Image, + /** + * Data is returned or set as XML data containing an SVG image. + * Note: Only applies to data in Excel, Word, and PowerPoint. + */ + XmlSvg } /** * Specifies whether the document in the associated application is read-only or read-write. @@ -3543,6 +3548,10 @@ declare namespace Office { * PowerPoint and PowerPoint Online * `Office.CoercionType.SlideRange` * + * + * Excel, PowerPoint, and Word + * `Office.CoercionType.XmlSvg` + * * * * **Support details** @@ -3710,6 +3719,10 @@ declare namespace Office { * PowerPoint and PowerPoint Online * `Office.CoercionType.SlideRange` * + * + * Excel, PowerPoint, and Word + * `Office.CoercionType.XmlSvg` + * * * * **Support details** diff --git a/types/oracle__oraclejet/index.d.ts b/types/oracle__oraclejet/index.d.ts index dd99802419..fae850b7df 100644 --- a/types/oracle__oraclejet/index.d.ts +++ b/types/oracle__oraclejet/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for oraclejet 6.0 +// Type definitions for oraclejet 6.1 // Project: https://github.com/oracle/oraclejet // Definitions by: Naizam Olakara // Jing Wu diff --git a/types/oracle__oraclejet/ojchart/index.d.ts b/types/oracle__oraclejet/ojchart/index.d.ts index 25970f316e..dead9ee55f 100644 --- a/types/oracle__oraclejet/ojchart/index.d.ts +++ b/types/oracle__oraclejet/ojchart/index.d.ts @@ -667,7 +667,7 @@ export namespace ojChart { }> { } interface ojSelectInput extends CustomEvent<{ - items: any[]; + items: string[]; selectionData: Array<{ data: object; itemData: object; @@ -1486,7 +1486,7 @@ export interface ojChartItem extends JetElement { close?: number; color?: string; drilling?: 'on' | 'off' | 'inherit'; - groupId: string[]; + groupId: Array<(string | number)>; high?: number; items?: object[] | number[]; label?: string | string[]; @@ -1502,7 +1502,7 @@ export interface ojChartItem extends JetElement { q1?: number; q2?: number; q3?: number; - seriesId: string; + seriesId: string | number; shortDesc?: string; source?: string; sourceHover?: string; @@ -1619,7 +1619,7 @@ export interface ojChartItemSettableProperties extends JetSettableProperties { close?: number; color?: string; drilling?: 'on' | 'off' | 'inherit'; - groupId: string[]; + groupId: Array<(string | number)>; high?: number; items?: object[] | number[]; label?: string | string[]; @@ -1635,7 +1635,7 @@ export interface ojChartItemSettableProperties extends JetSettableProperties { q1?: number; q2?: number; q3?: number; - seriesId: string; + seriesId: string | number; shortDesc?: string; source?: string; sourceHover?: string; diff --git a/types/oracle__oraclejet/ojcheckboxset/index.d.ts b/types/oracle__oraclejet/ojcheckboxset/index.d.ts index afed42d51c..47f2dc44c0 100644 --- a/types/oracle__oraclejet/ojcheckboxset/index.d.ts +++ b/types/oracle__oraclejet/ojcheckboxset/index.d.ts @@ -1,8 +1,12 @@ +import { DataProvider } from '../ojdataprovider'; import { editableValue, editableValueEventMap, editableValueSettableProperties } from '../ojeditablevalue'; import { JetElement, JetSettableProperties, JetElementCustomEvent, JetSetPropertyType } from '..'; -export interface ojCheckboxset extends editableValue { +export interface ojCheckboxset extends editableValue> { disabled: boolean; labelledBy: string | null; + optionRenderer?: ((param0: ojCheckboxset.OptionContext) => Element) | null; + options: DataProvider | null; + optionsKeys?: ojCheckboxset.OptionsKeys; required: boolean; value: any[]; translations: { @@ -12,19 +16,22 @@ export interface ojCheckboxset extends editableValue) => any) | null; - onLabelledByChanged: ((event: JetElementCustomEvent) => any) | null; - onRequiredChanged: ((event: JetElementCustomEvent) => any) | null; - onValueChanged: ((event: JetElementCustomEvent) => any) | null; + onDisabledChanged: ((event: JetElementCustomEvent["disabled"]>) => any) | null; + onLabelledByChanged: ((event: JetElementCustomEvent["labelledBy"]>) => any) | null; + onOptionRendererChanged: ((event: JetElementCustomEvent["optionRenderer"]>) => any) | null; + onOptionsChanged: ((event: JetElementCustomEvent["options"]>) => any) | null; + onOptionsKeysChanged: ((event: JetElementCustomEvent["optionsKeys"]>) => any) | null; + onRequiredChanged: ((event: JetElementCustomEvent["required"]>) => any) | null; + onValueChanged: ((event: JetElementCustomEvent["value"]>) => any) | null; onOjAnimateEnd: ((event: ojCheckboxset.ojAnimateEnd) => any) | null; onOjAnimateStart: ((event: ojCheckboxset.ojAnimateStart) => any) | null; - addEventListener(type: T, listener: (this: HTMLElement, ev: ojCheckboxsetEventMap[T]) => any, useCapture?: boolean): void; + addEventListener>(type: T, listener: (this: HTMLElement, ev: ojCheckboxsetEventMap[T]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - getProperty(property: T): ojCheckboxset[T]; + getProperty>(property: T): ojCheckboxset[T]; getProperty(property: string): any; - setProperty(property: T, value: ojCheckboxsetSettableProperties[T]): void; - setProperty(property: T, value: JetSetPropertyType): void; - setProperties(properties: ojCheckboxsetSettablePropertiesLenient): void; + setProperty>(property: T, value: ojCheckboxsetSettableProperties[T]): void; + setProperty(property: T, value: JetSetPropertyType>): void; + setProperties(properties: ojCheckboxsetSettablePropertiesLenient): void; refresh(): void; validate(): Promise; } @@ -42,18 +49,41 @@ export namespace ojCheckboxset { [propName: string]: any; }> { } + // tslint:disable-next-line interface-over-type-literal + type Option = { + disabled?: boolean; + label?: string; + value: any; + }; + // tslint:disable-next-line interface-over-type-literal + type OptionContext = { + component: Element; + index: number; + data: D; + }; + // tslint:disable-next-line interface-over-type-literal + type OptionsKeys = { + label?: string; + value?: string; + }; } -export interface ojCheckboxsetEventMap extends editableValueEventMap { +export interface ojCheckboxsetEventMap extends editableValueEventMap> { 'ojAnimateEnd': ojCheckboxset.ojAnimateEnd; 'ojAnimateStart': ojCheckboxset.ojAnimateStart; - 'disabledChanged': JetElementCustomEvent; - 'labelledByChanged': JetElementCustomEvent; - 'requiredChanged': JetElementCustomEvent; - 'valueChanged': JetElementCustomEvent; + 'disabledChanged': JetElementCustomEvent["disabled"]>; + 'labelledByChanged': JetElementCustomEvent["labelledBy"]>; + 'optionRendererChanged': JetElementCustomEvent["optionRenderer"]>; + 'optionsChanged': JetElementCustomEvent["options"]>; + 'optionsKeysChanged': JetElementCustomEvent["optionsKeys"]>; + 'requiredChanged': JetElementCustomEvent["required"]>; + 'valueChanged': JetElementCustomEvent["value"]>; } -export interface ojCheckboxsetSettableProperties extends editableValueSettableProperties { +export interface ojCheckboxsetSettableProperties extends editableValueSettableProperties { disabled: boolean; labelledBy: string | null; + optionRenderer?: ((param0: ojCheckboxset.OptionContext) => Element) | null; + options: DataProvider | null; + optionsKeys?: ojCheckboxset.OptionsKeys; required: boolean; value: any[]; translations: { @@ -64,6 +94,6 @@ export interface ojCheckboxsetSettableProperties extends editableValueSettablePr }; }; } -export interface ojCheckboxsetSettablePropertiesLenient extends Partial { +export interface ojCheckboxsetSettablePropertiesLenient extends Partial> { [key: string]: any; } diff --git a/types/oracle__oraclejet/ojcontext/index.d.ts b/types/oracle__oraclejet/ojcontext/index.d.ts index 0bb6a856c7..d6590a6682 100644 --- a/types/oracle__oraclejet/ojcontext/index.d.ts +++ b/types/oracle__oraclejet/ojcontext/index.d.ts @@ -1,6 +1,9 @@ declare class BusyContext { addBusyState(options: { - description: object | (() => string); + description: { + toString: () => string; + [propName: string]: any; + } | (() => string) | string; }): (() => void); applicationBootstrapComplete(): undefined; clear(): undefined; @@ -16,7 +19,10 @@ declare class BusyContext { declare namespace Context { interface BusyContext { addBusyState(options: { - description: object | (() => string); + description: { + toString: () => string; + [propName: string]: any; + } | (() => string) | string; }): (() => void); applicationBootstrapComplete(): undefined; clear(): undefined; diff --git a/types/oracle__oraclejet/ojdataprovider/index.d.ts b/types/oracle__oraclejet/ojdataprovider/index.d.ts index accc1f25bc..d05976730f 100644 --- a/types/oracle__oraclejet/ojdataprovider/index.d.ts +++ b/types/oracle__oraclejet/ojdataprovider/index.d.ts @@ -47,6 +47,10 @@ export interface DataProviderOperationEventDetail { keys: Set; metadata?: Array>; } +export interface FetchAttribute { + attributes?: Array; + name: string; +} export interface FetchByKeysCapability { implementation: 'iteration' | 'lookup'; } @@ -56,6 +60,7 @@ export namespace FetchByKeysMixin { }): any; } export interface FetchByKeysParameters { + attributes?: Array; keys: Set; } export interface FetchByKeysResults { @@ -71,6 +76,7 @@ export namespace FetchByOffsetMixin { }): any; } export interface FetchByOffsetParameters extends FetchListParameters { + attributes?: Array; offset: number; } export interface FetchByOffsetResults { @@ -79,6 +85,7 @@ export interface FetchByOffsetResults { results: Array>; } export interface FetchListParameters { + attributes?: Array; filterCriterion?: FilterOperator; size: number; sortCriteria?: Array>; diff --git a/types/oracle__oraclejet/ojdiagram-utils/index.d.ts b/types/oracle__oraclejet/ojdiagram-utils/index.d.ts new file mode 100644 index 0000000000..3cc5e21632 --- /dev/null +++ b/types/oracle__oraclejet/ojdiagram-utils/index.d.ts @@ -0,0 +1,38 @@ +import { DvtDiagramLayoutContext, DvtDiagramLayoutContextNode, DvtDiagramLayoutContextLink } from '../ojdiagram'; +export function getLayout(obj: { + nodes: { + id: any; + x: number; + y: number; + labelLayout: LabelLayout; + }; + links: { + id: any; + path: string; + coordinateSpace: any; + labelLayout: LabelLayout; + }; + nodeDefaults: { + labelLayout: LabelLayout | ((context: DvtDiagramLayoutContext, node: DvtDiagramLayoutContextNode) => LabelLayout); + }; + linkDefaults: { + path: (context: DvtDiagramLayoutContext, link: DvtDiagramLayoutContextLink) => string; + labelLayout: (context: DvtDiagramLayoutContext, link: DvtDiagramLayoutContextLink) => LabelLayout; + }; + viewport: { + x: number; + y: number; + w: number; + h: number; + }; +}): (context: DvtDiagramLayoutContext) => void; +// tslint:disable-next-line interface-over-type-literal +export type LabelLayout = { + x: number; + y: number; + rotationPointX: number; + rotationPointY: number; + angle: number; + halign: string; + valign: string; +}; diff --git a/types/oracle__oraclejet/ojdialog/index.d.ts b/types/oracle__oraclejet/ojdialog/index.d.ts index 42a8569bd4..709081b6de 100644 --- a/types/oracle__oraclejet/ojdialog/index.d.ts +++ b/types/oracle__oraclejet/ojdialog/index.d.ts @@ -1,6 +1,7 @@ import { baseComponent, baseComponentEventMap, baseComponentSettableProperties, JetElementCustomEvent, JetSetPropertyType } from '..'; export interface ojDialog extends baseComponent { cancelBehavior: 'icon' | 'escape' | 'none'; + dialogTitle: string | null; dragAffordance: 'title-bar' | 'none'; initialVisibility: 'hide' | 'show'; modality: 'modal' | 'modeless'; @@ -11,6 +12,7 @@ export interface ojDialog extends baseComponent { labelCloseIcon?: string; }; onCancelBehaviorChanged: ((event: JetElementCustomEvent) => any) | null; + onDialogTitleChanged: ((event: JetElementCustomEvent) => any) | null; onDragAffordanceChanged: ((event: JetElementCustomEvent) => any) | null; onInitialVisibilityChanged: ((event: JetElementCustomEvent) => any) | null; onModalityChanged: ((event: JetElementCustomEvent) => any) | null; @@ -124,6 +126,7 @@ export interface ojDialogEventMap extends baseComponentEventMap; + 'dialogTitleChanged': JetElementCustomEvent; 'dragAffordanceChanged': JetElementCustomEvent; 'initialVisibilityChanged': JetElementCustomEvent; 'modalityChanged': JetElementCustomEvent; @@ -133,6 +136,7 @@ export interface ojDialogEventMap extends baseComponentEventMap implements DataProvider { + attributes: Array; dataMapping: DataMapping; - from: any; + from: Kin; offset: number; sortCriteria: Array>; constructor(dataProvider: DataProvider, options?: { - from?: object; + from?: Kin; offset?: number; sortCriteria?: Array>; dataMapping?: DataMapping; + attributes?: Array; }); addEventListener(eventType: string, listener: EventListener): void; containsKeys(params: FetchByKeysParameters): Promise>; diff --git a/types/oracle__oraclejet/ojmenu/index.d.ts b/types/oracle__oraclejet/ojmenu/index.d.ts index b6b1c8a9cb..d2b72d9677 100644 --- a/types/oracle__oraclejet/ojmenu/index.d.ts +++ b/types/oracle__oraclejet/ojmenu/index.d.ts @@ -43,6 +43,7 @@ export namespace ojMenu { }> { } interface ojBeforeOpen extends CustomEvent<{ + openOptions: OpenOptions; [propName: string]: any; }> { } diff --git a/types/oracle__oraclejet/ojmessage/index.d.ts b/types/oracle__oraclejet/ojmessage/index.d.ts index 55e905ba8d..47541dd949 100644 --- a/types/oracle__oraclejet/ojmessage/index.d.ts +++ b/types/oracle__oraclejet/ojmessage/index.d.ts @@ -1,5 +1,6 @@ import { JetElement, JetSettableProperties, JetElementCustomEvent, JetSetPropertyType } from '..'; export interface ojMessage extends JetElement { + displayOptions: ojMessage.DisplayOptions; message: ojMessage.Message; translations: { categories?: { @@ -10,6 +11,7 @@ export interface ojMessage extends JetElement { }; labelCloseIcon?: string; }; + onDisplayOptionsChanged: ((event: JetElementCustomEvent) => any) | null; onMessageChanged: ((event: JetElementCustomEvent) => any) | null; onTranslationsChanged: ((event: JetElementCustomEvent) => any) | null; onOjAnimateEnd: ((event: ojMessage.ojAnimateEnd) => any) | null; @@ -39,11 +41,15 @@ export namespace ojMessage { }> { } interface ojClose extends CustomEvent<{ - message: object; + message: Message; [propName: string]: any; }> { } // tslint:disable-next-line interface-over-type-literal + type DisplayOptions = { + category?: 'header' | 'none' | 'auto'; + }; + // tslint:disable-next-line interface-over-type-literal type Message = { icon?: string; category?: string; @@ -60,10 +66,12 @@ export interface ojMessageEventMap extends HTMLElementEventMap { 'ojAnimateEnd': ojMessage.ojAnimateEnd; 'ojAnimateStart': ojMessage.ojAnimateStart; 'ojClose': ojMessage.ojClose; + 'displayOptionsChanged': JetElementCustomEvent; 'messageChanged': JetElementCustomEvent; 'translationsChanged': JetElementCustomEvent; } export interface ojMessageSettableProperties extends JetSettableProperties { + displayOptions: ojMessage.DisplayOptions; message: ojMessage.Message; translations: { categories?: { diff --git a/types/oracle__oraclejet/ojmessages/index.d.ts b/types/oracle__oraclejet/ojmessages/index.d.ts index 0b410266a3..f7d75a2be2 100644 --- a/types/oracle__oraclejet/ojmessages/index.d.ts +++ b/types/oracle__oraclejet/ojmessages/index.d.ts @@ -3,6 +3,7 @@ import { ojMessage } from '../ojmessage'; import { JetElement, JetSettableProperties, JetElementCustomEvent, JetSetPropertyType } from '..'; export interface ojMessages extends JetElement { display: 'general' | 'notification'; + displayOptions: ojMessage.DisplayOptions; messages: ojMessage.Message[] | null | DataProvider; position: ojMessages.Position | null; translations: { @@ -15,6 +16,7 @@ export interface ojMessages extends JetElement { labelLandmark?: string; }; onDisplayChanged: ((event: JetElementCustomEvent) => any) | null; + onDisplayOptionsChanged: ((event: JetElementCustomEvent) => any) | null; onMessagesChanged: ((event: JetElementCustomEvent) => any) | null; onPositionChanged: ((event: JetElementCustomEvent) => any) | null; onTranslationsChanged: ((event: JetElementCustomEvent) => any) | null; @@ -25,17 +27,19 @@ export interface ojMessages extends JetElement { setProperty(property: T, value: ojMessagesSettableProperties[T]): void; setProperty(property: T, value: JetSetPropertyType): void; setProperties(properties: ojMessagesSettablePropertiesLenient): void; - close(associated: object): void; + close(message: ojMessage.Message): void; closeAll(closeFilter?: (message: ojMessage.Message) => boolean): void; } export interface ojMessagesEventMap extends HTMLElementEventMap { 'displayChanged': JetElementCustomEvent; + 'displayOptionsChanged': JetElementCustomEvent; 'messagesChanged': JetElementCustomEvent; 'positionChanged': JetElementCustomEvent; 'translationsChanged': JetElementCustomEvent; } export interface ojMessagesSettableProperties extends JetSettableProperties { display: 'general' | 'notification'; + displayOptions: ojMessage.DisplayOptions; messages: ojMessage.Message[] | null | DataProvider; position: ojMessages.Position | null; translations: { diff --git a/types/oracle__oraclejet/ojmodule-element/index.d.ts b/types/oracle__oraclejet/ojmodule-element/index.d.ts index 693cb518f6..0501e30e26 100644 --- a/types/oracle__oraclejet/ojmodule-element/index.d.ts +++ b/types/oracle__oraclejet/ojmodule-element/index.d.ts @@ -27,9 +27,9 @@ export interface ModuleElementAnimation { export interface ojModule extends JetElement { animation: object; config: { - cleanupMode: 'onDisconnect' | 'none'; + cleanupMode?: 'onDisconnect' | 'none'; view: Node[]; - viewModel: object; + viewModel: object | null; }; onAnimationChanged: ((event: JetElementCustomEvent) => any) | null; onConfigChanged: ((event: JetElementCustomEvent) => any) | null; @@ -79,9 +79,9 @@ export interface ojModuleEventMap extends HTMLElementEventMap { export interface ojModuleSettableProperties extends JetSettableProperties { animation: object; config: { - cleanupMode: 'onDisconnect' | 'none'; + cleanupMode?: 'onDisconnect' | 'none'; view: Node[]; - viewModel: object; + viewModel: object | null; }; } export interface ojModuleSettablePropertiesLenient extends Partial { diff --git a/types/oracle__oraclejet/ojoffcanvas/index.d.ts b/types/oracle__oraclejet/ojoffcanvas/index.d.ts new file mode 100644 index 0000000000..7f099aea33 --- /dev/null +++ b/types/oracle__oraclejet/ojoffcanvas/index.d.ts @@ -0,0 +1,29 @@ +export function close(offcanvas: { + selector: string; +}): Promise; +export function open(offcanvas: { + selector: string; + content: string; + edge?: 'start' | 'end' | 'top' | 'bottom'; + displayMode?: 'push' | 'overlay'; + autoDismiss?: 'focusLoss' | 'none'; + size?: string; + modality?: 'modal' | 'modeless'; +}): Promise; +export function setupResponsive(offcanvas: { + selector: string; + edge?: 'start' | 'end' | 'top' | 'bottom'; + query: string | null; +}): void; +export function tearDownResponsive(offcanvas: { + selector: string; +}): void; +export function toggle(offcanvas: { + selector: string; + content: string; + edge?: 'start' | 'end' | 'top' | 'bottom'; + displayMode?: 'push' | 'overlay'; + autoDismiss?: 'focusLoss' | 'none'; + size?: string; + modality?: 'modal' | 'modeless'; +}): Promise; diff --git a/types/oracle__oraclejet/ojradioset/index.d.ts b/types/oracle__oraclejet/ojradioset/index.d.ts index 4b910c22fd..0860018f9d 100644 --- a/types/oracle__oraclejet/ojradioset/index.d.ts +++ b/types/oracle__oraclejet/ojradioset/index.d.ts @@ -1,8 +1,12 @@ +import { DataProvider } from '../ojdataprovider'; import { editableValue, editableValueEventMap, editableValueSettableProperties } from '../ojeditablevalue'; import { JetElement, JetSettableProperties, JetElementCustomEvent, JetSetPropertyType } from '..'; -export interface ojRadioset extends editableValue { +export interface ojRadioset extends editableValue> { disabled: boolean; labelledBy: string | null; + optionRenderer?: ((param0: ojRadioset.OptionContext) => Element) | null; + options: DataProvider | null; + optionsKeys?: ojRadioset.OptionsKeys; required: boolean; value: any; translations: { @@ -12,19 +16,22 @@ export interface ojRadioset extends editableValue) => any) | null; - onLabelledByChanged: ((event: JetElementCustomEvent) => any) | null; - onRequiredChanged: ((event: JetElementCustomEvent) => any) | null; - onValueChanged: ((event: JetElementCustomEvent) => any) | null; + onDisabledChanged: ((event: JetElementCustomEvent["disabled"]>) => any) | null; + onLabelledByChanged: ((event: JetElementCustomEvent["labelledBy"]>) => any) | null; + onOptionRendererChanged: ((event: JetElementCustomEvent["optionRenderer"]>) => any) | null; + onOptionsChanged: ((event: JetElementCustomEvent["options"]>) => any) | null; + onOptionsKeysChanged: ((event: JetElementCustomEvent["optionsKeys"]>) => any) | null; + onRequiredChanged: ((event: JetElementCustomEvent["required"]>) => any) | null; + onValueChanged: ((event: JetElementCustomEvent["value"]>) => any) | null; onOjAnimateEnd: ((event: ojRadioset.ojAnimateEnd) => any) | null; onOjAnimateStart: ((event: ojRadioset.ojAnimateStart) => any) | null; - addEventListener(type: T, listener: (this: HTMLElement, ev: ojRadiosetEventMap[T]) => any, useCapture?: boolean): void; + addEventListener>(type: T, listener: (this: HTMLElement, ev: ojRadiosetEventMap[T]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - getProperty(property: T): ojRadioset[T]; + getProperty>(property: T): ojRadioset[T]; getProperty(property: string): any; - setProperty(property: T, value: ojRadiosetSettableProperties[T]): void; - setProperty(property: T, value: JetSetPropertyType): void; - setProperties(properties: ojRadiosetSettablePropertiesLenient): void; + setProperty>(property: T, value: ojRadiosetSettableProperties[T]): void; + setProperty(property: T, value: JetSetPropertyType>): void; + setProperties(properties: ojRadiosetSettablePropertiesLenient): void; refresh(): void; validate(): Promise; } @@ -42,18 +49,41 @@ export namespace ojRadioset { [propName: string]: any; }> { } + // tslint:disable-next-line interface-over-type-literal + type Option = { + disabled?: boolean; + label?: string; + value: any; + }; + // tslint:disable-next-line interface-over-type-literal + type OptionContext = { + component: Element; + index: number; + data: D; + }; + // tslint:disable-next-line interface-over-type-literal + type OptionsKeys = { + label?: string; + value?: string; + }; } -export interface ojRadiosetEventMap extends editableValueEventMap { +export interface ojRadiosetEventMap extends editableValueEventMap> { 'ojAnimateEnd': ojRadioset.ojAnimateEnd; 'ojAnimateStart': ojRadioset.ojAnimateStart; - 'disabledChanged': JetElementCustomEvent; - 'labelledByChanged': JetElementCustomEvent; - 'requiredChanged': JetElementCustomEvent; - 'valueChanged': JetElementCustomEvent; + 'disabledChanged': JetElementCustomEvent["disabled"]>; + 'labelledByChanged': JetElementCustomEvent["labelledBy"]>; + 'optionRendererChanged': JetElementCustomEvent["optionRenderer"]>; + 'optionsChanged': JetElementCustomEvent["options"]>; + 'optionsKeysChanged': JetElementCustomEvent["optionsKeys"]>; + 'requiredChanged': JetElementCustomEvent["required"]>; + 'valueChanged': JetElementCustomEvent["value"]>; } -export interface ojRadiosetSettableProperties extends editableValueSettableProperties { +export interface ojRadiosetSettableProperties extends editableValueSettableProperties { disabled: boolean; labelledBy: string | null; + optionRenderer?: ((param0: ojRadioset.OptionContext) => Element) | null; + options: DataProvider | null; + optionsKeys?: ojRadioset.OptionsKeys; required: boolean; value: any; translations: { @@ -64,6 +94,6 @@ export interface ojRadiosetSettableProperties extends editableValueSettablePrope }; }; } -export interface ojRadiosetSettablePropertiesLenient extends Partial { +export interface ojRadiosetSettablePropertiesLenient extends Partial> { [key: string]: any; } diff --git a/types/oracle__oraclejet/ojselectcombobox/index.d.ts b/types/oracle__oraclejet/ojselectcombobox/index.d.ts index 2444c99c4c..2775d8a22a 100644 --- a/types/oracle__oraclejet/ojselectcombobox/index.d.ts +++ b/types/oracle__oraclejet/ojselectcombobox/index.d.ts @@ -74,9 +74,7 @@ export interface ojComboboxMany extends ojCombobox>; converter: Converter | Validation.RegisteredConverter | null; minLength: number; - optionRenderer?: ((param0: ojCombobox.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojCombobox.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys: { @@ -95,6 +93,7 @@ export interface ojComboboxMany extends ojCombobox | Validation.RegisteredValidator> | null; value: any[] | null; @@ -120,6 +119,7 @@ export interface ojComboboxMany extends ojCombobox["pickerAttributes"]>) => any) | null; onPlaceholderChanged: ((event: JetElementCustomEvent["placeholder"]>) => any) | null; onRawValueChanged: ((event: JetElementCustomEvent["rawValue"]>) => any) | null; + onReadOnlyChanged: ((event: JetElementCustomEvent["readOnly"]>) => any) | null; onRequiredChanged: ((event: JetElementCustomEvent["required"]>) => any) | null; onValidatorsChanged: ((event: JetElementCustomEvent["validators"]>) => any) | null; onValueChanged: ((event: JetElementCustomEvent["value"]>) => any) | null; @@ -161,6 +161,7 @@ export interface ojComboboxManyEventMap extends ojComboboxEventMap["pickerAttributes"]>; 'placeholderChanged': JetElementCustomEvent["placeholder"]>; 'rawValueChanged': JetElementCustomEvent["rawValue"]>; + 'readOnlyChanged': JetElementCustomEvent["readOnly"]>; 'requiredChanged': JetElementCustomEvent["required"]>; 'validatorsChanged': JetElementCustomEvent["validators"]>; 'valueChanged': JetElementCustomEvent["value"]>; @@ -170,9 +171,7 @@ export interface ojComboboxManySettableProperties extends ojComboboxSettab asyncValidators: Array>; converter: Converter | Validation.RegisteredConverter | null; minLength: number; - optionRenderer?: ((param0: ojCombobox.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojCombobox.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys: { @@ -191,6 +190,7 @@ export interface ojComboboxManySettableProperties extends ojComboboxSettab }; placeholder: string | null; readonly rawValue: string | null; + readOnly: boolean; required: boolean; validators: Array | Validation.RegisteredValidator> | null; value: any[] | null; @@ -216,9 +216,7 @@ export interface ojComboboxOne extends ojCombobox | Validation.RegisteredConverter | null; filterOnOpen: 'none' | 'rawValue'; minLength: number; - optionRenderer?: ((param0: ojCombobox.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojCombobox.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys: { @@ -237,6 +235,7 @@ export interface ojComboboxOne extends ojCombobox | Validation.RegisteredValidator> | null; value: any; @@ -263,6 +262,7 @@ export interface ojComboboxOne extends ojCombobox["pickerAttributes"]>) => any) | null; onPlaceholderChanged: ((event: JetElementCustomEvent["placeholder"]>) => any) | null; onRawValueChanged: ((event: JetElementCustomEvent["rawValue"]>) => any) | null; + onReadOnlyChanged: ((event: JetElementCustomEvent["readOnly"]>) => any) | null; onRequiredChanged: ((event: JetElementCustomEvent["required"]>) => any) | null; onValidatorsChanged: ((event: JetElementCustomEvent["validators"]>) => any) | null; onValueChanged: ((event: JetElementCustomEvent["value"]>) => any) | null; @@ -313,6 +313,7 @@ export interface ojComboboxOneEventMap extends ojComboboxEventMap["pickerAttributes"]>; 'placeholderChanged': JetElementCustomEvent["placeholder"]>; 'rawValueChanged': JetElementCustomEvent["rawValue"]>; + 'readOnlyChanged': JetElementCustomEvent["readOnly"]>; 'requiredChanged': JetElementCustomEvent["required"]>; 'validatorsChanged': JetElementCustomEvent["validators"]>; 'valueChanged': JetElementCustomEvent["value"]>; @@ -323,9 +324,7 @@ export interface ojComboboxOneSettableProperties extends ojComboboxSettabl converter: Converter | Validation.RegisteredConverter | null; filterOnOpen: 'none' | 'rawValue'; minLength: number; - optionRenderer?: ((param0: ojCombobox.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojCombobox.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys: { @@ -344,6 +343,7 @@ export interface ojComboboxOneSettableProperties extends ojComboboxSettabl }; placeholder: string | null; readonly rawValue: string | null; + readOnly: boolean; required: boolean; validators: Array | Validation.RegisteredValidator> | null; value: any; @@ -434,9 +434,7 @@ export interface ojSelectSettablePropertiesLenient extends Partial extends ojSelect> { minimumResultsForSearch: number; - optionRenderer?: ((param0: ojSelect.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojSelect.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys?: { @@ -454,6 +452,7 @@ export interface ojSelectMany extends ojSelect extends ojSelect["optionsKeys"]>) => any) | null; onPickerAttributesChanged: ((event: JetElementCustomEvent["pickerAttributes"]>) => any) | null; onPlaceholderChanged: ((event: JetElementCustomEvent["placeholder"]>) => any) | null; + onReadOnlyChanged: ((event: JetElementCustomEvent["readOnly"]>) => any) | null; onRenderModeChanged: ((event: JetElementCustomEvent["renderMode"]>) => any) | null; onRequiredChanged: ((event: JetElementCustomEvent["required"]>) => any) | null; onValueChanged: ((event: JetElementCustomEvent["value"]>) => any) | null; @@ -517,6 +517,7 @@ export interface ojSelectManyEventMap extends ojSelectEventMap["optionsKeys"]>; 'pickerAttributesChanged': JetElementCustomEvent["pickerAttributes"]>; 'placeholderChanged': JetElementCustomEvent["placeholder"]>; + 'readOnlyChanged': JetElementCustomEvent["readOnly"]>; 'renderModeChanged': JetElementCustomEvent["renderMode"]>; 'requiredChanged': JetElementCustomEvent["required"]>; 'valueChanged': JetElementCustomEvent["value"]>; @@ -524,9 +525,7 @@ export interface ojSelectManyEventMap extends ojSelectEventMap extends ojSelectSettableProperties { minimumResultsForSearch: number; - optionRenderer?: ((param0: ojSelect.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojSelect.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys?: { @@ -544,6 +543,7 @@ export interface ojSelectManySettableProperties extends ojSelectSettablePr class?: string; }; placeholder: string | null; + readOnly: boolean; renderMode: 'jet' | 'native'; required: boolean; value: any[] | null; @@ -569,9 +569,7 @@ export interface ojSelectManySettablePropertiesLenient extends Partial extends ojSelect> { minimumResultsForSearch: number; - optionRenderer?: ((param0: ojSelect.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojSelect.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys?: { @@ -589,6 +587,7 @@ export interface ojSelectOne extends ojSelect extends ojSelect["optionsKeys"]>) => any) | null; onPickerAttributesChanged: ((event: JetElementCustomEvent["pickerAttributes"]>) => any) | null; onPlaceholderChanged: ((event: JetElementCustomEvent["placeholder"]>) => any) | null; + onReadOnlyChanged: ((event: JetElementCustomEvent["readOnly"]>) => any) | null; onRenderModeChanged: ((event: JetElementCustomEvent["renderMode"]>) => any) | null; onRequiredChanged: ((event: JetElementCustomEvent["required"]>) => any) | null; onValueChanged: ((event: JetElementCustomEvent["value"]>) => any) | null; @@ -652,6 +652,7 @@ export interface ojSelectOneEventMap extends ojSelectEventMap["optionsKeys"]>; 'pickerAttributesChanged': JetElementCustomEvent["pickerAttributes"]>; 'placeholderChanged': JetElementCustomEvent["placeholder"]>; + 'readOnlyChanged': JetElementCustomEvent["readOnly"]>; 'renderModeChanged': JetElementCustomEvent["renderMode"]>; 'requiredChanged': JetElementCustomEvent["required"]>; 'valueChanged': JetElementCustomEvent["value"]>; @@ -659,9 +660,7 @@ export interface ojSelectOneEventMap extends ojSelectEventMap extends ojSelectSettableProperties { minimumResultsForSearch: number; - optionRenderer?: ((param0: ojSelect.OptionContext) => { - insert: Element; - } | undefined) | null; + optionRenderer?: ((param0: ojSelect.OptionContext) => Element) | null; options: Array | DataProvider | null; optionsKeys: { childKeys?: { @@ -679,6 +678,7 @@ export interface ojSelectOneSettableProperties extends ojSelectSettablePro class?: string; }; placeholder: string | null; + readOnly: boolean; renderMode: 'jet' | 'native'; required: boolean; value: any; diff --git a/types/oracle__oraclejet/ojthematicmap/index.d.ts b/types/oracle__oraclejet/ojthematicmap/index.d.ts index 45bbd3b907..830db16e8e 100644 --- a/types/oracle__oraclejet/ojthematicmap/index.d.ts +++ b/types/oracle__oraclejet/ojthematicmap/index.d.ts @@ -78,7 +78,6 @@ export interface ojThematicMap extends dvtBaseComponent< touchResponse: 'touchStart' | 'auto'; zooming: 'auto' | 'none'; translations: { - areasRegion?: string; componentName?: string; labelAndValue?: string; labelClearSelection?: string; @@ -86,8 +85,6 @@ export interface ojThematicMap extends dvtBaseComponent< labelDataVisualization?: string; labelInvalidData?: string; labelNoData?: string; - linksRegion?: string; - markersRegion?: string; stateCollapsed?: string; stateDrillable?: string; stateExpanded?: string; @@ -249,7 +246,6 @@ export interface ojThematicMapSettableProperties extends touchResponse: 'touchStart' | 'auto'; zooming: 'auto' | 'none'; translations: { - areasRegion?: string; componentName?: string; labelAndValue?: string; labelClearSelection?: string; @@ -257,8 +253,6 @@ export interface ojThematicMapSettableProperties extends labelDataVisualization?: string; labelInvalidData?: string; labelNoData?: string; - linksRegion?: string; - markersRegion?: string; stateCollapsed?: string; stateDrillable?: string; stateExpanded?: string; diff --git a/types/oracle__oraclejet/ojvalidation-base/index.d.ts b/types/oracle__oraclejet/ojvalidation-base/index.d.ts index 83a20555db..af2aad5ed5 100644 --- a/types/oracle__oraclejet/ojvalidation-base/index.d.ts +++ b/types/oracle__oraclejet/ojvalidation-base/index.d.ts @@ -1,7 +1,7 @@ import Message = require('../ojmessaging'); import Color = require('../ojcolor'); export interface AsyncValidator { - hint: Promise; + hint: Promise<(string | null)>; validate(value: V): Promise; } export class ColorConverter implements Converter { diff --git a/types/oracle__oraclejet/ojvalidation-number/index.d.ts b/types/oracle__oraclejet/ojvalidation-number/index.d.ts index 09addc6522..7184d33135 100644 --- a/types/oracle__oraclejet/ojvalidation-number/index.d.ts +++ b/types/oracle__oraclejet/ojvalidation-number/index.d.ts @@ -23,9 +23,14 @@ export namespace IntlNumberConverter { pattern?: string; roundingMode?: 'HALF_UP' | 'HALF_DOWN' | 'HALF_EVEN'; roundDuringParse?: boolean; - separators?: object; + separators?: Separators; lenientParse?: 'full' | 'none'; }; + // tslint:disable-next-line interface-over-type-literal + type Separators = { + decimal?: string; + group?: string; + }; } export class NumberConverter implements Converter { format(value: number): string | null; diff --git a/types/oracle__oraclejet/tsconfig.json b/types/oracle__oraclejet/tsconfig.json index 5f529007f8..be741c3fe7 100644 --- a/types/oracle__oraclejet/tsconfig.json +++ b/types/oracle__oraclejet/tsconfig.json @@ -52,6 +52,7 @@ "ojdefer/index.d.ts", "ojdeferreddataprovider/index.d.ts", "ojdiagram/index.d.ts", + "ojdiagram-utils/index.d.ts", "ojdialog/index.d.ts", "ojdvt-base/index.d.ts", "ojeditablevalue/index.d.ts", @@ -87,6 +88,7 @@ "ojmoduleanimations/index.d.ts", "ojnavigationlist/index.d.ts", "ojnbox/index.d.ts", + "ojoffcanvas/index.d.ts", "ojoptgroup/index.d.ts", "ojoption/index.d.ts", "ojpictochart/index.d.ts", diff --git a/types/p-pipe/index.d.ts b/types/p-pipe/index.d.ts new file mode 100644 index 0000000000..2c58bd8f01 --- /dev/null +++ b/types/p-pipe/index.d.ts @@ -0,0 +1,86 @@ +// Type definitions for p-pipe 1.2 +// Project: https://github.com/sindresorhus/p-pipe#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +export = pPipe; + +// tslint:disable:no-unnecessary-generics +declare function pPipe(...args: Tasks1): PromiseTask; +declare function pPipe(...args: Tasks2): PromiseTask; +declare function pPipe(...args: Tasks3): PromiseTask; +declare function pPipe(...args: Tasks4): PromiseTask; +declare function pPipe( + ...args: Tasks5 +): PromiseTask; +declare function pPipe( + ...args: Tasks6 +): PromiseTask; +declare function pPipe( + ...args: Tasks7 +): PromiseTask; +declare function pPipe( + ...args: Tasks8 +): PromiseTask; +declare function pPipe(...args: Array>): PromiseTask; + +declare function pPipe(tasks: Tasks1): PromiseTask; +declare function pPipe(tasks: Tasks2): PromiseTask; +declare function pPipe(tasks: Tasks3): PromiseTask; +declare function pPipe(tasks: Tasks4): PromiseTask; +declare function pPipe( + tasks: Tasks5 +): PromiseTask; +declare function pPipe( + tasks: Tasks6 +): PromiseTask; +declare function pPipe( + tasks: Tasks7 +): PromiseTask; +declare function pPipe( + tasks: Tasks8 +): PromiseTask; +declare function pPipe(tasks: Array>): PromiseTask; + +type Tasks1 = [PromiseTask]; +type Tasks2 = [Task, Task]; +type Tasks3 = [Task, Task, Task]; +type Tasks4 = [Task, Task, Task, Task]; +type Tasks5 = [ + Task, + Task, + Task, + Task, + Task +]; +type Tasks6 = [ + Task, + Task, + Task, + Task, + Task, + Task +]; +type Tasks7 = [ + Task, + Task, + Task, + Task, + Task, + Task, + Task +]; +type Tasks8 = [ + Task, + Task, + Task, + Task, + Task, + Task, + Task, + Task +]; + +type Task = (input: T) => PromiseLike | R; +type PromiseTask = (input: T) => Promise; diff --git a/types/p-pipe/p-pipe-tests.ts b/types/p-pipe/p-pipe-tests.ts new file mode 100644 index 0000000000..8901637430 --- /dev/null +++ b/types/p-pipe/p-pipe-tests.ts @@ -0,0 +1,57 @@ +import pPipe = require('p-pipe'); + +const addUnicorn = (str: string) => Promise.resolve(`${str} Unicorn`); +const addRainbow = (str: string) => Promise.resolve(`${str} Rainbow`); + +const pipeline = pPipe(addUnicorn, addRainbow); + +pipeline('❤️'); // $ExpectType Promise + +const strToInt = (s: string) => Promise.resolve(1); +const intToBool = (i: number) => Promise.resolve(true); +const boolToObj = (b: boolean) => Promise.resolve({}); +const objToNull = (o: object) => Promise.resolve(null); +const nullToVoid = (n: null) => Promise.resolve(undefined); +const voidToStr = (u: undefined) => Promise.resolve(''); + +pPipe(strToInt); // $ExpectType PromiseTask +pPipe(strToInt, intToBool); // $ExpectType PromiseTask +pPipe(strToInt, intToBool, boolToObj); // $ExpectType PromiseTask +pPipe(strToInt, intToBool, boolToObj, objToNull); // $ExpectType PromiseTask +pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid); // $ExpectType PromiseTask +pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr); // $ExpectType PromiseTask +pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt); // $ExpectType PromiseTask +pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt, intToBool); // $ExpectType PromiseTask +// $ExpectType PromiseTask +pPipe( + strToInt, + intToBool, + boolToObj, + objToNull, + nullToVoid, + voidToStr, + strToInt, + intToBool, + boolToObj +); + +pPipe([strToInt]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool, boolToObj]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool, boolToObj, objToNull]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt]); // $ExpectType PromiseTask +pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt, intToBool]); // $ExpectType PromiseTask +// $ExpectType PromiseTask +pPipe([ + strToInt, + intToBool, + boolToObj, + objToNull, + nullToVoid, + voidToStr, + strToInt, + intToBool, + boolToObj, +]); diff --git a/types/p-pipe/tsconfig.json b/types/p-pipe/tsconfig.json new file mode 100644 index 0000000000..46cabfcfeb --- /dev/null +++ b/types/p-pipe/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", + "p-pipe-tests.ts" + ] +} diff --git a/types/p-pipe/tslint.json b/types/p-pipe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/p-pipe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pidusage/index.d.ts b/types/pidusage/index.d.ts index b16dada0ef..3efec6ce09 100644 --- a/types/pidusage/index.d.ts +++ b/types/pidusage/index.d.ts @@ -5,46 +5,59 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +interface Stat { + /** + * percentage (from 0 to 100*vcore) + */ + cpu: number; + + /** + * bytes + */ + memory: number; + + /** + * PPID + */ + ppid: number; + + /** + * PID + */ + pid: number; + + /** + * ms user + system time + */ + ctime: number; + + /** + * ms since the start of the process + */ + elapsed: number; + + /** + * ms since epoch + */ + timestamp: number; +} + declare function pidusage(pid: number | string, callback: (err: Error | null, stats: Stat) => void): void; +declare function pidusage(pid: number | string, options: { [key: string]: any }, callback: (err: Error | null, stats: Stat) => void): void; declare function pidusage(pids: Array, callback: (err: Error | null, stats: { [key: string]: Stat }) => void): void; -declare function pidusage(pid: number | string): Promise; -declare function pidusage(pids: Array): Promise<{ [key: string]: Stat }>; +declare function pidusage(pids: Array, options: { [key: string]: any }, callback: (err: Error | null, stats: { [key: string]: Stat }) => void): void; +declare function pidusage(pid: number | string, options?: { [key: string]: any }): Promise; +declare function pidusage(pids: Array, options?: { [key: string]: any }): Promise<{ [key: string]: Stat }>; -export default pidusage; +declare namespace pidusage { + type Status = Stat; -export interface Stat { - /** - * percentage (from 0 to 100*vcore) - */ - cpu: number; + /** + * If needed this function can be used to clear the event loop. + * Indeed, we're registering an interval to free up the in-memory metrics. + * By calling this, it will clear this interval and all delete all in-memory data + */ + function clear(): void; +} - /** - * bytes - */ - memory: number; - - /** - * PPID - */ - ppid: number; - - /** - * PID - */ - pid: number; - - /** - * ms user + system time - */ - ctime: number; - - /** - * ms since the start of the process - */ - elapsed: number; - - /** - * ms since epoch - */ - timestamp: number; - } +export = pidusage; diff --git a/types/pidusage/pidusage-tests.ts b/types/pidusage/pidusage-tests.ts index 614569dfa3..faa2b30c0c 100644 --- a/types/pidusage/pidusage-tests.ts +++ b/types/pidusage/pidusage-tests.ts @@ -1,4 +1,4 @@ -import pidusage, { Stat } from 'pidusage'; +import pidusage = require('pidusage'); let cpu: number; let memory: number; @@ -8,7 +8,7 @@ let ctime: number; let elapsed: number; let timestamp: number; -pidusage(1, (err: Error | null, stats: Stat) => { +pidusage(1, (err: Error | null, stats: pidusage.Status) => { cpu = stats.cpu; memory = stats.memory; ppid = stats.ppid; @@ -18,7 +18,7 @@ pidusage(1, (err: Error | null, stats: Stat) => { timestamp = stats.timestamp; }); -pidusage('two', (err: Error | null, stats: Stat) => { +pidusage('two', {}, (err: Error | null, stats: pidusage.Status) => { cpu = stats.cpu; memory = stats.memory; ppid = stats.ppid; @@ -28,11 +28,18 @@ pidusage('two', (err: Error | null, stats: Stat) => { timestamp = stats.timestamp; }); -pidusage([1, 'two'], (err: Error | null, stats: { [key: string]: Stat }) => { - const one: Stat = stats[1]; - const two: Stat = stats.two; +pidusage([1, 'two'], (err: Error | null, stats: { [key: string]: pidusage.Status }) => { + const one: pidusage.Status = stats[1]; + const two: pidusage.Status = stats.two; }); -const stats_1: Promise = pidusage(1); -const stats_two: Promise = pidusage('two'); -const stats_obj: Promise<{ [key: string]: Stat }> = pidusage([1, 'two']); +pidusage([1, 'two'], {}, (err: Error | null, stats: { [key: string]: pidusage.Status }) => { + const one: pidusage.Status = stats[1]; + const two: pidusage.Status = stats.two; +}); + +const stats_1: Promise = pidusage(1); +const stats_two: Promise = pidusage('two', {}); + +const stats_obj: Promise<{ [key: string]: pidusage.Status }> = pidusage([1, 'two']); +const stats_obj_config: Promise<{ [key: string]: pidusage.Status }> = pidusage([1, 'two'], {}); diff --git a/types/pkg-versions/index.d.ts b/types/pkg-versions/index.d.ts new file mode 100644 index 0000000000..a271a57485 --- /dev/null +++ b/types/pkg-versions/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for pkg-versions 1.1 +// Project: https://github.com/sindresorhus/pkg-versions#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = pkgVersions; + +declare function pkgVersions(name: string): Promise>; diff --git a/types/pkg-versions/pkg-versions-tests.ts b/types/pkg-versions/pkg-versions-tests.ts new file mode 100644 index 0000000000..f0b963b998 --- /dev/null +++ b/types/pkg-versions/pkg-versions-tests.ts @@ -0,0 +1,3 @@ +import pkgVersions = require('pkg-versions'); + +pkgVersions('ava'); // $ExpectType Promise> diff --git a/types/pkg-versions/tsconfig.json b/types/pkg-versions/tsconfig.json new file mode 100644 index 0000000000..cc9bffbcd4 --- /dev/null +++ b/types/pkg-versions/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", + "pkg-versions-tests.ts" + ] +} diff --git a/types/pkg-versions/tslint.json b/types/pkg-versions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pkg-versions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/positive-zero/index.d.ts b/types/positive-zero/index.d.ts new file mode 100644 index 0000000000..7396c68302 --- /dev/null +++ b/types/positive-zero/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for positive-zero 2.0 +// Project: https://github.com/sindresorhus/positive-zero#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = positiveZero; + +declare function positiveZero(input: number): boolean; diff --git a/types/positive-zero/positive-zero-tests.ts b/types/positive-zero/positive-zero-tests.ts new file mode 100644 index 0000000000..03d689a5d3 --- /dev/null +++ b/types/positive-zero/positive-zero-tests.ts @@ -0,0 +1,3 @@ +import positiveZero = require('positive-zero'); + +positiveZero(0); // $ExpectType boolean diff --git a/types/positive-zero/tsconfig.json b/types/positive-zero/tsconfig.json new file mode 100644 index 0000000000..b6f4f58dbc --- /dev/null +++ b/types/positive-zero/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", + "positive-zero-tests.ts" + ] +} diff --git a/types/positive-zero/tslint.json b/types/positive-zero/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/positive-zero/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ramda/es/innerJoin.d.ts b/types/ramda/es/innerJoin.d.ts new file mode 100644 index 0000000000..de01332837 --- /dev/null +++ b/types/ramda/es/innerJoin.d.ts @@ -0,0 +1,2 @@ +import { innerJoin } from '../index'; +export default innerJoin; diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 4832a13fdd..d84c148d96 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -25,6 +25,7 @@ // Ryan McCuaig // Drew Wyatt // John Ottenlips +// Nitesh Phadatare // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -110,6 +111,7 @@ /// /// /// +/// /// /// /// @@ -1167,6 +1169,23 @@ declare namespace R { init(list: ReadonlyArray): T[]; init(list: string): string; + /** + * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list + * `xs'` comprising each of the elements of `xs` which is equal to one or more + * elements of `ys` according to `pred`. + * + * `pred` must be a binary function expecting an element from each list. + * + * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should + * not be significant, but since `xs'` is ordered the implementation guarantees + * that its values are in the same order as they appear in `xs`. Duplicates are + * not removed, so `xs'` may contain duplicates if `xs` contains duplicates. + */ + + innerJoin(pred: (a: T1, b: T2) => boolean, list1: ReadonlyArray, list2: ReadonlyArray): T1[]; + innerJoin(pred: (a: T1, b: T2) => boolean): (list1: ReadonlyArray, list2: ReadonlyArray) => T1[]; + innerJoin(pred: (a: T1, b: T2) => boolean, list1: ReadonlyArray): (list2: ReadonlyArray) => T1[]; + /** * Inserts the supplied element into the list, at index index. Note that * this is not destructive: it returns a copy of the list with the changes. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 362948adda..c67ef3944d 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -2521,6 +2521,24 @@ class Rectangle { R.symmetricDifferenceWith(eqL)(l1, l2); // => ['dddd', 'c'] }; +() => { + const list1 = [ + {id: 1, name: 'One'}, + {id: 2, name: 'Two'}, + {id: 3, name: 'Three'}, + {id: 4, name: 'Four'}, + {id: 5, name: 'Five'} + ]; + + const list2 = [5, 4, 6]; + const matchId = (record: { id: number, name: string }, id: number): boolean => record.id === id; + + R.innerJoin(matchId, list1, list2); // [{"id": 4, "name": "Four"}, {"id": 5, "name": "Five"}] + + const innerJoinCurried = R.innerJoin(matchId); + innerJoinCurried(list1, list2); // [{"id": 4, "name": "Four"}, {"id": 5, "name": "Five"}] +}; + /***************************************************************** * String category */ diff --git a/types/react-bootstrap-table/index.d.ts b/types/react-bootstrap-table/index.d.ts index 1284162778..226bdf1606 100644 --- a/types/react-bootstrap-table/index.d.ts +++ b/types/react-bootstrap-table/index.d.ts @@ -1291,7 +1291,7 @@ export interface TableHeaderColumnProps extends Props { * generated automatically after a row insertion. If a function given, you can customize the value by yourself and * remember to return the value for the cell from the function. */ - autovalue?: boolean | (() => any); + autoValue?: boolean | (() => any); /** * False to disable search functionality on column, default is true. */ diff --git a/types/react-bootstrap-table/react-bootstrap-table-tests.tsx b/types/react-bootstrap-table/react-bootstrap-table-tests.tsx index 39422f2152..e742e41145 100644 --- a/types/react-bootstrap-table/react-bootstrap-table-tests.tsx +++ b/types/react-bootstrap-table/react-bootstrap-table-tests.tsx @@ -1222,7 +1222,7 @@ class HideOnInsertTable extends React.Component { }; return ( - Job ID + Job ID Job Name Job Type Active diff --git a/types/react-is/index.d.ts b/types/react-is/index.d.ts index 35d4b4db12..962d3e1a13 100644 --- a/types/react-is/index.d.ts +++ b/types/react-is/index.d.ts @@ -1,13 +1,19 @@ -// Type definitions for react-is 16.5 +// Type definitions for react-is 16.7 // Project: https://reactjs.org/ // Definitions by: Avi Vahl // Christian Chown +// Sebastian Silbermann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 export as namespace ReactIs; -import { ReactElement, ReactType } from 'react'; +import { + LazyExoticComponent, + MemoExoticComponent, + ReactElement, + ReactType +} from "react"; export function typeOf(value: any): symbol | undefined; export function isValidElementType(value: any): value is ReactType; @@ -17,16 +23,22 @@ export function isContextProvider(value: any): value is ReactElement; export function isElement(value: any): value is ReactElement; export function isForwardRef(value: any): value is ReactElement; export function isFragment(value: any): value is ReactElement; +export function isLazy(value: any): value is LazyExoticComponent; +export function isMemo(value: any): value is MemoExoticComponent; export function isProfiler(value: any): value is ReactElement; export function isPortal(value: any): value is ReactElement; export function isStrictMode(value: any): value is ReactElement; +export function isSuspense(value: any): value is ReactElement; export const AsyncMode: symbol; -export const ContextProvider: symbol; export const ContextConsumer: symbol; +export const ContextProvider: symbol; export const Element: symbol; export const ForwardRef: symbol; export const Fragment: symbol; +export const Lazy: symbol; +export const Memo: symbol; export const Portal: symbol; export const Profiler: symbol; export const StrictMode: symbol; +export const Suspense: symbol; diff --git a/types/react-is/react-is-tests.tsx b/types/react-is/react-is-tests.tsx index 3b41e9d06f..afbf0aabb6 100644 --- a/types/react-is/react-is-tests.tsx +++ b/types/react-is/react-is-tests.tsx @@ -22,6 +22,12 @@ const ForwardRefComponent = React.forwardRef((props, ref) => React.createElement(ClassComponent, { forwardedRef: ref, ...props }) ); +const LazyComponent = React.lazy(() => + Promise.resolve({ default: ForwardRefComponent }) +); + +const MemoComponent = React.memo(StatelessComponent); + const Context = React.createContext(false); ReactIs.isValidElementType('div'); // true @@ -31,6 +37,8 @@ ReactIs.isValidElementType(ForwardRefComponent); // true ReactIs.isValidElementType(Context.Provider); // true ReactIs.isValidElementType(Context.Consumer); // true ReactIs.isValidElementType(React.createFactory('div')); // true +ReactIs.isValidElementType(LazyComponent); +ReactIs.isValidElementType(MemoComponent); // Determining an Element's Type @@ -74,5 +82,17 @@ ReactIs.typeOf(null) === undefined; ReactIs.typeOf(undefined) === undefined; // ForwardRef -const forwardRef = React.forwardRef((props, ref) =>
); -ReactIs.isForwardRef(forwardRef); // true +ReactIs.isForwardRef(); // true +ReactIs.typeOf() === ReactIs.ForwardRef; // true + +// Lazy +ReactIs.isLazy(LazyComponent); // true +ReactIs.typeOf(LazyComponent) === ReactIs.Lazy; // true + +// Memo +ReactIs.isMemo(MemoComponent); // true +ReactIs.typeOf(MemoComponent) === ReactIs.Memo; // true + +// Suspense +ReactIs.isForwardRef(); // true +ReactIs.typeOf() === ReactIs.Suspense; // true diff --git a/types/react-lifecycles-compat/index.d.ts b/types/react-lifecycles-compat/index.d.ts new file mode 100644 index 0000000000..7db045bdde --- /dev/null +++ b/types/react-lifecycles-compat/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for react-lifecycles-compat 3.0 +// Project: https://github.com/reactjs/react-lifecycles-compat#readme +// Definitions by: bySabi Files +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export function polyfill

(Comp: React.ComponentType

): React.ComponentType

; diff --git a/types/react-lifecycles-compat/react-lifecycles-compat-tests.ts b/types/react-lifecycles-compat/react-lifecycles-compat-tests.ts new file mode 100644 index 0000000000..bf514b6818 --- /dev/null +++ b/types/react-lifecycles-compat/react-lifecycles-compat-tests.ts @@ -0,0 +1,10 @@ +import * as React from 'react'; +import { polyfill } from 'react-lifecycles-compat'; + +class A extends React.Component { + render() { + return null; + } +} + +const Comp = polyfill(A); diff --git a/types/react-lifecycles-compat/tsconfig.json b/types/react-lifecycles-compat/tsconfig.json new file mode 100644 index 0000000000..25d2d0307d --- /dev/null +++ b/types/react-lifecycles-compat/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + }, + "files": [ + "index.d.ts", + "react-lifecycles-compat-tests.ts" + ] +} diff --git a/types/react-lifecycles-compat/tslint.json b/types/react-lifecycles-compat/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-lifecycles-compat/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native-push-notification/index.d.ts b/types/react-native-push-notification/index.d.ts index 4f58cd7385..825d5d11e6 100644 --- a/types/react-native-push-notification/index.d.ts +++ b/types/react-native-push-notification/index.d.ts @@ -14,7 +14,7 @@ export interface PushNotificationPermissions { export interface PushNotification { foreground: boolean; userInteraction: boolean; - message: string|object; + message: string | object; data: object; badge: number; alert: object; @@ -23,7 +23,7 @@ export interface PushNotification { } export interface PushNotificationOptions { - onRegister?: (token: { os: string, token: string }) => void; + onRegister?: (token: { os: string; token: string }) => void; onNotification?: (notification: PushNotification) => void; senderID?: string; permissions?: PushNotificationPermissions; @@ -31,6 +31,7 @@ export interface PushNotificationOptions { requestPermissions?: boolean; } +export type PriorityType = 'max' | 'high' | 'low' | 'min' | 'default'; export type RepeatType = 'week' | 'day' | 'hour' | 'minute' | 'time'; export class PushNotificationObject { @@ -48,6 +49,7 @@ export class PushNotificationObject { tag?: string; group?: string; ongoing?: boolean; + priority?: PriorityType; /* iOS only properties */ alertAction?: any; diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index cbc45eb065..0361934bf0 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7315,7 +7315,7 @@ export interface IntentAndroidStatic { @deprecated */ - getInitialURL(callback: (url: string) => void): void; + getInitialURL(callback: (url: string | null) => void): void; } export interface LinkingStatic extends NativeEventEmitter { @@ -7350,7 +7350,7 @@ export interface LinkingStatic extends NativeEventEmitter { * If the app launch was triggered by an app link with, it will give the link url, otherwise it will give null * NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents */ - getInitialURL(): Promise; + getInitialURL(): Promise; } export interface LinkingIOSStatic { diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 4186b082fb..38d86ae19e 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -33,6 +33,7 @@ import { ImageResolvedAssetSource, ImageBackground, InteractionManager, + Linking, ListView, ListViewDataSource, StyleSheet, @@ -406,6 +407,12 @@ export class CapsLockComponent extends React.Component { } } +const getInitialUrlTest = () => Linking.getInitialURL().then(val => { + if (val !== null) { + val.indexOf('val is now a string'); + } +}) + class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListViewDataSource }> { eventHandler = (event: NativeSyntheticEvent) => { console.log(event); diff --git a/types/react-overlays/index.d.ts b/types/react-overlays/index.d.ts index a8df0341be..59475d3c29 100644 --- a/types/react-overlays/index.d.ts +++ b/types/react-overlays/index.d.ts @@ -1,52 +1,55 @@ -// Type definitions for React Overlays 0.8 +// Type definitions for React Overlays 1.1 // Project: https://github.com/react-bootstrap/react-overlays // Definitions by: Aaron Beall // Vito Samson +// Aaron Dancer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 - import * as React from "react"; export { - Affix, - AutoAffix, - Modal, - ModalManager, - Overlay, - Portal, - Position, - RootCloseWrapper, + Affix, + AutoAffix, + Modal, + ModalManager, + Overlay, + Portal, + Dropdown, + DropdownMenu, + DropdownToggle, + RootCloseWrapper, + WaitForContainer } from './lib'; // these callbacks are used in a few components export interface TransitionCallbacks { - /** - * Callback fired before the Overlay transitions in - */ - onEnter?(node: HTMLElement): any; + /** + * Callback fired before the Overlay transitions in + */ + onEnter?(node: HTMLElement): any; - /** - * Callback fired as the Overlay begins to transition in - */ - onEntering?(node: HTMLElement): any; + /** + * Callback fired as the Overlay begins to transition in + */ + onEntering?(node: HTMLElement): any; - /** - * Callback fired after the Overlay finishes transitioning in - */ - onEntered?(node: HTMLElement): any; + /** + * Callback fired after the Overlay finishes transitioning in + */ + onEntered?(node: HTMLElement): any; - /** - * Callback fired right before the Overlay transitions out - */ - onExit?(node: HTMLElement): any; + /** + * Callback fired right before the Overlay transitions out + */ + onExit?(node: HTMLElement): any; - /** - * Callback fired as the Overlay begins to transition out - */ - onExiting?(node: HTMLElement): any; + /** + * Callback fired as the Overlay begins to transition out + */ + onExiting?(node: HTMLElement): any; - /** - * Callback fired after the Overlay finishes transitioning out - */ - onExited?(node: HTMLElement): any; + /** + * Callback fired after the Overlay finishes transitioning out + */ + onExited?(node: HTMLElement): any; } diff --git a/types/react-overlays/lib/Affix.d.ts b/types/react-overlays/lib/Affix.d.ts index e24cb8186a..abe04230ff 100644 --- a/types/react-overlays/lib/Affix.d.ts +++ b/types/react-overlays/lib/Affix.d.ts @@ -1,84 +1,84 @@ -import * as React from 'react'; +import * as React from "react"; -declare class Affix extends React.Component { } +declare class Affix extends React.Component {} export = Affix; declare namespace Affix { - // put AffixProps inside the exported namespace so it's importable in AutoAffix - interface AffixProps { - /** - * Pixels to offset from top of screen when calculating position - */ - offsetTop?: number; + // put AffixProps inside the exported namespace so it's importable in AutoAffix + interface AffixProps { + /** + * Pixels to offset from top of screen when calculating position + */ + offsetTop?: number; - /** - * When affixed, pixels to offset from top of viewport - */ - viewportOffsetTop?: number; + /** + * When affixed, pixels to offset from top of viewport + */ + viewportOffsetTop?: number; - /** - * Pixels to offset from bottom of screen when calculating position - */ - offsetBottom?: number; + /** + * Pixels to offset from bottom of screen when calculating position + */ + offsetBottom?: number; - /** - * CSS class or classes to apply when at top - */ - topClassName?: string; + /** + * CSS class or classes to apply when at top + */ + topClassName?: string; - /** - * Style to apply when at top - */ - topStyle?: React.CSSProperties; + /** + * Style to apply when at top + */ + topStyle?: React.CSSProperties; - /** - * CSS class or classes to apply when affixed - */ - affixClassName?: string; + /** + * CSS class or classes to apply when affixed + */ + affixClassName?: string; - /** - * Style to apply when affixed - */ - affixStyle?: React.CSSProperties; + /** + * Style to apply when affixed + */ + affixStyle?: React.CSSProperties; - /** - * CSS class or classes to apply when at bottom - */ - bottomClassName?: string; + /** + * CSS class or classes to apply when at bottom + */ + bottomClassName?: string; - /** - * Style to apply when at bottom - */ - bottomStyle?: React.CSSProperties; + /** + * Style to apply when at bottom + */ + bottomStyle?: React.CSSProperties; - /** - * Callback fired when the right before the `affixStyle` and `affixStyle` props are rendered - */ - onAffix?(): void; + /** + * Callback fired when the right before the `affixStyle` and `affixStyle` props are rendered + */ + onAffix?(): void; - /** - * Callback fired after the component `affixStyle` and `affixClassName` props have been rendered. - */ - onAffixed?(): void; + /** + * Callback fired after the component `affixStyle` and `affixClassName` props have been rendered. + */ + onAffixed?(): void; - /** - * Callback fired when the right before the `topStyle` and `topClassName` props are rendered - */ - onAffixTop?(): void; + /** + * Callback fired when the right before the `topStyle` and `topClassName` props are rendered + */ + onAffixTop?(): void; - /** - * Callback fired after the component `topStyle` and `topClassName` props have been rendered. - */ - onAffixedTop?(): void; + /** + * Callback fired after the component `topStyle` and `topClassName` props have been rendered. + */ + onAffixedTop?(): void; - /** - * Callback fired when the right before the `bottomStyle` and `bottomClassName` props are rendered - */ - onAffixBottom?(): void; + /** + * Callback fired when the right before the `bottomStyle` and `bottomClassName` props are rendered + */ + onAffixBottom?(): void; - /** - * Callback fired after the component `bottomStyle` and `bottomClassName` props have been rendered. - */ - onAffixedBottom?(): void; - } + /** + * Callback fired after the component `bottomStyle` and `bottomClassName` props have been rendered. + */ + onAffixedBottom?(): void; + } } diff --git a/types/react-overlays/lib/AutoAffix.d.ts b/types/react-overlays/lib/AutoAffix.d.ts index 8c075c1782..fb239106a0 100644 --- a/types/react-overlays/lib/AutoAffix.d.ts +++ b/types/react-overlays/lib/AutoAffix.d.ts @@ -1,19 +1,20 @@ -import * as React from 'react'; -import { AffixProps } from './Affix'; +import * as React from "react"; -declare class AutoAffix extends React.Component { } -declare namespace AutoAffix { } +import { AffixProps } from "./Affix"; + +declare class AutoAffix extends React.Component {} +declare namespace AutoAffix {} export = AutoAffix; interface AutoAffixProps extends AffixProps { - /** - * The logical container node or component for determining offset from bottom - * of viewport, or a function that returns it - */ - container?: React.ReactInstance | (() => React.ReactInstance); + /** + * The logical container node or component for determining offset from bottom + * of viewport, or a function that returns it + */ + container?: React.ReactInstance | (() => React.ReactInstance); - /** - * Automatically set width when affixed - */ - autoWidth?: boolean; + /** + * Automatically set width when affixed + */ + autoWidth?: boolean; } diff --git a/types/react-overlays/lib/Dropdown.d.ts b/types/react-overlays/lib/Dropdown.d.ts new file mode 100644 index 0000000000..ebd4c298af --- /dev/null +++ b/types/react-overlays/lib/Dropdown.d.ts @@ -0,0 +1,57 @@ +import * as React from "react"; + +import DropdownMenu = require("./DropdownMenu"); +import DropdownToggle = require("./DropdownToggle"); + +declare class Dropdown extends React.Component { + static Menu: typeof DropdownMenu; + static Toggle: typeof DropdownToggle; +} +export = Dropdown; + +declare namespace Dropdown { + interface DropdownRenderProps { + props: { + onKeyDown(event: React.SyntheticEvent): void; + }; + } + + type Directions = 'up' | 'left' | 'right' | 'down'; + + interface DropdownProps { + /** + * A render prop that returns the root dropdown element. The `props` + * argument should spread through to an element containing _both_ the + * menu and toggle in order to handle keyboard events for focus management. + */ + children(renderProps: DropdownRenderProps): React.ReactElement; + + /** + * Determines the direction and location of the Menu in relation to it's Toggle. + */ + drop?: Directions; + + /** + * A css slector string that will return __focusable__ menu items. + * Selectors should be relative to the menu component: + * e.g. ` > li:not('.disabled')` + */ + itemSelector?: string; + + /** + * Align the menu to the 'end' side of the placement side of the Dropdown toggle. The default placement is `top-start` or `bottom-start`. + */ + alignEnd?: boolean; + + /** + * Whether or not the Dropdown is visible + */ + show?: boolean; + + /** + * A callback fired when the Dropdown wishes to change visibility. Called with the requested + * `show` value, the DOM event, and the source that fired it: `'click'`,`'keydown'`,`'rootClose'`, or `'select'`. + */ + onToggle?(isOpen: boolean, event: React.SyntheticEvent): void; + } +} diff --git a/types/react-overlays/lib/DropdownMenu.d.ts b/types/react-overlays/lib/DropdownMenu.d.ts new file mode 100644 index 0000000000..c4a9090dcc --- /dev/null +++ b/types/react-overlays/lib/DropdownMenu.d.ts @@ -0,0 +1,55 @@ +import * as React from "react"; + +import Overlay = require("./Overlay"); + +declare class DropdownMenu extends React.Component< + DropdownMenu.DropdownMenuProps +> {} +export = DropdownMenu; + +declare namespace DropdownMenu { + interface DropdownMenuRenderProps extends Overlay.OverlayRenderProps { + alignEnd: boolean; + close(event: React.SyntheticEvent): void; + } + + interface DropdownMenuProps { + /** + * A render prop that returns a Menu element. The `props` + * argument should spread through to **a component that can accept a ref**. + */ + children(renderProps: DropdownMenuRenderProps): React.ReactElement; + + /** + * Controls the visible state of the menu, generally this is + * provided by the parent `Dropdown` component, + * but may also be specified as a prop directly. + */ + show?: boolean; + + /** + * Aligns the dropdown menu to the 'end' of it's placement position. + * Generally this is provided by the parent `Dropdown` component, + * but may also be specified as a prop directly. + */ + alignEnd?: boolean; + + /** + * Enables the Popper.js `flip` modifier, allowing the Dropdown to + * automatically adjust it's placement in case of overlap with the viewport or toggle. + */ + flip?: boolean; + + usePopper?: boolean; + + /** + * A set of popper options and props passed directly to react-popper's Popper component. + */ + popperConfig?: object; + + /** + * Override the default event used by RootCloseWrapper. + */ + rootCloseEvent?: string; + } +} diff --git a/types/react-overlays/lib/DropdownToggle.d.ts b/types/react-overlays/lib/DropdownToggle.d.ts new file mode 100644 index 0000000000..d2838e8fd1 --- /dev/null +++ b/types/react-overlays/lib/DropdownToggle.d.ts @@ -0,0 +1,29 @@ +import * as React from "react"; + +declare class DropdownToggle extends React.Component< + DropdownToggle.DropdownToggleProps +> {} +export = DropdownToggle; + +declare namespace DropdownToggle { + interface DropdownToggleRenderProps { + show: boolean; + toggle(show: boolean): void; + props: { + ref?(element: HTMLElement): void; + 'aria-haspopup': true; + 'aria-expanded': boolean; + }; + } + + interface DropdownToggleProps { + /** + * A render prop that returns a Toggle element. The `props` + * argument should spread through to **a component that can accept a ref**. Use + * the `onToggle` argument to toggle the menu open or closed + */ + children( + renderProps: DropdownToggleRenderProps + ): React.ReactElement; + } +} diff --git a/types/react-overlays/lib/Modal.d.ts b/types/react-overlays/lib/Modal.d.ts index f626a30119..c7fcb7a4e9 100644 --- a/types/react-overlays/lib/Modal.d.ts +++ b/types/react-overlays/lib/Modal.d.ts @@ -1,129 +1,131 @@ -import * as React from 'react'; -import { TransitionCallbacks } from 'react-overlays'; -import { TransitionProps } from 'react-transition-group/Transition'; -import * as ModalManager from './ModalManager'; -import { PortalProps } from './Portal'; +import * as React from "react"; + +import { TransitionCallbacks } from "react-overlays"; +import { TransitionProps } from "react-transition-group/Transition"; + +import * as ModalManager from "./ModalManager"; +import { PortalProps } from "./Portal"; declare class Modal extends React.Component { - public static Manager: ModalManager; + public static Manager: ModalManager; } -declare namespace Modal { } +declare namespace Modal {} export = Modal; interface ModalProps extends TransitionCallbacks, PortalProps { - className?: string; + className?: string; - /** - * Set the visibility of the Modal - */ - show?: boolean; + /** + * Set the visibility of the Modal + */ + show?: boolean; - /** - * A Node, Component instance, or function that returns either. The Modal is appended to it's container element. - * - * For the sake of assistive technologies, the container should usually be the document body, so that the rest of the - * page content can be placed behind a virtual backdrop as well as a visual one. - */ - container?: React.ReactNode | Function; + /** + * A Node, Component instance, or function that returns either. The Modal is appended to it's container element. + * + * For the sake of assistive technologies, the container should usually be the document body, so that the rest of the + * page content can be placed behind a virtual backdrop as well as a visual one. + */ + container?: React.ReactNode | Function; - /** - * A callback fired when the Modal is opening. - */ - onShow?: Function; + /** + * A callback fired when the Modal is opening. + */ + onShow?: Function; - /** - * A callback fired when either the backdrop is clicked, or the escape key is pressed. - * - * The `onHide` callback only signals intent from the Modal, - * you must actually set the `show` prop to `false` for the Modal to close. - */ - onHide?: Function; + /** + * A callback fired when either the backdrop is clicked, or the escape key is pressed. + * + * The `onHide` callback only signals intent from the Modal, + * you must actually set the `show` prop to `false` for the Modal to close. + */ + onHide?: Function; - /** - * Include a backdrop component. - */ - backdrop?: boolean | 'static'; + /** + * Include a backdrop component. + */ + backdrop?: boolean | 'static'; - /** - * A function that returns a backdrop component. Useful for custom - * backdrop rendering. - * - * ```js - * renderBackdrop={props => } - * ``` - */ - renderBackdrop?(props: any): React.ReactNode; + /** + * A function that returns the dialog component. Useful for custom + * rendering. **Note:** the component should make sure to apply the provided ref. + * + * ```js + * renderDialog={props => } + * ``` + */ + renderDialog?(props: any): React.ReactNode; - /** - * A callback fired when the escape key, if specified in `keyboard`, is pressed. - */ - onEscapeKeyUp?: Function; + /** + * A function that returns a backdrop component. Useful for custom + * backdrop rendering. + * + * ```js + * renderBackdrop={props => } + * ``` + */ + renderBackdrop?(props: any): React.ReactNode; - /** - * A callback fired when the backdrop, if specified, is clicked. - */ - onBackdropClick?: Function; + /** + * A callback fired when the escape key, if specified in `keyboard`, is pressed. + */ + onEscapeKeyDown?: Function; - /** - * A style object for the backdrop component. - */ - backdropStyle?: Object; + /** + * A callback fired when the backdrop, if specified, is clicked. + */ + onBackdropClick?: Function; - /** - * A css class or classes for the backdrop component. - */ - backdropClassName?: string; + /** + * A css class or set of classes applied to the modal container when the modal is open, + * and removed when it is closed. + */ + containerClassName?: string; - /** - * A css class or set of classes applied to the modal container when the modal is open, - * and removed when it is closed. - */ - containerClassName?: string; + /** + * Close the modal when escape key is pressed + */ + keyboard?: boolean; - /** - * Close the modal when escape key is pressed - */ - keyboard?: boolean; + /** + * A `react-transition-group@2.0.0` `` component used + * to control animations for the dialog component. + */ + transition?: React.ComponentType; - /** - * A `react-transition-group@2.0.0` `` component used - * to control animations for the dialog component. - */ - transition?: React.ComponentType; + /** + * A `react-transition-group@2.0.0` `` component used + * to control animations for the backdrop components. + */ + backdropTransition?: React.ComponentType; - /** - * A `react-transition-group@2.0.0` `` component used - * to control animations for the backdrop components. - */ - backdropTransition?: React.ComponentType; + /** + * When `true` The modal will automatically shift focus to itself when it opens, and + * replace it to the last focused element when it closes. This also + * works correctly with any Modal children that have the `autoFocus` prop. + * + * Generally this should never be set to `false` as it makes the Modal less + * accessible to assistive technologies, like screen readers. + */ + autoFocus?: boolean; - /** - * When `true` The modal will automatically shift focus to itself when it opens, and - * replace it to the last focused element when it closes. This also - * works correctly with any Modal children that have the `autoFocus` prop. - * - * Generally this should never be set to `false` as it makes the Modal less - * accessible to assistive technologies, like screen readers. - */ - autoFocus?: boolean; + /** + * When `true` The modal will prevent focus from leaving the Modal while open. + * + * Generally this should never be set to `false` as it makes the Modal less + * accessible to assistive technologies, like screen readers. + */ + enforceFocus?: boolean; - /** - * When `true` The modal will prevent focus from leaving the Modal while open. - * - * Generally this should never be set to `false` as it makes the Modal less - * accessible to assistive technologies, like screen readers. - */ - enforceFocus?: boolean; + /** + * When `true` The modal will restore focus to previously focused element once + * modal is hidden + */ + restoreFocus?: boolean; - /** - * When `true` The modal will restore focus to previously focused element once - * modal is hidden - */ - restoreFocus?: boolean; - - /** - * A ModalManager instance used to track and manage the state of open - * Modals. Useful when customizing how modals interact within a container - */ - manager?: ModalManager; + /** + * A ModalManager instance used to track and manage the state of open + * Modals. Useful when customizing how modals interact within a container + */ + manager?: ModalManager; } diff --git a/types/react-overlays/lib/ModalManager.d.ts b/types/react-overlays/lib/ModalManager.d.ts index f2492aee7d..2a63eb23ab 100644 --- a/types/react-overlays/lib/ModalManager.d.ts +++ b/types/react-overlays/lib/ModalManager.d.ts @@ -1,10 +1,17 @@ -import * as Modal from './Modal'; +import * as Modal from "./Modal"; declare class ModalManager { - constructor(opts?: { hideSiblingNodes?: boolean; handleContainerOverflow?: boolean }); - add(modal: Modal, container: any, className?: string): number; - remove(modal: Modal): void; - isTopModal(modal: Modal): boolean; + constructor(opts?: { + hideSiblingNodes?: boolean; + handleContainerOverflow?: boolean; + }); + isContainerOverflowing(modal: Modal): boolean; + containerIndexFromModal(modal: Modal): number; + setContainerStyle(containerState: any, container: any): void; + removeContainerStyle(containerState: any, container: any): void; + add(modal: Modal, container: any, className?: string): number; + remove(modal: Modal): void; + isTopModal(modal: Modal): boolean; } -declare namespace ModalManager { } +declare namespace ModalManager {} export = ModalManager; diff --git a/types/react-overlays/lib/Overlay.d.ts b/types/react-overlays/lib/Overlay.d.ts index 3b6cd22be9..c374846188 100644 --- a/types/react-overlays/lib/Overlay.d.ts +++ b/types/react-overlays/lib/Overlay.d.ts @@ -1,35 +1,87 @@ -import * as React from 'react'; -import { TransitionCallbacks } from 'react-overlays'; -import { TransitionProps } from 'react-transition-group/Transition'; -import { PortalProps } from './Portal'; -import { PositionProps } from './Position'; +import * as React from "react"; -declare class Overlay extends React.Component { } +import { TransitionCallbacks } from "react-overlays"; +import { TransitionProps } from "react-transition-group/Transition"; + +import { RootCloseWrapper } from "."; +import { PortalProps } from "./Portal"; + +declare class Overlay extends React.Component {} export = Overlay; declare namespace Overlay { - interface OverlayProps extends TransitionCallbacks, PortalProps, PositionProps { - /** - * Set the visibility of the Overlay - */ - show?: boolean; + type Placements = 'top' | 'left' | 'right' | 'bottom'; - /** - * Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay - */ - rootClose?: boolean; + interface OverlayRenderProps { + show: boolean; + placement: Placements; + outOfBoundaries?: boolean; + scheduleUpdate(): void; + props: { + ref?(element: HTMLElement): void; + style: { [key: string]: string | number }; + 'aria-labelledby'?: string; + }; + arrowProps: { + ref?(element: HTMLElement): void; + style: { [key: string]: string | number }; + }; + } - /** - * A Callback fired by the Overlay when it wishes to be hidden. - * - * __required__ when `rootClose` is `true`. - */ - onHide?(props: PortalProps, ...args: any[]): any; + interface OverlayProps extends TransitionCallbacks, PortalProps { + /** + * Set the visibility of the Overlay + */ + show?: boolean; - /** - * A `react-transition-group@2.0.0` `` component - * used to animate the overlay as it changes visibility. - */ - transition?: React.ComponentType; - } + /** Specify where the overlay element is positioned in relation to the target element */ + placement?: Placements; + + /** + * Enables the Popper.js `flip` modifier, allowing the Overlay to + * automatically adjust it's placement in case of overlap with the viewport or toggle. + */ + flip?: boolean; + + /** + * A render prop that returns an element to overlay and position. See + * the [react-popper documentation](https://github.com/FezVrasta/react-popper#children) for more info. + */ + children(renderProps: OverlayRenderProps): React.ReactElement; + + /** + * A set of popper options and props passed directly to react-popper's Popper component. + */ + popperConfig?: object; + + /** + * Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay + */ + rootClose?: boolean; + + /** + * Specify event for toggling overlay + */ + rootCloseEvent?: RootCloseWrapper.RootCloseWrapperProps['event']; + + /** + * Specify disabled for disable RootCloseWrapper + */ + rootCloseDisabled?: boolean; + + /** + * A Callback fired by the Overlay when it wishes to be hidden. + * + * __required__ when `rootClose` is `true`. + */ + onHide?(props: PortalProps, ...args: any[]): any; + + /** + * A `react-transition-group@2.0.0` `` component + * used to animate the overlay as it changes visibility. + */ + transition?: React.ComponentType; + + target?: React.ReactInstance | (() => React.ReactInstance); + } } diff --git a/types/react-overlays/lib/Portal.d.ts b/types/react-overlays/lib/Portal.d.ts index b70c273b33..c23645b008 100644 --- a/types/react-overlays/lib/Portal.d.ts +++ b/types/react-overlays/lib/Portal.d.ts @@ -1,10 +1,12 @@ -import * as React from 'react'; +import * as React from "react"; -declare class Portal extends React.Component { } +declare class Portal extends React.Component {} export = Portal; declare namespace Portal { - interface PortalProps { - container?: React.ReactNode | Function; - } + interface PortalProps { + container?: React.ReactNode | Function; + + onRendered?: Function; + } } diff --git a/types/react-overlays/lib/Position.d.ts b/types/react-overlays/lib/Position.d.ts deleted file mode 100644 index 2bbca4364e..0000000000 --- a/types/react-overlays/lib/Position.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as React from 'react'; - -declare class Position extends React.Component { } -export = Position; - -declare namespace Position { - interface PositionProps { - /** - * A node, element, or function that returns either. The child will be - * be positioned next to the `target` specified. - */ - target?: React.ReactNode | Function; - - /** - * "offsetParent" of the component - */ - container?: React.ReactNode | Function; - - /** - * Minimum spacing in pixels between container border and component border - */ - containerPadding?: number; - - /** - * How to position the component relative to the target - */ - placement?: 'top' | 'right' | 'bottom' | 'left'; - - /** - * Whether the position should be changed on each update - */ - shouldUpdatePosition?: boolean; - } -} diff --git a/types/react-overlays/lib/RootCloseWrapper.d.ts b/types/react-overlays/lib/RootCloseWrapper.d.ts index 679426b50c..e24ab89a6b 100644 --- a/types/react-overlays/lib/RootCloseWrapper.d.ts +++ b/types/react-overlays/lib/RootCloseWrapper.d.ts @@ -1,28 +1,31 @@ import * as React from "react"; -declare class RootCloseWrapper extends React.Component { } -declare namespace RootCloseWrapper { } +declare class RootCloseWrapper extends React.Component< + RootCloseWrapper.RootCloseWrapperProps +> {} export = RootCloseWrapper; -interface RootCloseWrapperProps { - /** - * Callback fired after click or mousedown. Also triggers when user hits `esc`. - */ - onRootClose?(e: React.SyntheticEvent): void; +declare namespace RootCloseWrapper { + interface RootCloseWrapperProps { + /** + * Callback fired after click or mousedown. Also triggers when user hits `esc`. + */ + onRootClose?(e: React.SyntheticEvent): void; - /** - * Children to render. - */ - children?: React.ReactNode; + /** + * Children to render. + */ + children?: React.ReactNode; - /** - * Disable the the RootCloseWrapper, preventing it from triggering - * `onRootClose`. - */ - disabled?: boolean; + /** + * Disable the the RootCloseWrapper, preventing it from triggering + * `onRootClose`. + */ + disabled?: boolean; - /** - * Choose which document mouse event to bind to - */ - event?: 'click' | 'mousedown'; + /** + * Choose which document mouse event to bind to + */ + event?: 'click' | 'mousedown'; + } } diff --git a/types/react-overlays/lib/WaitForContainer.d.ts b/types/react-overlays/lib/WaitForContainer.d.ts new file mode 100644 index 0000000000..c9e275639e --- /dev/null +++ b/types/react-overlays/lib/WaitForContainer.d.ts @@ -0,0 +1,17 @@ +import * as React from "react"; + +declare class WaitForContainer extends React.Component< + WaitForContainer.WaitForContainerProps +> {} +export = WaitForContainer; + +declare namespace WaitForContainer { + interface WaitForContainerProps { + /** + * "offsetParent" of the component + */ + container?: React.ReactNode | Function; + + onContainerResolved?: Function; + } +} diff --git a/types/react-overlays/lib/index.d.ts b/types/react-overlays/lib/index.d.ts index ea95108f8f..fd90edd095 100644 --- a/types/react-overlays/lib/index.d.ts +++ b/types/react-overlays/lib/index.d.ts @@ -1,19 +1,25 @@ -import Affix = require('./Affix'); -import AutoAffix = require('./AutoAffix'); -import Modal = require('./Modal'); -import ModalManager = require('./ModalManager'); -import Overlay = require('./Overlay'); -import Portal = require('./Portal'); -import Position = require('./Position'); -import RootCloseWrapper = require('./RootCloseWrapper'); +import Affix = require("./Affix"); +import AutoAffix = require("./AutoAffix"); +import Dropdown = require("./Dropdown"); +import DropdownMenu = require("./DropdownMenu"); +import DropdownToggle = require("./DropdownToggle"); +import Modal = require("./Modal"); +import ModalManager = require("./ModalManager"); +import Overlay = require("./Overlay"); +import Portal = require("./Portal"); +import RootCloseWrapper = require("./RootCloseWrapper"); +import WaitForContainer = require("./WaitForContainer"); export { - Affix, - AutoAffix, - Modal, - ModalManager, - Overlay, - Portal, - Position, - RootCloseWrapper, + Affix, + AutoAffix, + Dropdown, + DropdownMenu, + DropdownToggle, + Modal, + ModalManager, + Overlay, + Portal, + RootCloseWrapper, + WaitForContainer }; diff --git a/types/react-overlays/test/react-overlays-tests-individual.tsx b/types/react-overlays/test/react-overlays-tests-individual.tsx index 9201604d49..1872ebca66 100644 --- a/types/react-overlays/test/react-overlays-tests-individual.tsx +++ b/types/react-overlays/test/react-overlays-tests-individual.tsx @@ -1,66 +1,73 @@ import * as React from "react"; -import * as Portal from 'react-overlays/lib/Portal'; -import * as Modal from 'react-overlays/lib/Modal'; -import * as Position from 'react-overlays/lib/Position'; -import Overlay = require('react-overlays/lib/Overlay'); -import * as Affix from 'react-overlays/lib/Affix'; -import AutoAffix = require('react-overlays/lib/AutoAffix'); -import RootCloseWrapper = require('react-overlays/lib/RootCloseWrapper'); +import AutoAffix = require("react-overlays/lib/AutoAffix"); +import Overlay = require("react-overlays/lib/Overlay"); +import RootCloseWrapper = require("react-overlays/lib/RootCloseWrapper"); -import { OverlayFade } from './react-overlays-tests-transition'; +import { OverlayFade } from "./react-overlays-tests-transition"; class TestAffix extends React.Component { - render(): JSX.Element { - return ( -

- -
Test
-
-
- ); - } + render(): JSX.Element { + return ( +
+ +
Test
+
+
+ ); + } } interface OverlayTriggerProps extends Overlay.OverlayProps { - overlay: any; + overlay: any; } -class TestOverlay extends React.Component<{}, {open: boolean}> { - target: HTMLElement | null = null; - state = {open: false}; +function renderOverlayContent({ props }: Overlay.OverlayRenderProps) { + return
Popover content
; +} +class TestOverlay extends React.Component<{}, { open: boolean }> { + target: HTMLElement | null = null; + state = { open: false }; - render(): JSX.Element { - const { open } = this.state; + render(): JSX.Element { + const { open } = this.state; - return ( -
- + return ( +
+ - this.target} - transition={OverlayFade} - onHide={() => this.setState({open: false})} - placement="bottom"> -
Popover content
-
-
- ); - } + this.target} + transition={OverlayFade} + onHide={() => this.setState({ open: false })} + placement="bottom" + > + {renderOverlayContent} + +
+ ); + } } class TestRootCloseWrapper extends React.Component { - handleRootClose = () => { }; - render() { - return ( - -
Test
-
- ); - } + handleRootClose = () => {}; + render() { + return ( + +
Test
+
+ ); + } } diff --git a/types/react-overlays/test/react-overlays-tests-transition.tsx b/types/react-overlays/test/react-overlays-tests-transition.tsx index e1e04d7dda..f2a1769a79 100644 --- a/types/react-overlays/test/react-overlays-tests-transition.tsx +++ b/types/react-overlays/test/react-overlays-tests-transition.tsx @@ -1,12 +1,15 @@ -import * as React from 'react'; -import { CSSTransition } from 'react-transition-group'; -import { TransitionProps } from 'react-transition-group/Transition'; +import * as React from "react"; + +import { CSSTransition } from "react-transition-group"; +import { TransitionProps } from "react-transition-group/Transition"; export function OverlayFade(props: TransitionProps): JSX.Element { - return ( - - ); + return ( + + ); } diff --git a/types/react-overlays/test/react-overlays-tests.tsx b/types/react-overlays/test/react-overlays-tests.tsx index cbb2046fbc..f1465dc384 100644 --- a/types/react-overlays/test/react-overlays-tests.tsx +++ b/types/react-overlays/test/react-overlays-tests.tsx @@ -1,64 +1,69 @@ import * as React from "react"; -import { - Portal, - Modal, - Position, - Overlay, - Affix, - AutoAffix, - RootCloseWrapper, -} from "react-overlays"; +import { AutoAffix, Overlay, RootCloseWrapper } from "react-overlays"; +import { OverlayRenderProps } from "react-overlays/lib/Overlay"; -import { OverlayFade } from './react-overlays-tests-transition'; +import { OverlayFade } from "./react-overlays-tests-transition"; class TestAffix extends React.Component { - render(): JSX.Element { - return ( -
- -
Test
-
-
- ); - } + render(): JSX.Element { + return ( +
+ +
Test
+
+
+ ); + } } -class TestOverlay extends React.Component<{}, {open: boolean}> { - target: HTMLElement | null = null; - state = {open: false}; +function renderOverlayContent({ props }: OverlayRenderProps) { + return
Popover content
; +} - render(): JSX.Element { - const { open } = this.state; +class TestOverlay extends React.Component<{}, { open: boolean }> { + target: HTMLElement | null = null; + state = { open: false }; - return ( -
- + render(): JSX.Element { + const { open } = this.state; - this.target} - transition={OverlayFade} - onHide={() => this.setState({open: false})} - placement="bottom"> -
Popover content
-
-
- ); - } + return ( +
+ + + this.target} + transition={OverlayFade} + onHide={() => this.setState({ open: false })} + placement="bottom" + > + {renderOverlayContent} + +
+ ); + } } class TestRootCloseWrapper extends React.Component { - handleRootClose = () => { }; - render() { - return ( - -
Test
-
- ); - } + handleRootClose = () => {}; + render() { + return ( + +
Test
+
+ ); + } } diff --git a/types/react-overlays/tsconfig.json b/types/react-overlays/tsconfig.json index 33066cce2e..8451799969 100644 --- a/types/react-overlays/tsconfig.json +++ b/types/react-overlays/tsconfig.json @@ -1,18 +1,13 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom" - ], + "lib": ["es6", "dom"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, @@ -24,4 +19,4 @@ "test/react-overlays-tests-individual.tsx", "test/react-overlays-tests-transition.tsx" ] -} \ No newline at end of file +} diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 39d1a8d743..542894cb6f 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-redux 6.0 +// Type definitions for react-redux 7.0 // Project: https://github.com/reduxjs/react-redux // Definitions by: Qubo , // Kenzie Togami , @@ -12,6 +12,7 @@ // Johann Rakotoharisoa // Anatoli Papirovski // Boris Sergeyev +// Søren Bruus Frank // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 @@ -31,7 +32,8 @@ import { Component, ComponentClass, ComponentType, - StatelessComponent + StatelessComponent, + Context } from 'react'; import { @@ -395,6 +397,17 @@ export interface ConnectOptions { * @default false */ withRef?: boolean; + /** + * The react context to get the store from. + * + * @default ReactReduxContext + */ + context?: Context; +} + +export interface ReactReduxContextValue { + store: Store; + storeState: SS; } export interface ProviderProps { @@ -402,6 +415,12 @@ export interface ProviderProps { * The single Redux store in your application. */ store: Store; + /** + * Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used. + * If this is used, generate own connect HOC by using connectAdvanced, supplying the same context provided to the + * Provider. Initial value doesn't matter, as it is overwritten with the internal state of Provider. + */ + context?: Context; } /** @@ -410,10 +429,7 @@ export interface ProviderProps { export class Provider extends Component> { } /** - * Creates a new which will set the Redux Store on the passed key of the context. You probably only need this - * if you are in the inadvisable position of having multiple stores. You will also need to pass the same storeKey to the - * options argument of connect. - * - * @param storeKey The key of the context on which to set the store. + * Exposes the internal context used in react-redux. It is generally advised to use the connect HOC to connect to the + * redux store instead of this approeach. */ -export function createProvider(storeKey: string): typeof Provider; +export const ReactReduxContext: Context; diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index 554ace09ff..36cbe588ec 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { Store, Dispatch, AnyAction, ActionCreator, createStore, bindActionCreators, ActionCreatorsMapObject, Reducer } from 'redux'; -import { Connect, connect, createProvider, Provider, DispatchProp, MapStateToProps, Options } from 'react-redux'; +import { Connect, connect, Provider, DispatchProp, MapStateToProps, Options, ReactReduxContext, ReactReduxContextValue } from 'react-redux'; import objectAssign = require('object-assign'); // @@ -18,7 +18,7 @@ function Empty() { foo: string; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const Test = connect()(TestComponent); @@ -29,7 +29,7 @@ function MapState() { interface OwnProps { foo: string; } interface StateProps { bar: number; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapStateToProps = (_: any) => ({ bar: 1 @@ -46,7 +46,7 @@ function MapStateWithDispatchProp() { interface OwnProps { foo: string; } interface StateProps { bar: number; dispatch: Dispatch; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapStateToProps = (_: any) => ({ bar: 1 @@ -63,7 +63,7 @@ function MapStateFactory() { interface OwnProps { foo: string; } interface StateProps { bar: number; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapStateToProps = () => () => ({ bar: 1 @@ -80,10 +80,10 @@ function MapDispatch() { interface OwnProps { foo: string; } interface DispatchProps { onClick: () => void; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapDispatchToProps = () => ({ - onClick: () => {} + onClick: () => { } }); const TestNull = connect( @@ -117,8 +117,8 @@ function MapDispatchWithThunkActionCreators() { interface TestComponentProps extends OwnProps { simpleAction: typeof simpleAction; thunkAction(param1: number, param2: string): Promise; - } - class TestComponent extends React.Component {} + } + class TestComponent extends React.Component { } const mapStateToProps = ({ foo }: { foo: string }) => ({ foo }); const mapDispatchToProps = { simpleAction, thunkAction }; @@ -145,7 +145,7 @@ function MapManualDispatchThatLooksLikeThunk() { } interface TestComponentProps extends OwnProps { remove: (item: string) => () => object; - } + } class TestComponent extends React.Component { render() { return
; @@ -192,7 +192,7 @@ function MapStateAndDispatchObject() { bar: 1 }); - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const Test = connect( mapStateToProps, @@ -206,10 +206,10 @@ function MapDispatchFactory() { interface OwnProps { foo: string; } interface DispatchProps { onClick: () => void; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapDispatchToPropsFactory = () => () => ({ - onClick: () => {} + onClick: () => { } }); const TestNull = connect( @@ -232,14 +232,14 @@ function MapStateAndDispatch() { interface StateProps { bar: number; } interface DispatchProps { onClick: () => void; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapStateToProps = () => ({ bar: 1 }); const mapDispatchToProps = () => ({ - onClick: () => {} + onClick: () => { } }); const Test = connect( @@ -260,10 +260,10 @@ function MapStateFactoryAndDispatch() { }); const mapDispatchToProps = () => ({ - onClick: () => {} + onClick: () => { } }); - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const Test = connect( mapStateToPropsFactory, @@ -283,10 +283,10 @@ function MapStateFactoryAndDispatchFactory() { }); const mapDispatchToPropsFactory = () => () => ({ - onClick: () => {} + onClick: () => { } }); - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const Test = connect( mapStateToPropsFactory, @@ -301,14 +301,14 @@ function MapStateAndDispatchAndMerge() { interface StateProps { bar: number; } interface DispatchProps { onClick: () => void; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapStateToProps = () => ({ bar: 1 }); const mapDispatchToProps = () => ({ - onClick: () => {} + onClick: () => { } }); const mergeProps = (stateProps: StateProps, dispatchProps: DispatchProps) => ( @@ -330,7 +330,7 @@ function MapStateAndOptions() { interface StateProps { bar: number; } interface DispatchProps { dispatch: Dispatch; } - class TestComponent extends React.Component {} + class TestComponent extends React.Component { } const mapStateToProps = (state: State) => ({ bar: 1 @@ -444,9 +444,9 @@ ReactDOM.render(( declare var store: Store; class MyRootComponent extends React.Component { } -class TodoApp extends React.Component {} +class TodoApp extends React.Component { } interface TodoState { - todos: string[]|string; + todos: string[] | string; } interface TodoProps { userId: number; @@ -629,7 +629,7 @@ function TestTOwnPropsInference() { class OwnPropsComponent extends React.Component { render() { - return
; + return
; } } @@ -667,7 +667,7 @@ function TestTOwnPropsInference() { class AllPropsComponent extends React.Component { render() { - return
; + return
; } } @@ -701,7 +701,7 @@ function TestMergedPropsInference() { class MergedPropsComponent extends React.Component { render() { - return
; + return
; } } @@ -747,7 +747,7 @@ function Issue16652() { comments: Array<({ id: string } | undefined)>; } - class CommentList extends React.Component {} + class CommentList extends React.Component { } const mapStateToProps = (state: any, ownProps: PassedProps): GeneratedStateProps => { return { @@ -861,7 +861,7 @@ function TestInferredFunctionalComponentWithExplicitOwnProps() { const Header = connect( ( - { app: { title }}: { app: { title: string }}, + { app: { title } }: { app: { title: string } }, { extraText }: { extraText: string } ) => ({ title, @@ -873,7 +873,7 @@ function TestInferredFunctionalComponentWithExplicitOwnProps() { )(({ title, extraText, onClick }: Props) => { return

{title} {extraText}

; }); -
; +
; } function TestInferredFunctionalComponentWithImplicitOwnProps() { @@ -885,7 +885,7 @@ function TestInferredFunctionalComponentWithImplicitOwnProps() { const Header = connect( ( - { app: { title }}: { app: { title: string }}, + { app: { title } }: { app: { title: string } }, ) => ({ title, }), @@ -895,7 +895,7 @@ function TestInferredFunctionalComponentWithImplicitOwnProps() { )(({ title, extraText, onClick }: Props) => { return

{title} {extraText}

; }); -
; +
; } function TestWrappedComponent() { @@ -920,50 +920,6 @@ function TestWrappedComponent() { const TestConnected = (props: any) => ; } -function TestCreateProvider() { - const STORE_KEY = 'myStore'; - - const MyStoreProvider = createProvider(STORE_KEY); - - const myStoreConnect: Connect = ( - mapStateToProps?: any, - mapDispatchToProps?: any, - mergeProps?: any, - options: Options = {}, - ) => { - options.storeKey = STORE_KEY; - return connect( - mapStateToProps, - mapDispatchToProps, - mergeProps, - options, - ); - }; - - interface State { a: number; } - const store = createStore(() => ({ a: 1 })); - const myStore = createStore(() => ({ a: 2 })); - - interface AProps { a: number; } - const A = (props: AProps) => (

A is {props.a}

); - const A1 = connect(state => state)(A); - const A2 = myStoreConnect(state => state)(A); - - const Combined = () => ( - - - - - - - ); - - // This renders: - //

A is 1

- //

A is 2

- ReactDOM.render(, document.body); -} - function TestWithoutTOwnPropsDecoratedInference() { interface ForwardedProps { forwarded: string; @@ -1082,7 +1038,7 @@ function TestOptionalPropsMergedCorrectly() { function mapDispatchToProps(dispatch: any): MapDispatchProps { return { - dependsOnDispatch: () => {} + dependsOnDispatch: () => { } }; } @@ -1126,7 +1082,7 @@ function TestMoreGeneralDecorationProps() { function mapDispatchToProps(dispatch: any): MapDispatchProps { return { - dependsOnDispatch: () => {} + dependsOnDispatch: () => { } }; } @@ -1165,7 +1121,7 @@ function TestFailsMoreSpecificInjectedProps() { function mapDispatchToProps(dispatch: any): MapDispatchProps { return { - dependsOnDispatch: () => {} + dependsOnDispatch: () => { } }; } @@ -1205,8 +1161,34 @@ function TestLibraryManagedAttributes() { } const ConnectedComponent = connect(mapStateToProps)(Component); - {}} />; + { }} />; const ConnectedComponent2 = connect(mapStateToProps)(Component); - {}} />; + { }} />; +} + +function TestProviderContext() { + const store: Store = createStore((state = {}) => state); + const nullContext = React.createContext(null); + + // To ensure type safety when consuming the context in an app, a null-context does not suffice. + ; // $ExpectError + + // Providing a an object of the correct type ensures type safety when consuming the context. + const initialContextValue: ReactReduxContextValue = { storeState: null, store }; + const context = React.createContext(initialContextValue); + + ; + + // react-redux exports a default context used internally if none is supplied, used as shown below. + class ComponentWithDefaultContext extends React.Component { + static contextType = ReactReduxContext; + } + + + + ; + + // Null is not a valid value for the context. + ; // $ExpectError } diff --git a/types/react-redux/v6/index.d.ts b/types/react-redux/v6/index.d.ts new file mode 100644 index 0000000000..bcbcced0bd --- /dev/null +++ b/types/react-redux/v6/index.d.ts @@ -0,0 +1,412 @@ +// Type definitions for react-redux 6.0 +// Project: https://github.com/reduxjs/react-redux +// Definitions by: Qubo , +// Kenzie Togami , +// Curits Layne +// Frank Tan +// Nicholas Boll +// Dibyo Majumdar +// Prashant Deva +// Thomas Charlat +// Valentin Descamps +// Johann Rakotoharisoa +// Anatoli Papirovski +// Boris Sergeyev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +// Known Issue: +// There is a known issue in TypeScript, which doesn't allow decorators to change the signature of the classes +// they are decorating. Due to this, if you are using @connect() decorator in your code, +// you will see a bunch of errors from TypeScript. The current workaround is to use connect() as a function call on +// a separate line instead of as a decorator. Discussed in this github issue: +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20796 + +// NOTE about the wrong react-redux version in the header comment: +// The actual react-redux version is not 6.0.0, but we had to increase the major version +// to update this type definitions for redux@4.x from redux@3.x. +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/25321 + +import { + Component, + ComponentClass, + ComponentType, + StatelessComponent +} from 'react'; + +import { + Action, + ActionCreator, + AnyAction, + Dispatch, + Store +} from 'redux'; + +// Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html +export type Omit = Pick>; + +export interface DispatchProp { + dispatch: Dispatch; +} + +export type AdvancedComponentDecorator = + (component: ComponentType) => ComponentClass; + +/** + * A property P will be present if: + * - it is present in DecorationTargetProps + * + * Its value will be dependent on the following conditions + * - if property P is present in InjectedProps and its definition extends the definition + * in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P] + * - if property P is not present in InjectedProps then its definition will be that of + * DecorationTargetProps[P] + * - if property P is present in InjectedProps but does not extend the + * DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P] + */ +export type Matching = { + [P in keyof DecorationTargetProps]: P extends keyof InjectedProps + ? InjectedProps[P] extends DecorationTargetProps[P] + ? DecorationTargetProps[P] + : InjectedProps[P] + : DecorationTargetProps[P]; +}; + +/** + * a property P will be present if : + * - it is present in both DecorationTargetProps and InjectedProps + * - InjectedProps[P] can satisfy DecorationTargetProps[P] + * ie: decorated component can accept more types than decorator is injecting + * + * For decoration, inject props or ownProps are all optionally + * required by the decorated (right hand side) component. + * But any property required by the decorated component must be satisfied by the injected property. + */ +export type Shared< + InjectedProps, + DecorationTargetProps extends Shared + > = { + [P in Extract]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; + }; + +// Infers prop type from component C +export type GetProps = C extends ComponentType ? P : never; + +// Applies LibraryManagedAttributes (proper handling of defaultProps +// and propTypes), as well as defines WrappedComponent. +export type ConnectedComponentClass = ComponentClass> & { + WrappedComponent: C; +}; + +// Injects props and removes them from the prop requirements. +// Will not pass through the injected props if they are passed in during +// render. Also adds new prop requirements from TNeedsProps. +export type InferableComponentEnhancerWithProps = + >>>( + component: C + ) => ConnectedComponentClass, keyof Shared>> & TNeedsProps>; + +// Injects props and removes them from the prop requirements. +// Will not pass through the injected props if they are passed in during +// render. +export type InferableComponentEnhancer = + InferableComponentEnhancerWithProps; + +export type InferThunkActionCreatorType any> = + TActionCreator extends (...args: infer TParams) => (...args: any[]) => infer TReturn + ? (...args: TParams) => TReturn + : TActionCreator; + +export type HandleThunkActionCreator = + TActionCreator extends (...args: any[]) => any + ? InferThunkActionCreatorType + : TActionCreator; + +// redux-thunk middleware returns thunk's return value from dispatch call +// https://github.com/reduxjs/redux-thunk#composition +export type ResolveThunks = + TDispatchProps extends { [key: string]: any } + ? { + [C in keyof TDispatchProps]: HandleThunkActionCreator + } + : TDispatchProps; + +/** + * Connects a React component to a Redux store. + * + * - Without arguments, just wraps the component, without changing the behavior / props + * + * - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior + * is to override ownProps (as stated in the docs), so what remains is everything that's + * not a state or dispatch prop + * + * - When 3rd param is passed, we don't know if ownProps propagate and whether they + * should be valid component props, because it depends on mergeProps implementation. + * As such, it is the user's responsibility to extend ownProps interface from state or + * dispatch props or both when applicable + * + * @param mapStateToProps + * @param mapDispatchToProps + * @param mergeProps + * @param options + */ +export interface Connect { + // tslint:disable:no-unnecessary-generics + (): InferableComponentEnhancer; + + ( + mapStateToProps: MapStateToPropsParam + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: null | undefined, + mapDispatchToProps: MapDispatchToPropsNonObject + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: null | undefined, + mapDispatchToProps: TDispatchProps, + ): InferableComponentEnhancerWithProps< + ResolveThunks, + TOwnProps + >; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: MapDispatchToPropsNonObject + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: TDispatchProps, + ): InferableComponentEnhancerWithProps< + TStateProps & ResolveThunks, + TOwnProps + >; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: null | undefined, + mergeProps: MergeProps, + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: null | undefined, + mapDispatchToProps: MapDispatchToPropsParam, + mergeProps: MergeProps, + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: null | undefined, + mapDispatchToProps: null | undefined, + mergeProps: MergeProps, + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: MapDispatchToPropsParam, + mergeProps: MergeProps, + options?: Options + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: null | undefined, + mergeProps: null | undefined, + options: Options + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: null | undefined, + mapDispatchToProps: MapDispatchToPropsNonObject, + mergeProps: null | undefined, + options: Options<{}, TStateProps, TOwnProps> + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: null | undefined, + mapDispatchToProps: TDispatchProps, + mergeProps: null | undefined, + options: Options<{}, TStateProps, TOwnProps> + ): InferableComponentEnhancerWithProps< + ResolveThunks, + TOwnProps + >; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: MapDispatchToPropsNonObject, + mergeProps: null | undefined, + options: Options + ): InferableComponentEnhancerWithProps; + + ( + mapStateToProps: MapStateToPropsParam, + mapDispatchToProps: TDispatchProps, + mergeProps: null | undefined, + options: Options + ): InferableComponentEnhancerWithProps< + TStateProps & ResolveThunks, + TOwnProps + >; + // tslint:enable:no-unnecessary-generics +} + +/** + * The connect function. See {@type Connect} for details. + */ +export const connect: Connect; + +export type MapStateToProps = + (state: State, ownProps: TOwnProps) => TStateProps; + +export type MapStateToPropsFactory = + (initialState: State, ownProps: TOwnProps) => MapStateToProps; + +export type MapStateToPropsParam = MapStateToPropsFactory | MapStateToProps | null | undefined; + +export type MapDispatchToPropsFunction = + (dispatch: Dispatch, ownProps: TOwnProps) => TDispatchProps; + +export type MapDispatchToProps = + MapDispatchToPropsFunction | TDispatchProps; + +export type MapDispatchToPropsFactory = + (dispatch: Dispatch, ownProps: TOwnProps) => MapDispatchToPropsFunction; + +export type MapDispatchToPropsParam = MapDispatchToPropsFactory | MapDispatchToProps; + +export type MapDispatchToPropsNonObject = MapDispatchToPropsFactory | MapDispatchToPropsFunction; + +export type MergeProps = + (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps) => TMergedProps; + +export interface Options extends ConnectOptions { + /** + * If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps, + * preventing unnecessary updates, assuming that the component is a “pure” component + * and does not rely on any input or state other than its props and the selected Redux store’s state. + * Defaults to true. + * @default true + */ + pure?: boolean; + + /** + * When pure, compares incoming store state to its previous value. + * @default strictEqual + */ + areStatesEqual?: (nextState: State, prevState: State) => boolean; + + /** + * When pure, compares incoming props to its previous value. + * @default shallowEqual + */ + areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean; + + /** + * When pure, compares the result of mapStateToProps to its previous value. + * @default shallowEqual + */ + areStatePropsEqual?: (nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean; + + /** + * When pure, compares the result of mergeProps to its previous value. + * @default shallowEqual + */ + areMergedPropsEqual?: (nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean; +} + +/** + * Connects a React component to a Redux store. It is the base for {@link connect} but is less opinionated about + * how to combine state, props, and dispatch into your final props. It makes no + * assumptions about defaults or memoization of results, leaving those responsibilities to the caller.It does not + * modify the component class passed to it; instead, it returns a new, connected component class for you to use. + * + * @param selectorFactory The selector factory. See SelectorFactory type for details. + * @param connectOptions If specified, further customizes the behavior of the connector. Additionally, any extra + * options will be passed through to your selectorFactory in the factoryOptions argument. + */ +export function connectAdvanced( + // tslint:disable-next-line no-unnecessary-generics + selectorFactory: SelectorFactory, + connectOptions?: ConnectOptions & TFactoryOptions +): AdvancedComponentDecorator; + +/** + * Initializes a selector function (during each instance's constructor). That selector function is called any time the + * connector component needs to compute new props, as a result of a store state change or receiving new props. The + * result of selector is expected to be a plain object, which is passed as the props to the wrapped + * component. If a consecutive call to selector returns the same object (===) as its previous + * call, the component will not be re-rendered. It's the responsibility of selector to return that + * previous object when appropriate. + */ +export type SelectorFactory = + (dispatch: Dispatch, factoryOptions: TFactoryOptions) => Selector; + +export type Selector = (state: S, ownProps: TOwnProps) => TProps; + +export interface ConnectOptions { + /** + * Computes the connector component's displayName property relative to that of the wrapped component. Usually + * overridden by wrapper functions. + * + * @default name => 'ConnectAdvanced('+name+')' + * @param componentName + */ + getDisplayName?: (componentName: string) => string; + /** + * Shown in error messages. Usually overridden by wrapper functions. + * + * @default 'connectAdvanced' + */ + methodName?: string; + /** + * If defined, a property named this value will be added to the props passed to the wrapped component. Its value + * will be the number of times the component has been rendered, which can be useful for tracking down unnecessary + * re-renders. + * + * @default undefined + */ + renderCountProp?: string; + /** + * Controls whether the connector component subscribes to redux store state changes. If set to false, it will only + * re-render on componentWillReceiveProps. + * + * @default true + */ + shouldHandleStateChanges?: boolean; + /** + * The key of props/context to get the store. You probably only need this if you are in the inadvisable position of + * having multiple stores. + * + * @default 'store' + */ + storeKey?: string; + /** + * If true, stores a ref to the wrapped component instance and makes it available via getWrappedInstance() method. + * + * @default false + */ + withRef?: boolean; +} + +export interface ProviderProps { + /** + * The single Redux store in your application. + */ + store: Store; +} + +/** + * Makes the Redux store available to the connect() calls in the component hierarchy below. + */ +export class Provider extends Component> { } + +/** + * Creates a new which will set the Redux Store on the passed key of the context. You probably only need this + * if you are in the inadvisable position of having multiple stores. You will also need to pass the same storeKey to the + * options argument of connect. + * + * @param storeKey The key of the context on which to set the store. + */ +export function createProvider(storeKey: string): typeof Provider; diff --git a/types/react-redux/v6/package.json b/types/react-redux/v6/package.json new file mode 100644 index 0000000000..7f5b19d45b --- /dev/null +++ b/types/react-redux/v6/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "redux": "^4.0.0" + } +} diff --git a/types/react-redux/v6/react-redux-tests.tsx b/types/react-redux/v6/react-redux-tests.tsx new file mode 100644 index 0000000000..554ace09ff --- /dev/null +++ b/types/react-redux/v6/react-redux-tests.tsx @@ -0,0 +1,1212 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import { Store, Dispatch, AnyAction, ActionCreator, createStore, bindActionCreators, ActionCreatorsMapObject, Reducer } from 'redux'; +import { Connect, connect, createProvider, Provider, DispatchProp, MapStateToProps, Options } from 'react-redux'; +import objectAssign = require('object-assign'); + +// +// Quick Start +// https://github.com/rackt/react-redux/blob/master/docs/quick-start.md#quick-start +// + +// Test cases written in a way to isolate types and variables and verify the +// output of `connect` to make sure the signature is what is expected + +function Empty() { + interface OwnProps { + dispatch: Dispatch; + foo: string; + } + + class TestComponent extends React.Component {} + + const Test = connect()(TestComponent); + + const verify = ; +} + +function MapState() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + + class TestComponent extends React.Component {} + + const mapStateToProps = (_: any) => ({ + bar: 1 + }); + + const Test = connect( + mapStateToProps + )(TestComponent); + + const verify = ; +} + +function MapStateWithDispatchProp() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; dispatch: Dispatch; } + + class TestComponent extends React.Component {} + + const mapStateToProps = (_: any) => ({ + bar: 1 + }); + + const Test = connect( + mapStateToProps + )(TestComponent); + + const verify = ; +} + +function MapStateFactory() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + + class TestComponent extends React.Component {} + + const mapStateToProps = () => () => ({ + bar: 1 + }); + + const Test = connect( + mapStateToProps + )(TestComponent); + + const verify = ; +} + +function MapDispatch() { + interface OwnProps { foo: string; } + interface DispatchProps { onClick: () => void; } + + class TestComponent extends React.Component {} + + const mapDispatchToProps = () => ({ + onClick: () => {} + }); + + const TestNull = connect( + null, + mapDispatchToProps, + )(TestComponent); + + const verifyNull = ; + + const TestUndefined = connect( + undefined, + mapDispatchToProps, + )(TestComponent); + + const verifyUndefined = ; +} + +function MapDispatchWithThunkActionCreators() { + const simpleAction = (payload: boolean) => ({ + type: 'SIMPLE_ACTION', + payload, + }); + const thunkAction = (param1: number, param2: string) => ( + async (dispatch: Dispatch, { foo }: OwnProps) => { + return foo; + } + ); + interface OwnProps { + foo: string; + } + interface TestComponentProps extends OwnProps { + simpleAction: typeof simpleAction; + thunkAction(param1: number, param2: string): Promise; + } + class TestComponent extends React.Component {} + + const mapStateToProps = ({ foo }: { foo: string }) => ({ foo }); + const mapDispatchToProps = { simpleAction, thunkAction }; + + const Test1 = connect(null, mapDispatchToProps)(TestComponent); + const Test2 = connect(mapStateToProps, mapDispatchToProps)(TestComponent); + const Test3 = connect( + null, mapDispatchToProps, null, { storeKey: 'somekey' } + )(TestComponent); + const Test4 = connect( + mapStateToProps, mapDispatchToProps, null, { storeKey: 'somekey' } + )(TestComponent); + const verify =
+ ; + + ; + +
; +} + +function MapManualDispatchThatLooksLikeThunk() { + interface OwnProps { + foo: string; + } + interface TestComponentProps extends OwnProps { + remove: (item: string) => () => object; + } + class TestComponent extends React.Component { + render() { + return
; + } + } + + const mapStateToProps = ({ foo }: { foo: string }) => ({ foo }); + function mapDispatchToProps(dispatch: Dispatch) { + return { + remove(item: string) { + return () => dispatch({ type: 'REMOVE_ITEM', item }); + } + }; + } + + const Test1 = connect(null, mapDispatchToProps)(TestComponent); + const Test2 = connect(mapStateToProps, mapDispatchToProps)(TestComponent); + const Test3 = connect( + null, mapDispatchToProps, null, { storeKey: 'somekey' } + )(TestComponent); + const Test4 = connect( + mapStateToProps, mapDispatchToProps, null, { storeKey: 'somekey' } + )(TestComponent); + const verify =
+ ; + + ; + +
; +} + +function MapStateAndDispatchObject() { + interface ClickPayload { count: number; } + const onClick: ActionCreator = () => ({ count: 1 }); + const dispatchToProps = { + onClick, + }; + + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + interface DispatchProps { onClick: ActionCreator; } + + const mapStateToProps = (_: any, __: OwnProps): StateProps => ({ + bar: 1 + }); + + class TestComponent extends React.Component {} + + const Test = connect( + mapStateToProps, + dispatchToProps, + )(TestComponent); + + const verify = ; +} + +function MapDispatchFactory() { + interface OwnProps { foo: string; } + interface DispatchProps { onClick: () => void; } + + class TestComponent extends React.Component {} + + const mapDispatchToPropsFactory = () => () => ({ + onClick: () => {} + }); + + const TestNull = connect( + null, + mapDispatchToPropsFactory, + )(TestComponent); + + const verifyNull = ; + + const TestUndefined = connect( + undefined, + mapDispatchToPropsFactory, + )(TestComponent); + + const verifyUndefined = ; +} + +function MapStateAndDispatch() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + interface DispatchProps { onClick: () => void; } + + class TestComponent extends React.Component {} + + const mapStateToProps = () => ({ + bar: 1 + }); + + const mapDispatchToProps = () => ({ + onClick: () => {} + }); + + const Test = connect( + mapStateToProps, + mapDispatchToProps, + )(TestComponent); + + const verify = ; +} + +function MapStateFactoryAndDispatch() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + interface DispatchProps { onClick: () => void; } + + const mapStateToPropsFactory = () => () => ({ + bar: 1 + }); + + const mapDispatchToProps = () => ({ + onClick: () => {} + }); + + class TestComponent extends React.Component {} + + const Test = connect( + mapStateToPropsFactory, + mapDispatchToProps, + )(TestComponent); + + const verify = ; +} + +function MapStateFactoryAndDispatchFactory() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + interface DispatchProps { onClick: () => void; } + + const mapStateToPropsFactory = () => () => ({ + bar: 1 + }); + + const mapDispatchToPropsFactory = () => () => ({ + onClick: () => {} + }); + + class TestComponent extends React.Component {} + + const Test = connect( + mapStateToPropsFactory, + mapDispatchToPropsFactory, + )(TestComponent); + + const verify = ; +} + +function MapStateAndDispatchAndMerge() { + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + interface DispatchProps { onClick: () => void; } + + class TestComponent extends React.Component {} + + const mapStateToProps = () => ({ + bar: 1 + }); + + const mapDispatchToProps = () => ({ + onClick: () => {} + }); + + const mergeProps = (stateProps: StateProps, dispatchProps: DispatchProps) => ( + { ...stateProps, ...dispatchProps } + ); + + const Test = connect( + mapStateToProps, + mapDispatchToProps, + mergeProps, + )(TestComponent); + + const verify = ; +} + +function MapStateAndOptions() { + interface State { state: string; } + interface OwnProps { foo: string; } + interface StateProps { bar: number; } + interface DispatchProps { dispatch: Dispatch; } + + class TestComponent extends React.Component {} + + const mapStateToProps = (state: State) => ({ + bar: 1 + }); + + const areStatePropsEqual = (next: StateProps, current: StateProps) => true; + + const Test = connect( + mapStateToProps, + null, + null, + { + pure: true, + areStatePropsEqual, + } + )(TestComponent); + + const verify = ; +} + +interface CounterState { + counter: number; +} +declare var increment: () => { type: string }; + +class Counter extends React.Component { + render() { + return ( + + ); + } +} + +function mapStateToProps(state: CounterState) { + return { + value: state.counter + }; +} + +// Which action creators does it want to receive by props? +function mapDispatchToProps(dispatch: Dispatch) { + return { + onIncrement: () => dispatch(increment()) + }; +} + +connect( + mapStateToProps, + mapDispatchToProps +)(Counter); + +@connect(mapStateToProps) +class CounterContainer extends React.Component { +} + +// Ensure connect's first two arguments can be replaced by wrapper functions +interface CounterStateProps { + value: number; +} +interface CounterDispatchProps { + onIncrement: () => void; +} +// with higher order functions +connect( + () => mapStateToProps, + () => mapDispatchToProps +)(Counter); +// with higher order functions using parameters +connect( + (initialState: CounterState, ownProps) => mapStateToProps, + (dispatch: Dispatch, ownProps) => mapDispatchToProps +)(Counter); +// only first argument +connect( + () => mapStateToProps +)(Counter); +// wrap only one argument +connect( + mapStateToProps, + () => mapDispatchToProps +)(Counter); +// with extra arguments +connect( + () => mapStateToProps, + () => mapDispatchToProps, + (s: CounterStateProps, d: CounterDispatchProps) => + objectAssign({}, s, d), + { pure: true } +)(Counter); + +class App extends React.Component { + render() { + return null; + } +} + +const targetEl = document.getElementById('root'); + +ReactDOM.render(( + + {() => } + +), targetEl); + +// +// API +// https://github.com/rackt/react-redux/blob/master/docs/api.md +// +declare var store: Store; +class MyRootComponent extends React.Component { +} +class TodoApp extends React.Component {} +interface TodoState { + todos: string[]|string; +} +interface TodoProps { + userId: number; +} +interface DispatchProps { + addTodo(userId: number, text: string): void; + action: () => any; +} +declare var actionCreators: () => { + action: () => any; +}; +declare var dispatchActionCreators: () => DispatchProps; +declare var addTodo: () => { type: string; }; +declare var todoActionCreators: { [type: string]: (...args: any[]) => any; }; +declare var counterActionCreators: { [type: string]: (...args: any[]) => any; }; + +ReactDOM.render( + + {() => } + , + document.body +); + +// Inject just dispatch and don't listen to store + +const AppWrap = (props: DispatchProp & { children?: React.ReactNode }) =>
; +const WrappedApp = connect()(AppWrap); + +; + +// Inject dispatch and every field in the global state + +connect((state: TodoState) => state)(TodoApp); + +// Inject dispatch and todos + +function mapStateToProps2(state: TodoState) { + return { todos: state.todos }; +} + +export default connect(mapStateToProps2)(TodoApp); + +connect(mapStateToProps2, actionCreators)(TodoApp); + +function mapDispatchToProps2(dispatch: Dispatch) { + return { actions: bindActionCreators(actionCreators, dispatch) }; +} + +connect(mapStateToProps2, mapDispatchToProps2)(TodoApp); + +// Inject todos and a specific action creator (addTodo) + +function mapDispatchToProps3(dispatch: Dispatch) { + return bindActionCreators({ addTodo }, dispatch); +} + +connect(mapStateToProps2, mapDispatchToProps3)(TodoApp); + +// Inject todos, todoActionCreators as todoActions, and counterActionCreators as counterActions + +function mapDispatchToProps4(dispatch: Dispatch) { + return { + todoActions: bindActionCreators(todoActionCreators, dispatch), + counterActions: bindActionCreators(counterActionCreators, dispatch) + }; +} + +connect(mapStateToProps2, mapDispatchToProps4)(TodoApp); + +// Inject todos, and todoActionCreators and counterActionCreators together as actions + +function mapDispatchToProps5(dispatch: Dispatch) { + return { + actions: bindActionCreators(objectAssign({}, todoActionCreators, counterActionCreators), dispatch) + }; +} + +connect(mapStateToProps2, mapDispatchToProps5)(TodoApp); + +// Inject todos, and all todoActionCreators and counterActionCreators directly as props + +function mapDispatchToProps6(dispatch: Dispatch) { + return bindActionCreators(objectAssign({}, todoActionCreators, counterActionCreators), dispatch); +} + +connect(mapStateToProps2, mapDispatchToProps6)(TodoApp); + +// Inject todos of a specific user depending on props + +function mapStateToProps3(state: TodoState, ownProps: TodoProps): TodoState { + return { todos: state.todos[ownProps.userId] }; +} + +connect(mapStateToProps3)(TodoApp); + +// Inject todos of a specific user depending on props, and inject props.userId into the action + +function mergeProps(stateProps: TodoState, dispatchProps: DispatchProps, ownProps: TodoProps): DispatchProps & TodoState & TodoProps { + return objectAssign({}, ownProps, dispatchProps, { + todos: stateProps.todos[ownProps.userId], + addTodo: (text: string) => dispatchProps.addTodo(ownProps.userId, text) + }); +} + +connect(mapStateToProps2, dispatchActionCreators, mergeProps)(MyRootComponent); + +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14622#issuecomment-279820358 +// Allow for undefined mapStateToProps +connect(undefined, mapDispatchToProps6)(TodoApp); + +interface TestProp { + property1: number; + someOtherProperty?: string; +} +interface TestState { + isLoaded: boolean; + state1: number; +} +class TestComponent extends React.Component { } +const WrappedTestComponent = connect()(TestComponent); + +// return value of the connect()(TestComponent) is assignable to a ComponentClass +// ie: DispatchProp has been removed through decoration +const ADecoratedTestComponent: React.ComponentClass = WrappedTestComponent; +; + +const ATestComponent: React.ComponentClass = TestComponent; // $ExpectError + +// stateless functions +interface HelloMessageProps { + dispatch: Dispatch; + name: string; +} +const HelloMessage: React.StatelessComponent = (props) => { + return
Hello {props.name}
; +}; +const ConnectedHelloMessage = connect()(HelloMessage); +ReactDOM.render(, document.getElementById('content')); + +// stateless functions that uses mapStateToProps and mapDispatchToProps +function TestStatelessFunctionWithMapArguments() { + interface GreetingProps { + name: string; + onClick: () => void; + } + + function Greeting(props: GreetingProps) { + return
Hello {props.name}
; + } + + const mapStateToProps = (state: any, ownProps: GreetingProps) => { + return { + name: 'Connected! ' + ownProps.name + }; + }; + + const mapDispatchToProps = (dispatch: Dispatch, ownProps: GreetingProps) => { + return { + onClick: () => { + dispatch({ type: 'GREETING', name: ownProps.name }); + } + }; + }; + + const ConnectedGreeting = connect( + mapStateToProps, + mapDispatchToProps + )(Greeting); +} + +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/8787 +function TestTOwnPropsInference() { + interface OwnProps { + own: string; + } + + interface StateProps { + state: string; + } + + class OwnPropsComponent extends React.Component { + render() { + return
; + } + } + + function mapStateToPropsWithoutOwnProps(state: any): StateProps { + return { state: 'string' }; + } + + function mapStateToPropsWithOwnProps(state: any, ownProps: OwnProps): StateProps { + return { state: 'string' }; + } + + const ConnectedWithoutOwnProps = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); + const ConnectedWithOwnProps = connect(mapStateToPropsWithOwnProps)(OwnPropsComponent); + const ConnectedWithTypeHint = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); + + // This should not compile, which is good. + // React.createElement(ConnectedWithoutOwnProps, { anything: 'goes!' }); + + // This compiles, as expected. + React.createElement(ConnectedWithOwnProps, { own: 'string' }); + + // This should not compile, which is good. + // React.createElement(ConnectedWithOwnProps, { anything: 'goes!' }); + + // This compiles, as expected. + React.createElement(ConnectedWithTypeHint, { own: 'string' }); + + // This should not compile, which is good. + // React.createElement(ConnectedWithTypeHint, { anything: 'goes!' }); + + interface AllProps { + own: string; + state: string; + } + + class AllPropsComponent extends React.Component { + render() { + return
; + } + } + + type PickedOwnProps = Pick; + type PickedStateProps = Pick; + + const mapStateToPropsForPicked: MapStateToProps = (state: any): PickedStateProps => { + return { state: "string" }; + }; + const ConnectedWithPickedOwnProps = connect(mapStateToPropsForPicked)(AllPropsComponent); + ; +} + +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/16021 +function TestMergedPropsInference() { + interface StateProps { + state: string; + } + + interface DispatchProps { + dispatch: string; + } + + interface OwnProps { + own: string; + } + + interface MergedProps { + merged: string; + } + + class MergedPropsComponent extends React.Component { + render() { + return
; + } + } + + function mapStateToProps(state: any): StateProps { + return { state: 'string' }; + } + + function mapDispatchToProps(dispatch: Dispatch): DispatchProps { + return { dispatch: 'string' }; + } + + const ConnectedWithOwnAndState: React.ComponentClass = connect( + mapStateToProps, + undefined, + (stateProps: StateProps) => ({ + merged: "merged", + }), + )(MergedPropsComponent); + + const ConnectedWithOwnAndDispatch: React.ComponentClass = connect( + undefined, + mapDispatchToProps, + (stateProps: undefined, dispatchProps: DispatchProps) => ({ + merged: "merged", + }), + )(MergedPropsComponent); + + const ConnectedWithOwn: React.ComponentClass = connect( + undefined, + undefined, + () => ({ + merged: "merged", + }), + )(MergedPropsComponent); +} + +function Issue16652() { + interface PassedProps { + commentIds: string[]; + } + + interface GeneratedStateProps { + comments: Array<({ id: string } | undefined)>; + } + + class CommentList extends React.Component {} + + const mapStateToProps = (state: any, ownProps: PassedProps): GeneratedStateProps => { + return { + comments: ownProps.commentIds.map(id => ({ id })), + }; + }; + + const ConnectedCommentList = connect(mapStateToProps)( + CommentList + ); + + ; +} + +function Issue15463() { + interface SpinnerProps { + showGlobalSpinner: boolean; + } + + class SpinnerClass extends React.Component { + render() { + return (
); + } + } + + const Spinner = connect((state: any) => { + return { showGlobalSpinner: true }; + })(SpinnerClass); + + ; +} + +function RemoveInjectedAndPassOnRest() { + interface TProps { + showGlobalSpinner: boolean; + foo: string; + } + class SpinnerClass extends React.Component { + render() { + return (
); + } + } + + const Spinner = connect((state: any) => { + return { showGlobalSpinner: true }; + })(SpinnerClass); + + ; +} + +function TestControlledComponentWithoutDispatchProp() { + interface MyState { + count: number; + } + + interface MyProps { + label: string; + // `dispatch` is optional, but setting it to anything + // other than Dispatch will cause an error + // + // dispatch: Dispatch; // OK + // dispatch: number; // ERROR + } + + function mapStateToProps(state: MyState) { + return { + label: `The count is ${state.count}`, + }; + } + + class MyComponent extends React.Component { + render() { + return {this.props.label}; + } + } + + const MyFuncComponent = (props: MyProps) => ( + {props.label} + ); + + const MyControlledComponent = connect(mapStateToProps)(MyComponent); + const MyControlledFuncComponent = connect(mapStateToProps)(MyFuncComponent); +} + +function TestDispatchToPropsAsObject() { + const onClick: ActionCreator<{}> = () => ({}); + const mapStateToProps = (state: any) => { + return { + title: state.app.title as string, + }; + }; + const dispatchToProps = { + onClick, + }; + + type Props = { title: string; } & typeof dispatchToProps; + const HeaderComponent: React.StatelessComponent = (props) => { + return

{props.title}

; + }; + + const Header = connect(mapStateToProps, dispatchToProps)(HeaderComponent); +
; +} + +function TestInferredFunctionalComponentWithExplicitOwnProps() { + interface Props { + title: string; + extraText: string; + onClick: () => void; + } + + const Header = connect( + ( + { app: { title }}: { app: { title: string }}, + { extraText }: { extraText: string } + ) => ({ + title, + extraText + }), + (dispatch) => ({ + onClick: () => dispatch({ type: 'test' }) + }) + )(({ title, extraText, onClick }: Props) => { + return

{title} {extraText}

; + }); +
; +} + +function TestInferredFunctionalComponentWithImplicitOwnProps() { + interface Props { + title: string; + extraText: string; + onClick: () => void; + } + + const Header = connect( + ( + { app: { title }}: { app: { title: string }}, + ) => ({ + title, + }), + (dispatch) => ({ + onClick: () => dispatch({ type: 'test' }) + }) + )(({ title, extraText, onClick }: Props) => { + return

{title} {extraText}

; + }); +
; +} + +function TestWrappedComponent() { + interface InnerProps { + name: string; + } + const Inner: React.StatelessComponent = (props) => { + return

{props.name}

; + }; + + const mapStateToProps = (state: any) => { + return { + name: "Connected", + }; + }; + const Connected = connect(mapStateToProps)(Inner); + + // `Inner` and `Connected.WrappedComponent` require explicit `name` prop + const TestInner = (props: any) => ; + const TestWrapped = (props: any) => ; + // `Connected` does not require explicit `name` prop + const TestConnected = (props: any) => ; +} + +function TestCreateProvider() { + const STORE_KEY = 'myStore'; + + const MyStoreProvider = createProvider(STORE_KEY); + + const myStoreConnect: Connect = ( + mapStateToProps?: any, + mapDispatchToProps?: any, + mergeProps?: any, + options: Options = {}, + ) => { + options.storeKey = STORE_KEY; + return connect( + mapStateToProps, + mapDispatchToProps, + mergeProps, + options, + ); + }; + + interface State { a: number; } + const store = createStore(() => ({ a: 1 })); + const myStore = createStore(() => ({ a: 2 })); + + interface AProps { a: number; } + const A = (props: AProps) => (

A is {props.a}

); + const A1 = connect(state => state)(A); + const A2 = myStoreConnect(state => state)(A); + + const Combined = () => ( + + + + + + + ); + + // This renders: + //

A is 1

+ //

A is 2

+ ReactDOM.render(, document.body); +} + +function TestWithoutTOwnPropsDecoratedInference() { + interface ForwardedProps { + forwarded: string; + } + + interface OwnProps { + own: string; + } + + interface StateProps { + state: string; + } + + class WithoutOwnPropsComponentClass extends React.Component> { + render() { + return
; + } + } + + const WithoutOwnPropsComponentStateless: React.StatelessComponent> = () => (
); + + function mapStateToProps4(state: any, ownProps: OwnProps): StateProps { + return { state: 'string' }; + } + + // these decorations should compile, it is perfectly acceptable to receive props and ignore them + const ConnectedWithOwnPropsClass = connect(mapStateToProps4)(WithoutOwnPropsComponentClass); + const ConnectedWithOwnPropsStateless = connect(mapStateToProps4)(WithoutOwnPropsComponentStateless); + const ConnectedWithTypeHintClass = connect(mapStateToProps4)(WithoutOwnPropsComponentClass); + const ConnectedWithTypeHintStateless = connect(mapStateToProps4)(WithoutOwnPropsComponentStateless); + + // This should compile + React.createElement(ConnectedWithOwnPropsClass, { own: 'string', forwarded: 'string' }); + React.createElement(ConnectedWithOwnPropsClass, { own: 'string', forwarded: 'string' }); + + // This should not compile, it is missing ForwardedProps + React.createElement(ConnectedWithOwnPropsClass, { own: 'string' }); // $ExpectError + React.createElement(ConnectedWithOwnPropsStateless, { own: 'string' }); // $ExpectError + + // This should compile + React.createElement(ConnectedWithOwnPropsClass, { own: 'string', forwarded: 'string' }); + React.createElement(ConnectedWithOwnPropsStateless, { own: 'string', forwarded: 'string' }); + + // This should not compile, it is missing ForwardedProps + React.createElement(ConnectedWithTypeHintClass, { own: 'string' }); // $ExpectError + React.createElement(ConnectedWithTypeHintStateless, { own: 'string' }); // $ExpectError + + interface AllProps { + own: string; + state: string; + } + + class AllPropsComponent extends React.Component> { + render() { + return
; + } + } + + type PickedOwnProps = Pick; + type PickedStateProps = Pick; + + const mapStateToPropsForPicked: MapStateToProps = (state: any): PickedStateProps => { + return { state: "string" }; + }; + const ConnectedWithPickedOwnProps = connect(mapStateToPropsForPicked)(AllPropsComponent); + ; +} + +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/25321#issuecomment-387659500 +function ProviderAcceptsStoreWithCustomAction() { + const reducer: Reducer< + { foo: number } | undefined, + { type: "foo"; payload: number } + > = state => state; + + const store = createStore(reducer); + + const Whatever = () => ( + +
Whatever
+
+ ); +} + +function TestOptionalPropsMergedCorrectly() { + interface OptionalDecorationProps { + foo: string; + bar: number; + optionalProp?: boolean; + dependsOnDispatch?: () => void; + } + + class Component extends React.Component { + render() { + return
; + } + } + + interface MapStateProps { + foo: string; + bar: number; + optionalProp: boolean; + } + + interface MapDispatchProps { + dependsOnDispatch: () => void; + } + + function mapStateToProps(state: any): MapStateProps { + return { + foo: 'foo', + bar: 42, + optionalProp: true, + }; + } + + function mapDispatchToProps(dispatch: any): MapDispatchProps { + return { + dependsOnDispatch: () => {} + }; + } + + connect(mapStateToProps, mapDispatchToProps)(Component); +} + +function TestMoreGeneralDecorationProps() { + // connect() should support decoration props that are more permissive + // than the injected props, as long as the injected props can satisfy + // the decoration props. + interface MoreGeneralDecorationProps { + foo: string | number; + bar: number | 'foo'; + optionalProp?: boolean | object; + dependsOnDispatch?: () => void; + } + + class Component extends React.Component { + render() { + return
; + } + } + + interface MapStateProps { + foo: string; + bar: number; + optionalProp: boolean; + } + + interface MapDispatchProps { + dependsOnDispatch: () => void; + } + + function mapStateToProps(state: any): MapStateProps { + return { + foo: 'foo', + bar: 42, + optionalProp: true, + }; + } + + function mapDispatchToProps(dispatch: any): MapDispatchProps { + return { + dependsOnDispatch: () => {} + }; + } + + connect(mapStateToProps, mapDispatchToProps)(Component); +} + +function TestFailsMoreSpecificInjectedProps() { + interface MoreSpecificDecorationProps { + foo: string; + bar: number; + dependsOnDispatch: () => void; + } + + class Component extends React.Component { + render() { + return
; + } + } + + interface MapStateProps { + foo: string | number; + bar: number | 'foo'; + dependsOnDispatch?: () => void; + } + + interface MapDispatchProps { + dependsOnDispatch?: () => void; + } + + function mapStateToProps(state: any): MapStateProps { + return { + foo: 'foo', + bar: 42, + }; + } + + function mapDispatchToProps(dispatch: any): MapDispatchProps { + return { + dependsOnDispatch: () => {} + }; + } + + // Since it is possible the injected props could fail to satisfy the decoration props, + // the following line should fail to compile. + connect(mapStateToProps, mapDispatchToProps)(Component); // $ExpectError + + // Confirm that this also fails with functional components + const FunctionalComponent = (props: MoreSpecificDecorationProps) => null; + connect(mapStateToProps, mapDispatchToProps)(Component); // $ExpectError +} + +function TestLibraryManagedAttributes() { + interface OwnProps { + bar: number; + fn: () => void; + } + + interface MapStateProps { + foo: string; + } + + class Component extends React.Component { + static defaultProps = { + bar: 0, + }; + + render() { + return
; + } + } + + function mapStateToProps(state: any): MapStateProps { + return { + foo: 'foo', + }; + } + + const ConnectedComponent = connect(mapStateToProps)(Component); + {}} />; + + const ConnectedComponent2 = connect(mapStateToProps)(Component); + {}} />; +} diff --git a/types/react-redux/v6/tsconfig.json b/types/react-redux/v6/tsconfig.json new file mode 100644 index 0000000000..82085150da --- /dev/null +++ b/types/react-redux/v6/tsconfig.json @@ -0,0 +1,31 @@ +{ + "files": [ + "index.d.ts", + "react-redux-tests.tsx" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "jsx": "react", + "experimentalDecorators": true, + "typeRoots": [ + "../../" + ], + "paths": { + "react-redux": [ + "react-redux/v6" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/react-redux/v6/tslint.json b/types/react-redux/v6/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/react-redux/v6/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 11d879b2ff..1df5c5256a 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -491,6 +491,10 @@ declare namespace React { getDefaultProps?(): P; } + type JSXElementConstructor

= + | ((props: P) => ReactElement | null) + | (new (props: P) => Component); + /** * We use an intersection type to infer multiple type parameters from * a single argument, which is useful for many top-level API defs. @@ -719,8 +723,8 @@ declare namespace React { * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded, * or ComponentPropsWithoutRef when refs are not supported. */ - type ComponentProps = - T extends ComponentType + type ComponentProps> = + T extends JSXElementConstructor ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] @@ -2629,9 +2633,20 @@ declare namespace React { } } -// Declared props take priority over inferred props +// naked 'any' type in a conditional type will short circuit and union both the then/else branches +// so boolean is only resolved for T = any +type IsExactlyAny = boolean extends (T extends never ? true : false) ? true : false; + +// Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any +// If props is type any, use propTypes definitions, otherwise for each `any` property of props, use the propTypes type // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened -type MergePropTypes = P & Pick>; +type MergePropTypes = IsExactlyAny

extends true ? T : ({ + [K in keyof P]: IsExactlyAny extends true + ? K extends keyof T + ? T[K] + : P[K] + : P[K] +} & Pick>); // Any prop that has a default prop becomes optional, but its type is unchanged // Undeclared default props are augmented into the resulting allowable attributes @@ -2797,6 +2812,7 @@ declare global { svg: React.SVGProps; animate: React.SVGProps; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now. + animateMotion: React.SVGProps; animateTransform: React.SVGProps; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now. circle: React.SVGProps; clipPath: React.SVGProps; @@ -2836,6 +2852,7 @@ declare global { marker: React.SVGProps; mask: React.SVGProps; metadata: React.SVGProps; + mpath: React.SVGProps; path: React.SVGProps; pattern: React.SVGProps; polygon: React.SVGProps; diff --git a/types/react/test/managedAttributes.tsx b/types/react/test/managedAttributes.tsx index 1e0e8226d9..9939cffb15 100644 --- a/types/react/test/managedAttributes.tsx +++ b/types/react/test/managedAttributes.tsx @@ -222,3 +222,30 @@ interface LeaveMeAloneDtslint { foo: string; } // // $ExpectError the type of ForwardRef.defaultProps stays Partial

anyway even if assigned // // ]; + +// const weakComponentPropTypes = { +// foo: PropTypes.string, +// bar: PropTypes.bool.isRequired +// }; +// interface WeakComponentProps1 { +// foo: any; +// bar: number; +// } +// interface WeakComponentProps2 { +// foo: string; +// bar: any; +// } + +// // $ExpectType true +// type weakComponentTest1 = JSX.LibraryManagedAttributes<{ propTypes: typeof weakComponentPropTypes }, any> extends { +// foo?: string | null +// bar: boolean +// } ? true : false; +// type weakComponentTest2 = JSX.LibraryManagedAttributes<{ propTypes: typeof weakComponentPropTypes }, WeakComponentProps1> extends { +// foo?: string | null +// bar: number +// } ? true : false; +// type weakComponentTest3 = JSX.LibraryManagedAttributes<{ propTypes: typeof weakComponentPropTypes }, WeakComponentProps2> extends { +// foo: string +// bar: boolean +// } ? true : false; diff --git a/types/rgb-hex/index.d.ts b/types/rgb-hex/index.d.ts new file mode 100644 index 0000000000..44a54bad35 --- /dev/null +++ b/types/rgb-hex/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for rgb-hex 2.1 +// Project: https://github.com/sindresorhus/rgb-hex#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = rgbHex; + +declare function rgbHex(rgba: string): string; +declare function rgbHex(red: number, green: number, blue: number, alpha?: string | number): string; diff --git a/types/rgb-hex/rgb-hex-tests.ts b/types/rgb-hex/rgb-hex-tests.ts new file mode 100644 index 0000000000..b2c950dd1b --- /dev/null +++ b/types/rgb-hex/rgb-hex-tests.ts @@ -0,0 +1,6 @@ +import rgbHex = require('rgb-hex'); + +rgbHex('rgb(40, 42, 54)'); // $ExpectType string +rgbHex(65, 131, 196); // $ExpectType string +rgbHex(65, 131, 196, 0.2); // $ExpectType string +rgbHex(40, 42, 54, '75%'); // $ExpectType string diff --git a/types/rgb-hex/tsconfig.json b/types/rgb-hex/tsconfig.json new file mode 100644 index 0000000000..cb4498db23 --- /dev/null +++ b/types/rgb-hex/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", + "rgb-hex-tests.ts" + ] +} diff --git a/types/rgb-hex/tslint.json b/types/rgb-hex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rgb-hex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/semver-regex/index.d.ts b/types/semver-regex/index.d.ts new file mode 100644 index 0000000000..9cadd84791 --- /dev/null +++ b/types/semver-regex/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for semver-regex 2.0 +// Project: https://github.com/sindresorhus/semver-regex#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = semverRegex; + +declare function semverRegex(): RegExp; diff --git a/types/semver-regex/semver-regex-tests.ts b/types/semver-regex/semver-regex-tests.ts new file mode 100644 index 0000000000..3699d0b801 --- /dev/null +++ b/types/semver-regex/semver-regex-tests.ts @@ -0,0 +1,3 @@ +import semverRegex = require('semver-regex'); + +semverRegex(); // $ExpectType RegExp diff --git a/types/semver-regex/tsconfig.json b/types/semver-regex/tsconfig.json new file mode 100644 index 0000000000..372170a05a --- /dev/null +++ b/types/semver-regex/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "semver-regex-tests.ts" + ] +} diff --git a/types/semver-regex/tslint.json b/types/semver-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/semver-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/semver-truncate/index.d.ts b/types/semver-truncate/index.d.ts new file mode 100644 index 0000000000..bc00aa959f --- /dev/null +++ b/types/semver-truncate/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for semver-truncate 1.1 +// Project: https://github.com/sindresorhus/semver-truncate#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = semverTruncate; + +declare function semverTruncate(version: string, type: 'patch' | 'minor' | 'major'): string; diff --git a/types/semver-truncate/semver-truncate-tests.ts b/types/semver-truncate/semver-truncate-tests.ts new file mode 100644 index 0000000000..2f32560ca3 --- /dev/null +++ b/types/semver-truncate/semver-truncate-tests.ts @@ -0,0 +1,5 @@ +import semverTruncate = require('semver-truncate'); + +semverTruncate('1.2.3-foo', 'patch'); // $ExpectType string +semverTruncate('1.2.3', 'minor'); // $ExpectType string +semverTruncate('1.2.3', 'major'); // $ExpectType string diff --git a/types/semver-truncate/tsconfig.json b/types/semver-truncate/tsconfig.json new file mode 100644 index 0000000000..86ba69e880 --- /dev/null +++ b/types/semver-truncate/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", + "semver-truncate-tests.ts" + ] +} diff --git a/types/semver-truncate/tslint.json b/types/semver-truncate/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/semver-truncate/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index c058591d91..5b1e844cbf 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -340,11 +340,12 @@ declare namespace Showdown { /** * Converts an HTML string into a markdown string - * @param src + * + * @param src The input text (HTML) * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used. - * @returns {string} + * @returns The output markdown */ - makeMarkdown(src: string, HTMLParser?: any): string; + makeMarkdown(src: string, HTMLParser?: HTMLDocument): string; /** * Setting a "local" option only affects the specified Converter object. diff --git a/types/simpl-schema/index.d.ts b/types/simpl-schema/index.d.ts index b09a8fde96..f399096d61 100644 --- a/types/simpl-schema/index.d.ts +++ b/types/simpl-schema/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for simpl-schema 0.1 +// Type definitions for simpl-schema 0.2 // Project: https://github.com/aldeed/simple-schema-js // Definitions by: Andreas Richter // Qkramer @@ -134,6 +134,7 @@ interface SimpleSchemaStatic { objectKeys(keyPrefix: any): any[]; validate(obj: any, options?: ValidationOption): void; validator(options: ValidationOption): () => boolean; + extendOptions(options: string[]): void; RegEx: { Email: RegExp; EmailWithTLD: RegExp; @@ -235,7 +236,6 @@ export interface SimpleSchema extends SimpleSchemaStatic { /** Validate a data object. Options: {keys: []} to limit */ validate(obj: any, options?: ValidationOption): void; addValidator(validator: () => boolean): any; - extendOptions(options: {[key: string]: any}): void; messages(messages: any): void; } diff --git a/types/simpl-schema/simpl-schema-tests.ts b/types/simpl-schema/simpl-schema-tests.ts index a3555c4428..0b34d15187 100644 --- a/types/simpl-schema/simpl-schema-tests.ts +++ b/types/simpl-schema/simpl-schema-tests.ts @@ -75,3 +75,5 @@ new SimpleSchema({ shortArray: Array, subSchema: StringSchemaWithOptions }); + +SimpleSchema.extendOptions(['autoform']); diff --git a/types/sindresorhus__string-hash/index.d.ts b/types/sindresorhus__string-hash/index.d.ts new file mode 100644 index 0000000000..84b0de28a5 --- /dev/null +++ b/types/sindresorhus__string-hash/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for @sindresorhus/string-hash 1.0 +// Project: https://github.com/sindresorhus/string-hash +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = stringHash; + +declare function stringHash(input: string): number; diff --git a/types/sindresorhus__string-hash/sindresorhus__string-hash-tests.ts b/types/sindresorhus__string-hash/sindresorhus__string-hash-tests.ts new file mode 100644 index 0000000000..4a685a476d --- /dev/null +++ b/types/sindresorhus__string-hash/sindresorhus__string-hash-tests.ts @@ -0,0 +1,3 @@ +import stringHash = require('@sindresorhus/string-hash'); + +stringHash('🦄🌈'); // $ExpectType number diff --git a/types/sindresorhus__string-hash/tsconfig.json b/types/sindresorhus__string-hash/tsconfig.json new file mode 100644 index 0000000000..c0464c0e42 --- /dev/null +++ b/types/sindresorhus__string-hash/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@sindresorhus/string-hash": [ + "sindresorhus__string-hash" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sindresorhus__string-hash-tests.ts" + ] +} diff --git a/types/sindresorhus__string-hash/tslint.json b/types/sindresorhus__string-hash/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sindresorhus__string-hash/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/snapsvg/index.d.ts b/types/snapsvg/index.d.ts index 85f1eda7b8..cc9c4f3627 100644 --- a/types/snapsvg/index.d.ts +++ b/types/snapsvg/index.d.ts @@ -1,7 +1,11 @@ -// Type definitions for Snap-SVG 0.4.1 +// Type definitions for Snap-SVG 0.5.1 // Project: https://github.com/adobe-webplatform/Snap.svg -// Definitions by: Lars Klein , Mattanja Kern , Andrey Kurdyumov +// Definitions by: Lars Klein , +// Mattanja Kern , +// Andrey Kurdyumov , +// Terry Mun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 /// export = Snap; @@ -31,6 +35,7 @@ declare namespace Snap { export function plugin(f:Function):void; export function select(query:string):Snap.Element; export function selectAll(query:string):any; + export function set(...els:Snap.Element[]):Snap.Set; export function snapTo(values:Array|number,value:number,tolerance?:number):number; export function animate(from:number|number[],to:number|number[],updater:(n:number)=>void,duration:number,easing?:(num:number)=>number,callback?:()=>void):mina.MinaAnimation; @@ -299,22 +304,24 @@ declare namespace Snap { } export interface Set { - animate(attrs:{[attr:string]:string|number|boolean|any},duration:number,easing?:(num:number)=>number,callback?:()=>void):Snap.Element; - animate(...params:Array<{attrs:any,duration:number,easing:(num:number)=>number,callback?:()=>void}>):Snap.Element; - attr(params: {[attr:string]:string|number|boolean|BBox|any}): Snap.Element; - attr(param: "viewBox"): BBox; - attr(param: string): string; - bind(attr: string, callback: Function): Snap.Set; + animate(attrs:{[attr:string]:string|number|boolean|any},duration:number,easing?:(num:number)=>number,callback?:()=>void):Snap.Set; + animate(...attrs:[{[attr:string]:string|number|boolean|any},number?,((num:number)=>number)?,(()=>void)?][]):Snap.Element; + attr(params:{[attr:string]:string|number|boolean|BBox|any}):Snap.Set; + attr(param:"viewBox"):Snap.Set; + attr(param:string):Snap.Set; + bind(attr:string,callback:Function):Snap.Set; bind(attr:string,element:Snap.Element):Snap.Set; bind(attr:string,element:Snap.Element,eattr:string):Snap.Set; - clear():Snap.Set; - exclude(element:Snap.Element):boolean; - forEach(callback:Function,thisArg?:Object):Snap.Set; + clear():void; + exclude(el:Snap.Element):boolean; + forEach(callback:(el:Snap.Element,index?:number)=>void|boolean,thisArg?:Object):Snap.Set; + getBBox():BBox; + insertAfter():Snap.Set; pop():Snap.Element; - push(el:Snap.Element):Snap.Element; - push(els:Snap.Element[]):Snap.Element; - remove(): Snap.Set; - splice(index:number,count:number,insertion?:Object[]):Snap.Element[]; + push(el:Snap.Element):Snap.Set; + push(...els:Snap.Element[]):Snap.Set; + remove():Snap.Set; + splice(index:number,count:number,...insertion:Snap.Element[]):Snap.Set; } interface Filter { diff --git a/types/snapsvg/test/4.ts b/types/snapsvg/test/4.ts new file mode 100644 index 0000000000..cfe9b40b14 --- /dev/null +++ b/types/snapsvg/test/4.ts @@ -0,0 +1,121 @@ +(() => { + // Tests by Terry Mun + // Checks that Snap.set() is properly typed + + const s = Snap(300, 500); + s.attr({ + viewBox: '0 0 200 500' + }); + + // Create multiple elements to be added to set + const rect1 = s.rect(0, 0, 50, 50); + const rect2 = s.rect(0, 100, 50, 50); + const rect3 = s.rect(0, 200, 50, 50); + const rect4 = s.rect(0, 300, 50, 50); + let rect5: Snap.Element; + + // Create new set + const rectSet = Snap.set(rect1, rect2); + + // Add missing rectangles to set + rectSet.push(rect3, rect4); + + // Set all attributes + rectSet.attr({ + fill: 'steelblue' + }); + + // Animate all elements in set + function animateTest() { + return new Promise(resolve => { + rectSet.animate({ + x: 50 + }, 500, mina.bounce, resolve); + }); + } + + // Animate elements individually + function animateMultipleTest() { + return new Promise(resolve => { + rectSet.animate( + [{ x: 100 }, 500, mina.linear], + [{ x: 100 }, 1000, mina.linear], + [{ x: 100 }, 1500, mina.linear], + [{ x: 100 }, 2000, mina.linear, resolve] + ); + }); + } + + // Animate elements individually + function forEachTest() { + const colors = ['red', 'green', 'blue']; + return new Promise(resolve => { + rectSet.forEach((element, idx) => { + element.attr({ + fill: colors[idx] || '#aaa' + }); + }); + resolve(); + }); + } + + // Exclude rect4 from set + function excludeTest() { + return new Promise(resolve => { + rectSet.exclude(rect4); + rectSet.animate({ + x: 150 + }, 500, mina.bounce, resolve); + }); + } + + // Remove rect2 from set (it has index of 1) + // Add new rect5 to set + async function spliceTest() { + rectSet.splice(1, 1); + rectSet.attr({ + fill: '#000' + }); + + rect5 = s.rect(100, 400, 50, 50); + rectSet.splice(1, 0, rect5); + return; + } + + // Clear set. Rectangles should not go back to x=0 + function clearTest() { + return new Promise(resolve => { + rectSet.clear(); + + // SHOULD NOT WORK + rectSet.animate({ + x: 0 + }, 500, mina.bounce, resolve); + + // Re-add rects to set + rectSet.push(rect1, rect2, rect3, rect4, rect5); + resolve(); + }); + } + + // Remove all elements from DOM that are present in set + async function removeTest() { + rectSet.remove(); + return; + } + + // Start test + async function startTest() { + await animateTest(); + await animateMultipleTest(); + await forEachTest(); + await excludeTest(); + await spliceTest(); + await clearTest(); + await removeTest(); + + return; + } + + startTest(); +})(); diff --git a/types/snapsvg/tsconfig.json b/types/snapsvg/tsconfig.json index 7ee69cd259..23101593c7 100644 --- a/types/snapsvg/tsconfig.json +++ b/types/snapsvg/tsconfig.json @@ -21,6 +21,7 @@ "index.d.ts", "test/1.ts", "test/2.ts", - "test/3.ts" + "test/3.ts", + "test/4.ts" ] } \ No newline at end of file diff --git a/types/socketcluster-server/scserver.d.ts b/types/socketcluster-server/scserver.d.ts index 48952a8a8a..c04c4888f0 100644 --- a/types/socketcluster-server/scserver.d.ts +++ b/types/socketcluster-server/scserver.d.ts @@ -49,8 +49,27 @@ declare class SCServer extends EventEmitter { addMiddleware(type: "publishOut", middlewareFn: (req: SCServer.PublishOutRequest, next: SCServer.nextMiddlewareFunction) => void): void; addMiddleware(type: "emit", middlewareFn: (req: SCServer.EmitRequest, next: SCServer.nextMiddlewareFunction) => void): void; + removeMiddleware(type: "handshakeWS", middlewareFn: (req: IncomingMessage, next: SCServer.nextMiddlewareFunction) => void): void; + removeMiddleware(type: "handshakeSC", middlewareFn: (req: SCServer.HandshakeSCRequest, next: SCServer.nextHandshakeSCMiddlewareFunction) => void): void; + removeMiddleware(type: "authenticate", middlewareFn: (req: SCServer.AuthenticateRequest, next: SCServer.nextAuthenticateMiddlewareFunction) => void): void; + removeMiddleware(type: "subscribe", middlewareFn: (req: SCServer.SubscribeRequest, next: SCServer.nextMiddlewareFunction) => void): void; + removeMiddleware(type: "publishIn", middlewareFn: (req: SCServer.PublishInRequest, next: SCServer.nextMiddlewareFunction) => void): void; + removeMiddleware(type: "publishOut", middlewareFn: (req: SCServer.PublishOutRequest, next: SCServer.nextMiddlewareFunction) => void): void; + removeMiddleware(type: "emit", middlewareFn: (req: SCServer.EmitRequest, next: SCServer.nextMiddlewareFunction) => void): void; + setAuthEngine(authEngine: SCAuthEngine): void; setCodecEngine(codecEngine: SCServer.SCCodecEngine): void; + + close(cb?: (err?: Error) => void): void; + + getPath(): string; + generateId(): string; + + verifyHandshake(info: SCServer.VerifyHandshakeInfo, cb: SCServer.verifyHandshakeFunction): void; + verifyInboundEvent(socket: SCServerSocket, eventName: string, eventData: any, cb: (err: Error, eventData: any, ackData?: any) => void): void; + verifyOutboundEvent(socket: SCServerSocket, eventName: string, eventData: any, options: {} | null, cb: (err: Error | null, eventData: any) => void): void; + + isAuthTokenExpired(token: SCServer.AuthToken): boolean; } export = SCServer; @@ -322,7 +341,7 @@ declare namespace SCServer { type nextAuthenticateMiddlewareFunction = (error?: true | string | Error | null, isBadToken?: boolean) => void; type connectionListenerFunction = (scSocket: SCServerSocket, serverSocketStatus: SCServerSocketStatus) => void; type disconnectionListenerFunction = (scSocket: SCServerSocket, code: number, data: any) => void; - type subscriptionListenerFunction = (scSocket: SCServerSocket, name: string, options: {channel: string}) => void; + type subscriptionListenerFunction = (scSocket: SCServerSocket, name: string, options: { channel: string }) => void; type unsubscriptionListenerFunction = (scSocket: SCServerSocket, channel: string) => void; type handshakeListenerFunction = (scSocket: SCServerSocket) => void; type badSocketAuthTokenListenerFunction = (scSocket: SCServerSocket, status: badAuthStatus) => void; @@ -331,4 +350,11 @@ declare namespace SCServer { decode: (input: any) => any; ncode: (object: any) => any; } + + interface VerifyHandshakeInfo { + req: IncomingMessage; + origin?: string; + } + + type verifyHandshakeFunction = (success: boolean, errorCode?: number, errorMessage?: string) => void; } diff --git a/types/spected/index.d.ts b/types/spected/index.d.ts new file mode 100644 index 0000000000..13b46ddd22 --- /dev/null +++ b/types/spected/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for spected 0.26 +// Project: https://github.com/25th-floor/spected +// Definitions by: Benjamin Makus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +declare var spected: Spected; + +export type Spected = (spec: Spec, input: any) => Result; + +export type Predicate = (value: any, inputs: any) => boolean; + +export type ErrorMsg = + | string + | ((value: any, field: string) => string); + +export interface Spec { + [key: string]: SpecValue; +} + +export type SpecValue = + | ReadonlyArray<[Predicate, ErrorMsg]> + | ((value: any) => any) + | Spec; + +export interface Result { + [key: string]: true | string[] | Result; +} + +export default spected; diff --git a/types/spected/tsconfig.json b/types/spected/tsconfig.json new file mode 100644 index 0000000000..ecc22c8314 --- /dev/null +++ b/types/spected/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/types/spected/tslint.json b/types/spected/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/spected/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/srcset/index.d.ts b/types/srcset/index.d.ts new file mode 100644 index 0000000000..afbeecd918 --- /dev/null +++ b/types/srcset/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for srcset 1.0 +// Project: https://github.com/sindresorhus/srcset#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Parse the HTML `` + * [srcset](http://mobile.smashingmagazine.com/2013/08/21/webkit-implements-srcset-and-why-its-a-good-thing/) attribute. + * + * @param srcset An srcset string. + */ +export function parse(srcset: string): SrcSetDefinition[]; + +/** + * Stringify a list of `SrcSetDefinition`s. + * + * @param srcSetDefinitions An array of `SrcSetDefinition` object. + * @returns A srcset string. + */ +export function stringify(srcSetDefinitions: SrcSetDefinition[]): string; + +export interface SrcSetDefinition { + url: string; + width?: number; + height?: number; + density?: number; +} diff --git a/types/srcset/srcset-tests.ts b/types/srcset/srcset-tests.ts new file mode 100644 index 0000000000..b7091e1bd8 --- /dev/null +++ b/types/srcset/srcset-tests.ts @@ -0,0 +1,8 @@ +import srcset = require('srcset'); + +const parsed = srcset.parse('banner-HD.jpg 2x, banner-phone.jpg 100w'); +parsed; // $ExpectType SrcSetDefinition[] + +parsed.push({ url: 'banner-phone-HD.jpg', width: 100, density: 2 }); + +srcset.stringify(parsed); // $ExpectType string diff --git a/types/srcset/tsconfig.json b/types/srcset/tsconfig.json new file mode 100644 index 0000000000..42d580ed7e --- /dev/null +++ b/types/srcset/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", + "srcset-tests.ts" + ] +} diff --git a/types/srcset/tslint.json b/types/srcset/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/srcset/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 93a9b13300..9f30067495 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -15,6 +15,7 @@ // Ifiok Jr. // Simon Schick // Slava Yultyyev Schick +// Corey Psoinos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -76,7 +77,7 @@ declare class Stripe { webhooks: Stripe.resources.WebHooks; ephemeralKeys: Stripe.resources.EphemeralKeys; usageRecords: Stripe.resources.UsageRecords; - usageRecordSummarys: Stripe.resources.UsageRecordSummarys; + usageRecordSummaries: Stripe.resources.UsageRecordSummaries; setHost(host: string): void; setHost(host: string, port: string|number): void; @@ -5324,17 +5325,17 @@ declare namespace Stripe { } } - namespace usageRecordSummarys { + namespace usageRecordSummaries { /** * A object with a data property that contains an array of up to limit summaries, * starting after summary starting_after. Each entry in the array is a separate summary object. * If no more summaries are available, the resulting array is empty. */ - interface IUsageRecordSummarys extends IList { + interface IUsageRecordSummaries extends IList { object: 'list'; } - interface IUsageRecordSummarysItem { + interface IUsageRecordSummariesItem { id: string; object: string; invoice: string; @@ -5344,7 +5345,7 @@ declare namespace Stripe { total_usage: number; } - interface IUsageRecordSummarysListOptions extends IListOptions { + interface IUsageRecordSummariesListOptions extends IListOptions { /** * Only summary items for the given subscription item. */ @@ -5371,12 +5372,12 @@ declare namespace Stripe { create(subscription: string, data: usageRecords.IUsageRecordCreationOptions, response?: IResponseFn): Promise; } - class UsageRecordSummarys extends StripeResource { + class UsageRecordSummaries extends StripeResource { /** * Creates a usage record for a specified subscription item and date, and fills it with a quantity. */ - list(data: usageRecordSummarys.IUsageRecordSummarysListOptions, options: HeaderOptions, response?: IResponseFn): Promise; - list(data: usageRecordSummarys.IUsageRecordSummarysListOptions, response?: IResponseFn): Promise; + list(data: usageRecordSummaries.IUsageRecordSummariesListOptions, options: HeaderOptions, response?: IResponseFn): Promise; + list(data: usageRecordSummaries.IUsageRecordSummariesListOptions, response?: IResponseFn): Promise; } class Accounts extends StripeResource { diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 30e454f6dc..154a5e0a58 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -1332,8 +1332,8 @@ stripe.ephemeralKeys.create({ customer: "cus_5rfJKDJkuxzh5Q" }, { stripe_version stripe.usageRecords.create('sub_8QwCiwZ9tmMSpt', { action: 'set', quantity: 10000, timestamp: 1537006853 }).then((usageRecord: Stripe.usageRecords.IUsageRecord) => {}); stripe.usageRecords.create('sub_8QwCiwZ9tmMSpt', { action: 'set', quantity: 10000, timestamp: 1537006853 }, (err, usageRecord: Stripe.usageRecords.IUsageRecord) => {}); -stripe.usageRecordSummarys.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }).then((usageRecordSummarys: Stripe.usageRecordSummarys.IUsageRecordSummarys) => {}); -stripe.usageRecordSummarys.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }, (err, usageRecordSummarys: Stripe.usageRecordSummarys.IUsageRecordSummarys) => {}); +stripe.usageRecordSummaries.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }).then((usageRecordSummaries: Stripe.usageRecordSummaries.IUsageRecordSummaries) => {}); +stripe.usageRecordSummaries.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }, (err, usageRecordSummaries: Stripe.usageRecordSummaries.IUsageRecordSummaries) => {}); //#region Errors // ################################################################################## diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index 495df8a6d3..ca2f7ce1fc 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -40,7 +40,7 @@ export interface LowLevelStylefunctionArguments { scale?: Array; } -export function style(args: LowLevelStylefunctionArguments): any; +export function style(args: LowLevelStylefunctionArguments): {[cssProp: string]: string}; export type TLengthStyledSystem = string | 0 | number; export type ResponsiveValue = T | Array; diff --git a/types/to-semver/index.d.ts b/types/to-semver/index.d.ts new file mode 100644 index 0000000000..813c77378d --- /dev/null +++ b/types/to-semver/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for to-semver 1.1 +// Project: https://github.com/sindresorhus/to-semver#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = toSemver; + +/** + * Get an array of valid, sorted, and cleaned [semver](http://semver.org/) versions from an array of strings. + */ +declare function toSemver(versions: string[], options?: toSemver.Options): string[]; + +declare namespace toSemver { + interface Options { + /** + * Include prereleases, like `1.2.3-alpha.3`. + * @default true + */ + includePrereleases?: boolean; + /** + * Clean versions. For example `v1.3.0` → `1.3.0`. + * @default true + */ + clean?: boolean; + } +} diff --git a/types/to-semver/to-semver-tests.ts b/types/to-semver/to-semver-tests.ts new file mode 100644 index 0000000000..5599c594d1 --- /dev/null +++ b/types/to-semver/to-semver-tests.ts @@ -0,0 +1,3 @@ +import toSemver = require('to-semver'); + +toSemver(['v1.3.16', 'v1.7.0', 'test', 'v1.6.9']); // $ExpectType string[] diff --git a/types/to-semver/tsconfig.json b/types/to-semver/tsconfig.json new file mode 100644 index 0000000000..0584eb2068 --- /dev/null +++ b/types/to-semver/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", + "to-semver-tests.ts" + ] +} diff --git a/types/to-semver/tslint.json b/types/to-semver/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/to-semver/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/usb/index.d.ts b/types/usb/index.d.ts index 2543f0b06e..9bf7b10dc2 100644 --- a/types/usb/index.d.ts +++ b/types/usb/index.d.ts @@ -137,6 +137,7 @@ export class EndpointDescriptor { export function findByIds(vid: number, pid: number): Device; export function on(event: string, callback: (device: Device) => void): void; +export function removeListener(event: string, callback: (device: Device) => void): void; export function getDeviceList(): Device[]; export function setDebugLevel(level: number): void; diff --git a/types/usb/usb-tests.ts b/types/usb/usb-tests.ts index d4b36d16df..fcc658ddcc 100644 --- a/types/usb/usb-tests.ts +++ b/types/usb/usb-tests.ts @@ -124,6 +124,7 @@ iface.endpoints = [inEndpoint, outEndpoint]; const findByDevice: usb.Device = usb.findByIds(1, 1); usb.on("hey", (device: usb.Device) => null); +usb.removeListener("hey", (device: usb.Device) => null); const deviceList: usb.Device[] = usb.getDeviceList(); usb.setDebugLevel(1); diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 09f9b28d0d..62bbf83362 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -4613,6 +4613,7 @@ declare namespace videojs { languages?: { [code: string]: LanguageTranslations }; loop?: boolean; muted?: boolean; + nativeControlsForTouch?: boolean; notSupportedMessage?: string; playbackRates?: number[]; plugins?: any; diff --git a/types/webdriverio/index.d.ts b/types/webdriverio/index.d.ts index 4a1f585808..67fe0454db 100644 --- a/types/webdriverio/index.d.ts +++ b/types/webdriverio/index.d.ts @@ -171,7 +171,7 @@ declare namespace WebdriverIO { } interface Capabilities { - browserName: string; + browserName?: string; acceptInsecureCerts?: boolean; browserVersion?: string; platformName?: string; diff --git a/types/weixin-app/index.d.ts b/types/weixin-app/index.d.ts index 9422850bc5..3d418af38a 100644 --- a/types/weixin-app/index.d.ts +++ b/types/weixin-app/index.d.ts @@ -3729,13 +3729,6 @@ declare namespace wx { type DefaultProps = object | Record; - type ExtendedComponent< - Instance extends Component, - Data, - Methods, - Props - > = CombinedInstance & Component; - // CombinedInstance models the `this`, i.e. instance type for (user defined) component type CombinedInstance< Instance extends Component, @@ -3785,7 +3778,7 @@ declare namespace wx { Methods, Props > = object & - ComponentOptions Data), Methods, Props> & + ComponentOptions & ThisType>>; interface ComponentRelation { @@ -3899,7 +3892,7 @@ declare namespace wx { * 类似于mixins和traits的组件间代码复用机制 * 参见 [behaviors](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/custom-component/behaviors.html) */ - behaviors?: Array<(ComponentOptions>) | string>; + behaviors?: string[]; /** * 组件生命周期声明对象,组件的生命周期:created、attached、ready、moved、detached将收归到lifetimes字段内进行声明, @@ -4370,7 +4363,7 @@ declare function Component( M, P > -): wx.ExtendedComponent, D, M, P>; +): string; /** * behaviors 是用于组件间代码共享的特性 * 类似于一些编程语言中的“mixins”或“traits” @@ -4386,7 +4379,7 @@ declare function Behavior( M, P > -): wx.ExtendedComponent, D, M, P>; +): string; // #endregion // #region Page /** diff --git a/types/when-dom-ready/index.d.ts b/types/when-dom-ready/index.d.ts new file mode 100644 index 0000000000..4c7dda748c --- /dev/null +++ b/types/when-dom-ready/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for when-dom-ready 1.2 +// Project: https://github.com/lukechilds/when-dom-ready +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = whenDomReady; + +declare function whenDomReady(document?: EventTarget): Promise; +declare function whenDomReady(callback?: () => void, document?: EventTarget): Promise; + +declare namespace whenDomReady { + function resume(document?: EventTarget): (value: T) => Promise; +} diff --git a/types/when-dom-ready/tsconfig.json b/types/when-dom-ready/tsconfig.json new file mode 100644 index 0000000000..a00e26ff4a --- /dev/null +++ b/types/when-dom-ready/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "when-dom-ready-tests.ts" + ] +} diff --git a/types/when-dom-ready/tslint.json b/types/when-dom-ready/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/when-dom-ready/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/when-dom-ready/when-dom-ready-tests.ts b/types/when-dom-ready/when-dom-ready-tests.ts new file mode 100644 index 0000000000..0bc9e061a7 --- /dev/null +++ b/types/when-dom-ready/when-dom-ready-tests.ts @@ -0,0 +1,7 @@ +import whenDomReady = require('when-dom-ready'); + +whenDomReady(); // $ExpectType Promise +whenDomReady(document); // $ExpectType Promise +whenDomReady(() => {}, document); // $ExpectType Promise + +Promise.resolve('foo').then(whenDomReady.resume(document)); // $ExpectType Promise