diff --git a/types/abstract-leveldown/abstract-leveldown-tests.ts b/types/abstract-leveldown/abstract-leveldown-tests.ts new file mode 100644 index 0000000000..c5edadf069 --- /dev/null +++ b/types/abstract-leveldown/abstract-leveldown-tests.ts @@ -0,0 +1,13 @@ +import { AbstractLevelDOWN } from 'abstract-leveldown'; + +const test = (levelDown: AbstractLevelDOWN) => { + levelDown.put("key", "value", (err?) => { }); + levelDown.put(1, "value", { something: true }, (err?) => { }); + + levelDown.get("key", (err?) => { }); + levelDown.get(1, { something: true }, (err?) => { }); +}; +// $ExpectType void +test(new AbstractLevelDOWN('here')); +// $ExpectType void +test(AbstractLevelDOWN('there')); diff --git a/types/abstract-leveldown/index.d.ts b/types/abstract-leveldown/index.d.ts new file mode 100644 index 0000000000..2caf073432 --- /dev/null +++ b/types/abstract-leveldown/index.d.ts @@ -0,0 +1,103 @@ +// Type definitions for abstract-leveldown 5.0 +// Project: https://github.com/Level/abstract-leveldown +// Definitions by: Meirion Hughes +// Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface AbstractOptions { + readonly [k: string]: any; +} + +export type ErrorCallback = (err: Error | undefined) => void; +export type ErrorValueCallback = (err: Error | undefined, value: V) => void; +export type ErrorKeyValueCallback = (err: Error | undefined, key: K, value: V) => void; + +export interface AbstractOpenOptions extends AbstractOptions { + createIfMissing?: boolean; + errorIfExists?: boolean; +} + +export interface AbstractGetOptions extends AbstractOptions { + asBuffer?: boolean; +} + +export interface AbstractLevelDOWN extends AbstractOptions { + open(cb: ErrorCallback): void; + open(options: AbstractOpenOptions, cb: ErrorCallback): void; + + close(cb: ErrorCallback): void; + + get(key: K, cb: ErrorValueCallback): void; + get(key: K, options: AbstractGetOptions, cb: ErrorValueCallback): void; + + put(key: K, value: V, cb: ErrorCallback): void; + put(key: K, value: V, options: AbstractOptions, cb: ErrorCallback): void; + + del(key: K, cb: ErrorCallback): void; + del(key: K, options: AbstractOptions, cb: ErrorCallback): void; + + batch(): AbstractChainedBatch; + batch(array: ReadonlyArray>, cb: ErrorCallback): AbstractChainedBatch; + batch(array: ReadonlyArray>, options: AbstractOptions, cb: ErrorCallback): AbstractChainedBatch; + + iterator(options?: AbstractIteratorOptions): AbstractIterator; +} + +export interface AbstractLevelDOWNConstructor { + new (location: string): AbstractLevelDOWN; + (location: string): AbstractLevelDOWN; +} + +export interface AbstractIteratorOptions extends AbstractOptions { + gt?: K; + gte?: K; + lt?: K; + lte?: K; + reverse?: boolean; + limit?: number; + keys?: boolean; + values?: boolean; + keyAsBuffer?: boolean; + valueAsBuffer?: boolean; +} + +export type AbstractBatch = PutBatch | DelBatch; + +export interface PutBatch { + readonly type: 'put'; + readonly key: K; + readonly value: V; +} + +export interface DelBatch { + readonly type: 'del'; + readonly key: K; +} + +export interface AbstractChainedBatch extends AbstractChainedBatchConstructor, AbstractOptions { + put: (key: K, value: V) => this; + del: (key: K) => this; + clear: () => this; + write(cb: ErrorCallback): any; + write(options: any, cb: ErrorCallback): any; +} + +export interface AbstractChainedBatchConstructor { + new(db: any): AbstractChainedBatch; + (db: any): AbstractChainedBatch; +} + +export interface AbstractIterator extends AbstractChainedBatchConstructor { + db: AbstractLevelDOWN; + next(cb: ErrorKeyValueCallback): this; + end(cb: ErrorCallback): void; +} + +export interface AbstractIteratorConstructor { + new(db: any): AbstractIterator; + (db: any): AbstractIterator; +} + +export const AbstractLevelDOWN: AbstractLevelDOWNConstructor; +export const AbstractIterator: AbstractIteratorConstructor; +export const AbstractChainedBatch: AbstractChainedBatchConstructor; diff --git a/types/abstract-leveldown/tsconfig.json b/types/abstract-leveldown/tsconfig.json new file mode 100644 index 0000000000..286b867f00 --- /dev/null +++ b/types/abstract-leveldown/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", + "abstract-leveldown-tests.ts" + ] +} diff --git a/types/abstract-leveldown/tslint.json b/types/abstract-leveldown/tslint.json new file mode 100644 index 0000000000..256ee54775 --- /dev/null +++ b/types/abstract-leveldown/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/agenda/agenda-tests.ts b/types/agenda/agenda-tests.ts index 8e0e8b9fb6..aef7ecd7d6 100644 --- a/types/agenda/agenda-tests.ts +++ b/types/agenda/agenda-tests.ts @@ -1,10 +1,14 @@ import Agenda = require("agenda"); -import { Db, Server } from "mongodb"; +import { Db, Server, MongoClient } from "mongodb"; var mongoConnectionString = "mongodb://127.0.0.1/agenda"; (async () => { var agenda = new Agenda({ db: { address: mongoConnectionString } }); + var agenda = new Agenda({ + mongo: (await MongoClient.connect(mongoConnectionString)).db(), + db: { collection: 'agenda-jobs' }, + }); agenda.define<{ foo: Error }>('delete old users', (job, done) => { done(job.attrs.data.foo) diff --git a/types/agenda/index.d.ts b/types/agenda/index.d.ts index 206d40daf3..75246ecda3 100644 --- a/types/agenda/index.d.ts +++ b/types/agenda/index.d.ts @@ -203,17 +203,7 @@ declare namespace Agenda { /** * Specifies that Agenda should be initialized using and existing MongoDB connection. */ - mongo?: { - /** - * The MongoDB database connection to use. - */ - db: Db; - - /** - * The name of the collection to use. - */ - collection?: string; - } + mongo?: Db; /** * Specifies that Agenda should connect to MongoDB. @@ -221,8 +211,10 @@ declare namespace Agenda { db?: { /** * The connection URL. + * Required when using `db` option to connect. + * Not required when an existing connection is passed as `mongo` property. */ - address: string; + address?: string; /** * The name of the collection to use. @@ -231,6 +223,7 @@ declare namespace Agenda { /** * Connection options to pass to MongoDB. + * Not required when an existing connection is passed as `mongo` property. */ options?: any; } diff --git a/types/ansi-escape-sequences/ansi-escape-sequences-tests.ts b/types/ansi-escape-sequences/ansi-escape-sequences-tests.ts new file mode 100644 index 0000000000..ae27a57146 --- /dev/null +++ b/types/ansi-escape-sequences/ansi-escape-sequences-tests.ts @@ -0,0 +1,50 @@ +import * as ansi from 'ansi-escape-sequences'; + +// $ExpectType string +ansi.style.red; +// $ExpectError +ansi.style.invalidStyle; + +// $ExpectType string +ansi.styles('green'); +// $ExpectType string +ansi.styles(['green', 'underline']); +// $ExpectError +ansi.styles('invalidStyle'); +// $ExpectError +ansi.styles(['invalidStyle']); + +// $ExpectType string +ansi.format('what?', 'green'); +// $ExpectType string +ansi.format('what?', ['green', 'bold']); +// $ExpectType string +ansi.format('[green bold]{what?}'); +// $ExpectError +ansi.styles('what?', 'invalidStyle'); +// $ExpectError +ansi.styles('what?', ['invalidStyle']); + +// $ExpectType string +ansi.cursor.up(); +// $ExpectType string +ansi.cursor.up(1); + +// $ExpectType string +ansi.cursor.hide; +// $ExpectType string +ansi.cursor.show; + +// $ExpectType string +ansi.erase.display(); +// $ExpectType string +ansi.erase.display(3); +// $ExpectError +ansi.erase.display(4); + +// $ExpectType string +ansi.erase.inLine(); +// $ExpectType string +ansi.erase.inLine(2); +// $ExpectError +ansi.erase.inLine(3); diff --git a/types/ansi-escape-sequences/index.d.ts b/types/ansi-escape-sequences/index.d.ts new file mode 100644 index 0000000000..437841aefa --- /dev/null +++ b/types/ansi-escape-sequences/index.d.ts @@ -0,0 +1,148 @@ +// Type definitions for ansi-escape-sequences 4.0 +// Project: https://github.com/75lb/ansi-escape-sequences#readme +// Definitions by: Alexander Marks +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export type Style = 'reset'|'bold'|'italic'|'underline'|'fontDefault'|'font2'| + 'font3'|'font4'|'font5'|'font6'|'imageNegative'|'imagePositive'|'black'| + 'red'|'green'|'yellow'|'blue'|'magenta'|'cyan'|'white'|'grey'|'gray'| + 'bg-black'|'bg-red'|'bg-green'|'bg-yellow'|'bg-blue'|'bg-magenta'|'bg-cyan'| + 'bg-white'|'bg-grey'|'bg-gray'; + +/** + * Various formatting styles (aka Select Graphic Rendition codes). + * + * @example + * console.log(ansi.style.red + 'this is red' + ansi.style.reset) + */ +export const style: {[K in Style]: string}; + +/** + * Returns an ansi sequence setting one or more effects. + * + * @param styles a style, or list or styles + * + * @example + * > ansi.styles('green') + * '\u001b[32m' + * + * > ansi.styles([ 'green', 'underline' ]) + * '\u001b[32;4m' + */ +export function styles(styles: Style|ReadonlyArray\n' + + '\n' + + ' \n' + + ' \n' + + ' \n' + + '\n'; + + return webview; +} + +onload = () => { + var webview = CreateWebViewAndGuest(); + document.body.appendChild(webview); +}; + +// #endregion + +// #region Embedding & AppView +chrome.app.runtime.onEmbedRequested.addListener((request) => { + request.allow('foobar.html'); +}); +// Creates an element. +let appview = document.createElement('appview'); +appview = new AppView() || new window.AppView(); +// Appends the element to the document body. +document.body.appendChild(appview); +// Connects the appview to appToEmbed. +appview.connect('id of app'); +document.appendChild(appview); +//#endregion + -chrome.desktopCapture.chooseDesktopMedia(["screen", "window", "tab"], () => { }); -chrome.desktopCapture.chooseDesktopMedia([chrome.desktopCapture.DesktopCaptureSourceType.AUDIO], () => { }); diff --git a/types/chrome-apps/tsconfig.json b/types/chrome-apps/tsconfig.json index 50a50c3193..6e00d1a959 100644 --- a/types/chrome-apps/tsconfig.json +++ b/types/chrome-apps/tsconfig.json @@ -1,10 +1,6 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es2017", - "dom" - ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, @@ -13,6 +9,10 @@ "typeRoots": [ "../" ], + "lib": [ + "es2017", + "dom" + ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/cli-truncate/cli-truncate-tests.ts b/types/cli-truncate/cli-truncate-tests.ts new file mode 100644 index 0000000000..677108e6ad --- /dev/null +++ b/types/cli-truncate/cli-truncate-tests.ts @@ -0,0 +1,19 @@ +import cliTruncate = require('cli-truncate'); + +// Truncate at different positions +// $ExpectType string +cliTruncate('unicorn', 4); // default position: 'end' + +// $ExpectType string +cliTruncate('unicorn', 4, {position: 'start'}); + +// $ExpectType string +cliTruncate('unicorn', 4, {position: 'middle'}); + +// Truncate Unicode surrogate pairs +// $ExpectType string +cliTruncate('uni\uD83C\uDE00corn', 5); + +// Truncate full-width characters +// $ExpectType string +cliTruncate('안녕하세요', 3); diff --git a/types/cli-truncate/index.d.ts b/types/cli-truncate/index.d.ts new file mode 100644 index 0000000000..f02ec427b8 --- /dev/null +++ b/types/cli-truncate/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for cli-truncate 1.1 +// Project: https://github.com/sindresorhus/cli-truncate +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = cliTruncate; + +declare function cliTruncate( + input: string, + columns: number, + options?: {position?: 'start' | 'middle' | 'end'}, +): string; diff --git a/types/cli-truncate/tsconfig.json b/types/cli-truncate/tsconfig.json new file mode 100644 index 0000000000..efc2a3a1c7 --- /dev/null +++ b/types/cli-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", + "cli-truncate-tests.ts" + ] +} diff --git a/types/cli-truncate/tslint.json b/types/cli-truncate/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/cli-truncate/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 5ece4f497e..729b8a86d7 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -17,9 +17,17 @@ declare namespace CodeMirror { export var Pos: CodeMirror.PositionConstructor; export var Pass: {toString(): "CodeMirror.PASS"}; + /** Find the column position at a given string index using a given tabsize. */ function countColumn(line: string, index: number | null, tabSize: number): number; function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea; + /** Compare two positions, return 0 if they are the same, a negative number when a is less, and a positive number otherwise. */ + function cmpPos(a: Position, b: Position): number; + + /** Utility function that computes an end position from a change (an object with from, to, and text properties, as passed to various event handlers). + The returned position will be the end of the changed range, after the change is applied. */ + function changeEnd(change: EditorChange): Position; + /** It contains a string that indicates the version of the library. This is a triple of integers "major.minor.patch", where patch is zero for releases, and something else (usually one) for dev snapshots. */ var version: string; @@ -51,6 +59,14 @@ declare namespace CodeMirror { CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo. */ function registerHelper(namespace: string, name: string, helper: any): void; + /** Given a state object, returns a {state, mode} object with the inner mode and its state for the current position. */ + function innerMode(mode: Mode, state: any): { state: any, mode: Mode }; + + /** Sometimes, it is useful to add or override mode object properties from external code. + The CodeMirror.extendMode function can be used to add properties to mode objects produced for a specific mode. + Its first argument is the name of the mode, its second an object that specifies the properties that should be added. + This is mostly useful to add utilities that can later be looked up through getMode. */ + function extendMode(name: string, properties: Mode): void; function on(element: any, eventName: string, handler: Function): void; function off(element: any, eventName: string, handler: Function): void; @@ -324,6 +340,9 @@ declare namespace CodeMirror { you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */ refresh(): void; + /** Gets the inner mode at a given position. This will return the same as getMode for simple modes, but will return an inner mode for nesting modes (such as htmlmixed). */ + getModeAt(pos: Position): any; + /** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */ getTokenAt(pos: CodeMirror.Position, precise?: boolean): Token; @@ -555,8 +574,10 @@ declare namespace CodeMirror { /** Return true if any text is selected. */ somethingSelected(): boolean; - /** Set the cursor position.You can either pass a single { line , ch } object , or the line and the character as two separate parameters. */ - setCursor(pos: CodeMirror.Position): void; + /** Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. + Will replace all selections with a single, empty selection at the given position. + The supported options are the same as for setSelection */ + setCursor(pos: CodeMirror.Position | number, ch?: number, options?: { bias?: number, origin?: string, scroll?: boolean }): void; /** Set a single selection range. anchor and head should be {line, ch} objects. head defaults to anchor when not given. */ setSelection(anchor: CodeMirror.Position, head: CodeMirror.Position, options?: { bias?: number, origin?: string, scroll?: boolean }): void; @@ -709,9 +730,9 @@ declare namespace CodeMirror { /** Array of strings representing the text that replaced the changed range (split by line). */ text: string[]; /** Text that used to be between from and to, which is overwritten by this change. */ - removed: string[]; + removed?: string[]; /** String representing the origin of the change event and wether it can be merged with history */ - origin: string; + origin?: string; } interface EditorChangeLinkedList extends CodeMirror.EditorChange { @@ -1083,7 +1104,7 @@ declare namespace CodeMirror { * This function should read one token from the stream it is given as an argument, optionally update its state, * and return a style string, or null for tokens that do not have to be styled. Multiple styles can be returned, separated by spaces. */ - token(stream: StringStream, state: T): string | null; + token?: (stream: StringStream, state: T) => string | null; /** * A function that produces a state object to be used at the start of a document. diff --git a/types/cometd/index.d.ts b/types/cometd/index.d.ts index 0ac377c241..cc97b304fe 100644 --- a/types/cometd/index.d.ts +++ b/types/cometd/index.d.ts @@ -21,12 +21,16 @@ declare namespace CometD { } interface CometD { + + websocketEnabled?: boolean; onListenerException: (exception: any, subscriptionHandle: any, isListener: boolean, message: string) => void; init(options: CometD.ConfigurationOptions): void; configure(config: CometD.ConfigurationOptions): void; + + subscribe(channel: string, listener: (message: any) => void): void; addListener(channel: string, listener: (message: any) => void): void; removeListener(listener: (message: any) => void): void; diff --git a/types/crossfilter/crossfilter-tests.ts b/types/crossfilter/crossfilter-tests.ts index 5d9981b6d1..e96d83a7e2 100644 --- a/types/crossfilter/crossfilter-tests.ts +++ b/types/crossfilter/crossfilter-tests.ts @@ -1,4 +1,4 @@ - +import * as crossfilter from 'crossfilter'; interface Payment { diff --git a/types/crossfilter/index.d.ts b/types/crossfilter/index.d.ts index a009e920dd..bae8a06565 100644 --- a/types/crossfilter/index.d.ts +++ b/types/crossfilter/index.d.ts @@ -110,7 +110,6 @@ declare namespace CrossFilter { } } -declare var crossfilter: CrossFilter.CrossFilterStatic; declare module "crossfilter" { var crossfilter: CrossFilter.CrossFilterStatic; export = crossfilter; diff --git a/types/dc/dc-tests.ts b/types/dc/dc-tests.ts index 7e1a49727e..c431e3c714 100644 --- a/types/dc/dc-tests.ts +++ b/types/dc/dc-tests.ts @@ -1,4 +1,4 @@ -import * as CrossFilter from 'crossfilter'; +import * as crossfilter from 'crossfilter'; import * as d3 from "d3"; import * as dc from "dc"; diff --git a/types/dialogflow/index.d.ts b/types/dialogflow/index.d.ts index d4b43498e0..6a3faa8618 100644 --- a/types/dialogflow/index.d.ts +++ b/types/dialogflow/index.d.ts @@ -760,8 +760,8 @@ export enum MatchMode { } export interface Credentials { - client_email?: string; - private_key?: string; + client_email: string; + private_key: string; } export interface ClientOptions { diff --git a/types/doubleclick-gpt/doubleclick-gpt-tests.ts b/types/doubleclick-gpt/doubleclick-gpt-tests.ts index 5865ed02dd..9218408268 100644 --- a/types/doubleclick-gpt/doubleclick-gpt-tests.ts +++ b/types/doubleclick-gpt/doubleclick-gpt-tests.ts @@ -69,6 +69,10 @@ googletag.pubads().definePassback("/1234567/sports", [468, 60]) .setTagForChildDirectedTreatment(1) .display(); +googletag.pubads().definePassback('/1234567/sports', [468, 60]) + .setTagForUnderAgeOfConsent(1) + .display(); + googletag.pubads().definePassback("/1234567/sports", [468, 60]). setTargeting("color", "red"). setTargeting("sport", ["rugby", "rowing"]). @@ -79,6 +83,13 @@ googletag.pubads().definePassback("/1234567/sports", [160, 600]). "interests": ["sports", "music", "movies"]}). display(); +googletag.pubads().enableLazyLoad(); +googletag.pubads().enableLazyLoad({ + fetchMarginPercent: 500, + renderMarginPercent: 200, + mobileScaling: 2.0 +}); + // The calls to construct an ad and display contents. slot1 = googletag.pubads().display("/1234567/sports", [728, 90], "div-1"); slot2 = googletag.pubads().display("/1234567/news", [160, 600], "div-2"); @@ -107,6 +118,13 @@ googletag.pubads().setTagForChildDirectedTreatment(1); // Clear child-directed setting and return to initial not-set value. googletag.pubads().clearTagForChildDirectedTreatment(); +// Mark ad requests as coming from users under the age of consent. +googletag.pubads().setTagForUnderAgeOfConsent(1); + +// Clear the tag value that configures whether to mark ad requests as +// coming from users under the age of consent. +googletag.pubads().setTagForUnderAgeOfConsent(); + googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); diff --git a/types/doubleclick-gpt/index.d.ts b/types/doubleclick-gpt/index.d.ts index 545f534e79..ab71cdc99a 100644 --- a/types/doubleclick-gpt/index.d.ts +++ b/types/doubleclick-gpt/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Publisher Tag v199 +// Type definitions for Google Publisher Tag v238 // Project: https://developers.google.com/doubleclick-gpt/reference // Definitions by: John Wright // Steven Joyce @@ -40,6 +40,12 @@ declare namespace googletag { setContent(slot: Slot, content: String): void; } + export interface LazyLoadOptionsConfig { + fetchMarginPercent?: number, + renderMarginPercent?: number, + mobileScaling?: number + } + export interface ResponseInformation { advertiserId: string; campaignId: string; @@ -101,6 +107,7 @@ declare namespace googletag { setClickUrl(url: string): PassbackSlot; setForceSafeFrame(forceSafeFrame: boolean): PassbackSlot; setTagForChildDirectedTreatment(value: number): PassbackSlot; + setTagForUnderAgeOfConsent(value: number): PassbackSlot; setTargeting(key: string, value: string | string[]): PassbackSlot; updateTargetingFromMap(map: Object): PassbackSlot; } @@ -116,6 +123,7 @@ declare namespace googletag { disableInitialLoad(): void; display(adUnitPath: string, size: GeneralSize, opt_div?: string | Element, opt_clickUrl?: string): Slot; enableAsyncRendering(): boolean; + enableLazyLoad(opt_config?: LazyLoadOptionsConfig): void; enableSingleRequest(): boolean; enableSyncRendering(): boolean; enableVideoAds(): void; @@ -134,6 +142,7 @@ declare namespace googletag { setRequestNonPersonalizedAds(nonPersonalizedAds: 0 | 1): PubAdsService; setSafeFrameConfig(config: SafeFrameConfig): PubAdsService; setTagForChildDirectedTreatment(value: number): PubAdsService; + setTagForUnderAgeOfConsent(opt_value?: number): PubAdsService; setTargeting(key: string, value: string | string[]): PubAdsService; setVideoContent(videoContentId: string, videoCmsId: string): void; updateCorrelator(): PubAdsService; diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index 85574e3c91..68625bd5bb 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -37,6 +37,21 @@ client.search({ }, (error) => { }); +client.search({ + body: { + query: { + match_all: { + _name: 'test' + } + } + } +} +).then((body) => { + const hit = body.hits.hits[0]; + const names = hit && hit.matched_queries; +}, (error) => { +}); + client.indices.delete({ index: 'test_index', ignore: [404] diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index c791db72c3..a9dc133545 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -645,6 +645,7 @@ export interface SearchResponse { fields?: any; highlight?: any; inner_hits?: any; + matched_queries?: string[]; sort?: string[]; }>; }; diff --git a/types/elegant-spinner/elegant-spinner-tests.ts b/types/elegant-spinner/elegant-spinner-tests.ts new file mode 100644 index 0000000000..5d2ddb9dc7 --- /dev/null +++ b/types/elegant-spinner/elegant-spinner-tests.ts @@ -0,0 +1,8 @@ +import elegantSpinner = require('elegant-spinner'); + +const frameFunction = elegantSpinner(); + +// $ExpectType string +frameFunction(); + +const frames = elegantSpinner.frames; diff --git a/types/elegant-spinner/index.d.ts b/types/elegant-spinner/index.d.ts new file mode 100644 index 0000000000..fbb8d4710a --- /dev/null +++ b/types/elegant-spinner/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for elegant-spinner 1.0 +// Project: https://github.com/sindresorhus/elegant-spinner +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = elegantSpinner; + +declare function elegantSpinner(): () => string; + +declare namespace elegantSpinner { + const frames: ReadonlyArray; +} diff --git a/types/elegant-spinner/tsconfig.json b/types/elegant-spinner/tsconfig.json new file mode 100644 index 0000000000..cdd768d4c6 --- /dev/null +++ b/types/elegant-spinner/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "elegant-spinner-tests.ts" + ] +} diff --git a/types/elegant-spinner/tslint.json b/types/elegant-spinner/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/elegant-spinner/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/env-paths/env-paths-tests.ts b/types/env-paths/env-paths-tests.ts new file mode 100644 index 0000000000..b143fb47b5 --- /dev/null +++ b/types/env-paths/env-paths-tests.ts @@ -0,0 +1,4 @@ +import envPaths = require('env-paths'); + +// $ExpectType Paths +envPaths('./'); diff --git a/types/env-paths/index.d.ts b/types/env-paths/index.d.ts new file mode 100644 index 0000000000..c759f3875c --- /dev/null +++ b/types/env-paths/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for env-paths 1.0 +// Project: https://github.com/sindresorhus/env-paths +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = envPaths; + +declare function envPaths(name: string, opts?: { suffix: string; }): envPaths.Paths; + +declare namespace envPaths { + interface Paths { + readonly data: string; + readonly config: string; + readonly cache: string; + readonly log: string; + readonly temp: string; + } +} diff --git a/types/env-paths/tsconfig.json b/types/env-paths/tsconfig.json new file mode 100644 index 0000000000..62dcbca022 --- /dev/null +++ b/types/env-paths/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "env-paths-tests.ts" + ] +} diff --git a/types/env-paths/tslint.json b/types/env-paths/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/env-paths/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/expired-storage/expired-storage-tests.ts b/types/expired-storage/expired-storage-tests.ts new file mode 100644 index 0000000000..5c1a814b23 --- /dev/null +++ b/types/expired-storage/expired-storage-tests.ts @@ -0,0 +1,69 @@ +import ExpiredStorage = require('expired-storage'); + +const expiredStorage = new ExpiredStorage(); + +const mjkModel = { + firstName: 'Maynard', + middleName: 'James', + familyName: 'Keenan', +}; + +expiredStorage.clear(); + +expiredStorage.setItem('tool', '46&2', 10); + +if (expiredStorage.getItem('tool') !== '46&2') { + throw new Error('.setItem method is not working!'); +} + +expiredStorage.setJson('mjk', mjkModel, 1); + +const mjkTest = expiredStorage.getJson('mjk'); + +if (typeof mjkTest === 'undefined' || mjkTest.firstName !== mjkModel.firstName || mjkTest.middleName !== mjkModel.middleName || mjkTest.familyName !== mjkModel.familyName) { + throw new Error('.setJson method is not working!'); +} + +const keyCheck = expiredStorage.keys(true); + +if (keyCheck && keyCheck.length === 2) { + throw new Error('.keys method has failed.'); +} + +expiredStorage.setItem('apc', 'brena', 2); + +const goBackToSleep = expiredStorage.peek('apc'); + +if (!goBackToSleep.isExpired && goBackToSleep.value !== 'brena') { + throw new Error('.peek -- we have expired early... or our value was incorrect...'); +} + +do { + // nothing here to see +} while (!expiredStorage.isExpired('apc')); + +const expiredKeys = expiredStorage.clearExpired(); + +if (expiredKeys.indexOf('apc') !== -1) { + throw new Error('.clearExpired did not work..'); +} + +if (expiredStorage.getItem('apc') !== null) { + throw new Error('Expiration as a whole does not work.'); +} + +expiredStorage.setItem('puscifer', 'the humbling river', 10000); + +expiredStorage.updateExpiration('puscifer', 5000); + +const checkKeyTime = expiredStorage.getTimeLeft('puscifer'); + +if (checkKeyTime && checkKeyTime >= 10000) { + throw new Error('.updateExpiration method is broken -- or .getTimeLeft method is broken.'); +} + +if (!expiredStorage.isExpired('mjk')) { + throw new Error('.isExpired or Expiration as a whole is not working...'); +} + +expiredStorage.clear(); diff --git a/types/expired-storage/index.d.ts b/types/expired-storage/index.d.ts new file mode 100644 index 0000000000..bc7f7eb0b5 --- /dev/null +++ b/types/expired-storage/index.d.ts @@ -0,0 +1,105 @@ +// Type definitions for extended-storage 1.0 +// Project: https://github.com/RonenNess/ExpiredStorage/ +// Definitions by: Allen Gammel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = ExpiredStorage; + +declare class ExpiredStorage { + constructor(localStorage?: any); + /** + * Clear the entire storage and all keys in it. + */ + clear(): void; + /** + * Get a json serializable value. This basically calls JSON.parse on the returned value. + * @param key Item key to get (string). + * @return Stored value (JSON.parsed), or undefined if not set / expired. + */ + getJson(key: string): any; + /** + * Get item. + * @param key: Item key to get (string). + * @return: Stored value, or undefined if not set / expired. + */ + getItem(key: string): string | null; + /** + * Remove an item. + * @param key Item key to remove (string). + * @return Storage.removeItem() return code. + */ + removeItem(key: string): any; + /** + * Set a json serializable value. This basically calls JSON.stringify on 'val' before setting it. + * @param key Item key to set (string). + * @param value Value to store (object, will be JSON.stringified). + * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. + * @param return Storage.setItem() return code. + */ + setJson(key: string, value: object, expirationTime?: number): any; + /** + * Set item. + * @param key Item key to set (string). + * @param value Value to store (string). + * @param expiration Expiration time, in seconds. If not provided, will not set expiration time. + * @return Storage.setItem() return code. + */ + setItem(key: string, value: string, expiration?: number): any; + /** + * Get all keys in storage, not including internal keys used to store expiration. + * @param: includeExpired: if true, will also include expired keys. + * @return: Array with keys. + */ + keys(includeExpired: boolean): string[] | null; + /** + * Get item time left to live. + * @param key Item key to get (string). + * @return Time left to expire (in seconds), or null if don't have expiration date. + */ + getTimeLeft(key: string): number | null; + /** + * Clear expired keys. + * If you never call this function, expired keys will remain until you try to get them / reset a new value. + * + * @param return: List of removed keys due to expiration. + */ + clearExpired(): string[]; + /** + * Return if an item is expired (don't remove it, even if expired). + * @param key Item key to check (string). + * @return True if expired, False otherwise. + */ + isExpired(key: string): boolean; + /** + * Get item + metadata such as time left and if expired. + * Even if item expired, will not remove it. + * @param key Item key to get (string). + * @return PeekInterface with: {value, timeLeft, isExpired} + */ + peek(key: string): ExpiredStorage.PeekInterface; + /** + * Update expiration time for an item (note: doesn't validate that the item is set). + * @param key: Item key to update expiration for (string). + * @param expiration: New expiration time in seconds to set. + * @return: Storage.setItem() return code for setting new expiration. + */ + updateExpiration(key: string, expiration: number): any; +} + +declare namespace ExpiredStorage { + interface PeekInterface { + /** + * The value of a [key] + */ + value: string | null; + /** + * Time remaining until expiration + */ + timeLeft: number | null; + /** + * Has the [key] expired or not + */ + isExpired: boolean; + } +} diff --git a/types/expired-storage/tsconfig.json b/types/expired-storage/tsconfig.json new file mode 100644 index 0000000000..cd1454cca7 --- /dev/null +++ b/types/expired-storage/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", + "expired-storage-tests.ts" + ] +} \ No newline at end of file diff --git a/types/expired-storage/tslint.json b/types/expired-storage/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/expired-storage/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index e5cbfc2432..783a4f41f7 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -1998,7 +1998,17 @@ interface IObjectOptions { */ scaleY?: number; - /** + /** + * Object skew factor (horizontal) + */ + skewX?: number; + + /** + * Object skew factor (vertical) + */ + skewY?: number; + + /** * When true, an object is rendered as flipped horizontally */ flipX?: boolean; @@ -2308,7 +2318,13 @@ export class Object { getScaleY(): number; setScaleY(value: number): Object; - setShadow(options: any): Object; + getSkewX(): number; + setSkewX(value: number): Object; + + getSkewY(): number; + setSkewY(value: number): Object; + + setShadow(options: any): Object; getShadow(): Object; stateProperties: any[]; diff --git a/types/fabric/test/index.ts b/types/fabric/test/index.ts index 1060525a00..9a5c0b24d2 100644 --- a/types/fabric/test/index.ts +++ b/types/fabric/test/index.ts @@ -872,7 +872,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration === 'underline' ? '' : 'underline'); - this.className = activeObject.textDecoration ? 'selected' : ''; + (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; canvas.renderAll(); } }; @@ -885,7 +885,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration === 'line-through' ? '' : 'line-through'); - this.className = activeObject.textDecoration ? 'selected' : ''; + (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; canvas.renderAll(); } }; @@ -898,7 +898,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration === 'overline' ? '' : 'overline'); - this.className = activeObject.textDecoration ? 'selected' : ''; + (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; canvas.renderAll(); } }; @@ -911,7 +911,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontWeight = (activeObject.fontWeight === 'bold' ? '' : 'bold'); - this.className = activeObject.fontWeight ? 'selected' : ''; + (this as HTMLElement).className = activeObject.fontWeight ? 'selected' : ''; canvas.renderAll(); } }; @@ -924,7 +924,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontStyle = (activeObject.fontStyle === 'italic' ? '' : 'italic'); - this.className = activeObject.fontStyle ? 'selected' : ''; + (this as HTMLElement).className = activeObject.fontStyle ? 'selected' : ''; canvas.renderAll(); } }; @@ -937,7 +937,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.shadow = !activeObject.shadow ? 'rgba(0,0,0,0.2) 2px 2px 10px' : ''; - this.className = activeObject.shadow ? 'selected' : ''; + (this as HTMLElement).className = activeObject.shadow ? 'selected' : ''; canvas.renderAll(); } }; diff --git a/types/filesystem/index.d.ts b/types/filesystem/index.d.ts index 93dbb35d61..76ac35668c 100644 --- a/types/filesystem/index.d.ts +++ b/types/filesystem/index.d.ts @@ -1,21 +1,21 @@ // Type definitions for File System API // Project: http://www.w3.org/TR/file-system-api/ -// Definitions by: Kon -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Definitions by: Kon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// interface LocalFileSystem { - + /** * Used for storage with no guarantee of persistence. */ - TEMPORARY:number; + TEMPORARY: number; /** * Used for storage that should not be removed by the user agent without application or user permission. */ - PERSISTENT:number; + PERSISTENT: number; /** * Requests a filesystem in which to store application data. @@ -24,50 +24,50 @@ interface LocalFileSystem { * @param successCallback The callback that is called when the user agent provides a filesystem. * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied. */ - requestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; - + requestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void; + /** * Allows the user to look up the Entry for a file or directory referred to by a local URL. * @param url A URL referring to a local file in a filesystem accessable via this API. * @param successCallback A callback that is called to report the Entry to which the supplied URL refers. * @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is denied. - */ - resolveLocalFileSystemURL(url:string, successCallback:EntryCallback, errorCallback?:ErrorCallback):void; + */ + resolveLocalFileSystemURL(url: string, successCallback: EntryCallback, errorCallback?: ErrorCallback): void; /** * see requestFileSystem. */ - webkitRequestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; + webkitRequestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void; } interface LocalFileSystemSync { /** * Used for storage with no guarantee of persistence. */ - TEMPORARY:number; + TEMPORARY: number; /** * Used for storage that should not be removed by the user agent without application or user permission. */ - PERSISTENT:number; + PERSISTENT: number; /** * Requests a filesystem in which to store application data. * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. * @param size This is an indicator of how much storage space, in bytes, the application expects to need. */ - requestFileSystemSync(type:number, size:number):FileSystemSync; + requestFileSystemSync(type: number, size: number): FileSystemSync; /** * Allows the user to look up the Entry for a file or directory referred to by a local URL. * @param url A URL referring to a local file in a filesystem accessable via this API. */ - resolveLocalFileSystemSyncURL(url:string):EntrySync; + resolveLocalFileSystemSyncURL(url: string): EntrySync; /** * see requestFileSystemSync */ - webkitRequestFileSystemSync(type:number, size:number):FileSystemSync; + webkitRequestFileSystemSync(type: number, size: number): FileSystemSync; } interface Metadata { @@ -75,31 +75,31 @@ interface Metadata { * This is the time at which the file or directory was last modified. * @readonly */ - modificationTime:Date; + modificationTime: Date; /** * The size of the file, in bytes. This must return 0 for directories. * @readonly */ - size:number; + size: number; } interface Flags { /** * Used to indicate that the user wants to create a file or directory if it was not previously there. */ - create?:boolean; + create?: boolean; /** * By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. */ - exclusive?:boolean; + exclusive?: boolean; } -/** +/** * This interface represents a file system. */ -interface FileSystem{ +interface FileSystem { /** * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. * @readonly @@ -118,38 +118,38 @@ interface Entry { /** * Entry is a file. */ - isFile:boolean; + isFile: boolean; /** * Entry is a directory. */ - isDirectory:boolean; + isDirectory: boolean; /** * Look up metadata about this entry. * @param successCallback A callback that is called with the time of the last modification. * @param errorCallback ErrorCallback A callback that is called when errors happen. */ - getMetadata(successCallback:MetadataCallback, errorCallback?:ErrorCallback):void; - + getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void; + /** * The name of the entry, excluding the path leading to it. */ - name:string; + name: string; /** * The full absolute path from the root to the entry. */ - fullPath:string; + fullPath: string; /** * The file system on which the entry resides. */ - filesystem:FileSystem; + filesystem: FileSystem; /** * Move an entry to a different location on the file system. It is an error to try to: - * + * * *
  • move a directory inside itself or to any child at any depth;
  • *
  • move an entry into its parent if a name different from its current one isn't provided;
  • @@ -161,12 +161,12 @@ interface Entry { * A move of a file on top of an existing file must attempt to delete and replace that file. * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. */ - moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; - + moveTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void; + /** * Copy an entry to a different location on the file system. It is an error to try to: - * - *
      + * + *
        *
      • copy a directory inside itself or to any child at any depth;
      • *
      • copy an entry into its parent if a name different from its current one isn't provided;
      • *
      • copy a file to a path occupied by a directory;
      • @@ -178,26 +178,26 @@ interface Entry { * * Directory copies are always recursive--that is, they copy all contents of the directory. */ - copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; - + copyTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void; + /** * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. */ - toURL():string; + toURL(): string; /** * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. * @param successCallback A callback that is called on success. * @param errorCallback A callback that is called when errors happen. */ - remove(successCallback:VoidCallback, errorCallback?:ErrorCallback):void; - + remove(successCallback: VoidCallback, errorCallback?: ErrorCallback): void; + /** * Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself. * @param successCallback A callback that is called to return the parent Entry. * @param errorCallback A callback that is called when errors happen. */ - getParent(successCallback:DirectoryEntryCallback, errorCallback?:ErrorCallback):void; + getParent(successCallback: DirectoryEntryCallback, errorCallback?: ErrorCallback): void; } /** @@ -207,13 +207,13 @@ interface DirectoryEntry extends Entry { /** * Creates a new DirectoryReader to read Entries from this Directory. */ - createReader():DirectoryReader; + createReader(): DirectoryReader; /** * Creates or looks up a file. * @param path Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist. * @param options - *
          + *
            *
          • If create and exclusive are both true, and the path already exists, getFile must fail.
          • *
          • If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
          • *
          • If create is not true and the path doesn't exist, getFile must fail.
          • @@ -223,12 +223,12 @@ interface DirectoryEntry extends Entry { * @param successCallback A callback that is called to return the File selected or created. * @param errorCallback A callback that is called when errors happen. */ - getFile(path:string, options?:Flags, successCallback?:FileEntryCallback, errorCallback?:ErrorCallback):void; - + getFile(path: string, options?: Flags, successCallback?: FileEntryCallback, errorCallback?: ErrorCallback): void; + /** * Creates or looks up a directory. * @param path Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist. - * @param options + * @param options *
              *
            • If create and exclusive are both true and the path already exists, getDirectory must fail.
            • *
            • If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
            • @@ -238,16 +238,16 @@ interface DirectoryEntry extends Entry { *
            * @param successCallback A callback that is called to return the DirectoryEntry selected or created. * @param errorCallback A callback that is called when errors happen. - * + * */ - getDirectory(path:string, options?:Flags, successCallback?:DirectoryEntryCallback, errorCallback?:ErrorCallback):void; - + getDirectory(path: string, options?: Flags, successCallback?: DirectoryEntryCallback, errorCallback?: ErrorCallback): void; + /** * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. * @param successCallback A callback that is called on success. * @param errorCallback A callback that is called when errors happen. */ - removeRecursively(successCallback:VoidCallback, errorCallback?:ErrorCallback):void; + removeRecursively(successCallback: VoidCallback, errorCallback?: ErrorCallback): void; } /** @@ -265,7 +265,7 @@ interface DirectoryReader { * @param successCallback Called once per successful call to readEntries to deliver the next previously-unreported set of Entries in the associated Directory. If all Entries have already been returned from previous invocations of readEntries, successCallback must be called with a zero-length array as an argument. * @param errorCallback A callback indicating that there was an error reading from the Directory. */ - readEntries(successCallback:EntriesCallback, errorCallback?:ErrorCallback):void; + readEntries(successCallback: EntriesCallback, errorCallback?: ErrorCallback): void; } /** @@ -277,14 +277,14 @@ interface FileEntry extends Entry { * @param successCallback A callback that is called with the new FileWriter. * @param errorCallback A callback that is called when errors happen. */ - createWriter(successCallback:FileWriterCallback, errorCallback?:ErrorCallback):void; + createWriter(successCallback: FileWriterCallback, errorCallback?: ErrorCallback): void; /** * Returns a File that represents the current state of the file that this FileEntry represents. * @param successCallback A callback that is called with the File. * @param errorCallback A callback that is called when errors happen. */ - file(successCallback:FileCallback, errorCallback?:ErrorCallback):void; + file(successCallback: FileCallback, errorCallback?: ErrorCallback): void; } /** @@ -294,7 +294,7 @@ interface FileSystemCallback { /** * @param filesystem The file systems to which the app is granted access. */ - (filesystem:FileSystem):void; + (filesystem: FileSystem): void; } /** @@ -304,7 +304,7 @@ interface EntryCallback { /** * @param entry */ - (entry:Entry):void; + (entry: Entry): void; } /** @@ -314,7 +314,7 @@ interface FileEntryCallback { /** * @param entry */ - (entry:FileEntry):void; + (entry: FileEntry): void; } /** @@ -324,102 +324,102 @@ interface DirectoryEntryCallback { /** * @param entry */ - (entry:DirectoryEntry):void; + (entry: DirectoryEntry): void; } /** * When readEntries() succeeds, the following callback is made. */ interface EntriesCallback { - (entries:Entry[]):void; + (entries: Entry[]): void; } /** * This interface is the callback used to look up file and directory metadata. */ interface MetadataCallback { - (metadata:Metadata):void; + (metadata: Metadata): void; } /** * This interface is the callback used to create a FileWriter. - */ + */ interface FileWriterCallback { - (fileWriter:FileWriter):void; + (fileWriter: FileWriter): void; } /** * This interface is the callback used to obtain a File. */ interface FileCallback { - (file:File):void; + (file: File): void; } -/** +/** * This interface is the generic callback used to indicate success of an asynchronous method. - */ + */ interface VoidCallback { - ():void; + (): void; } /** * When an error occurs, the following callback is made. */ interface ErrorCallback { - (err:DOMError):void; + (err: DOMError): void; } -/** +/** * This interface represents a file system. */ interface FileSystemSync { /** * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. */ - name:string; + name: string; /** * root The root directory of the file system. */ - root:DirectoryEntrySync; + root: DirectoryEntrySync; } /** * An abstract interface representing entries in a file system, each of which may be a FileEntrySync or DirectoryEntrySync. */ -interface EntrySync{ +interface EntrySync { /** * EntrySync is a file. * @readonly */ - isFile:boolean; + isFile: boolean; /** * EntrySync is a directory. * @readonly */ - isDirectory:boolean; + isDirectory: boolean; /** * Look up metadata about this entry. */ - getMetadata():Metadata; - + getMetadata(): Metadata; + /** * The name of the entry, excluding the path leading to it. */ - name:string; + name: string; /** * The full absolute path from the root to the entry. */ - fullPath:string; + fullPath: string; /** * The file system on which the entry resides. */ - filesystem:FileSystemSync; + filesystem: FileSystemSync; /** * Move an entry to a different location on the file system. It is an error to try to: @@ -429,12 +429,12 @@ interface EntrySync{ *
          • move a file to a path occupied by a directory;
          • *
          • move a directory to a path occupied by a file;
          • *
          • move any element to a path occupied by a directory which is not empty.
          • - * + * * A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. * @param parent The directory to which to move the entry. * @param newName The new name of the entry. Defaults to the EntrySync's current name if unspecified. */ - moveTo(parent:DirectoryEntrySync, newName?:string):EntrySync; + moveTo(parent: DirectoryEntrySync, newName?: string): EntrySync; /** * Copy an entry to a different location on the file system. It is an error to try to: @@ -444,27 +444,27 @@ interface EntrySync{ *
          • copy a file to a path occupied by a directory;
          • *
          • copy a directory to a path occupied by a file;
          • *
          • copy any element to a path occupied by a directory which is not empty.
          • - * + * * A copy of a file on top of an existing file must attempt to delete and replace that file. * A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory. * Directory copies are always recursive--that is, they copy all contents of the directory. */ - copyTo(parent:DirectoryEntrySync, newName?:string):EntrySync; + copyTo(parent: DirectoryEntrySync, newName?: string): EntrySync; /** * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. */ - toURL():string; + toURL(): string; /** * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. */ - remove ():void; + remove(): void; /** * Look up the parent DirectoryEntrySync containing this Entry. If this EntrySync is the root of its filesystem, its parent is itself. */ - getParent():DirectoryEntrySync; + getParent(): DirectoryEntrySync; } /** @@ -474,12 +474,12 @@ interface DirectoryEntrySync extends EntrySync { /** * Creates a new DirectoryReaderSync to read EntrySyncs from this DirectorySync. */ - createReader():DirectoryReaderSync; + createReader(): DirectoryReaderSync; - /** + /** * Creates or looks up a directory. * @param path Either an absolute path or a relative path from this DirectoryEntrySync to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist. - * @param options + * @param options *
              *
            • If create and exclusive are both true and the path already exists, getFile must fail.
            • *
            • If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
            • @@ -488,12 +488,12 @@ interface DirectoryEntrySync extends EntrySync { *
            • Otherwise, if no other error occurs, getFile must return a FileEntrySync corresponding to path.
            • *
            */ - getFile(path:string, options?:Flags):FileEntrySync; + getFile(path: string, options?: Flags): FileEntrySync; - /** + /** * Creates or looks up a directory. * @param path Either an absolute path or a relative path from this DirectoryEntrySync to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist. - * @param options + * @param options *
              *
            • If create and exclusive are both true and the path already exists, getDirectory must fail.
            • *
            • If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
            • @@ -502,12 +502,12 @@ interface DirectoryEntrySync extends EntrySync { *
            • Otherwise, if no other error occurs, getDirectory must return a DirectoryEntrySync corresponding to path.
            • *
            */ - getDirectory(path:string, options?:Flags):DirectoryEntrySync; + getDirectory(path: string, options?: Flags): DirectoryEntrySync; /** * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. */ - removeRecursively():void; + removeRecursively(): void; } /** @@ -523,7 +523,7 @@ interface DirectoryReaderSync { /** * Read the next block of entries from this directory. */ - readEntries():EntrySync[]; + readEntries(): EntrySync[]; } /** @@ -533,16 +533,16 @@ interface FileEntrySync extends EntrySync { /** * Creates a new FileWriterSync associated with the file that this FileEntrySync represents. */ - createWriter():FileWriterSync; + createWriter(): FileWriterSync; /** * Returns a File that represents the current state of the file that this FileEntrySync represents. */ - file():File; + file(): File; } -interface Window extends LocalFileSystem, LocalFileSystemSync{ +interface Window extends LocalFileSystem, LocalFileSystemSync { } -interface WorkerGlobalScope extends LocalFileSystem, LocalFileSystemSync{ +interface WorkerGlobalScope extends LocalFileSystem, LocalFileSystemSync { } diff --git a/types/gamedig/gamedig-tests.ts b/types/gamedig/gamedig-tests.ts new file mode 100644 index 0000000000..3af9334b70 --- /dev/null +++ b/types/gamedig/gamedig-tests.ts @@ -0,0 +1,18 @@ +import Gamedig = require("gamedig"); + +Gamedig.query({ + type: "tf2", + host: "127.0.0.1" +}, (error, state) => { + if (error) throw error(); + + const { + name, + map, + password, + maxplayers, + players, + bots, + notes + } = state; +}); diff --git a/types/gamedig/index.d.ts b/types/gamedig/index.d.ts new file mode 100644 index 0000000000..a2ccf75de9 --- /dev/null +++ b/types/gamedig/index.d.ts @@ -0,0 +1,285 @@ +// Type definitions for Gamedig 1.0 +// Project: https://github.com/sonicsnes/node-gamedig +// Definitions by: Ivan Sieder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export type Type = + "7d2d" + | "ageofchivalry" + | "aoe2" + | "alienarena" + | "alienswarm" + | "arkse" + | "avp2" + | "avp2010" + | "americasarmy" + | "americasarmy2" + | "americasarmy3" + | "americasarmypg" + | "arma" + | "arma2" + | "arma3" + | "armagetron" + | "baldursgate" + | "bat1944" + | "bf1942" + | "bfv" + | "bf2" + | "bf2142" + | "bfbc2" + | "bf3" + | "bf4" + | "bfh" + | "breach" + | "breed" + | "brink" + | "buildandshoot" + | "cod" + | "coduo" + | "cod2" + | "cod3" + | "cod4" + | "codwaw" + | "codmw2" + | "codmw3" + | "callofjuarez" + | "chaser" + | "chrome" + | "codenameeagle" + | "commandos3" + | "cacrenegade" + | "conanexiles" + | "contactjack" + | "cs16" + | "cscz" + | "css" + | "csgo" + | "crossracing" + | "crysis" + | "crysiswars" + | "crysis2" + | "daikatana" + | "dmomam" + | "darkesthour" + | "dayz" + | "dayzmod" + | "deadlydozenpt" + | "dh2005" + | "descent3" + | "deusex" + | "devastation" + | "dinodday" + | "dirttrackracing2" + | "dnl" + | "dod" + | "dods" + | "doi" + | "doom3" + | "dota2" + | "drakan" + | "etqw" + | "fear" + | "f12002" + | "f1c9902" + | "farcry" + | "farcry2" + | "fortressforever" + | "flashpoint" + | "ffow" + | "fivem" + | "garrysmod" + | "graw" + | "graw2" + | "giantscitizenkabuto" + | "globaloperations" + | "geneshift" + | "ges" + | "gore" + | "gunmanchronicles" + | "hldm" + | "hl2dm" + | "halo" + | "halo2" + | "heretic2" + | "hexen2" + | "hidden" + | "had2" + | "homefront" + | "homeworld2" + | "hurtworld" + | "igi2" + | "il2" + | "insurgency" + | "ironstorm" + | "jamesbondnightfire" + | "jc2mp" + | "killingfloor" + | "killingfloor2" + | "kingpin" + | "kisspc" + | "kspdmp" + | "kzmod" + | "left4dead" + | "left4dead2" + | "m2mp" + | "medievalengineers" + | "mohaa" + | "mohpa" + | "mohab" + | "mohsh" + | "mohbt" + | "moh2010" + | "mohwf" + | "minecraft" + | "minecraftpe" + | "minecraftping" + | "mnc" + | "mtavc" + | "mtasa" + | "mumble" + | "mumbleping" + | "mutantfactions" + | "nascarthunder2004" + | "netpanzer" + | "nmrih" + | "ns" + | "ns2" + | "nfshp2" + | "nab" + | "nwn" + | "nwn2" + | "nexuiz" + | "nitrofamily" + | "nolf" + | "nolf2" + | "nucleardawn" + | "openarena" + | "openttd" + | "operationflashpoint" + | "painkiller" + | "postal2" + | "prey" + | "primalcarnage" + | "quake1" + | "quake2" + | "quake3" + | "quake4" + | "ragdollkungfu" + | "r6" + | "r6roguespear" + | "r6ravenshield" + | "rallisportchallenge" + | "rallymasters" + | "redorchestra" + | "redorchestraost" + | "redorchestra2" + | "redline" + | "rtcw" + | "ricochet" + | "riseofnations" + | "rune" + | "rust" + | "samp" + | "spaceengineers" + | "ss" + | "ss2" + | "shatteredhorizon" + | "ship" + | "shogo" + | "shootmania" + | "sin" + | "sinep" + | "soldat" + | "sof" + | "sof2" + | "stalker" + | "stbc" + | "stvef" + | "stvef2" + | "swbf" + | "swbf2" + | "swjk" + | "swjk2" + | "swrc" + | "starbound" + | "starmade" + | "suicidesurvival" + | "swat4" + | "svencoop" + | "synergy" + | "tacticalops" + | "teamfactor" + | "tfc" + | "tf2" + | "teamspeak2" + | "teamspeak3" + | "terminus" + | "terraria" + | "thps3" + | "thps4" + | "thu2" + | "towerunite" + | "trackmania2" + | "trackmaniaforever" + | "tremulous" + | "tribes1" + | "tribesvengeance" + | "tron20" + | "turok2" + | "universalcombat" + | "unreal" + | "unturned" + | "ut" + | "ut2003" + | "ut2004" + | "ut3" + | "urbanterror" + | "v8supercar" + | "ventrilo" + | "vietcong" + | "vietcong2" + | "warsow" + | "wheeloftime" + | "wolfenstein2009" + | "wolfensteinet" + | "xpandrally" + | "zombiemaster" + | "zps"; + +export interface Player { + name?: string; + ping?: number; + score?: number; + team?: string; + address?: string; +} + +export interface QueryOptions { + type: Type; + host: string; + port?: number; + notes?: object; + maxAttempts?: number; + socketTimeout?: number; + attemptTimeout?: number; +} + +export interface QueryResult { + name: string; + map: string; + password: boolean; + maxplayers: number; + players: Player[]; + bots: Player[]; + notes: object; + raw?: object; + query?: object; +} + +export function query( + options: QueryOptions, + callback: (error: any, state: QueryResult) => void +): void; + +export function query(options: QueryOptions): Promise; diff --git a/types/gamedig/tsconfig.json b/types/gamedig/tsconfig.json new file mode 100644 index 0000000000..ae26ece7da --- /dev/null +++ b/types/gamedig/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gamedig-tests.ts" + ] +} diff --git a/types/gamedig/tslint.json b/types/gamedig/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gamedig/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/google-cloud__storage/index.d.ts b/types/google-cloud__storage/index.d.ts index 18ac093c5d..2053abcc62 100644 --- a/types/google-cloud__storage/index.d.ts +++ b/types/google-cloud__storage/index.d.ts @@ -104,10 +104,12 @@ declare namespace Storage { interface BucketQuery { autoPaginate?: boolean; delimiter?: string; + directory?: string; prefix?: string; maxApiCalls?: number; maxResults?: number; pageToken?: string; + userProject?: string; versions?: boolean; } diff --git a/types/gulp-imagemin/gulp-imagemin-tests.ts b/types/gulp-imagemin/gulp-imagemin-tests.ts index 7fc1d86311..839e126fe2 100644 --- a/types/gulp-imagemin/gulp-imagemin-tests.ts +++ b/types/gulp-imagemin/gulp-imagemin-tests.ts @@ -1,20 +1,33 @@ -import * as GulpImagemin from 'gulp-imagemin'; +import gulp = require('gulp'); +import gulpImagemin = require('gulp-imagemin'); -GulpImagemin(); +const plugins = [ + gulpImagemin.gifsicle({ interlaced: true }), + gulpImagemin.jpegtran({ progressive: true }), + gulpImagemin.optipng({ optimizationLevel: 5 }), + gulpImagemin.svgo({ floatPrecision: 2 }) +]; -GulpImagemin([ - GulpImagemin.gifsicle({ interlaced: true }), - GulpImagemin.jpegtran({ progressive: true }), - GulpImagemin.optipng({ optimizationLevel: 5 }), - GulpImagemin.svgo({ - plugins: [{ removeViewBox: true }, { cleanupIDs: false }] - }) -]); +gulp.task('build', () => { + return gulp.src('*.{gif,jpg,png,svg}') + .pipe(gulpImagemin()) + .pipe(gulp.dest('dist')); +}); -GulpImagemin({ verbose: true }); +gulp.task('build', () => { + return gulp.src('*.{gif,jpg,png,svg}') + .pipe(gulpImagemin(plugins)) + .pipe(gulp.dest('dist')); +}); -GulpImagemin([ - GulpImagemin.svgo({ - plugins: [{ removeViewBox: true }] - }) -], { verbose: true }); +gulp.task('build', () => { + return gulp.src('*.{gif,jpg,png,svg}') + .pipe(gulpImagemin({ verbose: true })) + .pipe(gulp.dest('dist')); +}); + +gulp.task('build', () => { + return gulp.src('*.{gif,jpg,png,svg}') + .pipe(gulpImagemin(plugins, { verbose: true })) + .pipe(gulp.dest('dist')); +}); diff --git a/types/gulp-imagemin/index.d.ts b/types/gulp-imagemin/index.d.ts index 42c1ef8d5c..ac61547a74 100644 --- a/types/gulp-imagemin/index.d.ts +++ b/types/gulp-imagemin/index.d.ts @@ -2,26 +2,31 @@ // Project: https://github.com/sindresorhus/gulp-imagemin#readme // Definitions by: Romain Faust // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// +import { Plugin } from 'imagemin'; +import { Options as GifsicleOptions } from 'imagemin-gifsicle'; +import { Options as JpegtranOptions } from 'imagemin-jpegtran'; +import { Options as OptipngOptions } from 'imagemin-optipng'; +import { Options as SvgoOptions } from 'imagemin-svgo'; import { Transform } from 'stream'; -declare function imagemin(pluginsOrOptions?: imagemin.Plugin[] | imagemin.Options): Transform; -declare function imagemin(plugins?: imagemin.Plugin[], options?: imagemin.Options): Transform; +declare function imagemin(pluginsOrOptions?: ReadonlyArray | imagemin.Options): Transform; +declare function imagemin(plugins?: ReadonlyArray, options?: imagemin.Options): Transform; declare namespace imagemin { interface Options { verbose?: boolean; } - type Plugin = (input: any) => Promise; - type PluginFactory = (options?: any) => Plugin; + type PluginFactory = (options?: T) => Plugin; - const gifsicle: PluginFactory; - const jpegtran: PluginFactory; - const optipng: PluginFactory; - const svgo: PluginFactory; + const gifsicle: PluginFactory; + const jpegtran: PluginFactory; + const optipng: PluginFactory; + const svgo: PluginFactory; } export = imagemin; diff --git a/types/gulp-jsonmin/gulp-jsonmin-tests.ts b/types/gulp-jsonmin/gulp-jsonmin-tests.ts index 5c0cf66cc3..e13ec2c69f 100644 --- a/types/gulp-jsonmin/gulp-jsonmin-tests.ts +++ b/types/gulp-jsonmin/gulp-jsonmin-tests.ts @@ -1,5 +1,14 @@ -import * as GulpJsonmin from 'gulp-jsonmin'; +import gulp = require('gulp'); +import gulpJsonmin = require('gulp-jsonmin'); -GulpJsonmin(); -GulpJsonmin({}); -GulpJsonmin({ verbose: true }); +gulp.task('build', () => { + return gulp.src('*.json') + .pipe(gulpJsonmin()) + .pipe(gulp.dest('dist')); +}); + +gulp.task('build', () => { + return gulp.src('*.json') + .pipe(gulpJsonmin({ verbose: true })) + .pipe(gulp.dest('dist')); +}); diff --git a/types/gulp-jsonmin/index.d.ts b/types/gulp-jsonmin/index.d.ts index 16a4347dd2..d5faa2b969 100644 --- a/types/gulp-jsonmin/index.d.ts +++ b/types/gulp-jsonmin/index.d.ts @@ -7,12 +7,12 @@ import { Transform } from 'stream'; -declare function jsonmin(options?: jsonmin.Options): Transform; +declare function gulpJsonmin(options?: gulpJsonmin.Options): Transform; -declare namespace jsonmin { +declare namespace gulpJsonmin { interface Options { verbose?: boolean; } } -export = jsonmin; +export = gulpJsonmin; diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 3d3b69b959..b152d34e5b 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -2904,7 +2904,7 @@ export interface ServerOptions { * Default value: none. * Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation. */ - tls?: boolean | https.RequestOptions; + tls?: boolean | https.ServerOptions; /** * Default value: constructed from runtime server information. diff --git a/types/hat/hat-tests.ts b/types/hat/hat-tests.ts new file mode 100644 index 0000000000..3156a138f0 --- /dev/null +++ b/types/hat/hat-tests.ts @@ -0,0 +1,10 @@ +import hat = require('hat'); + +const randomId = hat(); + +const rack = hat.rack(); +rack('car'); +const tractorId = rack('tractor'); +rack.get(tractorId); +rack.set(randomId, 'bicycle'); +rack.hats; diff --git a/types/hat/index.d.ts b/types/hat/index.d.ts new file mode 100644 index 0000000000..58a7bdc983 --- /dev/null +++ b/types/hat/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for hat 0.0 +// Project: https://github.com/substack/node-hat +// Definitions by: Sasha Grin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface HatsList { + [key: string]: any; +} + +interface Rack { + bits: number; + base: number; + hats: HatsList; + + (data: any): string; + get(id: string): any; + set(id: string, value: any): Rack; +} + +type CreateRack = (bits?: number, base?: number, expandBy?: number) => Rack; + +interface Hat { + (bits?: number, base?: number): string; + rack: CreateRack; +} + +declare const hat: Hat; +export = hat; diff --git a/types/hat/tsconfig.json b/types/hat/tsconfig.json new file mode 100644 index 0000000000..c13e03fd48 --- /dev/null +++ b/types/hat/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es5" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hat-tests.ts" + ] +} diff --git a/types/hat/tslint.json b/types/hat/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hat/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/hedron/hedron-tests.tsx b/types/hedron/hedron-tests.tsx index 8b2ce82f01..3fe25ddff1 100644 --- a/types/hedron/hedron-tests.tsx +++ b/types/hedron/hedron-tests.tsx @@ -4,7 +4,29 @@ import * as hedron from 'hedron'; - test + + test + ; + +// withBreakpoints test +interface Props { + numeric: number; + str: string; +} + +class ComponentWithBreakpoints extends React.Component { + render() { + // `breakpoints` prop is accessible in component + this.props.breakpoints; + + return null; + } +} + +const WithBreakpoints = hedron.withBreakpoints(ComponentWithBreakpoints); + +// breakpoints props is not needed +; diff --git a/types/hedron/index.d.ts b/types/hedron/index.d.ts index 1e19aaee7a..8ce464c017 100644 --- a/types/hedron/index.d.ts +++ b/types/hedron/index.d.ts @@ -150,8 +150,14 @@ export interface HiddenProps { lg?: boolean; } -export interface BreakpointProviderProps { - breakpoints: { sm?: number; md?: number; lg?: number }; +export interface Breakpoints { + sm?: number; + md?: number; + lg?: number; +} + +export interface BreakpointsProps { + breakpoints: Breakpoints; } export class Column extends React.Component> {} @@ -159,8 +165,8 @@ export class Page extends React.Component> {} export class Hidden extends React.Component> {} export class BreakpointProvider extends React.Component< - BreakpointProviderProps & React.HTMLProps + BreakpointsProps & React.HTMLProps > {} export function withBreakpoints( - wrappedComponent: React.ComponentClass + wrappedComponent: React.ComponentClass ): React.ComponentClass; diff --git a/types/helmet/helmet-tests.ts b/types/helmet/helmet-tests.ts index 53fba8e948..afedea6c23 100644 --- a/types/helmet/helmet-tests.ts +++ b/types/helmet/helmet-tests.ts @@ -58,6 +58,7 @@ function contentSecurityPolicyTest() { directives: { defaultSrc: ["'self'"] }, + loose: false, setAllHeaders: true })); } diff --git a/types/helmet/index.d.ts b/types/helmet/index.d.ts index 1abe99c20f..6f89728e8a 100644 --- a/types/helmet/index.d.ts +++ b/types/helmet/index.d.ts @@ -60,6 +60,7 @@ declare namespace helmet { disableAndroid?: boolean; browserSniff?: boolean; directives?: IHelmetContentSecurityPolicyDirectives; + loose?: boolean; } export interface IHelmetDnsPrefetchControlConfiguration { diff --git a/types/i18next/index.d.ts b/types/i18next/index.d.ts index 7674762de6..484745bcad 100644 --- a/types/i18next/index.d.ts +++ b/types/i18next/index.d.ts @@ -97,17 +97,29 @@ declare namespace i18next { interface ReactOptions { /** * set to true if you like to wait for loaded in every translated hoc + * @default false */ wait?: boolean; /** * set it to fallback to let passed namespaces to translated hoc act as fallbacks + * @default 'default' */ - nsMode?: string; + nsMode?: 'default' | 'fallback'; /** * set it to the default parent element created by the Trans component. - * @default div + * @default 'div' */ defaultTransParent?: string; + /** + * set which events trigger a rerender, can be set to false or string of events + * @default 'languageChanged loaded' + */ + bindI18n?: string | false; + /** + * set which events on store trigger a rerender, can be set to false or string of events + * @default 'added removed' + */ + bindStore?: string | false; } interface InitOptions { diff --git a/types/imagemin-gifsicle/imagemin-gifsicle-tests.ts b/types/imagemin-gifsicle/imagemin-gifsicle-tests.ts new file mode 100644 index 0000000000..0156322cd7 --- /dev/null +++ b/types/imagemin-gifsicle/imagemin-gifsicle-tests.ts @@ -0,0 +1,9 @@ +import imagemin = require('imagemin'); +import imageminGifsicle = require('imagemin-gifsicle'); + +imagemin(['*.gif'], { + plugins: [ + imageminGifsicle(), + imageminGifsicle({ colors: 255 }) + ] +}); diff --git a/types/imagemin-gifsicle/index.d.ts b/types/imagemin-gifsicle/index.d.ts new file mode 100644 index 0000000000..80bc128286 --- /dev/null +++ b/types/imagemin-gifsicle/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for imagemin-gifsicle 5.2 +// Project: https://github.com/imagemin/imagemin-gifsicle#readme +// Definitions by: Romain Faust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'imagemin'; + +declare function imageminGifsicle(options?: imageminGifsicle.Options): Plugin; + +declare namespace imageminGifsicle { + interface Options { + colors?: number; + interlaced?: boolean; + optimizationLevel?: number; + } +} + +export = imageminGifsicle; diff --git a/types/imagemin-gifsicle/tsconfig.json b/types/imagemin-gifsicle/tsconfig.json new file mode 100644 index 0000000000..8efb698e59 --- /dev/null +++ b/types/imagemin-gifsicle/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", + "imagemin-gifsicle-tests.ts" + ] +} diff --git a/types/imagemin-gifsicle/tslint.json b/types/imagemin-gifsicle/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/imagemin-gifsicle/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/imagemin-jpegtran/imagemin-jpegtran-tests.ts b/types/imagemin-jpegtran/imagemin-jpegtran-tests.ts new file mode 100644 index 0000000000..82a8ea927f --- /dev/null +++ b/types/imagemin-jpegtran/imagemin-jpegtran-tests.ts @@ -0,0 +1,9 @@ +import imagemin = require('imagemin'); +import imageminJpegtran = require('imagemin-jpegtran'); + +imagemin(['*.jpg'], { + plugins: [ + imageminJpegtran(), + imageminJpegtran({ progressive: true }) + ] +}); diff --git a/types/imagemin-jpegtran/index.d.ts b/types/imagemin-jpegtran/index.d.ts new file mode 100644 index 0000000000..2ec98c3c17 --- /dev/null +++ b/types/imagemin-jpegtran/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for imagemin-jpegtran 5.0 +// Project: https://github.com/imagemin/imagemin-jpegtran#readme +// Definitions by: Romain Faust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'imagemin'; + +declare function imageminJpegtran(options?: imageminJpegtran.Options): Plugin; + +declare namespace imageminJpegtran { + interface Options { + arithmetic?: boolean; + progressive?: boolean; + } +} + +export = imageminJpegtran; diff --git a/types/imagemin-jpegtran/tsconfig.json b/types/imagemin-jpegtran/tsconfig.json new file mode 100644 index 0000000000..e26dc49c0e --- /dev/null +++ b/types/imagemin-jpegtran/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", + "imagemin-jpegtran-tests.ts" + ] +} diff --git a/types/imagemin-jpegtran/tslint.json b/types/imagemin-jpegtran/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/imagemin-jpegtran/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/imagemin-optipng/imagemin-optipng-tests.ts b/types/imagemin-optipng/imagemin-optipng-tests.ts new file mode 100644 index 0000000000..ce0eb272ee --- /dev/null +++ b/types/imagemin-optipng/imagemin-optipng-tests.ts @@ -0,0 +1,9 @@ +import imagemin = require('imagemin'); +import imageminOptipng = require('imagemin-optipng'); + +imagemin(['*.png'], { + plugins: [ + imageminOptipng(), + imageminOptipng({ optimizationLevel: 2 }) + ] +}); diff --git a/types/imagemin-optipng/index.d.ts b/types/imagemin-optipng/index.d.ts new file mode 100644 index 0000000000..9ab9506205 --- /dev/null +++ b/types/imagemin-optipng/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for imagemin-optipng 5.2 +// Project: https://github.com/imagemin/imagemin-optipng#readme +// Definitions by: Romain Faust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'imagemin'; + +declare function imageminOptipng(options?: imageminOptipng.Options): Plugin; + +declare namespace imageminOptipng { + interface Options { + bitDepthReduction?: boolean; + colorTypeReduction?: boolean; + optimizationLevel?: number; + paletteReduction?: boolean; + } +} + +export = imageminOptipng; diff --git a/types/imagemin-optipng/tsconfig.json b/types/imagemin-optipng/tsconfig.json new file mode 100644 index 0000000000..586e747281 --- /dev/null +++ b/types/imagemin-optipng/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", + "imagemin-optipng-tests.ts" + ] +} diff --git a/types/imagemin-optipng/tslint.json b/types/imagemin-optipng/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/imagemin-optipng/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/imagemin-svgo/imagemin-svgo-tests.ts b/types/imagemin-svgo/imagemin-svgo-tests.ts new file mode 100644 index 0000000000..23895afcd6 --- /dev/null +++ b/types/imagemin-svgo/imagemin-svgo-tests.ts @@ -0,0 +1,9 @@ +import imagemin = require('imagemin'); +import imageminSvgo = require('imagemin-svgo'); + +imagemin(['*.svg'], { + plugins: [ + imageminSvgo(), + imageminSvgo({ floatPrecision: 2 }) + ] +}); diff --git a/types/imagemin-svgo/index.d.ts b/types/imagemin-svgo/index.d.ts new file mode 100644 index 0000000000..24d3b73ca9 --- /dev/null +++ b/types/imagemin-svgo/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for imagemin-svgo 7.0 +// Project: https://github.com/imagemin/imagemin-svgo#readme +// Definitions by: Romain Faust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Plugin } from 'imagemin'; +import { Options as SvgoOptions } from 'svgo'; + +declare function imageminSvgo(options?: imageminSvgo.Options): Plugin; + +declare namespace imageminSvgo { + type Options = SvgoOptions; +} + +export = imageminSvgo; diff --git a/types/imagemin-svgo/tsconfig.json b/types/imagemin-svgo/tsconfig.json new file mode 100644 index 0000000000..6b4f221e13 --- /dev/null +++ b/types/imagemin-svgo/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", + "imagemin-svgo-tests.ts" + ] +} diff --git a/types/imagemin-svgo/tslint.json b/types/imagemin-svgo/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/imagemin-svgo/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index 3bd04944db..017fc04505 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ioredis 3.2 +// Type definitions for ioredis 4.0 // Project: https://github.com/luin/ioredis // Definitions by: York Yao // Christopher Eck @@ -12,12 +12,11 @@ /* =================== USAGE =================== import * as Redis from "ioredis"; - var redis = new Redis(); + const redis = new Redis(); =============================================== */ /// -import Promise = require('bluebird'); import tls = require('tls'); interface RedisStatic { @@ -842,6 +841,17 @@ declare namespace IORedis { * Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858 */ retryStrategy?(times: number): number | false; + /** + * By default, all pending commands will be flushed with an error every + * 20 retry attempts. That makes sure commands won't wait forever when + * the connection is down. You can change this behavior by setting + * `maxRetriesPerRequest`. + * + * Set maxRetriesPerRequest to `null` to disable this behavior, and + * every command will wait forever until the connection is alive again + * (which is the default behavior before ioredis v4). + */ + maxRetriesPerRequest?: number | null; /** * 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore * the error and do nothing. diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index 106a50210b..848f0b2841 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -46,6 +46,7 @@ new Redis({ password: 'auth', db: 0, retryStrategy() { return false; }, + maxRetriesPerRequest: 20, showFriendlyErrorStack: true, tls: { servername: 'tlsservername' @@ -129,9 +130,6 @@ redis.multi([ // results = [[null, 'OK'], [null, 'bar']] }); -redis.Promise.onPossiblyUnhandledRejection((error) => { -}); - const keys = ['foo', 'bar']; redis.mget(...keys); diff --git a/types/ioredis/v3/index.d.ts b/types/ioredis/v3/index.d.ts new file mode 100644 index 0000000000..e593f4dcc3 --- /dev/null +++ b/types/ioredis/v3/index.d.ts @@ -0,0 +1,911 @@ +// Type definitions for ioredis 3.2 +// Project: https://github.com/luin/ioredis +// Definitions by: York Yao +// Christopher Eck +// Yoga Aliarham +// Ebrahim +// Shahar Mor +// Whemoon Jang +// Francis Gulotta +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +/* =================== USAGE =================== + import * as Redis from "ioredis"; + var redis = new Redis(); + =============================================== */ + +/// + +import Promise = require('bluebird'); +import tls = require('tls'); + +interface RedisStatic { + new(port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + new(host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + new(options?: IORedis.RedisOptions): IORedis.Redis; + (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; + (options?: IORedis.RedisOptions): IORedis.Redis; + Cluster: IORedis.Cluster; + Command: IORedis.Command; +} + +declare var IORedis: RedisStatic; +export = IORedis; + +declare class Commander { + getBuiltinCommands(): string[]; + createBuiltinCommand(commandName: string): {}; + defineCommand(name: string, definition: { + numberOfKeys?: number; + lua?: string; + }): any; + sendCommand(): void; +} + +declare namespace IORedis { + interface Command { + setArgumentTransformer(name: string, fn: (args: any[]) => any[]): void; + setReplyTransformer(name: string, fn: (result: any) => any): void; + } + + interface Redis extends NodeJS.EventEmitter, Commander { + Promise: typeof Promise; + status: string; + connect(callback?: () => void): Promise; + disconnect(): void; + duplicate(): Redis; + + send_command(command: string, ...args: any[]): any; + + bitcount(key: string, callback: (err: Error, res: number) => void): void; + bitcount(key: string, start: number, end: number, callback: (err: Error, res: number) => void): void; + bitcount(key: string): Promise; + bitcount(key: string, start: number, end: number): Promise; + + get(key: string, callback: (err: Error, res: string) => void): void; + get(key: string): Promise; + + getBuffer(key: string, callback: (err: Error, res: Buffer) => void): void; + getBuffer(key: string): Promise; + + set(key: string, value: any, expiryMode?: string | any[], time?: number | string, setMode?: number | string): Promise; + + set(key: string, value: any, callback: (err: Error, res: string) => void): void; + set(key: string, value: any, setMode: string | any[], callback: (err: Error, res: string) => void): void; + set(key: string, value: any, expiryMode: string, time: number | string, callback: (err: Error, res: string) => void): void; + set(key: string, value: any, expiryMode: string, time: number | string, setMode: number | string, callback: (err: Error, res: string) => void): void; + + setBuffer(key: string, value: any, expiryMode?: string | any[], time?: number | string, setMode?: number | string): Promise; + + setBuffer(key: string, value: any, callback: (err: Error, res: Buffer) => void): void; + setBuffer(key: string, value: any, setMode: string, callback: (err: Error, res: Buffer) => void): void; + setBuffer(key: string, value: any, expiryMode: string, time: number, callback: (err: Error, res: Buffer) => void): void; + setBuffer(key: string, value: any, expiryMode: string, time: number | string, setMode: number | string, callback: (err: Error, res: Buffer) => void): void; + + setnx(key: string, value: any, callback: (err: Error, res: any) => void): void; + setnx(key: string, value: any): Promise; + + setex(key: string, seconds: number, value: any, callback: (err: Error, res: any) => void): void; + setex(key: string, seconds: number, value: any): Promise; + + psetex(key: string, milliseconds: number, value: any, callback: (err: Error, res: any) => void): void; + psetex(key: string, milliseconds: number, value: any): Promise; + + append(key: string, value: any, callback: (err: Error, res: number) => void): void; + append(key: string, value: any): Promise; + + strlen(key: string, callback: (err: Error, res: number) => void): void; + strlen(key: string): Promise; + + del(...keys: string[]): any; + + exists(...keys: string[]): any; + + setbit(key: string, offset: number, value: any, callback: (err: Error, res: number) => void): void; + setbit(key: string, offset: number, value: any): Promise; + + getbit(key: string, offset: number, callback: (err: Error, res: number) => void): void; + getbit(key: string, offset: number): Promise; + + setrange(key: string, offset: number, value: any, callback: (err: Error, res: number) => void): void; + setrange(key: string, offset: number, value: any): Promise; + + getrange(key: string, start: number, end: number, callback: (err: Error, res: string) => void): void; + getrange(key: string, start: number, end: number): Promise; + + substr(key: string, start: number, end: number, callback: (err: Error, res: string) => void): void; + substr(key: string, start: number, end: number): Promise; + + incr(key: string, callback: (err: Error, res: number) => void): void; + incr(key: string): Promise; + + decr(key: string, callback: (err: Error, res: number) => void): void; + decr(key: string): Promise; + + mget(...keys: string[]): any; + + rpush(key: string, ...values: any[]): any; + + lpush(key: string, ...values: any[]): any; + + rpushx(key: string, value: any, callback: (err: Error, res: number) => void): void; + rpushx(key: string, value: any): Promise; + + lpushx(key: string, value: any, callback: (err: Error, res: number) => void): void; + lpushx(key: string, value: any): Promise; + + linsert(key: string, direction: "BEFORE" | "AFTER", pivot: string, value: any, callback: (err: Error, res: number) => void): void; + linsert(key: string, direction: "BEFORE" | "AFTER", pivot: string, value: any): Promise; + + rpop(key: string, callback: (err: Error, res: string) => void): void; + rpop(key: string): Promise; + + lpop(key: string, callback: (err: Error, res: string) => void): void; + lpop(key: string): Promise; + + brpop(...keys: string[]): any; + + blpop(...keys: string[]): any; + + brpoplpush(source: string, destination: string, timeout: number, callback: (err: Error, res: any) => void): void; + brpoplpush(source: string, destination: string, timeout: number): Promise; + + llen(key: string, callback: (err: Error, res: number) => void): void; + llen(key: string): Promise; + + lindex(key: string, index: number, callback: (err: Error, res: string) => void): void; + lindex(key: string, index: number): Promise; + + lset(key: string, index: number, value: any, callback: (err: Error, res: any) => void): void; + lset(key: string, index: number, value: any): Promise; + + lrange(key: string, start: number, stop: number, callback: (err: Error, res: any) => void): void; + lrange(key: string, start: number, stop: number): Promise; + + ltrim(key: string, start: number, stop: number, callback: (err: Error, res: any) => void): void; + ltrim(key: string, start: number, stop: number): Promise; + + lrem(key: string, count: number, value: any, callback: (err: Error, res: number) => void): void; + lrem(key: string, count: number, value: any): Promise; + + rpoplpush(source: string, destination: string, callback: (err: Error, res: string) => void): void; + rpoplpush(source: string, destination: string): Promise; + + sadd(key: string, ...members: any[]): any; + + srem(key: string, ...members: any[]): any; + + smove(source: string, destination: string, member: string, callback: (err: Error, res: string) => void): void; + smove(source: string, destination: string, member: string): Promise; + + sismember(key: string, member: string, callback: (err: Error, res: 1 | 0) => void): void; + sismember(key: string, member: string): Promise<1 | 0>; + + scard(key: string, callback: (err: Error, res: number) => void): void; + scard(key: string): Promise; + + spop(key: string, callback: (err: Error, res: any) => void): void; + spop(key: string, count: number, callback: (err: Error, res: any) => void): void; + spop(key: string, count?: number): Promise; + + srandmember(key: string, callback: (err: Error, res: any) => void): void; + srandmember(key: string, count: number, callback: (err: Error, res: any) => void): void; + srandmember(key: string, count?: number): Promise; + + sinter(...keys: string[]): any; + + sinterstore(destination: string, ...keys: string[]): any; + + sunion(...keys: string[]): any; + + sunionstore(destination: string, ...keys: string[]): any; + + sdiff(...keys: string[]): any; + + sdiffstore(destination: string, ...keys: string[]): any; + + smembers(key: string, callback: (err: Error, res: any) => void): void; + smembers(key: string): Promise; + + zadd(key: string, ...args: string[]): any; + + zincrby(key: string, increment: number, member: string, callback: (err: Error, res: any) => void): void; + zincrby(key: string, increment: number, member: string): Promise; + + zrem(key: string, ...members: any[]): any; + + zremrangebyscore(key: string, min: number | string, max: number | string, callback: (err: Error, res: any) => void): void; + zremrangebyscore(key: string, min: number | string, max: number | string): Promise; + + zremrangebyrank(key: string, start: number, stop: number, callback: (err: Error, res: any) => void): void; + zremrangebyrank(key: string, start: number, stop: number): Promise; + + zunionstore(destination: string, numkeys: number, key: string, ...args: string[]): any; + + zinterstore(destination: string, numkeys: number, key: string, ...args: string[]): any; + + zrange(key: string, start: number, stop: number, callback: (err: Error, res: any) => void): void; + zrange(key: string, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; + zrange(key: string, start: number, stop: number, withScores?: "WITHSCORES"): Promise; + + zrevrange(key: string, start: number, stop: number, callback: (err: Error, res: any) => void): void; + zrevrange(key: string, start: number, stop: number, withScores: "WITHSCORES", callback: (err: Error, res: any) => void): void; + zrevrange(key: string, start: number, stop: number, withScores?: "WITHSCORES"): Promise; + + zrangebyscore(key: string, min: number | string, max: number | string, ...args: string[]): any; + + zrevrangebyscore(key: string, max: number | string, min: number | string, ...args: string[]): any; + + zcount(key: string, min: number | string, max: number | string, callback: (err: Error, res: number) => void): void; + zcount(key: string, min: number | string, max: number | string): Promise; + + zcard(key: string, callback: (err: Error, res: number) => void): void; + zcard(key: string): Promise; + + zscore(key: string, member: string, callback: (err: Error, res: string) => void): void; + zscore(key: string, member: string): Promise; + + zrank(key: string, member: string, callback: (err: Error, res: number) => void): void; + zrank(key: string, member: string): Promise; + + zrevrank(key: string, member: string, callback: (err: Error, res: number) => void): void; + zrevrank(key: string, member: string): Promise; + + hset(key: string, field: string, value: any, callback: (err: Error, res: 0 | 1) => void): void; + hset(key: string, field: string, value: any): Promise<0 | 1>; + hsetBuffer(key: string, field: string, value: any, callback: (err: Error, res: 0 | 1) => void): void; + hsetBuffer(key: string, field: string, value: any): Promise; + + hsetnx(key: string, field: string, value: any, callback: (err: Error, res: 0 | 1) => void): void; + hsetnx(key: string, field: string, value: any): Promise<0 | 1>; + + hget(key: string, field: string, callback: (err: Error, res: string) => void): void; + hget(key: string, field: string): Promise; + hgetBuffer(key: string, field: string, callback: (err: Error, res: Buffer) => void): void; + hgetBuffer(key: string, field: string): Promise; + + hmset(key: string, field: string, value: any, ...args: string[]): Promise<0 | 1>; + hmset(key: string, data: any, callback: (err: Error, res: 0 | 1) => void): void; + hmset(key: string, data: any): Promise<0 | 1>; + + hmget(key: string, ...fields: string[]): any; + + hincrby(key: string, field: string, increment: number, callback: (err: Error, res: number) => void): void; + hincrby(key: string, field: string, increment: number): Promise; + + hincrbyfloat(key: string, field: string, increment: number, callback: (err: Error, res: number) => void): void; + hincrbyfloat(key: string, field: string, increment: number): Promise; + + hdel(key: string, ...fields: string[]): any; + + hlen(key: string, callback: (err: Error, res: number) => void): void; + hlen(key: string): Promise; + + hkeys(key: string, callback: (err: Error, res: any) => void): void; + hkeys(key: string): Promise; + + hvals(key: string, callback: (err: Error, res: any) => void): void; + hvals(key: string): Promise; + + hgetall(key: string, callback: (err: Error, res: any) => void): void; + hgetall(key: string): Promise; + + hexists(key: string, field: string, callback: (err: Error, res: 0 | 1) => void): void; + hexists(key: string, field: string): Promise<0 | 1>; + + incrby(key: string, increment: number, callback: (err: Error, res: number) => void): void; + incrby(key: string, increment: number): Promise; + + incrbyfloat(key: string, increment: number, callback: (err: Error, res: number) => void): void; + incrbyfloat(key: string, increment: number): Promise; + + decrby(key: string, decrement: number, callback: (err: Error, res: number) => void): void; + decrby(key: string, decrement: number): Promise; + + getset(key: string, value: any, callback: (err: Error, res: string) => void): void; + getset(key: string, value: any): Promise; + + mset(key: string, value: any, ...args: string[]): any; + + msetnx(key: string, value: any, ...args: string[]): any; + + randomkey(callback: (err: Error, res: string) => void): void; + randomkey(): Promise; + + select(index: number, callback: (err: Error, res: string) => void): void; + select(index: number): Promise; + + move(key: string, db: string, callback: (err: Error, res: 0 | 1) => void): void; + move(key: string, db: string): Promise<0 | 1>; + + rename(key: string, newkey: string, callback: (err: Error, res: string) => void): void; + rename(key: string, newkey: string): Promise; + + renamenx(key: string, newkey: string, callback: (err: Error, res: 0 | 1) => void): void; + renamenx(key: string, newkey: string): Promise<0 | 1>; + + expire(key: string, seconds: number, callback: (err: Error, res: 0 | 1) => void): void; + expire(key: string, seconds: number): Promise<0 | 1>; + + pexpire(key: string, milliseconds: number, callback: (err: Error, res: 0 | 1) => void): void; + pexpire(key: string, milliseconds: number): Promise<0 | 1>; + + expireat(key: string, timestamp: number, callback: (err: Error, res: 0 | 1) => void): void; + expireat(key: string, timestamp: number): Promise<0 | 1>; + + pexpireat(key: string, millisecondsTimestamp: number, callback: (err: Error, res: 0 | 1) => void): void; + pexpireat(key: string, millisecondsTimestamp: number): Promise<0 | 1>; + + keys(pattern: string, callback: (err: Error, res: string[]) => void): void; + keys(pattern: string): Promise; + + dbsize(callback: (err: Error, res: number) => void): void; + dbsize(): Promise; + + auth(password: string, callback: (err: Error, res: string) => void): void; + auth(password: string): Promise; + + ping(callback: (err: Error, res: string) => void): void; + ping(message: string, callback: (err: Error, res: string) => void): void; + ping(message?: string): Promise; + + echo(message: string, callback: (err: Error, res: string) => void): void; + echo(message: string): Promise; + + save(callback: (err: Error, res: string) => void): void; + save(): Promise; + + bgsave(callback: (err: Error, res: string) => void): void; + bgsave(): Promise; + + bgrewriteaof(callback: (err: Error, res: string) => void): void; + bgrewriteaof(): Promise; + + shutdown(save: "SAVE" | "NOSAVE", callback: (err: Error, res: any) => void): void; + shutdown(save: "SAVE" | "NOSAVE"): Promise; + + lastsave(callback: (err: Error, res: number) => void): void; + lastsave(): Promise; + + type(key: string, callback: (err: Error, res: string) => void): void; + type(key: string): Promise; + + multi(commands?: string[][], options?: MultiOptions): Pipeline; + multi(options: { pipeline: false }): Promise; + + exec(callback: (err: Error, res: any) => void): void; + exec(): Promise; + + discard(callback: (err: Error, res: any) => void): void; + discard(): Promise; + + sync(callback: (err: Error, res: any) => void): void; + sync(): Promise; + + flushdb(callback: (err: Error, res: string) => void): void; + flushdb(): Promise; + + flushall(callback: (err: Error, res: string) => void): void; + flushall(): Promise; + + sort(key: string, ...args: string[]): any; + + info(callback: (err: Error, res: any) => void): void; + info(section: string, callback: (err: Error, res: any) => void): void; + info(section?: string): Promise; + + time(callback: (err: Error, res: any) => void): void; + time(): Promise; + + monitor(callback: (err: Error, res: NodeJS.EventEmitter) => void): void; + monitor(): Promise; + + ttl(key: string, callback: (err: Error, res: number) => void): void; + ttl(key: string): Promise; + + persist(key: string, callback: (err: Error, res: 0 | 1) => void): void; + persist(key: string): Promise<0 | 1>; + + slaveof(host: string, port: number, callback: (err: Error, res: string) => void): void; + slaveof(host: string, port: number): Promise; + + debug(...args: any[]): any; + + config(...args: any[]): any; + + subscribe(...channels: any[]): any; + + unsubscribe(...channels: string[]): any; + + psubscribe(...patterns: string[]): any; + + punsubscribe(...patterns: string[]): any; + + publish(channel: string, message: string, callback: (err: Error, res: number) => void): void; + publish(channel: string, message: string): Promise; + + watch(...keys: string[]): any; + + unwatch(callback: (err: Error, res: string) => void): void; + unwatch(): Promise; + + cluster(...args: any[]): any; + + restore(...args: any[]): any; + + migrate(...args: any[]): any; + + dump(key: string, callback: (err: Error, res: string) => void): void; + dump(key: string): Promise; + + object(subcommand: string, ...args: any[]): any; + + client(...args: any[]): any; + + eval(...args: any[]): any; + + evalsha(...args: any[]): any; + + script(...args: any[]): any; + + quit(callback: (err: Error, res: string) => void): void; + quit(): Promise; + + scan(cursor: number, ...args: any[]): any; + + sscan(key: string, cursor: number, ...args: any[]): any; + + hscan(key: string, cursor: number, ...args: any[]): any; + + zscan(key: string, cursor: number, ...args: any[]): any; + + pfmerge(destkey: string, ...sourcekeys: string[]): any; + + pfadd(key: string, ...elements: string[]): any; + + pfcount(...keys: string[]): any; + + pipeline(commands?: string[][]): Pipeline; + + scanStream(options?: ScanStreamOption): NodeJS.EventEmitter; + sscanStream(key: string, options?: ScanStreamOption): NodeJS.EventEmitter; + hscanStream(key: string, options?: ScanStreamOption): NodeJS.EventEmitter; + zscanStream(key: string, options?: ScanStreamOption): NodeJS.EventEmitter; + } + + interface Pipeline { + redis: Redis; + isCluster: boolean; + options: RedisOptions; + _queue: Command[]; + _result: any[]; + _transactions: number; + _shaToScript: {}; + bitcount(key: string, callback?: (err: Error, res: number) => void): Pipeline; + bitcount(key: string, start: number, end: number, callback?: (err: Error, res: number) => void): Pipeline; + + get(key: string, callback?: (err: Error, res: string) => void): Pipeline; + getBuffer(key: string, callback?: (err: Error, res: Buffer) => void): Pipeline; + + set(key: string, value: any, callback?: (err: Error, res: string) => void): Pipeline; + set(key: string, value: any, setMode: string, callback?: (err: Error, res: string) => void): Pipeline; + set(key: string, value: any, expiryMode: string, time: number, callback?: (err: Error, res: string) => void): Pipeline; + set(key: string, value: any, expiryMode: string, time: number, setMode: string, callback?: (err: Error, res: string) => void): Pipeline; + + setBuffer(key: string, value: any, callback?: (err: Error, res: Buffer) => void): Pipeline; + setBuffer(key: string, value: any, setMode: string, callback?: (err: Error, res: Buffer) => void): Pipeline; + setBuffer(key: string, value: any, expiryMode: string, time: number, callback?: (err: Error, res: Buffer) => void): Pipeline; + setBuffer(key: string, value: any, expiryMode: string, time: number, setMode: string, callback?: (err: Error, res: Buffer) => void): Pipeline; + + setnx(key: string, value: any, callback?: (err: Error, res: any) => void): Pipeline; + + setex(key: string, seconds: number, value: any, callback?: (err: Error, res: any) => void): Pipeline; + + psetex(key: string, milliseconds: number, value: any, callback?: (err: Error, res: any) => void): Pipeline; + + append(key: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + strlen(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + del(...keys: string[]): Pipeline; + + exists(...keys: string[]): Pipeline; + + setbit(key: string, offset: number, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + getbit(key: string, offset: number, callback?: (err: Error, res: number) => void): Pipeline; + + setrange(key: string, offset: number, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + getrange(key: string, start: number, end: number, callback?: (err: Error, res: string) => void): Pipeline; + + substr(key: string, start: number, end: number, callback?: (err: Error, res: string) => void): Pipeline; + + incr(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + decr(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + mget(...keys: string[]): Pipeline; + + rpush(key: string, ...values: any[]): Pipeline; + + lpush(key: string, ...values: any[]): Pipeline; + + rpushx(key: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + lpushx(key: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + linsert(key: string, direction: "BEFORE" | "AFTER", pivot: string, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + rpop(key: string, callback?: (err: Error, res: string) => void): Pipeline; + + lpop(key: string, callback?: (err: Error, res: string) => void): Pipeline; + + brpop(...keys: string[]): Pipeline; + + blpop(...keys: string[]): Pipeline; + + brpoplpush(source: string, destination: string, timeout: number, callback?: (err: Error, res: any) => void): Pipeline; + + llen(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + lindex(key: string, index: number, callback?: (err: Error, res: string) => void): Pipeline; + + lset(key: string, index: number, value: any, callback?: (err: Error, res: any) => void): Pipeline; + + lrange(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; + + ltrim(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; + + lrem(key: string, count: number, value: any, callback?: (err: Error, res: number) => void): Pipeline; + + rpoplpush(source: string, destination: string, callback?: (err: Error, res: string) => void): Pipeline; + + sadd(key: string, ...members: any[]): Pipeline; + + srem(key: string, ...members: any[]): Pipeline; + + smove(source: string, destination: string, member: string, callback?: (err: Error, res: string) => void): Pipeline; + + sismember(key: string, member: string, callback?: (err: Error, res: 1 | 0) => void): Pipeline; + + scard(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + spop(key: string, callback?: (err: Error, res: any) => void): Pipeline; + spop(key: string, count: number, callback?: (err: Error, res: any) => void): Pipeline; + + srandmember(key: string, callback?: (err: Error, res: any) => void): Pipeline; + srandmember(key: string, count: number, callback?: (err: Error, res: any) => void): Pipeline; + + sinter(...keys: string[]): Pipeline; + + sinterstore(destination: string, ...keys: string[]): Pipeline; + + sunion(...keys: string[]): Pipeline; + + sunionstore(destination: string, ...keys: string[]): Pipeline; + + sdiff(...keys: string[]): Pipeline; + + sdiffstore(destination: string, ...keys: string[]): Pipeline; + + smembers(key: string, callback?: (err: Error, res: any) => void): Pipeline; + + zadd(key: string, ...args: string[]): Pipeline; + + zincrby(key: string, increment: number, member: string, callback?: (err: Error, res: any) => void): Pipeline; + + zrem(key: string, ...members: any[]): Pipeline; + + zremrangebyscore(key: string, min: number | string, max: number | string, callback?: (err: Error, res: any) => void): Pipeline; + + zremrangebyrank(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; + + zunionstore(destination: string, numkeys: number, key: string, ...args: string[]): Pipeline; + + zinterstore(destination: string, numkeys: number, key: string, ...args: string[]): Pipeline; + + zrange(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; + zrange(key: string, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; + + zrevrange(key: string, start: number, stop: number, callback?: (err: Error, res: any) => void): Pipeline; + zrevrange(key: string, start: number, stop: number, withScores: "WITHSCORES", callback?: (err: Error, res: any) => void): Pipeline; + + zrangebyscore(key: string, min: number | string, max: number | string, ...args: string[]): Pipeline; + + zrevrangebyscore(key: string, max: number | string, min: number | string, ...args: string[]): Pipeline; + + zcount(key: string, min: number | string, max: number | string, callback?: (err: Error, res: number) => void): Pipeline; + + zcard(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + zscore(key: string, member: string, callback?: (err: Error, res: number) => void): Pipeline; + + zrank(key: string, member: string, callback?: (err: Error, res: number) => void): Pipeline; + + zrevrank(key: string, member: string, callback?: (err: Error, res: number) => void): Pipeline; + + hset(key: string, field: string, value: any, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + hsetBuffer(key: string, field: string, value: any, callback?: (err: Error, res: Buffer) => void): Pipeline; + + hsetnx(key: string, field: string, value: any, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + hget(key: string, field: string, callback?: (err: Error, res: string) => void): Pipeline; + hgetBuffer(key: string, field: string, callback?: (err: Error, res: Buffer) => void): Pipeline; + + hmset(key: string, field: string, value: any, ...args: string[]): Pipeline; + hmset(key: string, data: any, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + hmget(key: string, ...fields: string[]): Pipeline; + + hincrby(key: string, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; + + hincrbyfloat(key: string, field: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; + + hdel(key: string, ...fields: string[]): Pipeline; + + hlen(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + hkeys(key: string, callback?: (err: Error, res: any) => void): Pipeline; + + hvals(key: string, callback?: (err: Error, res: any) => void): Pipeline; + + hgetall(key: string, callback?: (err: Error, res: any) => void): Pipeline; + + hexists(key: string, field: string, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + incrby(key: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; + + incrbyfloat(key: string, increment: number, callback?: (err: Error, res: number) => void): Pipeline; + + decrby(key: string, decrement: number, callback?: (err: Error, res: number) => void): Pipeline; + + getset(key: string, value: any, callback?: (err: Error, res: string) => void): Pipeline; + + mset(key: string, value: any, ...args: string[]): Pipeline; + + msetnx(key: string, value: any, ...args: string[]): Pipeline; + + randomkey(callback?: (err: Error, res: string) => void): Pipeline; + + select(index: number, callback?: (err: Error, res: string) => void): Pipeline; + + move(key: string, db: string, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + rename(key: string, newkey: string, callback?: (err: Error, res: string) => void): Pipeline; + + renamenx(key: string, newkey: string, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + expire(key: string, seconds: number, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + pexpire(key: string, milliseconds: number, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + expireat(key: string, timestamp: number, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + pexpireat(key: string, millisecondsTimestamp: number, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + keys(pattern: string, callback?: (err: Error, res: string[]) => void): Pipeline; + + dbsize(callback?: (err: Error, res: number) => void): Pipeline; + + auth(password: string, callback?: (err: Error, res: string) => void): Pipeline; + + ping(callback?: (err: Error, res: string) => void): Pipeline; + ping(message: string, callback?: (err: Error, res: string) => void): Pipeline; + + echo(message: string, callback?: (err: Error, res: string) => void): Pipeline; + + save(callback?: (err: Error, res: string) => void): Pipeline; + + bgsave(callback?: (err: Error, res: string) => void): Pipeline; + + bgrewriteaof(callback?: (err: Error, res: string) => void): Pipeline; + + shutdown(save: "SAVE" | "NOSAVE", callback?: (err: Error, res: any) => void): Pipeline; + + lastsave(callback?: (err: Error, res: number) => void): Pipeline; + + type(key: string, callback?: (err: Error, res: string) => void): Pipeline; + + multi(callback?: (err: Error, res: string) => void): Pipeline; + + exec(callback?: (err: Error, res: any) => void): Promise; + + discard(callback?: (err: Error, res: any) => void): Pipeline; + + sync(callback?: (err: Error, res: any) => void): Pipeline; + + flushdb(callback?: (err: Error, res: string) => void): Pipeline; + + flushall(callback?: (err: Error, res: string) => void): Pipeline; + + sort(key: string, ...args: string[]): Pipeline; + + info(callback?: (err: Error, res: any) => void): Pipeline; + info(section: string, callback?: (err: Error, res: any) => void): Pipeline; + + time(callback?: (err: Error, res: any) => void): Pipeline; + + monitor(callback?: (err: Error, res: NodeJS.EventEmitter) => void): Pipeline; + + ttl(key: string, callback?: (err: Error, res: number) => void): Pipeline; + + persist(key: string, callback?: (err: Error, res: 0 | 1) => void): Pipeline; + + slaveof(host: string, port: number, callback?: (err: Error, res: string) => void): Pipeline; + + debug(...args: any[]): Pipeline; + + config(...args: any[]): Pipeline; + + subscribe(...channels: any[]): Pipeline; + + unsubscribe(...channels: string[]): Pipeline; + + psubscribe(...patterns: string[]): Pipeline; + + punsubscribe(...patterns: string[]): Pipeline; + + publish(channel: string, message: string, callback?: (err: Error, res: number) => void): Pipeline; + + watch(...keys: string[]): Pipeline; + + unwatch(callback?: (err: Error, res: string) => void): Pipeline; + + cluster(...args: any[]): Pipeline; + + restore(...args: any[]): Pipeline; + + migrate(...args: any[]): Pipeline; + + dump(key: string, callback?: (err: Error, res: string) => void): Pipeline; + + object(subcommand: string, ...args: any[]): Pipeline; + + client(...args: any[]): Pipeline; + + eval(...args: any[]): Pipeline; + + evalsha(...args: any[]): Pipeline; + + script(...args: any[]): Pipeline; + + quit(callback?: (err: Error, res: string) => void): Pipeline; + + scan(cursor: number, ...args: any[]): Pipeline; + + sscan(key: string, cursor: number, ...args: any[]): Pipeline; + + hscan(key: string, cursor: number, ...args: any[]): Pipeline; + + zscan(key: string, cursor: number, ...args: any[]): Pipeline; + + pfmerge(destkey: string, ...sourcekeys: string[]): Pipeline; + + pfadd(key: string, ...elements: string[]): Pipeline; + + pfcount(...keys: string[]): Pipeline; + } + + interface NodeConfiguration { + host?: string; + port?: number; + } + + type ClusterNode = string | number | NodeConfiguration; + + interface Cluster extends NodeJS.EventEmitter, Commander { + new(nodes: ClusterNode[], options?: ClusterOptions): Redis; + connect(callback: () => void): Promise; + disconnect(): void; + nodes(role: string): Redis[]; + } + + interface RedisOptions { + port?: number; + host?: string; + /** + * 4 (IPv4) or 6 (IPv6), Defaults to 4. + */ + family?: number; + /** + * Local domain socket path. If set the port, host and family will be ignored. + */ + path?: string; + /** + * TCP KeepAlive on the socket with a X ms delay before start. Set to a non-number value to disable keepAlive. + */ + keepAlive?: number; + connectionName?: string; + /** + * If set, client will send AUTH command with the value of this option when connected. + */ + password?: string; + /** + * Database index to use. + */ + db?: number; + /** + * When a connection is established to the Redis server, the server might still be loading + * the database from disk. While loading, the server not respond to any commands. + * To work around this, when this option is true, ioredis will check the status of the Redis server, + * and when the Redis server is able to process commands, a ready event will be emitted. + */ + enableReadyCheck?: boolean; + keyPrefix?: string; + /** + * When the return value isn't a number, ioredis will stop trying to reconnect. + * Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858 + */ + retryStrategy?(times: number): number | false; + /** + * 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore + * the error and do nothing. + */ + reconnectOnError?(error: Error): boolean | 1 | 2; + /** + * By default, if there is no active connection to the Redis server, commands are added to a queue + * and are executed once the connection is "ready" (when enableReadyCheck is true, "ready" means + * the Redis server has loaded the database from disk, otherwise means the connection to the Redis + * server has been established). If this option is false, when execute the command when the connection + * isn't ready, an error will be returned. + */ + enableOfflineQueue?: boolean; + /** + * The milliseconds before a timeout occurs during the initial connection to the Redis server. + * default: 10000. + */ + connectTimeout?: number; + /** + * After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels. + * default: true. + */ + autoResubscribe?: boolean; + /** + * If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected. + * default: true. + */ + autoResendUnfulfilledCommands?: boolean; + lazyConnect?: boolean; + tls?: tls.ConnectionOptions; + sentinels?: Array<{ host: string; port: number; }>; + name?: string; + /** + * Enable READONLY mode for the connection. Only available for cluster mode. + * default: false. + */ + readOnly?: boolean; + /** + * If you are using the hiredis parser, it's highly recommended to enable this option. + * Create another instance with dropBufferSupport disabled for other commands that you want to return binary instead of string + */ + dropBufferSupport?: boolean; + /** + * Whether to show a friendly error stack. Will decrease the performance significantly. + */ + showFriendlyErrorStack?: boolean; + } + + interface ScanStreamOption { + match?: string; + count?: number; + } + + interface ClusterOptions { + clusterRetryStrategy?(times: number): number; + enableOfflineQueue?: boolean; + enableReadyCheck?: boolean; + scaleReads?: string; + maxRedirections?: number; + retryDelayOnFailover?: number; + retryDelayOnClusterDown?: number; + retryDelayOnTryAgain?: number; + redisOptions?: RedisOptions; + } + + interface MultiOptions { + pipeline: boolean; + } +} diff --git a/types/ioredis/v3/ioredis-tests.ts b/types/ioredis/v3/ioredis-tests.ts new file mode 100644 index 0000000000..32ae5c24d5 --- /dev/null +++ b/types/ioredis/v3/ioredis-tests.ts @@ -0,0 +1,153 @@ +import Redis = require("ioredis"); +const redis = new Redis(); + +redis.set('foo', 'bar'); +redis.get('foo', (err, result) => { + console.log(result); +}); + +// Or using a promise if the last argument isn't a function +redis.get('foo').then((result: any) => { + console.log(result); +}); + +// Arguments to commands are flattened, so the following are the same: +redis.sadd('set', 1, 3, 5, 7); +redis.sadd('set', [1, 3, 5, 7]); + +// All arguments are passed directly to the redis server: +redis.set('key', '100'); +redis.set('key', '100', 'XX'); +redis.set('key', '100', 'PX', 10); +redis.set('key', '100', 'EX', 10, 'NX'); +redis.set('key', '100', 'NX', 'EX', 10); +redis.set('key', '100', ['EX', 10, 'NX']); +redis.setBuffer('key', '100', 'NX', 'EX', 10); + +redis.set('key', '100', (err, data) => {}); +redis.set('key', '100', 'XX', (err, data) => {}); +redis.set('key', '100', 'PX', 10, (err, data) => {}); +redis.set('key', '100', 'EX', 10, 'NX', (err, data) => {}); +redis.set('key', '100', ['EX', 10, 'NX'], (err, data) => {}); +redis.setBuffer('key', '100', 'NX', 'EX', 10, (err, data) => {}); + +new Redis(); // Connect to 127.0.0.1:6379 +new Redis(6380); // 127.0.0.1:6380 +new Redis(6379, '192.168.1.1'); // 192.168.1.1:6379 +new Redis('/tmp/redis.sock'); +new Redis({ + port: 6379, // Redis port + host: '127.0.0.1', // Redis host + family: 4, // 4 (IPv4) or 6 (IPv6) + password: 'auth', + db: 0, + retryStrategy() { return false; }, + showFriendlyErrorStack: true, + tls: { + servername: 'tlsservername' + } +}); + +const pub = new Redis(); +redis.subscribe('news', 'music', (err: any, count: any) => { + // Now we are subscribed to both the 'news' and 'music' channels. + // `count` represents the number of channels we are currently subscribed to. + + pub.publish('news', 'Hello world!'); + pub.publish('music', 'Hello again!'); +}); + +redis.on('message', (channel: any, message: any) => { + // Receive message Hello world! from channel news + // Receive message Hello again! from channel music + console.log('Receive message %s from channel %s', message, channel); +}); + +// There's also an event called 'messageBuffer', which is the same as 'message' except +// it returns buffers instead of strings. +redis.on('messageBuffer', (channel: any, message: any) => { + // Both `channel` and `message` are buffers. +}); + +const pipeline = redis.pipeline(); +pipeline.set('foo', 'bar'); +pipeline.del('cc'); +pipeline.hset('hash', 'foo', 4); +pipeline.hget('hash', 'foo'); +pipeline.hsetBuffer('hash', 'fooBuffer', 4); +pipeline.hgetBuffer('hash', 'fooBuffer'); +pipeline.exec((err, results) => { + // `err` is always null, and `results` is an array of responses + // corresponding to the sequence of queued commands. + // Each response follows the format `[err, result]`. +}); + +// You can even chain the commands: +redis.pipeline().set('foo', 'bar').del('cc').exec((err, results) => { +}); + +// `exec` also returns a Promise: +const promise = redis.pipeline().set('foo', 'bar').get('foo').exec(); +promise.then((result) => { + // result === [[null, 'OK'], [null, 'bar']] +}); + +redis.pipeline().set('foo', 'bar').get('foo', (err, result) => { + // result === 'bar' +}).exec((err, result) => { + // result[1][1] === 'bar' +}); + +redis.pipeline([ + ['set', 'foo', 'bar'], + ['get', 'foo'] +]).exec(() => { /* ... */ }); + +Redis.Command.setArgumentTransformer('set', args => { + return args; +}); + +Redis.Command.setReplyTransformer('get', (result: any) => { + return result; +}); + +// multi +redis.multi().set('foo', 'bar').set('foo', 'baz').get('foo', (err, result) => { + // result === 'QUEUED' +}).exec((err, results) => { + // results = [[null, 'OK'], [null, 'OK'], [null, 'baz']] +}); + +redis.multi([ + ['set', 'foo', 'bar'], + ['get', 'foo'] +]).exec((err, results) => { + // results = [[null, 'OK'], [null, 'bar']] +}); + +redis.Promise.onPossiblyUnhandledRejection((error) => { +}); + +const keys = ['foo', 'bar']; +redis.mget(...keys); + +new Redis.Cluster([ + 'localhost' +]); + +new Redis.Cluster([ + 6379 +]); + +new Redis.Cluster([{ + host: 'localhost' +}]); + +new Redis.Cluster([{ + port: 6379 +}]); + +new Redis.Cluster([{ + host: 'localhost', + port: 6379 +}]); diff --git a/types/ioredis/v3/tsconfig.json b/types/ioredis/v3/tsconfig.json new file mode 100644 index 0000000000..eb6e042a5d --- /dev/null +++ b/types/ioredis/v3/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "ioredis": [ "ioredis/v3" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ioredis-tests.ts" + ] +} diff --git a/types/ioredis/v3/tslint.json b/types/ioredis/v3/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ioredis/v3/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ip-address/index.d.ts b/types/ip-address/index.d.ts new file mode 100644 index 0000000000..59dbb07d57 --- /dev/null +++ b/types/ip-address/index.d.ts @@ -0,0 +1,110 @@ +// Type definitions for ip-address 5.8 +// Project: https://github.com/beaugunderson/ip-address +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace ipAddress; + +export interface v6Helpers { + spanAllZeroes(s: string): string; + spanAll(s: string, optionalOffset?: number): string; + spanLeadingZeroes(address: string): string; + simpleGroup(addressString: string, offset?: number): string; +} + +export interface TeredoObject { + readonly prefix: string; + readonly server4: string; + readonly client4: string; + readonly flags: string; + readonly coneNat: any; + readonly microsoft: { + readonly reserved: any, + readonly universalLocal: any, + readonly groupIndividual: any, + readonly nonce: any, + }; + udpPort: string; +} + +export interface SixToFourResponse { + readonly prefix: string; + readonly gateway: string; +} + +export class Address4 { + constructor(address: string); + static fromHex(hex: string): Address4; + static fromInteger(integer: number): Address4; + static fromBigInteger(bigInteger: any): Address4; + + valid: boolean; + address: string; + parsedAddress: string; + groups: number; + v4: boolean; + subnet: string; + subnetMask: number; + + isValid(): boolean; + correctForm(): string; + isCorrect(): boolean; + toHex(): string; + toArray(): any; + toGroup6(): string; + bigInteger(): any; + startAddress(): Address4; + startAddressExclusive(): Address4; + endAddress(): Address4; + endAddressExclusive(): Address4; + mask(optionalMask?: number): string; + getBitsBase2(start: number, end: number): string; + isInSubnet(): boolean; + binaryZeroPad(): string; +} + +export class Address6 { + constructor(address: string, optionalGroups?: number); + static fromBigInteger(bigInteger: any): Address6; + static fromURL(url: string): Address6; + static fromAddress4(address4: string): Address6; + static fromArpa(arpaFormAddress: string): Address6; + static fromByteArray(bytes: any): Address6; + static fromUnsignedByteArray(bytes: any): Address6; + + valid: boolean; + address: string; + groups: number; + v4: boolean; + subnet: string; + subnetMask: number; + + microsoftTranscription(): string; + mask(optionalMask?: number): string; + possibleSubnets(optionalSubnetSize?: number): string; + startAddress(): Address6; + startAddressExclusive(): Address6; + endAddress(): Address6; + endAddressExclusive(): Address6; + getScope(): string; + getType(): string; + getBits(start: number, end: number): any; + getBitsBase2(start: number, end: number): string; + getBitsBase16(start: number, end: number): string; + getBitsPastSubnet(): string; + reverseForm(options?: { omitSuffix: boolean }): string; + correctForm(): string; + binaryZeroPad(): string; + canonicalForm(): string; + decimal(): string; + bigInteger(): any; + to4(): string; + to4in6(): string; + inspectTeredo(): TeredoObject; + inspect6to4(): SixToFourResponse; + to6to4(): Address6; + toByteArray(): any; + toUnsignedByteArray(): any; +} + +export const v6: {helpers: v6Helpers}; diff --git a/types/ip-address/ip-address-tests.ts b/types/ip-address/ip-address-tests.ts new file mode 100644 index 0000000000..76b4e471aa --- /dev/null +++ b/types/ip-address/ip-address-tests.ts @@ -0,0 +1,121 @@ +import ipAddress = require('ip-address'); + +// Test Address4 Typings +const address4 = new ipAddress.Address4('127.0.0.1'); + +const address4Valid = address4.valid; +const address4String = address4.address; +const address4Parsed = address4.parsedAddress; +const address4Groups = address4.groups; +const address4v4 = address4.v4; +const address4Subnet = address4.subnet; +const address4Mask = address4.subnetMask; + +// $ExpectType Address4 +ipAddress.Address4.fromHex('127.0.0.1'); +// $ExpectType Address4 +ipAddress.Address4.fromInteger(127001); +// $ExpectType Address4 +address4.startAddress(); +// $ExpectType Address4 +address4.startAddressExclusive(); +// $ExpectType Address4 +address4.endAddress(); +// $ExpectType Address4 +address4.endAddressExclusive(); + +// $ExpectType string +address4.correctForm(); +// $ExpectType string +address4.toHex(); +// $ExpectType string +address4.toGroup6(); +// $ExpectType string +address4.mask(); +// $ExpectType string +address4.mask(0); +// $ExpectType string +address4.getBitsBase2(0, 1); +// $ExpectType string +address4.binaryZeroPad(); + +// $ExpectType boolean +address4.isValid(); +// $ExpectType boolean +address4.isCorrect(); +// $ExpectType boolean +address4.isInSubnet(); + +// Test Address6 Typings +const address6 = new ipAddress.Address6('127.0.0.1'); + +const address6Valid = address6.valid; +const address6String = address6.address; +const address6Groups = address6.groups; +const address6v4 = address6.v4; +const address6Subnet = address6.subnet; +const address6Mask = address6.subnetMask; + +// $ExpectType Address6 +address6.startAddress(); +// $ExpectType Address6 +address6.startAddressExclusive(); +// $ExpectType Address6 +address6.endAddress(); +// $ExpectType Address6 +address6.endAddressExclusive(); +// $ExpectType Address6 +address6.to6to4(); + +// $ExpectType string +address6.microsoftTranscription(); +// $ExpectType string +address6.mask(); +// $ExpectType string +address6.mask(0); +// $ExpectType string +address6.possibleSubnets(); +// $ExpectType string +address6.possibleSubnets(1); +// $ExpectType string +address6.getScope(); +// $ExpectType string +address6.getType(); +// $ExpectType string +address6.getBitsBase2(0, 1); +// $ExpectType string +address6.getBitsBase16(0, 1); +// $ExpectType string +address6.getBitsPastSubnet(); +// $ExpectType string +address6.reverseForm(); +// $ExpectType string +address6.correctForm(); +// $ExpectType string +address6.binaryZeroPad(); +// $ExpectType string +address6.canonicalForm(); +// $ExpectType string +address6.decimal(); +// $ExpectType string +address6.to4(); +// $ExpectType string +address6.to4in6(); + +// $ExpectType TeredoObject +address6.inspectTeredo(); + +// $ExpectType SixToFourResponse +address6.inspect6to4(); + +// Test v6 Typings +const v6 = ipAddress.v6; + +// $ExpectType string +v6.helpers.simpleGroup(address6.address); +// $ExpectType string +v6.helpers.spanAll(address6.address); +// $ExpectType string +v6.helpers.spanAllZeroes(address6.address); +// $ExpectType string +v6.helpers.spanLeadingZeroes(address6.address); diff --git a/types/ip-address/tsconfig.json b/types/ip-address/tsconfig.json new file mode 100644 index 0000000000..79254ab191 --- /dev/null +++ b/types/ip-address/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ip-address-tests.ts" + ] +} diff --git a/types/ip-address/tslint.json b/types/ip-address/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/ip-address/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/is-running/index.d.ts b/types/is-running/index.d.ts new file mode 100644 index 0000000000..e573a44193 --- /dev/null +++ b/types/is-running/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for is-running 2.1 +// Project: https://github.com/nisaacson/is-running +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function isRunning(pid: number): boolean; + +export = isRunning; diff --git a/types/is-running/is-running-tests.ts b/types/is-running/is-running-tests.ts new file mode 100644 index 0000000000..5f8ad2983a --- /dev/null +++ b/types/is-running/is-running-tests.ts @@ -0,0 +1,4 @@ +import isRunning = require("is-running"); + +// $ExpectType boolean +isRunning(100); diff --git a/types/is-running/tsconfig.json b/types/is-running/tsconfig.json new file mode 100644 index 0000000000..3a03f10b96 --- /dev/null +++ b/types/is-running/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-running-tests.ts" + ] +} diff --git a/types/is-running/tslint.json b/types/is-running/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/is-running/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/johnny-five/index.d.ts b/types/johnny-five/index.d.ts index 5f0f6a9f37..eafa4038de 100644 --- a/types/johnny-five/index.d.ts +++ b/types/johnny-five/index.d.ts @@ -378,6 +378,8 @@ export declare class LCD { autoscroll(): void; noAutoscroll(): void; bgColor(color: any): void; + noBacklight(): void; + backlight(): void; } export interface LedOption { diff --git a/types/jqueryui/index.d.ts b/types/jqueryui/index.d.ts index a979c65c7a..7dca429ce4 100644 --- a/types/jqueryui/index.d.ts +++ b/types/jqueryui/index.d.ts @@ -1071,6 +1071,17 @@ declare namespace JQueryUI { show?: any; } + interface WidgetCommonProperties { + element: JQuery; + defaultElement : string; + document: Document; + namespace: string; + uuid: string; + widgetEventPrefix: string; + widgetFullName: string; + window: Window; + } + interface Widget { (methodName: string): JQuery; (options: WidgetOptions): JQuery; @@ -1079,8 +1090,8 @@ declare namespace JQueryUI { (optionLiteral: string, options: WidgetOptions): any; (optionLiteral: string, optionName: string, optionValue: any): JQuery; - (name: string, prototype: any): JQuery; - (name: string, base: Function, prototype: any): JQuery; + (name: string, prototype: T & ThisType): JQuery; + (name: string, base: Function, prototype: T & ThisType ): JQuery; } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/types/jsgraph/index.d.ts b/types/jsgraph/index.d.ts new file mode 100644 index 0000000000..fe4fa42e2f --- /dev/null +++ b/types/jsgraph/index.d.ts @@ -0,0 +1,174 @@ +// Type definitions for jsgraph 0.7 +// Project: https://github.com/Encapsule/jsgraph +// Definitions by: Joel Rosinbum +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare namespace jsgraph { + + interface jsGraphStatic { + directed: Directed; + } + + export interface VertexRequest { + u: string; + p: any + } + + export interface JsGraphResponse { + error?: any; + result?: any; + } + + export interface Edge { + u: string; + v: string + } + + export interface EdgeRequest { + e: Edge; + p: any; + } + + export interface DirectedGraph { + new(): DirectedGraph; + + setGraphName(name: string): JsGraphResponse; + + getGraphName(): string; + + setGraphDescription(description: string): JsGraphResponse; + + getGraphDescription(): string; + + verticesCount(): number; + + getVertices(): string[]; + + getEdgeCount(): number; + + getEdeges(): Edge[]; + + rootVerticesCount(): number; + + getRootVertices(): string[]; + + leafVerticesCount(): number; + + getLeafVertices(): string[]; + + toObject(): string; + + toJSON(): string; + + stringify(replacer: Function, space?: number): string; + + fromObject(graph: any): JsGraphResponse; + + + //Vertex functions + addVertex(vertex: VertexRequest): JsGraphResponse; + + removeVertex(vertex: string): boolean; + + getVertexProperty(vertex: string): any; + + setVertexProperty(vertex: VertexRequest): JsGraphResponse; + + hasVertexProperty(vertex: string): boolean; + + clearVertexProperty(vertex: string): boolean; + + inDegree(vertex: string): number; + + inEdges(vertex: string): Edge[]; + + outDegree(vertex: string): number; + + outEdges(vertex: string): Edge[]; + + //Edge functions + addEdge(request: EdgeRequest): JsGraphResponse; + + isEdge(edge: Edge): boolean; + + removeEdge(edge: Edge): JsGraphResponse; + + getEdgeProperty(edge: Edge): any; + + setEdgeProperty(request: EdgeRequest): JsGraphResponse; + + hasEdgeProperty(edge: Edge): boolean; + + clearEdgeProperty(edge: Edge): boolean; + + + } + + export interface Visitor { + initializeVertex(req: { u: string, g: DirectedGraph }): void; + + startVertex(req: { u: string, g: DirectedGraph }): void; + + discoverVertex(req: { u: string, g: DirectedGraph }): void; + + examineVertex(req: { u: string, g: DirectedGraph }): void; + + examineEdge(req: { e: Edge, g: DirectedGraph }): void; + + nonTreeEdge(req: { e: Edge, g: DirectedGraph }): void; + + grayTarget(req: { e: Edge, g: DirectedGraph }): void; + + blackTarget(req: { e: Edge, g: DirectedGraph }): void; + + finishVertex(req: { u: string, g: DirectedGraph }): void; + } + + export interface TraversalContext { + searchStatus: string; + colorMap: any; + undiscoveredMap: any; + } + + export interface TraversalOptions { + startVector: string | string[]; + allowEmptyStartVector: boolean; + signalStart: boolean; + traverseContext: TraversalContext; + } + + export interface TraversalParams { + digraph: DirectedGraph, + visitor: Visitor, + options?: TraversalOptions + } + + export interface TraversalResult { + error?: any; + result?: TraversalContext + } + + export type colors = { white: 0, gray: 1, black: 2 }; + + export interface Directed { + breadthFirstTraverse(params: TraversalParams): TraversalResult; + + colors: colors; + + create(): { result: DirectedGraph }; + + createTraversalContext(req: { dirgaph: DirectedGraph }): TraversalContext; + + depthFirstTraverse(params: TraversalParams): TraversalResult; + + transpose(graph: DirectedGraph): { error?: any, result?: DirectedGraph }; + + directedGraph: DirectedGraph; + + } +} + +declare var jsgraph: jsgraph.jsGraphStatic; + +export = jsgraph; diff --git a/types/jsgraph/jsgraph-tests.ts b/types/jsgraph/jsgraph-tests.ts new file mode 100644 index 0000000000..2fdab3c0bf --- /dev/null +++ b/types/jsgraph/jsgraph-tests.ts @@ -0,0 +1,43 @@ +import * as jsgraph from 'jsgraph'; +import {Edge, JsGraphResponse} from 'jsgraph'; + +const mygraph = jsgraph.directed.create().result; + +let name: string = 'my name'; +mygraph.setGraphName(name); +name = mygraph.getGraphName(); +let description: string = 'My desc'; +mygraph.setGraphDescription(description); +description = mygraph.getGraphDescription(); + +let count: number = mygraph.verticesCount(); +let verticies: string [] = mygraph.getVertices(); +count = mygraph.getEdgeCount(); +let edges: Edge[] = mygraph.getEdeges(); +count = mygraph.rootVerticesCount(); +verticies = mygraph.getRootVertices(); +count = mygraph.leafVerticesCount(); +verticies = mygraph.getLeafVertices(); +let json: string = mygraph.toObject(); +json = mygraph.toJSON(); +json = mygraph.stringify( () => {return}, 2); +const graph2 = mygraph.fromObject(mygraph); + +let response: JsGraphResponse = mygraph.addVertex({u: 'a', p: 'some data'}); +let bool: boolean = mygraph.removeVertex('a'); +let property: string = mygraph.getVertexProperty('a'); +mygraph.setVertexProperty({u: 'a', p: property}); +bool = mygraph.hasVertexProperty('a'); +bool = mygraph.clearVertexProperty('a'); +count = mygraph.inDegree('a'); +edges = mygraph.inEdges('a'); +count = mygraph.outDegree('a'); +edges = mygraph.outEdges('a'); + +response = mygraph.addEdge({e: {u: 'a', v:'b'}, p: 'some data'}); +bool = mygraph.isEdge({u: 'a', v:'b'}); +response = mygraph.removeEdge({u: 'a', v: 'b'}); +property = mygraph.getEdgeProperty({u: 'a', v: 'b'}); +response = mygraph.setEdgeProperty({e: {u: 'a', v: 'b'}, p: 'some data'}); +bool = mygraph.hasEdgeProperty({u: 'a', v: 'b'}); +bool = mygraph.clearEdgeProperty({u:'a', v: 'b'}); diff --git a/types/jsgraph/tsconfig.json b/types/jsgraph/tsconfig.json new file mode 100644 index 0000000000..22997eae59 --- /dev/null +++ b/types/jsgraph/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jsgraph-tests.ts" + ] +} diff --git a/types/jsgraph/tslint.json b/types/jsgraph/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/jsgraph/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/jss/index.d.ts b/types/jss/index.d.ts index 3318f9a565..c8e0f13c6c 100644 --- a/types/jss/index.d.ts +++ b/types/jss/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Brenton Simpson // Oleg Slobodskoi // Thomas Crockett +// Sebastian Silbermann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -137,6 +138,7 @@ export declare class JSS { * Creates a new instance of JSS. */ export function create(options?: Partial): JSS; +export function createGenerateClassName(): GenerateClassName; declare const sharedInstance: JSS; /** * A global JSS instance. diff --git a/types/jss/jss-tests.ts b/types/jss/jss-tests.ts index 5e9a876036..4c7fcc9270 100644 --- a/types/jss/jss-tests.ts +++ b/types/jss/jss-tests.ts @@ -2,11 +2,12 @@ import { create as createJSS, + createGenerateClassName, SheetsRegistry, default as sharedInstance, } from 'jss'; -const jss = createJSS().setup({}); +const jss = createJSS().setup({ createGenerateClassName }); jss.use({}, {}); // $ExpectType JSS const styleSheet = jss.createStyleSheet( diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index 54dece1068..8945a16168 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -138,14 +138,19 @@ declare namespace Knex { limit(limit: number): QueryBuilder; // Aggregation - count(columnName?: string): QueryBuilder; - countDistinct(columnName?: string): QueryBuilder; - min(columnName: string): QueryBuilder; - max(columnName: string): QueryBuilder; - sum(columnName: string): QueryBuilder; - sumDistinct(columnName: string): QueryBuilder; - avg(columnName: string): QueryBuilder; - avgDistinct(columnName: string): QueryBuilder; + count(...columnNames: string[]): QueryBuilder; + count(columnName: Record | Knex.Raw): QueryBuilder; + countDistinct(columnName: string | Record | Knex.Raw): QueryBuilder; + min(columnName: string, ...columnNames: string[]): QueryBuilder; + min(columnName: Record | Knex.Raw): QueryBuilder; + max(columnName: string, ...columnNames: string[]): QueryBuilder; + max(columnName: Record | Knex.Raw): QueryBuilder; + sum(columnName: string, ...columnNames: string[]): QueryBuilder; + sum(columnName: Record | Knex.Raw): QueryBuilder; + sumDistinct(columnName: string | Record | Knex.Raw): QueryBuilder; + avg(columnName: string, ...columnNames: string[]): QueryBuilder; + avg(columnName: Record | Knex.Raw): QueryBuilder; + avgDistinct(columnName: string | Record | Knex.Raw): QueryBuilder; increment(columnName: string, amount?: number): QueryBuilder; decrement(columnName: string, amount?: number): QueryBuilder; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index 0037948415..e7fb3e1b81 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -251,6 +251,58 @@ knex('users').whereRaw('id = ?', [1]); knex('users').whereRaw('id = :id', { id: 1 }); knex('users').whereRaw('id = :id', { id: knex('users').select('id').limit(1) }); +// Aggregate functions can use string/object parameters +knex('users').count(); +knex('users').count('*'); +knex('users').count('id', 'votes'); +knex('users').count({count: '*'}); +knex('users').count({count: ['id', 'votes']}); +knex('users').count({count: knex.raw('*')}); +knex('users').count(knex.raw('id')); + +knex('users').countDistinct('votes'); +knex('users').countDistinct(knex.raw('votes')); +knex('users').countDistinct({votes: 'votes'}); +knex('users').countDistinct({votes: knex.raw('votes')}); + +knex('users').avg('id'); +knex('users').avg('id', 'votes'); +knex('users').avg({avg: 'id'}); +knex('users').avg({avg: ['id', 'votes']}); +knex('users').avg({ab: knex.raw('a + b')}); +knex('users').avg(knex.raw('votes')); + +knex('users').avgDistinct('votes'); +knex('users').avgDistinct(knex.raw('votes')); +knex('users').avgDistinct({votes: 'votes'}); +knex('users').avgDistinct({votes: knex.raw('votes')}); + +knex('users').max('id'); +knex('users').max('id', 'votes'); +knex('users').max({max: 'id'}); +knex('users').max({max: ['id', 'votes']}); +knex('users').max({ab: knex.raw('a + b')}); +knex('users').max(knex.raw('votes')); + +knex('users').min('id'); +knex('users').min('id', 'votes'); +knex('users').min({min: 'id'}); +knex('users').min({min: ['id', 'votes']}); +knex('users').min({ab: knex.raw('a + b')}); +knex('users').min(knex.raw('votes')); + +knex('users').sum('id'); +knex('users').sum('id', 'votes'); +knex('users').sum({sum: 'id'}); +knex('users').sum({sum: ['id', 'votes']}); +knex('users').sum({ab: knex.raw('a + b')}); +knex('users').sum(knex.raw('votes')); + +knex('users').sumDistinct('votes'); +knex('users').sumDistinct(knex.raw('votes')); +knex('users').sumDistinct({votes: 'votes'}); +knex('users').sumDistinct({votes: knex.raw('votes')}); + // Join methods knex('users') .join('contacts', 'users.id', '=', 'contacts.user_id') diff --git a/types/koa-better-body/index.d.ts b/types/koa-better-body/index.d.ts new file mode 100644 index 0000000000..ab7cf5b21f --- /dev/null +++ b/types/koa-better-body/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for koa-better-body 3.0 +// Project: https://github.com/tunnckoCore/koa-better-body +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Context } from 'koa'; + +declare function KoaBetterBody(options?: KoaBetterBody.Options): KoaBetterBody.Body; + +declare namespace KoaBetterBody { + interface Options { + fields?: boolean | string; + files?: boolean | string; + multipart?: boolean; + textLimit?: string; + formLimit?: string; + urlencodedLimit?: string; + jsonLimit?: string; + bufferLimit?: string; + jsonStrict?: boolean; + detectJSON?: () => any; + strict?: boolean; + delimiter?: symbol; + decodeURIComponent?: any; + maxKeys?: number; + buffer?: boolean; + } + + type Body = (context: Context, next: () => void) => Generator; +} + +export = KoaBetterBody; diff --git a/types/koa-better-body/koa-better-body-tests.ts b/types/koa-better-body/koa-better-body-tests.ts new file mode 100644 index 0000000000..2f4deb2d49 --- /dev/null +++ b/types/koa-better-body/koa-better-body-tests.ts @@ -0,0 +1,11 @@ +import body = require('koa-better-body'); + +// $ExpectType Body +body(); + +const testOptions: body.Options = { + jsonLimit: '100mb', +}; + +// $ExpectType Body +body(testOptions); diff --git a/types/koa-better-body/tsconfig.json b/types/koa-better-body/tsconfig.json new file mode 100644 index 0000000000..74a794a11c --- /dev/null +++ b/types/koa-better-body/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-better-body-tests.ts" + ] +} diff --git a/types/koa-better-body/tslint.json b/types/koa-better-body/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/koa-better-body/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/koa-convert/index.d.ts b/types/koa-convert/index.d.ts new file mode 100644 index 0000000000..ed5cd38480 --- /dev/null +++ b/types/koa-convert/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for koa-convert 1.2 +// Project: https://github.com/koajs/convert +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Context, Middleware } from "koa"; + +declare function convert( + mw: (context: Context, next: () => void) => Generator +): Middleware; + +export = convert; diff --git a/types/koa-convert/koa-convert-tests.ts b/types/koa-convert/koa-convert-tests.ts new file mode 100644 index 0000000000..0a795e522b --- /dev/null +++ b/types/koa-convert/koa-convert-tests.ts @@ -0,0 +1,16 @@ +import convert = require('koa-convert'); +import Koa = require('koa'); + +const app = new Koa(); + +app.use(modernMiddleware); + +app.use(convert(legacyMiddleware)); + +function * legacyMiddleware(next: any) { + yield next; +} + +function modernMiddleware(ctx: Koa.Context, next: any) { + return next().then(() => {}); +} diff --git a/types/koa-convert/tsconfig.json b/types/koa-convert/tsconfig.json new file mode 100644 index 0000000000..c86211adaa --- /dev/null +++ b/types/koa-convert/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-convert-tests.ts" + ] +} diff --git a/types/koa-convert/tslint.json b/types/koa-convert/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/koa-convert/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/koa2-session-redis/index.d.ts b/types/koa2-session-redis/index.d.ts new file mode 100644 index 0000000000..24e85e1674 --- /dev/null +++ b/types/koa2-session-redis/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for koa2-session-redis 0.0 +// Project: https://github.com/lonord/koa2-session-redis +// Definitions by: Dima Mukhin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as Redis from 'redis'; +import * as session from 'koa-session'; + +export = RedisStore; + +declare class RedisStore implements session.stores { + constructor(config?: Redis.ClientOpts); + + /** + * get session object by key + */ + get(key: string): any; + + /** + * set session object for key, with a maxAge (in ms) + */ + set(key: string, sess: Partial & { _expire?: number, _maxAge?: number }, maxAge: session.opts["maxAge"]): any; + + /** + * destroy session for key + */ + destroy(key: string): any; + + /** + * sends the quit command to the redis server and ends cleanly right after all running commands were properly handled + */ + quit(): void; +} diff --git a/types/koa2-session-redis/koa2-session-redis-tests.ts b/types/koa2-session-redis/koa2-session-redis-tests.ts new file mode 100644 index 0000000000..7623b30aca --- /dev/null +++ b/types/koa2-session-redis/koa2-session-redis-tests.ts @@ -0,0 +1,15 @@ +import * as session from 'koa-session'; +import * as Koa from 'koa'; +import RedisStore = require('koa2-session-redis'); + +const app = new Koa(); + +const CONFIG = { + store: new RedisStore({ + host: '127.0.0.1', + port: 6379, + max_attempts: 0 + }) +}; + +app.use(session(CONFIG, app)); diff --git a/types/koa2-session-redis/tsconfig.json b/types/koa2-session-redis/tsconfig.json new file mode 100644 index 0000000000..e96bc50af3 --- /dev/null +++ b/types/koa2-session-redis/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", + "koa2-session-redis-tests.ts" + ] +} diff --git a/types/koa2-session-redis/tslint.json b/types/koa2-session-redis/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/koa2-session-redis/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-editable/index.d.ts b/types/leaflet-editable/index.d.ts index 932ca33fd2..f73befb161 100644 --- a/types/leaflet-editable/index.d.ts +++ b/types/leaflet-editable/index.d.ts @@ -124,6 +124,11 @@ declare module 'leaflet' { * When you need to stop any ongoing drawing, without needing to know which editor is active. */ stopDrawing(): void; + + /** + * When you need to commit any ongoing drawing, without needing to know which editor is active. + */ + commitDrawing(): void; } let Editable: EditableStatic; diff --git a/types/leaflet-editable/leaflet-editable-tests.ts b/types/leaflet-editable/leaflet-editable-tests.ts index 23bcc988fb..e804fcc250 100644 --- a/types/leaflet-editable/leaflet-editable-tests.ts +++ b/types/leaflet-editable/leaflet-editable-tests.ts @@ -31,6 +31,7 @@ const map: L.Map = L.map('div', { const currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; map.editTools.stopDrawing(); +map.editTools.commitDrawing(); const marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); marker.disable(); diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 89c9cbd9b9..0822dea605 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -612,10 +612,10 @@ export interface PolylineOptions extends PathOptions { } export class Polyline extends Path { - constructor(latlngs: LatLngExpression[], options?: PolylineOptions); + constructor(latlngs: LatLngExpression[] | LatLngExpression[][], options?: PolylineOptions); toGeoJSON(): geojson.Feature; getLatLngs(): LatLng[] | LatLng[][] | LatLng[][][]; - setLatLngs(latlngs: LatLngExpression[]): this; + setLatLngs(latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][]): this; isEmpty(): boolean; getCenter(): LatLng; getBounds(): LatLngBounds; @@ -625,13 +625,13 @@ export class Polyline extends Polyline { - constructor(latlngs: LatLngExpression[] | LatLngExpression[][], options?: PolylineOptions); + constructor(latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][], options?: PolylineOptions); } -export function polygon(latlngs: LatLngExpression[] | LatLngExpression[][], options?: PolylineOptions): Polygon; +export function polygon(latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][], options?: PolylineOptions): Polygon; export class Rectangle

            extends Polygon

            { constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions); diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index 1f6671cc8c..66f12fd0ed 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -473,15 +473,58 @@ L.marker([1, 2], { className: 'my-div-icon' })); -const latLngs = [ - {lat: 0, lng: 0}, - {lat: 1, lng: 1} -]; -const polygon = new L.Polygon(latLngs); -const polygonExclusion = new L.Polygon([latLngs, latLngs]); +let polygon: L.Polygon; -L.polygon(latLngs).addTo(map); -L.polygon([latLngs, latLngs]).addTo(map); +// simple polygon +const simplePolygonLatLngs: L.LatLngExpression[] = [[37, -109.05], [41, -109.03], [41, -102.05], [37, -102.04]]; +polygon = L.polygon(simplePolygonLatLngs); +polygon = new L.Polygon(simplePolygonLatLngs); +polygon.setLatLngs(simplePolygonLatLngs); +const simplePolygonLatLngs2: L.LatLng[] = polygon.getLatLngs() as L.LatLng[]; + +// complex polygon (polygon with holes) +const complexPolygonLatLngs: L.LatLngExpression[][] = [ + [[37, -109.05], [41, -109.03], [41, -102.05], [37, -102.04]], // outer ring + [[37.29, -108.58], [40.71, -108.58], [40.71, -102.50], [37.29, -102.50]] // hole +]; +polygon = L.polygon(complexPolygonLatLngs); +polygon = new L.Polygon(complexPolygonLatLngs); +polygon.setLatLngs(complexPolygonLatLngs); +const complexPolygonLatLngs2: L.LatLng[][] = polygon.getLatLngs() as L.LatLng[][]; + +// multi polygon +const multiPolygonLatLngs: L.LatLngExpression[][][] = [ + [ // first polygon + [[37, -109.05], [41, -109.03], [41, -102.05], [37, -102.04]], // outer ring + [[37.29, -108.58], [40.71, -108.58], [40.71, -102.50], [37.29, -102.50]] // hole + ], + [ // second polygon + [[41, -111.03], [45, -111.04], [45, -104.05], [41, -104.05]] + ] +]; +polygon = L.polygon(multiPolygonLatLngs); +polygon = new L.Polygon(multiPolygonLatLngs); +polygon.setLatLngs(multiPolygonLatLngs); +const multiPolygonLatLngs2: L.LatLng[][][] = polygon.getLatLngs() as L.LatLng[][][]; + +let polyline: L.Polyline; + +// simple polyline +const simplePolylineLatLngs: L.LatLngExpression[] = [[45.51, -122.68], [37.77, -122.43], [34.04, -118.2]]; +polyline = L.polyline(simplePolylineLatLngs); +polyline = new L.Polyline(simplePolylineLatLngs); +polyline.setLatLngs(simplePolylineLatLngs); +const simplePolylineLatLngs2: L.LatLng[] = polyline.getLatLngs() as L.LatLng[]; + +// multi polyline +const multiPolylineLatLngs: L.LatLngExpression[][] = [ + [[45.51, -122.68], [37.77, -122.43], [34.04, -118.2]], + [[40.78, -73.91], [41.83, -87.62], [32.76, -96.72]] +]; +polyline = L.polyline(multiPolylineLatLngs); +polyline = new L.Polyline(multiPolylineLatLngs); +polyline.setLatLngs(multiPolylineLatLngs); +const multiPolylineLatLngs2: L.LatLng[][] = polyline.getLatLngs() as L.LatLng[][]; L.Util.extend({}); L.Util.create({}); @@ -512,7 +555,7 @@ interface MyProperties { testProperty: string; } -(L.polygon(latLngs) as L.Polygon).feature.properties.testProperty = "test"; +(L.polygon(simplePolygonLatLngs) as L.Polygon).feature.properties.testProperty = "test"; (L.marker([1, 2], { icon: L.icon({ diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index 27b5d66dc9..3f09b5d6de 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.47.0 +// Type definitions for Mapbox GL JS v0.48.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer , Patrick Reames // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -63,9 +63,9 @@ declare namespace mapboxgl { isRotating(): boolean; - queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: { layers?: string[], filter?: any[] }): GeoJSON.Feature[]; + queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: { layers?: string[], filter?: any[] }): GeoJSON.Feature[]; - querySourceFeatures(sourceID: string, parameters?: { sourceLayer?: string, filter?: any[] }): GeoJSON.Feature[]; + querySourceFeatures(sourceID: string, parameters?: { sourceLayer?: string, filter?: any[] }): GeoJSON.Feature[]; setStyle(style: mapboxgl.Style | string, options?: { diff?: boolean, localIdeographFontFamily?: string }): this; @@ -226,6 +226,10 @@ declare namespace mapboxgl { /** ID of the container element */ container?: string | Element; + /** String or strings to show in an AttributionControl. + * Only applicable if options.attributionControl is `true`. */ + customAttribution?: string | string[]; + /** If true, enable the "drag to pan" interaction (see DragPanHandler). */ dragPan?: boolean; @@ -441,7 +445,7 @@ declare namespace mapboxgl { * Attribution */ export class AttributionControl extends Control { - constructor(options?: { compact?: boolean }); + constructor(options?: { compact?: boolean, customAttribution?: string | string[] }); } /** @@ -530,8 +534,6 @@ declare namespace mapboxgl { type: 'vector' | 'raster' | 'raster-dem' | 'geojson' | 'image' | 'video' | 'canvas'; } - export type GeoJSONGeometry = GeoJSON.Point | GeoJSON.LineString | GeoJSON.MultiPoint | GeoJSON.Polygon | GeoJSON.MultiLineString | GeoJSON.MultiPolygon | GeoJSON.GeometryCollection; - /** * GeoJSONSource */ @@ -545,17 +547,17 @@ declare namespace mapboxgl { constructor(options?: mapboxgl.GeoJSONSourceOptions); - setData(data: GeoJSON.Feature | GeoJSON.FeatureCollection | String): this; + setData(data: GeoJSON.Feature | GeoJSON.FeatureCollection | String): this; getClusterExpansionZoom(clusterId: number, callback: (error: any, zoom: number) => void): this; - getClusterChildren(clusterId: number, callback: (error: any, features: GeoJSON.Feature[]) => void): this; + getClusterChildren(clusterId: number, callback: (error: any, features: GeoJSON.Feature[]) => void): this; - getClusterLeaves(cluserId: number, limit: number, offset: number, callback: (error: any, features: GeoJSON.Feature[]) => void): this; + getClusterLeaves(cluserId: number, limit: number, offset: number, callback: (error: any, features: GeoJSON.Feature[]) => void): this; } export interface GeoJSONSourceOptions { - data?: GeoJSON.Feature | GeoJSON.FeatureCollection | string; + data?: GeoJSON.Feature | GeoJSON.FeatureCollection | string; maxzoom?: number; diff --git a/types/mapbox-gl/mapbox-gl-tests.ts b/types/mapbox-gl/mapbox-gl-tests.ts index 87297effda..783ee86f74 100644 --- a/types/mapbox-gl/mapbox-gl-tests.ts +++ b/types/mapbox-gl/mapbox-gl-tests.ts @@ -17,7 +17,8 @@ let map = new mapboxgl.Map({ minZoom: 1, maxZoom: 2, interactive: true, - attributionControl: false, + attributionControl: true, + customAttribution: '© YourCo', bearingSnap: 7, scrollZoom: true, maxBounds: [[-100,-90],[100,90]], @@ -387,6 +388,16 @@ let marker = new mapboxgl.Marker(undefined, {offset: [10, 0]}) .addTo(map); marker.remove(); + +/* + * LngLatBounds + */ let bool:boolean let bounds = new mapboxgl.LngLatBounds() bool = bounds.isEmpty() + +/* + * AttributionControl + */ +let attributionControl = new mapboxgl.AttributionControl({ compact: false, customAttribution: '© YourCo' }); +attributionControl.on('click', () => {}); diff --git a/types/meteor/accounts.d.ts b/types/meteor/accounts-base.d.ts similarity index 51% rename from types/meteor/accounts.d.ts rename to types/meteor/accounts-base.d.ts index b4e78c1664..6e25e71b07 100644 --- a/types/meteor/accounts.d.ts +++ b/types/meteor/accounts-base.d.ts @@ -1,54 +1,3 @@ -interface URLS { - resetPassword: (token: string) => string; - verifyEmail: (token: string) => string; - enrollAccount: (token: string) => string; -} - -interface EmailFields { - from?: () => string; - subject?: (user: Meteor.User) => string; - text?: (user: Meteor.User, url: string) => string; - html?: (user: Meteor.User, url: string) => string; -} - -declare module Accounts { - var urls: URLS; - - function user(): Meteor.User; - - function userId(): string; - - function createUser(options: { - username?: string; - email?: string; - password?: string; - profile?: Object; - }, callback?: Function): string; - - function config(options: { - sendVerificationEmail?: boolean; - forbidClientAccountCreation?: boolean; - restrictCreationByEmailDomain?: string | Function; - loginExpirationInDays?: number; - oauthSecretKey?: string; - passwordResetTokenExpirationInDays?: number; - passwordEnrollTokenExpirationInDays?: number; - ambiguousErrorMessages?: boolean; - }): void; - - function onLogin(func: Function): { - stop: () => void - }; - - function onLoginFailure(func: Function): { - stop: () => void - }; - - function loginServicesConfigured(): boolean; - - function onPageLoadLogin(func: Function): void; -} - declare module "meteor/accounts-base" { interface URLS { resetPassword: (token: string) => string; @@ -56,6 +5,13 @@ declare module "meteor/accounts-base" { enrollAccount: (token: string) => string; } + interface EmailFields { + from?: () => string; + subject?: (user: Meteor.User) => string; + text?: (user: Meteor.User, url: string) => string; + html?: (user: Meteor.User, url: string) => string; + } + module Accounts { var urls: URLS; @@ -93,42 +49,7 @@ declare module "meteor/accounts-base" { function onPageLoadLogin(func: Function): void; } -} -declare module Accounts { - function changePassword(oldPassword: string, newPassword: string, callback?: Function): void; - - function forgotPassword(options: { - email?: string; - }, callback?: Function): void; - - function resetPassword(token: string, newPassword: string, callback?: Function): void; - - function verifyEmail(token: string, callback?: Function): void; - - function onEmailVerificationLink(callback: Function): void; - - function onEnrollmentLink(callback: Function): void; - - function onResetPasswordLink(callback: Function): void; - - function loggingIn(): boolean; - - function logout(callback?: Function): void; - - function logoutOtherClients(callback?: Function): void; - - var ui: { - config(options: { - requestPermissions?: Object; - requestOfflineToken?: Object; - forceApprovalPrompt?: Object; - passwordSignupFields?: string; - }): void; - }; -} - -declare module "meteor/accounts-base" { module Accounts { function changePassword(oldPassword: string, newPassword: string, callback?: Function): void; @@ -161,72 +82,6 @@ declare module "meteor/accounts-base" { }): void; }; } -} - -interface Header { - [id: string]: string; -} - -interface EmailTemplates { - from: string; - siteName: string; - headers?: Header; - resetPassword: EmailFields; - enrollAccount: EmailFields; - verifyEmail: EmailFields; -} - -declare module Accounts { - var emailTemplates: EmailTemplates; - - function addEmail(userId: string, newEmail: string, verified?: boolean): void; - - function removeEmail(userId: string, email: string): void; - - function onCreateUser(func: Function): void; - - function findUserByEmail(email: string): Object; - - function findUserByUsername(username: string): Object; - - function sendEnrollmentEmail(userId: string, email?: string): void; - - function sendResetPasswordEmail(userId: string, email?: string): void; - - function sendVerificationEmail(userId: string, email?: string): void; - - function setUsername(userId: string, newUsername: string): void; - - function setPassword(userId: string, newPassword: string, options?: { - logout?: Object; - }): void; - - function validateNewUser(func: Function): boolean; - - function validateLoginAttempt(func: Function): { - stop: () => void - }; - - function _hashPassword(password: string): { digest: string; algorithm: string; }; - - interface IValidateLoginAttemptCbOpts { - type: string; - allowed: boolean; - error: Meteor.Error; - user: Meteor.User; - connection: Meteor.Connection; - methodName: string; - methodArguments: any[]; - } -} - -declare module "meteor/accounts-base" { - interface EmailFields { - from?: () => string; - subject?: (user: Meteor.User) => string; - text?: (user: Meteor.User, url: string) => string; - html?: (user: Meteor.User, url: string) => string; - } interface Header { [id: string]: string; @@ -284,23 +139,11 @@ declare module "meteor/accounts-base" { methodArguments: any[]; } } -} -declare module Accounts { - function onLogout(func: Function): void; -} - -declare module "meteor/accounts-base" { module Accounts { function onLogout(func: Function): void; } -} -declare module Accounts { - function onLogout(func: (user: Meteor.User, connection: Meteor.Connection) => void): void; -} - -declare module "meteor/accounts-base" { module Accounts { function onLogout(func: (user: Meteor.User, connection: Meteor.Connection) => void): void; } diff --git a/types/meteor/blaze.d.ts b/types/meteor/blaze.d.ts index dbb562558d..bd3b3cf79e 100644 --- a/types/meteor/blaze.d.ts +++ b/types/meteor/blaze.d.ts @@ -1,112 +1,3 @@ - -declare module Blaze { - var View: ViewStatic; - - interface ViewStatic { - new (name?: string, renderFunction?: Function): View; - } - - interface View { - name: string; - parentView: View; - isCreated: boolean; - isRendered: boolean; - isDestroyed: boolean; - renderCount: number; - autorun(runFunc: (computation: Tracker.Computation) => void): Tracker.Computation; - onViewCreated(func: Function): void; - onViewReady(func: Function): void; - onViewDestroyed(func: Function): void; - firstNode(): Node; - lastNode(): Node; - template: Template; - templateInstance(): TemplateInstance; - } - var currentView: View; - - function isTemplate(value: any): boolean; - - interface HelpersMap { - [key: string]: Function; - } - - interface EventsMap { - [key: string]: Function; - } - - var Template: TemplateStatic; - - interface TemplateStatic { - new (viewName?: string, renderFunction?: Function): Template; - - registerHelper(name: string, func: Function): void; - instance(): TemplateInstance; - currentData(): any; - parentData(numLevels: number): any; - } - - interface Template { - viewName: string; - renderFunction: Function; - constructView(): View; - head: Template; - find(selector: string): HTMLElement; - findAll(selector: string): HTMLElement[]; - $: any; - onCreated(cb: Function): void; - onRendered(cb: Function): void; - onDestroyed(cb: Function): void; - created: Function; - rendered: Function; - destroyed: Function; - helpers(helpersMap: HelpersMap): void; - events(eventsMap: EventsMap): void; - } - - var TemplateInstance: TemplateInstanceStatic; - - interface TemplateInstanceStatic { - new (view: View): TemplateInstance; - } - - interface TemplateInstance { - $(selector: string): any; - autorun(runFunc: (computation: Tracker.Computation) => void): Tracker.Computation; - data: Object; - find(selector: string): HTMLElement; - findAll(selector: string): HTMLElement[]; - firstNode: Object; - lastNode: Object; - subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; - subscriptionsReady(): boolean; - view: Object; - } - - function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): View; - - function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): View; - - function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): View; - - function Let(bindings: Function, contentFunc: Function): View; - - function With(data: Object | Function, contentFunc: Function): View; - - function getData(elementOrView?: HTMLElement | View): Object; - - function getView(element?: HTMLElement): View; - - function remove(renderedView: View): void; - - function render(templateOrView: Template | View, parentNode: Node, nextNode?: Node, parentView?: View): View; - - function renderWithData(templateOrView: Template | View, data: Object | Function, parentNode: Node, nextNode?: Node, parentView?: View): View; - - function toHTML(templateOrView: Template | View): string; - - function toHTMLWithData(templateOrView: Template | View, data: Object | Function): string; -} - declare module "meteor/blaze" { module Blaze { var View: ViewStatic; diff --git a/types/meteor/browser-policy-common.d.ts b/types/meteor/browser-policy-common.d.ts index 6d82eab683..4aa3810f45 100644 --- a/types/meteor/browser-policy-common.d.ts +++ b/types/meteor/browser-policy-common.d.ts @@ -1,39 +1,3 @@ - -declare module BrowserPolicy { - var framing: { - disallow(): void; - restrictToOrigin(origin: string): void; - allowAll(): void; - }; - - var content: { - allowEval(): void; - allowInlineStyles(): void; - allowInlineScripts(): void; - allowSameOriginForAll(): void; - allowDataUrlForAll(): void; - allowOriginForAll(origin: string): void; - allowImageOrigin(origin: string): void; - allowMediaOrigin(origin: string): void; - allowFontOrigin(origin: string): void; - allowStyleOrigin(origin: string): void; - allowScriptOrigin(origin: string): void; - allowFrameOrigin(origin: string): void; - allowContentTypeSniffing(): void; - allowAllContentOrigin(): void; - allowAllContentDataUrl(): void; - allowAllContentSameOrigin(): void; - - disallowAll(): void; - disallowInlineStyles(): void; - disallowEval(): void; - disallowInlineScripts(): void; - disallowFont(): void; - disallowObject(): void; - disallowAllContent(): void; - }; -} - declare module "meteor/browser-policy-common" { module BrowserPolicy { var framing: { diff --git a/types/meteor/check.d.ts b/types/meteor/check.d.ts index 57482cd3f5..065850fb4e 100644 --- a/types/meteor/check.d.ts +++ b/types/meteor/check.d.ts @@ -1,27 +1,3 @@ - -declare module Match { - var Any: any; - var String: any; - var Integer: any; - var Boolean: any; - var undefined: any; - var Object: any; - - function Maybe(pattern: any): boolean; - - function Optional(pattern: any): boolean; - - function ObjectIncluding(dico: any): boolean; - - function OneOf(...patterns: any[]): any; - - function Where(condition: any): any; - - function test(value: any, pattern: any): boolean; -} - -declare function check(value: any, pattern: any): void; - declare module "meteor/check" { module Match { var Any: any; diff --git a/types/meteor/ddp-rate-limiter.d.ts b/types/meteor/ddp-rate-limiter.d.ts index dc906f4ac1..86e47bf9ac 100644 --- a/types/meteor/ddp-rate-limiter.d.ts +++ b/types/meteor/ddp-rate-limiter.d.ts @@ -1,18 +1,3 @@ - -declare module DDPRateLimiter { - interface Matcher { - type?: string | ((type: string) => boolean); - name?: string | ((name: string) => boolean); - userId?: string | ((userId: string) => boolean); - connectionId?: string | ((connectionId: string) => boolean); - clientAddress?: string | ((clientAddress: string) => boolean); - } - - function addRule(matcher: Matcher, numRequests: number, timeInterval: number): string; - - function removeRule(ruleId: string): boolean; -} - declare module "meteor/ddp-rate-limiter" { module DDPRateLimiter { interface Matcher { diff --git a/types/meteor/ddp.d.ts b/types/meteor/ddp.d.ts index 083244d601..ea4ca4fc96 100644 --- a/types/meteor/ddp.d.ts +++ b/types/meteor/ddp.d.ts @@ -1,42 +1,3 @@ - - -declare module DDP { - interface DDPStatic { - subscribe(name: string, ...rest: any[]): Meteor.SubscriptionHandle; - call(method: string, ...parameters: any[]): void; - apply(method: string, ...parameters: any[]): void; - methods(IMeteorMethodsDictionary: any): any; - status(): DDPStatus; - reconnect(): void; - disconnect(): void; - onReconnect(): void; - } - - function _allSubscriptionsReady(): boolean; - - type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline'; - - interface DDPStatus { - connected: boolean; - status: Status; - retryCount: number; - retryTime?: number; - reason?: string; - } - - function connect(url: string): DDPStatic; -} - -declare module DDPCommon { - interface MethodInvocation { - new (options: {}): MethodInvocation; - - unblock(): void; - - setUserId(userId: number): void; - } -} - declare module "meteor/ddp" { module DDP { interface DDPStatic { diff --git a/types/meteor/ejson.d.ts b/types/meteor/ejson.d.ts index aa5cd0f5f9..3c9f161097 100644 --- a/types/meteor/ejson.d.ts +++ b/types/meteor/ejson.d.ts @@ -1,41 +1,3 @@ -interface EJSONableCustomType { - clone?(): EJSONableCustomType; - equals?(other: Object): boolean; - toJSONValue(): JSONable; - typeName(): string; -} -interface EJSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType | undefined | null; -} -interface JSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | undefined | null; -} -interface EJSON extends EJSONable { } - -declare module EJSON { - function addType(name: string, factory: (val: JSONable) => EJSONableCustomType): void; - - function clone(val: T): T; - - function equals(a: EJSON, b: EJSON, options?: { - keyOrderSensitive?: boolean; - }): boolean; - - function fromJSONValue(val: JSONable): any; - - function isBinary(x: Object): boolean; - var newBinary: any; - - function parse(str: string): EJSON; - - function stringify(val: EJSON, options?: { - indent?: boolean | number | string; - canonical?: boolean; - }): string; - - function toJSONValue(val: EJSON): JSONable; -} - declare module "meteor/ejson" { interface EJSONableCustomType { clone?(): EJSONableCustomType; diff --git a/types/meteor/email.d.ts b/types/meteor/email.d.ts index 0e0e81590d..464dbed8a9 100644 --- a/types/meteor/email.d.ts +++ b/types/meteor/email.d.ts @@ -1,38 +1,3 @@ -declare module Email { - function send(options: { - from?: string; - to?: string | string[]; - cc?: string | string[]; - bcc?: string | string[]; - replyTo?: string | string[]; - subject?: string; - text?: string; - html?: string; - headers?: Object; - attachments?: Object[]; - mailComposer?: MailComposer; - }): void; -} - -interface MailComposerOptions { - escapeSMTP: boolean; - encoding: string; - charset: string; - keepBcc: boolean; - forceEmbeddedImages: boolean; -} - -declare var MailComposer: MailComposerStatic; -interface MailComposerStatic { - new (options: MailComposerOptions): MailComposer; -} -interface MailComposer { - addHeader(name: string, value: string): void; - setMessageOption(from: string, to: string, body: string, html: string): void; - streamMessage(): void; - pipe(stream: any /** fs.WriteStream **/): void; -} - declare module "meteor/email" { module Email { function send(options: { diff --git a/types/meteor/globals/README.md b/types/meteor/globals/README.md new file mode 100644 index 0000000000..b9e3615b2b --- /dev/null +++ b/types/meteor/globals/README.md @@ -0,0 +1,3 @@ +This `globals/` directory is generated by `scripts/generate-globals`! To update +this directory, edit the corresponding files outside `globals/` and re-run +`scripts/generate-globals`. \ No newline at end of file diff --git a/types/meteor/globals/accounts-base.d.ts b/types/meteor/globals/accounts-base.d.ts new file mode 100644 index 0000000000..f7b914f734 --- /dev/null +++ b/types/meteor/globals/accounts-base.d.ts @@ -0,0 +1,148 @@ +declare interface URLS { + resetPassword: (token: string) => string; + verifyEmail: (token: string) => string; + enrollAccount: (token: string) => string; +} + +declare interface EmailFields { + from?: () => string; + subject?: (user: Meteor.User) => string; + text?: (user: Meteor.User, url: string) => string; + html?: (user: Meteor.User, url: string) => string; +} + +declare module Accounts { + var urls: URLS; + + function user(): Meteor.User; + + function userId(): string; + + function createUser(options: { + username?: string; + email?: string; + password?: string; + profile?: Object; + }, callback?: Function): string; + + function config(options: { + sendVerificationEmail?: boolean; + forbidClientAccountCreation?: boolean; + restrictCreationByEmailDomain?: string | Function; + loginExpirationInDays?: number; + oauthSecretKey?: string; + passwordResetTokenExpirationInDays?: number; + passwordEnrollTokenExpirationInDays?: number; + ambiguousErrorMessages?: boolean; + }): void; + + function onLogin(func: Function): { + stop: () => void + }; + + function onLoginFailure(func: Function): { + stop: () => void + }; + + function loginServicesConfigured(): boolean; + + function onPageLoadLogin(func: Function): void; +} + +declare module Accounts { + function changePassword(oldPassword: string, newPassword: string, callback?: Function): void; + + function forgotPassword(options: { + email?: string; + }, callback?: Function): void; + + function resetPassword(token: string, newPassword: string, callback?: Function): void; + + function verifyEmail(token: string, callback?: Function): void; + + function onEmailVerificationLink(callback: Function): void; + + function onEnrollmentLink(callback: Function): void; + + function onResetPasswordLink(callback: Function): void; + + function loggingIn(): boolean; + + function logout(callback?: Function): void; + + function logoutOtherClients(callback?: Function): void; + + var ui: { + config(options: { + requestPermissions?: Object; + requestOfflineToken?: Object; + forceApprovalPrompt?: Object; + passwordSignupFields?: string; + }): void; + }; +} + +declare interface Header { + [id: string]: string; +} + +declare interface EmailTemplates { + from: string; + siteName: string; + headers?: Header; + resetPassword: EmailFields; + enrollAccount: EmailFields; + verifyEmail: EmailFields; +} + +declare module Accounts { + var emailTemplates: EmailTemplates; + + function addEmail(userId: string, newEmail: string, verified?: boolean): void; + + function removeEmail(userId: string, email: string): void; + + function onCreateUser(func: Function): void; + + function findUserByEmail(email: string): Object; + + function findUserByUsername(username: string): Object; + + function sendEnrollmentEmail(userId: string, email?: string): void; + + function sendResetPasswordEmail(userId: string, email?: string): void; + + function sendVerificationEmail(userId: string, email?: string): void; + + function setUsername(userId: string, newUsername: string): void; + + function setPassword(userId: string, newPassword: string, options?: { + logout?: Object; + }): void; + + function validateNewUser(func: Function): boolean; + + function validateLoginAttempt(func: Function): { + stop: () => void + }; + + function _hashPassword(password: string): { digest: string; algorithm: string; }; + + interface IValidateLoginAttemptCbOpts { + type: string; + allowed: boolean; + error: Meteor.Error; + user: Meteor.User; + connection: Meteor.Connection; + methodName: string; + methodArguments: any[]; + } +} + +declare module Accounts { + function onLogout(func: Function): void; +} + +declare module Accounts { + function onLogout(func: (user: Meteor.User, connection: Meteor.Connection) => void): void; +} diff --git a/types/meteor/globals/blaze.d.ts b/types/meteor/globals/blaze.d.ts new file mode 100644 index 0000000000..2082382100 --- /dev/null +++ b/types/meteor/globals/blaze.d.ts @@ -0,0 +1,107 @@ +declare module Blaze { + var View: ViewStatic; + + interface ViewStatic { + new (name?: string, renderFunction?: Function): View; + } + + interface View { + name: string; + parentView: View; + isCreated: boolean; + isRendered: boolean; + isDestroyed: boolean; + renderCount: number; + autorun(runFunc: (computation: Tracker.Computation) => void): Tracker.Computation; + onViewCreated(func: Function): void; + onViewReady(func: Function): void; + onViewDestroyed(func: Function): void; + firstNode(): Node; + lastNode(): Node; + template: Template; + templateInstance(): TemplateInstance; + } + var currentView: View; + + function isTemplate(value: any): boolean; + + interface HelpersMap { + [key: string]: Function; + } + + interface EventsMap { + [key: string]: Function; + } + + var Template: TemplateStatic; + + interface TemplateStatic { + new (viewName?: string, renderFunction?: Function): Template; + + registerHelper(name: string, func: Function): void; + instance(): TemplateInstance; + currentData(): any; + parentData(numLevels: number): any; + } + + interface Template { + viewName: string; + renderFunction: Function; + constructView(): View; + head: Template; + find(selector: string): HTMLElement; + findAll(selector: string): HTMLElement[]; + $: any; + onCreated(cb: Function): void; + onRendered(cb: Function): void; + onDestroyed(cb: Function): void; + created: Function; + rendered: Function; + destroyed: Function; + helpers(helpersMap: HelpersMap): void; + events(eventsMap: EventsMap): void; + } + + var TemplateInstance: TemplateInstanceStatic; + + interface TemplateInstanceStatic { + new (view: View): TemplateInstance; + } + + interface TemplateInstance { + $(selector: string): any; + autorun(runFunc: (computation: Tracker.Computation) => void): Tracker.Computation; + data: Object; + find(selector: string): HTMLElement; + findAll(selector: string): HTMLElement[]; + firstNode: Object; + lastNode: Object; + subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; + subscriptionsReady(): boolean; + view: Object; + } + + function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): View; + + function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): View; + + function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): View; + + function Let(bindings: Function, contentFunc: Function): View; + + function With(data: Object | Function, contentFunc: Function): View; + + function getData(elementOrView?: HTMLElement | View): Object; + + function getView(element?: HTMLElement): View; + + function remove(renderedView: View): void; + + function render(templateOrView: Template | View, parentNode: Node, nextNode?: Node, parentView?: View): View; + + function renderWithData(templateOrView: Template | View, data: Object | Function, parentNode: Node, nextNode?: Node, parentView?: View): View; + + function toHTML(templateOrView: Template | View): string; + + function toHTMLWithData(templateOrView: Template | View, data: Object | Function): string; +} diff --git a/types/meteor/globals/browser-policy-common.d.ts b/types/meteor/globals/browser-policy-common.d.ts new file mode 100644 index 0000000000..826065844f --- /dev/null +++ b/types/meteor/globals/browser-policy-common.d.ts @@ -0,0 +1,34 @@ +declare module BrowserPolicy { + var framing: { + disallow(): void; + restrictToOrigin(origin: string): void; + allowAll(): void; + }; + + var content: { + allowEval(): void; + allowInlineStyles(): void; + allowInlineScripts(): void; + allowSameOriginForAll(): void; + allowDataUrlForAll(): void; + allowOriginForAll(origin: string): void; + allowImageOrigin(origin: string): void; + allowMediaOrigin(origin: string): void; + allowFontOrigin(origin: string): void; + allowStyleOrigin(origin: string): void; + allowScriptOrigin(origin: string): void; + allowFrameOrigin(origin: string): void; + allowContentTypeSniffing(): void; + allowAllContentOrigin(): void; + allowAllContentDataUrl(): void; + allowAllContentSameOrigin(): void; + + disallowAll(): void; + disallowInlineStyles(): void; + disallowEval(): void; + disallowInlineScripts(): void; + disallowFont(): void; + disallowObject(): void; + disallowAllContent(): void; + }; +} diff --git a/types/meteor/globals/check.d.ts b/types/meteor/globals/check.d.ts new file mode 100644 index 0000000000..1b1ec39736 --- /dev/null +++ b/types/meteor/globals/check.d.ts @@ -0,0 +1,22 @@ +declare module Match { + var Any: any; + var String: any; + var Integer: any; + var Boolean: any; + var undefined: any; + var Object: any; + + function Maybe(pattern: any): boolean; + + function Optional(pattern: any): boolean; + + function ObjectIncluding(dico: any): boolean; + + function OneOf(...patterns: any[]): any; + + function Where(condition: any): any; + + function test(value: any, pattern: any): boolean; +} + +declare function check(value: any, pattern: any): void; diff --git a/types/meteor/globals/ddp-rate-limiter.d.ts b/types/meteor/globals/ddp-rate-limiter.d.ts new file mode 100644 index 0000000000..5093837eb1 --- /dev/null +++ b/types/meteor/globals/ddp-rate-limiter.d.ts @@ -0,0 +1,13 @@ +declare module DDPRateLimiter { + interface Matcher { + type?: string | ((type: string) => boolean); + name?: string | ((name: string) => boolean); + userId?: string | ((userId: string) => boolean); + connectionId?: string | ((connectionId: string) => boolean); + clientAddress?: string | ((clientAddress: string) => boolean); + } + + function addRule(matcher: Matcher, numRequests: number, timeInterval: number): string; + + function removeRule(ruleId: string): boolean; +} diff --git a/types/meteor/globals/ddp.d.ts b/types/meteor/globals/ddp.d.ts new file mode 100644 index 0000000000..2b92528391 --- /dev/null +++ b/types/meteor/globals/ddp.d.ts @@ -0,0 +1,36 @@ +declare module DDP { + interface DDPStatic { + subscribe(name: string, ...rest: any[]): Meteor.SubscriptionHandle; + call(method: string, ...parameters: any[]): void; + apply(method: string, ...parameters: any[]): void; + methods(IMeteorMethodsDictionary: any): any; + status(): DDPStatus; + reconnect(): void; + disconnect(): void; + onReconnect(): void; + } + + function _allSubscriptionsReady(): boolean; + + type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline'; + + interface DDPStatus { + connected: boolean; + status: Status; + retryCount: number; + retryTime?: number; + reason?: string; + } + + function connect(url: string): DDPStatic; +} + +declare module DDPCommon { + interface MethodInvocation { + new (options: {}): MethodInvocation; + + unblock(): void; + + setUserId(userId: number): void; + } +} diff --git a/types/meteor/globals/ejson.d.ts b/types/meteor/globals/ejson.d.ts new file mode 100644 index 0000000000..3a85075c6b --- /dev/null +++ b/types/meteor/globals/ejson.d.ts @@ -0,0 +1,37 @@ +declare interface EJSONableCustomType { + clone?(): EJSONableCustomType; + equals?(other: Object): boolean; + toJSONValue(): JSONable; + typeName(): string; +} +declare interface EJSONable { + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType | undefined | null; +} +declare interface JSONable { + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | undefined | null; +} +declare interface EJSON extends EJSONable { } + +declare module EJSON { + function addType(name: string, factory: (val: JSONable) => EJSONableCustomType): void; + + function clone(val: T): T; + + function equals(a: EJSON, b: EJSON, options?: { + keyOrderSensitive?: boolean; + }): boolean; + + function fromJSONValue(val: JSONable): any; + + function isBinary(x: Object): boolean; + var newBinary: any; + + function parse(str: string): EJSON; + + function stringify(val: EJSON, options?: { + indent?: boolean | number | string; + canonical?: boolean; + }): string; + + function toJSONValue(val: EJSON): JSONable; +} diff --git a/types/meteor/globals/email.d.ts b/types/meteor/globals/email.d.ts new file mode 100644 index 0000000000..f80528893b --- /dev/null +++ b/types/meteor/globals/email.d.ts @@ -0,0 +1,34 @@ +declare module Email { + function send(options: { + from?: string; + to?: string | string[]; + cc?: string | string[]; + bcc?: string | string[]; + replyTo?: string | string[]; + subject?: string; + text?: string; + html?: string; + headers?: Object; + attachments?: Object[]; + mailComposer?: MailComposer; + }): void; +} + +declare interface MailComposerOptions { + escapeSMTP: boolean; + encoding: string; + charset: string; + keepBcc: boolean; + forceEmbeddedImages: boolean; +} + +declare var MailComposer: MailComposerStatic; +declare interface MailComposerStatic { + new (options: MailComposerOptions): MailComposer; +} +declare interface MailComposer { + addHeader(name: string, value: string): void; + setMessageOption(from: string, to: string, body: string, html: string): void; + streamMessage(): void; + pipe(stream: any /** fs.WriteStream **/): void; +} diff --git a/types/meteor/globals/http.d.ts b/types/meteor/globals/http.d.ts new file mode 100644 index 0000000000..88a67fe790 --- /dev/null +++ b/types/meteor/globals/http.d.ts @@ -0,0 +1,48 @@ +declare module HTTP { + interface HTTPRequest { + content?: string; + data?: any; + query?: string; + params?: { + [id: string]: string + }; + auth?: string; + headers?: { + [id: string]: string + }; + timeout?: number; + followRedirects?: boolean; + } + + interface HTTPResponse { + statusCode?: number; + headers?: { + [id: string]: string + }; + content?: string; + data?: any; + } + + function call(method: string, url: string, options?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; + + function del(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; + + function get(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; + + function post(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; + + function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; + + function call(method: string, url: string, options?: { + content?: string; + data?: Object; + query?: string; + params?: Object; + auth?: string; + headers?: Object; + timeout?: number; + followRedirects?: boolean; + npmRequestOptions?: Object; + beforeSend?: Function; + }, asyncCallback?: Function): HTTP.HTTPResponse; +} diff --git a/types/meteor/globals/meteor.d.ts b/types/meteor/globals/meteor.d.ts new file mode 100644 index 0000000000..7a90b0611e --- /dev/null +++ b/types/meteor/globals/meteor.d.ts @@ -0,0 +1,220 @@ +declare module Meteor { + /** Global props **/ + var isClient: boolean; + var isCordova: boolean; + var isServer: boolean; + var isProduction: boolean; + var release: string; + /** Global props **/ + + /** Settings **/ + interface Settings { + public: { + [id: string]: any + }, [id: string]: any + } + var settings: Settings; + /** Settings **/ + + /** User **/ + interface UserEmail { + address: string; + verified: boolean; + } + interface User { + _id?: string; + username?: string; + emails?: UserEmail[]; + createdAt?: number; + profile?: any; + services?: any; + } + + function user(): User; + + function userId(): string; + var users: Mongo.Collection; + /** User **/ + + /** Error **/ + var Error: ErrorStatic; + interface ErrorStatic { + new (error: string | number, reason?: string, details?: string): Error; + } + interface Error { + error: string | number; + reason?: string; + details?: string; + } + /** Error **/ + + /** Method **/ + function methods(methods: Object): void; + + function call(name: string, ...args: any[]): any; + + function apply(name: string, args: EJSONable[], options?: { + wait?: boolean; + onResultReceived?: Function; + returnStubValue?: boolean; + throwStubExceptions?: boolean; + }, asyncCallback?: Function): any; + /** Method **/ + + /** Url **/ + function absoluteUrl(path?: string, options?: { + secure?: boolean; + replaceLocalhost?: boolean; + rootUrl?: string; + }): string; + /** Url **/ + + /** Timeout **/ + function setInterval(func: Function, delay: number): number; + + function setTimeout(func: Function, delay: number): number; + + function clearInterval(id: number): void; + + function clearTimeout(id: number): void; + + function defer(func: Function): void; + /** Timeout **/ + + /** utils **/ + function startup(func: Function): void; + + function wrapAsync(func: Function, context?: Object): any; + + function bindEnvironment(func: Function): any; + /** utils **/ + + /** Pub/Sub **/ + interface SubscriptionHandle { + stop(): void; + ready(): boolean; + } + interface LiveQueryHandle { + stop(): void; + } + /** Pub/Sub **/ +} + +declare module Meteor { + /** Login **/ + interface LoginWithExternalServiceOptions { + requestPermissions?: string[]; + requestOfflineToken?: Boolean; + forceApprovalPrompt?: Boolean; + loginUrlParameters?: Object; + redirectUrl?: string; + loginHint?: string; + loginStyle?: string; + } + + function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + + function loggingIn(): boolean; + + function loginWith(options?: { + requestPermissions?: string[]; + requestOfflineToken?: boolean; + loginUrlParameters?: Object; + userEmail?: string; + loginStyle?: string; + redirectUrl?: string; + }, callback?: Function): void; + + function loginWithPassword(user: Object | string, password: string, callback?: Function): void; + + function loginWithToken(token: string, callback?: Function): void; + + function logout(callback?: Function): void; + + function logoutOtherClients(callback?: Function): void; + /** Login **/ + + /** Event **/ + interface Event { + type: string; + target: HTMLElement; + currentTarget: HTMLElement; + which: number; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + isPropagationStopped(): boolean; + isImmediatePropagationStopped(): boolean; + isDefaultPrevented(): boolean; + } + interface EventHandlerFunction extends Function { + (event?: Meteor.Event, templateInstance?: Blaze.TemplateInstance): void; + } + interface EventMap { + [id: string]: Meteor.EventHandlerFunction; + } + /** Event **/ + + /** Connection **/ + function reconnect(): void; + + function disconnect(): void; + /** Connection **/ + + /** Status **/ + function status(): DDP.DDPStatus; + /** Status **/ + + /** Pub/Sub **/ + function subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; + /** Pub/Sub **/ +} + +declare module Meteor { + /** Connection **/ + interface Connection { + id: string; + close: Function; + onClose: Function; + clientAddress: string; + httpHeaders: Object; + } + + function onConnection(callback: Function): void; + /** Connection **/ + + function publish(name: string, func: Function): void; + + function _debug(...args: any[]): void; +} + +declare interface Subscription { + added(collection: string, id: string, fields: Object): void; + changed(collection: string, id: string, fields: Object): void; + connection: Meteor.Connection; + error(error: Error): void; + onStop(func: Function): void; + ready(): void; + removed(collection: string, id: string): void; + stop(): void; + userId: string; +} + +declare module Meteor { + /** Global props **/ + var isDevelopment: boolean; + var isTest: boolean; + /** Global props **/ +} diff --git a/types/meteor/globals/mongo.d.ts b/types/meteor/globals/mongo.d.ts new file mode 100644 index 0000000000..108008febe --- /dev/null +++ b/types/meteor/globals/mongo.d.ts @@ -0,0 +1,234 @@ +declare module Mongo { + + type BsonType = 1 | "double" | + 2 | "string" | + 3 | "object" | + 4 | "array" | + 5 | "binData" | + 6 | "undefined" | + 7 | "objectId" | + 8 | "bool" | + 9 | "date" | + 10 | "null" | + 11 | "regex" | + 12 | "dbPointer" | + 13 | "javascript" | + 14 | "symbol" | + 15 | "javascriptWithScope" | + 16 | "int" | + 17 | "timestamp" | + 18 | "long" | + 19 | "decimal" | + -1 | "minKey" | + 127 | "maxKey" | "number" + + type FieldExpression = { + $eq?: T, + $gt?: T, + $gte?: T, + $lt?: T, + $lte?: T, + $in?: T[], + $nin?: T[], + $ne?: T, + $exists?: boolean, + $type?: BsonType[] | BsonType, + $not?: FieldExpression, + $expr?: FieldExpression, + $jsonSchema?: any, + $mod?: number[], + $regex?: RegExp | string, + $options?: string, + $text?: { $search: string, $language?: string, $caseSensitive?: boolean, $diacriticSensitive?: boolean }, + $where?: string | Function, + $geoIntersects?: any, + $geoWithin?: any, + $near?: any, + $nearSphere?: any, + $all?: T[], + $elemMatch?: T extends {} ? Query : FieldExpression, + $size?: number, + $bitsAllClear?: any, + $bitsAllSet?: any, + $bitsAnyClear?: any, + $bitsAnySet?: any, + $comment?: string + } + + type Flatten = T extends any[] ? T[0] : T + + type Query = { + [P in keyof T]?: Flatten | RegExp | FieldExpression> + } & { + $or?: Query[], + $and?: Query[], + $nor?: Query[] + } & Dictionary + + type QueryWithModifiers = { + $query: Query, + $comment?: string, + $explain?: any, + $hint?: any, + $maxScan?: any, + $max?: any, + $maxTimeMS?: any, + $min?: any, + $orderby?: any, + $returnKey?: any, + $showDiskLoc?: any, + $natural?: any + } + + type Selector = Query | QueryWithModifiers + + type Dictionary = { [key: string]: T } + type PartialMapTo = Partial> + type OnlyArrays = T extends any[] ? T : never; + type OnlyElementsOfArrays = T extends any[] ? Partial : never + type ElementsOf = { + [P in keyof T]?: OnlyElementsOfArrays + } + type PushModifier = { + [P in keyof T]?: + OnlyElementsOfArrays | + { $each?: T[P], $position?: number, $slice?: number, $sort?: 1 | -1 | Dictionary } + } + type ArraysOrEach = { + [P in keyof T]?: OnlyArrays | { $each: T[P] } + } + type CurrentDateModifier = { $type: "timestamp" | "date" } | true + type Modifier = T | { + $currentDate?: Partial> & Dictionary, + $inc?: PartialMapTo & Dictionary, + $min?: PartialMapTo & Dictionary, + $max?: PartialMapTo & Dictionary, + $mul?: PartialMapTo & Dictionary, + $rename?: PartialMapTo & Dictionary, + $set?: Partial & Dictionary, + $setOnInsert?: Partial & Dictionary, + $unset?: PartialMapTo & Dictionary, + $addToSet?: ArraysOrEach & Dictionary, + $push?: PushModifier & Dictionary, + $pull?: ElementsOf & Dictionary, + $pullAll?: Partial & Dictionary, + $pop?: PartialMapTo & Dictionary<1 | -1>, + } + + + interface SortSpecifier { } + interface FieldSpecifier { + [id: string]: Number; + } + + var Collection: CollectionStatic; + interface CollectionStatic { + new (name: string, options?: { + connection?: Object | null; + idGeneration?: string; + transform?: Function; + }): Collection; + } + interface Collection { + allow(options: { + insert?: (userId: string, doc: T) => boolean; + update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean; + remove?: (userId: string, doc: T) => boolean; + fetch?: string[]; + transform?: Function; + }): boolean; + deny(options: { + insert?: (userId: string, doc: T) => boolean; + update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean; + remove?: (userId: string, doc: T) => boolean; + fetch?: string[]; + transform?: Function; + }): boolean; + find(selector?: Selector | ObjectID | string, options?: { + sort?: SortSpecifier; + skip?: number; + limit?: number; + fields?: FieldSpecifier; + reactive?: boolean; + transform?: Function; + }): Cursor; + findOne(selector?: Selector | ObjectID | string, options?: { + sort?: SortSpecifier; + skip?: number; + fields?: FieldSpecifier; + reactive?: boolean; + transform?: Function; + }): T; + insert(doc: T, callback?: Function): string; + rawCollection(): any; + rawDatabase(): any; + remove(selector: Selector | ObjectID | string, callback?: Function): number; + update(selector: Selector | ObjectID | string, modifier: Modifier, options?: { + multi?: boolean; + upsert?: boolean; + }, callback?: Function): number; + upsert(selector: Selector | ObjectID | string, modifier: Modifier, options?: { + multi?: boolean; + }, callback?: Function): { + numberAffected?: number; insertedId?: string; + }; + _ensureIndex(keys: { + [key: string]: number | string + } | string, options?: { + [key: string]: any + }): void; + _dropIndex(keys: { + [key: string]: number | string + } | string): void; + } + + var Cursor: CursorStatic; + interface CursorStatic { + new (): Cursor; + } + interface ObserveCallbacks { + added?(document: Object): void; + addedAt?(document: Object, atIndex: number, before: Object): void; + changed?(newDocument: Object, oldDocument: Object): void; + changedAt?(newDocument: Object, oldDocument: Object, indexAt: number): void; + removed?(oldDocument: Object): void; + removedAt?(oldDocument: Object, atIndex: number): void; + movedTo?(document: Object, fromIndex: number, toIndex: number, before: Object): void; + } + interface ObserveChangesCallbacks { + added?(id: string, fields: Object): void; + addedBefore?(id: string, fields: Object, before: Object): void; + changed?(id: string, fields: Object): void; + movedBefore?(id: string, before: Object): void; + removed?(id: string): void; + } + interface Cursor { + count(applySkipLimit?: boolean): number; + fetch(): Array; + forEach(callback: (doc: T, index: number, cursor: Cursor) => void, thisArg?: any): void; + map(callback: (doc: T, index: number, cursor: Cursor) => U, thisArg?: any): Array; + observe(callbacks: ObserveCallbacks): Meteor.LiveQueryHandle; + observeChanges(callbacks: ObserveChangesCallbacks): Meteor.LiveQueryHandle; + } + + var ObjectID: ObjectIDStatic; + interface ObjectIDStatic { + new(hexString?: string): ObjectID; + } + interface ObjectID { + toHexString(): string; + equals(otherID: ObjectID): boolean; + } + + function setConnectionOptions(options: any): void; +} + +declare module Mongo { + interface AllowDenyOptions { + insert?: (userId: string, doc: any) => boolean; + update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean; + remove?: (userId: string, doc: any) => boolean; + fetch?: string[]; + transform?: Function; + } +} diff --git a/types/meteor/globals/random.d.ts b/types/meteor/globals/random.d.ts new file mode 100644 index 0000000000..db334d98c6 --- /dev/null +++ b/types/meteor/globals/random.d.ts @@ -0,0 +1,13 @@ +declare module Random { + function id(numberOfChars?: number): string; + + function secret(numberOfChars?: number): string; + + function fraction(): number; + // @param numberOfDigits, @returns a random hex string of the given length + function hexString(numberOfDigits: number): string; + // @param array, @return a random element in array + function choice(array: any[]): string; + // @param str, @return a random char in str + function choice(str: string): string; +} diff --git a/types/meteor/globals/reactive-var.d.ts b/types/meteor/globals/reactive-var.d.ts new file mode 100644 index 0000000000..5d322ad27b --- /dev/null +++ b/types/meteor/globals/reactive-var.d.ts @@ -0,0 +1,8 @@ +declare var ReactiveVar: ReactiveVarStatic; +declare interface ReactiveVarStatic { + new (initialValue: T, equalsFunc?: Function): ReactiveVar; +} +declare interface ReactiveVar { + get(): T; + set(newValue: T): void; +} diff --git a/types/meteor/globals/session.d.ts b/types/meteor/globals/session.d.ts new file mode 100644 index 0000000000..1e7c4f24f2 --- /dev/null +++ b/types/meteor/globals/session.d.ts @@ -0,0 +1,9 @@ +declare module Session { + function equals(key: string, value: string | number | boolean | any): boolean; + + function get(key: string): any; + + function set(key: string, value: EJSONable | any): void; + + function setDefault(key: string, value: EJSONable | any): void; +} diff --git a/types/meteor/globals/templating.d.ts b/types/meteor/globals/templating.d.ts new file mode 100644 index 0000000000..5962fb9a71 --- /dev/null +++ b/types/meteor/globals/templating.d.ts @@ -0,0 +1,6 @@ +declare var Template: TemplateStatic; +declare interface TemplateStatic extends Blaze.TemplateStatic { + new (viewName?: string, renderFunction?: Function): Blaze.Template; + body: Blaze.Template; + [index: string]: any | Blaze.Template; +} diff --git a/types/meteor/globals/tiny-test.d.ts b/types/meteor/globals/tiny-test.d.ts new file mode 100644 index 0000000000..1289d87d23 --- /dev/null +++ b/types/meteor/globals/tiny-test.d.ts @@ -0,0 +1,36 @@ +declare interface ILengthAble { + length: number; +} + +declare interface ITinytestAssertions { + ok(doc: Object): void; + expect_fail(): void; + fail(doc: Object): void; + runId(): string; + equal(actual: T, expected: T, message?: string, not?: boolean): void; + notEqual(actual: T, expected: T, message?: string): void; + instanceOf(obj: Object, klass: Function, message?: string): void; + notInstanceOf(obj: Object, klass: Function, message?: string): void; + matches(actual: any, regexp: RegExp, message?: string): void; + notMatches(actual: any, regexp: RegExp, message?: string): void; + throws(f: Function, expected?: string | RegExp): void; + isTrue(v: boolean, msg?: string): void; + isFalse(v: boolean, msg?: string): void; + isNull(v: any, msg?: string): void; + isNotNull(v: any, msg?: string): void; + isUndefined(v: any, msg?: string): void; + isNotUndefined(v: any, msg?: string): void; + isNan(v: any, msg?: string): void; + isNotNan(v: any, msg?: string): void; + include(s: Array | Object | string, value: any, msg?: string, not?: boolean): void; + + notInclude(s: Array | Object | string, value: any, msg?: string, not?: boolean): void; + length(obj: ILengthAble, expected_length: number, msg?: string): void; + _stringEqual(actual: string, expected: string, msg?: string): void; +} + +declare module Tinytest { + function add(description: string, func: (test: ITinytestAssertions) => void): void; + + function addAsync(description: string, func: (test: ITinytestAssertions) => void): void; +} diff --git a/types/meteor/globals/tools.d.ts b/types/meteor/globals/tools.d.ts new file mode 100644 index 0000000000..ecba67f06b --- /dev/null +++ b/types/meteor/globals/tools.d.ts @@ -0,0 +1,102 @@ +declare module App { + function accessRule(pattern: string, options?: { + type?: string; + launchExternal?: boolean; + }): void; + + function configurePlugin(id: string, config: Object): void; + + function icons(icons: Object): void; + + function info(options: { + id?: string; + version?: string; + name?: string; + description?: string; + author?: string; + email?: string; + website?: string; + }): void; + + function launchScreens(launchScreens: Object): void; + + function setPreference(name: string, value: string, platform?: string): void; +} + +declare function execFileAsync(command: string, args?: any[], options?: { + cwd?: Object; + env?: Object; + stdio?: any[] | string; + destination?: any; + waitForClose?: string; +}): any; +declare function execFileSync(command: string, args?: any[], options?: { + cwd?: Object; + env?: Object; + stdio?: any[] | string; + destination?: any; + waitForClose?: string; +}): String; + +declare module Assets { + function getBinary(assetPath: string, asyncCallback?: Function): EJSON; + + function getText(assetPath: string, asyncCallback?: Function): string; + + function absoluteFilePath(assetPath: string): string; +} + +declare module Cordova { + function depends(dependencies: { + [id: string]: string + }): void; +} + +declare module Npm { + function depends(dependencies: { + [id: string]: string + }): void; + + function require(name: string): any; +} + +declare namespace Package { + function describe(options: { + summary?: string; + version?: string; + name?: string; + git?: string; + documentation?: string; + debugOnly?: boolean; + prodOnly?: boolean; + testOnly?: boolean; + }): void; + + function onTest(func: (api: PackageAPI) => void): void; + + function onUse(func: (api: PackageAPI) => void): void; + + function registerBuildPlugin(options?: { + name?: string; + use?: string | string[]; + sources?: string[]; + npmDependencies?: Object; + }): void; +} + +declare interface PackageAPI { + new (): PackageAPI; + addAssets(filenames: string | string[], architecture: string | string[]): void; + addFiles(filenames: string | string[], architecture?: string | string[], options?: { + bare?: boolean; + }): void; + export(exportedObjects: string | string[], architecture?: string | string[], exportOptions?: Object, testOnly?: boolean): void; + imply(packageNames: string | string[], architecture?: string | string[]): void; + use(packageNames: string | string[], architecture?: string | string[], options?: { + weak?: boolean; + unordered?: boolean; + }): void; + versionsFrom(meteorRelease: string | string[]): void; +} + +declare var console: Console; diff --git a/types/meteor/globals/tracker.d.ts b/types/meteor/globals/tracker.d.ts new file mode 100644 index 0000000000..15c1be408a --- /dev/null +++ b/types/meteor/globals/tracker.d.ts @@ -0,0 +1,37 @@ +declare module Tracker { + function Computation(): void; + interface Computation { + firstRun: boolean; + invalidate(): void; + invalidated: boolean; + onInvalidate(callback: Function): void; + onStop(callback: Function): void; + stop(): void; + stopped: boolean; + } + var currentComputation: Computation; + + var Dependency: DependencyStatic; + interface DependencyStatic { + new (): Dependency; + } + interface Dependency { + changed(): void; + depend(fromComputation?: Computation): boolean; + hasDependents(): boolean; + } + + var active: boolean; + + function afterFlush(callback: Function): void; + + function autorun(runFunc: (computation: Computation) => void, options?: { + onError?: Function; + }): Computation; + + function flush(): void; + + function nonreactive(func: Function): void; + + function onInvalidate(callback: Function): void; +} diff --git a/types/meteor/http.d.ts b/types/meteor/http.d.ts index 0d8bb6afa1..166a5cf96a 100644 --- a/types/meteor/http.d.ts +++ b/types/meteor/http.d.ts @@ -1,52 +1,3 @@ -declare module HTTP { - interface HTTPRequest { - content?: string; - data?: any; - query?: string; - params?: { - [id: string]: string - }; - auth?: string; - headers?: { - [id: string]: string - }; - timeout?: number; - followRedirects?: boolean; - } - - interface HTTPResponse { - statusCode?: number; - headers?: { - [id: string]: string - }; - content?: string; - data?: any; - } - - function call(method: string, url: string, options?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; - - function del(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; - - function get(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; - - function post(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; - - function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; - - function call(method: string, url: string, options?: { - content?: string; - data?: Object; - query?: string; - params?: Object; - auth?: string; - headers?: Object; - timeout?: number; - followRedirects?: boolean; - npmRequestOptions?: Object; - beforeSend?: Function; - }, asyncCallback?: Function): HTTP.HTTPResponse; -} - declare module "meteor/http" { module HTTP { interface HTTPRequest { diff --git a/types/meteor/index.d.ts b/types/meteor/index.d.ts index fad7da05bf..0822bab8e7 100644 --- a/types/meteor/index.d.ts +++ b/types/meteor/index.d.ts @@ -11,25 +11,43 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -/// +/// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// +/// /// /// /// +/// /// +/// /// +/// /// +/// /// +/// /// /// diff --git a/types/meteor/meteor.d.ts b/types/meteor/meteor.d.ts index 07c1365459..ca08c31c98 100644 --- a/types/meteor/meteor.d.ts +++ b/types/meteor/meteor.d.ts @@ -1,105 +1,3 @@ -declare module Meteor { - /** Global props **/ - var isClient: boolean; - var isCordova: boolean; - var isServer: boolean; - var isProduction: boolean; - var release: string; - /** Global props **/ - - /** Settings **/ - interface Settings { - public: { - [id: string]: any - }, [id: string]: any - } - var settings: Settings; - /** Settings **/ - - /** User **/ - interface UserEmail { - address: string; - verified: boolean; - } - interface User { - _id?: string; - username?: string; - emails?: UserEmail[]; - createdAt?: number; - profile?: any; - services?: any; - } - - function user(): User; - - function userId(): string; - var users: Mongo.Collection; - /** User **/ - - /** Error **/ - var Error: ErrorStatic; - interface ErrorStatic { - new (error: string | number, reason?: string, details?: string): Error; - } - interface Error { - error: string | number; - reason?: string; - details?: string; - } - /** Error **/ - - /** Method **/ - function methods(methods: Object): void; - - function call(name: string, ...args: any[]): any; - - function apply(name: string, args: EJSONable[], options?: { - wait?: boolean; - onResultReceived?: Function; - returnStubValue?: boolean; - throwStubExceptions?: boolean; - }, asyncCallback?: Function): any; - /** Method **/ - - /** Url **/ - function absoluteUrl(path?: string, options?: { - secure?: boolean; - replaceLocalhost?: boolean; - rootUrl?: string; - }): string; - /** Url **/ - - /** Timeout **/ - function setInterval(func: Function, delay: number): number; - - function setTimeout(func: Function, delay: number): number; - - function clearInterval(id: number): void; - - function clearTimeout(id: number): void; - - function defer(func: Function): void; - /** Timeout **/ - - /** utils **/ - function startup(func: Function): void; - - function wrapAsync(func: Function, context?: Object): any; - - function bindEnvironment(func: Function): any; - /** utils **/ - - /** Pub/Sub **/ - interface SubscriptionHandle { - stop(): void; - ready(): boolean; - } - interface LiveQueryHandle { - stop(): void; - } - /** Pub/Sub **/ -} - declare module "meteor/meteor" { module Meteor { /** Global props **/ @@ -202,91 +100,7 @@ declare module "meteor/meteor" { } /** Pub/Sub **/ } -} -declare module Meteor { - /** Login **/ - interface LoginWithExternalServiceOptions { - requestPermissions?: string[]; - requestOfflineToken?: Boolean; - forceApprovalPrompt?: Boolean; - loginUrlParameters?: Object; - redirectUrl?: string; - loginHint?: string; - loginStyle?: string; - } - - function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; - - function loggingIn(): boolean; - - function loginWith(options?: { - requestPermissions?: string[]; - requestOfflineToken?: boolean; - loginUrlParameters?: Object; - userEmail?: string; - loginStyle?: string; - redirectUrl?: string; - }, callback?: Function): void; - - function loginWithPassword(user: Object | string, password: string, callback?: Function): void; - - function loginWithToken(token: string, callback?: Function): void; - - function logout(callback?: Function): void; - - function logoutOtherClients(callback?: Function): void; - /** Login **/ - - /** Event **/ - interface Event { - type: string; - target: HTMLElement; - currentTarget: HTMLElement; - which: number; - stopPropagation(): void; - stopImmediatePropagation(): void; - preventDefault(): void; - isPropagationStopped(): boolean; - isImmediatePropagationStopped(): boolean; - isDefaultPrevented(): boolean; - } - interface EventHandlerFunction extends Function { - (event?: Meteor.Event, templateInstance?: Blaze.TemplateInstance): void; - } - interface EventMap { - [id: string]: Meteor.EventHandlerFunction; - } - /** Event **/ - - /** Connection **/ - function reconnect(): void; - - function disconnect(): void; - /** Connection **/ - - /** Status **/ - function status(): DDP.DDPStatus; - /** Status **/ - - /** Pub/Sub **/ - function subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; - /** Pub/Sub **/ -} - -declare module "meteor/meteor" { module Meteor { /** Login **/ interface LoginWithExternalServiceOptions { @@ -368,39 +182,7 @@ declare module "meteor/meteor" { function subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; /** Pub/Sub **/ } -} -declare module Meteor { - /** Connection **/ - interface Connection { - id: string; - close: Function; - onClose: Function; - clientAddress: string; - httpHeaders: Object; - } - - function onConnection(callback: Function): void; - /** Connection **/ - - function publish(name: string, func: Function): void; - - function _debug(...args: any[]): void; -} - -interface Subscription { - added(collection: string, id: string, fields: Object): void; - changed(collection: string, id: string, fields: Object): void; - connection: Meteor.Connection; - error(error: Error): void; - onStop(func: Function): void; - ready(): void; - removed(collection: string, id: string): void; - stop(): void; - userId: string; -} - -declare module "meteor/meteor" { module Meteor { /** Connection **/ interface Connection { @@ -430,16 +212,7 @@ declare module "meteor/meteor" { stop(): void; userId: string; } -} -declare module Meteor { - /** Global props **/ - var isDevelopment: boolean; - var isTest: boolean; - /** Global props **/ -} - -declare module "meteor/meteor" { module Meteor { /** Global props **/ var isDevelopment: boolean; diff --git a/types/meteor/mongo.d.ts b/types/meteor/mongo.d.ts index 771d24edc1..ced791205b 100644 --- a/types/meteor/mongo.d.ts +++ b/types/meteor/mongo.d.ts @@ -1,230 +1,6 @@ -declare module Mongo { - - type BsonType = 1 | "double" | - 2 | "string" | - 3 | "object" | - 4 | "array" | - 5 | "binData" | - 6 | "undefined" | - 7 | "objectId" | - 8 | "bool" | - 9 | "date" | - 10 | "null" | - 11 | "regex" | - 12 | "dbPointer" | - 13 | "javascript" | - 14 | "symbol" | - 15 | "javascriptWithScope" | - 16 | "int" | - 17 | "timestamp" | - 18 | "long" | - 19 | "decimal" | - -1 | "minKey" | - 127 | "maxKey" | "number" - - type FieldExpression = { - $eq?: T, - $gt?: T, - $gte?: T, - $lt?: T, - $lte?: T, - $in?: T[], - $nin?: T[], - $ne?: T, - $exists?: boolean, - $type?: BsonType[] | BsonType, - $not?: FieldExpression, - $expr?: FieldExpression, - $jsonSchema?: any, - $mod?: number[], - $regex?: RegExp | string, - $options?: string, - $text?: { $search: string, $language?: string, $caseSensitive?: boolean, $diacriticSensitive?: boolean }, - $where?: string | Function, - $geoIntersects?: any, - $geoWithin?: any, - $near?: any, - $nearSphere?: any, - $all?: T[], - $elemMatch?: T extends {} ? Query : FieldExpression, - $size?: number, - $bitsAllClear?: any, - $bitsAllSet?: any, - $bitsAnyClear?: any, - $bitsAnySet?: any, - $comment?: string - } - - type Flatten = T extends any[] ? T[0] : T - - type Query = { - [P in keyof T]?: Flatten | RegExp | FieldExpression> - } & { - $or?: Query[], - $and?: Query[], - $nor?: Query[] - } & Dictionary - - type QueryWithModifiers = { - $query: Query, - $comment?: string, - $explain?: any, - $hint?: any, - $maxScan?: any, - $max?: any, - $maxTimeMS?: any, - $min?: any, - $orderby?: any, - $returnKey?: any, - $showDiskLoc?: any, - $natural?: any - } - - type Selector = Query | QueryWithModifiers - - type Dictionary = { [key: string]: T } - type PartialMapTo = Partial> - type OnlyArrays = T extends any[] ? T : never; - type OnlyElementsOfArrays = T extends any[] ? Partial : never - type ElementsOf = { - [P in keyof T]?: OnlyElementsOfArrays - } - type PushModifier = { - [P in keyof T]?: - OnlyElementsOfArrays | - { $each?: T[P], $position?: number, $slice?: number, $sort?: 1 | -1 | Dictionary } - } - type ArraysOrEach = { - [P in keyof T]?: OnlyArrays | { $each: T[P] } - } - type CurrentDateModifier = { $type: "timestamp" | "date" } | true - type Modifier = T | { - $currentDate?: Partial> & Dictionary, - $inc?: PartialMapTo & Dictionary, - $min?: PartialMapTo & Dictionary, - $max?: PartialMapTo & Dictionary, - $mul?: PartialMapTo & Dictionary, - $rename?: PartialMapTo & Dictionary, - $set?: Partial & Dictionary, - $setOnInsert?: Partial & Dictionary, - $unset?: PartialMapTo & Dictionary, - $addToSet?: ArraysOrEach & Dictionary, - $push?: PushModifier & Dictionary, - $pull?: ElementsOf & Dictionary, - $pullAll?: Partial & Dictionary, - $pop?: PartialMapTo & Dictionary<1 | -1>, - } - - - interface SortSpecifier { } - interface FieldSpecifier { - [id: string]: Number; - } - - var Collection: CollectionStatic; - interface CollectionStatic { - new (name: string, options?: { - connection?: Object | null; - idGeneration?: string; - transform?: Function; - }): Collection; - } - interface Collection { - allow(options: { - insert?: (userId: string, doc: T) => boolean; - update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean; - remove?: (userId: string, doc: T) => boolean; - fetch?: string[]; - transform?: Function; - }): boolean; - deny(options: { - insert?: (userId: string, doc: T) => boolean; - update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean; - remove?: (userId: string, doc: T) => boolean; - fetch?: string[]; - transform?: Function; - }): boolean; - find(selector?: Selector | ObjectID | string, options?: { - sort?: SortSpecifier; - skip?: number; - limit?: number; - fields?: FieldSpecifier; - reactive?: boolean; - transform?: Function; - }): Cursor; - findOne(selector?: Selector | ObjectID | string, options?: { - sort?: SortSpecifier; - skip?: number; - fields?: FieldSpecifier; - reactive?: boolean; - transform?: Function; - }): T; - insert(doc: T, callback?: Function): string; - rawCollection(): any; - rawDatabase(): any; - remove(selector: Selector | ObjectID | string, callback?: Function): number; - update(selector: Selector | ObjectID | string, modifier: Modifier, options?: { - multi?: boolean; - upsert?: boolean; - }, callback?: Function): number; - upsert(selector: Selector | ObjectID | string, modifier: Modifier, options?: { - multi?: boolean; - }, callback?: Function): { - numberAffected?: number; insertedId?: string; - }; - _ensureIndex(keys: { - [key: string]: number | string - } | string, options?: { - [key: string]: any - }): void; - _dropIndex(keys: { - [key: string]: number | string - } | string): void; - } - - var Cursor: CursorStatic; - interface CursorStatic { - new (): Cursor; - } - interface ObserveCallbacks { - added?(document: Object): void; - addedAt?(document: Object, atIndex: number, before: Object): void; - changed?(newDocument: Object, oldDocument: Object): void; - changedAt?(newDocument: Object, oldDocument: Object, indexAt: number): void; - removed?(oldDocument: Object): void; - removedAt?(oldDocument: Object, atIndex: number): void; - movedTo?(document: Object, fromIndex: number, toIndex: number, before: Object): void; - } - interface ObserveChangesCallbacks { - added?(id: string, fields: Object): void; - addedBefore?(id: string, fields: Object, before: Object): void; - changed?(id: string, fields: Object): void; - movedBefore?(id: string, before: Object): void; - removed?(id: string): void; - } - interface Cursor { - count(applySkipLimit?: boolean): number; - fetch(): Array; - forEach(callback: < T > (doc: T, index: number, cursor: Cursor) => void, thisArg?: any): void; - map(callback: (doc: T, index: number, cursor: Cursor) => U, thisArg?: any): Array; - observe(callbacks: ObserveCallbacks): Meteor.LiveQueryHandle; - observeChanges(callbacks: ObserveChangesCallbacks): Meteor.LiveQueryHandle; - } - - var ObjectID: ObjectIDStatic; - interface ObjectIDStatic { - new(hexString?: string): ObjectID; - } - interface ObjectID { - toHexString(): string; - equals(otherID: ObjectID): boolean; - } - - function setConnectionOptions(options: any): void; -} - declare module "meteor/mongo" { module Mongo { + type BsonType = 1 | "double" | 2 | "string" | 3 | "object" | @@ -340,6 +116,7 @@ declare module "meteor/mongo" { $pop?: PartialMapTo & Dictionary<1 | -1>, } + interface SortSpecifier { } interface FieldSpecifier { [id: string]: Number; @@ -446,19 +223,7 @@ declare module "meteor/mongo" { function setConnectionOptions(options: any): void; } -} -declare module Mongo { - interface AllowDenyOptions { - insert?: (userId: string, doc: any) => boolean; - update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean; - remove?: (userId: string, doc: any) => boolean; - fetch?: string[]; - transform?: Function; - } -} - -declare module "meteor/mongo" { module Mongo { interface AllowDenyOptions { insert?: (userId: string, doc: any) => boolean; diff --git a/types/meteor/random.d.ts b/types/meteor/random.d.ts index 6a0232088f..775616396e 100644 --- a/types/meteor/random.d.ts +++ b/types/meteor/random.d.ts @@ -1,17 +1,3 @@ -declare module Random { - function id(numberOfChars?: number): string; - - function secret(numberOfChars?: number): string; - - function fraction(): number; - // @param numberOfDigits, @returns a random hex string of the given length - function hexString(numberOfDigits: number): string; - // @param array, @return a random element in array - function choice(array: any[]): string; - // @param str, @return a random char in str - function choice(str: string): string; -} - declare module "meteor/random" { module Random { function id(numberOfChars?: number): string; diff --git a/types/meteor/reactive-var.d.ts b/types/meteor/reactive-var.d.ts index 8426433b7f..ec399d598f 100644 --- a/types/meteor/reactive-var.d.ts +++ b/types/meteor/reactive-var.d.ts @@ -1,12 +1,3 @@ -declare var ReactiveVar: ReactiveVarStatic; -interface ReactiveVarStatic { - new (initialValue: T, equalsFunc?: Function): ReactiveVar; -} -interface ReactiveVar { - get(): T; - set(newValue: T): void; -} - declare module "meteor/reactive-var" { var ReactiveVar: ReactiveVarStatic; interface ReactiveVarStatic { diff --git a/types/meteor/scripts/generate-globals b/types/meteor/scripts/generate-globals new file mode 100755 index 0000000000..3c5f8fc781 --- /dev/null +++ b/types/meteor/scripts/generate-globals @@ -0,0 +1,79 @@ +#!/usr/bin/env node + +/* +For a Meteor package that is exposed as both a global and an ES6 module, we +unfortunately need to provide two copies of the typings for compatibility with +existing code that expects to augment and use either the global or the ES6 +module. We maintain the module typings by hand and use this script to generate +the global typings in the `globals/` subdirectory. Not every package is exposed +globally; `generate-globals` reads `tsconfig.json` to get the list of expected +files in `globals/`. Similarly, we maintain `meteor-tests.ts` (which tests the +the modules that also have globals) by hand, and this script generates +`globals/meteor-tests.ts` (which tests the globals). + +Usage: scripts/generate-globals + +This script may be used by Meteor typings packages in DefinitelyTyped other than +`meteor` itself. + +Inspired by prior art (but not believed to constitute a derivative work): +https://github.com/meteor-typings/meteor/blob/09ef92da99549ac090603ce70cfa632db4fad6e7/gulpfile.js#L43 +*/ + +// @ts-check + +// We are relying on the following modules to be transitive dependencies of +// DefinitelyTyped and npm 5 to install them in a place visible to us. :/ +let ts = require("typescript"); +let path = require("path"); +let os = require("os"); +let fs = require("fs"); +let mkdirp = require("mkdirp"); +let rimraf = require("rimraf"); + +function formatDiagnostic(diag) { + return ts.flattenDiagnosticMessageText(diag.messageText, os.EOL); +} + +let rcfResult = ts.readConfigFile("tsconfig.json", (path) => { + try { + return fs.readFileSync(path, "UTF-8"); + } catch (e) { + return undefined; + } +}); +let configObject = rcfResult.config; +if (!configObject) { + throw new Error(formatDiagnostic(rcfResult.error)); +} +rimraf.sync("globals"); +rimraf.sync("test/globals"); +let readmeText = `This \`globals/\` directory is generated by \`scripts/generate-globals\`! To update +this directory, edit the corresponding files outside \`globals/\` and re-run +\`scripts/generate-globals\`.`.replace("\n", os.EOL); +mkdirp.sync("globals"); +fs.writeFileSync("globals/README.md", readmeText, "UTF-8"); +mkdirp.sync("test/globals"); +fs.writeFileSync("test/globals/README.md", readmeText, "UTF-8"); +for (let outFile of configObject.files) { + let m = /^(test\/)?globals\/(.*)$/.exec(outFile); + if (m) { + let inFile = (m[1] || "") + m[2]; + let inLines = fs.readFileSync(inFile, "UTF-8").split(os.EOL); + let isTest = !!m[1]; + let outLines = inLines.map((l) => { + if (/^import /.test(l)) return null; + if (isTest) { + return l; + } else { + let m2; + if ((m2 = /^ ([^} ].*)$/.exec(l)) != null) return "declare " + m2[1]; + if ((m2 = /^ (.*)$/.exec(l)) != null) return m2[1]; + if (l == "") return l; + return null; // Strip `declare module "..." {` and `}`. + } + }).filter((l) => l != null); + mkdirp.sync(path.dirname(outFile)); + fs.writeFileSync(outFile, outLines.join(os.EOL), "UTF-8"); + } +} diff --git a/types/meteor/session.d.ts b/types/meteor/session.d.ts index 3dad5e682c..221e0e379e 100644 --- a/types/meteor/session.d.ts +++ b/types/meteor/session.d.ts @@ -1,14 +1,3 @@ - -declare module Session { - function equals(key: string, value: string | number | boolean | any): boolean; - - function get(key: string): any; - - function set(key: string, value: EJSONable | any): void; - - function setDefault(key: string, value: EJSONable | any): void; -} - declare module "meteor/session" { module Session { function equals(key: string, value: string | number | boolean | any): boolean; diff --git a/types/meteor/templating.d.ts b/types/meteor/templating.d.ts index e3b05109fb..0d8da7e899 100644 --- a/types/meteor/templating.d.ts +++ b/types/meteor/templating.d.ts @@ -1,11 +1,3 @@ - -declare var Template: TemplateStatic; -interface TemplateStatic extends Blaze.TemplateStatic { - new (viewName?: string, renderFunction?: Function): Blaze.Template; - body: Blaze.Template; - [index: string]: any | Blaze.Template; -} - declare module "meteor/templating" { var Template: TemplateStatic; interface TemplateStatic extends Blaze.TemplateStatic { diff --git a/types/meteor/test/globals/README.md b/types/meteor/test/globals/README.md new file mode 100644 index 0000000000..b9e3615b2b --- /dev/null +++ b/types/meteor/test/globals/README.md @@ -0,0 +1,3 @@ +This `globals/` directory is generated by `scripts/generate-globals`! To update +this directory, edit the corresponding files outside `globals/` and re-run +`scripts/generate-globals`. \ No newline at end of file diff --git a/types/meteor/test/globals/meteor-tests.ts b/types/meteor/test/globals/meteor-tests.ts new file mode 100644 index 0000000000..c2145be0a6 --- /dev/null +++ b/types/meteor/test/globals/meteor-tests.ts @@ -0,0 +1,785 @@ +// This file may use only modules that have corresponding globals, because +// `globals/meteor-tests.ts` is generated from it. Tests that involve modules +// that don't have corresponding globals belong in +// `meteor-tests-module-only.ts`. + +/** + * All code below was copied from the examples at http://docs.meteor.com/. + * When necessary, code was added to make the examples work (e.g. declaring a variable + * that was assumed to have been declared earlier) + */ + +/*********************************** Begin setup for tests ******************************/ + +// Avoid conflicts between `meteor-tests.ts` and `globals/meteor-tests.ts`. +namespace MeteorTests { + +var Rooms = new Mongo.Collection('rooms'); +var Messages = new Mongo.Collection('messages'); +interface MonkeyDAO { + _id: string; + name: string; +} +var Monkeys = new Mongo.Collection('monkeys'); +//var x = new Mongo.Collection('x'); +//var y = new Mongo.Collection('y'); +/********************************** End setup for tests *********************************/ + + +/** + * From Core, Meteor.startup section + * Tests Meteor.isServer, Meteor.startup, Collection.insert(), Collection.find() + */ +if (Meteor.isServer) { + Meteor.startup(function () { + if (Rooms.find().count() === 0) { + Rooms.insert({ name: "Initial room" }); + } + }); +} + +/** + * From Publish and Subscribe, Meteor.publish section + **/ +Meteor.publish("rooms", function () { + return Rooms.find({}, { fields: { secretInfo: 0 } }); +}); + +Meteor.publish("adminSecretInfo", function () { + return Rooms.find({ admin: this.userId }, { fields: { secretInfo: 1 } }); +}); + +Meteor.publish("roomAndMessages", function (roomId: string) { + check(roomId, String); + return [ + Rooms.find({ _id: roomId }, { fields: { secretInfo: 0 } }), + Messages.find({ roomId: roomId }) + ]; +}); + +/** + * Also from Publish and Subscribe, Meteor.publish section + */ +Meteor.publish("counts-by-room", function (roomId: string) { + var self = this; + check(roomId, String); + var count = 0; + var initializing = true; + var handle = Messages.find({ roomId: roomId }).observeChanges({ + added: function (id: any) { + count++; + // if (!initializing) + // this.changed("counts", roomId, {count: count}); + }, + removed: function (id: any) { + count--; + // Todo: Not sure how to define in typescript + // self.changed("counts", roomId, {count: count}); + } + }); + + initializing = false; + + // Todo: Not sure how to define in typescript + // self.added("counts", roomId, {count: count}); + self.ready(); + + self.onStop(function () { + handle.stop(); + }); +}); + +var Counts = new Mongo.Collection("counts"); + +Tracker.autorun(function () { + Meteor.subscribe("counts-by-room", Session.get("roomId")); +}); + +// Checking status +let status: DDP.Status = 'connected'; + +console.log("Current room has " + + Counts.find(Session.get("roomId")).count + + " messages."); + +/** + * From Publish and Subscribe, Meteor.subscribe section + */ +Meteor.subscribe("allplayers"); + +/** + * Also from Meteor.subscribe section + */ +Tracker.autorun(function () { + Meteor.subscribe("chat", { room: Session.get("current-room") }); + Meteor.subscribe("privateMessages"); +}); + +/** + * From Methods, Meteor.methods section + */ +Meteor.methods({ + foo: function (arg1: string, arg2: number[]) { + check(arg1, String); + check(arg2, [Number]); + + var you_want_to_throw_an_error = true; + if (you_want_to_throw_an_error) + throw new Meteor.Error("404", "Can't find my pants"); + return "some return value"; + }, + + bar: function () { + // .. do other stuff .. + return "baz"; + } +}); + +/** + * From Methods, Meteor.Error section + */ +function meteorErrorTestFunction1() { + throw new Meteor.Error("logged-out", + "The user must be logged in to post a comment."); +} + +function meteorErrorTestFunction2() { + throw new Meteor.Error(403, + "The user must be logged in to post a comment."); +} + +Meteor.call("methodName", function (error: Meteor.Error) { + if (error.error === "logged-out") { + Session.set("errorMessage", "Please log in to post a comment."); + } +}); +var error = new Meteor.Error("logged-out", "The user must be logged in to post a comment."); +console.log(error.error === "logged-out"); +console.log(error.reason === "The user must be logged in to post a comment."); +console.log(error.details !== ""); + +/** + * From Methods, Meteor.call section + */ +Meteor.call('foo', 1, 2, function (error: any, result: any) { }); +var result = Meteor.call('foo', 1, 2); + +/** + * From Collections, Mongo.Collection section + */ +// DA: I added the "var" keyword in there + +interface ChatroomsDAO { + _id?: string; +} +interface MessagesDAO { + _id?: string; +} +var Chatrooms = new Mongo.Collection("chatrooms"); +Messages = new Mongo.Collection("messages"); + +var myMessages: any[] = Messages.find({ userId: Session.get('myUserId') }).fetch(); + +Messages.insert({ text: "Hello, world!" }); + +Messages.update(myMessages[0]._id, { $set: { important: true } }); + +var Posts = new Mongo.Collection("posts"); +Posts.insert({ title: "Hello world", body: "First post" }); + +// Couldn't find assert() in the meteor docs +//assert(Posts.find().count() === 1); + +/** + * Todo: couldn't figure out how to make this next line work with Typescript + * since there is already a Collection constructor with a different signature + * + var Scratchpad = new Mongo.Collection; + for (var i = 0; i < 10; i++) + Scratchpad.insert({number: i * 2}); + assert(Scratchpad.find({number: {$lt: 9}}).count() === 5); + **/ + +class Animal { + constructor(doc: any) {} +} + +interface AnimalDAO { + _id?: string; + name: string; + sound: string; + makeNoise?: () => void; +} + +// Define a Collection that uses Animal as its document +var Animals = new Mongo.Collection("Animals", { + transform: function (doc: any): Animal { return new Animal(doc); } +}); + +// Create an Animal and call its makeNoise method +Animals.insert({ name: "raptor", sound: "roar" }); +Animals.findOne({ name: "raptor" }).makeNoise(); // prints "roar" + +/** + * From Collections, Collection.insert section + */ +// DA: I added the variable declaration statements to make this work +var Lists = new Mongo.Collection('Lists'); +var Items = new Mongo.Collection('Lists'); + +var groceriesId = Lists.insert({ name: "Groceries" }); +Items.insert({ list: groceriesId, name: "Watercress" }); +Items.insert({ list: groceriesId, name: "Persimmons" }); + +/** + * From Collections, collection.update section + */ +var Players = new Mongo.Collection('Players'); + +Template['adminDashboard'].events({ + 'click .givePoints': function () { + Players.update(Session.get("currentPlayer"), { $inc: { score: 5 } }); + } +}); + +/** + * Also from Collections, collection.update section + */ +Meteor.methods({ + declareWinners: function () { + Players.update({ score: { $gt: 10 } }, + { $addToSet: { badges: "Winner" } }, + { multi: true }); + } +}); + +/** + * From Collections, collection.remove section + */ +Template['chat'].events({ + 'click .remove': function () { + Messages.remove(this._id); + } +}); + +// DA: I added this next line +var Logs = new Mongo.Collection('logs'); + +Meteor.startup(function () { + if (Meteor.isServer) { + Logs.remove({}); + Players.remove({ karma: { $lt: -2 } }); + } +}); + +/*** + * From Collections, collection.allow section + */ + +interface iPost { + _id: string; + owner: string; + userId: string; + locked: boolean; +} + +Posts = new Mongo.Collection("posts"); + +Posts.allow({ + insert: function (userId: string, doc: iPost) { + // the user must be logged in, and the document must be owned by the user + return (userId && doc.owner === userId); + }, + update: function (userId: string, doc: iPost, fields: string[], modifier: any) { + // can only change your own documents + return doc.owner === userId; + }, + remove: function (userId: string, doc: iPost) { + // can only remove your own documents + return doc.owner === userId; + }, + fetch: ['owner'] +}); + +Posts.deny({ + update: function (userId: string, doc: iPost, fields: string[], modifier: any) { + // can't change owners + return doc.userId !== userId; + }, + remove: function (userId: string, doc: iPost) { + // can't remove locked documents + return doc.locked; + }, + fetch: ['locked'] // no need to fetch 'owner' +}); + +/** + * From Collections, cursor.forEach section + */ +var topPosts = Posts.find({}, { sort: { score: -1 }, limit: 5 }); +var count = 0; +topPosts.forEach(function (post: { title: string }) { + console.log("Title of post " + count + ": " + post.title); + count += 1; +}); + +/** + * From Collections, cursor.observeChanges section + */ +// DA: I added this line to make it work +var Users = new Mongo.Collection('users'); + +var count1 = 0; +var query = Users.find({ admin: true, onlineNow: true }); +var handle = query.observeChanges({ + added: function (id: string, user: { name: string }) { + count1++; + console.log(user.name + " brings the total to " + count1 + " admins."); + }, + removed: function () { + count1--; + console.log("Lost one. We're now down to " + count1 + " admins."); + } +}); + +let cursor: Mongo.Cursor; + +// After five seconds, stop keeping the count. +setTimeout(function () { handle.stop(); }, 5000); + +// Additional testing for Mongo.Collection +enum InlineObjectType { + Invalid, + Link, + Image, + Video, + Person +} +interface CommentsDAO { + text: string; + authorId: string; + inlineLinks: { objectType: InlineObjectType, objectId: string, objectUrl: string }[], + tags: string[], + viewNumber: number, + private: boolean +} + +var Comments = new Mongo.Collection("comments"); + +Comments.find({ text: { $regex: /test/ } }); +Comments.find({ viewNumber: { $gt: 100 } }); +Comments.find({ viewNumber: { $not: { $lt: 100, $gt: 1000 } } }); +Comments.find({ tags: { $in: [ "tag-1", "tag-2", "tag-3" ] } }); +Comments.find({ $or: [ { text: "hello" }, { text: "world" } ] }); +Comments.find({ $or: [ + { text: "hello" }, + { text: "world", viewNumber: { $gt: 0 } } +], authorId: "test-author-id" }); +Comments.find({ $and: [ + { $or: [{ authorId: "author-id-1" }, { authorId: "author-id-2" }] }, + { $or: [{ tags: "tag-1" }, { tags: "tag-2" }] } +]}); + +Comments.find({ inlineLinks: { $exists: true, $type: "array" } }); +Comments.find({ inlineLinks: { $elemMatch: { + objectType: InlineObjectType.Image, + objectUrl: { $regex: "https://(www\.?)youtube\.com" } +} } }); +Comments.find({ "inlineLinks.objectType": InlineObjectType.Person }); +Comments.find({ tags: "tag-1" }); +Comments.find({ tags: { $all: ["tag-1", "tag2"] } }); + +Comments.update({ viewNumber: { $exists: false } }, { $set: { viewNumber: 0 } }); +Comments.update({ authorId: "author-id-1" }, { $push: { tags: "test-tag-1" } }); +Comments.update({ authorId: "author-id-1" }, { $push: { tags: { $each: [ "test-tag-2", "test-tag-3" ] } } }); + +Comments.update({ authorId: "author-id-1" }, { $push: { inlineLinks: { + objectId: "test-object-id", + objectType: InlineObjectType.Link, + objectUrl: "https://test.url/" +} } }); +Comments.update({ viewNumber: { $exists: false } }, { $set: { viewNumber: 0 } }); +Comments.update({ private: true }, { $unset: { tags: true } }); + +/** + * From Sessions, Session.set section + */ +Tracker.autorun(function () { + Meteor.subscribe("chat-history", { room: Session.get("currentRoomId") }); +}); + +// Causes the function passed to Tracker.autorun to be re-run, so +// that the chat-history subscription is moved to the room "home". +Session.set("currentRoomId", "home"); + +/** + * From Sessions, Session.get section + */ +// Page will say "We've always been at war with Eastasia" + +// DA: commented out since transpiler didn't like append() +//document.body.append(frag1); + +// Page will change to say "We've always been at war with Eurasia" +Session.set("enemy", "Eurasia"); + +/** + * From Sessions, Session.equals section + */ +var value: string; +Session.get("key") === value; +Session.equals("key", value); + +/** + * From Accounts, Meteor.users section + */ +Meteor.publish("userData", function () { + return Meteor.users.find({ _id: this.userId }, + { fields: { 'other': 1, 'things': 1 } }); +}); + +Meteor.users.deny({ update: function () { return true; } }); + +/** + * From Accounts, Meteor.loginWithExternalService section + */ +Meteor.loginWithGithub({ + requestPermissions: ['user', 'public_repo'] +}, function (err: Meteor.Error) { + if (err) + Session.set('errorMessage', err.reason || 'Unknown error'); +}); + +/** + * From Accounts, Accounts.ui.config section + */ +Accounts.ui.config({ + requestPermissions: { + facebook: ['user_likes'], + github: ['user', 'repo'] + }, + requestOfflineToken: { + google: true + }, + passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL' +}); + +/** + * From Accounts, Accounts.validateNewUser section + */ +Accounts.validateNewUser(function (user: { username: string }) { + if (user.username && user.username.length >= 3) + return true; + throw new Meteor.Error("403", "Username must have at least 3 characters"); +}); +// Validate username, without a specific error message. +Accounts.validateNewUser(function (user: { username: string }) { + return user.username !== "root"; +}); + +/** + * From Accounts, Accounts.onCreateUser section + */ +Accounts.onCreateUser(function (options: { profile: any }, user: { profile: any, dexterity: number }) { + var d6 = function () { return Math.floor(Math.random() * 6) + 1; }; + user.dexterity = d6() + d6() + d6(); + // We still want the default hook's 'profile' behavior. + if (options.profile) + user.profile = options.profile; + return user; +}); + +/** + * From Passwords, Accounts.emailTemplates section + */ +Accounts.emailTemplates.siteName = "AwesomeSite"; +Accounts.emailTemplates.from = "AwesomeSite Admin "; +Accounts.emailTemplates.enrollAccount.subject = function (user: { profile: { name: string } }) { + return "Welcome to Awesome Town, " + user.profile.name; +}; +Accounts.emailTemplates.enrollAccount.text = function (user: any, url: string) { + return "You have been selected to participate in building a better future!" + + " To activate your account, simply click the link below:\n\n" + + url; +}; + +/** + * From Templates, Template.myTemplate.helpers section + */ +Template['adminDashboard'].helpers({ + foo: function () { + return Session.get("foo"); + } +}); + +Template['newTemplate'].helpers({ + helperName: function () { + } +}); + +Template['newTemplate'].created = function () { + +}; + +Template['newTemplate'].rendered = function () { + +}; + +Template['newTemplate'].destroyed = function () { + +}; + +Template['newTemplate'].events({ + 'click .something': function (event: Meteor.Event, template: Blaze.TemplateInstance) { + } +}); + +Template.registerHelper('testHelper', function () { + return 'tester'; +}); + +var instance = Template.instance(); +var data = Template.currentData(); +var data = Template.parentData(1); +var body = Template.body; + +/** + * From Match section + */ +var Chats = new Mongo.Collection('chats'); + +Meteor.publish("chats-in-room", function (roomId: string) { + // Make sure roomId is a string, not an arbitrary mongo selector object. + check(roomId, String); + return Chats.find({ room: roomId }); +}); + +Meteor.methods({ + addChat: function (roomId: string, message: { text: string, timestamp: Date, tags: string }) { + check(roomId, String); + check(message, { + text: String, + timestamp: Date, + // Optional, but if present must be an array of strings. + tags: Match.Optional('Test String') + }); + + // ... do something with the message ... + } +}); + +/** + * From Match patterns section + */ +var pat = { name: Match.Optional('test') }; +check({ name: "something" }, pat) // OK +check({}, pat) // OK +check({ name: undefined }, pat) // Throws an exception + +// Outside an object +check(undefined, Match.Optional('test')); // OK + +/** + * From Deps, Tracker.autorun section + */ +Tracker.autorun(function () { + var oldest = Monkeys.findOne('age = 20'); + + if (oldest) + Session.set("oldest", oldest.name); +}); + +Tracker.autorun(function (c) { + if (!Session.equals("shouldAlert", true)) + return; + + c.stop(); + alert("Oh no!"); +}); + +/** + * From Deps, Deps.Computation + */ +if (Tracker.active) { + Tracker.onInvalidate(function () { + console.log('invalidated'); + }); +} + +/** + * From Tracker, Tracker.Dependency + */ +var weather = "sunny"; +var weatherDep = new Tracker.Dependency; + +var getWeather = function () { + weatherDep.depend(); + return weather; +}; + +var setWeather = function (w: string) { + weather = w; + // (could add logic here to only call changed() + // if the new value is different from the old) + weatherDep.changed(); +}; + +/** + * From HTTP, HTTP.call section + */ +Meteor.methods({ + checkTwitter: function (userId: string) { + check(userId, String); + this.unblock(); + var result = HTTP.call("GET", "http://api.twitter.com/xyz", + { params: { user: userId } }); + if (result.statusCode === 200) + return true + return false; + } +}); + + +HTTP.call("POST", "http://api.twitter.com/xyz", + { data: { some: "json", stuff: 1 } }, + function (error: Meteor.Error, result: any) { + if (result.statusCode === 200) { + Session.set("twizzled", true); + } + }); + +/** + * From Email, Email.send section + */ +Meteor.methods({ + sendEmail: function (to: string, from: string, subject: string, text: string) { + check([to, from, subject, text], [String]); + + // Let other method calls from the same client start running, + // without waiting for the email sending to complete. + this.unblock(); + } +}); + +// In your client code: asynchronously send an email +Meteor.call('sendEmail', + 'alice@example.com', + 'Hello from Meteor!', + 'This is a test of Email.send.'); + +var testTemplate = new Blaze.Template('foo'); +var testView = new Blaze.View('foo'); +Blaze.Template.instance(); + +declare var el: HTMLElement; +Blaze.render(testTemplate, el); +Blaze.renderWithData(testTemplate, { testData: 123 }, el); +Blaze.remove(testView); +Blaze.getData(el); +Blaze.getData(testView); +Blaze.toHTML(testTemplate); +Blaze.toHTML(testView); +Blaze.toHTMLWithData(testTemplate, { test: 1 }); +Blaze.toHTMLWithData(testTemplate, function () { }); +Blaze.toHTMLWithData(testView, { test: 1 }); +Blaze.toHTMLWithData(testView, function () { }); + +var reactiveVar1 = new ReactiveVar('test value'); +var reactiveVar2 = new ReactiveVar('test value', function (oldVal: any) { return true; }); + +var varValue: string = reactiveVar1.get(); +reactiveVar1.set('new value'); + +// Covers this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8233 +var isConfigured: boolean = Accounts.loginServicesConfigured(); +Accounts.onPageLoadLogin(function () { + // do something +}); + +// Covers this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8065 +var loginOpts = { + requestPermissions: ["a", "b"], + requestOfflineToken: true, + loginUrlParameters: { asdf: 1, qwer: "1234" }, + loginHint: "Help me", + loginStyle: "Bold and powerful", + redirectUrl: "popup", + profile: "asdfasdf" +}; +Meteor.loginWithMeteorDeveloperAccount(loginOpts, function (error: Meteor.Error) { }); + +Accounts.emailTemplates.siteName = "AwesomeSite"; +Accounts.emailTemplates.from = "AwesomeSite Admin "; +Accounts.emailTemplates.headers = { asdf: 'asdf', qwer: 'qwer' }; + +Accounts.emailTemplates.enrollAccount.subject = function (user: Meteor.User) { + return "Welcome to Awesome Town, " + user.profile.name; +}; +Accounts.emailTemplates.enrollAccount.html = function (user: Meteor.User, url: string) { + return "

            Some html here

            "; +}; +Accounts.emailTemplates.enrollAccount.from = function () { + return "asdf@asdf.com"; +}; +Accounts.emailTemplates.enrollAccount.text = function (user: Meteor.User, url: string) { + return "You have been selected to participate in building a better future!" + + " To activate your account, simply click the link below:\n\n" + + url; +}; + +var handle = Accounts.validateLoginAttempt(function (attemptInfoObject: Accounts.IValidateLoginAttemptCbOpts) { + var type: string = attemptInfoObject.type; + var allowed: boolean = attemptInfoObject.allowed; + var error: Meteor.Error = attemptInfoObject.error; + var user: Meteor.User = attemptInfoObject.user; + var connection: Meteor.Connection = attemptInfoObject.connection; + var methodName: string = attemptInfoObject.methodName; + var methodArguments: any[] = attemptInfoObject.methodArguments; + return true; +}); +handle.stop(); + + +// Covers https://github.com/meteor-typings/meteor/issues/8 +const publicSetting = Meteor.settings.public['somePublicSetting']; +const deeperPublicSetting = Meteor.settings.public['somePublicSetting']['deeperSetting']; +const privateSetting = Meteor.settings['somePrivateSetting']; +const deeperPrivateSetting = Meteor.settings['somePrivateSettings']['deeperSetting']; + + +// Covers https://github.com/meteor-typings/meteor/issues/9 +const username = (Template.instance().find('#username')).value; + + +// Covers https://github.com/meteor-typings/meteor/issues/3 +BrowserPolicy.framing.disallow(); +BrowserPolicy.content.allowEval(); + + +// Covers https://github.com/meteor-typings/meteor/issues/18 +if (Meteor.isDevelopment) { + Rooms._dropIndex({ field: 1 }); +} + + +// Covers https://github.com/meteor-typings/meteor/issues/20 +Rooms.find().count(true); + + +// Covers https://github.com/meteor-typings/meteor/issues/21 +if (Meteor.isTest) { + // do something +} + +DDPRateLimiter.addRule({ userId: 'foo' }, 5, 1000); + +DDPRateLimiter.addRule({ userId: userId => userId == 'foo' }, 5, 1000); + +Template.instance().autorun(() => { }).stop(); + +// Mongo Collection without connection (local collection) +const collectionWithoutConnection = new Mongo.Collection("monkey", { + connection: null +}); + +} // End of namespace diff --git a/types/meteor/test/meteor-tests-module-only.ts b/types/meteor/test/meteor-tests-module-only.ts new file mode 100644 index 0000000000..3591b90635 --- /dev/null +++ b/types/meteor/test/meteor-tests-module-only.ts @@ -0,0 +1,8 @@ +// This file is for tests that involve modules that don't have corresponding +// globals. + +import { onPageLoad } from "meteor/server-render"; +import { ServiceConfiguration } from "meteor/service-configuration"; +import { WebApp } from "meteor/webapp"; + +// We have no actual tests beyond the imports yet. diff --git a/types/meteor/meteor-tests.ts b/types/meteor/test/meteor-tests.ts similarity index 98% rename from types/meteor/meteor-tests.ts rename to types/meteor/test/meteor-tests.ts index a321e4a409..c7fde5b8be 100644 --- a/types/meteor/meteor-tests.ts +++ b/types/meteor/test/meteor-tests.ts @@ -1,10 +1,14 @@ +// This file may use only modules that have corresponding globals, because +// `globals/meteor-tests.ts` is generated from it. Tests that involve modules +// that don't have corresponding globals belong in +// `meteor-tests-module-only.ts`. + /** * All code below was copied from the examples at http://docs.meteor.com/. * When necessary, code was added to make the examples work (e.g. declaring a variable * that was assumed to have been declared earlier) */ - /*********************************** Begin setup for tests ******************************/ import { Mongo } from "meteor/mongo"; import { Meteor } from "meteor/meteor"; @@ -19,6 +23,9 @@ import { Accounts } from "meteor/accounts-base"; import { BrowserPolicy } from "meteor/browser-policy-common"; import { DDPRateLimiter } from "meteor/ddp-rate-limiter"; +// Avoid conflicts between `meteor-tests.ts` and `globals/meteor-tests.ts`. +namespace MeteorTests { + var Rooms = new Mongo.Collection('rooms'); var Messages = new Mongo.Collection('messages'); interface MonkeyDAO { @@ -786,3 +793,5 @@ Template.instance().autorun(() => { }).stop(); const collectionWithoutConnection = new Mongo.Collection("monkey", { connection: null }); + +} // End of namespace diff --git a/types/meteor/tiny-test.d.ts b/types/meteor/tiny-test.d.ts index 15e0939684..8d149e0711 100644 --- a/types/meteor/tiny-test.d.ts +++ b/types/meteor/tiny-test.d.ts @@ -1,41 +1,3 @@ - -interface ILengthAble { - length: number; -} - -interface ITinytestAssertions { - ok(doc: Object): void; - expect_fail(): void; - fail(doc: Object): void; - runId(): string; - equal(actual: T, expected: T, message?: string, not?: boolean): void; - notEqual(actual: T, expected: T, message?: string): void; - instanceOf(obj: Object, klass: Function, message?: string): void; - notInstanceOf(obj: Object, klass: Function, message?: string): void; - matches(actual: any, regexp: RegExp, message?: string): void; - notMatches(actual: any, regexp: RegExp, message?: string): void; - throws(f: Function, expected?: string | RegExp): void; - isTrue(v: boolean, msg?: string): void; - isFalse(v: boolean, msg?: string): void; - isNull(v: any, msg?: string): void; - isNotNull(v: any, msg?: string): void; - isUndefined(v: any, msg?: string): void; - isNotUndefined(v: any, msg?: string): void; - isNan(v: any, msg?: string): void; - isNotNan(v: any, msg?: string): void; - include(s: Array | Object | string, value: any, msg?: string, not?: boolean): void; - - notInclude(s: Array | Object | string, value: any, msg?: string, not?: boolean): void; - length(obj: ILengthAble, expected_length: number, msg?: string): void; - _stringEqual(actual: string, expected: string, msg?: string): void; -} - -declare module Tinytest { - function add(description: string, func: (test: ITinytestAssertions) => void): void; - - function addAsync(description: string, func: (test: ITinytestAssertions) => void): void; -} - declare module "meteor/tiny-test" { interface ILengthAble { length: number; diff --git a/types/meteor/tools.d.ts b/types/meteor/tools.d.ts index a23a2bafaa..f45f75d0cc 100644 --- a/types/meteor/tools.d.ts +++ b/types/meteor/tools.d.ts @@ -1,107 +1,3 @@ - -declare module App { - function accessRule(pattern: string, options?: { - type?: string; - launchExternal?: boolean; - }): void; - - function configurePlugin(id: string, config: Object): void; - - function icons(icons: Object): void; - - function info(options: { - id?: string; - version?: string; - name?: string; - description?: string; - author?: string; - email?: string; - website?: string; - }): void; - - function launchScreens(launchScreens: Object): void; - - function setPreference(name: string, value: string, platform?: string): void; -} - -declare function execFileAsync(command: string, args?: any[], options?: { - cwd?: Object; - env?: Object; - stdio?: any[] | string; - destination?: any; - waitForClose?: string; -}): any; -declare function execFileSync(command: string, args?: any[], options?: { - cwd?: Object; - env?: Object; - stdio?: any[] | string; - destination?: any; - waitForClose?: string; -}): String; - -declare module Assets { - function getBinary(assetPath: string, asyncCallback?: Function): EJSON; - - function getText(assetPath: string, asyncCallback?: Function): string; - - function absoluteFilePath(assetPath: string): string; -} - -declare module Cordova { - function depends(dependencies: { - [id: string]: string - }): void; -} - -declare module Npm { - function depends(dependencies: { - [id: string]: string - }): void; - - function require(name: string): any; -} - -declare namespace Package { - function describe(options: { - summary?: string; - version?: string; - name?: string; - git?: string; - documentation?: string; - debugOnly?: boolean; - prodOnly?: boolean; - testOnly?: boolean; - }): void; - - function onTest(func: (api: PackageAPI) => void): void; - - function onUse(func: (api: PackageAPI) => void): void; - - function registerBuildPlugin(options?: { - name?: string; - use?: string | string[]; - sources?: string[]; - npmDependencies?: Object; - }): void; -} - -interface PackageAPI { - new (): PackageAPI; - addAssets(filenames: string | string[], architecture: string | string[]): void; - addFiles(filenames: string | string[], architecture?: string | string[], options?: { - bare?: boolean; - }): void; - export(exportedObjects: string | string[], architecture?: string | string[], exportOptions?: Object, testOnly?: boolean): void; - imply(packageNames: string | string[], architecture?: string | string[]): void; - use(packageNames: string | string[], architecture?: string | string[], options?: { - weak?: boolean; - unordered?: boolean; - }): void; - versionsFrom(meteorRelease: string | string[]): void; -} - -declare var console: Console; - declare module "meteor/tools" { module App { function accessRule(pattern: string, options?: { @@ -135,7 +31,6 @@ declare module "meteor/tools" { destination?: any; waitForClose?: string; }): any; - function execFileSync(command: string, args?: any[], options?: { cwd?: Object; env?: Object; diff --git a/types/meteor/tracker.d.ts b/types/meteor/tracker.d.ts index 495ae46abd..8a8b69c8da 100644 --- a/types/meteor/tracker.d.ts +++ b/types/meteor/tracker.d.ts @@ -1,42 +1,3 @@ - -declare module Tracker { - function Computation(): void; - interface Computation { - firstRun: boolean; - invalidate(): void; - invalidated: boolean; - onInvalidate(callback: Function): void; - onStop(callback: Function): void; - stop(): void; - stopped: boolean; - } - var currentComputation: Computation; - - var Dependency: DependencyStatic; - interface DependencyStatic { - new (): Dependency; - } - interface Dependency { - changed(): void; - depend(fromComputation?: Computation): boolean; - hasDependents(): boolean; - } - - var active: boolean; - - function afterFlush(callback: Function): void; - - function autorun(runFunc: (computation: Computation) => void, options?: { - onError?: Function; - }): Computation; - - function flush(): void; - - function nonreactive(func: Function): void; - - function onInvalidate(callback: Function): void; -} - declare module "meteor/tracker" { module Tracker { function Computation(): void; diff --git a/types/meteor/tsconfig.json b/types/meteor/tsconfig.json index b6cfc721f1..7ad451fd56 100644 --- a/types/meteor/tsconfig.json +++ b/types/meteor/tsconfig.json @@ -18,27 +18,49 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "accounts.d.ts", + "accounts-base.d.ts", + "globals/accounts-base.d.ts", "blaze.d.ts", + "globals/blaze.d.ts", "browser-policy-common.d.ts", + "globals/browser-policy-common.d.ts", "check.d.ts", + "globals/check.d.ts", "ddp-rate-limiter.d.ts", + "globals/ddp-rate-limiter.d.ts", "ddp.d.ts", + "globals/ddp.d.ts", "ejson.d.ts", + "globals/ejson.d.ts", "email.d.ts", + "globals/email.d.ts", "http.d.ts", + "globals/http.d.ts", "meteor.d.ts", + "globals/meteor.d.ts", "mongo.d.ts", + "globals/mongo.d.ts", + "random.d.ts", + "globals/random.d.ts", "reactive-var.d.ts", + "globals/reactive-var.d.ts", "server-render.d.ts", "service-configuration.d.ts", "session.d.ts", + "globals/session.d.ts", + "templating.d.ts", + "globals/templating.d.ts", "tiny-test.d.ts", + "globals/tiny-test.d.ts", "tools.d.ts", + "globals/tools.d.ts", "tracker.d.ts", + "globals/tracker.d.ts", "underscore.d.ts", "webapp.d.ts", "index.d.ts", - "meteor-tests.ts" + "test/meteor-tests.ts", + "test/globals/meteor-tests.ts", + "test/meteor-tests-module-only.ts" ] -} \ No newline at end of file +} diff --git a/types/money-math/index.d.ts b/types/money-math/index.d.ts new file mode 100644 index 0000000000..a86734c477 --- /dev/null +++ b/types/money-math/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for money-math 2.5 +// Project: https://github.com/ikr/money-math#readme +// Definitions by: taoqf +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Money; + +export function add(a: string, b: string): string; +export function subtract(a: string, b: string): string; +export function mul(a: string, b: string): string; +export function div(a: string, b: string): string; +export function percent(a: string, b: string): string; +export function cmp(a: string, b: string): 0 | number; +export function isEqual(a: string, b: string): boolean; +export function isZero(value: string): boolean; +export function isNegative(value: string): boolean; +export function isPositive(value: string): boolean; +export function floatToAmount(value: number): string; +export function format(currency: 'CHF' | 'CNY' | 'EUR' | 'GBP' | 'JPY' | 'LTL' | 'PLN' | 'SEK' | 'SKK' | 'UAH' | 'USD' | string, value: string): string; +export function roundUpTo5Cents(value: string): string; +export function roundTo5Cents(value: string): string; diff --git a/types/money-math/money-math-tests.ts b/types/money-math/money-math-tests.ts new file mode 100644 index 0000000000..9b93824ca1 --- /dev/null +++ b/types/money-math/money-math-tests.ts @@ -0,0 +1,18 @@ +import * as money from 'money-math'; + +money.add("16.11", "17.07"); // "33.18" +money.subtract("16.00", "7.00"); // "9.00" +money.mul("24.00", "0.25"); // "6.00" +money.div("64.00", "2.00"); // "32.00" +money.percent("200.00", "3.25"); // "6.50" +money.cmp("100.00", "200.00"); // -1 +money.isEqual("100.00", "100.00"); // true +money.isZero("0.00"); // true +money.isNegative("-1.00"); // true +money.isPositive("-1.00"); // false + +money.format("JPY", "236800.00"); // "236,800" +money.floatToAmount(56.345); // "56.35" + +money.roundUpTo5Cents("42.02"); // "42.05" +money.roundTo5Cents("442.26"); // "442.25" diff --git a/types/money-math/tsconfig.json b/types/money-math/tsconfig.json new file mode 100644 index 0000000000..fd8b7d167d --- /dev/null +++ b/types/money-math/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "strictFunctionTypes": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "money-math-tests.ts" + ] +} \ No newline at end of file diff --git a/types/money-math/tslint.json b/types/money-math/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/money-math/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 5db31bf4f6..742b0f188e 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -808,11 +808,11 @@ declare module "mongoose" { // Hook functions: https://github.com/vkarpov15/hooks-fixed interface HookSyncCallback { - (this: T, next: HookNextFunction): Promise | void; + (this: T, next: HookNextFunction, docs: any[]): Promise | void; } interface HookAsyncCallback { - (this: T, next: HookNextFunction, done: HookDoneFunction): Promise | void; + (this: T, next: HookNextFunction, done: HookDoneFunction, docs: any[]): Promise | void; } interface HookErrorCallback { diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index f745600e4b..9b9059b807 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -390,23 +390,23 @@ preHookTestSchemaArr.push( // Model preHookTestSchemaArr.push( - schema.pre("insertMany", function(next) { + schema.pre("insertMany", function(next, docs) { const isDefaultType: mongoose.Model = this; }, err => {}) ); preHookTestSchemaArr.push( - schema.pre>("insertMany", function(next) { + schema.pre>("insertMany", function(next, docs) { const isSpecificType: PreHookTestModelInterface = this; return Promise.resolve("") }, err => {}) ); preHookTestSchemaArr.push( - schema.pre("insertMany", true, function(next, done) { + schema.pre("insertMany", true, function(next, done, docs) { const isDefaultType: mongoose.Model = this; }, err => {}) ); preHookTestSchemaArr.push( - schema.pre>("insertMany", true, function(next, done) { + schema.pre>("insertMany", true, function(next, done, docs) { const isSpecificType: PreHookTestModelInterface = this; return Promise.resolve("") }, err => {}) diff --git a/types/mssql/index.d.ts b/types/mssql/index.d.ts index db1256e2a3..d4558737ba 100644 --- a/types/mssql/index.d.ts +++ b/types/mssql/index.d.ts @@ -8,6 +8,7 @@ // Peter Keuter // David Gasperoni // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/types/mssql/msnodesqlv8.d.ts b/types/mssql/msnodesqlv8.d.ts new file mode 100644 index 0000000000..27d51e2daa --- /dev/null +++ b/types/mssql/msnodesqlv8.d.ts @@ -0,0 +1,2 @@ +// Export the same API as index.d.ts (which implicitly uses the "msnodesqlv8" driver): +export * from '.'; diff --git a/types/mssql/mssql-tests.ts b/types/mssql/mssql-tests.ts index 9d9e72bd4f..72bbc15126 100644 --- a/types/mssql/mssql-tests.ts +++ b/types/mssql/mssql-tests.ts @@ -1,4 +1,5 @@ import * as sql from 'mssql'; +import * as msnodesqlv8 from 'mssql/msnodesqlv8'; interface Entity { value: number; @@ -203,3 +204,10 @@ function test_classes_extend_eventemitter() { preparedStatment.on('error', () => { }) } + +async function test_msnodesqlv8() { + const connection = new msnodesqlv8.ConnectionPool({ server: "localhost", database: "master", options: { trustedConnection: true } }); + await connection.connect(); + const result = await connection.query`SELECT * FROM sys.databases`; + await connection.close(); +} diff --git a/types/mssql/tsconfig.json b/types/mssql/tsconfig.json index 51f03fd652..d53105dc0a 100644 --- a/types/mssql/tsconfig.json +++ b/types/mssql/tsconfig.json @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", + "msnodesqlv8.d.ts", "mssql-tests.ts" ] } \ No newline at end of file diff --git a/types/nested-error-stacks/index.d.ts b/types/nested-error-stacks/index.d.ts new file mode 100644 index 0000000000..29d629a50b --- /dev/null +++ b/types/nested-error-stacks/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for nested-error-stacks 2.1 +// Project: https://github.com/mdlavin/nested-error-stacks +// Definitions by: Wouter van Heeswijk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class NestedError extends Error { + constructor(message?: any, nested?: Error); +} + +export = NestedError; diff --git a/types/nested-error-stacks/nested-error-stacks-tests.ts b/types/nested-error-stacks/nested-error-stacks-tests.ts new file mode 100644 index 0000000000..52a9a55495 --- /dev/null +++ b/types/nested-error-stacks/nested-error-stacks-tests.ts @@ -0,0 +1,6 @@ +import NestedErrorStacks = require('nested-error-stacks'); + +const error = new NestedErrorStacks('Top level error', new Error('Nested error')); +const message = error.message; +const name = error.name; +const stack = error.stack; diff --git a/types/nested-error-stacks/tsconfig.json b/types/nested-error-stacks/tsconfig.json new file mode 100644 index 0000000000..2954204b36 --- /dev/null +++ b/types/nested-error-stacks/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", + "nested-error-stacks-tests.ts" + ] +} \ No newline at end of file diff --git a/types/nested-error-stacks/tslint.json b/types/nested-error-stacks/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/nested-error-stacks/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/node-forge/README.md b/types/node-forge/README.md new file mode 100644 index 0000000000..fcac651de8 --- /dev/null +++ b/types/node-forge/README.md @@ -0,0 +1,29 @@ +# DefinitelyTyped for node-forge + +## Current node-forge Version +`v0.7.6` +## Usage + +```bash +npm install --save-dev @types/node-forge +npm install --save node-forge +``` + +example: +```ts +import * as forge from "node-forge"; + +Buffer.isBuffer(forge.pki.ed25519.generateKeyPair().publicKey) // true +``` +## License +BSD-2-Clause + +## dependencies +`@types/node` + +## Author +[Seth Westphal](https://github.com/westy92) +[Kay Schecker](https://github.com/flynetworks) +[Aakash Goenka](https://github.com/a-k-g) +[Rafal2228](https://github.com/rafal2228) +[Beeno Tung](https://github.com/beenotung) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index 65ff4edb47..e30a217ddc 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -1,10 +1,14 @@ -// Type definitions for node-forge 0.7.5 +// Type definitions for node-forge 0.7.6 // Project: https://github.com/digitalbazaar/forge // Definitions by: Seth Westphal // Kay Schecker // Aakash Goenka // Rafal2228 +// Beeno Tung // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/// declare module "node-forge" { type Byte = string; @@ -73,6 +77,33 @@ declare module "node-forge" { function generateKeyPair(options?: GenerateKeyPairOptions, callback?: (err: Error, keypair: KeyPair) => void): KeyPair; } + namespace ed25519 { + + type NativeBuffer = Buffer | Uint8Array; + + namespace constants { + const PUBLIC_KEY_BYTE_LENGTH = 32; + const PRIVATE_KEY_BYTE_LENGTH = 64; + const SEED_BYTE_LENGTH = 32; + const SIGN_BYTE_LENGTH = 64; + const HASH_BYTE_LENGTH = 64; + } + + function generateKeyPair(options?: { seed?: Buffer | Uint8Array | string }): { + publicKey: NativeBuffer; + privateKey: NativeBuffer; + }; + + function publicKeyFromPrivateKey(options: { privateKey: NativeBuffer }): NativeBuffer; + + function sign(options: { privateKey: NativeBuffer }): NativeBuffer; + + function verify(options: { + signature: Buffer | Uint8Array | util.ByteBuffer | string, + publicKey: NativeBuffer + }): boolean; + } + interface CertificateFieldOptions { name?: string; type?: string; diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 2ce2d7299e..a2ecf33028 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -28,6 +28,7 @@ // Zane Hannan AU // Thomas den Hollander // Eugene Y. Q. Shen +// Matthieu Sieben // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** inspector module types */ @@ -828,7 +829,7 @@ declare namespace NodeJS { emit(event: "unhandledRejection", reason: any, promise: Promise): boolean; emit(event: "warning", warning: Error): boolean; emit(event: "message", message: any, sendHandle: any): this; - emit(event: Signals): boolean; + emit(event: Signals, signal: Signals): boolean; emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this; emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this; diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 490063fb77..17dc31810f 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -1132,12 +1132,14 @@ declare namespace Office { asyncContext?: any } /** - * The Office Auth namespace, Office.context.auth, provides a method that allows the Office host to obtain and access the add-in token. - * Indirectly, enable the add-in to access the signed-in user's Microsoft Graph data without requiring the user to sign in a second time. + * The Office Auth namespace, Office.context.auth, provides a method that allows the Office host to obtain an access token to the add-in's web application. + * Indirectly, this also enables the add-in to access the signed-in user's Microsoft Graph data without requiring the user to sign in a second time. + * + * @beta */ interface Auth { /** - * Calls the Azure Active Directory V 2.0 endpoint to get an access token to your add-in's web application. Allows add-ins to identify users. + * Calls the Azure Active Directory V 2.0 endpoint to get an access token to your add-in's web application. Enables add-ins to identify users. * Server side code can use this token to access Microsoft Graph for the add-in's web application by using the * {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}. * @@ -1148,11 +1150,8 @@ declare namespace Office { * * Requirement sets{@link https://docs.microsoft.com/office/dev/add-ins/develop/specify-office-hosts-and-api-requirements | IdentityAPI} * - * This API requires a single sign-on configuration that bridges the add-in to an Azure application. Office users sign-in with Organizational - * Accounts and Microsoft Accounts. Microsoft Azure returns tokens intended for both user account types to access resources in the Microsoft Graph. - * * @param options - Optional. Accepts an AuthOptions object to define sign-on behaviors. - * @param callback - Optional. Accepts a callback method to handle the token acquisition attempt. + * @param callback - Optional. Accepts a callback method that can parse the token for the user's ID or use the token in the "on behalf of" flow to get access to Microsoft Graph. * If AsyncResult.status is "succeeded", then AsyncResult.value is the raw AAD v. 2.0-formatted access token. * * @beta @@ -1170,7 +1169,7 @@ declare namespace Office { */ forceConsent?: boolean, /** - * Prompts the user to add (or to switch if already added) his or her Office account. + * Prompts the user to add their Office account (or to switch to it, if it is already added). */ forceAddAccount?: boolean, /** @@ -8618,7 +8617,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose or read * * @param coercionType The format for the returned body. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * The body is provided in the requested format in the asyncResult.value property. */ getAsync(coerciontype: Office.CoercionType, callback: (result: AsyncResult) => void): void; @@ -8635,7 +8634,7 @@ declare namespace Office { * * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * The content type is returned as one of the CoercionType values in the asyncResult.value property. */ getTypeAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -8669,7 +8668,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: The desired format for the body. The string in the data parameter will be converted to this format. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * Any errors encountered will be provided in the asyncResult.error property. */ prependAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (result: AsyncResult) => void): void; @@ -8714,7 +8713,7 @@ declare namespace Office { * ErrorsDataExceedsMaximumSize - The data parameter is longer than 1,000,000 characters. * * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * Any errors encountered will be provided in the asyncResult.error property. */ prependAsync(data: string, callback: (result: AsyncResult) => void): void; @@ -8768,7 +8767,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: The desired format for the body. The string in the data parameter will be converted to this format. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * Any errors encountered will be provided in the asyncResult.error property. */ setAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (result: AsyncResult) => void): void; @@ -8817,7 +8816,7 @@ declare namespace Office { * ErrorsDataExceedsMaximumSize - The data parameter is longer than 1,000,000 characters.InvalidFormatError - The options.coercionType parameter is set to Office.CoercionType.Html and the message body is in plain text. * * @param data The string that will replace the existing body. The string is limited to 1,000,000 characters. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * Any errors encountered will be provided in the asyncResult.error property. */ setAsync(data: string, callback: (result: AsyncResult) => void): void; @@ -8875,7 +8874,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: The desired format for the body. The string in the data parameter will be converted to this format. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * Any errors encountered will be provided in the asyncResult.error property. */ setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (result: AsyncResult) => void): void; @@ -8924,7 +8923,7 @@ declare namespace Office { * ErrorsDataExceedsMaximumSize - The data parameter is longer than 1,000,000 characters.InvalidFormatError - The options.coercionType parameter is set to Office.CoercionType.Html and the message body is in plain text. * * @param data The string that will replace the existing body. The string is limited to 1,000,000 characters. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * Any errors encountered will be provided in the asyncResult.error property. */ setSelectedDataAsync(data: string, callback: (result: AsyncResult) => void): void; @@ -9066,7 +9065,7 @@ declare namespace Office { * Your callback method should handle this error accordingly. * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * @param asyncContext Optional. Any state data that is passed to the callback method. * * [Api set: Mailbox 1.0] @@ -9286,7 +9285,7 @@ declare namespace Office { * * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an {@link Office.AsyncResult} object. + * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object. * The `value` property of the result is message's from value, as an EmailAddressDetails object. */ getAsync(options: Office.AsyncContextOptions, callback: (result: AsyncResult) => void): void; @@ -9305,7 +9304,7 @@ declare namespace Office { * * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose * - * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an {@link Office.AsyncResult} object. + * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object. * The `value` property of the result is message's from value, as an EmailAddressDetails object. */ getAsync(callback?: (result: AsyncResult) => void): void; @@ -9727,7 +9726,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -9750,7 +9749,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to addHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -9789,7 +9788,7 @@ declare namespace Office { * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters. * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * On success, the attachment identifier will be provided in the asyncResult.value property. * If adding the attachment fails, the asyncResult object will contain an Error object that provides a description of the error. */ @@ -9872,7 +9871,7 @@ declare namespace Office { * * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters. * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters. - * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * On success, the attachment identifier will be provided in the asyncResult.value property. * If adding the attachment fails, the asyncResult object will contain an Error object that provides a description of the error. */ @@ -9914,7 +9913,7 @@ declare namespace Office { * * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property set to 9020 and its name property set to GenericResponseError. * @@ -9971,7 +9970,7 @@ declare namespace Office { * @param coercionType Requests a format for the data. If Text, the method returns the plain text as a string , removing any HTML tags present. * If HTML, the method returns the selected text, whether it is plaintext or HTML. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ getSelectedDataAsync(coerciontype: Office.CoercionType, callback: (result: AsyncResult) => void): void; /** @@ -9994,7 +9993,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Appointment Organizer * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * @param userContext Optional. Developers can provide any object they wish to access in the callback function. * This object can be accessed by the asyncResult.asyncContext property in the callback function. */ @@ -10029,7 +10028,7 @@ declare namespace Office { * @param attachmentIndex The identifier of the attachment to remove. The maximum length of the string is 100 characters. * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ removeAttachmentAsync(attachmentIndex: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -10101,7 +10100,7 @@ declare namespace Office { * * @param attachmentIndex The identifier of the attachment to remove. The maximum length of the string is 100 characters. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ removeAttachmentAsync(attachmentIndex: string, callback: (result: AsyncResult) => void): void; @@ -10129,7 +10128,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -10151,7 +10150,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to removeHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -10197,7 +10196,7 @@ declare namespace Office { * * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. */ saveAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -10298,7 +10297,7 @@ declare namespace Office { * * ErrorsInvalidAttachmentId - The attachment identifier does not exist. * - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. */ saveAsync(callback: (result: AsyncResult) => void): void; /** @@ -10338,7 +10337,7 @@ declare namespace Office { * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (result: AsyncResult) => void): void; /** @@ -10411,7 +10410,7 @@ declare namespace Office { * @param data The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ setSelectedDataAsync(data: string, callback: (result: AsyncResult) => void): void; } @@ -10752,7 +10751,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -10776,7 +10775,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to addHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -10854,7 +10853,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -10876,7 +10875,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Appointment Attendee * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -11107,7 +11106,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Appointment Attendee * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * @param userContext Optional. Developers can provide any object they wish to access in the callback function. * This object can be accessed by the asyncResult.asyncContext property in the callback function. */ @@ -11137,7 +11136,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -11160,7 +11159,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to removeHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -11319,7 +11318,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -11342,7 +11341,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to addHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -11368,7 +11367,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose or read * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * @param userContext Optional. Developers can provide any object they wish to access in the callback function. * This object can be accessed by the asyncResult.asyncContext property in the callback function. */ @@ -11398,7 +11397,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -11422,7 +11421,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to removeHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -11550,7 +11549,7 @@ declare namespace Office { * @param uri The URI that provides the location of the file to attach to the message or appointment. The maximum length is 2048 characters. * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. On success, the attachment identifier will be provided in the asyncResult.value property. + * type Office.AsyncResult. On success, the attachment identifier will be provided in the asyncResult.value property. * If uploading the attachment fails, the asyncResult object will contain an Error object that provides a description of * the error. */ @@ -11618,7 +11617,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. On success, the attachment identifier will be provided in the asyncResult.value property. + * type Office.AsyncResult. On success, the attachment identifier will be provided in the asyncResult.value property. * If adding the attachment fails, the asyncResult object will contain an Error object that provides a description of * the error. */ @@ -11702,7 +11701,7 @@ declare namespace Office { * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters. * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. On success, the attachment identifier will be provided in the asyncResult.value property. + * type Office.AsyncResult. On success, the attachment identifier will be provided in the asyncResult.value property. * If adding the attachment fails, the asyncResult object will contain an Error object that provides a description of * the error. */ @@ -11746,7 +11745,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -11777,7 +11776,7 @@ declare namespace Office { * @param coercionType Requests a format for the data. If Text, the method returns the plain text as a string , removing any HTML tags present. * If HTML, the method returns the selected text, whether it is plaintext or HTML. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ getSelectedDataAsync(coerciontype: Office.CoercionType, callback: (result: AsyncResult) => void): void; /** @@ -11805,7 +11804,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ getSelectedDataAsync(coerciontype: Office.CoercionType, options: Office.AsyncContextOptions, callback: (result: AsyncResult) => void): void; /** @@ -11839,7 +11838,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ removeAttachmentAsync(attachmentIndex: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -11957,7 +11956,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ saveAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -12061,7 +12060,7 @@ declare namespace Office { * ErrorsInvalidAttachmentId - The attachment identifier does not exist. * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ saveAsync(callback: (result: AsyncResult) => void): void; @@ -12102,7 +12101,7 @@ declare namespace Office { * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (result: AsyncResult) => void): void; /** @@ -12176,7 +12175,7 @@ declare namespace Office { * @param data The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ setSelectedDataAsync(data: string, callback: (result: AsyncResult) => void): void; } @@ -12365,7 +12364,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -12388,7 +12387,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Read * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -12877,7 +12876,7 @@ declare namespace Office { * isInline: If true, indicates that the attachment will be shown inline in the message body, and should not be displayed in the * attachment list. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.asyncResult}. On success, the attachment identifier will be provided in the asyncResult.value property. + * type Office.AsyncResult. On success, the attachment identifier will be provided in the asyncResult.value property. * If uploading the attachment fails, the asyncResult object will contain an Error object that provides a description of * the error. */ @@ -12944,7 +12943,7 @@ declare namespace Office { * @param uri The URI that provides the location of the file to attach to the message or appointment. The maximum length is 2048 characters. * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. On success, the attachment identifier will be provided in the asyncResult.value property. + * type Office.AsyncResult. On success, the attachment identifier will be provided in the asyncResult.value property. * If uploading the attachment fails, the asyncResult object will contain an Error object that provides a description of * the error. */ @@ -12998,7 +12997,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -13021,7 +13020,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to addHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -13145,7 +13144,7 @@ declare namespace Office { * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters. * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. On success, the attachment identifier will be provided in the asyncResult.value property. + * type Office.AsyncResult. On success, the attachment identifier will be provided in the asyncResult.value property. * If adding the attachment fails, the asyncResult object will contain an Error object that provides a description of * the error. */ @@ -13189,7 +13188,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -13220,7 +13219,7 @@ declare namespace Office { * @param coercionType Requests a format for the data. If Text, the method returns the plain text as a string, removing any HTML tags present. * If HTML, the method returns the selected text, whether it is plaintext or HTML. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ getSelectedDataAsync(coerciontype: Office.CoercionType, callback: (result: AsyncResult) => void): void; /** @@ -13248,7 +13247,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ getSelectedDataAsync(coerciontype: Office.CoercionType, options: Office.AsyncContextOptions, callback: (result: AsyncResult) => void): void; /** @@ -13271,7 +13270,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Message Compose * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * @param userContext Optional. Developers can provide any object they wish to access in the callback function. * This object can be accessed by the asyncResult.asyncContext property in the callback function. */ @@ -13307,7 +13306,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ removeAttachmentAsync(attachmentIndex: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -13378,7 +13377,7 @@ declare namespace Office { * * @param attachmentIndex The identifier of the attachment to remove. The maximum length of the string is 100 characters. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If removing the attachment fails, the asyncResult.error property will contain an error code with the reason for the failure. */ removeAttachmentAsync(attachmentIndex: string, callback: (result: AsyncResult) => void): void; @@ -13406,7 +13405,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -13429,7 +13428,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to removeHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -13476,7 +13475,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ saveAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -13578,7 +13577,7 @@ declare namespace Office { * ErrorsInvalidAttachmentId - The attachment identifier does not exist. * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ saveAsync(callback: (result: AsyncResult) => void): void; /** @@ -13617,7 +13616,7 @@ declare namespace Office { * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (result: AsyncResult) => void): void; /** @@ -13690,7 +13689,7 @@ declare namespace Office { * @param data The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type{@link Office.AsyncResult}. + * typeOffice.AsyncResult. */ setSelectedDataAsync(data: string, callback: (result: AsyncResult) => void): void; } @@ -14046,7 +14045,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -14070,7 +14069,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to addHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -14149,7 +14148,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -14173,7 +14172,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Message Read * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * On success, the initialization data is provided in the asyncResult.value property as a string. * If there is no initialization context, the asyncResult object will contain an Error object with its code property * set to 9020 and its name property set to GenericResponseError. @@ -14406,7 +14405,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Message Read * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * @param userContext Optional. Developers can provide any object they wish to access in the callback function. * This object can be accessed by the asyncResult.asyncContext property in the callback function. */ @@ -14435,7 +14434,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -14458,7 +14457,7 @@ declare namespace Office { * @param handler The function to handle the event. The function must accept a single parameter, which is an object literal. * The type property on the parameter will match the eventType parameter passed to removeHandlerAsync. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * * @beta */ @@ -14530,7 +14529,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * * [Api set: Mailbox 1.1] * @@ -14552,7 +14551,7 @@ declare namespace Office { * The location of the appointment is provided as a string in the asyncResult.value property. * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * * [Api set: Mailbox 1.1] * @@ -14572,7 +14571,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. If setting the location fails, the asyncResult.error property will contain an error code. + * type Office.AsyncResult. If setting the location fails, the asyncResult.error property will contain an error code. * * [Api set: Mailbox 1.1] * @@ -14638,7 +14637,7 @@ declare namespace Office { * * @param location The location of the appointment. The string is limited to 255 characters. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. If setting the location fails, the asyncResult.error property will contain an error code. + * type Office.AsyncResult. If setting the location fails, the asyncResult.error property will contain an error code. * * [Api set: Mailbox 1.1] * @@ -14770,7 +14769,7 @@ declare namespace Office { * The type property on the parameter will match the eventType parameter passed to addHandlerAsync. * @param options Optional. Provides an option for preserving context data of any type, unchanged, for use in a callback. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ addHandlerAsync(eventType: Office.EventType, handler: (type: EventType) => void, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -15028,7 +15027,7 @@ declare namespace Office { * isRest: Determines if the token provided will be used for the Outlook REST APIs or Exchange Web Services. Default value is false. * asyncContext: Any state data that is passed to the asynchronous method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. The token is provided as a string in the asyncResult.value property. + * type Office.AsyncResult. The token is provided as a string in the asyncResult.value property. */ getCallbackTokenAsync(options: Office.AsyncContextOptions & { isRest?: boolean }, callback: (result: AsyncResult) => void): void; /** @@ -15082,7 +15081,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose and read * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. The token is provided as a string in the asyncResult.value property. + * type Office.AsyncResult. The token is provided as a string in the asyncResult.value property. * @param userContext Optional. Any state data that is passed to the asynchronous method. */ getCallbackTokenAsync(callback: (result: AsyncResult) => void, userContext?: any): void; @@ -15103,7 +15102,7 @@ declare namespace Office { * {@link https://msdn.microsoft.com/library/office/fp179828.aspx | authenticate the add-in and user with a third-party system}. * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * The token is provided as a string in the asyncResult.value property. * @param userContext Optional. Any state data that is passed to the asynchronous method.| */ @@ -15155,7 +15154,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose and read * * @param data The EWS request. - * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * The `value` property of the result is the XML of the EWS request provided as a string. * If the result exceeds 1 MB in size, an error message is returned instead. * @param userContext Optional. Any state data that is passed to the asynchronous method. @@ -15269,7 +15268,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * * [Api set: Mailbox 1.3] * @@ -15336,7 +15335,7 @@ declare namespace Office { * @param JSONmessage A JSON object that contains the notification message to be added to the item. * It contains a NotificationMessageDetails object. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * * [Api set: Mailbox 1.3] * @@ -15362,7 +15361,7 @@ declare namespace Office { * * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * The `value` property of the result is an array of NotificationMessageDetails objects. */ getAllAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -15376,7 +15375,7 @@ declare namespace Office { * * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose or read * - * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type {@link Office.AsyncResult}. + * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. * The `value` property of the result is an array of NotificationMessageDetails objects. */ getAllAsync(callback: (result: AsyncResult) => void): void; @@ -15402,7 +15401,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ removeAsync(key: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -15445,7 +15444,7 @@ declare namespace Office { * * @param key The key for the notification message to remove. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ removeAsync(key: string, callback: (result: AsyncResult) => void): void; /** @@ -15474,7 +15473,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ replaceAsync(key: string, JSONmessage: NotificationMessageDetails, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -15529,7 +15528,7 @@ declare namespace Office { * @param JSONmessage A JSON object that contains the new notification message to replace the existing message. * It contains a NotificationMessageDetails object. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ replaceAsync(key: string, JSONmessage: NotificationMessageDetails, callback: (result: AsyncResult) => void): void; } @@ -15601,7 +15600,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. If adding the recipients fails, the asyncResult.error property will contain an error code. + * type Office.AsyncResult. If adding the recipients fails, the asyncResult.error property will contain an error code. */ addAsync(recipients: (string | EmailUser | EmailAddressDetails)[], options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -15674,7 +15673,7 @@ declare namespace Office { * * @param recipients The recipients to add to the recipients list. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. If adding the recipients fails, the asyncResult.error property will contain an error code. + * type Office.AsyncResult. If adding the recipients fails, the asyncResult.error property will contain an error code. */ addAsync(recipients: (string | EmailUser | EmailAddressDetails)[], callback: (result: AsyncResult) => void): void; /** @@ -15696,7 +15695,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * The `value` property of the result is an array of EmailAddressDetails objects. */ getAsync(options: Office.AsyncContextOptions, callback: (result: AsyncResult) => void): void; @@ -15713,7 +15712,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose * * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * The `value` property of the result is an array of EmailAddressDetails objects. */ getAsync(callback: (result: AsyncResult) => void): void; @@ -15751,7 +15750,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If setting the recipients fails the asyncResult.error property will contain a code that indicates any error that occurred * while adding the data. */ @@ -15832,7 +15831,7 @@ declare namespace Office { * * @param recipients The recipients to add to the recipients list. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If setting the recipients fails the asyncResult.error property will contain a code that indicates any error that occurred * while adding the data. */ @@ -15969,7 +15968,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * The `value` property of the result is a Recurrence object. */ getAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -15988,7 +15987,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose or read * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. * The `value` property of the result is a Recurrence object. */ getAsync(callback?: (result: AsyncResult) => void): void; @@ -16016,7 +16015,7 @@ declare namespace Office { * @param options Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. */ setAsync(recurrencePattern: Recurrence, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -16037,7 +16036,7 @@ declare namespace Office { * * @param recurrencePattern A recurrence object. * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. */ setAsync(recurrencePattern: Recurrence, callback?: (result: AsyncResult) => void): void; } @@ -16128,7 +16127,7 @@ declare namespace Office { attachments?: ReplyFormAttachment[]; /** * When the reply display call completes, the function passed in the callback parameter is called with a single parameter, - * asyncResult, which is an {@link Office.AsyncResult} object. + * asyncResult, which is an Office.AsyncResult object. */ callback?: (result: AsyncResult) => void; } @@ -16199,7 +16198,7 @@ declare namespace Office { * {@link https://docs.microsoft.com/outlook/add-ins/#extension-points | Applicable Outlook mode}Compose or read * * @param callback Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. */ saveAsync(callback?: (result: AsyncResult) => void): void; /** @@ -16461,7 +16460,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * The `value` property of the result is the subject of the item. */ getAsync(options: Office.AsyncContextOptions, callback: (result: AsyncResult) => void): void; @@ -16508,7 +16507,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. If setting the subject fails, the asyncResult.error property will contain an error code. + * type Office.AsyncResult. If setting the subject fails, the asyncResult.error property will contain an error code. */ setAsync(subject: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; /** @@ -16566,7 +16565,7 @@ declare namespace Office { * * @param subject The subject of the appointment or message. The string is limited to 255 characters. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. If setting the subject fails, the asyncResult.error property will contain an error code. + * type Office.AsyncResult. If setting the subject fails, the asyncResult.error property will contain an error code. */ setAsync(data: string, callback: (result: AsyncResult) => void): void; @@ -16674,7 +16673,7 @@ declare namespace Office { * @param options An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If setting the date and time fails, the asyncResult.error property will contain an error code. */ setAsync(dateTime: Date, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult) => void): void; @@ -16739,7 +16738,7 @@ declare namespace Office { * * @param dateTime A date-time object in Coordinated Universal Time (UTC). * @param callback When the method completes, the function passed in the callback parameter is called with a single parameter of - * type {@link Office.AsyncResult}. + * type Office.AsyncResult. * If setting the date and time fails, the asyncResult.error property will contain an error code. */ setAsync(dateTime: Date, callback: (result: AsyncResult) => void): void; diff --git a/types/p-cancelable/index.d.ts b/types/p-cancelable/index.d.ts index 4f26cd17ca..775400bca8 100644 --- a/types/p-cancelable/index.d.ts +++ b/types/p-cancelable/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for p-cancelable 0.3 +// Type definitions for p-cancelable 0.5 // Project: https://github.com/sindresorhus/p-cancelable#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,20 +11,21 @@ interface PCancelableConstructor extends PromiseConstructor { readonly prototype: PCancelable.PCancelable; readonly CancelError: PCancelable.CancelErrorConstructor; fn(wrapper: (onCancel: (fn?: () => void) => void, input: T) => PromiseLike): (input: T) => PCancelable.PCancelable; - new(executor: (onCancel: (fn?: () => void) => void, resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): PCancelable.PCancelable; + new(executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void, onCancel: (fn?: () => void) => void) => void): PCancelable.PCancelable; } declare namespace PCancelable { interface PCancelable extends Promise { - readonly canceled: boolean; - cancel(): void; + readonly isCanceled: boolean; + cancel(reason?: string): void; } interface CancelErrorConstructor extends ErrorConstructor { - new (): CancelError; + new (reason?: string): CancelError; } interface CancelError extends Error { readonly name: 'CancelError'; + readonly isCanceled: boolean; } } diff --git a/types/p-cancelable/p-cancelable-tests.ts b/types/p-cancelable/p-cancelable-tests.ts index ca5f728e18..8bd3790e08 100644 --- a/types/p-cancelable/p-cancelable-tests.ts +++ b/types/p-cancelable/p-cancelable-tests.ts @@ -3,7 +3,7 @@ import PCancelableCtor = require('p-cancelable'); import { EventEmitter } from "events"; -const cancelablePromise: PCancelableCtor.PCancelable<{}> = new PCancelableCtor((onCancel, resolve, reject) => { +const cancelablePromise: PCancelableCtor.PCancelable<{}> = new PCancelableCtor((resolve, reject, onCancel) => { class Worker extends EventEmitter { close() { } @@ -24,7 +24,7 @@ cancelablePromise console.log('Operation finished successfully:', value); }) .catch(reason => { - if (cancelablePromise.canceled) { + if (cancelablePromise.isCanceled) { // Handle the cancelation here console.log('Operation was canceled'); return; @@ -56,7 +56,7 @@ const fn = PCancelableCtor.fn((onCancel: (fn?: () => void) => void, input: strin const promise = fn('input'); let num: number; promise.then(innum => num = innum); -if (!promise.canceled) { +if (!promise.isCanceled) { promise.cancel(); } diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index bbd75e9e61..de820c771f 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -6,6 +6,7 @@ // John Reilly // Alberto Restifo // Behind The Math +// 3af // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -93,6 +94,7 @@ export interface ParseConfig { newline?: string; // default: "\r\n" quoteChar?: string; // default: '"' header?: boolean; // default: false + trimHeaders?: boolean; // default: false dynamicTyping?: boolean; // default: false preview?: number; // default: 0 encoding?: string; // default: "" @@ -109,6 +111,7 @@ export interface ParseConfig { error?(error: ParseError, file?: File): void; // default: undefined chunk?(results: ParseResult, parser: Parser): void; // default: undefined beforeFirstChunk?(chunk: string): string | void; // default: undefined + transform?(value: string, field: string | number): any; // default: undefined } export interface UnparseConfig { @@ -138,6 +141,7 @@ export interface ParseMeta { aborted: boolean; // Whether process was aborted fields: Array; // Array of field names truncated: boolean; // Whether preview consumed all input + cursor: number; } /** diff --git a/types/papaparse/papaparse-tests.ts b/types/papaparse/papaparse-tests.ts index 5edcf9a251..5db22091ca 100644 --- a/types/papaparse/papaparse-tests.ts +++ b/types/papaparse/papaparse-tests.ts @@ -20,6 +20,7 @@ res.errors[0].code; Papa.parse("3,3,3", { delimiter: ';', comments: false, + trimHeaders: false, step: function (results, p) { p.abort(); @@ -30,6 +31,9 @@ Papa.parse("3,3,3", { var file = new File(null, null, null); Papa.parse(file, { + transform: function(value, field) { + + }, complete: function (a, b) { a.meta.fields; b.name; diff --git a/types/pbkdf2/index.d.ts b/types/pbkdf2/index.d.ts new file mode 100644 index 0000000000..80e3678dc6 --- /dev/null +++ b/types/pbkdf2/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for pbkdf2 3.0 +// Project: https://github.com/crypto-browserify/pbkdf2 +// Definitions by: Timon Engelke +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => void): void; +export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => void): void; +export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest?: string): Buffer; diff --git a/types/pbkdf2/pbkdf2-tests.ts b/types/pbkdf2/pbkdf2-tests.ts new file mode 100644 index 0000000000..cf1a30c4bb --- /dev/null +++ b/types/pbkdf2/pbkdf2-tests.ts @@ -0,0 +1,6 @@ +import * as pbkdf2 from "pbkdf2"; + +pbkdf2.pbkdf2("password", "salt", 1000, 32, "sha1", (err, derivedKey) => {}); // $ExpectType void +pbkdf2.pbkdf2("password", "salt", 1000, 32, (err, derivedKey) => {}); // $ExpectType void +pbkdf2.pbkdf2Sync("password", "salt", 1000, 32, "sha1"); // $ExpectType Buffer +pbkdf2.pbkdf2Sync("password", "salt", 1000, 32); // $ExpectType Buffer diff --git a/types/pbkdf2/tsconfig.json b/types/pbkdf2/tsconfig.json new file mode 100644 index 0000000000..955d8232ec --- /dev/null +++ b/types/pbkdf2/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", + "pbkdf2-tests.ts" + ] +} diff --git a/types/pbkdf2/tslint.json b/types/pbkdf2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pbkdf2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pg-large-object/index.d.ts b/types/pg-large-object/index.d.ts index 804b86df1a..64a450d545 100644 --- a/types/pg-large-object/index.d.ts +++ b/types/pg-large-object/index.d.ts @@ -2,14 +2,58 @@ // Project: https://github.com/Joris-van-der-Wel/node-pg-large-object#readme // Definitions by: Mateusz Krupa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// -import { WriteStream } from "fs"; +import stream = require("stream"); +import pg = require("pg"); + +export class LargeObject { + static readonly SEEK_SET: number; + static readonly SEEK_CUR: number; + static readonly SEEK_END: number; + constructor(query: any, oid: number, fd: any); + close(callback: (error: Error) => void): void; + closeAsync(): Promise; + read(length: number, callback: (error: Error, data: Buffer) => void): void; + readAsync(length: number): Promise; + write(buffer: Buffer, callback?: (error: Error) => void): void; + writeAsync(buffer: Buffer): Promise; + seek(position: number, ref: number, callback?: (error: Error, position: number) => void): void; + seekAsync(position: number, ref: number): Promise; + tell(callback: (error: Error, position: number) => void): void; + tellAsync(): Promise; + size(callback: (error: Error, size: number) => void): void; + sizeAsync(): Promise; + truncate(length: number, callback?: (error: Error) => void): void; + truncateAsync(length: number): Promise; + getReadableStream(bufferSize?: number): ReadStream; + getWritableStream(bufferSize?: number): WriteStream; +} + +export interface LargeObjectManagerSettings { + pg?: pg.Client; + pgPromise?: object; // module: pg-promise/Task +} export class LargeObjectManager { - constructor(options: any); - openAndReadableStreamAsync(oid: number, bufferSize: number): Promise<[number, NodeJS.ReadableStream]>; - createAndWritableStreamAsync(bufferSize: number): Promise<[number, WriteStream]>; + static readonly WRITE: number; + static readonly READ: number; + static readonly READWRITE: number; + constructor(options: LargeObjectManagerSettings|object); + open(oid: number, mode: number, callback: (error: Error, result: LargeObject) => void): void; + openAsync(oid: number, mode: number): Promise; + create(callback: (error: Error, oid: number) => void): void; + createAsync(): Promise; + openAndReadableStream(oid: number, bufferSize: number, callback: (error: Error, size: number, stream: ReadStream) => void): void; + openAndReadableStreamAsync(oid: number, bufferSize?: number): Promise<[number, ReadStream]>; + createAndWritableStream(bufferSize?: number, callback?: (error: Error, oid: number, stream: WriteStream) => void): void; + createAndWritableStreamAsync(bufferSize?: number): Promise<[number, WriteStream]>; + unlink(oid: number, callback?: (error: Error) => void): void; unlinkAsync(oid: number): Promise; } + +export class ReadStream extends stream.Readable {} + +export class WriteStream extends stream.Writable {} diff --git a/types/pg-large-object/pg-large-object-tests.ts b/types/pg-large-object/pg-large-object-tests.ts index 050fad80f6..42a939572b 100644 --- a/types/pg-large-object/pg-large-object-tests.ts +++ b/types/pg-large-object/pg-large-object-tests.ts @@ -1,8 +1,56 @@ -import { LargeObjectManager } from 'pg-large-object'; +import { + LargeObject, + LargeObjectManager, + LargeObjectManagerSettings, + ReadStream, + WriteStream +} from "pg-large-object"; +import { Buffer } from "buffer"; +import pg = require("pg"); +const buffer = new Buffer(""); const bufferSize = 16384; +const length = 16384; const oid = 1; -const lom = new LargeObjectManager({}); +const seekSetConst = LargeObject.SEEK_SET; // $ExpectType number +const seekCurConst = LargeObject.SEEK_CUR; // $ExpectType number +const seekEndConst = LargeObject.SEEK_END; // $ExpectType number + +const lo = new LargeObject({}, oid, {}); +lo.close((error: Error) => {}); // $ExpectType void +lo.closeAsync(); // $ExpectType Promise +lo.read(length, (error: Error, data: Buffer) => {}); // $ExpectType void +lo.readAsync(length); // $ExpectType Promise +lo.write(buffer, (error: Error) => {}); // $ExpectType void +lo.writeAsync(buffer); // $ExpectType Promise +lo.seek(0, LargeObject.SEEK_CUR, (error: Error, position: number) => {}); // $ExpectType void +lo.seekAsync(0, LargeObject.SEEK_CUR); // $ExpectType Promise +lo.tell((error: Error, position: number) => {}); // $ExpectType void +lo.tellAsync(); // $ExpectType Promise +lo.size((error: Error, size: number) => {}); // $ExpectType void +lo.sizeAsync(); //// $ExpectType Promise +lo.truncate(length, (error: Error) => {}); // $ExpectType void +lo.truncateAsync(length); // $ExpectType Promise +lo.getReadableStream(bufferSize); // $ExpectType ReadStream +lo.getWritableStream(bufferSize); // $ExpectType WriteStream + +const writeConst = LargeObjectManager.WRITE; // $ExpectType number +const readConst = LargeObjectManager.READ; // $ExpectType number +const readWriteConst = LargeObjectManager.READWRITE; // $ExpectType number +const config: LargeObjectManagerSettings = { + pg: new pg.Client(), + pgPromise: {} +}; + +const lom = new LargeObjectManager(config); +lom.open(oid, LargeObjectManager.READWRITE, (error: Error, result: LargeObject) => {}); // $ExpectType void +lom.openAsync(oid, LargeObjectManager.READWRITE); // $ExpectType Promise +lom.create((error: Error, oid: number) => {}); // $ExpectType void +lom.createAsync(); // $ExpectType Promise +lom.unlink(oid, (error: Error) => {}); // $ExpectType void +lom.unlinkAsync(oid); // $ExpectType Promise +lom.openAndReadableStream(oid, bufferSize, (error: Error, size: number, stream: ReadStream) => {}); // $ExpectType void +lom.openAndReadableStreamAsync(oid, bufferSize); // $ExpectType Promise<[number, ReadStream]> +lom.createAndWritableStream(bufferSize, (error: Error, oid: number, stream: WriteStream) => {}); // $ExpectType void lom.createAndWritableStreamAsync(bufferSize); // $ExpectType Promise<[number, WriteStream]> -lom.openAndReadableStreamAsync(oid, bufferSize); // $ExpectType Promise<[number, ReadableStream]> lom.unlinkAsync(oid); // $ExpectType Promise diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index 7bdf862ea2..fa312dbb0f 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -9,6 +9,7 @@ // Drew Diamantoukos // Sooraj Pudiyadath // Jon Freedman +// Megan Riel-Mehan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -29,7 +30,7 @@ export interface Point { export interface PlotScatterDataPoint { curveNumber: number; - data: ScatterData; + data: PlotData; pointIndex: number; pointNumber: number; x: number; @@ -49,8 +50,17 @@ export interface PlotCoordinate { pointNumber: number; } +export interface SelectionRange { + x: number[]; + y: number[]; +} + +export type PlotSelectedData = Partial; + export interface PlotSelectionEvent { - points: PlotCoordinate[]; + points: PlotScatterDataPoint[]; + range?: SelectionRange; + lassoPoints?: SelectionRange; } export type PlotRestyleEvent = [ @@ -141,10 +151,10 @@ export interface PlotlyHTMLElement extends HTMLElement { on(event: 'plotly_sliderend', callback: (event: SliderEndEvent) => void): void; on(event: 'plotly_sliderstart', callback: (event: SliderStartEvent) => void): void; on(event: 'plotly_event', callback: (data: any) => void): void; - on(event: 'plotly_beforeplot' , callback: (event: BeforePlotEvent) => boolean): void; + on(event: 'plotly_beforeplot', callback: (event: BeforePlotEvent) => boolean): void; on(event: 'plotly_afterexport' | 'plotly_afterplot' | 'plotly_animated' | 'plotly_animationinterrupted' | 'plotly_autosize' | 'plotly_beforeexport' | 'plotly_deselect' | 'plotly_doubleclick' | 'plotly_framework' | 'plotly_redraw' | - 'plotly_transitioning' | 'plotly_transitioninterrupted' , callback: () => void): void; + 'plotly_transitioning' | 'plotly_transitioninterrupted', callback: () => void): void; } export interface ToImgopts { @@ -192,6 +202,14 @@ export interface Layout { separators: string; hidesources: boolean; xaxis: Partial; + xaxis2: Partial; + xaxis3: Partial; + xaxis4: Partial; + xaxis5: Partial; + xaxis6: Partial; + xaxis7: Partial; + xaxis8: Partial; + xaxis9: Partial; yaxis: Partial; yaxis2: Partial; yaxis3: Partial; @@ -418,12 +436,13 @@ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int export type Dash = 'solid' | 'dot' | 'dash' | 'longdash' | 'dashdot' | 'longdashdot'; -export type Data = Partial; +export type Data = Partial; export type Color = string | Array | Array>; - +export type DataTransform = Partial; +export type ScatterData = PlotData; // Bar Scatter -export interface ScatterData { - type: 'bar' | 'pointcloud' | 'scatter' | 'scattergl' | 'scatter3d' |'surface'; +export interface PlotData { + type: 'bar' | 'histogram' | 'pointcloud' | 'scatter' | 'scattergl' | 'scatter3d' | 'surface'; x: Datum[] | Datum[][] | TypedArray; y: Datum[] | Datum[][] | TypedArray; z: Datum[] | Datum[][] | Datum[][][] | TypedArray; @@ -438,7 +457,7 @@ export interface ScatterData { 'line.shape': 'linear' | 'spline' | 'hv' | 'vh' | 'hvh' | 'vhv'; 'line.smoothing': number; 'line.simplify': boolean; - marker: Partial; + marker: Partial; 'marker.symbol': string | string[]; // Drawing.symbolList 'marker.color': Color; 'marker.opacity': number | number[]; @@ -454,15 +473,15 @@ export interface ScatterData { mode: 'lines' | 'markers' | 'text' | 'lines+markers' | 'text+markers' | 'text+lines' | 'text+lines+markers' | 'none'; hoveron: 'points' | 'fills'; hoverinfo: 'all' | 'name' | 'none' | 'skip' | 'text' | - 'x' | 'x+text' | 'x+name' | - 'x+y' | 'x+y+text' | 'x+y+name' | - 'x+y+z' | 'x+y+z+text' | 'x+y+z+name' | - 'y+x' | 'y+x+text' | 'y+x+name' | - 'y+z' | 'y+z+text' | 'y+z+name' | - 'y+x+z' | 'y+x+z+text' | 'y+x+z+name' | - 'z+x' | 'z+x+text' | 'z+x+name' | - 'z+y+x' | 'z+y+x+text' | 'z+y+x+name' | - 'z+x+y' | 'z+x+y+text' | 'z+x+y+name'; + 'x' | 'x+text' | 'x+name' | + 'x+y' | 'x+y+text' | 'x+y+name' | + 'x+y+z' | 'x+y+z+text' | 'x+y+z+name' | + 'y+x' | 'y+x+text' | 'y+x+name' | + 'y+z' | 'y+z+text' | 'y+z+name' | + 'y+x+z' | 'y+x+z+text' | 'y+x+z+name' | + 'z+x' | 'z+x+text' | 'z+x+name' | + 'z+y+x' | 'z+y+x+text' | 'z+y+x+name' | + 'z+x+y' | 'z+x+y+text' | 'z+x+y+name'; hoverlabel: Partial